Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestInterfaceEmpty.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 "V8TestInterfaceEmpty.h"
9
10 #include "RuntimeEnabledFeatures.h"
11 #include "bindings/v8/ExceptionState.h"
12 #include "bindings/v8/V8DOMConfiguration.h"
13 #include "bindings/v8/V8HiddenValue.h"
14 #include "bindings/v8/V8ObjectConstructor.h"
15 #include "core/dom/ContextFeatures.h"
16 #include "core/dom/Document.h"
17 #include "platform/TraceEvent.h"
18 #include "wtf/GetPtr.h"
19 #include "wtf/RefPtr.h"
20
21 namespace WebCore {
22
23 static void initializeScriptWrappableForInterface(TestInterfaceEmpty* object)
24 {
25     if (ScriptWrappable::wrapperCanBeStoredInObject(object))
26         ScriptWrappable::fromObject(object)->setTypeInfo(&V8TestInterfaceEmpty::wrapperTypeInfo);
27     else
28         ASSERT_NOT_REACHED();
29 }
30
31 } // namespace WebCore
32
33 void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterfaceEmpty* object)
34 {
35     WebCore::initializeScriptWrappableForInterface(object);
36 }
37
38 namespace WebCore {
39 const WrapperTypeInfo V8TestInterfaceEmpty::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterfaceEmpty::domTemplate, V8TestInterfaceEmpty::derefObject, 0, 0, 0, V8TestInterfaceEmpty::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, RefCountedObject };
40
41 namespace TestInterfaceEmptyV8Internal {
42
43 template <typename T> void V8_USE(T) { }
44
45 } // namespace TestInterfaceEmptyV8Internal
46
47 static void configureV8TestInterfaceEmptyTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate)
48 {
49     functionTemplate->ReadOnlyPrototype();
50
51     v8::Local<v8::Signature> defaultSignature;
52     defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterfaceEmpty", v8::Local<v8::FunctionTemplate>(), V8TestInterfaceEmpty::internalFieldCount,
53         0, 0,
54         0, 0,
55         0, 0,
56         isolate);
57     v8::Local<v8::ObjectTemplate> instanceTemplate ALLOW_UNUSED = functionTemplate->InstanceTemplate();
58     v8::Local<v8::ObjectTemplate> prototypeTemplate ALLOW_UNUSED = functionTemplate->PrototypeTemplate();
59
60     // Custom toString template
61     functionTemplate->Set(v8AtomicString(isolate, "toString"), V8PerIsolateData::from(isolate)->toStringTemplate());
62 }
63
64 v8::Handle<v8::FunctionTemplate> V8TestInterfaceEmpty::domTemplate(v8::Isolate* isolate)
65 {
66     V8PerIsolateData* data = V8PerIsolateData::from(isolate);
67     v8::Local<v8::FunctionTemplate> result = data->existingDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo));
68     if (!result.IsEmpty())
69         return result;
70
71     TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
72     result = v8::FunctionTemplate::New(isolate, V8ObjectConstructor::isValidConstructorMode);
73     configureV8TestInterfaceEmptyTemplate(result, isolate);
74     data->setDOMTemplate(const_cast<WrapperTypeInfo*>(&wrapperTypeInfo), result);
75     return result;
76 }
77
78 bool V8TestInterfaceEmpty::hasInstance(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
79 {
80     return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, v8Value);
81 }
82
83 v8::Handle<v8::Object> V8TestInterfaceEmpty::findInstanceInPrototypeChain(v8::Handle<v8::Value> v8Value, v8::Isolate* isolate)
84 {
85     return V8PerIsolateData::from(isolate)->findInstanceInPrototypeChain(&wrapperTypeInfo, v8Value);
86 }
87
88 TestInterfaceEmpty* V8TestInterfaceEmpty::toNativeWithTypeCheck(v8::Isolate* isolate, v8::Handle<v8::Value> value)
89 {
90     return hasInstance(value, isolate) ? fromInternalPointer(v8::Handle<v8::Object>::Cast(value)->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)) : 0;
91 }
92
93 v8::Handle<v8::Object> V8TestInterfaceEmpty::createWrapper(PassRefPtr<TestInterfaceEmpty> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
94 {
95     ASSERT(impl);
96     ASSERT(!DOMDataStore::containsWrapper<V8TestInterfaceEmpty>(impl.get(), isolate));
97     if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
98         const WrapperTypeInfo* actualInfo = ScriptWrappable::fromObject(impl.get())->typeInfo();
99         // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have
100         // the same object de-ref functions, though, so use that as the basis of the check.
101         RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
102     }
103
104     v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
105     if (UNLIKELY(wrapper.IsEmpty()))
106         return wrapper;
107
108     installPerContextEnabledProperties(wrapper, impl.get(), isolate);
109     V8DOMWrapper::associateObjectWithWrapper<V8TestInterfaceEmpty>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
110     return wrapper;
111 }
112
113 void V8TestInterfaceEmpty::derefObject(void* object)
114 {
115     fromInternalPointer(object)->deref();
116 }
117
118 template<>
119 v8::Handle<v8::Value> toV8NoInline(TestInterfaceEmpty* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
120 {
121     return toV8(impl, creationContext, isolate);
122 }
123
124 } // namespace WebCore