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 "JSURLSearchParams.h" |
23 | |
24 | #include "JSDOMBinding.h" |
25 | #include "JSDOMConstructor.h" |
26 | #include "JSDOMConvertBoolean.h" |
27 | #include "JSDOMConvertInterface.h" |
28 | #include "JSDOMConvertNullable.h" |
29 | #include "JSDOMConvertRecord.h" |
30 | #include "JSDOMConvertSequences.h" |
31 | #include "JSDOMConvertStrings.h" |
32 | #include "JSDOMConvertUnion.h" |
33 | #include "JSDOMExceptionHandling.h" |
34 | #include "JSDOMGlobalObject.h" |
35 | #include "JSDOMIterator.h" |
36 | #include "JSDOMOperation.h" |
37 | #include "JSDOMWrapperCache.h" |
38 | #include "ScriptExecutionContext.h" |
39 | #include <JavaScriptCore/BuiltinNames.h> |
40 | #include <JavaScriptCore/FunctionPrototype.h> |
41 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
42 | #include <JavaScriptCore/JSArray.h> |
43 | #include <JavaScriptCore/JSCInlines.h> |
44 | #include <wtf/GetPtr.h> |
45 | #include <wtf/PointerPreparations.h> |
46 | #include <wtf/URL.h> |
47 | #include <wtf/Variant.h> |
48 | #include <wtf/Vector.h> |
49 | |
50 | |
51 | namespace WebCore { |
52 | using namespace JSC; |
53 | |
54 | // Functions |
55 | |
56 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionAppend(JSC::ExecState*); |
57 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionDelete(JSC::ExecState*); |
58 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionGet(JSC::ExecState*); |
59 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionGetAll(JSC::ExecState*); |
60 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionHas(JSC::ExecState*); |
61 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionSet(JSC::ExecState*); |
62 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionSort(JSC::ExecState*); |
63 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionToString(JSC::ExecState*); |
64 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionSymbolIterator(JSC::ExecState*); |
65 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionEntries(JSC::ExecState*); |
66 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionKeys(JSC::ExecState*); |
67 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionValues(JSC::ExecState*); |
68 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionForEach(JSC::ExecState*); |
69 | |
70 | // Attributes |
71 | |
72 | JSC::EncodedJSValue jsURLSearchParamsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
73 | bool setJSURLSearchParamsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
74 | |
75 | class JSURLSearchParamsPrototype : public JSC::JSNonFinalObject { |
76 | public: |
77 | using Base = JSC::JSNonFinalObject; |
78 | static JSURLSearchParamsPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
79 | { |
80 | JSURLSearchParamsPrototype* ptr = new (NotNull, JSC::allocateCell<JSURLSearchParamsPrototype>(vm.heap)) JSURLSearchParamsPrototype(vm, globalObject, structure); |
81 | ptr->finishCreation(vm); |
82 | return ptr; |
83 | } |
84 | |
85 | DECLARE_INFO; |
86 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
87 | { |
88 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
89 | } |
90 | |
91 | private: |
92 | JSURLSearchParamsPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
93 | : JSC::JSNonFinalObject(vm, structure) |
94 | { |
95 | } |
96 | |
97 | void finishCreation(JSC::VM&); |
98 | }; |
99 | |
100 | using JSURLSearchParamsConstructor = JSDOMConstructor<JSURLSearchParams>; |
101 | |
102 | template<> EncodedJSValue JSC_HOST_CALL JSURLSearchParamsConstructor::construct(ExecState* state) |
103 | { |
104 | VM& vm = state->vm(); |
105 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
106 | UNUSED_PARAM(throwScope); |
107 | auto* castedThis = jsCast<JSURLSearchParamsConstructor*>(state->jsCallee()); |
108 | ASSERT(castedThis); |
109 | auto init = state->argument(0).isUndefined() ? "" : convert<IDLUnion<IDLSequence<IDLSequence<IDLUSVString>>, IDLRecord<IDLUSVString, IDLUSVString>, IDLUSVString>>(*state, state->uncheckedArgument(0)); |
110 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
111 | auto object = URLSearchParams::create(WTFMove(init)); |
112 | return JSValue::encode(toJSNewlyCreated<IDLInterface<URLSearchParams>>(*state, *castedThis->globalObject(), throwScope, WTFMove(object))); |
113 | } |
114 | |
115 | template<> JSValue JSURLSearchParamsConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
116 | { |
117 | UNUSED_PARAM(vm); |
118 | return globalObject.functionPrototype(); |
119 | } |
120 | |
121 | template<> void JSURLSearchParamsConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
122 | { |
123 | putDirect(vm, vm.propertyNames->prototype, JSURLSearchParams::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
124 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("URLSearchParams"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
125 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
126 | } |
127 | |
128 | template<> const ClassInfo JSURLSearchParamsConstructor::s_info = { "URLSearchParams" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSURLSearchParamsConstructor) }; |
129 | |
130 | /* Hash table for prototype */ |
131 | |
132 | static const HashTableValue JSURLSearchParamsPrototypeTableValues[] = |
133 | { |
134 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsURLSearchParamsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSURLSearchParamsConstructor) } }, |
135 | { "append" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionAppend), (intptr_t) (2) } }, |
136 | { "delete" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionDelete), (intptr_t) (1) } }, |
137 | { "get" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionGet), (intptr_t) (1) } }, |
138 | { "getAll" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionGetAll), (intptr_t) (1) } }, |
139 | { "has" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionHas), (intptr_t) (1) } }, |
140 | { "set" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionSet), (intptr_t) (2) } }, |
141 | { "sort" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionSort), (intptr_t) (0) } }, |
142 | { "toString" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionToString), (intptr_t) (0) } }, |
143 | { "entries" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionEntries), (intptr_t) (0) } }, |
144 | { "keys" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionKeys), (intptr_t) (0) } }, |
145 | { "values" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionValues), (intptr_t) (0) } }, |
146 | { "forEach" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsURLSearchParamsPrototypeFunctionForEach), (intptr_t) (1) } }, |
147 | }; |
148 | |
149 | const ClassInfo JSURLSearchParamsPrototype::s_info = { "URLSearchParamsPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSURLSearchParamsPrototype) }; |
150 | |
151 | void JSURLSearchParamsPrototype::finishCreation(VM& vm) |
152 | { |
153 | Base::finishCreation(vm); |
154 | reifyStaticProperties(vm, JSURLSearchParams::info(), JSURLSearchParamsPrototypeTableValues, *this); |
155 | putDirect(vm, vm.propertyNames->iteratorSymbol, getDirect(vm, vm.propertyNames->builtinNames().entriesPublicName()), static_cast<unsigned>(JSC::PropertyAttribute::DontEnum)); |
156 | } |
157 | |
158 | const ClassInfo JSURLSearchParams::s_info = { "URLSearchParams" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSURLSearchParams) }; |
159 | |
160 | JSURLSearchParams::JSURLSearchParams(Structure* structure, JSDOMGlobalObject& globalObject, Ref<URLSearchParams>&& impl) |
161 | : JSDOMWrapper<URLSearchParams>(structure, globalObject, WTFMove(impl)) |
162 | { |
163 | } |
164 | |
165 | void JSURLSearchParams::finishCreation(VM& vm) |
166 | { |
167 | Base::finishCreation(vm); |
168 | ASSERT(inherits(vm, info())); |
169 | |
170 | } |
171 | |
172 | JSObject* JSURLSearchParams::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
173 | { |
174 | return JSURLSearchParamsPrototype::create(vm, &globalObject, JSURLSearchParamsPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
175 | } |
176 | |
177 | JSObject* JSURLSearchParams::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
178 | { |
179 | return getDOMPrototype<JSURLSearchParams>(vm, globalObject); |
180 | } |
181 | |
182 | JSValue JSURLSearchParams::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
183 | { |
184 | return getDOMConstructor<JSURLSearchParamsConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
185 | } |
186 | |
187 | void JSURLSearchParams::destroy(JSC::JSCell* cell) |
188 | { |
189 | JSURLSearchParams* thisObject = static_cast<JSURLSearchParams*>(cell); |
190 | thisObject->JSURLSearchParams::~JSURLSearchParams(); |
191 | } |
192 | |
193 | template<> inline JSURLSearchParams* IDLOperation<JSURLSearchParams>::cast(ExecState& state) |
194 | { |
195 | return jsDynamicCast<JSURLSearchParams*>(state.vm(), state.thisValue()); |
196 | } |
197 | |
198 | EncodedJSValue jsURLSearchParamsConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
199 | { |
200 | VM& vm = state->vm(); |
201 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
202 | auto* prototype = jsDynamicCast<JSURLSearchParamsPrototype*>(vm, JSValue::decode(thisValue)); |
203 | if (UNLIKELY(!prototype)) |
204 | return throwVMTypeError(state, throwScope); |
205 | return JSValue::encode(JSURLSearchParams::getConstructor(state->vm(), prototype->globalObject())); |
206 | } |
207 | |
208 | bool setJSURLSearchParamsConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
209 | { |
210 | VM& vm = state->vm(); |
211 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
212 | auto* prototype = jsDynamicCast<JSURLSearchParamsPrototype*>(vm, JSValue::decode(thisValue)); |
213 | if (UNLIKELY(!prototype)) { |
214 | throwVMTypeError(state, throwScope); |
215 | return false; |
216 | } |
217 | // Shadowing a built-in constructor |
218 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
219 | } |
220 | |
221 | static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunctionAppendBody(JSC::ExecState* state, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
222 | { |
223 | UNUSED_PARAM(state); |
224 | UNUSED_PARAM(throwScope); |
225 | auto& impl = castedThis->wrapped(); |
226 | if (UNLIKELY(state->argumentCount() < 2)) |
227 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
228 | auto name = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
229 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
230 | auto value = convert<IDLUSVString>(*state, state->uncheckedArgument(1)); |
231 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
232 | impl.append(WTFMove(name), WTFMove(value)); |
233 | return JSValue::encode(jsUndefined()); |
234 | } |
235 | |
236 | EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionAppend(ExecState* state) |
237 | { |
238 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionAppendBody>(*state, "append" ); |
239 | } |
240 | |
241 | static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunctionDeleteBody(JSC::ExecState* state, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
242 | { |
243 | UNUSED_PARAM(state); |
244 | UNUSED_PARAM(throwScope); |
245 | auto& impl = castedThis->wrapped(); |
246 | if (UNLIKELY(state->argumentCount() < 1)) |
247 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
248 | auto name = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
249 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
250 | impl.remove(WTFMove(name)); |
251 | return JSValue::encode(jsUndefined()); |
252 | } |
253 | |
254 | EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionDelete(ExecState* state) |
255 | { |
256 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionDeleteBody>(*state, "delete" ); |
257 | } |
258 | |
259 | static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunctionGetBody(JSC::ExecState* state, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
260 | { |
261 | UNUSED_PARAM(state); |
262 | UNUSED_PARAM(throwScope); |
263 | auto& impl = castedThis->wrapped(); |
264 | if (UNLIKELY(state->argumentCount() < 1)) |
265 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
266 | auto name = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
267 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
268 | return JSValue::encode(toJS<IDLNullable<IDLUSVString>>(*state, impl.get(WTFMove(name)))); |
269 | } |
270 | |
271 | EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionGet(ExecState* state) |
272 | { |
273 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionGetBody>(*state, "get" ); |
274 | } |
275 | |
276 | static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunctionGetAllBody(JSC::ExecState* state, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
277 | { |
278 | UNUSED_PARAM(state); |
279 | UNUSED_PARAM(throwScope); |
280 | auto& impl = castedThis->wrapped(); |
281 | if (UNLIKELY(state->argumentCount() < 1)) |
282 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
283 | auto name = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
284 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
285 | return JSValue::encode(toJS<IDLSequence<IDLUSVString>>(*state, *castedThis->globalObject(), impl.getAll(WTFMove(name)))); |
286 | } |
287 | |
288 | EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionGetAll(ExecState* state) |
289 | { |
290 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionGetAllBody>(*state, "getAll" ); |
291 | } |
292 | |
293 | static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunctionHasBody(JSC::ExecState* state, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
294 | { |
295 | UNUSED_PARAM(state); |
296 | UNUSED_PARAM(throwScope); |
297 | auto& impl = castedThis->wrapped(); |
298 | if (UNLIKELY(state->argumentCount() < 1)) |
299 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
300 | auto name = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
301 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
302 | return JSValue::encode(toJS<IDLBoolean>(impl.has(WTFMove(name)))); |
303 | } |
304 | |
305 | EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionHas(ExecState* state) |
306 | { |
307 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionHasBody>(*state, "has" ); |
308 | } |
309 | |
310 | static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunctionSetBody(JSC::ExecState* state, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
311 | { |
312 | UNUSED_PARAM(state); |
313 | UNUSED_PARAM(throwScope); |
314 | auto& impl = castedThis->wrapped(); |
315 | if (UNLIKELY(state->argumentCount() < 2)) |
316 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
317 | auto name = convert<IDLUSVString>(*state, state->uncheckedArgument(0)); |
318 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
319 | auto value = convert<IDLUSVString>(*state, state->uncheckedArgument(1)); |
320 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
321 | impl.set(WTFMove(name), WTFMove(value)); |
322 | return JSValue::encode(jsUndefined()); |
323 | } |
324 | |
325 | EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionSet(ExecState* state) |
326 | { |
327 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionSetBody>(*state, "set" ); |
328 | } |
329 | |
330 | static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunctionSortBody(JSC::ExecState* state, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
331 | { |
332 | UNUSED_PARAM(state); |
333 | UNUSED_PARAM(throwScope); |
334 | auto& impl = castedThis->wrapped(); |
335 | impl.sort(); |
336 | return JSValue::encode(jsUndefined()); |
337 | } |
338 | |
339 | EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionSort(ExecState* state) |
340 | { |
341 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionSortBody>(*state, "sort" ); |
342 | } |
343 | |
344 | static inline JSC::EncodedJSValue jsURLSearchParamsPrototypeFunctionToStringBody(JSC::ExecState* state, typename IDLOperation<JSURLSearchParams>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
345 | { |
346 | UNUSED_PARAM(state); |
347 | UNUSED_PARAM(throwScope); |
348 | auto& impl = castedThis->wrapped(); |
349 | return JSValue::encode(toJS<IDLDOMString>(*state, impl.toString())); |
350 | } |
351 | |
352 | EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionToString(ExecState* state) |
353 | { |
354 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionToStringBody>(*state, "toString" ); |
355 | } |
356 | |
357 | struct URLSearchParamsIteratorTraits { |
358 | static constexpr JSDOMIteratorType type = JSDOMIteratorType::Map; |
359 | using KeyType = IDLUSVString; |
360 | using ValueType = IDLUSVString; |
361 | }; |
362 | |
363 | using URLSearchParamsIterator = JSDOMIterator<JSURLSearchParams, URLSearchParamsIteratorTraits>; |
364 | using URLSearchParamsIteratorPrototype = JSDOMIteratorPrototype<JSURLSearchParams, URLSearchParamsIteratorTraits>; |
365 | |
366 | template<> |
367 | const JSC::ClassInfo URLSearchParamsIterator::s_info = { "URLSearchParams Iterator" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(URLSearchParamsIterator) }; |
368 | |
369 | template<> |
370 | const JSC::ClassInfo URLSearchParamsIteratorPrototype::s_info = { "URLSearchParams Iterator" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(URLSearchParamsIteratorPrototype) }; |
371 | |
372 | static inline EncodedJSValue jsURLSearchParamsPrototypeFunctionEntriesCaller(ExecState*, JSURLSearchParams* thisObject, JSC::ThrowScope&) |
373 | { |
374 | return JSValue::encode(iteratorCreate<URLSearchParamsIterator>(*thisObject, IterationKind::KeyValue)); |
375 | } |
376 | |
377 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionEntries(JSC::ExecState* state) |
378 | { |
379 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionEntriesCaller>(*state, "entries" ); |
380 | } |
381 | |
382 | static inline EncodedJSValue jsURLSearchParamsPrototypeFunctionKeysCaller(ExecState*, JSURLSearchParams* thisObject, JSC::ThrowScope&) |
383 | { |
384 | return JSValue::encode(iteratorCreate<URLSearchParamsIterator>(*thisObject, IterationKind::Key)); |
385 | } |
386 | |
387 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionKeys(JSC::ExecState* state) |
388 | { |
389 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionKeysCaller>(*state, "keys" ); |
390 | } |
391 | |
392 | static inline EncodedJSValue jsURLSearchParamsPrototypeFunctionValuesCaller(ExecState*, JSURLSearchParams* thisObject, JSC::ThrowScope&) |
393 | { |
394 | return JSValue::encode(iteratorCreate<URLSearchParamsIterator>(*thisObject, IterationKind::Value)); |
395 | } |
396 | |
397 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionValues(JSC::ExecState* state) |
398 | { |
399 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionValuesCaller>(*state, "values" ); |
400 | } |
401 | |
402 | static inline EncodedJSValue jsURLSearchParamsPrototypeFunctionForEachCaller(ExecState* state, JSURLSearchParams* thisObject, JSC::ThrowScope& throwScope) |
403 | { |
404 | return JSValue::encode(iteratorForEach<URLSearchParamsIterator>(*state, *thisObject, throwScope)); |
405 | } |
406 | |
407 | JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionForEach(JSC::ExecState* state) |
408 | { |
409 | return IDLOperation<JSURLSearchParams>::call<jsURLSearchParamsPrototypeFunctionForEachCaller>(*state, "forEach" ); |
410 | } |
411 | |
412 | void JSURLSearchParams::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
413 | { |
414 | auto* thisObject = jsCast<JSURLSearchParams*>(cell); |
415 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
416 | if (thisObject->scriptExecutionContext()) |
417 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
418 | Base::heapSnapshot(cell, builder); |
419 | } |
420 | |
421 | bool JSURLSearchParamsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
422 | { |
423 | UNUSED_PARAM(handle); |
424 | UNUSED_PARAM(visitor); |
425 | UNUSED_PARAM(reason); |
426 | return false; |
427 | } |
428 | |
429 | void JSURLSearchParamsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
430 | { |
431 | auto* jsURLSearchParams = static_cast<JSURLSearchParams*>(handle.slot()->asCell()); |
432 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
433 | uncacheWrapper(world, &jsURLSearchParams->wrapped(), jsURLSearchParams); |
434 | } |
435 | |
436 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<URLSearchParams>&& impl) |
437 | { |
438 | // If you hit this failure the interface definition has the ImplementationLacksVTable |
439 | // attribute. You should remove that attribute. If the class has subclasses |
440 | // that may be passed through this toJS() function you should use the SkipVTableValidation |
441 | // attribute to URLSearchParams. |
442 | static_assert(!std::is_polymorphic<URLSearchParams>::value, "URLSearchParams is polymorphic but the IDL claims it is not" ); |
443 | return createWrapper<URLSearchParams>(globalObject, WTFMove(impl)); |
444 | } |
445 | |
446 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, URLSearchParams& impl) |
447 | { |
448 | return wrap(state, globalObject, impl); |
449 | } |
450 | |
451 | URLSearchParams* JSURLSearchParams::toWrapped(JSC::VM& vm, JSC::JSValue value) |
452 | { |
453 | if (auto* wrapper = jsDynamicCast<JSURLSearchParams*>(vm, value)) |
454 | return &wrapper->wrapped(); |
455 | return nullptr; |
456 | } |
457 | |
458 | } |
459 | |