1 /* 2 This file is part of the Blink open source project. 3 This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY! 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public License 16 along with this library; see the file COPYING.LIB. If not, write to 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 Boston, MA 02111-1307, USA. 19 */ 20 21 #include "config.h" 22 #include "V8TestMediaQueryListListener.h" 23 24 #include "RuntimeEnabledFeatures.h" 25 #include "bindings/v8/ExceptionState.h" 26 #include "bindings/v8/ScriptController.h" 27 #include "bindings/v8/V8Binding.h" 28 #include "bindings/v8/V8DOMConfiguration.h" 29 #include "bindings/v8/V8DOMWrapper.h" 30 #include "core/css/MediaQueryListListener.h" 31 #include "core/dom/ContextFeatures.h" 32 #include "core/dom/Document.h" 33 #include "core/page/Frame.h" 34 #include "core/platform/chromium/TraceEvent.h" 35 #include "wtf/UnusedParam.h" 36 37 namespace WebCore { 38 39 static void initializeScriptWrappableForInterface(TestMediaQueryListListener* object) 40 { 41 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 42 ScriptWrappable::setTypeInfoInObject(object, &V8TestMediaQueryListListener::info); 43 else 44 ASSERT_NOT_REACHED(); 45 } 46 47 } // namespace WebCore 48 49 // In ScriptWrappable::init, the use of a local function declaration has an issue on Windows: 50 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function 51 // in the global namespace. 52 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c) 53 void webCoreInitializeScriptWrappableForInterface(WebCore::TestMediaQueryListListener* object) 54 { 55 WebCore::initializeScriptWrappableForInterface(object); 56 } 57 58 namespace WebCore { 59 WrapperTypeInfo V8TestMediaQueryListListener::info = { V8TestMediaQueryListListener::GetTemplate, V8TestMediaQueryListListener::derefObject, 0, 0, 0, V8TestMediaQueryListListener::installPerContextPrototypeProperties, 0, WrapperTypeObjectPrototype }; 60 61 namespace TestMediaQueryListListenerV8Internal { 62 63 template <typename T> void V8_USE(T) { } 64 65 static void methodMethod(const v8::FunctionCallbackInfo<v8::Value>& args) 66 { 67 if (args.Length() < 1) { 68 throwNotEnoughArgumentsError(args.GetIsolate()); 69 return; 70 } 71 TestMediaQueryListListener* imp = V8TestMediaQueryListListener::toNative(args.Holder()); 72 V8TRYCATCH_VOID(RefPtr<MediaQueryListListener>, listener, MediaQueryListListener::create(args[0])); 73 imp->method(listener); 74 75 return; 76 } 77 78 static void methodMethodCallback(const v8::FunctionCallbackInfo<v8::Value>& args) 79 { 80 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 81 TestMediaQueryListListenerV8Internal::methodMethod(args); 82 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 83 } 84 85 } // namespace TestMediaQueryListListenerV8Internal 86 87 static const V8DOMConfiguration::BatchedMethod V8TestMediaQueryListListenerMethods[] = { 88 {"method", TestMediaQueryListListenerV8Internal::methodMethodCallback, 0, 1}, 89 }; 90 91 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestMediaQueryListListenerTemplate(v8::Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType currentWorldType) 92 { 93 desc->ReadOnlyPrototype(); 94 95 v8::Local<v8::Signature> defaultSignature; 96 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestMediaQueryListListener", v8::Local<v8::FunctionTemplate>(), V8TestMediaQueryListListener::internalFieldCount, 97 0, 0, 98 V8TestMediaQueryListListenerMethods, WTF_ARRAY_LENGTH(V8TestMediaQueryListListenerMethods), isolate, currentWorldType); 99 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. 100 v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); 101 v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); 102 UNUSED_PARAM(instance); // In some cases, it will not be used. 103 UNUSED_PARAM(proto); // In some cases, it will not be used. 104 105 // Custom toString template 106 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->toStringTemplate()); 107 return desc; 108 } 109 110 v8::Handle<v8::FunctionTemplate> V8TestMediaQueryListListener::GetTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType) 111 { 112 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 113 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&info); 114 if (result != data->templateMap(currentWorldType).end()) 115 return result->value.newLocal(isolate); 116 117 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 118 v8::HandleScope handleScope(isolate); 119 v8::Handle<v8::FunctionTemplate> templ = 120 ConfigureV8TestMediaQueryListListenerTemplate(data->rawTemplate(&info, currentWorldType), isolate, currentWorldType); 121 data->templateMap(currentWorldType).add(&info, UnsafePersistent<v8::FunctionTemplate>(isolate, templ)); 122 return handleScope.Close(templ); 123 } 124 125 bool V8TestMediaQueryListListener::HasInstance(v8::Handle<v8::Value> value, v8::Isolate* isolate, WrapperWorldType currentWorldType) 126 { 127 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, currentWorldType); 128 } 129 130 bool V8TestMediaQueryListListener::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isolate* isolate) 131 { 132 return V8PerIsolateData::from(isolate)->hasInstance(&info, value, MainWorld) 133 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, IsolatedWorld) 134 || V8PerIsolateData::from(isolate)->hasInstance(&info, value, WorkerWorld); 135 } 136 137 138 v8::Handle<v8::Object> V8TestMediaQueryListListener::createWrapper(PassRefPtr<TestMediaQueryListListener> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 139 { 140 ASSERT(impl.get()); 141 ASSERT(DOMDataStore::getWrapper<V8TestMediaQueryListListener>(impl.get(), isolate).IsEmpty()); 142 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 143 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get()); 144 // Might be a XXXConstructor::info instead of an XXX::info. These will both have 145 // the same object de-ref functions, though, so use that as the basis of the check. 146 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == info.derefObjectFunction); 147 } 148 149 150 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &info, toInternalPointer(impl.get()), isolate); 151 if (UNLIKELY(wrapper.IsEmpty())) 152 return wrapper; 153 installPerContextProperties(wrapper, impl.get(), isolate); 154 V8DOMWrapper::associateObjectWithWrapper<V8TestMediaQueryListListener>(impl, &info, wrapper, isolate, WrapperConfiguration::Independent); 155 return wrapper; 156 } 157 void V8TestMediaQueryListListener::derefObject(void* object) 158 { 159 fromInternalPointer(object)->deref(); 160 } 161 162 } // namespace WebCore 163