Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(60)

Side by Side Diff: Source/bindings/tests/results/V8TestInterfaceConstructor3.cpp

Issue 112303003: IDL compiler: [Constructor] overloading (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Formatting Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY! 31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
32 32
33 #include "config.h" 33 #include "config.h"
34 #include "V8TestInterfacePython2.h" 34 #include "V8TestInterfaceConstructor3.h"
35 35
36 #include "RuntimeEnabledFeatures.h" 36 #include "RuntimeEnabledFeatures.h"
37 #include "V8Interface1.h"
38 #include "V8Interface2.h"
39 #include "bindings/v8/ExceptionState.h" 37 #include "bindings/v8/ExceptionState.h"
40 #include "bindings/v8/V8DOMConfiguration.h" 38 #include "bindings/v8/V8DOMConfiguration.h"
39 #include "bindings/v8/V8ObjectConstructor.h"
41 #include "core/dom/ContextFeatures.h" 40 #include "core/dom/ContextFeatures.h"
42 #include "core/dom/Document.h" 41 #include "core/dom/Document.h"
43 #include "platform/TraceEvent.h" 42 #include "platform/TraceEvent.h"
44 43
45 namespace WebCore { 44 namespace WebCore {
46 45
47 static void initializeScriptWrappableForInterface(TestInterfacePython2* object) 46 static void initializeScriptWrappableForInterface(TestInterfaceConstructor3* obj ect)
48 { 47 {
49 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 48 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
50 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfacePython2::wr apperTypeInfo); 49 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterfaceConstructor 3::wrapperTypeInfo);
51 else 50 else
52 ASSERT_NOT_REACHED(); 51 ASSERT_NOT_REACHED();
53 } 52 }
54 53
55 } // namespace WebCore 54 } // namespace WebCore
56 55
57 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows: 56 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows:
58 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function 57 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
59 // in the global namespace. 58 // in the global namespace.
60 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c) 59 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c)
61 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfacePython2* object) 60 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceConstruc tor3* object)
62 { 61 {
63 WebCore::initializeScriptWrappableForInterface(object); 62 WebCore::initializeScriptWrappableForInterface(object);
64 } 63 }
65 64
66 namespace WebCore { 65 namespace WebCore {
67 const WrapperTypeInfo V8TestInterfacePython2::wrapperTypeInfo = { gin::kEmbedder Blink, V8TestInterfacePython2::domTemplate, V8TestInterfacePython2::derefObject, 0, 0, V8TestInterfacePython2::visitDOMWrapper, V8TestInterfacePython2::installP erContextEnabledMethods, 0, WrapperTypeObjectPrototype }; 66 const WrapperTypeInfo V8TestInterfaceConstructor3::wrapperTypeInfo = { gin::kEmb edderBlink, V8TestInterfaceConstructor3::domTemplate, V8TestInterfaceConstructor 3::derefObject, 0, 0, 0, V8TestInterfaceConstructor3::installPerContextEnabledMe thods, 0, WrapperTypeObjectPrototype };
68 67
69 namespace TestInterfacePython2V8Internal { 68 namespace TestInterfaceConstructor3V8Internal {
70 69
71 template <typename T> void V8_USE(T) { } 70 template <typename T> void V8_USE(T) { }
72 71
73 } // namespace TestInterfacePython2V8Internal 72 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
73 {
74 if (UNLIKELY(info.Length() < 1)) {
75 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestIn terfaceConstructor3", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate());
76 return;
77 }
78 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringArg, info[0]) ;
79 RefPtr<TestInterfaceConstructor3> impl = TestInterfaceConstructor3::create(s tringArg);
80 v8::Handle<v8::Object> wrapper = info.Holder();
74 81
75 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestInterfacePython2Template( v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, Wrapper WorldType currentWorldType) 82 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor3>(impl.r elease(), &V8TestInterfaceConstructor3::wrapperTypeInfo, wrapper, info.GetIsolat e(), WrapperConfiguration::Dependent);
83 v8SetReturnValue(info, wrapper);
84 }
85
86 } // namespace TestInterfaceConstructor3V8Internal
87
88 void V8TestInterfaceConstructor3::constructorCallback(const v8::FunctionCallback Info<v8::Value>& info)
89 {
90 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
91 if (!info.IsConstructCall()) {
92 throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstr uctor3", "Please use the 'new' operator, this DOM object constructor cannot be c alled as a function."), info.GetIsolate());
93 return;
94 }
95
96 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
97 v8SetReturnValue(info, info.Holder());
98 return;
99 }
100
101 TestInterfaceConstructor3V8Internal::constructor(info);
102 }
103
104 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestInterfaceConstructor3Temp late(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, Wr apperWorldType currentWorldType)
76 { 105 {
77 functionTemplate->ReadOnlyPrototype(); 106 functionTemplate->ReadOnlyPrototype();
78 107
79 v8::Local<v8::Signature> defaultSignature; 108 v8::Local<v8::Signature> defaultSignature;
80 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfacePython2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceP ython2::internalFieldCount, 109 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfaceConstructor3", v8::Local<v8::FunctionTemplate>(), V8TestInter faceConstructor3::internalFieldCount,
81 0, 0, 110 0, 0,
82 0, 0, 111 0, 0,
83 0, 0, 112 0, 0,
84 isolate, currentWorldType); 113 isolate, currentWorldType);
114 functionTemplate->SetCallHandler(V8TestInterfaceConstructor3::constructorCal lback);
115 functionTemplate->SetLength(1);
85 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate(); 116 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate();
86 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate(); 117 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate();
87 118
88 // Custom toString template 119 // Custom toString template
89 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); 120 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate());
90 return functionTemplate; 121 return functionTemplate;
91 } 122 }
92 123
93 v8::Handle<v8::FunctionTemplate> V8TestInterfacePython2::domTemplate(v8::Isolate * isolate, WrapperWorldType currentWorldType) 124 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor3::domTemplate(v8::Is olate* isolate, WrapperWorldType currentWorldType)
94 { 125 {
95 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 126 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
96 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo); 127 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo);
97 if (result != data->templateMap(currentWorldType).end()) 128 if (result != data->templateMap(currentWorldType).end())
98 return result->value.newLocal(isolate); 129 return result->value.newLocal(isolate);
99 130
100 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 131 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
101 v8::EscapableHandleScope handleScope(isolate); 132 v8::EscapableHandleScope handleScope(isolate);
102 v8::Local<v8::FunctionTemplate> templ = 133 v8::Local<v8::FunctionTemplate> templ =
103 ConfigureV8TestInterfacePython2Template(data->rawDOMTemplate(&wrapperTyp eInfo, currentWorldType), isolate, currentWorldType); 134 ConfigureV8TestInterfaceConstructor3Template(data->rawDOMTemplate(&wrapp erTypeInfo, currentWorldType), isolate, currentWorldType);
104 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ)); 135 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
105 return handleScope.Escape(templ); 136 return handleScope.Escape(templ);
106 } 137 }
107 138
108 bool V8TestInterfacePython2::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isol ate* isolate, WrapperWorldType currentWorldType) 139 bool V8TestInterfaceConstructor3::hasInstance(v8::Handle<v8::Value> jsValue, v8: :Isolate* isolate, WrapperWorldType currentWorldType)
109 { 140 {
110 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType); 141 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType);
111 } 142 }
112 143
113 bool V8TestInterfacePython2::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue , v8::Isolate* isolate) 144 bool V8TestInterfaceConstructor3::hasInstanceInAnyWorld(v8::Handle<v8::Value> js Value, v8::Isolate* isolate)
114 { 145 {
115 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld) 146 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld)
116 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld) 147 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld)
117 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld); 148 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld);
118 } 149 }
119 150
120 v8::Handle<v8::Object> wrap(TestInterfacePython2* impl, v8::Handle<v8::Object> c reationContext, v8::Isolate* isolate) 151 v8::Handle<v8::Object> V8TestInterfaceConstructor3::createWrapper(PassRefPtr<Tes tInterfaceConstructor3> impl, v8::Handle<v8::Object> creationContext, v8::Isolat e* isolate)
121 { 152 {
122 ASSERT(impl); 153 ASSERT(impl);
123 if (impl->isInterface1()) 154 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor3>(impl.get( ), isolate));
124 return wrap(toInterface1(impl), creationContext, isolate);
125 if (impl->isInterface2())
126 return wrap(toInterface2(impl), creationContext, isolate);
127 v8::Handle<v8::Object> wrapper = V8TestInterfacePython2::createWrapper(impl, creationContext, isolate);
128 return wrapper;
129 }
130
131 v8::Handle<v8::Object> V8TestInterfacePython2::createWrapper(PassRefPtr<TestInte rfacePython2> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate )
132 {
133 ASSERT(impl);
134 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfacePython2>(impl.get(), is olate));
135 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 155 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
136 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get()); 156 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
137 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have 157 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
138 // the same object de-ref functions, though, so use that as the basis of the check. 158 // the same object de-ref functions, though, so use that as the basis of the check.
139 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 159 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
140 } 160 }
141 161
142 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); 162 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
143 if (UNLIKELY(wrapper.IsEmpty())) 163 if (UNLIKELY(wrapper.IsEmpty()))
144 return wrapper; 164 return wrapper;
145 165
146 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 166 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
147 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfacePython2>(impl, &wrap perTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent); 167 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor3>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
148 return wrapper; 168 return wrapper;
149 } 169 }
150 170
151 void V8TestInterfacePython2::derefObject(void* object) 171 void V8TestInterfaceConstructor3::derefObject(void* object)
152 { 172 {
153 fromInternalPointer(object)->deref(); 173 fromInternalPointer(object)->deref();
154 } 174 }
155 175
156 template<> 176 template<>
157 v8::Handle<v8::Value> toV8NoInline(TestInterfacePython2* impl, v8::Handle<v8::Ob ject> creationContext, v8::Isolate* isolate) 177 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor3* impl, v8::Handle<v 8::Object> creationContext, v8::Isolate* isolate)
158 { 178 {
159 return toV8(impl, creationContext, isolate); 179 return toV8(impl, creationContext, isolate);
160 } 180 }
161 181
162 } // namespace WebCore 182 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698