[WebIDL] Remove GetterMayThrowException
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSTestGlobalObject.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 "JSTestGlobalObject.h"
23
24 #include "DOMWrapperWorld.h"
25 #include "JSDOMAttribute.h"
26 #include "JSDOMBinding.h"
27 #include "JSDOMConstructorNotConstructable.h"
28 #include "JSDOMConvertBoolean.h"
29 #include "JSDOMConvertNumbers.h"
30 #include "JSDOMConvertStrings.h"
31 #include "JSDOMExceptionHandling.h"
32 #include "JSDOMOperation.h"
33 #include "JSDOMOperationReturningPromise.h"
34 #include "JSDOMWrapperCache.h"
35 #include "RuntimeEnabledFeatures.h"
36 #include "ScriptExecutionContext.h"
37 #include "WebCoreJSClientData.h"
38 #include <runtime/FunctionPrototype.h>
39 #include <runtime/JSCInlines.h>
40 #include <wtf/GetPtr.h>
41
42 #if ENABLE(TEST_FEATURE)
43 #include "TestGlobalObjectBuiltins.h"
44 #endif
45
46 using namespace JSC;
47
48 namespace WebCore {
49
50 // Functions
51
52 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionRegularOperation(JSC::ExecState*);
53 #if ENABLE(TEST_FEATURE)
54 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation(JSC::ExecState*);
55 #endif
56 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorld(JSC::ExecState*);
57 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeatureEnabled(JSC::ExecState*);
58 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeaturesEnabled(JSC::ExecState*);
59 #if ENABLE(TEST_FEATURE)
60 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(JSC::ExecState*);
61 #endif
62 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionCalculateSecretResult(JSC::ExecState*);
63 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionGetSecretBoolean(JSC::ExecState*);
64 #if ENABLE(TEST_FEATURE)
65 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBoolean(JSC::ExecState*);
66 #endif
67
68 // Attributes
69
70 JSC::EncodedJSValue jsTestGlobalObjectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
71 bool setJSTestGlobalObjectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
72 JSC::EncodedJSValue jsTestGlobalObjectRegularAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
73 bool setJSTestGlobalObjectRegularAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
74 JSC::EncodedJSValue jsTestGlobalObjectPublicAndPrivateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
75 bool setJSTestGlobalObjectPublicAndPrivateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
76 #if ENABLE(TEST_FEATURE)
77 JSC::EncodedJSValue jsTestGlobalObjectPublicAndPrivateConditionalAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
78 bool setJSTestGlobalObjectPublicAndPrivateConditionalAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
79 #endif
80 #if ENABLE(TEST_FEATURE)
81 JSC::EncodedJSValue jsTestGlobalObjectEnabledAtRuntimeAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
82 bool setJSTestGlobalObjectEnabledAtRuntimeAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
83 #endif
84
85 using JSTestGlobalObjectConstructor = JSDOMConstructorNotConstructable<JSTestGlobalObject>;
86
87 /* Hash table */
88
89 static const struct CompactHashIndex JSTestGlobalObjectTableIndex[16] = {
90     { -1, -1 },
91     { -1, -1 },
92     { 2, -1 },
93     { 0, -1 },
94     { -1, -1 },
95     { -1, -1 },
96     { -1, -1 },
97     { -1, -1 },
98     { -1, -1 },
99     { 3, -1 },
100     { -1, -1 },
101     { -1, -1 },
102     { -1, -1 },
103     { -1, -1 },
104     { 1, -1 },
105     { -1, -1 },
106 };
107
108
109 static const HashTableValue JSTestGlobalObjectTableValues[] =
110 {
111     { "regularAttribute", CustomAccessor | DOMAttribute, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectRegularAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectRegularAttribute) } },
112     { "publicAndPrivateAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectPublicAndPrivateAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectPublicAndPrivateAttribute) } },
113 #if ENABLE(TEST_FEATURE)
114     { "publicAndPrivateConditionalAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectPublicAndPrivateConditionalAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectPublicAndPrivateConditionalAttribute) } },
115 #else
116     { 0, 0, NoIntrinsic, { 0, 0 } },
117 #endif
118     { "regularOperation", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestGlobalObjectInstanceFunctionRegularOperation), (intptr_t) (1) } },
119 };
120
121 static const HashTable JSTestGlobalObjectTable = { 4, 15, true, JSTestGlobalObject::info(), JSTestGlobalObjectTableValues, JSTestGlobalObjectTableIndex };
122 template<> JSValue JSTestGlobalObjectConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
123 {
124     UNUSED_PARAM(vm);
125     return globalObject.functionPrototype();
126 }
127
128 template<> void JSTestGlobalObjectConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
129 {
130     putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(), DontDelete | ReadOnly | DontEnum);
131     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestGlobalObject"))), ReadOnly | DontEnum);
132     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
133 }
134
135 template<> const ClassInfo JSTestGlobalObjectConstructor::s_info = { "TestGlobalObject", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSTestGlobalObjectConstructor) };
136
137 /* Hash table for prototype */
138
139 static const struct CompactHashIndex JSTestGlobalObjectPrototypeTableIndex[2] = {
140     { -1, -1 },
141     { 0, -1 },
142 };
143
144
145 static const HashTableValue JSTestGlobalObjectPrototypeTableValues[] =
146 {
147     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectConstructor) } },
148 };
149
150 static const HashTable JSTestGlobalObjectPrototypeTable = { 1, 1, true, JSTestGlobalObject::info(), JSTestGlobalObjectPrototypeTableValues, JSTestGlobalObjectPrototypeTableIndex };
151 const ClassInfo JSTestGlobalObjectPrototype::s_info = { "TestGlobalObjectPrototype", &Base::s_info, &JSTestGlobalObjectPrototypeTable, nullptr, CREATE_METHOD_TABLE(JSTestGlobalObjectPrototype) };
152
153 const ClassInfo JSTestGlobalObject::s_info = { "TestGlobalObject", &Base::s_info, &JSTestGlobalObjectTable, nullptr, CREATE_METHOD_TABLE(JSTestGlobalObject) };
154
155 JSTestGlobalObject::JSTestGlobalObject(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestGlobalObject>&& impl)
156     : JSDOMWrapper<TestGlobalObject>(structure, globalObject, WTFMove(impl))
157 {
158 }
159
160 void JSTestGlobalObject::finishCreation(VM& vm)
161 {
162     Base::finishCreation(vm);
163     ASSERT(inherits(vm, info()));
164
165 #if ENABLE(TEST_FEATURE)
166     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
167         putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().enabledAtRuntimeAttributePublicName(), CustomGetterSetter::create(vm, jsTestGlobalObjectEnabledAtRuntimeAttribute, setJSTestGlobalObjectEnabledAtRuntimeAttribute), attributesForStructure(CustomAccessor));
168 #endif
169     putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().publicAndPrivateAttributePrivateName(), CustomGetterSetter::create(vm, jsTestGlobalObjectPublicAndPrivateAttribute, nullptr), attributesForStructure(DontDelete | ReadOnly));
170 #if ENABLE(TEST_FEATURE)
171     putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().publicAndPrivateConditionalAttributePrivateName(), CustomGetterSetter::create(vm, jsTestGlobalObjectPublicAndPrivateConditionalAttribute, nullptr), attributesForStructure(DontDelete | ReadOnly));
172 #endif
173 #if ENABLE(TEST_FEATURE)
174     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
175         putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().enabledAtRuntimeOperationPublicName(), 1, jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation, NoIntrinsic, attributesForStructure(JSC::Function));
176 #endif
177     if (worldForDOMObject(this).specificWorld())
178         putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().enabledInSpecificWorldPublicName(), 1, jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorld, NoIntrinsic, attributesForStructure(JSC::Function));
179     if ((worldForDOMObject(this).specificWorld() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()))
180         putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().enabledInSpecificWorldWhenRuntimeFeatureEnabledPublicName(), 1, jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeatureEnabled, NoIntrinsic, attributesForStructure(JSC::Function));
181     if ((worldForDOMObject(this).specificWorld() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled() && RuntimeEnabledFeatures::sharedFeatures().testFeature1Enabled()))
182         putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().enabledInSpecificWorldWhenRuntimeFeaturesEnabledPublicName(), 1, jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeaturesEnabled, NoIntrinsic, attributesForStructure(JSC::Function));
183 #if ENABLE(TEST_FEATURE)
184     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
185         putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().testPrivateFunctionPrivateName(), 0, jsTestGlobalObjectInstanceFunctionTestPrivateFunction, NoIntrinsic, attributesForStructure(JSC::Function));
186 #endif
187 #if ENABLE(TEST_FEATURE)
188     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
189         putDirectBuiltinFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().testJSBuiltinFunctionPublicName(), testGlobalObjectTestJSBuiltinFunctionCodeGenerator(vm), attributesForStructure(JSC::Builtin));
190 #endif
191     if (jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext())
192         putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().calculateSecretResultPublicName(), 0, jsTestGlobalObjectInstanceFunctionCalculateSecretResult, NoIntrinsic, attributesForStructure(JSC::Function));
193     if (jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext())
194         putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().getSecretBooleanPublicName(), 0, jsTestGlobalObjectInstanceFunctionGetSecretBoolean, NoIntrinsic, attributesForStructure(JSC::Function));
195 #if ENABLE(TEST_FEATURE)
196     if ((jsCast<JSDOMGlobalObject*>(globalObject())->scriptExecutionContext()->isSecureContext() && RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()))
197         putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().testFeatureGetSecretBooleanPublicName(), 0, jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBoolean, NoIntrinsic, attributesForStructure(JSC::Function));
198 #endif
199 }
200
201 JSValue JSTestGlobalObject::getConstructor(VM& vm, const JSGlobalObject* globalObject)
202 {
203     return getDOMConstructor<JSTestGlobalObjectConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
204 }
205
206 void JSTestGlobalObject::destroy(JSC::JSCell* cell)
207 {
208     JSTestGlobalObject* thisObject = static_cast<JSTestGlobalObject*>(cell);
209     thisObject->JSTestGlobalObject::~JSTestGlobalObject();
210 }
211
212 template<> inline JSTestGlobalObject* IDLAttribute<JSTestGlobalObject>::cast(ExecState& state, EncodedJSValue thisValue)
213 {
214     return jsDynamicDowncast<JSTestGlobalObject*>(state.vm(), JSValue::decode(thisValue));
215 }
216
217 template<> inline JSTestGlobalObject* IDLOperation<JSTestGlobalObject>::cast(ExecState& state)
218 {
219     return jsDynamicDowncast<JSTestGlobalObject*>(state.vm(), state.thisValue());
220 }
221
222 EncodedJSValue jsTestGlobalObjectConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
223 {
224     VM& vm = state->vm();
225     auto throwScope = DECLARE_THROW_SCOPE(vm);
226     auto* prototype = jsDynamicDowncast<JSTestGlobalObjectPrototype*>(vm, JSValue::decode(thisValue));
227     if (UNLIKELY(!prototype))
228         return throwVMTypeError(state, throwScope);
229     return JSValue::encode(JSTestGlobalObject::getConstructor(state->vm(), prototype->globalObject()));
230 }
231
232 bool setJSTestGlobalObjectConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
233 {
234     VM& vm = state->vm();
235     auto throwScope = DECLARE_THROW_SCOPE(vm);
236     auto* prototype = jsDynamicDowncast<JSTestGlobalObjectPrototype*>(vm, JSValue::decode(thisValue));
237     if (UNLIKELY(!prototype)) {
238         throwVMTypeError(state, throwScope);
239         return false;
240     }
241     // Shadowing a built-in constructor
242     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
243 }
244
245 static inline JSValue jsTestGlobalObjectRegularAttributeGetter(ExecState& state, JSTestGlobalObject& thisObject, ThrowScope& throwScope)
246 {
247     UNUSED_PARAM(throwScope);
248     UNUSED_PARAM(state);
249     auto& impl = thisObject.wrapped();
250     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.regularAttribute());
251     return result;
252 }
253
254 EncodedJSValue jsTestGlobalObjectRegularAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
255 {
256     return IDLAttribute<JSTestGlobalObject>::get<jsTestGlobalObjectRegularAttributeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "regularAttribute");
257 }
258
259 static inline bool setJSTestGlobalObjectRegularAttributeSetter(ExecState& state, JSTestGlobalObject& thisObject, JSValue value, ThrowScope& throwScope)
260 {
261     UNUSED_PARAM(throwScope);
262     auto& impl = thisObject.wrapped();
263     auto nativeValue = convert<IDLDOMString>(state, value);
264     RETURN_IF_EXCEPTION(throwScope, false);
265     AttributeSetter::call(state, throwScope, [&] {
266         return impl.setRegularAttribute(WTFMove(nativeValue));
267     });
268     return true;
269 }
270
271 bool setJSTestGlobalObjectRegularAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
272 {
273     return IDLAttribute<JSTestGlobalObject>::set<setJSTestGlobalObjectRegularAttributeSetter>(*state, thisValue, encodedValue, "regularAttribute");
274 }
275
276 static inline JSValue jsTestGlobalObjectPublicAndPrivateAttributeGetter(ExecState& state, JSTestGlobalObject& thisObject, ThrowScope& throwScope)
277 {
278     UNUSED_PARAM(throwScope);
279     UNUSED_PARAM(state);
280     auto& impl = thisObject.wrapped();
281     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.publicAndPrivateAttribute());
282     return result;
283 }
284
285 EncodedJSValue jsTestGlobalObjectPublicAndPrivateAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
286 {
287     return IDLAttribute<JSTestGlobalObject>::get<jsTestGlobalObjectPublicAndPrivateAttributeGetter>(*state, thisValue, "publicAndPrivateAttribute");
288 }
289
290 static inline bool setJSTestGlobalObjectPublicAndPrivateAttributeSetter(ExecState& state, JSTestGlobalObject& thisObject, JSValue value, ThrowScope& throwScope)
291 {
292     UNUSED_PARAM(throwScope);
293     auto& impl = thisObject.wrapped();
294     auto nativeValue = convert<IDLDOMString>(state, value);
295     RETURN_IF_EXCEPTION(throwScope, false);
296     AttributeSetter::call(state, throwScope, [&] {
297         return impl.setPublicAndPrivateAttribute(WTFMove(nativeValue));
298     });
299     return true;
300 }
301
302 bool setJSTestGlobalObjectPublicAndPrivateAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
303 {
304     return IDLAttribute<JSTestGlobalObject>::set<setJSTestGlobalObjectPublicAndPrivateAttributeSetter>(*state, thisValue, encodedValue, "publicAndPrivateAttribute");
305 }
306
307 #if ENABLE(TEST_FEATURE)
308 static inline JSValue jsTestGlobalObjectPublicAndPrivateConditionalAttributeGetter(ExecState& state, JSTestGlobalObject& thisObject, ThrowScope& throwScope)
309 {
310     UNUSED_PARAM(throwScope);
311     UNUSED_PARAM(state);
312     auto& impl = thisObject.wrapped();
313     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.publicAndPrivateConditionalAttribute());
314     return result;
315 }
316
317 EncodedJSValue jsTestGlobalObjectPublicAndPrivateConditionalAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
318 {
319     return IDLAttribute<JSTestGlobalObject>::get<jsTestGlobalObjectPublicAndPrivateConditionalAttributeGetter>(*state, thisValue, "publicAndPrivateConditionalAttribute");
320 }
321
322 #endif
323
324 #if ENABLE(TEST_FEATURE)
325 static inline bool setJSTestGlobalObjectPublicAndPrivateConditionalAttributeSetter(ExecState& state, JSTestGlobalObject& thisObject, JSValue value, ThrowScope& throwScope)
326 {
327     UNUSED_PARAM(throwScope);
328     auto& impl = thisObject.wrapped();
329     auto nativeValue = convert<IDLDOMString>(state, value);
330     RETURN_IF_EXCEPTION(throwScope, false);
331     AttributeSetter::call(state, throwScope, [&] {
332         return impl.setPublicAndPrivateConditionalAttribute(WTFMove(nativeValue));
333     });
334     return true;
335 }
336
337 bool setJSTestGlobalObjectPublicAndPrivateConditionalAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
338 {
339     return IDLAttribute<JSTestGlobalObject>::set<setJSTestGlobalObjectPublicAndPrivateConditionalAttributeSetter>(*state, thisValue, encodedValue, "publicAndPrivateConditionalAttribute");
340 }
341
342 #endif
343
344 #if ENABLE(TEST_FEATURE)
345 static inline JSValue jsTestGlobalObjectEnabledAtRuntimeAttributeGetter(ExecState& state, JSTestGlobalObject& thisObject, ThrowScope& throwScope)
346 {
347     UNUSED_PARAM(throwScope);
348     UNUSED_PARAM(state);
349     auto& impl = thisObject.wrapped();
350     JSValue result = toJS<IDLDOMString>(state, throwScope, impl.enabledAtRuntimeAttribute());
351     return result;
352 }
353
354 EncodedJSValue jsTestGlobalObjectEnabledAtRuntimeAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
355 {
356     return IDLAttribute<JSTestGlobalObject>::get<jsTestGlobalObjectEnabledAtRuntimeAttributeGetter>(*state, thisValue, "enabledAtRuntimeAttribute");
357 }
358
359 #endif
360
361 #if ENABLE(TEST_FEATURE)
362 static inline bool setJSTestGlobalObjectEnabledAtRuntimeAttributeSetter(ExecState& state, JSTestGlobalObject& thisObject, JSValue value, ThrowScope& throwScope)
363 {
364     UNUSED_PARAM(throwScope);
365     auto& impl = thisObject.wrapped();
366     auto nativeValue = convert<IDLDOMString>(state, value);
367     RETURN_IF_EXCEPTION(throwScope, false);
368     AttributeSetter::call(state, throwScope, [&] {
369         return impl.setEnabledAtRuntimeAttribute(WTFMove(nativeValue));
370     });
371     return true;
372 }
373
374 bool setJSTestGlobalObjectEnabledAtRuntimeAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
375 {
376     return IDLAttribute<JSTestGlobalObject>::set<setJSTestGlobalObjectEnabledAtRuntimeAttributeSetter>(*state, thisValue, encodedValue, "enabledAtRuntimeAttribute");
377 }
378
379 #endif
380
381 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionRegularOperationBody(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
382 {
383     UNUSED_PARAM(state);
384     UNUSED_PARAM(throwScope);
385     auto& impl = castedThis->wrapped();
386     if (UNLIKELY(state->argumentCount() < 1))
387         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
388     auto testParam = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
389     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
390     impl.regularOperation(WTFMove(testParam));
391     return JSValue::encode(jsUndefined());
392 }
393
394 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionRegularOperation(ExecState* state)
395 {
396     return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionRegularOperationBody>(*state, "regularOperation");
397 }
398
399 #if ENABLE(TEST_FEATURE)
400 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation1Body(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
401 {
402     UNUSED_PARAM(state);
403     UNUSED_PARAM(throwScope);
404     auto& impl = castedThis->wrapped();
405     auto testParam = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
406     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
407     impl.enabledAtRuntimeOperation(WTFMove(testParam));
408     return JSValue::encode(jsUndefined());
409 }
410
411 #endif
412
413 #if ENABLE(TEST_FEATURE)
414 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2Body(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
415 {
416     UNUSED_PARAM(state);
417     UNUSED_PARAM(throwScope);
418     auto& impl = castedThis->wrapped();
419     auto testParam = convert<IDLLong>(*state, state->uncheckedArgument(0));
420     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
421     impl.enabledAtRuntimeOperation(WTFMove(testParam));
422     return JSValue::encode(jsUndefined());
423 }
424
425 #endif
426
427 #if ENABLE(TEST_FEATURE)
428
429 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperationOverloadDispatcher(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
430 {
431     UNUSED_PARAM(state);
432     UNUSED_PARAM(throwScope);
433     VM& vm = state->vm();
434     UNUSED_PARAM(vm);
435     size_t argsCount = std::min<size_t>(1, state->argumentCount());
436     if (argsCount == 1) {
437         JSValue distinguishingArg = state->uncheckedArgument(0);
438 #if ENABLE(TEST_FEATURE)
439         if (distinguishingArg.isNumber())
440             return jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2Body(state, castedThis, throwScope);
441 #endif
442 #if ENABLE(TEST_FEATURE)
443         return jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation1Body(state, castedThis, throwScope);
444 #endif
445     }
446     return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope);
447 }
448
449 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation(ExecState* state)
450 {
451     return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperationOverloadDispatcher>(*state, "enabledAtRuntimeOperation");
452 }
453
454 #endif
455
456 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldBody(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
457 {
458     UNUSED_PARAM(state);
459     UNUSED_PARAM(throwScope);
460     auto& impl = castedThis->wrapped();
461     if (UNLIKELY(state->argumentCount() < 1))
462         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
463     auto testParam = convert<IDLLong>(*state, state->uncheckedArgument(0));
464     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
465     impl.enabledInSpecificWorld(WTFMove(testParam));
466     return JSValue::encode(jsUndefined());
467 }
468
469 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorld(ExecState* state)
470 {
471     return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldBody>(*state, "enabledInSpecificWorld");
472 }
473
474 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeatureEnabledBody(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
475 {
476     UNUSED_PARAM(state);
477     UNUSED_PARAM(throwScope);
478     auto& impl = castedThis->wrapped();
479     if (UNLIKELY(state->argumentCount() < 1))
480         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
481     auto testParam = convert<IDLLong>(*state, state->uncheckedArgument(0));
482     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
483     impl.enabledInSpecificWorldWhenRuntimeFeatureEnabled(WTFMove(testParam));
484     return JSValue::encode(jsUndefined());
485 }
486
487 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeatureEnabled(ExecState* state)
488 {
489     return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeatureEnabledBody>(*state, "enabledInSpecificWorldWhenRuntimeFeatureEnabled");
490 }
491
492 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeaturesEnabledBody(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
493 {
494     UNUSED_PARAM(state);
495     UNUSED_PARAM(throwScope);
496     auto& impl = castedThis->wrapped();
497     if (UNLIKELY(state->argumentCount() < 1))
498         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
499     auto testParam = convert<IDLLong>(*state, state->uncheckedArgument(0));
500     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
501     impl.enabledInSpecificWorldWhenRuntimeFeaturesEnabled(WTFMove(testParam));
502     return JSValue::encode(jsUndefined());
503 }
504
505 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeaturesEnabled(ExecState* state)
506 {
507     return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionEnabledInSpecificWorldWhenRuntimeFeaturesEnabledBody>(*state, "enabledInSpecificWorldWhenRuntimeFeaturesEnabled");
508 }
509
510 #if ENABLE(TEST_FEATURE)
511 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionTestPrivateFunctionBody(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
512 {
513     UNUSED_PARAM(state);
514     UNUSED_PARAM(throwScope);
515     auto& impl = castedThis->wrapped();
516     impl.testPrivateFunction();
517     return JSValue::encode(jsUndefined());
518 }
519
520 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(ExecState* state)
521 {
522     return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionTestPrivateFunctionBody, CastedThisErrorBehavior::Assert>(*state, "testPrivateFunction");
523 }
524
525 #endif
526
527 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionCalculateSecretResultBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSTestGlobalObject>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope)
528 {
529     UNUSED_PARAM(state);
530     UNUSED_PARAM(throwScope);
531     auto& impl = castedThis->wrapped();
532     impl.calculateSecretResult(WTFMove(promise));
533     return JSValue::encode(jsUndefined());
534 }
535
536 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionCalculateSecretResult(ExecState* state)
537 {
538     return IDLOperationReturningPromise<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionCalculateSecretResultBody, PromiseExecutionScope::WindowOnly>(*state, "calculateSecretResult");
539 }
540
541 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
542 {
543     UNUSED_PARAM(state);
544     UNUSED_PARAM(throwScope);
545     auto& impl = castedThis->wrapped();
546     return JSValue::encode(toJS<IDLBoolean>(impl.getSecretBoolean()));
547 }
548
549 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionGetSecretBoolean(ExecState* state)
550 {
551     return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionGetSecretBooleanBody>(*state, "getSecretBoolean");
552 }
553
554 #if ENABLE(TEST_FEATURE)
555 static inline JSC::EncodedJSValue jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBooleanBody(JSC::ExecState* state, typename IDLOperation<JSTestGlobalObject>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
556 {
557     UNUSED_PARAM(state);
558     UNUSED_PARAM(throwScope);
559     auto& impl = castedThis->wrapped();
560     return JSValue::encode(toJS<IDLBoolean>(impl.testFeatureGetSecretBoolean()));
561 }
562
563 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBoolean(ExecState* state)
564 {
565     return IDLOperation<JSTestGlobalObject>::call<jsTestGlobalObjectInstanceFunctionTestFeatureGetSecretBooleanBody>(*state, "testFeatureGetSecretBoolean");
566 }
567
568 #endif
569
570 bool JSTestGlobalObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
571 {
572     UNUSED_PARAM(handle);
573     UNUSED_PARAM(visitor);
574     return false;
575 }
576
577 void JSTestGlobalObjectOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
578 {
579     auto* jsTestGlobalObject = static_cast<JSTestGlobalObject*>(handle.slot()->asCell());
580     auto& world = *static_cast<DOMWrapperWorld*>(context);
581     uncacheWrapper(world, &jsTestGlobalObject->wrapped(), jsTestGlobalObject);
582 }
583
584 #if ENABLE(BINDING_INTEGRITY)
585 #if PLATFORM(WIN)
586 #pragma warning(disable: 4483)
587 extern "C" { extern void (*const __identifier("??_7TestGlobalObject@WebCore@@6B@")[])(); }
588 #else
589 extern "C" { extern void* _ZTVN7WebCore16TestGlobalObjectE[]; }
590 #endif
591 #endif
592
593 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestGlobalObject>&& impl)
594 {
595
596 #if ENABLE(BINDING_INTEGRITY)
597     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
598 #if PLATFORM(WIN)
599     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestGlobalObject@WebCore@@6B@"));
600 #else
601     void* expectedVTablePointer = &_ZTVN7WebCore16TestGlobalObjectE[2];
602 #endif
603
604     // If this fails TestGlobalObject does not have a vtable, so you need to add the
605     // ImplementationLacksVTable attribute to the interface definition
606     static_assert(std::is_polymorphic<TestGlobalObject>::value, "TestGlobalObject is not polymorphic");
607
608     // If you hit this assertion you either have a use after free bug, or
609     // TestGlobalObject has subclasses. If TestGlobalObject has subclasses that get passed
610     // to toJS() we currently require TestGlobalObject you to opt out of binding hardening
611     // by adding the SkipVTableValidation attribute to the interface IDL definition
612     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
613 #endif
614     return createWrapper<TestGlobalObject>(globalObject, WTFMove(impl));
615 }
616
617 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestGlobalObject& impl)
618 {
619     return wrap(state, globalObject, impl);
620 }
621
622 TestGlobalObject* JSTestGlobalObject::toWrapped(JSC::VM& vm, JSC::JSValue value)
623 {
624     if (auto* wrapper = jsDynamicDowncast<JSTestGlobalObject*>(vm, value))
625         return &wrapper->wrapped();
626     return nullptr;
627 }
628
629 }