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