blob: c8ced36addc79fed1574ea4097dd48a8536eb9ef [file] [log] [blame]
/*
This file is part of the WebKit open source project.
This file has been generated by generate-bindings.pl. DO NOT MODIFY!
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "JSURLSearchParams.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSURLSearchParams.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/FunctionPrototype.h>
#include <runtime/JSArray.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionAppend(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionDelete(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionGet(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionGetAll(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionHas(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionSet(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionToString(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsURLSearchParamsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSURLSearchParamsConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSURLSearchParamsPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSURLSearchParamsPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSURLSearchParamsPrototype* ptr = new (NotNull, JSC::allocateCell<JSURLSearchParamsPrototype>(vm.heap)) JSURLSearchParamsPrototype(vm, globalObject, structure);
ptr->finishCreation(vm);
return ptr;
}
DECLARE_INFO;
static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
{
return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
}
private:
JSURLSearchParamsPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructor<JSURLSearchParams> JSURLSearchParamsConstructor;
static inline EncodedJSValue constructJSURLSearchParams1(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
auto* castedThis = jsCast<JSURLSearchParamsConstructor*>(state->callee());
ASSERT(castedThis);
auto arg = state->argument(0).isUndefined() ? emptyString() : valueToUSVString(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto object = URLSearchParams::create(WTFMove(arg));
return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
}
static inline EncodedJSValue constructJSURLSearchParams2(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
auto* castedThis = jsCast<JSURLSearchParamsConstructor*>(state->callee());
ASSERT(castedThis);
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto init = JSURLSearchParams::toWrapped(state->uncheckedArgument(0));
if (UNLIKELY(!init))
return throwArgumentTypeError(*state, throwScope, 0, "init", "URLSearchParams", nullptr, "URLSearchParams");
auto object = URLSearchParams::create(*init);
return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
}
template<> EncodedJSValue JSC_HOST_CALL JSURLSearchParamsConstructor::construct(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
size_t argsCount = std::min<size_t>(1, state->argumentCount());
if (argsCount == 0) {
return constructJSURLSearchParams1(state);
}
if (argsCount == 1) {
JSValue distinguishingArg = state->uncheckedArgument(0);
if (distinguishingArg.isUndefined())
return constructJSURLSearchParams1(state);
if (distinguishingArg.isObject() && asObject(distinguishingArg)->inherits(JSURLSearchParams::info()))
return constructJSURLSearchParams2(state);
return constructJSURLSearchParams1(state);
}
return throwVMTypeError(state, throwScope);
}
template<> JSValue JSURLSearchParamsConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
UNUSED_PARAM(vm);
return globalObject.functionPrototype();
}
template<> void JSURLSearchParamsConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSURLSearchParams::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("URLSearchParams"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSURLSearchParamsConstructor::s_info = { "URLSearchParams", &Base::s_info, 0, CREATE_METHOD_TABLE(JSURLSearchParamsConstructor) };
/* Hash table for prototype */
static const HashTableValue JSURLSearchParamsPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsURLSearchParamsConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSURLSearchParamsConstructor) } },
{ "append", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsURLSearchParamsPrototypeFunctionAppend), (intptr_t) (2) } },
{ "delete", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsURLSearchParamsPrototypeFunctionDelete), (intptr_t) (1) } },
{ "get", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsURLSearchParamsPrototypeFunctionGet), (intptr_t) (1) } },
{ "getAll", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsURLSearchParamsPrototypeFunctionGetAll), (intptr_t) (1) } },
{ "has", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsURLSearchParamsPrototypeFunctionHas), (intptr_t) (1) } },
{ "set", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsURLSearchParamsPrototypeFunctionSet), (intptr_t) (2) } },
{ "toString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsURLSearchParamsPrototypeFunctionToString), (intptr_t) (0) } },
};
const ClassInfo JSURLSearchParamsPrototype::s_info = { "URLSearchParamsPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSURLSearchParamsPrototype) };
void JSURLSearchParamsPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSURLSearchParamsPrototypeTableValues, *this);
}
const ClassInfo JSURLSearchParams::s_info = { "URLSearchParams", &Base::s_info, 0, CREATE_METHOD_TABLE(JSURLSearchParams) };
JSURLSearchParams::JSURLSearchParams(Structure* structure, JSDOMGlobalObject& globalObject, Ref<URLSearchParams>&& impl)
: JSDOMWrapper<URLSearchParams>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSURLSearchParams::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSURLSearchParamsPrototype::create(vm, globalObject, JSURLSearchParamsPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSURLSearchParams::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSURLSearchParams>(vm, globalObject);
}
void JSURLSearchParams::destroy(JSC::JSCell* cell)
{
JSURLSearchParams* thisObject = static_cast<JSURLSearchParams*>(cell);
thisObject->JSURLSearchParams::~JSURLSearchParams();
}
EncodedJSValue jsURLSearchParamsConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSURLSearchParamsPrototype* domObject = jsDynamicCast<JSURLSearchParamsPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSURLSearchParams::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSURLSearchParamsConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSURLSearchParamsPrototype* domObject = jsDynamicCast<JSURLSearchParamsPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject)) {
throwVMTypeError(state, throwScope);
return false;
}
// Shadowing a built-in constructor
return domObject->putDirect(state->vm(), state->propertyNames().constructor, value);
}
JSValue JSURLSearchParams::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSURLSearchParamsConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionAppend(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSURLSearchParams*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "URLSearchParams", "append");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSURLSearchParams::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 2))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto name = valueToUSVString(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto value = valueToUSVString(state, state->uncheckedArgument(1));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.append(WTFMove(name), WTFMove(value));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionDelete(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSURLSearchParams*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "URLSearchParams", "delete");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSURLSearchParams::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto name = valueToUSVString(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.remove(WTFMove(name));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionGet(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSURLSearchParams*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "URLSearchParams", "get");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSURLSearchParams::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto name = valueToUSVString(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsStringOrNull(state, impl.get(WTFMove(name)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionGetAll(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSURLSearchParams*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "URLSearchParams", "getAll");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSURLSearchParams::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto name = valueToUSVString(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsArray(state, castedThis->globalObject(), impl.getAll(WTFMove(name)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionHas(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSURLSearchParams*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "URLSearchParams", "has");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSURLSearchParams::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto name = valueToUSVString(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsBoolean(impl.has(WTFMove(name)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionSet(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSURLSearchParams*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "URLSearchParams", "set");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSURLSearchParams::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 2))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto name = valueToUSVString(state, state->uncheckedArgument(0));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto value = valueToUSVString(state, state->uncheckedArgument(1));
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.set(WTFMove(name), WTFMove(value));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsURLSearchParamsPrototypeFunctionToString(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSURLSearchParams*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "URLSearchParams", "toString");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSURLSearchParams::info());
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.toString());
return JSValue::encode(result);
}
bool JSURLSearchParamsOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
UNUSED_PARAM(handle);
UNUSED_PARAM(visitor);
return false;
}
void JSURLSearchParamsOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsURLSearchParams = jsCast<JSURLSearchParams*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsURLSearchParams->wrapped(), jsURLSearchParams);
}
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<URLSearchParams>&& impl)
{
#if COMPILER(CLANG)
// If you hit this failure the interface definition has the ImplementationLacksVTable
// attribute. You should remove that attribute. If the class has subclasses
// that may be passed through this toJS() function you should use the SkipVTableValidation
// attribute to URLSearchParams.
static_assert(!__is_polymorphic(URLSearchParams), "URLSearchParams is polymorphic but the IDL claims it is not");
#endif
return createWrapper<URLSearchParams>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, URLSearchParams& impl)
{
return wrap(state, globalObject, impl);
}
URLSearchParams* JSURLSearchParams::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSURLSearchParams*>(value))
return &wrapper->wrapped();
return nullptr;
}
}