Home | History | Annotate | Download | only in core
      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/core/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::kEmbedderBlink, V8TestInterfaceConstructor2::domTemplate, V8TestInterfaceConstructor2::refObject, V8TestInterfaceConstructor2::derefObject, V8TestInterfaceConstructor2::createPersistentHandle, 0, 0, 0, V8TestInterfaceConstructor2::installConditionallyEnabledMethods, V8TestInterfaceConstructor2::installConditionallyEnabledProperties, 0, WrapperTypeInfo::WrapperTypeObjectPrototype, WrapperTypeInfo::ObjectClassId, WrapperTypeInfo::Independent, WrapperTypeInfo::RefCountedObject };
     27 
     28 // This static member must be declared by DEFINE_WRAPPERTYPEINFO in TestInterfaceConstructor2.h.
     29 // For details, see the comment of DEFINE_WRAPPERTYPEINFO in
     30 // bindings/core/v8/ScriptWrappable.h.
     31 const WrapperTypeInfo& TestInterfaceConstructor2::s_wrapperTypeInfo = V8TestInterfaceConstructor2::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(stringArg);
     44     v8::Handle<v8::Object> wrapper = info.Holder();
     45     impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate());
     46     v8SetReturnValue(info, wrapper);
     47 }
     48 
     49 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
     50 {
     51     Dictionary dictionaryArg;
     52     {
     53         if (!isUndefinedOrNull(info[0]) && !info[0]->IsObject()) {
     54             V8ThrowException::throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstructor2", "parameter 1 ('dictionaryArg') is not an object."), info.GetIsolate());
     55             return;
     56         }
     57         dictionaryArg = Dictionary(info[0], info.GetIsolate());
     58     }
     59     RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(dictionaryArg);
     60     v8::Handle<v8::Object> wrapper = info.Holder();
     61     impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate());
     62     v8SetReturnValue(info, wrapper);
     63 }
     64 
     65 static void constructor3(const v8::FunctionCallbackInfo<v8::Value>& info)
     66 {
     67     ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor2", info.Holder(), info.GetIsolate());
     68     Vector<Vector<String> > stringSequenceSequenceArg;
     69     {
     70         TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(stringSequenceSequenceArg, toImplArray<Vector<String>>(info[0], 1, info.GetIsolate(), exceptionState), exceptionState);
     71     }
     72     RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(stringSequenceSequenceArg);
     73     v8::Handle<v8::Object> wrapper = info.Holder();
     74     impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate());
     75     v8SetReturnValue(info, wrapper);
     76 }
     77 
     78 static void constructor4(const v8::FunctionCallbackInfo<v8::Value>& info)
     79 {
     80     ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor2", info.Holder(), info.GetIsolate());
     81     TestInterfaceEmpty* testInterfaceEmptyArg;
     82     int longArg;
     83     V8StringResource<> defaultUndefinedOptionalStringArg;
     84     V8StringResource<> defaultNullStringOptionalStringArg;
     85     Dictionary defaultUndefinedOptionalDictionaryArg;
     86     V8StringResource<> optionalStringArg;
     87     {
     88         testInterfaceEmptyArg = V8TestInterfaceEmpty::toImplWithTypeCheck(info.GetIsolate(), info[0]);
     89         TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(longArg, toInt32(info[1], exceptionState), exceptionState);
     90         TOSTRING_VOID_INTERNAL(defaultUndefinedOptionalStringArg, info[2]);
     91         if (!info[3]->IsUndefined()) {
     92             TOSTRING_VOID_INTERNAL(defaultNullStringOptionalStringArg, info[3]);
     93         } else {
     94             defaultNullStringOptionalStringArg = nullptr;
     95         }
     96         if (!isUndefinedOrNull(info[4]) && !info[4]->IsObject()) {
     97             exceptionState.throwTypeError("parameter 5 ('defaultUndefinedOptionalDictionaryArg') is not an object.");
     98             exceptionState.throwIfNeeded();
     99             return;
    100         }
    101         defaultUndefinedOptionalDictionaryArg = Dictionary(info[4], info.GetIsolate());
    102         if (UNLIKELY(info.Length() <= 5)) {
    103             RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg);
    104             v8::Handle<v8::Object> wrapper = info.Holder();
    105             impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate());
    106             v8SetReturnValue(info, wrapper);
    107             return;
    108         }
    109         TOSTRING_VOID_INTERNAL(optionalStringArg, info[5]);
    110     }
    111     RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg, optionalStringArg);
    112     v8::Handle<v8::Object> wrapper = info.Holder();
    113     impl->associateWithWrapper(&V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, info.GetIsolate());
    114     v8SetReturnValue(info, wrapper);
    115 }
    116 
    117 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
    118 {
    119     ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor2", info.Holder(), info.GetIsolate());
    120     switch (std::min(6, info.Length())) {
    121     case 1:
    122         if (info[0]->IsArray()) {
    123             TestInterfaceConstructor2V8Internal::constructor3(info);
    124             return;
    125         }
    126         if (info[0]->IsObject()) {
    127             TestInterfaceConstructor2V8Internal::constructor2(info);
    128             return;
    129         }
    130         if (true) {
    131             TestInterfaceConstructor2V8Internal::constructor1(info);
    132             return;
    133         }
    134         break;
    135     case 2:
    136         if (true) {
    137             TestInterfaceConstructor2V8Internal::constructor4(info);
    138             return;
    139         }
    140         break;
    141     case 3:
    142         if (true) {
    143             TestInterfaceConstructor2V8Internal::constructor4(info);
    144             return;
    145         }
    146         break;
    147     case 4:
    148         if (true) {
    149             TestInterfaceConstructor2V8Internal::constructor4(info);
    150             return;
    151         }
    152         break;
    153     case 5:
    154         if (true) {
    155             TestInterfaceConstructor2V8Internal::constructor4(info);
    156             return;
    157         }
    158         break;
    159     case 6:
    160         if (true) {
    161             TestInterfaceConstructor2V8Internal::constructor4(info);
    162             return;
    163         }
    164         break;
    165     default:
    166         exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
    167         exceptionState.throwIfNeeded();
    168         return;
    169     }
    170     exceptionState.throwTypeError("No matching constructor signature.");
    171     exceptionState.throwIfNeeded();
    172 }
    173 
    174 } // namespace TestInterfaceConstructor2V8Internal
    175 
    176 void V8TestInterfaceConstructor2::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
    177 {
    178     TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "DOMConstructor");
    179     if (!info.IsConstructCall()) {
    180         V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceConstructor2"), info.GetIsolate());
    181         return;
    182     }
    183 
    184     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
    185         v8SetReturnValue(info, info.Holder());
    186         return;
    187     }
    188 
    189     TestInterfaceConstructor2V8Internal::constructor(info);
    190 }
    191 
    192 static void installV8TestInterfaceConstructor2Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
    193 {
    194     functionTemplate->ReadOnlyPrototype();
    195 
    196     v8::Local<v8::Signature> defaultSignature;
    197     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceConstructor2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceConstructor2::internalFieldCount,
    198         0, 0,
    199         0, 0,
    200         0, 0,
    201         isolate);
    202     functionTemplate->SetCallHandler(V8TestInterfaceConstructor2::constructorCallback);
    203     functionTemplate->SetLength(1);
    204     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
    205     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
    206 
    207     // Custom toString template
    208     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
    209 }
    210 
    211 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor2::domTemplate(v8::Isolate* isolate)
    212 {
    213     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceConstructor2Template);
    214 }
    215 
    216 bool V8TestInterfaceConstructor2::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
    217 {
    218     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
    219 }
    220 
    221 v8::Handle<v8::Object> V8TestInterfaceConstructor2::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
    222 {
    223     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
    224 }
    225 
    226 TestInterfaceConstructor2* V8TestInterfaceConstructor2::toImplWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
    227 {
    228     return hasInstance(value, isolate) ? blink::toScriptWrappableBase(v8::Handle<v8::Object>::Cast(value))->toImpl<TestInterfaceConstructor2>() : 0;
    229 }
    230 
    231 
    232 void V8TestInterfaceConstructor2::refObject(ScriptWrappableBase* internalPointer)
    233 {
    234     internalPointer->toImpl<TestInterfaceConstructor2>()->ref();
    235 }
    236 
    237 void V8TestInterfaceConstructor2::derefObject(ScriptWrappableBase* internalPointer)
    238 {
    239     internalPointer->toImpl<TestInterfaceConstructor2>()->deref();
    240 }
    241 
    242 WrapperPersistentNode* V8TestInterfaceConstructor2::createPersistentHandle(ScriptWrappableBase* internalPointer)
    243 {
    244     ASSERT_NOT_REACHED();
    245     return 0;
    246 }
    247 
    248 template<>
    249 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    250 {
    251     return toV8(impl, creationContext, isolate);
    252 }
    253 
    254 } // namespace blink
    255