Change ProxyObject.[[Get]] not to use custom accessor
[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 "JSDOMBinding.h"
28 #include "JSDOMConstructor.h"
29 #include "JSMessagePort.h"
30 #include "SerializedScriptValue.h"
31 #include <runtime/FunctionPrototype.h>
32 #include <runtime/JSArray.h>
33 #include <wtf/GetPtr.h>
34
35 using namespace JSC;
36
37 namespace WebCore {
38
39 // Attributes
40
41 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
42 bool setJSTestSerializedScriptValueInterfaceValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
43 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
44 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
45 bool setJSTestSerializedScriptValueInterfaceCachedValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
46 JSC::EncodedJSValue jsTestSerializedScriptValueInterfacePorts(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
47 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
48 JSC::EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49 bool setJSTestSerializedScriptValueInterfaceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
50
51 class JSTestSerializedScriptValueInterfacePrototype : public JSC::JSNonFinalObject {
52 public:
53     typedef JSC::JSNonFinalObject Base;
54     static JSTestSerializedScriptValueInterfacePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
55     {
56         JSTestSerializedScriptValueInterfacePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestSerializedScriptValueInterfacePrototype>(vm.heap)) JSTestSerializedScriptValueInterfacePrototype(vm, globalObject, structure);
57         ptr->finishCreation(vm);
58         return ptr;
59     }
60
61     DECLARE_INFO;
62     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
63     {
64         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
65     }
66
67 private:
68     JSTestSerializedScriptValueInterfacePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
69         : JSC::JSNonFinalObject(vm, structure)
70     {
71     }
72
73     void finishCreation(JSC::VM&);
74 };
75
76 typedef JSDOMConstructorNotConstructable<JSTestSerializedScriptValueInterface> JSTestSerializedScriptValueInterfaceConstructor;
77
78 template<> JSValue JSTestSerializedScriptValueInterfaceConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
79 {
80     UNUSED_PARAM(vm);
81     return globalObject.functionPrototype();
82 }
83
84 template<> void JSTestSerializedScriptValueInterfaceConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
85 {
86     putDirect(vm, vm.propertyNames->prototype, JSTestSerializedScriptValueInterface::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
87     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestSerializedScriptValueInterface"))), ReadOnly | DontEnum);
88     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
89 }
90
91 template<> const ClassInfo JSTestSerializedScriptValueInterfaceConstructor::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfaceConstructor) };
92
93 /* Hash table for prototype */
94
95 static const HashTableValue JSTestSerializedScriptValueInterfacePrototypeTableValues[] =
96 {
97     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceConstructor) } },
98     { "value", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceValue) } },
99     { "readonlyValue", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
100     { "cachedValue", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestSerializedScriptValueInterfaceCachedValue) } },
101     { "ports", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfacePorts), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
102     { "cachedReadonlyValue", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestSerializedScriptValueInterfaceCachedReadonlyValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
103 };
104
105 const ClassInfo JSTestSerializedScriptValueInterfacePrototype::s_info = { "TestSerializedScriptValueInterfacePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterfacePrototype) };
106
107 void JSTestSerializedScriptValueInterfacePrototype::finishCreation(VM& vm)
108 {
109     Base::finishCreation(vm);
110     reifyStaticProperties(vm, JSTestSerializedScriptValueInterfacePrototypeTableValues, *this);
111 }
112
113 const ClassInfo JSTestSerializedScriptValueInterface::s_info = { "TestSerializedScriptValueInterface", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestSerializedScriptValueInterface) };
114
115 JSTestSerializedScriptValueInterface::JSTestSerializedScriptValueInterface(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestSerializedScriptValueInterface>&& impl)
116     : JSDOMWrapper<TestSerializedScriptValueInterface>(structure, globalObject, WTFMove(impl))
117 {
118 }
119
120 JSObject* JSTestSerializedScriptValueInterface::createPrototype(VM& vm, JSGlobalObject* globalObject)
121 {
122     return JSTestSerializedScriptValueInterfacePrototype::create(vm, globalObject, JSTestSerializedScriptValueInterfacePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
123 }
124
125 JSObject* JSTestSerializedScriptValueInterface::prototype(VM& vm, JSGlobalObject* globalObject)
126 {
127     return getDOMPrototype<JSTestSerializedScriptValueInterface>(vm, globalObject);
128 }
129
130 void JSTestSerializedScriptValueInterface::destroy(JSC::JSCell* cell)
131 {
132     JSTestSerializedScriptValueInterface* thisObject = static_cast<JSTestSerializedScriptValueInterface*>(cell);
133     thisObject->JSTestSerializedScriptValueInterface::~JSTestSerializedScriptValueInterface();
134 }
135
136 EncodedJSValue jsTestSerializedScriptValueInterfaceValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
137 {
138     UNUSED_PARAM(state);
139     UNUSED_PARAM(thisValue);
140     JSValue decodedThisValue = JSValue::decode(thisValue);
141     auto* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(decodedThisValue);
142     if (UNLIKELY(!castedThis)) {
143         return throwGetterTypeError(*state, "TestSerializedScriptValueInterface", "value");
144     }
145     auto& impl = castedThis->wrapped();
146     JSValue result = impl.value() ? impl.value()->deserialize(state, castedThis->globalObject(), 0) : jsNull();
147     return JSValue::encode(result);
148 }
149
150
151 EncodedJSValue jsTestSerializedScriptValueInterfaceReadonlyValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
152 {
153     UNUSED_PARAM(state);
154     UNUSED_PARAM(thisValue);
155     JSValue decodedThisValue = JSValue::decode(thisValue);
156     auto* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(decodedThisValue);
157     if (UNLIKELY(!castedThis)) {
158         return throwGetterTypeError(*state, "TestSerializedScriptValueInterface", "readonlyValue");
159     }
160     auto& impl = castedThis->wrapped();
161     JSValue result = impl.readonlyValue() ? impl.readonlyValue()->deserialize(state, castedThis->globalObject(), 0) : jsNull();
162     return JSValue::encode(result);
163 }
164
165
166 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
167 {
168     UNUSED_PARAM(state);
169     UNUSED_PARAM(thisValue);
170     JSValue decodedThisValue = JSValue::decode(thisValue);
171     auto* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(decodedThisValue);
172     if (UNLIKELY(!castedThis)) {
173         return throwGetterTypeError(*state, "TestSerializedScriptValueInterface", "cachedValue");
174     }
175     if (JSValue cachedValue = castedThis->m_cachedValue.get())
176         return JSValue::encode(cachedValue);
177     auto& impl = castedThis->wrapped();
178     JSValue result = impl.cachedValue() ? impl.cachedValue()->deserialize(state, castedThis->globalObject(), 0) : jsNull();
179     castedThis->m_cachedValue.set(state->vm(), castedThis, result);
180     return JSValue::encode(result);
181 }
182
183
184 EncodedJSValue jsTestSerializedScriptValueInterfacePorts(ExecState* state, EncodedJSValue thisValue, PropertyName)
185 {
186     UNUSED_PARAM(state);
187     UNUSED_PARAM(thisValue);
188     JSValue decodedThisValue = JSValue::decode(thisValue);
189     auto* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(decodedThisValue);
190     if (UNLIKELY(!castedThis)) {
191         return throwGetterTypeError(*state, "TestSerializedScriptValueInterface", "ports");
192     }
193     auto& impl = castedThis->wrapped();
194     JSValue result = jsArray(state, castedThis->globalObject(), impl.ports());
195     return JSValue::encode(result);
196 }
197
198
199 EncodedJSValue jsTestSerializedScriptValueInterfaceCachedReadonlyValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
200 {
201     UNUSED_PARAM(state);
202     UNUSED_PARAM(thisValue);
203     JSValue decodedThisValue = JSValue::decode(thisValue);
204     auto* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(decodedThisValue);
205     if (UNLIKELY(!castedThis)) {
206         return throwGetterTypeError(*state, "TestSerializedScriptValueInterface", "cachedReadonlyValue");
207     }
208     if (JSValue cachedValue = castedThis->m_cachedReadonlyValue.get())
209         return JSValue::encode(cachedValue);
210     auto& impl = castedThis->wrapped();
211     JSValue result = impl.cachedReadonlyValue() ? impl.cachedReadonlyValue()->deserialize(state, castedThis->globalObject(), 0) : jsNull();
212     castedThis->m_cachedReadonlyValue.set(state->vm(), castedThis, result);
213     return JSValue::encode(result);
214 }
215
216
217 EncodedJSValue jsTestSerializedScriptValueInterfaceConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
218 {
219     JSTestSerializedScriptValueInterfacePrototype* domObject = jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(JSValue::decode(thisValue));
220     if (UNLIKELY(!domObject))
221         return throwVMTypeError(state);
222     return JSValue::encode(JSTestSerializedScriptValueInterface::getConstructor(state->vm(), domObject->globalObject()));
223 }
224
225 bool setJSTestSerializedScriptValueInterfaceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
226 {
227     JSValue value = JSValue::decode(encodedValue);
228     JSTestSerializedScriptValueInterfacePrototype* domObject = jsDynamicCast<JSTestSerializedScriptValueInterfacePrototype*>(JSValue::decode(thisValue));
229     if (UNLIKELY(!domObject)) {
230         throwVMTypeError(state);
231         return false;
232     }
233     // Shadowing a built-in constructor
234     return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
235 }
236
237 bool setJSTestSerializedScriptValueInterfaceValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
238 {
239     JSValue value = JSValue::decode(encodedValue);
240     UNUSED_PARAM(thisValue);
241     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
242     if (UNLIKELY(!castedThis)) {
243         return throwSetterTypeError(*state, "TestSerializedScriptValueInterface", "value");
244     }
245     auto& impl = castedThis->wrapped();
246     auto nativeValue = SerializedScriptValue::create(state, value, 0, 0);
247     if (UNLIKELY(state->hadException()))
248         return false;
249     impl.setValue(WTFMove(nativeValue));
250     return true;
251 }
252
253
254 bool setJSTestSerializedScriptValueInterfaceCachedValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
255 {
256     JSValue value = JSValue::decode(encodedValue);
257     UNUSED_PARAM(thisValue);
258     JSTestSerializedScriptValueInterface* castedThis = jsDynamicCast<JSTestSerializedScriptValueInterface*>(JSValue::decode(thisValue));
259     if (UNLIKELY(!castedThis)) {
260         return throwSetterTypeError(*state, "TestSerializedScriptValueInterface", "cachedValue");
261     }
262     auto& impl = castedThis->wrapped();
263     auto nativeValue = SerializedScriptValue::create(state, value, 0, 0);
264     if (UNLIKELY(state->hadException()))
265         return false;
266     impl.setCachedValue(WTFMove(nativeValue));
267     return true;
268 }
269
270
271 JSValue JSTestSerializedScriptValueInterface::getConstructor(VM& vm, const JSGlobalObject* globalObject)
272 {
273     return getDOMConstructor<JSTestSerializedScriptValueInterfaceConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
274 }
275
276 void JSTestSerializedScriptValueInterface::visitChildren(JSCell* cell, SlotVisitor& visitor)
277 {
278     auto* thisObject = jsCast<JSTestSerializedScriptValueInterface*>(cell);
279     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
280     Base::visitChildren(thisObject, visitor);
281     visitor.append(&thisObject->m_cachedValue);
282     visitor.append(&thisObject->m_cachedReadonlyValue);
283 }
284
285 bool JSTestSerializedScriptValueInterfaceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
286 {
287     UNUSED_PARAM(handle);
288     UNUSED_PARAM(visitor);
289     return false;
290 }
291
292 void JSTestSerializedScriptValueInterfaceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
293 {
294     auto* jsTestSerializedScriptValueInterface = jsCast<JSTestSerializedScriptValueInterface*>(handle.slot()->asCell());
295     auto& world = *static_cast<DOMWrapperWorld*>(context);
296     uncacheWrapper(world, &jsTestSerializedScriptValueInterface->wrapped(), jsTestSerializedScriptValueInterface);
297 }
298
299 #if ENABLE(BINDING_INTEGRITY)
300 #if PLATFORM(WIN)
301 #pragma warning(disable: 4483)
302 extern "C" { extern void (*const __identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@")[])(); }
303 #else
304 extern "C" { extern void* _ZTVN7WebCore34TestSerializedScriptValueInterfaceE[]; }
305 #endif
306 #endif
307
308 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestSerializedScriptValueInterface>&& impl)
309 {
310
311 #if ENABLE(BINDING_INTEGRITY)
312     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
313 #if PLATFORM(WIN)
314     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestSerializedScriptValueInterface@WebCore@@6B@"));
315 #else
316     void* expectedVTablePointer = &_ZTVN7WebCore34TestSerializedScriptValueInterfaceE[2];
317 #if COMPILER(CLANG)
318     // If this fails TestSerializedScriptValueInterface does not have a vtable, so you need to add the
319     // ImplementationLacksVTable attribute to the interface definition
320     static_assert(__is_polymorphic(TestSerializedScriptValueInterface), "TestSerializedScriptValueInterface is not polymorphic");
321 #endif
322 #endif
323     // If you hit this assertion you either have a use after free bug, or
324     // TestSerializedScriptValueInterface has subclasses. If TestSerializedScriptValueInterface has subclasses that get passed
325     // to toJS() we currently require TestSerializedScriptValueInterface you to opt out of binding hardening
326     // by adding the SkipVTableValidation attribute to the interface IDL definition
327     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
328 #endif
329     return createWrapper<JSTestSerializedScriptValueInterface, TestSerializedScriptValueInterface>(globalObject, WTFMove(impl));
330 }
331
332 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestSerializedScriptValueInterface& impl)
333 {
334     return wrap(state, globalObject, impl);
335 }
336
337 TestSerializedScriptValueInterface* JSTestSerializedScriptValueInterface::toWrapped(JSC::JSValue value)
338 {
339     if (auto* wrapper = jsDynamicCast<JSTestSerializedScriptValueInterface*>(value))
340         return &wrapper->wrapped();
341     return nullptr;
342 }
343
344 }
345
346 #endif // ENABLE(Condition1) || ENABLE(Condition2)