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

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

Issue 338893004: Extend ScalarValueString handling to include constructors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Tweaks Created 6 years, 6 months 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY!
6 6
7 #include "config.h" 7 #include "config.h"
8 #include "V8TestInterfaceConstructor3.h" 8 #include "V8TestInterfaceConstructor4.h"
9 9
10 #include "bindings/tests/v8/V8TestInterfaceConstructor4.h"
10 #include "bindings/v8/ExceptionState.h" 11 #include "bindings/v8/ExceptionState.h"
11 #include "bindings/v8/V8DOMConfiguration.h" 12 #include "bindings/v8/V8DOMConfiguration.h"
12 #include "bindings/v8/V8HiddenValue.h" 13 #include "bindings/v8/V8HiddenValue.h"
13 #include "bindings/v8/V8ObjectConstructor.h" 14 #include "bindings/v8/V8ObjectConstructor.h"
14 #include "core/dom/ContextFeatures.h" 15 #include "core/dom/ContextFeatures.h"
15 #include "core/dom/Document.h" 16 #include "core/dom/Document.h"
16 #include "core/frame/LocalDOMWindow.h" 17 #include "core/frame/LocalDOMWindow.h"
17 #include "platform/RuntimeEnabledFeatures.h" 18 #include "platform/RuntimeEnabledFeatures.h"
18 #include "platform/TraceEvent.h" 19 #include "platform/TraceEvent.h"
19 #include "wtf/GetPtr.h" 20 #include "wtf/GetPtr.h"
20 #include "wtf/RefPtr.h" 21 #include "wtf/RefPtr.h"
21 22
22 namespace WebCore { 23 namespace WebCore {
23 24
24 static void initializeScriptWrappableForInterface(TestInterfaceConstructor3* obj ect) 25 static void initializeScriptWrappableForInterface(TestInterfaceConstructor4* obj ect)
25 { 26 {
26 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 27 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
27 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceConstru ctor3::wrapperTypeInfo); 28 ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceConstru ctor4::wrapperTypeInfo);
28 else 29 else
29 ASSERT_NOT_REACHED(); 30 ASSERT_NOT_REACHED();
30 } 31 }
31 32
32 } // namespace WebCore 33 } // namespace WebCore
33 34
34 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceConstruc tor3* object) 35 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceConstruc tor4* object)
35 { 36 {
36 WebCore::initializeScriptWrappableForInterface(object); 37 WebCore::initializeScriptWrappableForInterface(object);
37 } 38 }
38 39
39 namespace WebCore { 40 namespace WebCore {
40 const WrapperTypeInfo V8TestInterfaceConstructor3::wrapperTypeInfo = { gin::kEmb edderBlink, V8TestInterfaceConstructor3::domTemplate, V8TestInterfaceConstructor 3::derefObject, 0, 0, 0, V8TestInterfaceConstructor3::installPerContextEnabledMe thods, 0, WrapperTypeObjectPrototype, RefCountedObject }; 41 const WrapperTypeInfo V8TestInterfaceConstructor4::wrapperTypeInfo = { gin::kEmb edderBlink, V8TestInterfaceConstructor4::domTemplate, V8TestInterfaceConstructor 4::derefObject, 0, 0, 0, V8TestInterfaceConstructor4::installPerContextEnabledMe thods, 0, WrapperTypeObjectPrototype, RefCountedObject };
41 42
42 namespace TestInterfaceConstructor3V8Internal { 43 namespace TestInterfaceConstructor4V8Internal {
43 44
44 template <typename T> void V8_USE(T) { } 45 template <typename T> void V8_USE(T) { }
45 46
47 static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info)
48 {
49 v8::Isolate* isolate = info.GetIsolate();
50 TestInterfaceConstructor4* testInterface4Arg;
51 {
52 v8::TryCatch block;
53 V8RethrowTryCatchScope rethrow(block);
54 TONATIVE_VOID_INTERNAL(testInterface4Arg, V8TestInterfaceConstructor4::t oNativeWithTypeCheck(info.GetIsolate(), info[0]));
55 }
56 RefPtr<TestInterfaceConstructor4> impl = TestInterfaceConstructor4::create(t estInterface4Arg);
57
58 v8::Handle<v8::Object> wrapper = info.Holder();
59 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor4>(impl.r elease(), &V8TestInterfaceConstructor4::wrapperTypeInfo, wrapper, isolate, Wrapp erConfiguration::Independent);
60 v8SetReturnValue(info, wrapper);
61 }
62
63 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
64 {
65 v8::Isolate* isolate = info.GetIsolate();
66 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte rfaceConstructor4", info.Holder(), isolate);
67 V8StringResource<> scalarValueStringArg;
68 {
69 v8::TryCatch block;
70 V8RethrowTryCatchScope rethrow(block);
71 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(scalarValueStringArg, toScalarValu eString(info[0], exceptionState), exceptionState);
72 }
73 RefPtr<TestInterfaceConstructor4> impl = TestInterfaceConstructor4::create(s calarValueStringArg);
74
75 v8::Handle<v8::Object> wrapper = info.Holder();
76 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor4>(impl.r elease(), &V8TestInterfaceConstructor4::wrapperTypeInfo, wrapper, isolate, Wrapp erConfiguration::Independent);
77 v8SetReturnValue(info, wrapper);
78 }
79
46 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 80 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
47 { 81 {
48 v8::Isolate* isolate = info.GetIsolate(); 82 v8::Isolate* isolate = info.GetIsolate();
49 if (UNLIKELY(info.Length() < 1)) { 83 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte rfaceConstructor4", info.Holder(), isolate);
50 throwMinimumArityTypeErrorForConstructor("TestInterfaceConstructor3", 1, info.Length(), info.GetIsolate()); 84 switch (std::min(1, info.Length())) {
85 case 1:
86 if (V8TestInterfaceConstructor4::hasInstance(info[0], isolate)) {
87 TestInterfaceConstructor4V8Internal::constructor1(info);
88 return;
89 }
90 if (true) {
91 TestInterfaceConstructor4V8Internal::constructor2(info);
92 return;
93 }
94 break;
95 default:
96 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i nfo.Length()));
97 exceptionState.throwIfNeeded();
51 return; 98 return;
52 } 99 }
53 V8StringResource<> stringArg; 100 exceptionState.throwTypeError("No matching constructor signature.");
54 { 101 exceptionState.throwIfNeeded();
55 TOSTRING_VOID_INTERNAL(stringArg, info[0]);
56 }
57 RefPtr<TestInterfaceConstructor3> impl = TestInterfaceConstructor3::create(s tringArg);
58
59 v8::Handle<v8::Object> wrapper = info.Holder();
60 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor3>(impl.r elease(), &V8TestInterfaceConstructor3::wrapperTypeInfo, wrapper, isolate, Wrapp erConfiguration::Independent);
61 v8SetReturnValue(info, wrapper);
62 } 102 }
63 103
64 } // namespace TestInterfaceConstructor3V8Internal 104 } // namespace TestInterfaceConstructor4V8Internal
65 105
66 void V8TestInterfaceConstructor3::constructorCallback(const v8::FunctionCallback Info<v8::Value>& info) 106 void V8TestInterfaceConstructor4::constructorCallback(const v8::FunctionCallback Info<v8::Value>& info)
67 { 107 {
68 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); 108 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
69 if (!info.IsConstructCall()) { 109 if (!info.IsConstructCall()) {
70 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Test InterfaceConstructor3"), info.GetIsolate()); 110 throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Test InterfaceConstructor4"), info.GetIsolate());
71 return; 111 return;
72 } 112 }
73 113
74 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis tingObject) { 114 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis tingObject) {
75 v8SetReturnValue(info, info.Holder()); 115 v8SetReturnValue(info, info.Holder());
76 return; 116 return;
77 } 117 }
78 118
79 TestInterfaceConstructor3V8Internal::constructor(info); 119 TestInterfaceConstructor4V8Internal::constructor(info);
80 } 120 }
81 121
82 static void configureV8TestInterfaceConstructor3Template(v8::Handle<v8::Function Template> functionTemplate, v8::Isolate* isolate) 122 static void configureV8TestInterfaceConstructor4Template(v8::Handle<v8::Function Template> functionTemplate, v8::Isolate* isolate)
83 { 123 {
84 functionTemplate->ReadOnlyPrototype(); 124 functionTemplate->ReadOnlyPrototype();
85 125
86 v8::Local<v8::Signature> defaultSignature; 126 v8::Local<v8::Signature> defaultSignature;
87 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfaceConstructor3", v8::Local<v8::FunctionTemplate>(), V8TestInter faceConstructor3::internalFieldCount, 127 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl ate, "TestInterfaceConstructor4", v8::Local<v8::FunctionTemplate>(), V8TestInter faceConstructor4::internalFieldCount,
88 0, 0, 128 0, 0,
89 0, 0, 129 0, 0,
90 0, 0, 130 0, 0,
91 isolate); 131 isolate);
92 functionTemplate->SetCallHandler(V8TestInterfaceConstructor3::constructorCal lback); 132 functionTemplate->SetCallHandler(V8TestInterfaceConstructor4::constructorCal lback);
93 functionTemplate->SetLength(1); 133 functionTemplate->SetLength(1);
94 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTempla te->InstanceTemplate(); 134 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTempla te->InstanceTemplate();
95 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTempl ate->PrototypeTemplate(); 135 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTempl ate->PrototypeTemplate();
96 136
97 // Custom toString template 137 // Custom toString template
98 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :from(isolate)->toStringTemplate()); 138 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData: :from(isolate)->toStringTemplate());
99 } 139 }
100 140
101 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor3::domTemplate(v8::Is olate* isolate) 141 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor4::domTemplate(v8::Is olate* isolate)
102 { 142 {
103 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), configureV8TestInterfaceConstructor3Template); 143 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI nfo*>(&wrapperTypeInfo), configureV8TestInterfaceConstructor4Template);
104 } 144 }
105 145
106 bool V8TestInterfaceConstructor3::hasInstance(v8::Handle<v8::Value> v8Value, v8: :Isolate* isolate) 146 bool V8TestInterfaceConstructor4::hasInstance(v8::Handle<v8::Value> v8Value, v8: :Isolate* isolate)
107 { 147 {
108 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e); 148 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu e);
109 } 149 }
110 150
111 v8::Handle<v8::Object> V8TestInterfaceConstructor3::findInstanceInPrototypeChain (v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) 151 v8::Handle<v8::Object> V8TestInterfaceConstructor4::findInstanceInPrototypeChain (v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
112 { 152 {
113 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe rTypeInfo, v8Value); 153 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe rTypeInfo, v8Value);
114 } 154 }
115 155
116 TestInterfaceConstructor3* V8TestInterfaceConstructor3::toNativeWithTypeCheck(v8 ::Isolate* isolate, v8::Handle<v8::Value> value) 156 TestInterfaceConstructor4* V8TestInterfaceConstructor4::toNativeWithTypeCheck(v8 ::Isolate* isolate, v8::Handle<v8::Value> value)
117 { 157 {
118 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0; 158 return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Obje ct>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
119 } 159 }
120 160
121 v8::Handle<v8::Object> wrap(TestInterfaceConstructor3* impl, v8::Handle<v8::Obje ct> creationContext, v8::Isolate* isolate) 161 v8::Handle<v8::Object> wrap(TestInterfaceConstructor4* impl, v8::Handle<v8::Obje ct> creationContext, v8::Isolate* isolate)
122 { 162 {
123 ASSERT(impl); 163 ASSERT(impl);
124 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor3>(impl, iso late)); 164 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor4>(impl, iso late));
125 return V8TestInterfaceConstructor3::createWrapper(impl, creationContext, iso late); 165 return V8TestInterfaceConstructor4::createWrapper(impl, creationContext, iso late);
126 } 166 }
127 167
128 v8::Handle<v8::Object> V8TestInterfaceConstructor3::createWrapper(PassRefPtr<Tes tInterfaceConstructor3> impl, v8::Handle<v8::Object> creationContext, v8::Isolat e* isolate) 168 v8::Handle<v8::Object> V8TestInterfaceConstructor4::createWrapper(PassRefPtr<Tes tInterfaceConstructor4> impl, v8::Handle<v8::Object> creationContext, v8::Isolat e* isolate)
129 { 169 {
130 ASSERT(impl); 170 ASSERT(impl);
131 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor3>(impl.get( ), isolate)); 171 ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor4>(impl.get( ), isolate));
132 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 172 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
133 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get ())->typeInfo(); 173 const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get ())->typeInfo();
134 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have 174 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
135 // the same object de-ref functions, though, so use that as the basis of the check. 175 // the same object de-ref functions, though, so use that as the basis of the check.
136 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 176 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
137 } 177 }
138 178
139 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); 179 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
140 if (UNLIKELY(wrapper.IsEmpty())) 180 if (UNLIKELY(wrapper.IsEmpty()))
141 return wrapper; 181 return wrapper;
142 182
143 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 183 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
144 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor3>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); 184 V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor4>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
145 return wrapper; 185 return wrapper;
146 } 186 }
147 187
148 void V8TestInterfaceConstructor3::derefObject(void* object) 188 void V8TestInterfaceConstructor4::derefObject(void* object)
149 { 189 {
150 fromInternalPointer(object)->deref(); 190 fromInternalPointer(object)->deref();
151 } 191 }
152 192
153 template<> 193 template<>
154 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor3* impl, v8::Handle<v 8::Object> creationContext, v8::Isolate* isolate) 194 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor4* impl, v8::Handle<v 8::Object> creationContext, v8::Isolate* isolate)
155 { 195 {
156 return toV8(impl, creationContext, isolate); 196 return toV8(impl, creationContext, isolate);
157 } 197 }
158 198
159 } // namespace WebCore 199 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestInterfaceConstructor4.h ('k') | Source/bindings/tests/results/V8TestObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698