006b6a4efed1a2217d84a859c890d52910f726eb
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestInterfaceEventTarget.cpp
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 "V8TestInterfaceEventTarget.h"
9
10 #include "bindings/core/v8/ExceptionState.h"
11 #include "bindings/core/v8/V8DOMConfiguration.h"
12 #include "bindings/core/v8/V8HiddenValue.h"
13 #include "bindings/core/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 blink {
23
24 static void initializeScriptWrappableForInterface(TestInterfaceEventTarget* object)
25 {
26     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
27         ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceEventTarget::wrapperTypeInfo);
28     else
29         ASSERT_NOT_REACHED();
30 }
31
32 } // namespace blink
33
34 void webCoreInitializeScriptWrappableForInterface(blink::TestInterfaceEventTarget* object)
35 {
36     blink::initializeScriptWrappableForInterface(object);
37 }
38
39 namespace blink {
40 const WrapperTypeInfo V8TestInterfaceEventTarget::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTarget::domTemplate, V8TestInterfaceEventTarget::derefObject, 0, V8TestInterfaceEventTarget::toEventTarget, 0, V8TestInterfaceEventTarget::installConditionallyEnabledMethods, &V8EventTarget::wrapperTypeInfo, WrapperTypeObjectPrototype, WillBeGarbageCollectedObject };
41
42 namespace TestInterfaceEventTargetV8Internal {
43
44 template <typename T> void V8_USE(T) { }
45
46 } // namespace TestInterfaceEventTargetV8Internal
47
48 const WrapperTypeInfo V8TestInterfaceEventTargetConstructor::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEventTargetConstructor::domTemplate, V8TestInterfaceEventTarget::derefObject, 0, V8TestInterfaceEventTarget::toEventTarget, 0, V8TestInterfaceEventTarget::installConditionallyEnabledMethods, 0, WrapperTypeObjectPrototype, WillBeGarbageCollectedObject };
49
50 static void V8TestInterfaceEventTargetConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
51 {
52     if (!info.IsConstructCall()) {
53         V8ThrowException::throwTypeError(ExceptionMessages::constructorNotCallableAsFunction("Name"), info.GetIsolate());
54         return;
55     }
56
57     if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::WrapExistingObject) {
58         v8SetReturnValue(info, info.Holder());
59         return;
60     }
61     Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
62     RefPtrWillBeRawPtr<TestInterfaceEventTarget> impl = TestInterfaceEventTarget::createForJSConstructor(document);
63     v8::Handle<v8::Object> wrapper = info.Holder();
64     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventTarget>(impl.release(), &V8TestInterfaceEventTargetConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Independent);
65     v8SetReturnValue(info, wrapper);
66 }
67
68 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTargetConstructor::domTemplate(v8::Isolate* isolate)
69 {
70     static int domTemplateKey; // This address is used for a key to look up the dom template.
71     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
72     v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(&domTemplateKey);
73     if (!result.IsEmpty())
74         return result;
75
76     TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "BuildDOMTemplate");
77     result = v8::FunctionTemplate::New(isolate, V8TestInterfaceEventTargetConstructorCallback);
78     v8::Local<v8::ObjectTemplate> instanceTemplate = result->InstanceTemplate();
79     instanceTemplate->SetInternalFieldCount(V8TestInterfaceEventTarget::internalFieldCount);
80     result->SetClassName(v8AtomicString(isolate, "TestInterfaceEventTarget"));
81     result->Inherit(V8TestInterfaceEventTarget::domTemplate(isolate));
82     data->setDOMTemplate(&domTemplateKey, result);
83     return result;
84 }
85
86 static void installV8TestInterfaceEventTargetTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
87 {
88     functionTemplate->ReadOnlyPrototype();
89
90     v8::Local<v8::Signature> defaultSignature;
91     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceEventTarget", V8EventTarget::domTemplate(isolate), V8TestInterfaceEventTarget::internalFieldCount,
92         0, 0,
93         0, 0,
94         0, 0,
95         isolate);
96     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
97     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
98
99     // Custom toString template
100     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
101 }
102
103 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEventTarget::domTemplate(v8::Isolate* isolate)
104 {
105     return V8DOMConfiguration::domClassTemplate(isolate, const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), installV8TestInterfaceEventTargetTemplate);
106 }
107
108 bool V8TestInterfaceEventTarget::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
109 {
110     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
111 }
112
113 v8::Handle<v8::Object> V8TestInterfaceEventTarget::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
114 {
115     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
116 }
117
118 TestInterfaceEventTarget* V8TestInterfaceEventTarget::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
119 {
120     return hasInstance(value, isolate) ? fromInternalPointer(blink::toInternalPointer(v8::Handle<v8::Object>::Cast(value))) : 0;
121 }
122
123 EventTarget* V8TestInterfaceEventTarget::toEventTarget(v8::Handle<v8::Object> object)
124 {
125     return toNative(object);
126 }
127
128 v8::Handle<v8::Object> wrap(TestInterfaceEventTarget* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
129 {
130     ASSERT(impl);
131     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceEventTarget>(impl, isolate));
132     return V8TestInterfaceEventTarget::createWrapper(impl, creationContext, isolate);
133 }
134
135 v8::Handle<v8::Object> V8TestInterfaceEventTarget::createWrapper(PassRefPtrWillBeRawPtr<TestInterfaceEventTarget> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
136 {
137     ASSERT(impl);
138     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceEventTarget>(impl.get(), isolate));
139     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
140         const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
141         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
142         // the same object de-ref functions, though, so use that as the basis of the check.
143         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
144     }
145
146     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
147     if (UNLIKELY(wrapper.IsEmpty()))
148         return wrapper;
149
150     installConditionallyEnabledProperties(wrapper, isolate);
151     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEventTarget>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
152     return wrapper;
153 }
154
155 void V8TestInterfaceEventTarget::derefObject(ScriptWrappableBase* internalPointer)
156 {
157 #if !ENABLE(OILPAN)
158     fromInternalPointer(internalPointer)->deref();
159 #endif // !ENABLE(OILPAN)
160 }
161
162 template<>
163 v8::Handle<v8::Value> toV8NoInline(TestInterfaceEventTarget* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
164 {
165     return toV8(impl, creationContext, isolate);
166 }
167
168 } // namespace blink