04deaf10a20a5f850d685cb57083e4f0c07e5264
[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 "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 | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceValue) },
43     { "readonlyValue", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
44     { "cachedValue", DontDelete | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceCachedValue) },
45     { "ports", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfacePorts), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
46     { "cachedReadonlyValue", DontDelete | ReadOnly | CustomAccessor, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
47     { "constructor", DontEnum | ReadOnly, NoIntrinsic, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) },
48     { 0, 0, NoIntrinsic, 0, 0 }
49 };
50
51 static const HashTable JSTestSerializedScriptValueInterfaceTable = { 17, 15, true, JSTestSerializedScriptValueInterfaceTableValues, 0 };
52 /* Hash table for constructor */
53
54 static const HashTableValue JSTestSerializedScriptValueInterfaceConstructorTableValues[] =
55 {
56     { 0, 0, NoIntrinsic, 0, 0 }
57 };
58
59 static const HashTable JSTestSerializedScriptValueInterfaceConstructorTable = { 1, 0, false, 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(VM& vm, JSDOMGlobalObject* globalObject)
68 {
69     Base::finishCreation(vm);
70     ASSERT(inherits(info()));
71     putDirect(vm, vm.propertyNames->prototype, JSTestSerializedScriptValueInterfacePrototype::self(vm, globalObject), DontDelete | ReadOnly);
72     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontDelete | DontEnum);
73 }
74
75 bool JSTestSerializedScriptValueInterfaceConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
76 {
77     return getStaticValueSlot<JSTestSerializedScriptValueInterfaceConstructor, JSDOMWrapper>(exec, JSTestSerializedScriptValueInterfaceConstructorTable, jsCast<JSTestSerializedScriptValueInterfaceConstructor*>(object), propertyName, slot);
78 }
79
80 /* Hash table for prototype */
81
82 static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[] =
83 {
84     { 0, 0, NoIntrinsic, 0, 0 }
85 };
86
87 static const HashTable JSTestSerializedScriptValueInterfacePrototypeTable = { 1, 0, false, JSTestSerializedScriptValueInterfacePrototypeTableValues, 0 };
88 const ClassInfo JSTestSerializedScriptValueInterfacePrototype::s_info = { "TestSerializedScriptValueInterfacePrototype", &Base::s_info, &JSTestSerializedScriptValueInterfacePrototypeTable, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfacePrototype) };
89
90 JSObject* JSTestSerializedScriptValueInterfacePrototype::self(VM& vm, JSGlobalObject* globalObject)
91 {
92     return getDOMPrototype<JSTestSerializedScriptValueInterface>(vm, globalObject);
93 }
94
95 const ClassInfo JSTestSerializedScriptValueInterface::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, &JSTestSerializedScriptValueInterfaceTable, 0 , CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterface) };
96
97 JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestSerializedScriptValueInterface> impl)
98     : JSDOMWrapper(structure, globalObject)
99     , m_impl(impl.leakRef())
100 {
101 }
102
103 void JSTestSerializedScriptValueInterface::finishCreation(VM& vm)
104 {
105     Base::finishCreation(vm);
106     ASSERT(inherits(info()));
107 }
108
109 JSObject* JSTestSerializedScriptValueInterface::createPrototype(VM& vm, JSGlobalObject* globalObject)
110 {
111     return JSTestSerializedScriptValueInterfacePrototype::create(vm, globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
112 }
113
114 void JSTestSerializedScriptValueInterface::destroy(JSC::JSCell* cell)
115 {
116     JSTestSerializedScriptValueInterface* thisObject = static_cast<JSTestSerializedScriptValueInterface*>(cell);
117     thisObject->JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface();
118 }
119
120 JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface()
121 {
122     releaseImplIfNotNull();
123 }
124
125 bool JSTestSerializedScriptValueInterface::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
126 {
127     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(object);
128     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
129     return getStaticValueSlot<JSTestSerializedScriptValueInterface, Base>(exec, JSTestSerializedScriptValueInterfaceTable, thisObject, propertyName, slot);
130 }
131
132 EncodedJSValue jsTestSerializedScriptValueInterfaceValue(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
133 {
134     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
135     UNUSED_PARAM(slotBase);
136     if (!castedThis)
137         return throwVMTypeError(exec);
138     UNUSED_PARAM(exec);
139     TestSerializedScriptValueInterface& impl = castedThis->impl();
140     JSValue result = impl.value() ? impl.value()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
141     return JSValue::encode(result);
142 }
143
144
145 EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
146 {
147     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
148     UNUSED_PARAM(slotBase);
149     if (!castedThis)
150         return throwVMTypeError(exec);
151     UNUSED_PARAM(exec);
152     TestSerializedScriptValueInterface& impl = castedThis->impl();
153     JSValue result = impl.readonlyValue() ? impl.readonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
154     return JSValue::encode(result);
155 }
156
157
158 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
159 {
160     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
161     UNUSED_PARAM(slotBase);
162     if (!castedThis)
163         return throwVMTypeError(exec);
164     UNUSED_PARAM(exec);
165     if (JSValue cachedValue = castedThis->m_cachedValue.get())
166         return JSValue::encode(cachedValue);
167     TestSerializedScriptValueInterface& impl = castedThis->impl();
168     JSValue result = impl.cachedValue() ? impl.cachedValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
169     castedThis->m_cachedValue.set(exec->vm(), castedThis, result);
170     return JSValue::encode(result);
171 }
172
173
174 EncodedJSValue jsTestSerializedScriptValueInterfacePorts(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
175 {
176     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
177     UNUSED_PARAM(slotBase);
178     if (!castedThis)
179         return throwVMTypeError(exec);
180     UNUSED_PARAM(exec);
181     TestSerializedScriptValueInterface& impl = castedThis->impl();
182     JSValue result = jsArray(exec, castedThis->globalObject(), impl.ports());
183     return JSValue::encode(result);
184 }
185
186
187 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue thisValue, PropertyName)
188 {
189     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
190     UNUSED_PARAM(slotBase);
191     if (!castedThis)
192         return throwVMTypeError(exec);
193     UNUSED_PARAM(exec);
194     if (JSValue cachedValue = castedThis->m_cachedReadonlyValue.get())
195         return JSValue::encode(cachedValue);
196     TestSerializedScriptValueInterface& impl = castedThis->impl();
197     JSValue result = impl.cachedReadonlyValue() ? impl.cachedReadonlyValue()->deserialize(exec, castedThis->globalObject(), 0) : jsNull();
198     castedThis->m_cachedReadonlyValue.set(exec->vm(), castedThis, result);
199     return JSValue::encode(result);
200 }
201
202
203 EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* exec, EncodedJSValue, EncodedJSValue thisValue, PropertyName)
204 {
205     JSTestSerializedScriptValueInterface* domObject = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
206     if (!domObject)
207         return throwVMTypeError(exec);
208     return JSValue::encode(JSTestSerializedScriptValueInterface::getConstructor(exec->vm(), domObject->globalObject()));
209 }
210
211 void setJSTestSerializedScriptValueInterfaceValue(ExecState* exec, JSObject* /* baseObject */, EncodedJSValue thisValue, EncodedJSValue encodedValue)
212 {
213     JSValue value = JSValue::decode(encodedValue);
214     UNUSED_PARAM(exec);
215     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
216     if (!castedThis) {
217         throwVMTypeError(exec);
218         return;
219     }
220     TestSerializedScriptValueInterface& impl = castedThis->impl();
221     RefPtr<SerializedScriptValue> nativeValue(SerializedScriptValue::create(exec, value, 0, 0));
222     if (exec->hadException())
223         return;
224     impl.setValue(nativeValue);
225 }
226
227
228 void setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* exec, JSObject* /* baseObject */, EncodedJSValue thisValue, EncodedJSValue encodedValue)
229 {
230     JSValue value = JSValue::decode(encodedValue);
231     UNUSED_PARAM(exec);
232     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
233     if (!castedThis) {
234         throwVMTypeError(exec);
235         return;
236     }
237     TestSerializedScriptValueInterface& impl = castedThis->impl();
238     RefPtr<SerializedScriptValue> nativeValue(SerializedScriptValue::create(exec, value, 0, 0));
239     if (exec->hadException())
240         return;
241     impl.setCachedValue(nativeValue);
242 }
243
244
245 JSValue JSTestSerializedScriptValueInterface::getConstructor(VM& vm, JSGlobalObject* globalObject)
246 {
247     return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(vm, jsCast<JSDOMGlobalObject*>(globalObject));
248 }
249
250 void JSTestSerializedScriptValueInterface::visitChildren(JSCell* cell, SlotVisitor& visitor)
251 {
252     JSTestSerializedScriptValueInterface* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
253     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
254     COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
255     ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
256     Base::visitChildren(thisObject, visitor);
257     visitor.append(&thisObject->m_cachedValue);
258     visitor.append(&thisObject->m_cachedReadonlyValue);
259 }
260
261 bool JSTestSerializedScriptValueInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
262 {
263     UNUSED_PARAM(handle);
264     UNUSED_PARAM(visitor);
265     return false;
266 }
267
268 void JSTestSerializedScriptValueInterfaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
269 {
270     JSTestSerializedScriptValueInterface* jsTestSerializedScriptValueInterface = jsCast<JSTestSerializedScriptValueInterface*>(handle.get().asCell());
271     DOMWrapperWorld& world = *static_cast<DOMWrapperWorld*>(context);
272     uncacheWrapper(world, &jsTestSerializedScriptValueInterface->impl(), jsTestSerializedScriptValueInterface);
273     jsTestSerializedScriptValueInterface->releaseImpl();
274 }
275
276 #if ENABLE(BINDING_INTEGRITY)
277 #if PLATFORM(WIN)
278 #pragma warning(disable: 4483)
279 extern "C" { extern void (*const __identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@")[])(); }
280 #else
281 extern "C" { extern void* _ZTVN7WebCore34TestSerializedScriptValueInterfaceE[]; }
282 #endif
283 #endif
284 JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface* impl)
285 {
286     if (!impl)
287         return jsNull();
288     if (JSValue result = getExistingWrapper<JSTestSerializedScriptValueInterface>(exec, impl))
289         return result;
290
291 #if ENABLE(BINDING_INTEGRITY)
292     void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
293 #if PLATFORM(WIN)
294     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@"));
295 #else
296     void* expectedVTablePointer = &_ZTVN7WebCore34TestSerializedScriptValueInterfaceE[2];
297 #if COMPILER(CLANG)
298     // If this fails TestSerializedScriptValueInterface does not have a vtable, so you need to add the
299     // ImplementationLacksVTable attribute to the interface definition
300     COMPILE_ASSERT(__is_polymorphic(TestSerializedScriptValueInterface), TestSerializedScriptValueInterface_is_not_polymorphic);
301 #endif
302 #endif
303     // If you hit this assertion you either have a use after free bug, or
304     // TestSerializedScriptValueInterface has subclasses. If TestSerializedScriptValueInterface has subclasses that get passed
305     // to toJS() we currently require TestSerializedScriptValueInterface you to opt out of binding hardening
306     // by adding the SkipVTableValidation attribute to the interface IDL definition
307     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
308 #endif
309     ReportMemoryCost<TestSerializedScriptValueInterface>::reportMemoryCost(exec, impl);
310     return createNewWrapper<JSTestSerializedScriptValueInterface>(exec, globalObject, impl);
311 }
312
313 TestSerializedScriptValueInterface* toTestSerializedScriptValueInterface(JSC::JSValue value)
314 {
315     return value.inherits(JSTestSerializedScriptValueInterface::info()) ? &jsCast<JSTestSerializedScriptValueInterface*>(value)->impl() : 0;
316 }
317
318 }
319
320 #endif // ENABLE(Condition1) || ENABLE(Condition2)