Fix several style warnings in generated bindings
[WebKit.git] / Source / WebCore / bindings / scripts / test / JS / JSTestSerializedScriptValueInterface.cpp
1 /*
2     This file is part of the WebKit open source project.
3     This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 #include "config.h"
22
23 #if ENABLE(Condition1) || ENABLE(Condition2)
24
25 #include "JSTestSerializedScriptValueInterface.h"
26
27 #include "JSMessagePort.h"
28 #include "MessagePort.h"
29 #include "SerializedScriptValue.h"
30 #include "TestSerializedScriptValueInterface.h"
31 #include <runtime/JSArray.h>
32 #include <wtf/GetPtr.h>
33
34 using namespace JSC;
35
36 namespace WebCore {
37
38 /* Hash table */
39
40 static const HashTableValue JSTestSerializedScriptValueInterfaceTableValues[] =
41 {
42     { "value", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t)setJSTestSerializedScriptValueInterfaceValue, NoIntrinsic },
43     { "readonlyValue", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceReadonlyValue), (intptr_t)0, NoIntrinsic },
44     { "cachedValue", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedValue), (intptr_t)setJSTestSerializedScriptValueInterfaceCachedValue, NoIntrinsic },
45     { "ports", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfacePorts), (intptr_t)0, NoIntrinsic },
46     { "cachedReadonlyValue", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedReadonlyValue), (intptr_t)0, NoIntrinsic },
47     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t)0, NoIntrinsic },
48     { 0, 0, 0, 0, NoIntrinsic }
49 };
50
51 static const HashTable JSTestSerializedScriptValueInterfaceTable = { 17, 15, JSTestSerializedScriptValueInterfaceTableValues, 0 };
52 /* Hash table for constructor */
53
54 static const HashTableValue JSTestSerializedScriptValueInterfaceConstructorTableValues[] =
55 {
56     { 0, 0, 0, 0, NoIntrinsic }
57 };
58
59 static const HashTable JSTestSerializedScriptValueInterfaceConstructorTable = { 1, 0, JSTestSerializedScriptValueInterfaceConstructorTableValues, 0 };
60 const ClassInfo JSTestSerializedScriptValueInterfaceConstructor::s_info = { "TestSerializedScriptValueInterfaceConstructor", &Base::s_info, &JSTestSerializedScriptValueInterfaceConstructorTable, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfaceConstructor) };
61
62 JSTestSerializedScriptValueInterfaceConstructor::JSTestSerializedScriptValueInterfaceConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
63     : DOMConstructorObject(structure, globalObject)
64 {
65 }
66
67 void JSTestSerializedScriptValueInterfaceConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
68 {
69     Base::finishCreation(exec->vm());
70     ASSERT(inherits(&s_info));
71     putDirect(exec->vm(), exec->propertyNames().prototype, JSTestSerializedScriptValueInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly);
72     putDirect(exec->vm(), exec->propertyNames().length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
73 }
74
75 bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
76 {
77     return getStaticValueSlot<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(cell), propertyName, slot);
78 }
79
80 bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
81 {
82     return getStaticValueDescriptor<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(object), propertyName, descriptor);
83 }
84
85 /* Hash table for prototype */
86
87 static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[] =
88 {
89     { 0, 0, 0, 0, NoIntrinsic }
90 };
91
92 static const HashTable JSTestSerializedScriptValueInterfacePrototypeTable = { 1, 0, JSTestSerializedScriptValueInterfacePrototypeTableValues, 0 };
93 const ClassInfo JSTestSerializedScriptValueInterfacePrototype::s_info = { "TestSerializedScriptValueInterfacePrototype", &Base::s_info, &JSTestSerializedScriptValueInterfacePrototypeTable, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfacePrototype) };
94
95 JSObject* JSTestSerializedScriptValueInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject)
96 {
97     return getDOMPrototype<JSTestSerializedScriptValueInterface>(exec, globalObject);
98 }
99
100 const ClassInfo JSTestSerializedScriptValueInterface::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, &JSTestSerializedScriptValueInterfaceTable, 0 , CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterface) };
101
102 JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestSerializedScriptValueInterface> impl)
103     : JSDOMWrapper(structure, globalObject)
104     , m_impl(impl.leakRef())
105 {
106 }
107
108 void JSTestSerializedScriptValueInterface::finishCreation(VM& vm)
109 {
110     Base::finishCreation(vm);
111     ASSERT(inherits(&s_info));
112 }
113
114 JSObject* JSTestSerializedScriptValueInterface::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
115 {
116     return JSTestSerializedScriptValueInterfacePrototype::create(exec->vm(), globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(globalObject->vm(), globalObject, globalObject->objectPrototype()));
117 }
118
119 void JSTestSerializedScriptValueInterface::destroy(JSC::JSCell* cell)
120 {
121     JSTestSerializedScriptValueInterface* thisObject = static_cast<JSTestSerializedScriptValueInterface*>(cell);
122     thisObject->JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface();
123 }
124
125 JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface()
126 {
127     releaseImplIfNotNull();
128 }
129
130 bool JSTestSerializedScriptValueInterface::getOwnPropertySlot(JSCell* cell, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
131 {
132     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
133     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
134     return getStaticValueSlot<JSTestSerializedScriptValueInterface, Base>(exec, &JSTestSerializedScriptValueInterfaceTable, thisObject, propertyName, slot);
135 }
136
137 bool JSTestSerializedScriptValueInterface::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
138 {
139     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(object);
140     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
141     return getStaticValueDescriptor<JSTestSerializedScriptValueInterface, Base>(exec, &JSTestSerializedScriptValueInterfaceTable, thisObject, propertyName, descriptor);
142 }
143
144 JSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, JSValue slotBase, PropertyName)
145 {
146     JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
147     UNUSED_PARAM(exec);
148     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
149     JSValue result = impl->value() ? impl->value()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
150     return result;
151 }
152
153
154 JSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* exec, JSValue slotBase, PropertyName)
155 {
156     JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
157     UNUSED_PARAM(exec);
158     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
159     JSValue result = impl->readonlyValue() ? impl->readonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
160     return result;
161 }
162
163
164 JSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSValue slotBase, PropertyName)
165 {
166     JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
167     UNUSED_PARAM(exec);
168     if (JSValue cachedValue = castedThis->m_cachedValue.get())
169         return cachedValue;
170     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
171     JSValue result = impl->cachedValue() ? impl->cachedValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
172     castedThis->m_cachedValue.set(exec->vm(), castedThis, result);
173     return result;
174 }
175
176
177 JSValue jsTestSerializedScriptValueInterfacePorts(ExecState* exec, JSValue slotBase, PropertyName)
178 {
179     JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
180     UNUSED_PARAM(exec);
181     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
182     JSValue result = jsArray(exec, castedThis->globalObject(), *impl->ports());
183     return result;
184 }
185
186
187 JSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* exec, JSValue slotBase, PropertyName)
188 {
189     JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
190     UNUSED_PARAM(exec);
191     if (JSValue cachedValue = castedThis->m_cachedReadonlyValue.get())
192         return cachedValue;
193     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
194     JSValue result = impl->cachedReadonlyValue() ? impl->cachedReadonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
195     castedThis->m_cachedReadonlyValue.set(exec->vm(), castedThis, result);
196     return result;
197 }
198
199
200 JSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* exec, JSValue slotBase, PropertyName)
201 {
202     JSTestSerializedScriptValueInterface* domObject = jsCast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
203     return JSTestSerializedScriptValueInterface::getConstructor(exec, domObject->globalObject());
204 }
205
206 void JSTestSerializedScriptValueInterface::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
207 {
208     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
209     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
210     lookupPut<JSTestSerializedScriptValueInterface, Base>(exec, propertyName, value, &JSTestSerializedScriptValueInterfaceTable, thisObject, slot);
211 }
212
213 void setJSTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* thisObject, JSValue value)
214 {
215     UNUSED_PARAM(exec);
216     JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(thisObject);
217     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
218     RefPtr<SerializedScriptValue> nativeValue(SerializedScriptValue::create(exec, value, 0, 0));
219     if (exec->hadException())
220         return;
221     impl->setValue(nativeValue);
222 }
223
224
225 void setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSObject* thisObject, JSValue value)
226 {
227     UNUSED_PARAM(exec);
228     JSTestSerializedScriptValueInterface* castedThis = jsCast<JSTestSerializedScriptValueInterface*>(thisObject);
229     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
230     RefPtr<SerializedScriptValue> nativeValue(SerializedScriptValue::create(exec, value, 0, 0));
231     if (exec->hadException())
232         return;
233     impl->setCachedValue(nativeValue);
234 }
235
236
237 JSValue JSTestSerializedScriptValueInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
238 {
239     return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(exec, jsCast<JSDOMGlobalObject*>(globalObject));
240 }
241
242 void JSTestSerializedScriptValueInterface::visitChildren(JSCell* cell, SlotVisitor& visitor)
243 {
244     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
245     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
246     COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
247     ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
248     Base::visitChildren(thisObject, visitor);
249     visitor.append(&thisObject->m_cachedValue);
250     visitor.append(&thisObject->m_cachedReadonlyValue);
251 }
252
253 static inline bool isObservable(JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface)
254 {
255     if (jsTestSerializedScriptValueInterface->hasCustomProperties())
256         return true;
257     return false;
258 }
259
260 bool JSTestSerializedScriptValueInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
261 {
262     JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = jsCast<JSTestSerializedScriptValueInterface*>(handle.get().asCell());
263     if (!isObservable(jsTestSerializedScriptValueInterface))
264         return false;
265     UNUSED_PARAM(visitor);
266     return false;
267 }
268
269 void JSTestSerializedScriptValueInterfaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
270 {
271     JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = jsCast<JSTestSerializedScriptValueInterface*>(handle.get().asCell());
272     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
273     uncacheWrapper(world, jsTestSerializedScriptValueInterface->impl(), jsTestSerializedScriptValueInterface);
274     jsTestSerializedScriptValueInterface->releaseImpl();
275 }
276
277 #if ENABLE(BINDING_INTEGRITY)
278 #if PLATFORM(WIN)
279 #pragma warning(disable: 4483)
280 extern "C" { extern void (*const __identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@")[])(); }
281 #else
282 extern "C" { extern void* _ZTVN7WebCore34TestSerializedScriptValueInterfaceE[]; }
283 #endif
284 #endif
285 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* impl)
286 {
287     if (!impl)
288         return jsNull();
289     if (JSValue result = getExistingWrapper<JSTestSerializedScriptValueInterface>(exec, impl))
290         return result;
291
292 #if ENABLE(BINDING_INTEGRITY)
293     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
294 #if PLATFORM(WIN)
295     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@"));
296 #else
297     void* expectedVTablePointer = &_ZTVN7WebCore34TestSerializedScriptValueInterfaceE[2];
298 #if COMPILER(CLANG)
299     // If this fails TestSerializedScriptValueInterface does not have a vtable, so you need to add the
300     // ImplementationLacksVTable attribute to the interface definition
301     COMPILE_ASSERT(__is_polymorphic(TestSerializedScriptValueInterface), TestSerializedScriptValueInterface_is_not_polymorphic);
302 #endif
303 #endif
304     // If you hit this assertion you either have a use after free bug, or
305     // TestSerializedScriptValueInterface has subclasses. If TestSerializedScriptValueInterface has subclasses that get passed
306     // to toJS() we currently require TestSerializedScriptValueInterface you to opt out of binding hardening
307     // by adding the SkipVTableValidation attribute to the interface IDL definition
308     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
309 #endif
310     ReportMemoryCost<TestSerializedScriptValueInterface>::reportMemoryCost(exec, impl);
311     return createNewWrapper<JSTestSerializedScriptValueInterface>(exec, globalObject, impl);
312 }
313
314 TestSerializedScriptValueInterface* toTestSerializedScriptValueInterface(JSC::JSValue value)
315 {
316     return value.inherits(&JSTestSerializedScriptValueInterface::s_info) ? jsCast<JSTestSerializedScriptValueInterface*>(asObject(value))->impl() : 0;
317 }
318
319 }
320
321 #endif // ENABLE(Condition1) || ENABLE(Condition2)