Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / tests / results / V8TestInterface.h
1 /*
2  * Copyright (C) 2013 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
32
33 #ifndef V8TestInterface_h
34 #define V8TestInterface_h
35
36 #if ENABLE(Condition1) || ENABLE(Condition2)
37 #include "bindings/tests/idls/TestInterface.h"
38 #include "bindings/v8/V8Binding.h"
39 #include "bindings/v8/V8DOMWrapper.h"
40 #include "bindings/v8/WrapperTypeInfo.h"
41 #include "heap/Handle.h"
42
43 namespace WebCore {
44
45 class V8TestInterface {
46 public:
47     static bool hasInstance(v8::Handle<v8::Value>, v8::Isolate*);
48     static v8::Handle<v8::FunctionTemplate> domTemplate(v8::Isolate*, WrapperWorldType);
49     static TestInterface* toNative(v8::Handle<v8::Object> object)
50     {
51         return fromInternalPointer(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex));
52     }
53     static const WrapperTypeInfo wrapperTypeInfo;
54     static void derefObject(void*);
55     static void visitDOMWrapper(void*, const v8::Persistent<v8::Object>&, v8::Isolate*);
56     static ActiveDOMObject* toActiveDOMObject(v8::Handle<v8::Object>);
57     static void implementsCustomVoidMethodMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
58 #if ENABLE(CONDITION_PARTIAL)
59     static void supplementalMethod3MethodCustom(const v8::FunctionCallbackInfo<v8::Value>&);
60 #endif // ENABLE(CONDITION_PARTIAL)
61     static void constructorCallback(const v8::FunctionCallbackInfo<v8::Value>&);
62     static void namedPropertySetterCustom(v8::Local<v8::String>, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);
63     static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0;
64     static inline void* toInternalPointer(TestInterface* impl)
65     {
66         return impl;
67     }
68
69     static inline TestInterface* fromInternalPointer(void* object)
70     {
71         return static_cast<TestInterface*>(object);
72     }
73     static void installPerContextEnabledProperties(v8::Handle<v8::Object>, TestInterface*, v8::Isolate*);
74     static void installPerContextEnabledMethods(v8::Handle<v8::Object>, v8::Isolate*) { }
75
76 private:
77     friend v8::Handle<v8::Object> wrap(TestInterface*, v8::Handle<v8::Object> creationContext, v8::Isolate*);
78     static v8::Handle<v8::Object> createWrapper(PassRefPtr<TestInterface>, v8::Handle<v8::Object> creationContext, v8::Isolate*);
79 };
80
81 template<>
82 class WrapperTypeTraits<TestInterface > {
83 public:
84     static const WrapperTypeInfo* wrapperTypeInfo() { return &V8TestInterface::wrapperTypeInfo; }
85 };
86
87 inline v8::Handle<v8::Object> wrap(TestInterface* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
88 {
89     ASSERT(impl);
90     ASSERT(!DOMDataStore::containsWrapper<V8TestInterface>(impl, isolate));
91     return V8TestInterface::createWrapper(impl, creationContext, isolate);
92 }
93
94 inline v8::Handle<v8::Value> toV8(TestInterface* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
95 {
96     if (UNLIKELY(!impl))
97         return v8::Null(isolate);
98     v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<V8TestInterface>(impl, isolate);
99     if (!wrapper.IsEmpty())
100         return wrapper;
101     return wrap(impl, creationContext, isolate);
102 }
103
104 template<typename CallbackInfo>
105 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, TestInterface* impl)
106 {
107     if (UNLIKELY(!impl)) {
108         v8SetReturnValueNull(callbackInfo);
109         return;
110     }
111     if (DOMDataStore::setReturnValueFromWrapper<V8TestInterface>(callbackInfo.GetReturnValue(), impl))
112         return;
113     v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
114     v8SetReturnValue(callbackInfo, wrapper);
115 }
116
117 template<typename CallbackInfo>
118 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, TestInterface* impl)
119 {
120     ASSERT(worldType(callbackInfo.GetIsolate()) == MainWorld);
121     if (UNLIKELY(!impl)) {
122         v8SetReturnValueNull(callbackInfo);
123         return;
124     }
125     if (DOMDataStore::setReturnValueFromWrapperForMainWorld<V8TestInterface>(callbackInfo.GetReturnValue(), impl))
126         return;
127     v8::Handle<v8::Value> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
128     v8SetReturnValue(callbackInfo, wrapper);
129 }
130
131 template<class CallbackInfo, class Wrappable>
132 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, TestInterface* impl, Wrappable* wrappable)
133 {
134     if (UNLIKELY(!impl)) {
135         v8SetReturnValueNull(callbackInfo);
136         return;
137     }
138     if (DOMDataStore::setReturnValueFromWrapperFast<V8TestInterface>(callbackInfo.GetReturnValue(), impl, callbackInfo.Holder(), wrappable))
139         return;
140     v8::Handle<v8::Object> wrapper = wrap(impl, callbackInfo.Holder(), callbackInfo.GetIsolate());
141     v8SetReturnValue(callbackInfo, wrapper);
142 }
143
144 inline v8::Handle<v8::Value> toV8(PassRefPtr<TestInterface> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
145 {
146     return toV8(impl.get(), creationContext, isolate);
147 }
148
149 template<class CallbackInfo>
150 inline void v8SetReturnValue(const CallbackInfo& callbackInfo, PassRefPtr<TestInterface> impl)
151 {
152     v8SetReturnValue(callbackInfo, impl.get());
153 }
154
155 template<class CallbackInfo>
156 inline void v8SetReturnValueForMainWorld(const CallbackInfo& callbackInfo, PassRefPtr<TestInterface> impl)
157 {
158     v8SetReturnValueForMainWorld(callbackInfo, impl.get());
159 }
160
161 template<class CallbackInfo, class Wrappable>
162 inline void v8SetReturnValueFast(const CallbackInfo& callbackInfo, PassRefPtr<TestInterface> impl, Wrappable* wrappable)
163 {
164     v8SetReturnValueFast(callbackInfo, impl.get(), wrappable);
165 }
166
167 }
168 #endif // ENABLE(Condition1) || ENABLE(Condition2)
169 #endif // V8TestInterface_h