Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestInterfaceGarbageCollected.h
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 #ifndef V8TestInterfaceGarbageCollected_h
8 #define V8TestInterfaceGarbageCollected_h
9
10 #include "bindings/core/v8/ScriptWrappable.h"
11 #include "bindings/core/v8/V8Binding.h"
12 #include "bindings/core/v8/V8DOMWrapper.h"
13 #include "bindings/core/v8/WrapperTypeInfo.h"
14 #include "bindings/tests/idls/TestInterfaceGarbageCollected.h"
15 #include "bindings/tests/v8/V8EventTarget.h"
16 #include "platform/heap/Handle.h"
17
18 namespace blink {
19
20 class V8TestInterfaceGarbageCollected {
21 public:
22     static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*);
23     static v8::Handle<v8::Object> findInstanceInPrototypeChain(v8::Handle<v8::Value>, v8::Isolate*);
24     static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*);
25     static TestInterfaceGarbageCollected* toNative(v8::Handle<v8::Object> object)
26     {
27         return fromInternalPointer(blink::toInternalPointer(object));
28     }
29     static TestInterfaceGarbageCollected* toNativeWithTypeCheck(v8::Isolate*, v8::Handle<v8::Value>);
30     static const WrapperTypeInfo wrapperTypeInfo;
31     static void derefObject(ScriptWrappableBase* internalPointer);
32     static EventTarget* toEventTarget(v8::Handle<v8::Object>);
33     static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
34     static const int eventListenerCacheIndex = v8DefaultWrapperInternalFieldCount + 0;
35     static const int persistentHandleIndex = v8DefaultWrapperInternalFieldCount + 1;
36     static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 1 + 1;
37     static inline ScriptWrappableBase* toInternalPointer(TestInterfaceGarbageCollected* impl)
38     {
39         return V8EventTarget::toInternalPointer(impl);
40     }
41
42     static inline TestInterfaceGarbageCollected* fromInternalPointer(ScriptWrappableBase* internalPointer)
43     {
44         return static_cast<TestInterfaceGarbageCollected*>(V8EventTarget::fromInternalPointer(internalPointer));
45     }
46     static void installConditionallyEnabledProperties(v8::Handle<v8::Object>, v8::Isolate*) { }
47     static void installConditionallyEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*) { }
48
49 private:
50     friend v8::Handle<v8::Object> wrap(TestInterfaceGarbageCollected*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
51     static v8::Handle<v8::Object> createWrapper(RawPtr<TestInterfaceGarbageCollected>, v8::Handle<v8::Object> creationContext, v8::Isolate*);
52 };
53
54 v8::Handle<v8::Object> wrap(TestInterfaceGarbageCollected* impl, v8::Handle<v8::Object> creationContext, v8::Isolate*);
55
56 inline v8::Handle<v8::Value> toV8(TestInterfaceGarbageCollected* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
57 {
58     if (UNLIKELY(!impl))
59         return v8::Null(isolate);
60     v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<V8TestInterfaceGarbageCollected>(impl, isolate);
61     if (!wrapper.IsEmpty())
62         return wrapper;
63     return wrap(impl, creationContext, isolate);
64 }
65
66 template<typename CallbackInfo>
67 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterfaceGarbageCollected* impl)
68 {
69     if (UNLIKELY(!impl)) {
70         v8SetReturnValueNull(callbackInfo);
71         return;
72     }
73     if (DOMDataStore::setReturnValueFromWrapper<V8TestInterfaceGarbageCollected>(callbackInfo.GetReturnValue(), impl))
74         return;
75     v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
76     v8SetReturnValue(callbackInfo, wrapper);
77 }
78
79 template<typename CallbackInfo>
80 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, TestInterfaceGarbageCollected* impl)
81 {
82     ASSERT(DOMWrapperWorld::current(callbackInfo.GetIsolate()).isMainWorld());
83     if (UNLIKELY(!impl)) {
84         v8SetReturnValueNull(callbackInfo);
85         return;
86     }
87     if (DOMDataStore::setReturnValueFromWrapperForMainWorld<V8TestInterfaceGarbageCollected>(callbackInfo.GetReturnValue(), impl))
88         return;
89     v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
90     v8SetReturnValue(callbackInfo, wrapper);
91 }
92
93 template<class CallbackInfo, class Wrappable>
94 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, TestInterfaceGarbageCollected* impl, Wrappable* wrappable)
95 {
96     if (UNLIKELY(!impl)) {
97         v8SetReturnValueNull(callbackInfo);
98         return;
99     }
100     if (DOMDataStore::setReturnValueFromWrapperFast<V8TestInterfaceGarbageCollected>(callbackInfo.GetReturnValue(), impl, callbackInfo.Holder(), wrappable))
101         return;
102     v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
103     v8SetReturnValue(callbackInfo, wrapper);
104 }
105
106 inline v8::Handle<v8::Value> toV8(RawPtr<TestInterfaceGarbageCollected> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
107 {
108     return toV8(impl.get(), creationContext, isolate);
109 }
110
111 template<class CallbackInfo>
112 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, RawPtr<TestInterfaceGarbageCollected> impl)
113 {
114     v8SetReturnValue(callbackInfo, impl.get());
115 }
116
117 template<class CallbackInfo>
118 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, RawPtr<TestInterfaceGarbageCollected> impl)
119 {
120     v8SetReturnValueForMainWorld(callbackInfo, impl.get());
121 }
122
123 template<class CallbackInfo, class Wrappable>
124 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, RawPtr<TestInterfaceGarbageCollected> impl, Wrappable* wrappable)
125 {
126     v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
127 }
128
129 }
130 #endif // V8TestInterfaceGarbageCollected_h