Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestNode.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 #include "JSTestNode.h"
23
24 #include "JSDOMAttribute.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructor.h"
27 #include "JSDOMConvertBoolean.h"
28 #include "JSDOMConvertInterface.h"
29 #include "JSDOMConvertStrings.h"
30 #include "JSDOMExceptionHandling.h"
31 #include "JSDOMIterator.h"
32 #include "JSDOMOperation.h"
33 #include "JSDOMOperationReturningPromise.h"
34 #include "JSDOMWrapperCache.h"
35 #include "RuntimeEnabledFeatures.h"
36 #include "ScriptExecutionContext.h"
37 #include <JavaScriptCore/BuiltinNames.h>
38 #include <JavaScriptCore/HeapSnapshotBuilder.h>
39 #include <JavaScriptCore/JSCInlines.h>
40 #include <JavaScriptCore/ObjectConstructor.h>
41 #include <wtf/GetPtr.h>
42 #include <wtf/PointerPreparations.h>
43 #include <wtf/URL.h>
44
45
46 namespace WebCore {
47 using namespace JSC;
48
49 // Functions
50
51 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestWorkerPromise(JSC::ExecState*);
52 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionCalculateSecretResult(JSC::ExecState*);
53 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionGetSecretBoolean(JSC::ExecState*);
54 #if ENABLE(TEST_FEATURE)
55 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean(JSC::ExecState*);
56 #endif
57 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::ExecState*);
58 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState*);
59 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState*);
60 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState*);
61 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState*);
62 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionToJSON(JSC::ExecState*);
63
64 // Attributes
65
66 JSC::EncodedJSValue jsTestNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
67 bool setJSTestNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
68 JSC::EncodedJSValue jsTestNodeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
69 bool setJSTestNodeName(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
70
71 class JSTestNodePrototype : public JSC::JSNonFinalObject {
72 public:
73     using Base = JSC::JSNonFinalObject;
74     static JSTestNodePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
75     {
76         JSTestNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestNodePrototype>(vm.heap)) JSTestNodePrototype(vm, globalObject, structure);
77         ptr->finishCreation(vm);
78         return ptr;
79     }
80
81     DECLARE_INFO;
82     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
83     {
84         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
85     }
86
87 private:
88     JSTestNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
89         : JSC::JSNonFinalObject(vm, structure)
90     {
91     }
92
93     void finishCreation(JSC::VM&);
94 };
95
96 using JSTestNodeConstructor = JSDOMConstructor<JSTestNode>;
97
98 template<> EncodedJSValue JSC_HOST_CALL JSTestNodeConstructor::construct(ExecState* state)
99 {
100     VM& vm = state->vm();
101     auto throwScope = DECLARE_THROW_SCOPE(vm);
102     UNUSED_PARAM(throwScope);
103     auto* castedThis = jsCast<JSTestNodeConstructor*>(state->jsCallee());
104     ASSERT(castedThis);
105     auto object = TestNode::create();
106     return JSValue::encode(toJSNewlyCreated<IDLInterface<TestNode>>(*state, *castedThis->globalObject(), WTFMove(object)));
107 }
108
109 template<> JSValue JSTestNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
110 {
111     return JSNode::getConstructor(vm, &globalObject);
112 }
113
114 template<> void JSTestNodeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
115 {
116     putDirect(vm, vm.propertyNames->prototype, JSTestNode::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
117     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("TestNode"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
118     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
119 }
120
121 template<> const ClassInfo JSTestNodeConstructor::s_info = { "TestNode", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestNodeConstructor) };
122
123 /* Hash table for prototype */
124
125 static const HashTableValue JSTestNodePrototypeTableValues[] =
126 {
127     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeConstructor) } },
128     { "name", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeName), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeName) } },
129     { "testWorkerPromise", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionTestWorkerPromise), (intptr_t) (0) } },
130     { "calculateSecretResult", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionCalculateSecretResult), (intptr_t) (0) } },
131     { "getSecretBoolean", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionGetSecretBoolean), (intptr_t) (0) } },
132 #if ENABLE(TEST_FEATURE)
133     { "testFeatureGetSecretBoolean", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean), (intptr_t) (0) } },
134 #else
135     { 0, 0, NoIntrinsic, { 0, 0 } },
136 #endif
137     { "entries", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionEntries), (intptr_t) (0) } },
138     { "keys", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionKeys), (intptr_t) (0) } },
139     { "values", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionValues), (intptr_t) (0) } },
140     { "forEach", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionForEach), (intptr_t) (1) } },
141     { "toJSON", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionToJSON), (intptr_t) (0) } },
142 };
143
144 const ClassInfo JSTestNodePrototype::s_info = { "TestNodePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestNodePrototype) };
145
146 void JSTestNodePrototype::finishCreation(VM& vm)
147 {
148     Base::finishCreation(vm);
149     reifyStaticProperties(vm, JSTestNode::info(), JSTestNodePrototypeTableValues, *this);
150     if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
151         auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("calculateSecretResult"), strlen("calculateSecretResult"));
152         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
153         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
154     }
155     if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
156         auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("getSecretBoolean"), strlen("getSecretBoolean"));
157         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
158         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
159     }
160 #if ENABLE(TEST_FEATURE)
161     if (!(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())) {
162         auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("testFeatureGetSecretBoolean"), strlen("testFeatureGetSecretBoolean"));
163         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
164         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
165     }
166 #endif
167     if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
168         auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("entries"), strlen("entries"));
169         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
170         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
171     }
172     if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
173         auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("keys"), strlen("keys"));
174         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
175         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
176     }
177     if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
178         auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("values"), strlen("values"));
179         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
180         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
181     }
182     if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
183         auto propertyName = Identifier::fromString(&vm, reinterpret_cast<const LChar*>("forEach"), strlen("forEach"));
184         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
185         JSObject::deleteProperty(this, globalObject()->globalExec(), propertyName);
186     }
187     putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));
188 }
189
190 const ClassInfo JSTestNode::s_info = { "TestNode", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestNode) };
191
192 JSTestNode::JSTestNode(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestNode>&& impl)
193     : JSNode(structure, globalObject, WTFMove(impl))
194 {
195 }
196
197 void JSTestNode::finishCreation(VM& vm)
198 {
199     Base::finishCreation(vm);
200     ASSERT(inherits(vm, info()));
201
202 }
203
204 JSObject* JSTestNode::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
205 {
206     return JSTestNodePrototype::create(vm, &globalObject, JSTestNodePrototype::createStructure(vm, &globalObject, JSNode::prototype(vm, globalObject)));
207 }
208
209 JSObject* JSTestNode::prototype(VM& vm, JSDOMGlobalObject& globalObject)
210 {
211     return getDOMPrototype<JSTestNode>(vm, globalObject);
212 }
213
214 JSValue JSTestNode::getConstructor(VM& vm, const JSGlobalObject* globalObject)
215 {
216     return getDOMConstructor<JSTestNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
217 }
218
219 template<> inline JSTestNode* IDLAttribute<JSTestNode>::cast(ExecState& state, EncodedJSValue thisValue)
220 {
221     return jsDynamicCast<JSTestNode*>(state.vm(), JSValue::decode(thisValue));
222 }
223
224 template<> inline JSTestNode* IDLOperation<JSTestNode>::cast(ExecState& state)
225 {
226     return jsDynamicCast<JSTestNode*>(state.vm(), state.thisValue());
227 }
228
229 EncodedJSValue jsTestNodeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
230 {
231     VM& vm = state->vm();
232     auto throwScope = DECLARE_THROW_SCOPE(vm);
233     auto* prototype = jsDynamicCast<JSTestNodePrototype*>(vm, JSValue::decode(thisValue));
234     if (UNLIKELY(!prototype))
235         return throwVMTypeError(state, throwScope);
236     return JSValue::encode(JSTestNode::getConstructor(state->vm(), prototype->globalObject()));
237 }
238
239 bool setJSTestNodeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
240 {
241     VM& vm = state->vm();
242     auto throwScope = DECLARE_THROW_SCOPE(vm);
243     auto* prototype = jsDynamicCast<JSTestNodePrototype*>(vm, JSValue::decode(thisValue));
244     if (UNLIKELY(!prototype)) {
245         throwVMTypeError(state, throwScope);
246         return false;
247     }
248     // Shadowing a built-in constructor
249     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
250 }
251
252 static inline JSValue jsTestNodeNameGetter(ExecState& state, JSTestNode& thisObject, ThrowScope& throwScope)
253 {
254     UNUSED_PARAM(throwScope);
255     UNUSED_PARAM(state);
256     auto& impl = thisObject.wrapped();
257     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.name());
258     return result;
259 }
260
261 EncodedJSValue jsTestNodeName(ExecState* state, EncodedJSValue thisValue, PropertyName)
262 {
263     return IDLAttribute<JSTestNode>::get<jsTestNodeNameGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "name");
264 }
265
266 static inline bool setJSTestNodeNameSetter(ExecState& state, JSTestNode& thisObject, JSValue value, ThrowScope& throwScope)
267 {
268     UNUSED_PARAM(throwScope);
269     auto& impl = thisObject.wrapped();
270     auto nativeValue = convert<IDLDOMString>(state, value);
271     RETURN_IF_EXCEPTION(throwScope, false);
272     AttributeSetter::call(state, throwScope, [&] {
273         return impl.setName(WTFMove(nativeValue));
274     });
275     return true;
276 }
277
278 bool setJSTestNodeName(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
279 {
280     return IDLAttribute<JSTestNode>::set<setJSTestNodeNameSetter>(*state, thisValue, encodedValue, "name");
281 }
282
283 static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionTestWorkerPromiseBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSTestNode>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
284 {
285     UNUSED_PARAM(state);
286     UNUSED_PARAM(throwScope);
287     auto& impl = castedThis->wrapped();
288     impl.testWorkerPromise(WTFMove(promise));
289     return JSValue::encode(jsUndefined());
290 }
291
292 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestWorkerPromise(ExecState* state)
293 {
294     return IDLOperationReturningPromise<JSTestNode>::call<jsTestNodePrototypeFunctionTestWorkerPromiseBody, PromiseExecutionScope::WindowOrWorker>(*state, "testWorkerPromise");
295 }
296
297 static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionCalculateSecretResultBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSTestNode>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
298 {
299     UNUSED_PARAM(state);
300     UNUSED_PARAM(throwScope);
301     auto& impl = castedThis->wrapped();
302     impl.calculateSecretResult(WTFMove(promise));
303     return JSValue::encode(jsUndefined());
304 }
305
306 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionCalculateSecretResult(ExecState* state)
307 {
308     return IDLOperationReturningPromise<JSTestNode>::call<jsTestNodePrototypeFunctionCalculateSecretResultBody, PromiseExecutionScope::WindowOrWorker>(*state, "calculateSecretResult");
309 }
310
311 static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
312 {
313     UNUSED_PARAM(state);
314     UNUSED_PARAM(throwScope);
315     auto& impl = castedThis->wrapped();
316     return JSValue::encode(toJS<IDLBoolean>(impl.getSecretBoolean()));
317 }
318
319 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionGetSecretBoolean(ExecState* state)
320 {
321     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionGetSecretBooleanBody>(*state, "getSecretBoolean");
322 }
323
324 #if ENABLE(TEST_FEATURE)
325 static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionTestFeatureGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
326 {
327     UNUSED_PARAM(state);
328     UNUSED_PARAM(throwScope);
329     auto& impl = castedThis->wrapped();
330     return JSValue::encode(toJS<IDLBoolean>(impl.testFeatureGetSecretBoolean()));
331 }
332
333 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean(ExecState* state)
334 {
335     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionTestFeatureGetSecretBooleanBody>(*state, "testFeatureGetSecretBoolean");
336 }
337
338 #endif
339
340 struct TestNodeIteratorTraits {
341     static constexpr JSDOMIteratorType type = JSDOMIteratorType::Set;
342     using KeyType = void;
343     using ValueType = IDLInterface<TestNode>;
344 };
345
346 using TestNodeIterator = JSDOMIterator<JSTestNode, TestNodeIteratorTraits>;
347 using TestNodeIteratorPrototype = JSDOMIteratorPrototype<JSTestNode, TestNodeIteratorTraits>;
348
349 template<>
350 const JSC::ClassInfo TestNodeIterator::s_info = { "TestNode Iterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(TestNodeIterator) };
351
352 template<>
353 const JSC::ClassInfo TestNodeIteratorPrototype::s_info = { "TestNode Iterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(TestNodeIteratorPrototype) };
354
355 static inline EncodedJSValue jsTestNodePrototypeFunctionEntriesCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
356 {
357     return JSValue::encode(iteratorCreate<TestNodeIterator>(*thisObject, IterationKind::Value));
358 }
359
360 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::ExecState* state)
361 {
362     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionEntriesCaller>(*state, "entries");
363 }
364
365 static inline EncodedJSValue jsTestNodePrototypeFunctionKeysCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
366 {
367     return JSValue::encode(iteratorCreate<TestNodeIterator>(*thisObject, IterationKind::Key));
368 }
369
370 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::ExecState* state)
371 {
372     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionKeysCaller>(*state, "keys");
373 }
374
375 static inline EncodedJSValue jsTestNodePrototypeFunctionValuesCaller(ExecState*, JSTestNode* thisObject, JSC::ThrowScope&)
376 {
377     return JSValue::encode(iteratorCreate<TestNodeIterator>(*thisObject, IterationKind::Value));
378 }
379
380 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::ExecState* state)
381 {
382     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionValuesCaller>(*state, "values");
383 }
384
385 static inline EncodedJSValue jsTestNodePrototypeFunctionForEachCaller(ExecState* state, JSTestNode* thisObject, JSC::ThrowScope& throwScope)
386 {
387     return JSValue::encode(iteratorForEach<TestNodeIterator>(*state, *thisObject, throwScope));
388 }
389
390 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::ExecState* state)
391 {
392     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionForEachCaller>(*state, "forEach");
393 }
394
395 JSC::JSObject* JSTestNode::serialize(ExecState& state, JSTestNode& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope)
396 {
397     auto& vm = state.vm();
398     auto* result = constructEmptyObject(&state, globalObject.objectPrototype());
399
400     auto nameValue = jsTestNodeNameGetter(state, thisObject, throwScope);
401     throwScope.assertNoException();
402     result->putDirect(vm, Identifier::fromString(&vm, "name"), nameValue);
403
404     return result;
405 }
406
407 static inline EncodedJSValue jsTestNodePrototypeFunctionToJSONBody(ExecState* state, JSTestNode* thisObject, JSC::ThrowScope& throwScope)
408 {
409     return JSValue::encode(JSTestNode::serialize(*state, *thisObject, *thisObject->globalObject(), throwScope));
410 }
411
412 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionToJSON(ExecState* state)
413 {
414     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionToJSONBody>(*state, "toJSON");
415 }
416
417 void JSTestNode::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder)
418 {
419     auto* thisObject = jsCast<JSTestNode*>(cell);
420     builder.setWrappedObjectForCell(cell, &thisObject->wrapped());
421     if (thisObject->scriptExecutionContext())
422         builder.setLabelForCell(cell, String::format("url %s", thisObject->scriptExecutionContext()->url().string().utf8().data()));
423     Base::heapSnapshot(cell, builder);
424 }
425
426 #if ENABLE(BINDING_INTEGRITY)
427 #if PLATFORM(WIN)
428 #pragma warning(disable: 4483)
429 extern "C" { extern void (*const __identifier("??_7TestNode@WebCore@@6B@")[])(); }
430 #else
431 extern "C" { extern void* _ZTVN7WebCore8TestNodeE[]; }
432 #endif
433 #endif
434
435 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestNode>&& impl)
436 {
437
438 #if ENABLE(BINDING_INTEGRITY)
439     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
440 #if PLATFORM(WIN)
441     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7TestNode@WebCore@@6B@"));
442 #else
443     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore8TestNodeE[2]);
444 #endif
445
446     // If this fails TestNode does not have a vtable, so you need to add the
447     // ImplementationLacksVTable attribute to the interface definition
448     static_assert(std::is_polymorphic<TestNode>::value, "TestNode is not polymorphic");
449
450     // If you hit this assertion you either have a use after free bug, or
451     // TestNode has subclasses. If TestNode has subclasses that get passed
452     // to toJS() we currently require TestNode you to opt out of binding hardening
453     // by adding the SkipVTableValidation attribute to the interface IDL definition
454     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
455 #endif
456     return createWrapper<TestNode>(globalObject, WTFMove(impl));
457 }
458
459 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestNode& impl)
460 {
461     return wrap(state, globalObject, impl);
462 }
463
464
465 }