Remove unnecessary explicit parsing for mo@maxsize value "infinity"
[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 "ActiveDOMObject.h"
25 #include "DOMIsoSubspaces.h"
26 #include "JSDOMAttribute.h"
27 #include "JSDOMBinding.h"
28 #include "JSDOMConstructor.h"
29 #include "JSDOMConvertBoolean.h"
30 #include "JSDOMConvertInterface.h"
31 #include "JSDOMConvertStrings.h"
32 #include "JSDOMExceptionHandling.h"
33 #include "JSDOMIterator.h"
34 #include "JSDOMOperation.h"
35 #include "JSDOMOperationReturningPromise.h"
36 #include "JSDOMWrapperCache.h"
37 #include "JSTestNode.h"
38 #include "RuntimeEnabledFeatures.h"
39 #include "ScriptExecutionContext.h"
40 #include "WebCoreJSClientData.h"
41 #include <JavaScriptCore/BuiltinNames.h>
42 #include <JavaScriptCore/HeapAnalyzer.h>
43 #include <JavaScriptCore/JSCInlines.h>
44 #include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
45 #include <JavaScriptCore/ObjectConstructor.h>
46 #include <JavaScriptCore/SubspaceInlines.h>
47 #include <wtf/GetPtr.h>
48 #include <wtf/PointerPreparations.h>
49 #include <wtf/URL.h>
50
51
52 namespace WebCore {
53 using namespace JSC;
54
55 // Functions
56
57 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestWorkerPromise(JSC::JSGlobalObject*, JSC::CallFrame*);
58 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionCalculateSecretResult(JSC::JSGlobalObject*, JSC::CallFrame*);
59 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionGetSecretBoolean(JSC::JSGlobalObject*, JSC::CallFrame*);
60 #if ENABLE(TEST_FEATURE)
61 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean(JSC::JSGlobalObject*, JSC::CallFrame*);
62 #endif
63 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionSymbolIterator(JSC::JSGlobalObject*, JSC::CallFrame*);
64 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::JSGlobalObject*, JSC::CallFrame*);
65 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::JSGlobalObject*, JSC::CallFrame*);
66 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::JSGlobalObject*, JSC::CallFrame*);
67 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::JSGlobalObject*, JSC::CallFrame*);
68 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionToJSON(JSC::JSGlobalObject*, JSC::CallFrame*);
69
70 // Attributes
71
72 JSC::EncodedJSValue jsTestNodeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
73 bool setJSTestNodeConstructor(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
74 JSC::EncodedJSValue jsTestNodeName(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::PropertyName);
75 bool setJSTestNodeName(JSC::JSGlobalObject*, JSC::EncodedJSValue, JSC::EncodedJSValue);
76
77 class JSTestNodePrototype final : public JSC::JSNonFinalObject {
78 public:
79     using Base = JSC::JSNonFinalObject;
80     static JSTestNodePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
81     {
82         JSTestNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSTestNodePrototype>(vm.heap)) JSTestNodePrototype(vm, globalObject, structure);
83         ptr->finishCreation(vm);
84         return ptr;
85     }
86
87     DECLARE_INFO;
88     template<typename CellType, JSC::SubspaceAccess>
89     static JSC::IsoSubspace* subspaceFor(JSC::VM& vm)
90     {
91         STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTestNodePrototype, Base);
92         return &vm.plainObjectSpace;
93     }
94     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
95     {
96         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
97     }
98
99 private:
100     JSTestNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
101         : JSC::JSNonFinalObject(vm, structure)
102     {
103     }
104
105     void finishCreation(JSC::VM&);
106 };
107 STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSTestNodePrototype, JSTestNodePrototype::Base);
108
109 using JSTestNodeConstructor = JSDOMConstructor<JSTestNode>;
110
111 template<> EncodedJSValue JSC_HOST_CALL JSTestNodeConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
112 {
113     VM& vm = lexicalGlobalObject->vm();
114     auto throwScope = DECLARE_THROW_SCOPE(vm);
115     auto* castedThis = jsCast<JSTestNodeConstructor*>(callFrame->jsCallee());
116     ASSERT(castedThis);
117     auto object = TestNode::create();
118     auto jsValue = toJSNewlyCreated<IDLInterface<TestNode>>(*lexicalGlobalObject, *castedThis->globalObject(), WTFMove(object));
119     setSubclassStructureIfNeeded<TestNode>(lexicalGlobalObject, callFrame, asObject(jsValue));
120     RETURN_IF_EXCEPTION(throwScope, { });
121     return JSValue::encode(jsValue);
122 }
123
124 template<> JSValue JSTestNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
125 {
126     return JSNode::getConstructor(vm, &globalObject);
127 }
128
129 template<> void JSTestNodeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
130 {
131     putDirect(vm, vm.propertyNames->prototype, JSTestNode::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
132     putDirect(vm, vm.propertyNames->name, jsNontrivialString(vm, String("TestNode"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
133     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
134 }
135
136 template<> const ClassInfo JSTestNodeConstructor::s_info = { "TestNode", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestNodeConstructor) };
137
138 /* Hash table for prototype */
139
140 static const HashTableValue JSTestNodePrototypeTableValues[] =
141 {
142     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestNodeConstructor) } },
143     { "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) } },
144     { "testWorkerPromise", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionTestWorkerPromise), (intptr_t) (0) } },
145     { "calculateSecretResult", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionCalculateSecretResult), (intptr_t) (0) } },
146     { "getSecretBoolean", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionGetSecretBoolean), (intptr_t) (0) } },
147 #if ENABLE(TEST_FEATURE)
148     { "testFeatureGetSecretBoolean", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean), (intptr_t) (0) } },
149 #else
150     { 0, 0, NoIntrinsic, { 0, 0 } },
151 #endif
152     { "entries", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionEntries), (intptr_t) (0) } },
153     { "keys", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionKeys), (intptr_t) (0) } },
154     { "values", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionValues), (intptr_t) (0) } },
155     { "forEach", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionForEach), (intptr_t) (1) } },
156     { "toJSON", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsTestNodePrototypeFunctionToJSON), (intptr_t) (0) } },
157 };
158
159 const ClassInfo JSTestNodePrototype::s_info = { "TestNodePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestNodePrototype) };
160
161 void JSTestNodePrototype::finishCreation(VM& vm)
162 {
163     Base::finishCreation(vm);
164     reifyStaticProperties(vm, JSTestNode::info(), JSTestNodePrototypeTableValues, *this);
165     bool hasDisabledRuntimeProperties = false;
166     if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
167         hasDisabledRuntimeProperties = true;
168         auto propertyName = Identifier::fromString(vm, reinterpret_cast<const LChar*>("calculateSecretResult"), strlen("calculateSecretResult"));
169         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
170         DeletePropertySlot slot;
171         JSObject::deleteProperty(this, globalObject(), propertyName, slot);
172     }
173     if (!jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext()) {
174         hasDisabledRuntimeProperties = true;
175         auto propertyName = Identifier::fromString(vm, reinterpret_cast<const LChar*>("getSecretBoolean"), strlen("getSecretBoolean"));
176         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
177         DeletePropertySlot slot;
178         JSObject::deleteProperty(this, globalObject(), propertyName, slot);
179     }
180 #if ENABLE(TEST_FEATURE)
181     if (!(jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())) {
182         hasDisabledRuntimeProperties = true;
183         auto propertyName = Identifier::fromString(vm, reinterpret_cast<const LChar*>("testFeatureGetSecretBoolean"), strlen("testFeatureGetSecretBoolean"));
184         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
185         DeletePropertySlot slot;
186         JSObject::deleteProperty(this, globalObject(), propertyName, slot);
187     }
188 #endif
189     if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
190         hasDisabledRuntimeProperties = true;
191         auto propertyName = Identifier::fromString(vm, reinterpret_cast<const LChar*>("entries"), strlen("entries"));
192         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
193         DeletePropertySlot slot;
194         JSObject::deleteProperty(this, globalObject(), propertyName, slot);
195     }
196     if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
197         hasDisabledRuntimeProperties = true;
198         auto propertyName = Identifier::fromString(vm, reinterpret_cast<const LChar*>("keys"), strlen("keys"));
199         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
200         DeletePropertySlot slot;
201         JSObject::deleteProperty(this, globalObject(), propertyName, slot);
202     }
203     if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
204         hasDisabledRuntimeProperties = true;
205         auto propertyName = Identifier::fromString(vm, reinterpret_cast<const LChar*>("values"), strlen("values"));
206         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
207         DeletePropertySlot slot;
208         JSObject::deleteProperty(this, globalObject(), propertyName, slot);
209     }
210     if (!RuntimeEnabledFeatures::sharedFeatures().domIteratorEnabled()) {
211         hasDisabledRuntimeProperties = true;
212         auto propertyName = Identifier::fromString(vm, reinterpret_cast<const LChar*>("forEach"), strlen("forEach"));
213         VM::DeletePropertyModeScope scope(vm, VM::DeletePropertyMode::IgnoreConfigurable);
214         DeletePropertySlot slot;
215         JSObject::deleteProperty(this, globalObject(), propertyName, slot);
216     }
217     if (hasDisabledRuntimeProperties && structure()->isDictionary())
218         flattenDictionaryObject(vm);
219     putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));
220 }
221
222 const ClassInfo JSTestNode::s_info = { "TestNode", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestNode) };
223
224 JSTestNode::JSTestNode(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestNode>&& impl)
225     : JSNode(structure, globalObject, WTFMove(impl))
226 {
227 }
228
229 void JSTestNode::finishCreation(VM& vm)
230 {
231     Base::finishCreation(vm);
232     ASSERT(inherits(vm, info()));
233
234     static_assert(!std::is_base_of<ActiveDOMObject, TestNode>::value, "Interface is not marked as [ActiveDOMObject] even though implementation class subclasses ActiveDOMObject.");
235
236 }
237
238 JSObject* JSTestNode::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
239 {
240     return JSTestNodePrototype::create(vm, &globalObject, JSTestNodePrototype::createStructure(vm, &globalObject, JSNode::prototype(vm, globalObject)));
241 }
242
243 JSObject* JSTestNode::prototype(VM& vm, JSDOMGlobalObject& globalObject)
244 {
245     return getDOMPrototype<JSTestNode>(vm, globalObject);
246 }
247
248 JSValue JSTestNode::getConstructor(VM& vm, const JSGlobalObject* globalObject)
249 {
250     return getDOMConstructor<JSTestNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
251 }
252
253 template<> inline JSTestNode* IDLAttribute<JSTestNode>::cast(JSGlobalObject& lexicalGlobalObject, EncodedJSValue thisValue)
254 {
255     return jsDynamicCast<JSTestNode*>(JSC::getVM(&lexicalGlobalObject), JSValue::decode(thisValue));
256 }
257
258 template<> inline JSTestNode* IDLOperation<JSTestNode>::cast(JSGlobalObject& lexicalGlobalObject, CallFrame& callFrame)
259 {
260     return jsDynamicCast<JSTestNode*>(JSC::getVM(&lexicalGlobalObject), callFrame.thisValue());
261 }
262
263 EncodedJSValue jsTestNodeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)
264 {
265     VM& vm = JSC::getVM(lexicalGlobalObject);
266     auto throwScope = DECLARE_THROW_SCOPE(vm);
267     auto* prototype = jsDynamicCast<JSTestNodePrototype*>(vm, JSValue::decode(thisValue));
268     if (UNLIKELY(!prototype))
269         return throwVMTypeError(lexicalGlobalObject, throwScope);
270     return JSValue::encode(JSTestNode::getConstructor(JSC::getVM(lexicalGlobalObject), prototype->globalObject()));
271 }
272
273 bool setJSTestNodeConstructor(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
274 {
275     VM& vm = JSC::getVM(lexicalGlobalObject);
276     auto throwScope = DECLARE_THROW_SCOPE(vm);
277     auto* prototype = jsDynamicCast<JSTestNodePrototype*>(vm, JSValue::decode(thisValue));
278     if (UNLIKELY(!prototype)) {
279         throwVMTypeError(lexicalGlobalObject, throwScope);
280         return false;
281     }
282     // Shadowing a built-in constructor
283     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
284 }
285
286 static inline JSValue jsTestNodeNameGetter(JSGlobalObject& lexicalGlobalObject, JSTestNode& thisObject, ThrowScope& throwScope)
287 {
288     UNUSED_PARAM(throwScope);
289     UNUSED_PARAM(lexicalGlobalObject);
290     auto& impl = thisObject.wrapped();
291     JSValue result = toJS<IDLDOMString>(lexicalGlobalObject, throwScope, impl.name());
292     return result;
293 }
294
295 EncodedJSValue jsTestNodeName(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)
296 {
297     return IDLAttribute<JSTestNode>::get<jsTestNodeNameGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, "name");
298 }
299
300 static inline bool setJSTestNodeNameSetter(JSGlobalObject& lexicalGlobalObject, JSTestNode& thisObject, JSValue value, ThrowScope& throwScope)
301 {
302     UNUSED_PARAM(lexicalGlobalObject);
303     UNUSED_PARAM(throwScope);
304     auto& impl = thisObject.wrapped();
305     auto nativeValue = convert<IDLDOMString>(lexicalGlobalObject, value);
306     RETURN_IF_EXCEPTION(throwScope, false);
307     AttributeSetter::call(lexicalGlobalObject, throwScope, [&] {
308         return impl.setName(WTFMove(nativeValue));
309     });
310     return true;
311 }
312
313 bool setJSTestNodeName(JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue)
314 {
315     return IDLAttribute<JSTestNode>::set<setJSTestNodeNameSetter>(*lexicalGlobalObject, thisValue, encodedValue, "name");
316 }
317
318 static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionTestWorkerPromiseBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperationReturningPromise<JSTestNode>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
319 {
320     UNUSED_PARAM(lexicalGlobalObject);
321     UNUSED_PARAM(callFrame);
322     UNUSED_PARAM(throwScope);
323     auto& impl = castedThis->wrapped();
324     impl.testWorkerPromise(WTFMove(promise));
325     return JSValue::encode(jsUndefined());
326 }
327
328 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestWorkerPromise(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
329 {
330     return IDLOperationReturningPromise<JSTestNode>::call<jsTestNodePrototypeFunctionTestWorkerPromiseBody>(*lexicalGlobalObject, *callFrame, "testWorkerPromise");
331 }
332
333 static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionCalculateSecretResultBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperationReturningPromise<JSTestNode>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
334 {
335     UNUSED_PARAM(lexicalGlobalObject);
336     UNUSED_PARAM(callFrame);
337     UNUSED_PARAM(throwScope);
338     auto& impl = castedThis->wrapped();
339     impl.calculateSecretResult(WTFMove(promise));
340     return JSValue::encode(jsUndefined());
341 }
342
343 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionCalculateSecretResult(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
344 {
345     return IDLOperationReturningPromise<JSTestNode>::call<jsTestNodePrototypeFunctionCalculateSecretResultBody>(*lexicalGlobalObject, *callFrame, "calculateSecretResult");
346 }
347
348 static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionGetSecretBooleanBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
349 {
350     UNUSED_PARAM(lexicalGlobalObject);
351     UNUSED_PARAM(callFrame);
352     UNUSED_PARAM(throwScope);
353     auto& impl = castedThis->wrapped();
354     auto result = JSValue::encode(toJS<IDLBoolean>(impl.getSecretBoolean()));
355     return result;
356 }
357
358 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionGetSecretBoolean(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
359 {
360     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionGetSecretBooleanBody>(*lexicalGlobalObject, *callFrame, "getSecretBoolean");
361 }
362
363 #if ENABLE(TEST_FEATURE)
364 static inline JSC::EncodedJSValue jsTestNodePrototypeFunctionTestFeatureGetSecretBooleanBody(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame, typename IDLOperation<JSTestNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
365 {
366     UNUSED_PARAM(lexicalGlobalObject);
367     UNUSED_PARAM(callFrame);
368     UNUSED_PARAM(throwScope);
369     auto& impl = castedThis->wrapped();
370     auto result = JSValue::encode(toJS<IDLBoolean>(impl.testFeatureGetSecretBoolean()));
371     return result;
372 }
373
374 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestFeatureGetSecretBoolean(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
375 {
376     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionTestFeatureGetSecretBooleanBody>(*lexicalGlobalObject, *callFrame, "testFeatureGetSecretBoolean");
377 }
378
379 #endif
380
381 struct TestNodeIteratorTraits {
382     static constexpr JSDOMIteratorType type = JSDOMIteratorType::Set;
383     using KeyType = void;
384     using ValueType = IDLInterface<TestNode>;
385 };
386
387 using TestNodeIteratorBase = JSDOMIteratorBase<JSTestNode, TestNodeIteratorTraits>;
388 class TestNodeIterator final : public TestNodeIteratorBase {
389 public:
390     using Base = TestNodeIteratorBase;
391     DECLARE_INFO;
392
393     template<typename, JSC::SubspaceAccess mode> static JSC::IsoSubspace* subspaceFor(JSC::VM& vm)
394     {
395         if constexpr (mode == JSC::SubspaceAccess::Concurrently)
396             return nullptr;
397         auto& clientData = *static_cast<JSVMClientData*>(vm.clientData);
398         auto& spaces = clientData.subspaces();
399         if (auto* space = spaces.m_subspaceForTestNodeIterator.get())
400             return space;
401         static_assert(std::is_base_of_v<JSC::JSDestructibleObject, TestNodeIterator> || !TestNodeIterator::needsDestruction);
402         if constexpr (std::is_base_of_v<JSC::JSDestructibleObject, TestNodeIterator>)
403             spaces.m_subspaceForTestNodeIterator = makeUnique<IsoSubspace> ISO_SUBSPACE_INIT(vm.heap, vm.destructibleObjectHeapCellType.get(), TestNodeIterator);
404         else
405             spaces.m_subspaceForTestNodeIterator = makeUnique<IsoSubspace> ISO_SUBSPACE_INIT(vm.heap, vm.cellHeapCellType.get(), TestNodeIterator);
406         auto* space = spaces.m_subspaceForTestNodeIterator.get();
407 IGNORE_WARNINGS_BEGIN("unreachable-code")
408 IGNORE_WARNINGS_BEGIN("tautological-compare")
409         if (&TestNodeIterator::visitOutputConstraints != &JSC::JSCell::visitOutputConstraints)
410             clientData.outputConstraintSpaces().append(space);
411 IGNORE_WARNINGS_END
412 IGNORE_WARNINGS_END
413         return space;
414     }
415
416     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
417     {
418         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
419     }
420
421     static TestNodeIterator* create(JSC::VM& vm, JSC::Structure* structure, JSTestNode& iteratedObject, IterationKind kind)
422     {
423         auto* instance = new (NotNull, JSC::allocateCell<TestNodeIterator>(vm.heap)) TestNodeIterator(structure, iteratedObject, kind);
424         instance->finishCreation(vm);
425         return instance;
426     }
427
428 private:
429     TestNodeIterator(JSC::Structure* structure, JSTestNode& iteratedObject, IterationKind kind)
430         : Base(structure, iteratedObject, kind)
431     {
432     }
433 };
434
435 using TestNodeIteratorPrototype = JSDOMIteratorPrototype<JSTestNode, TestNodeIteratorTraits>;
436
437 template<>
438 const JSC::ClassInfo TestNodeIteratorBase::s_info = { "TestNode Iterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(TestNodeIteratorBase) };
439 const JSC::ClassInfo TestNodeIterator::s_info = { "TestNode Iterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(TestNodeIterator) };
440
441 template<>
442 const JSC::ClassInfo TestNodeIteratorPrototype::s_info = { "TestNode Iterator", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(TestNodeIteratorPrototype) };
443
444 static inline EncodedJSValue jsTestNodePrototypeFunctionEntriesCaller(JSGlobalObject*, CallFrame*, JSTestNode* thisObject, JSC::ThrowScope&)
445 {
446     return JSValue::encode(iteratorCreate<TestNodeIterator>(*thisObject, IterationKind::Values));
447 }
448
449 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionEntries(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
450 {
451     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionEntriesCaller>(*lexicalGlobalObject, *callFrame, "entries");
452 }
453
454 static inline EncodedJSValue jsTestNodePrototypeFunctionKeysCaller(JSGlobalObject*, CallFrame*, JSTestNode* thisObject, JSC::ThrowScope&)
455 {
456     return JSValue::encode(iteratorCreate<TestNodeIterator>(*thisObject, IterationKind::Keys));
457 }
458
459 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionKeys(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
460 {
461     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionKeysCaller>(*lexicalGlobalObject, *callFrame, "keys");
462 }
463
464 static inline EncodedJSValue jsTestNodePrototypeFunctionValuesCaller(JSGlobalObject*, CallFrame*, JSTestNode* thisObject, JSC::ThrowScope&)
465 {
466     return JSValue::encode(iteratorCreate<TestNodeIterator>(*thisObject, IterationKind::Values));
467 }
468
469 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionValues(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
470 {
471     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionValuesCaller>(*lexicalGlobalObject, *callFrame, "values");
472 }
473
474 static inline EncodedJSValue jsTestNodePrototypeFunctionForEachCaller(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame, JSTestNode* thisObject, JSC::ThrowScope& throwScope)
475 {
476     return JSValue::encode(iteratorForEach<TestNodeIterator>(*lexicalGlobalObject, *callFrame, *thisObject, throwScope));
477 }
478
479 JSC::EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionForEach(JSC::JSGlobalObject* lexicalGlobalObject, JSC::CallFrame* callFrame)
480 {
481     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionForEachCaller>(*lexicalGlobalObject, *callFrame, "forEach");
482 }
483
484 JSC::JSObject* JSTestNode::serialize(JSGlobalObject& lexicalGlobalObject, JSTestNode& thisObject, JSDOMGlobalObject& globalObject, ThrowScope& throwScope)
485 {
486     auto& vm = JSC::getVM(&lexicalGlobalObject);
487     auto* result = constructEmptyObject(&lexicalGlobalObject, globalObject.objectPrototype());
488
489     auto nameValue = jsTestNodeNameGetter(lexicalGlobalObject, thisObject, throwScope);
490     throwScope.assertNoException();
491     result->putDirect(vm, Identifier::fromString(vm, "name"), nameValue);
492
493     return result;
494 }
495
496 static inline EncodedJSValue jsTestNodePrototypeFunctionToJSONBody(JSGlobalObject* lexicalGlobalObject, CallFrame*, JSTestNode* thisObject, JSC::ThrowScope& throwScope)
497 {
498     return JSValue::encode(JSTestNode::serialize(*lexicalGlobalObject, *thisObject, *thisObject->globalObject(), throwScope));
499 }
500
501 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionToJSON(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)
502 {
503     return IDLOperation<JSTestNode>::call<jsTestNodePrototypeFunctionToJSONBody>(*lexicalGlobalObject, *callFrame, "toJSON");
504 }
505
506 JSC::IsoSubspace* JSTestNode::subspaceForImpl(JSC::VM& vm)
507 {
508     auto& clientData = *static_cast<JSVMClientData*>(vm.clientData);
509     auto& spaces = clientData.subspaces();
510     if (auto* space = spaces.m_subspaceForTestNode.get())
511         return space;
512     static_assert(std::is_base_of_v<JSC::JSDestructibleObject, JSTestNode> || !JSTestNode::needsDestruction);
513     if constexpr (std::is_base_of_v<JSC::JSDestructibleObject, JSTestNode>)
514         spaces.m_subspaceForTestNode = makeUnique<IsoSubspace> ISO_SUBSPACE_INIT(vm.heap, vm.destructibleObjectHeapCellType.get(), JSTestNode);
515     else
516         spaces.m_subspaceForTestNode = makeUnique<IsoSubspace> ISO_SUBSPACE_INIT(vm.heap, vm.cellHeapCellType.get(), JSTestNode);
517     auto* space = spaces.m_subspaceForTestNode.get();
518 IGNORE_WARNINGS_BEGIN("unreachable-code")
519 IGNORE_WARNINGS_BEGIN("tautological-compare")
520     if (&JSTestNode::visitOutputConstraints != &JSC::JSCell::visitOutputConstraints)
521         clientData.outputConstraintSpaces().append(space);
522 IGNORE_WARNINGS_END
523 IGNORE_WARNINGS_END
524     return space;
525 }
526
527 void JSTestNode::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
528 {
529     auto* thisObject = jsCast<JSTestNode*>(cell);
530     analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
531     if (thisObject->scriptExecutionContext())
532         analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
533     Base::analyzeHeap(cell, analyzer);
534 }
535
536 #if ENABLE(BINDING_INTEGRITY)
537 #if PLATFORM(WIN)
538 #pragma warning(disable: 4483)
539 extern "C" { extern void (*const __identifier("??_7TestNode@WebCore@@6B@")[])(); }
540 #else
541 extern "C" { extern void* _ZTVN7WebCore8TestNodeE[]; }
542 #endif
543 #endif
544
545 JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<TestNode>&& impl)
546 {
547
548 #if ENABLE(BINDING_INTEGRITY)
549     const void* actualVTablePointer = getVTablePointer(impl.ptr());
550 #if PLATFORM(WIN)
551     void* expectedVTablePointer = __identifier("??_7TestNode@WebCore@@6B@");
552 #else
553     void* expectedVTablePointer = &_ZTVN7WebCore8TestNodeE[2];
554 #endif
555
556     // If this fails TestNode does not have a vtable, so you need to add the
557     // ImplementationLacksVTable attribute to the interface definition
558     static_assert(std::is_polymorphic<TestNode>::value, "TestNode is not polymorphic");
559
560     // If you hit this assertion you either have a use after free bug, or
561     // TestNode has subclasses. If TestNode has subclasses that get passed
562     // to toJS() we currently require TestNode you to opt out of binding hardening
563     // by adding the SkipVTableValidation attribute to the interface IDL definition
564     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
565 #endif
566     return createWrapper<TestNode>(globalObject, WTFMove(impl));
567 }
568
569 JSC::JSValue toJS(JSC::JSGlobalObject* lexicalGlobalObject, JSDOMGlobalObject* globalObject, TestNode& impl)
570 {
571     return wrap(lexicalGlobalObject, globalObject, impl);
572 }
573
574
575 }