Unreviewed, rolling out r251040.
[WebKit-https.git] / Source / WebCore / bindings / scripts / test / JS / JSMapLike.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 "JSMapLike.h"
23
24 #include "JSDOMAttribute.h"
25 #include "JSDOMBinding.h"
26 #include "JSDOMConstructorNotConstructable.h"
27 #include "JSDOMConvertAny.h"
28 #include "JSDOMConvertStrings.h"
29 #include "JSDOMExceptionHandling.h"
30 #include "JSDOMMapLike.h"
31 #include "JSDOMOperation.h"
32 #include "JSDOMWrapperCache.h"
33 #include "ScriptExecutionContext.h"
34 #include <JavaScriptCore/BuiltinNames.h>
35 #include <JavaScriptCore/FunctionPrototype.h>
36 #include <JavaScriptCore/HeapAnalyzer.h>
37 #include <JavaScriptCore/JSCInlines.h>
38 #include <wtf/GetPtr.h>
39 #include <wtf/PointerPreparations.h>
40 #include <wtf/URL.h>
41
42
43 namespace WebCore {
44 using namespace JSC;
45
46 // Functions
47
48 JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionGet(JSC::JSGlobalObject*, JSC::CallFrame*);
49 JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionHas(JSC::JSGlobalObject*, JSC::CallFrame*);
50 JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionEntries(JSC::JSGlobalObject*, JSC::CallFrame*);
51 JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionKeys(JSC::JSGlobalObject*, JSC::CallFrame*);
52 JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionValues(JSC::JSGlobalObject*, JSC::CallFrame*);
53 JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionForEach(JSC::JSGlobalObject*, JSC::CallFrame*);
54 JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionAdd(JSC::JSGlobalObject*, JSC::CallFrame*);
55 JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionClear(JSC::JSGlobalObject*, JSC::CallFrame*);
56 JSC::EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionDelete(JSC::JSGlobalObject*, JSC::CallFrame*);
57
58 // Attributes
59
60 JSC::EncodedJSValue jsMapLikeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
61 bool setJSMapLikeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
62 JSC::EncodedJSValue jsMapLikeSize(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
63
64 class JSMapLikePrototype : public JSC::JSNonFinalObject {
65 public:
66     using Base = JSC::JSNonFinalObject;
67     static JSMapLikePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
68     {
69         JSMapLikePrototype* ptr = new (NotNull, JSC::allocateCell<JSMapLikePrototype>(vm.heap)) JSMapLikePrototype(vm, globalObject, structure);
70         ptr->finishCreation(vm);
71         return ptr;
72     }
73
74     DECLARE_INFO;
75     static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
76     {
77         return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
78     }
79
80 private:
81     JSMapLikePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
82         : JSC::JSNonFinalObject(vm, structure)
83     {
84     }
85
86     void finishCreation(JSC::VM&);
87 };
88
89 using JSMapLikeConstructor = JSDOMConstructorNotConstructable<JSMapLike>;
90
91 template<> JSValue JSMapLikeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
92 {
93     UNUSED_PARAM(vm);
94     return globalObject.functionPrototype();
95 }
96
97 template<> void JSMapLikeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
98 {
99     putDirect(vm, vm.propertyNames->prototype, JSMapLike::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
100     putDirect(vm, vm.propertyNames->name, jsNontrivialString(vm, String("MapLike"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
101     putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
102 }
103
104 template<> const ClassInfo JSMapLikeConstructor::s_info = { "MapLike", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMapLikeConstructor) };
105
106 /* Hash table for prototype */
107
108 static const HashTableValue JSMapLikePrototypeTableValues[] =
109 {
110     { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMapLikeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSMapLikeConstructor) } },
111     { "size", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsMapLikeSize), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
112     { "get", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMapLikePrototypeFunctionGet), (intptr_t) (1) } },
113     { "has", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMapLikePrototypeFunctionHas), (intptr_t) (1) } },
114     { "entries", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMapLikePrototypeFunctionEntries), (intptr_t) (0) } },
115     { "keys", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMapLikePrototypeFunctionKeys), (intptr_t) (0) } },
116     { "values", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMapLikePrototypeFunctionValues), (intptr_t) (0) } },
117     { "forEach", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMapLikePrototypeFunctionForEach), (intptr_t) (1) } },
118     { "add", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMapLikePrototypeFunctionAdd), (intptr_t) (1) } },
119     { "clear", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMapLikePrototypeFunctionClear), (intptr_t) (0) } },
120     { "delete", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsMapLikePrototypeFunctionDelete), (intptr_t) (1) } },
121 };
122
123 const ClassInfo JSMapLikePrototype::s_info = { "MapLikePrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMapLikePrototype) };
124
125 void JSMapLikePrototype::finishCreation(VM& vm)
126 {
127     Base::finishCreation(vm);
128     reifyStaticProperties(vm, JSMapLike::info(), JSMapLikePrototypeTableValues, *this);
129     putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum));
130 }
131
132 const ClassInfo JSMapLike::s_info = { "MapLike", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSMapLike) };
133
134 JSMapLike::JSMapLike(Structure* structure, JSDOMGlobalObject& globalObject, Ref<MapLike>&& impl)
135     : JSDOMWrapper<MapLike>(structure, globalObject, WTFMove(impl))
136 {
137 }
138
139 void JSMapLike::finishCreation(VM& vm)
140 {
141     Base::finishCreation(vm);
142     ASSERT(inherits(vm, info()));
143
144     synchronizeBackingMap(*globalObject()->globalExec(), *globalObject(), *this);
145 }
146
147 JSObject* JSMapLike::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
148 {
149     return JSMapLikePrototype::create(vm, &globalObject, JSMapLikePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
150 }
151
152 JSObject* JSMapLike::prototype(VM& vm, JSDOMGlobalObject& globalObject)
153 {
154     return getDOMPrototype<JSMapLike>(vm, globalObject);
155 }
156
157 JSValue JSMapLike::getConstructor(VM& vm, const JSGlobalObject* globalObject)
158 {
159     return getDOMConstructor<JSMapLikeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
160 }
161
162 void JSMapLike::destroy(JSC::JSCell* cell)
163 {
164     JSMapLike* thisObject = static_cast<JSMapLike*>(cell);
165     thisObject->JSMapLike::~JSMapLike();
166 }
167
168 template<> inline JSMapLike* IDLAttribute<JSMapLike>::cast(ExecState& state, EncodedJSValue thisValue)
169 {
170     return jsDynamicCast<JSMapLike*>(state.vm(), JSValue::decode(thisValue));
171 }
172
173 template<> inline JSMapLike* IDLOperation<JSMapLike>::cast(ExecState& state)
174 {
175     return jsDynamicCast<JSMapLike*>(state.vm(), state.thisValue());
176 }
177
178 EncodedJSValue jsMapLikeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
179 {
180     VM& vm = state->vm();
181     auto throwScope = DECLARE_THROW_SCOPE(vm);
182     auto* prototype = jsDynamicCast<JSMapLikePrototype*>(vm, JSValue::decode(thisValue));
183     if (UNLIKELY(!prototype))
184         return throwVMTypeError(state, throwScope);
185     return JSValue::encode(JSMapLike::getConstructor(state->vm(), prototype->globalObject()));
186 }
187
188 bool setJSMapLikeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
189 {
190     VM& vm = state->vm();
191     auto throwScope = DECLARE_THROW_SCOPE(vm);
192     auto* prototype = jsDynamicCast<JSMapLikePrototype*>(vm, JSValue::decode(thisValue));
193     if (UNLIKELY(!prototype)) {
194         throwVMTypeError(state, throwScope);
195         return false;
196     }
197     // Shadowing a built-in constructor
198     return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
199 }
200
201 static inline JSValue jsMapLikeSizeGetter(ExecState& state, JSMapLike& thisObject, ThrowScope& throwScope)
202 {
203     UNUSED_PARAM(throwScope);
204     UNUSED_PARAM(state);
205     JSValue result = toJS<IDLAny>(state, throwScope, forwardSizeToMapLike(state, thisObject));
206     return result;
207 }
208
209 EncodedJSValue jsMapLikeSize(ExecState* state, EncodedJSValue thisValue, PropertyName)
210 {
211     return IDLAttribute<JSMapLike>::get<jsMapLikeSizeGetter>(*state, thisValue, "size");
212 }
213
214 static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionGetBody(JSC::ExecState* state, typename IDLOperation<JSMapLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
215 {
216     UNUSED_PARAM(state);
217     UNUSED_PARAM(throwScope);
218     if (UNLIKELY(state->argumentCount() < 1))
219         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
220     auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
221     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
222     return JSValue::encode(toJS<IDLAny>(forwardGetToMapLike(*state, *castedThis, WTFMove(key))));
223 }
224
225 EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionGet(JSGlobalObject* globalObject, CallFrame* state)
226 {
227     UNUSED_PARAM(globalObject);
228     return IDLOperation<JSMapLike>::call<jsMapLikePrototypeFunctionGetBody>(*state, "get");
229 }
230
231 static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionHasBody(JSC::ExecState* state, typename IDLOperation<JSMapLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
232 {
233     UNUSED_PARAM(state);
234     UNUSED_PARAM(throwScope);
235     if (UNLIKELY(state->argumentCount() < 1))
236         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
237     auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
238     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
239     return JSValue::encode(toJS<IDLAny>(forwardHasToMapLike(*state, *castedThis, WTFMove(key))));
240 }
241
242 EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionHas(JSGlobalObject* globalObject, CallFrame* state)
243 {
244     UNUSED_PARAM(globalObject);
245     return IDLOperation<JSMapLike>::call<jsMapLikePrototypeFunctionHasBody>(*state, "has");
246 }
247
248 static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionEntriesBody(JSC::ExecState* state, typename IDLOperation<JSMapLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
249 {
250     UNUSED_PARAM(state);
251     UNUSED_PARAM(throwScope);
252     return JSValue::encode(toJS<IDLAny>(forwardEntriesToMapLike(*state, *castedThis)));
253 }
254
255 EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionEntries(JSGlobalObject* globalObject, CallFrame* state)
256 {
257     UNUSED_PARAM(globalObject);
258     return IDLOperation<JSMapLike>::call<jsMapLikePrototypeFunctionEntriesBody>(*state, "entries");
259 }
260
261 static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionKeysBody(JSC::ExecState* state, typename IDLOperation<JSMapLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
262 {
263     UNUSED_PARAM(state);
264     UNUSED_PARAM(throwScope);
265     return JSValue::encode(toJS<IDLAny>(forwardKeysToMapLike(*state, *castedThis)));
266 }
267
268 EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionKeys(JSGlobalObject* globalObject, CallFrame* state)
269 {
270     UNUSED_PARAM(globalObject);
271     return IDLOperation<JSMapLike>::call<jsMapLikePrototypeFunctionKeysBody>(*state, "keys");
272 }
273
274 static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionValuesBody(JSC::ExecState* state, typename IDLOperation<JSMapLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
275 {
276     UNUSED_PARAM(state);
277     UNUSED_PARAM(throwScope);
278     return JSValue::encode(toJS<IDLAny>(forwardValuesToMapLike(*state, *castedThis)));
279 }
280
281 EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionValues(JSGlobalObject* globalObject, CallFrame* state)
282 {
283     UNUSED_PARAM(globalObject);
284     return IDLOperation<JSMapLike>::call<jsMapLikePrototypeFunctionValuesBody>(*state, "values");
285 }
286
287 static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionForEachBody(JSC::ExecState* state, typename IDLOperation<JSMapLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
288 {
289     UNUSED_PARAM(state);
290     UNUSED_PARAM(throwScope);
291     if (UNLIKELY(state->argumentCount() < 1))
292         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
293     auto callback = convert<IDLAny>(*state, state->uncheckedArgument(0));
294     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
295     return JSValue::encode(toJS<IDLAny>(forwardForEachToMapLike(*state, *castedThis, WTFMove(callback))));
296 }
297
298 EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionForEach(JSGlobalObject* globalObject, CallFrame* state)
299 {
300     UNUSED_PARAM(globalObject);
301     return IDLOperation<JSMapLike>::call<jsMapLikePrototypeFunctionForEachBody>(*state, "forEach");
302 }
303
304 static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionAddBody(JSC::ExecState* state, typename IDLOperation<JSMapLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
305 {
306     UNUSED_PARAM(state);
307     UNUSED_PARAM(throwScope);
308     if (UNLIKELY(state->argumentCount() < 1))
309         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
310     auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
311     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
312     return JSValue::encode(toJS<IDLAny>(forwardAddToMapLike(*state, *castedThis, WTFMove(key))));
313 }
314
315 EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionAdd(JSGlobalObject* globalObject, CallFrame* state)
316 {
317     UNUSED_PARAM(globalObject);
318     return IDLOperation<JSMapLike>::call<jsMapLikePrototypeFunctionAddBody>(*state, "add");
319 }
320
321 static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionClearBody(JSC::ExecState* state, typename IDLOperation<JSMapLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
322 {
323     UNUSED_PARAM(state);
324     UNUSED_PARAM(throwScope);
325     forwardClearToMapLike(*state, *castedThis);
326     return JSValue::encode(jsUndefined());
327 }
328
329 EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionClear(JSGlobalObject* globalObject, CallFrame* state)
330 {
331     UNUSED_PARAM(globalObject);
332     return IDLOperation<JSMapLike>::call<jsMapLikePrototypeFunctionClearBody>(*state, "clear");
333 }
334
335 static inline JSC::EncodedJSValue jsMapLikePrototypeFunctionDeleteBody(JSC::ExecState* state, typename IDLOperation<JSMapLike>::ClassParameter castedThis, JSC::ThrowScope& throwScope)
336 {
337     UNUSED_PARAM(state);
338     UNUSED_PARAM(throwScope);
339     if (UNLIKELY(state->argumentCount() < 1))
340         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
341     auto key = convert<IDLDOMString>(*state, state->uncheckedArgument(0));
342     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
343     return JSValue::encode(toJS<IDLAny>(forwardDeleteToMapLike(*state, *castedThis, WTFMove(key))));
344 }
345
346 EncodedJSValue JSC_HOST_CALL jsMapLikePrototypeFunctionDelete(JSGlobalObject* globalObject, CallFrame* state)
347 {
348     UNUSED_PARAM(globalObject);
349     return IDLOperation<JSMapLike>::call<jsMapLikePrototypeFunctionDeleteBody>(*state, "delete");
350 }
351
352 void JSMapLike::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
353 {
354     auto* thisObject = jsCast<JSMapLike*>(cell);
355     analyzer.setWrappedObjectForCell(cell, &thisObject->wrapped());
356     if (thisObject->scriptExecutionContext())
357         analyzer.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string());
358     Base::analyzeHeap(cell, analyzer);
359 }
360
361 bool JSMapLikeOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason)
362 {
363     UNUSED_PARAM(handle);
364     UNUSED_PARAM(visitor);
365     UNUSED_PARAM(reason);
366     return false;
367 }
368
369 void JSMapLikeOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
370 {
371     auto* jsMapLike = static_cast<JSMapLike*>(handle.slot()->asCell());
372     auto& world = *static_cast<DOMWrapperWorld*>(context);
373     uncacheWrapper(world, &jsMapLike->wrapped(), jsMapLike);
374 }
375
376 #if ENABLE(BINDING_INTEGRITY)
377 #if PLATFORM(WIN)
378 #pragma warning(disable: 4483)
379 extern "C" { extern void (*const __identifier("??_7MapLike@WebCore@@6B@")[])(); }
380 #else
381 extern "C" { extern void* _ZTVN7WebCore7MapLikeE[]; }
382 #endif
383 #endif
384
385 JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<MapLike>&& impl)
386 {
387
388 #if ENABLE(BINDING_INTEGRITY)
389     void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
390 #if PLATFORM(WIN)
391     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7MapLike@WebCore@@6B@"));
392 #else
393     void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore7MapLikeE[2]);
394 #endif
395
396     // If this fails MapLike does not have a vtable, so you need to add the
397     // ImplementationLacksVTable attribute to the interface definition
398     static_assert(std::is_polymorphic<MapLike>::value, "MapLike is not polymorphic");
399
400     // If you hit this assertion you either have a use after free bug, or
401     // MapLike has subclasses. If MapLike has subclasses that get passed
402     // to toJS() we currently require MapLike you to opt out of binding hardening
403     // by adding the SkipVTableValidation attribute to the interface IDL definition
404     RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
405 #endif
406     return createWrapper<MapLike>(globalObject, WTFMove(impl));
407 }
408
409 JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, MapLike& impl)
410 {
411     return wrap(state, globalObject, impl);
412 }
413
414 MapLike* JSMapLike::toWrapped(JSC::VM& vm, JSC::JSValue value)
415 {
416     if (auto* wrapper = jsDynamicCast<JSMapLike*>(vm, value))
417         return &wrapper->wrapped();
418     return nullptr;
419 }
420
421 }