d1d3c1861716203f0aa54ef6b155741aebf6e5d1
[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 "ExceptionCode.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructor.h"
27 #include "JSDOMConvert.h"
28 #include "RuntimeEnabledFeatures.h"
29 #include "URL.h"
30 #include "WebCoreJSClientData.h"
31 #include <runtime/Error.h>
32 #include <runtime/FunctionPrototype.h>
33 #include <runtime/JSString.h>
34 #include <wtf/GetPtr.h>
35
36 #if ENABLE(TEST_FEATURE)
37 #include "TestGlobalObjectBuiltins.h"
38 #endif
39
40 using namespace JSC;
41
42 namespace WebCore {
43
44 // Functions
45
46 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionRegularOperation(JSC::ExecState*);
47 #if ENABLE(TEST_FEATURE)
48 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation(JSC::ExecState*);
49 #endif
50 #if ENABLE(TEST_FEATURE)
51 JSC::EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(JSC::ExecState*);
52 #endif
53
54 // Attributes
55
56 JSC::EncodedJSValue jsTestGlobalObjectRegularAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
57 bool setJSTestGlobalObjectRegularAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
58 JSC::EncodedJSValue jsTestGlobalObjectPublicAndPrivateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
59 bool setJSTestGlobalObjectPublicAndPrivateAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
60 #if ENABLE(TEST_FEATURE)
61 JSC::EncodedJSValue jsTestGlobalObjectPublicAndPrivateConditionalAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
62 bool setJSTestGlobalObjectPublicAndPrivateConditionalAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
63 #endif
64 #if ENABLE(TEST_FEATURE)
65 JSC::EncodedJSValue jsTestGlobalObjectEnabledAtRuntimeAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
66 bool setJSTestGlobalObjectEnabledAtRuntimeAttribute(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
67 #endif
68 JSC::EncodedJSValue jsTestGlobalObjectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
69 bool setJSTestGlobalObjectConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
70
71 using JSTestGlobalObjectConstructor = JSDOMConstructorNotConstructable<JSTestGlobalObject>;
72
73 /* Hash table */
74
75 static const struct CompactHashIndex JSTestGlobalObjectTableIndex[16] = {
76     { -1, -1 },
77     { -1, -1 },
78     { 2, -1 },
79     { 0, -1 },
80     { -1, -1 },
81     { -1, -1 },
82     { -1, -1 },
83     { -1, -1 },
84     { -1, -1 },
85     { 3, -1 },
86     { -1, -1 },
87     { -1, -1 },
88     { -1, -1 },
89     { -1, -1 },
90     { 1, -1 },
91     { -1, -1 },
92 };
93
94
95 static const HashTableValue JSTestGlobalObjectTableValues[] =
96 {
97     { "regularAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectRegularAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectRegularAttribute) } },
98     { "publicAndPrivateAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectPublicAndPrivateAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectPublicAndPrivateAttribute) } },
99 #if ENABLE(TEST_FEATURE)
100     { "publicAndPrivateConditionalAttribute", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectPublicAndPrivateConditionalAttribute), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectPublicAndPrivateConditionalAttribute) } },
101 #else
102     { 0, 0, NoIntrinsic, { 0, 0 } },
103 #endif
104     { "regularOperation", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestGlobalObjectInstanceFunctionRegularOperation), (intptr_t) (1) } },
105 };
106
107 static const HashTable JSTestGlobalObjectTable = { 4, 15, true, JSTestGlobalObjectTableValues, JSTestGlobalObjectTableIndex };
108 template<> JSValue JSTestGlobalObjectConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
109 {
110     UNUSED_PARAM(vm);
111     return globalObject.functionPrototype();
112 }
113
114 template<> void JSTestGlobalObjectConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
115 {
116     putDirect(vm, vm.propertyNames->prototype, globalObject.getPrototypeDirect(), DontDelete | ReadOnly | DontEnum);
117     putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestGlobalObject"))), ReadOnly | DontEnum);
118     putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
119 }
120
121 template<> const ClassInfo JSTestGlobalObjectConstructor::s_info = { "TestGlobalObject", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestGlobalObjectConstructor) };
122
123 /* Hash table for prototype */
124
125 static const struct CompactHashIndex JSTestGlobalObjectPrototypeTableIndex[2] = {
126     { -1, -1 },
127     { 0, -1 },
128 };
129
130
131 static const HashTableValue JSTestGlobalObjectPrototypeTableValues[] =
132 {
133     { "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestGlobalObjectConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSTestGlobalObjectConstructor) } },
134 };
135
136 static const HashTable JSTestGlobalObjectPrototypeTable = { 1, 1, true, JSTestGlobalObjectPrototypeTableValues, JSTestGlobalObjectPrototypeTableIndex };
137 const ClassInfo JSTestGlobalObjectPrototype::s_info = { "TestGlobalObjectPrototype", &Base::s_info, &JSTestGlobalObjectPrototypeTable, CREATE_METHOD_TABLE(JSTestGlobalObjectPrototype) };
138
139 const ClassInfo JSTestGlobalObject::s_info = { "TestGlobalObject", &Base::s_info, &JSTestGlobalObjectTable, CREATE_METHOD_TABLE(JSTestGlobalObject) };
140
141 JSTestGlobalObject::JSTestGlobalObject(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestGlobalObject>&& impl)
142     : JSDOMWrapper<TestGlobalObject>(structure, globalObject, WTFMove(impl))
143 {
144 }
145
146 void JSTestGlobalObject::finishCreation(VM& vm, JSProxy* proxy)
147 {
148     Base::finishCreation(vm, proxy);
149
150 #if ENABLE(TEST_FEATURE)
151     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled()) {
152         auto* customGetterSetter = CustomGetterSetter::create(vm, jsTestGlobalObjectEnabledAtRuntimeAttribute, setJSTestGlobalObjectEnabledAtRuntimeAttribute);
153         putDirectCustomAccessor(vm, vm.propertyNames->enabledAtRuntimeAttribute, customGetterSetter, attributesForStructure(CustomAccessor));
154     }
155 #endif
156     putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().publicAndPrivateAttributePrivateName(), CustomGetterSetter::create(vm, jsTestGlobalObjectPublicAndPrivateAttribute, nullptr), attributesForStructure(DontDelete | ReadOnly));
157 #if ENABLE(TEST_FEATURE)
158     putDirectCustomAccessor(vm, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().publicAndPrivateConditionalAttributePrivateName(), CustomGetterSetter::create(vm, jsTestGlobalObjectPublicAndPrivateConditionalAttribute, nullptr), attributesForStructure(DontDelete | ReadOnly));
159 #endif
160 #if ENABLE(TEST_FEATURE)
161     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
162         putDirectNativeFunction(vm, this, vm.propertyNames->enabledAtRuntimeOperation, 1, jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation, NoIntrinsic, attributesForStructure(JSC::Function));
163 #endif
164 #if ENABLE(TEST_FEATURE)
165     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
166         putDirectNativeFunction(vm, this, static_cast<JSVMClientData*>(vm.clientData)->builtinNames().testPrivateFunctionPrivateName(), 0, jsTestGlobalObjectInstanceFunctionTestPrivateFunction, NoIntrinsic, attributesForStructure(JSC::Function));
167 #endif
168 #if ENABLE(TEST_FEATURE)
169     if (RuntimeEnabledFeatures::sharedFeatures().testFeatureEnabled())
170         putDirectBuiltinFunction(vm, this, vm.propertyNames->testJSBuiltinFunction, testGlobalObjectTestJSBuiltinFunctionCodeGenerator(vm), attributesForStructure(JSC::Builtin));
171 #endif
172 }
173
174 void JSTestGlobalObject::destroy(JSC::JSCell* cell)
175 {
176     JSTestGlobalObject* thisObject = static_cast<JSTestGlobalObject*>(cell);
177     thisObject->JSTestGlobalObject::~JSTestGlobalObject();
178 }
179
180 EncodedJSValue jsTestGlobalObjectRegularAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
181 {
182     VM& vm = state->vm();
183     auto throwScope = DECLARE_THROW_SCOPE(vm);
184     UNUSED_PARAM(throwScope);
185     UNUSED_PARAM(thisValue);
186     JSValue decodedThisValue = JSValue::decode(thisValue);
187     auto* castedThis = jsDynamicCast<JSTestGlobalObject*>(decodedThisValue);
188     if (UNLIKELY(!castedThis)) {
189         return throwGetterTypeError(*state, throwScope, "TestGlobalObject", "regularAttribute");
190     }
191     auto& impl = castedThis->wrapped();
192     JSValue result = jsStringWithCache(state, impl.regularAttribute());
193     return JSValue::encode(result);
194 }
195
196
197 EncodedJSValue jsTestGlobalObjectPublicAndPrivateAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
198 {
199     VM& vm = state->vm();
200     auto throwScope = DECLARE_THROW_SCOPE(vm);
201     UNUSED_PARAM(throwScope);
202     UNUSED_PARAM(thisValue);
203     JSValue decodedThisValue = JSValue::decode(thisValue);
204     auto* castedThis = jsDynamicCast<JSTestGlobalObject*>(decodedThisValue);
205     if (UNLIKELY(!castedThis)) {
206         return throwGetterTypeError(*state, throwScope, "TestGlobalObject", "publicAndPrivateAttribute");
207     }
208     auto& impl = castedThis->wrapped();
209     JSValue result = jsStringWithCache(state, impl.publicAndPrivateAttribute());
210     return JSValue::encode(result);
211 }
212
213
214 #if ENABLE(TEST_FEATURE)
215 EncodedJSValue jsTestGlobalObjectPublicAndPrivateConditionalAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
216 {
217     VM& vm = state->vm();
218     auto throwScope = DECLARE_THROW_SCOPE(vm);
219     UNUSED_PARAM(throwScope);
220     UNUSED_PARAM(thisValue);
221     JSValue decodedThisValue = JSValue::decode(thisValue);
222     auto* castedThis = jsDynamicCast<JSTestGlobalObject*>(decodedThisValue);
223     if (UNLIKELY(!castedThis)) {
224         return throwGetterTypeError(*state, throwScope, "TestGlobalObject", "publicAndPrivateConditionalAttribute");
225     }
226     auto& impl = castedThis->wrapped();
227     JSValue result = jsStringWithCache(state, impl.publicAndPrivateConditionalAttribute());
228     return JSValue::encode(result);
229 }
230
231 #endif
232
233 #if ENABLE(TEST_FEATURE)
234 EncodedJSValue jsTestGlobalObjectEnabledAtRuntimeAttribute(ExecState* state, EncodedJSValue thisValue, PropertyName)
235 {
236     VM& vm = state->vm();
237     auto throwScope = DECLARE_THROW_SCOPE(vm);
238     UNUSED_PARAM(throwScope);
239     UNUSED_PARAM(thisValue);
240     JSValue decodedThisValue = JSValue::decode(thisValue);
241     auto* castedThis = jsDynamicCast<JSTestGlobalObject*>(decodedThisValue);
242     if (UNLIKELY(!castedThis)) {
243         return throwGetterTypeError(*state, throwScope, "TestGlobalObject", "enabledAtRuntimeAttribute");
244     }
245     auto& impl = castedThis->wrapped();
246     JSValue result = jsStringWithCache(state, impl.enabledAtRuntimeAttribute());
247     return JSValue::encode(result);
248 }
249
250 #endif
251
252 EncodedJSValue jsTestGlobalObjectConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
253 {
254     VM& vm = state->vm();
255     auto throwScope = DECLARE_THROW_SCOPE(vm);
256     JSTestGlobalObjectPrototype* domObject = jsDynamicCast<JSTestGlobalObjectPrototype*>(JSValue::decode(thisValue));
257     if (UNLIKELY(!domObject))
258         return throwVMTypeError(state, throwScope);
259     return JSValue::encode(JSTestGlobalObject::getConstructor(state->vm(), domObject->globalObject()));
260 }
261
262 bool setJSTestGlobalObjectConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
263 {
264     VM& vm = state->vm();
265     auto throwScope = DECLARE_THROW_SCOPE(vm);
266     JSValue value = JSValue::decode(encodedValue);
267     JSTestGlobalObjectPrototype* domObject = jsDynamicCast<JSTestGlobalObjectPrototype*>(JSValue::decode(thisValue));
268     if (UNLIKELY(!domObject)) {
269         throwVMTypeError(state, throwScope);
270         return false;
271     }
272     // Shadowing a built-in constructor
273     return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
274 }
275
276 bool setJSTestGlobalObjectRegularAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
277 {
278     VM& vm = state->vm();
279     auto throwScope = DECLARE_THROW_SCOPE(vm);
280     UNUSED_PARAM(throwScope);
281     JSValue value = JSValue::decode(encodedValue);
282     UNUSED_PARAM(thisValue);
283     JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
284     if (UNLIKELY(!castedThis)) {
285         return throwSetterTypeError(*state, throwScope, "TestGlobalObject", "regularAttribute");
286     }
287     auto& impl = castedThis->wrapped();
288     auto nativeValue = value.toWTFString(state);
289     RETURN_IF_EXCEPTION(throwScope, false);
290     impl.setRegularAttribute(WTFMove(nativeValue));
291     return true;
292 }
293
294
295 bool setJSTestGlobalObjectPublicAndPrivateAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
296 {
297     VM& vm = state->vm();
298     auto throwScope = DECLARE_THROW_SCOPE(vm);
299     UNUSED_PARAM(throwScope);
300     JSValue value = JSValue::decode(encodedValue);
301     UNUSED_PARAM(thisValue);
302     JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
303     if (UNLIKELY(!castedThis)) {
304         return throwSetterTypeError(*state, throwScope, "TestGlobalObject", "publicAndPrivateAttribute");
305     }
306     auto& impl = castedThis->wrapped();
307     auto nativeValue = value.toWTFString(state);
308     RETURN_IF_EXCEPTION(throwScope, false);
309     impl.setPublicAndPrivateAttribute(WTFMove(nativeValue));
310     return true;
311 }
312
313
314 #if ENABLE(TEST_FEATURE)
315 bool setJSTestGlobalObjectPublicAndPrivateConditionalAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
316 {
317     VM& vm = state->vm();
318     auto throwScope = DECLARE_THROW_SCOPE(vm);
319     UNUSED_PARAM(throwScope);
320     JSValue value = JSValue::decode(encodedValue);
321     UNUSED_PARAM(thisValue);
322     JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
323     if (UNLIKELY(!castedThis)) {
324         return throwSetterTypeError(*state, throwScope, "TestGlobalObject", "publicAndPrivateConditionalAttribute");
325     }
326     auto& impl = castedThis->wrapped();
327     auto nativeValue = value.toWTFString(state);
328     RETURN_IF_EXCEPTION(throwScope, false);
329     impl.setPublicAndPrivateConditionalAttribute(WTFMove(nativeValue));
330     return true;
331 }
332
333 #endif
334
335 #if ENABLE(TEST_FEATURE)
336 bool setJSTestGlobalObjectEnabledAtRuntimeAttribute(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
337 {
338     VM& vm = state->vm();
339     auto throwScope = DECLARE_THROW_SCOPE(vm);
340     UNUSED_PARAM(throwScope);
341     JSValue value = JSValue::decode(encodedValue);
342     UNUSED_PARAM(thisValue);
343     JSTestGlobalObject* castedThis = jsDynamicCast<JSTestGlobalObject*>(JSValue::decode(thisValue));
344     if (UNLIKELY(!castedThis)) {
345         return throwSetterTypeError(*state, throwScope, "TestGlobalObject", "enabledAtRuntimeAttribute");
346     }
347     auto& impl = castedThis->wrapped();
348     auto nativeValue = value.toWTFString(state);
349     RETURN_IF_EXCEPTION(throwScope, false);
350     impl.setEnabledAtRuntimeAttribute(WTFMove(nativeValue));
351     return true;
352 }
353
354 #endif
355
356 JSValue JSTestGlobalObject::getConstructor(VM& vm, const JSGlobalObject* globalObject)
357 {
358     return getDOMConstructor<JSTestGlobalObjectConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
359 }
360
361 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionRegularOperation(ExecState* state)
362 {
363     VM& vm = state->vm();
364     auto throwScope = DECLARE_THROW_SCOPE(vm);
365     UNUSED_PARAM(throwScope);
366     JSValue thisValue = state->thisValue();
367     auto castedThis = jsDynamicCast<JSTestGlobalObject*>(thisValue);
368     if (UNLIKELY(!castedThis))
369         return throwThisTypeError(*state, throwScope, "TestGlobalObject", "regularOperation");
370     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestGlobalObject::info());
371     auto& impl = castedThis->wrapped();
372     if (UNLIKELY(state->argumentCount() < 1))
373         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
374     auto testParam = state->uncheckedArgument(0).toWTFString(state);
375     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
376     impl.regularOperation(WTFMove(testParam));
377     return JSValue::encode(jsUndefined());
378 }
379
380 #if ENABLE(TEST_FEATURE)
381 static inline EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation1(ExecState* state)
382 {
383     VM& vm = state->vm();
384     auto throwScope = DECLARE_THROW_SCOPE(vm);
385     UNUSED_PARAM(throwScope);
386     JSValue thisValue = state->thisValue();
387     auto castedThis = jsDynamicCast<JSTestGlobalObject*>(thisValue);
388     if (UNLIKELY(!castedThis))
389         return throwThisTypeError(*state, throwScope, "TestGlobalObject", "enabledAtRuntimeOperation");
390     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestGlobalObject::info());
391     auto& impl = castedThis->wrapped();
392     if (UNLIKELY(state->argumentCount() < 1))
393         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
394     auto testParam = state->uncheckedArgument(0).toWTFString(state);
395     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
396     impl.enabledAtRuntimeOperation(WTFMove(testParam));
397     return JSValue::encode(jsUndefined());
398 }
399
400 #endif
401
402 #if ENABLE(TEST_FEATURE)
403 static inline EncodedJSValue jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2(ExecState* state)
404 {
405     VM& vm = state->vm();
406     auto throwScope = DECLARE_THROW_SCOPE(vm);
407     UNUSED_PARAM(throwScope);
408     JSValue thisValue = state->thisValue();
409     auto castedThis = jsDynamicCast<JSTestGlobalObject*>(thisValue);
410     if (UNLIKELY(!castedThis))
411         return throwThisTypeError(*state, throwScope, "TestGlobalObject", "enabledAtRuntimeOperation");
412     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestGlobalObject::info());
413     auto& impl = castedThis->wrapped();
414     if (UNLIKELY(state->argumentCount() < 1))
415         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
416     auto testParam = convert<int32_t>(*state, state->uncheckedArgument(0), NormalConversion);
417     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
418     impl.enabledAtRuntimeOperation(WTFMove(testParam));
419     return JSValue::encode(jsUndefined());
420 }
421
422 #endif
423
424 #if ENABLE(TEST_FEATURE)
425 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation(ExecState* state)
426 {
427     VM& vm = state->vm();
428     auto throwScope = DECLARE_THROW_SCOPE(vm);
429     UNUSED_PARAM(throwScope);
430     size_t argsCount = std::min<size_t>(1, state->argumentCount());
431     if (argsCount == 1) {
432         JSValue distinguishingArg = state->uncheckedArgument(0);
433 #if ENABLE(TEST_FEATURE)
434         if (distinguishingArg.isNumber())
435             return jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation2(state);
436 #endif
437 #if ENABLE(TEST_FEATURE)
438         return jsTestGlobalObjectInstanceFunctionEnabledAtRuntimeOperation1(state);
439 #endif
440     }
441     return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope);
442 }
443 #endif
444
445 #if ENABLE(TEST_FEATURE)
446 EncodedJSValue JSC_HOST_CALL jsTestGlobalObjectInstanceFunctionTestPrivateFunction(ExecState* state)
447 {
448     VM& vm = state->vm();
449     auto throwScope = DECLARE_THROW_SCOPE(vm);
450     UNUSED_PARAM(throwScope);
451     JSValue thisValue = state->thisValue();
452     auto castedThis = jsDynamicCast<JSTestGlobalObject*>(thisValue);
453     if (UNLIKELY(!castedThis))
454         return throwThisTypeError(*state, throwScope, "TestGlobalObject", "testPrivateFunction");
455     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestGlobalObject::info());
456     auto& impl = castedThis->wrapped();
457     impl.testPrivateFunction();
458     return JSValue::encode(jsUndefined());
459 }
460
461 #endif
462
463 bool JSTestGlobalObjectOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
464 {
465     UNUSED_PARAM(handle);
466     UNUSED_PARAM(visitor);
467     return false;
468 }
469
470 void JSTestGlobalObjectOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
471 {
472     auto* jsTestGlobalObject = jsCast<JSTestGlobalObject*>(handle.slot()->asCell());
473     auto& world = *static_cast<DOMWrapperWorld*>(context);
474     uncacheWrapper(world, &jsTestGlobalObject->wrapped(), jsTestGlobalObject);
475 }
476
477 #if ENABLE(BINDING_INTEGRITY)
478 #if PLATFORM(WIN)
479 #pragma warning(disable: 4483)
480 extern "C" { extern void (*const __identifier("??_7TestGlobalObject@WebCore@@6B@")[])(); }
481 #else
482 extern "C" { extern void* _ZTVN7WebCore16TestGlobalObjectE[]; }
483 #endif
484 #endif
485
486 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<TestGlobalObject>&& impl)
487 {
488
489 #if ENABLE(BINDING_INTEGRITY)
490     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
491 #if PLATFORM(WIN)
492     void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestGlobalObject@WebCore@@6B@"));
493 #else
494     void* expectedVTablePointer = &_ZTVN7WebCore16TestGlobalObjectE[2];
495 #if COMPILER(CLANG)
496     // If this fails TestGlobalObject does not have a vtable, so you need to add the
497     // ImplementationLacksVTable attribute to the interface definition
498     static_assert(__is_polymorphic(TestGlobalObject), "TestGlobalObject is not polymorphic");
499 #endif
500 #endif
501     // If you hit this assertion you either have a use after free bug, or
502     // TestGlobalObject has subclasses. If TestGlobalObject has subclasses that get passed
503     // to toJS() we currently require TestGlobalObject you to opt out of binding hardening
504     // by adding the SkipVTableValidation attribute to the interface IDL definition
505     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
506 #endif
507     return createWrapper<TestGlobalObject>(globalObject, WTFMove(impl));
508 }
509
510 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestGlobalObject& impl)
511 {
512     return wrap(state, globalObject, impl);
513 }
514
515 TestGlobalObject* JSTestGlobalObject::toWrapped(JSC::JSValue value)
516 {
517     if (auto* wrapper = jsDynamicCast<JSTestGlobalObject*>(value))
518         return &wrapper->wrapped();
519     return nullptr;
520 }
521
522 }