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 "V8TestInterfaceConstructor3.h"
      9 
     10 #include "bindings/v8/ExceptionState.h"
     11 #include "bindings/v8/V8DOMConfiguration.h"
     12 #include "bindings/v8/V8HiddenValue.h"
     13 #include "bindings/v8/V8ObjectConstructor.h"
     14 #include "core/dom/ContextFeatures.h"
     15 #include "core/dom/Document.h"
     16 #include "core/frame/LocalDOMWindow.h"
     17 #include "platform/RuntimeEnabledFeatures.h"
     18 #include "platform/TraceEvent.h"
     19 #include "wtf/GetPtr.h"
     20 #include "wtf/RefPtr.h"
     21 
     22 namespace WebCore {
     23 
     24 static void initializeScriptWrappableForInterface(TestInterfaceConstructor3* object)
     25 {
     26     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
     27         ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceConstructor3::wrapperTypeInfo);
     28     else
     29         ASSERT_NOT_REACHED();
     30 }
     31 
     32 } // namespace WebCore
     33 
     34 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceConstructor3* object)
     35 {
     36     WebCore::initializeScriptWrappableForInterface(object);
     37 }
     38 
     39 namespace WebCore {
     40 const WrapperTypeInfo V8TestInterfaceConstructor3::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceConstructor3::domTemplate, V8TestInterfaceConstructor3::derefObject, 0, 0, 0, V8TestInterfaceConstructor3::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
     41 
     42 namespace TestInterfaceConstructor3V8Internal {
     43 
     44 template <typename T> void V8_USE(T) { }
     45 
     46 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
     47 {
     48     v8::Isolate* isolate = info.GetIsolate();
     49     if (UNLIKELY(info.Length() < 1)) {
     50         throwMinimumArityTypeErrorForConstructor("TestInterfaceConstructor3", 1, info.Length(), info.GetIsolate());
     51         return;
     52     }
     53     V8StringResource<> stringArg;
     54     {
     55         TOSTRING_VOID_INTERNAL(stringArg, info[0]);
     56     }
     57     RefPtr<TestInterfaceConstructor3> impl = TestInterfaceConstructor3::create(stringArg);
     58 
     59     v8::Handle<v8::Object> wrapper = info.Holder();
     60     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor3>(impl.release(), &V8TestInterfaceConstructor3::wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
     61     v8SetReturnValue(info, wrapper);
     62 }
     63 
     64 } // namespace TestInterfaceConstructor3V8Internal
     65 
     66 void V8TestInterfaceConstructor3::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
     67 {
     68     TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
     69     if (!info.IsConstructCall()) {
     70         throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("TestInterfaceConstructor3"), info.GetIsolate());
     71         return;
     72     }
     73 
     74     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
     75         v8SetReturnValue(info, info.Holder());
     76         return;
     77     }
     78 
     79     TestInterfaceConstructor3V8Internal::constructor(info);
     80 }
     81 
     82 static void configureV8TestInterfaceConstructor3Template(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
     83 {
     84     functionTemplate->ReadOnlyPrototype();
     85 
     86     v8::Local<v8::Signature> defaultSignature;
     87     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceConstructor3", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceConstructor3::internalFieldCount,
     88         0, 0,
     89         0, 0,
     90         0, 0,
     91         isolate);
     92     functionTemplate->SetCallHandler(V8TestInterfaceConstructor3::constructorCallback);
     93     functionTemplate->SetLength(1);
     94     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
     95     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
     96 
     97     // Custom toString template
     98     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
     99 }
    100 
    101 v8::Handle<v8::FunctionTemplate> V8TestInterfaceConstructor3::domTemplate(v8::Isolate* isolate)
    102 {
    103     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), configureV8TestInterfaceConstructor3Template);
    104 }
    105 
    106 bool V8TestInterfaceConstructor3::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
    107 {
    108     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
    109 }
    110 
    111 v8::Handle<v8::Object> V8TestInterfaceConstructor3::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
    112 {
    113     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
    114 }
    115 
    116 TestInterfaceConstructor3* V8TestInterfaceConstructor3::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
    117 {
    118     return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
    119 }
    120 
    121 v8::Handle<v8::Object> wrap(TestInterfaceConstructor3* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    122 {
    123     ASSERT(impl);
    124     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor3>(impl, isolate));
    125     return V8TestInterfaceConstructor3::createWrapper(impl, creationContext, isolate);
    126 }
    127 
    128 v8::Handle<v8::Object> V8TestInterfaceConstructor3::createWrapper(PassRefPtr<TestInterfaceConstructor3> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    129 {
    130     ASSERT(impl);
    131     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceConstructor3>(impl.get(), isolate));
    132     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
    133         const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
    134         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
    135         // 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);
    137     }
    138 
    139     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
    140     if (UNLIKELY(wrapper.IsEmpty()))
    141         return wrapper;
    142 
    143     installPerContextEnabledProperties(wrapper, impl.get(), isolate);
    144     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceConstructor3>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
    145     return wrapper;
    146 }
    147 
    148 void V8TestInterfaceConstructor3::derefObject(void* object)
    149 {
    150     fromInternalPointer(object)->deref();
    151 }
    152 
    153 template<>
    154 v8::Handle<v8::Value> toV8NoInline(TestInterfaceConstructor3* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
    155 {
    156     return toV8(impl, creationContext, isolate);
    157 }
    158 
    159 } // namespace WebCore
    160