Home | History | Annotate | Download | only in results
      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/tests/v8/V8TestInterfaceEmpty.h"
     11 #include "bindings/v8/Dictionary.h"
     12 #include "bindings/v8/ExceptionState.h"
     13 #include "bindings/v8/V8DOMConfiguration.h"
     14 #include "bindings/v8/V8HiddenValue.h"
     15 #include "bindings/v8/V8ObjectConstructor.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 WebCore {
     25 
     26 static void initializeScriptWrappableForInterface(TestInterfaceConstructor2* object)
     27 {
     28     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
     29         ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceConstructor2::wrapperTypeInfo);
     30     else
     31         ASSERT_NOT_REACHED();
     32 }
     33 
     34 } // namespace WebCore
     35 
     36 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceConstructor2* object)
     37 {
     38     WebCore::initializeScriptWrappableForInterface(object);
     39 }
     40 
     41 namespace WebCore {
     42 const WrapperTypeInfo V8TestInterfaceConstructor2::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructor2::domTemplate, V8TestInterfaceConstructor2::derefObject, 0, 0, 0, V8TestInterfaceConstructor2::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
     43 
     44 namespace TestInterfaceConstructor2V8Internal {
     45 
     46 template <typename T> void V8_USE(T) { }
     47 
     48 static void constructor1(const v8::FunctionCallbackInfo<v8::Value>& info)
     49 {
     50     v8::Isolate* isolate = info.GetIsolate();
     51     V8StringResource<> stringArg;
     52     {
     53         TOSTRING_VOID_INTERNAL(stringArg, info[0]);
     54     }
     55     RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(stringArg);
     56 
     57     v8::Handle<v8::Object> wrapper = info.Holder();
     58     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
     59     v8SetReturnValue(info, wrapper);
     60 }
     61 
     62 static void constructor2(const v8::FunctionCallbackInfo<v8::Value>& info)
     63 {
     64     v8::Isolate* isolate = info.GetIsolate();
     65     Dictionary dictionaryArg;
     66     {
     67         v8::TryCatch block;
     68         V8RethrowTryCatchScope rethrow(block);
     69         TONATIVE_VOID_INTERNAL(dictionaryArg, Dictionary(info[0], info.GetIsolate()));
     70         if (!dictionaryArg.isUndefinedOrNull() && !dictionaryArg.isObject()) {
     71             throwTypeError(ExceptionMessages::failedToConstruct("TestInterfaceConstructor2", "parameter 1 ('dictionaryArg') is not an object."), info.GetIsolate());
     72             return;
     73         }
     74     }
     75     RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(dictionaryArg);
     76 
     77     v8::Handle<v8::Object> wrapper = info.Holder();
     78     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
     79     v8SetReturnValue(info, wrapper);
     80 }
     81 
     82 static void constructor3(const v8::FunctionCallbackInfo<v8::Value>& info)
     83 {
     84     v8::Isolate* isolate = info.GetIsolate();
     85     ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor2", info.Holder(), isolate);
     86     TestInterfaceEmpty* testInterfaceEmptyArg;
     87     int longArg;
     88     V8StringResource<> defaultUndefinedOptionalStringArg;
     89     V8StringResource<> defaultNullStringOptionalStringArg;
     90     Dictionary defaultUndefinedOptionalDictionaryArg;
     91     V8StringResource<> optionalStringArg;
     92     {
     93         v8::TryCatch block;
     94         V8RethrowTryCatchScope rethrow(block);
     95         TONATIVE_VOID_INTERNAL(testInterfaceEmptyArg, V8TestInterfaceEmpty::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
     96         TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(longArg, toInt32(info[1], exceptionState), exceptionState);
     97         TOSTRING_VOID_INTERNAL(defaultUndefinedOptionalStringArg, info[2]);
     98         TOSTRING_VOID_INTERNAL(defaultNullStringOptionalStringArg, argumentOrNull(info, 3));
     99         TONATIVE_VOID_INTERNAL(defaultUndefinedOptionalDictionaryArg, Dictionary(info[4], info.GetIsolate()));
    100         if (!defaultUndefinedOptionalDictionaryArg.isUndefinedOrNull() && !defaultUndefinedOptionalDictionaryArg.isObject()) {
    101             exceptionState.throwTypeError("parameter 5 ('defaultUndefinedOptionalDictionaryArg') is not an object.");
    102             exceptionState.throwIfNeeded();
    103             return;
    104         }
    105         if (UNLIKELY(info.Length() <= 5)) {
    106             RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg);
    107             v8::Handle<v8::Object> wrapper = info.Holder();
    108             V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
    109             v8SetReturnValue(info, wrapper);
    110             return;
    111         }
    112         TOSTRING_VOID_INTERNAL(optionalStringArg, info[5]);
    113     }
    114     RefPtr<TestInterfaceConstructor2> impl = TestInterfaceConstructor2::create(testInterfaceEmptyArg, longArg, defaultUndefinedOptionalStringArg, defaultNullStringOptionalStringArg, defaultUndefinedOptionalDictionaryArg, optionalStringArg);
    115 
    116     v8::Handle<v8::Object> wrapper = info.Holder();
    117     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl.release(), &V8TestInterfaceConstructor2::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
    118     v8SetReturnValue(info, wrapper);
    119 }
    120 
    121 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
    122 {
    123     v8::Isolate* isolate = info.GetIsolate();
    124     ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor2", info.Holder(), isolate);
    125     switch (std::min(6, info.Length())) {
    126     case 1:
    127         if (info[0]->IsObject()) {
    128             TestInterfaceConstructor2V8Internal::constructor2(info);
    129             return;
    130         }
    131         if (true) {
    132             TestInterfaceConstructor2V8Internal::constructor1(info);
    133             return;
    134         }
    135         break;
    136     case 2:
    137         if (true) {
    138             TestInterfaceConstructor2V8Internal::constructor3(info);
    139             return;
    140         }
    141         break;
    142     case 3:
    143         if (true) {
    144             TestInterfaceConstructor2V8Internal::constructor3(info);
    145             return;
    146         }
    147         break;
    148     case 4:
    149         if (true) {
    150             TestInterfaceConstructor2V8Internal::constructor3(info);
    151             return;
    152         }
    153         break;
    154     case 5:
    155         if (true) {
    156             TestInterfaceConstructor2V8Internal::constructor3(info);
    157             return;
    158         }
    159         break;
    160     case 6:
    161         if (true) {
    162             TestInterfaceConstructor2V8Internal::constructor3(info);
    163             return;
    164         }
    165         break;
    166     default:
    167         exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
    168         exceptionState.throwIfNeeded();
    169         return;
    170     }
    171     exceptionState.throwTypeError("No matching constructor signature.");
    172     exceptionState.throwIfNeeded();
    173 }
    174 
    175 } // namespace TestInterfaceConstructor2V8Internal
    176 
    177 void V8TestInterfaceConstructor2::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
    178 {
    179     TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
    180     if (!info.IsConstructCall()) {
    181         throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceConstructor2"), info.GetIsolate());
    182         return;
    183     }
    184 
    185     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
    186         v8SetReturnValue(info, info.Holder());
    187         return;
    188     }
    189 
    190     TestInterfaceConstructor2V8Internal::constructor(info);
    191 }
    192 
    193 static void configureV8TestInterfaceConstructor2Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
    194 {
    195     functionTemplate->ReadOnlyPrototype();
    196 
    197     v8::Local<v8::Signature> defaultSignature;
    198     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceConstructor2", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceConstructor2::internalFieldCount,
    199         0, 0,
    200         0, 0,
    201         0, 0,
    202         isolate);
    203     functionTemplate->SetCallHandler(V8TestInterfaceConstructor2::constructorCallback);
    204     functionTemplate->SetLength(1);
    205     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
    206     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
    207 
    208     // Custom toString template
    209     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
    210 }
    211 
    212 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor2::domTemplate(v8::Isolate* isolate)
    213 {
    214     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), configureV8TestInterfaceConstructor2Template);
    215 }
    216 
    217 bool V8TestInterfaceConstructor2::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
    218 {
    219     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
    220 }
    221 
    222 v8::Handle<v8::Object> V8TestInterfaceConstructor2::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
    223 {
    224     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
    225 }
    226 
    227 TestInterfaceConstructor2* V8TestInterfaceConstructor2::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
    228 {
    229     return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
    230 }
    231 
    232 v8::Handle<v8::Object> wrap(TestInterfaceConstructor2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    233 {
    234     ASSERT(impl);
    235     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor2>(impl, isolate));
    236     return V8TestInterfaceConstructor2::createWrapper(impl, creationContext, isolate);
    237 }
    238 
    239 v8::Handle<v8::Object> V8TestInterfaceConstructor2::createWrapper(PassRefPtr<TestInterfaceConstructor2> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    240 {
    241     ASSERT(impl);
    242     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor2>(impl.get(), isolate));
    243     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
    244         const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
    245         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
    246         // the same object de-ref functions, though, so use that as the basis of the check.
    247         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
    248     }
    249 
    250     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
    251     if (UNLIKELY(wrapper.IsEmpty()))
    252         return wrapper;
    253 
    254     installPerContextEnabledProperties(wrapper, impl.get(), isolate);
    255     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor2>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
    256     return wrapper;
    257 }
    258 
    259 void V8TestInterfaceConstructor2::derefObject(void* object)
    260 {
    261     fromInternalPointer(object)->deref();
    262 }
    263 
    264 template<>
    265 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor2* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    266 {
    267     return toV8(impl, creationContext, isolate);
    268 }
    269 
    270 } // namespace WebCore
    271