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