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