The JSC code generator doesn't generate correct code for Constructors
[WebKit-https.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 "ExceptionCode.h"
28 #include "JSArray.h"
29 #include "JSDOMBinding.h"
30 #include "SerializedScriptValue.h"
31 #include "TestSerializedScriptValueInterface.h"
32 #include <runtime/Error.h>
33 #include <wtf/GetPtr.h>
34
35 using namespace JSC;
36
37 namespace WebCore {
38
39 ASSERT_CLASS_FITS_IN_CELL(JSTestSerializedScriptValueInterface);
40 /* Hash table */
41
42 static const HashTableValue JSTestSerializedScriptValueInterfaceTableValues[] =
43 {
44     { "value", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t)setJSTestSerializedScriptValueInterfaceValue, NoIntrinsic },
45     { "readonlyValue", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceReadonlyValue), (intptr_t)0, NoIntrinsic },
46     { "cachedValue", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedValue), (intptr_t)setJSTestSerializedScriptValueInterfaceCachedValue, NoIntrinsic },
47     { "cachedReadonlyValue", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedReadonlyValue), (intptr_t)0, NoIntrinsic },
48     { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t)0, NoIntrinsic },
49     { 0, 0, 0, 0, NoIntrinsic }
50 };
51
52 static const HashTable JSTestSerializedScriptValueInterfaceTable = { 17, 15, JSTestSerializedScriptValueInterfaceTableValues, 0 };
53 /* Hash table for constructor */
54
55 static const HashTableValue JSTestSerializedScriptValueInterfaceConstructorTableValues[] =
56 {
57     { 0, 0, 0, 0, NoIntrinsic }
58 };
59
60 static const HashTable JSTestSerializedScriptValueInterfaceConstructorTable = { 1, 0, JSTestSerializedScriptValueInterfaceConstructorTableValues, 0 };
61 const ClassInfo JSTestSerializedScriptValueInterfaceConstructor::s_info = { "TestSerializedScriptValueInterfaceConstructor", &Base::s_info, &JSTestSerializedScriptValueInterfaceConstructorTable, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfaceConstructor) };
62
63 JSTestSerializedScriptValueInterfaceConstructor::JSTestSerializedScriptValueInterfaceConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
64     : DOMConstructorObject(structure, globalObject)
65 {
66 }
67
68 void JSTestSerializedScriptValueInterfaceConstructor::finishCreation(ExecState* exec, JSDOMGlobalObject* globalObject)
69 {
70     Base::finishCreation(exec->globalData());
71     ASSERT(inherits(&s_info));
72     putDirect(exec->globalData(), exec->propertyNames().prototype, JSTestSerializedScriptValueInterfacePrototype::self(exec, globalObject), DontDelete | ReadOnly);
73     putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(3), ReadOnly | DontDelete | DontEnum);
74 }
75
76 bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
77 {
78     return getStaticValueSlot<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, static_cast<JSTestSerializedScriptValueInterfaceConstructor*>(cell), propertyName, slot);
79 }
80
81 bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
82 {
83     return getStaticValueDescriptor<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, &JSTestSerializedScriptValueInterfaceConstructorTable, static_cast<JSTestSerializedScriptValueInterfaceConstructor*>(object), propertyName, descriptor);
84 }
85
86 EncodedJSValue JSC_HOST_CALL JSTestSerializedScriptValueInterfaceConstructor::constructJSTestSerializedScriptValueInterface(ExecState* exec)
87 {
88     JSTestSerializedScriptValueInterfaceConstructor* castedThis = static_cast<JSTestSerializedScriptValueInterfaceConstructor*>(exec->callee());
89     if (exec->argumentCount() < 2)
90         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
91     const String& hello(ustringToString(MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).isEmpty() ? UString() : MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined).toString(exec)->value(exec)));
92     if (exec->hadException())
93         return JSValue::encode(jsUndefined());
94     RefPtr<SerializedScriptValue> data(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined)));
95     if (exec->hadException())
96         return JSValue::encode(jsUndefined());
97     Array* transferList(toArray(MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsUndefined)));
98     if (exec->hadException())
99         return JSValue::encode(jsUndefined());
100     RefPtr<TestSerializedScriptValueInterface> object = TestSerializedScriptValueInterface::create(hello, data, transferList);
101     return JSValue::encode(asObject(toJS(exec, castedThis->globalObject(), object.get())));
102 }
103
104 ConstructType JSTestSerializedScriptValueInterfaceConstructor::getConstructData(JSCell*, ConstructData& constructData)
105 {
106     constructData.native.function = constructJSTestSerializedScriptValueInterface;
107     return ConstructTypeHost;
108 }
109
110 /* Hash table for prototype */
111
112 static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[] =
113 {
114     { "acceptTransferList", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestSerializedScriptValueInterfacePrototypeFunctionAcceptTransferList), (intptr_t)2, NoIntrinsic },
115     { "multiTransferList", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestSerializedScriptValueInterfacePrototypeFunctionMultiTransferList), (intptr_t)4, NoIntrinsic },
116     { 0, 0, 0, 0, NoIntrinsic }
117 };
118
119 static const HashTable JSTestSerializedScriptValueInterfacePrototypeTable = { 5, 3, JSTestSerializedScriptValueInterfacePrototypeTableValues, 0 };
120 const ClassInfo JSTestSerializedScriptValueInterfacePrototype::s_info = { "TestSerializedScriptValueInterfacePrototype", &Base::s_info, &JSTestSerializedScriptValueInterfacePrototypeTable, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfacePrototype) };
121
122 JSObject* JSTestSerializedScriptValueInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject)
123 {
124     return getDOMPrototype<JSTestSerializedScriptValueInterface>(exec, globalObject);
125 }
126
127 bool JSTestSerializedScriptValueInterfacePrototype::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
128 {
129     JSTestSerializedScriptValueInterfacePrototype* thisObject = jsCast<JSTestSerializedScriptValueInterfacePrototype*>(cell);
130     return getStaticFunctionSlot<JSObject>(exec, &JSTestSerializedScriptValueInterfacePrototypeTable, thisObject, propertyName, slot);
131 }
132
133 bool JSTestSerializedScriptValueInterfacePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
134 {
135     JSTestSerializedScriptValueInterfacePrototype* thisObject = jsCast<JSTestSerializedScriptValueInterfacePrototype*>(object);
136     return getStaticFunctionDescriptor<JSObject>(exec, &JSTestSerializedScriptValueInterfacePrototypeTable, thisObject, propertyName, descriptor);
137 }
138
139 const ClassInfo JSTestSerializedScriptValueInterface::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, &JSTestSerializedScriptValueInterfaceTable, 0 , CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterface) };
140
141 JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestSerializedScriptValueInterface> impl)
142     : JSDOMWrapper(structure, globalObject)
143     , m_impl(impl.leakRef())
144 {
145 }
146
147 void JSTestSerializedScriptValueInterface::finishCreation(JSGlobalData& globalData)
148 {
149     Base::finishCreation(globalData);
150     ASSERT(inherits(&s_info));
151 }
152
153 JSObject* JSTestSerializedScriptValueInterface::createPrototype(ExecState* exec, JSGlobalObject* globalObject)
154 {
155     return JSTestSerializedScriptValueInterfacePrototype::create(exec->globalData(), globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype()));
156 }
157
158 void JSTestSerializedScriptValueInterface::destroy(JSC::JSCell* cell)
159 {
160     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
161     thisObject->JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface();
162 }
163
164 JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface()
165 {
166     releaseImplIfNotNull();
167 }
168
169 bool JSTestSerializedScriptValueInterface::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
170 {
171     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
172     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
173     return getStaticValueSlot<JSTestSerializedScriptValueInterface, Base>(exec, &JSTestSerializedScriptValueInterfaceTable, thisObject, propertyName, slot);
174 }
175
176 bool JSTestSerializedScriptValueInterface::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor)
177 {
178     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(object);
179     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
180     return getStaticValueDescriptor<JSTestSerializedScriptValueInterface, Base>(exec, &JSTestSerializedScriptValueInterfaceTable, thisObject, propertyName, descriptor);
181 }
182
183 JSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, JSValue slotBase, const Identifier&)
184 {
185     JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
186     UNUSED_PARAM(exec);
187     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
188     JSValue result = impl->value() ? impl->value()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
189     return result;
190 }
191
192
193 JSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* exec, JSValue slotBase, const Identifier&)
194 {
195     JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
196     UNUSED_PARAM(exec);
197     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
198     JSValue result = impl->readonlyValue() ? impl->readonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
199     return result;
200 }
201
202
203 JSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSValue slotBase, const Identifier&)
204 {
205     JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
206     UNUSED_PARAM(exec);
207     if (JSValue cachedValue = castedThis->m_cachedValue.get())
208         return cachedValue;
209     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
210     JSValue result = impl->cachedValue() ? impl->cachedValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
211     castedThis->m_cachedValue.set(exec->globalData(), castedThis, result);
212     return result;
213 }
214
215
216 JSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* exec, JSValue slotBase, const Identifier&)
217 {
218     JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
219     UNUSED_PARAM(exec);
220     if (JSValue cachedValue = castedThis->m_cachedReadonlyValue.get())
221         return cachedValue;
222     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
223     JSValue result = impl->cachedReadonlyValue() ? impl->cachedReadonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
224     castedThis->m_cachedReadonlyValue.set(exec->globalData(), castedThis, result);
225     return result;
226 }
227
228
229 JSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* exec, JSValue slotBase, const Identifier&)
230 {
231     JSTestSerializedScriptValueInterface* domObject = static_cast<JSTestSerializedScriptValueInterface*>(asObject(slotBase));
232     return JSTestSerializedScriptValueInterface::getConstructor(exec, domObject->globalObject());
233 }
234
235 void JSTestSerializedScriptValueInterface::put(JSCell* cell, ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot)
236 {
237     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
238     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
239     lookupPut<JSTestSerializedScriptValueInterface, Base>(exec, propertyName, value, &JSTestSerializedScriptValueInterfaceTable, thisObject, slot);
240 }
241
242 void setJSTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* thisObject, JSValue value)
243 {
244     JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(thisObject);
245     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
246     impl->setValue(SerializedScriptValue::create(exec, value));
247 }
248
249
250 void setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSObject* thisObject, JSValue value)
251 {
252     JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(thisObject);
253     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
254     impl->setCachedValue(SerializedScriptValue::create(exec, value));
255 }
256
257
258 JSValue JSTestSerializedScriptValueInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject)
259 {
260     return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject));
261 }
262
263 EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionAcceptTransferList(ExecState* exec)
264 {
265     JSValue thisValue = exec->hostThisValue();
266     if (!thisValue.inherits(&JSTestSerializedScriptValueInterface::s_info))
267         return throwVMTypeError(exec);
268     JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(thisValue));
269     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestSerializedScriptValueInterface::s_info);
270     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
271     if (exec->argumentCount() < 1)
272         return throwVMError(exec, createTypeError(exec, "Not enough arguments"));
273     RefPtr<SerializedScriptValue> data(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
274     if (exec->hadException())
275         return JSValue::encode(jsUndefined());
276
277     size_t argsCount = exec->argumentCount();
278     if (argsCount <= 1) {
279         impl->acceptTransferList(data);
280         return JSValue::encode(jsUndefined());
281     }
282
283     Array* transferList(toArray(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined)));
284     if (exec->hadException())
285         return JSValue::encode(jsUndefined());
286     impl->acceptTransferList(data, transferList);
287     return JSValue::encode(jsUndefined());
288 }
289
290 EncodedJSValue JSC_HOST_CALL jsTestSerializedScriptValueInterfacePrototypeFunctionMultiTransferList(ExecState* exec)
291 {
292     JSValue thisValue = exec->hostThisValue();
293     if (!thisValue.inherits(&JSTestSerializedScriptValueInterface::s_info))
294         return throwVMTypeError(exec);
295     JSTestSerializedScriptValueInterface* castedThis = static_cast<JSTestSerializedScriptValueInterface*>(asObject(thisValue));
296     ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestSerializedScriptValueInterface::s_info);
297     TestSerializedScriptValueInterface* impl = static_cast<TestSerializedScriptValueInterface*>(castedThis->impl());
298
299     size_t argsCount = exec->argumentCount();
300     if (argsCount <= 0) {
301         impl->multiTransferList();
302         return JSValue::encode(jsUndefined());
303     }
304
305     RefPtr<SerializedScriptValue> first(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 0, DefaultIsUndefined)));
306     if (exec->hadException())
307         return JSValue::encode(jsUndefined());
308     if (argsCount <= 1) {
309         impl->multiTransferList(first);
310         return JSValue::encode(jsUndefined());
311     }
312
313     Array* tx(toArray(MAYBE_MISSING_PARAMETER(exec, 1, DefaultIsUndefined)));
314     if (exec->hadException())
315         return JSValue::encode(jsUndefined());
316     if (argsCount <= 2) {
317         impl->multiTransferList(first, tx);
318         return JSValue::encode(jsUndefined());
319     }
320
321     RefPtr<SerializedScriptValue> second(SerializedScriptValue::create(exec, MAYBE_MISSING_PARAMETER(exec, 2, DefaultIsUndefined)));
322     if (exec->hadException())
323         return JSValue::encode(jsUndefined());
324     if (argsCount <= 3) {
325         impl->multiTransferList(first, tx, second);
326         return JSValue::encode(jsUndefined());
327     }
328
329     Array* txx(toArray(MAYBE_MISSING_PARAMETER(exec, 3, DefaultIsUndefined)));
330     if (exec->hadException())
331         return JSValue::encode(jsUndefined());
332     impl->multiTransferList(first, tx, second, txx);
333     return JSValue::encode(jsUndefined());
334 }
335
336 void JSTestSerializedScriptValueInterface::visitChildren(JSCell* cell, SlotVisitor& visitor)
337 {
338     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
339     ASSERT_GC_OBJECT_INHERITS(thisObject, &s_info);
340     COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
341     ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
342     Base::visitChildren(thisObject, visitor);
343     if (thisObject->m_cachedValue)
344         visitor.append(&thisObject->m_cachedValue);
345     if (thisObject->m_cachedReadonlyValue)
346         visitor.append(&thisObject->m_cachedReadonlyValue);
347 }
348
349 static inline bool isObservable(JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface)
350 {
351     if (jsTestSerializedScriptValueInterface->hasCustomProperties())
352         return true;
353     return false;
354 }
355
356 bool JSTestSerializedScriptValueInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
357 {
358     JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = static_cast<JSTestSerializedScriptValueInterface*>(handle.get().asCell());
359     if (!isObservable(jsTestSerializedScriptValueInterface))
360         return false;
361     UNUSED_PARAM(visitor);
362     return false;
363 }
364
365 void JSTestSerializedScriptValueInterfaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
366 {
367     JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = static_cast<JSTestSerializedScriptValueInterface*>(handle.get().asCell());
368     DOMWrapperWorld* world = static_cast<DOMWrapperWorld*>(context);
369     uncacheWrapper(world, jsTestSerializedScriptValueInterface->impl(), jsTestSerializedScriptValueInterface);
370     jsTestSerializedScriptValueInterface->releaseImpl();
371 }
372
373 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* impl)
374 {
375     return wrap<JSTestSerializedScriptValueInterface>(exec, globalObject, impl);
376 }
377
378 TestSerializedScriptValueInterface* toTestSerializedScriptValueInterface(JSC::JSValue value)
379 {
380     return value.inherits(&JSTestSerializedScriptValueInterface::s_info) ? static_cast<JSTestSerializedScriptValueInterface*>(asObject(value))->impl() : 0;
381 }
382
383 }
384
385 #endif // ENABLE(Condition1) || ENABLE(Condition2)