| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! | |
| 6 | |
| 7 #include "config.h" | |
| 8 #include "V8TestInterfaceConstructor2.h" | |
| 9 | |
| 10 #include "bindings/core/v8/Dictionary.h" | |
| 11 #include "bindings/core/v8/ExceptionState.h" | |
| 12 #include "bindings/core/v8/V8DOMConfiguration.h" | |
| 13 #include "bindings/core/v8/V8HiddenValue.h" | |
| 14 #include "bindings/core/v8/V8ObjectConstructor.h" | |
| 15 #include "bindings/tests/v8/V8TestInterfaceEmpty.h" | |
| 16 #include "core/dom/ContextFeatures.h" | |
| 17 #include "core/dom/Document.h" | |
| 18 #include "core/frame/LocalDOMWindow.h" | |
| 19 #include "platform/RuntimeEnabledFeatures.h" | |
| 20 #include "platform/TraceEvent.h" | |
| 21 #include "wtf/GetPtr.h" | |
| 22 #include "wtf/RefPtr.h" | |
| 23 | |
| 24 namespace blink { | |
| 25 | |
| 26 const WrapperTypeInfo V8TestInterfaceConstructor2::wrapperTypeInfo = { gin::kEmb
edderBlink, V8TestInterfaceConstructor2::domTemplate, V8TestInterfaceConstructor
2::refObject, V8TestInterfaceConstructor2::derefObject, V8TestInterfaceConstruct
or2::createPersistentHandle, 0, 0, 0, V8TestInterfaceConstructor2::installCondit
ionallyEnabledMethods, V8TestInterfaceConstructor2::installConditionallyEnabledP
roperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::Obje
ctClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::RefCountedObject }; | |
| 27 | |
| 28 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfac
eConstructor2.h. | |
| 29 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in | |
| 30 // bindings/core/v8/ScriptWrappable.h. | |
| 31 const WrapperTypeInfo& TestInterfaceConstructor2::s_wrapperTypeInfo = V8TestInte
rfaceConstructor2::wrapperTypeInfo; | |
| 32 | |
| 33 namespace TestInterfaceConstructor2V8Internal { | |
| 34 | |
| 35 template <typename T> void V8_USE(T) { } | |
| 36 | |
| 37 static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 38 { | |
| 39 V8StringResource<> stringArg; | |
| 40 { | |
| 41 TOSTRING_VOID_INTERNAL(stringArg, info[0]); | |
| 42 } | |
| 43 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(s
tringArg); | |
| 44 v8::Handle<v8::Object> wrapper = info.Holder(); | |
| 45 impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wr
apper, info.GetIsolate()); | |
| 46 v8SetReturnValue(info, wrapper); | |
| 47 } | |
| 48 | |
| 49 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 50 { | |
| 51 Dictionary dictionaryArg; | |
| 52 { | |
| 53 v8::TryCatch block; | |
| 54 V8RethrowTryCatchScope rethrow(block); | |
| 55 TONATIVE_VOID_INTERNAL(dictionaryArg, Dictionary(info[0], info.GetIsolat
e())); | |
| 56 if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) { | |
| 57 V8ThrowException::throwTypeError(ExceptionMessages::failedToConstruc
t("TestInterfaceConstructor2", "parameter 1 ('dictionaryArg') is not an object."
), info.GetIsolate()); | |
| 58 return; | |
| 59 } | |
| 60 } | |
| 61 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(d
ictionaryArg); | |
| 62 v8::Handle<v8::Object> wrapper = info.Holder(); | |
| 63 impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wr
apper, info.GetIsolate()); | |
| 64 v8SetReturnValue(info, wrapper); | |
| 65 } | |
| 66 | |
| 67 static void constructor3(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 68 { | |
| 69 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor2", info.Holder(), info.GetIsolate()); | |
| 70 TestInterfaceEmpty* testInterfaceEmptyArg; | |
| 71 int longArg; | |
| 72 V8StringResource<> defaultUndefinedOptionalStringArg; | |
| 73 V8StringResource<> defaultNullStringOptionalStringArg; | |
| 74 Dictionary defaultUndefinedOptionalDictionaryArg; | |
| 75 V8StringResource<> optionalStringArg; | |
| 76 { | |
| 77 v8::TryCatch block; | |
| 78 V8RethrowTryCatchScope rethrow(block); | |
| 79 TONATIVE_VOID_INTERNAL(testInterfaceEmptyArg, V8TestInterfaceEmpty::toIm
plWithTypeCheck(info.GetIsolate(), info[0])); | |
| 80 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(longArg, toInt32(info[1], exceptio
nState), exceptionState); | |
| 81 TOSTRING_VOID_INTERNAL(defaultUndefinedOptionalStringArg, info[2]); | |
| 82 if (!info[3]->IsUndefined()) { | |
| 83 TOSTRING_VOID_INTERNAL(defaultNullStringOptionalStringArg, info[3]); | |
| 84 } else { | |
| 85 defaultNullStringOptionalStringArg = nullptr; | |
| 86 } | |
| 87 TONATIVE_VOID_INTERNAL(defaultUndefinedOptionalDictionaryArg, Dictionary
(info[4], info.GetIsolate())); | |
| 88 if (!defaultUndefinedOptionalDictionaryArg.isUndefinedOrNull() && !defau
ltUndefinedOptionalDictionaryArg.isObject()) { | |
| 89 exceptionState.throwTypeError("parameter 5 ('defaultUndefinedOptiona
lDictionaryArg') is not an object."); | |
| 90 exceptionState.throwIfNeeded(); | |
| 91 return; | |
| 92 } | |
| 93 if (UNLIKELY(info.Length() <= 5)) { | |
| 94 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::
create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaul
tNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg); | |
| 95 v8::Handle<v8::Object> wrapper = info.Holder(); | |
| 96 impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperType
Info, wrapper, info.GetIsolate()); | |
| 97 v8SetReturnValue(info, wrapper); | |
| 98 return; | |
| 99 } | |
| 100 TOSTRING_VOID_INTERNAL(optionalStringArg, info[5]); | |
| 101 } | |
| 102 RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(t
estInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStr
ingOptionalStringArg, defaultUndefinedOptionalDictionaryArg, optionalStringArg); | |
| 103 v8::Handle<v8::Object> wrapper = info.Holder(); | |
| 104 impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wr
apper, info.GetIsolate()); | |
| 105 v8SetReturnValue(info, wrapper); | |
| 106 } | |
| 107 | |
| 108 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | |
| 109 { | |
| 110 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInte
rfaceConstructor2", info.Holder(), info.GetIsolate()); | |
| 111 switch (std::min(6, info.Length())) { | |
| 112 case 1: | |
| 113 if (info[0]->IsObject()) { | |
| 114 TestInterfaceConstructor2V8Internal::constructor2(info); | |
| 115 return; | |
| 116 } | |
| 117 if (true) { | |
| 118 TestInterfaceConstructor2V8Internal::constructor1(info); | |
| 119 return; | |
| 120 } | |
| 121 break; | |
| 122 case 2: | |
| 123 if (true) { | |
| 124 TestInterfaceConstructor2V8Internal::constructor3(info); | |
| 125 return; | |
| 126 } | |
| 127 break; | |
| 128 case 3: | |
| 129 if (true) { | |
| 130 TestInterfaceConstructor2V8Internal::constructor3(info); | |
| 131 return; | |
| 132 } | |
| 133 break; | |
| 134 case 4: | |
| 135 if (true) { | |
| 136 TestInterfaceConstructor2V8Internal::constructor3(info); | |
| 137 return; | |
| 138 } | |
| 139 break; | |
| 140 case 5: | |
| 141 if (true) { | |
| 142 TestInterfaceConstructor2V8Internal::constructor3(info); | |
| 143 return; | |
| 144 } | |
| 145 break; | |
| 146 case 6: | |
| 147 if (true) { | |
| 148 TestInterfaceConstructor2V8Internal::constructor3(info); | |
| 149 return; | |
| 150 } | |
| 151 break; | |
| 152 default: | |
| 153 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | |
| 154 exceptionState.throwIfNeeded(); | |
| 155 return; | |
| 156 } | |
| 157 exceptionState.throwTypeError("No matching constructor signature."); | |
| 158 exceptionState.throwIfNeeded(); | |
| 159 } | |
| 160 | |
| 161 } // namespace TestInterfaceConstructor2V8Internal | |
| 162 | |
| 163 void V8TestInterfaceConstructor2::constructorCallback(const v8::FunctionCallback
Info<v8::Value>& info) | |
| 164 { | |
| 165 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor"); | |
| 166 if (!info.IsConstructCall()) { | |
| 167 V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallab
leAsFunction("TestInterfaceConstructor2"), info.GetIsolate()); | |
| 168 return; | |
| 169 } | |
| 170 | |
| 171 if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExis
tingObject) { | |
| 172 v8SetReturnValue(info, info.Holder()); | |
| 173 return; | |
| 174 } | |
| 175 | |
| 176 TestInterfaceConstructor2V8Internal::constructor(info); | |
| 177 } | |
| 178 | |
| 179 static void installV8TestInterfaceConstructor2Template(v8::Handle<v8::FunctionTe
mplate> functionTemplate, v8::Isolate* isolate) | |
| 180 { | |
| 181 functionTemplate->ReadOnlyPrototype(); | |
| 182 | |
| 183 v8::Local<v8::Signature> defaultSignature; | |
| 184 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTempl
ate, "TestInterfaceConstructor2", v8::Local<v8::FunctionTemplate>(), V8TestInter
faceConstructor2::internalFieldCount, | |
| 185 0, 0, | |
| 186 0, 0, | |
| 187 0, 0, | |
| 188 isolate); | |
| 189 functionTemplate->SetCallHandler(V8TestInterfaceConstructor2::constructorCal
lback); | |
| 190 functionTemplate->SetLength(1); | |
| 191 v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTempla
te->InstanceTemplate(); | |
| 192 v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTempl
ate->PrototypeTemplate(); | |
| 193 | |
| 194 // Custom toString template | |
| 195 functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData:
:from(isolate)->toStringTemplate()); | |
| 196 } | |
| 197 | |
| 198 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor2::domTemplate(v8::Is
olate* isolate) | |
| 199 { | |
| 200 return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeI
nfo*>(&wrapperTypeInfo), installV8TestInterfaceConstructor2Template); | |
| 201 } | |
| 202 | |
| 203 bool V8TestInterfaceConstructor2::hasInstance(v8::Handle<v8::Value> v8Value, v8:
:Isolate* isolate) | |
| 204 { | |
| 205 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Valu
e); | |
| 206 } | |
| 207 | |
| 208 v8::Handle<v8::Object> V8TestInterfaceConstructor2::findInstanceInPrototypeChain
(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate) | |
| 209 { | |
| 210 return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrappe
rTypeInfo, v8Value); | |
| 211 } | |
| 212 | |
| 213 TestInterfaceConstructor2* V8TestInterfaceConstructor2::toImplWithTypeCheck(v8::
Isolate* isolate, v8::Handle<v8::Value> value) | |
| 214 { | |
| 215 return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle
<v8::Object>::Cast(value))->toImpl<TestInterfaceConstructor2>() : 0; | |
| 216 } | |
| 217 | |
| 218 | |
| 219 void V8TestInterfaceConstructor2::refObject(ScriptWrappableBase* internalPointer
) | |
| 220 { | |
| 221 internalPointer->toImpl<TestInterfaceConstructor2>()->ref(); | |
| 222 } | |
| 223 | |
| 224 void V8TestInterfaceConstructor2::derefObject(ScriptWrappableBase* internalPoint
er) | |
| 225 { | |
| 226 internalPointer->toImpl<TestInterfaceConstructor2>()->deref(); | |
| 227 } | |
| 228 | |
| 229 WrapperPersistentNode* V8TestInterfaceConstructor2::createPersistentHandle(Scrip
tWrappableBase* internalPointer) | |
| 230 { | |
| 231 ASSERT_NOT_REACHED(); | |
| 232 return 0; | |
| 233 } | |
| 234 | |
| 235 template<> | |
| 236 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor2* impl, v8::Handle<v
8::Object> creationContext, v8::Isolate* isolate) | |
| 237 { | |
| 238 return toV8(impl, creationContext, isolate); | |
| 239 } | |
| 240 | |
| 241 } // namespace blink | |
| OLD | NEW |