blob: 7b044d508bbb8c2e069abb499e60d5f9d414ee23 [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 "JSDOMTokenList.h"
#include "Element.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "JSDOMIterator.h"
#include "JSNodeCustom.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/FunctionPrototype.h>
#include <runtime/JSString.h>
#include <runtime/PropertyNameArray.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionItem(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionContains(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionAdd(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionRemove(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToggle(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionReplace(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToString(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsDOMTokenListLength(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsDOMTokenListValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSDOMTokenListValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsDOMTokenListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSDOMTokenListConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSDOMTokenListPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSDOMTokenListPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSDOMTokenListPrototype* ptr = new (NotNull, JSC::allocateCell<JSDOMTokenListPrototype>(vm.heap)) JSDOMTokenListPrototype(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:
JSDOMTokenListPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSDOMTokenList> JSDOMTokenListConstructor;
template<> JSValue JSDOMTokenListConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
UNUSED_PARAM(vm);
return globalObject.functionPrototype();
}
template<> void JSDOMTokenListConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSDOMTokenList::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("DOMTokenList"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSDOMTokenListConstructor::s_info = { "DOMTokenList", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDOMTokenListConstructor) };
/* Hash table for prototype */
static const HashTableValue JSDOMTokenListPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMTokenListConstructor) } },
{ "length", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListLength), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "value", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDOMTokenListValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDOMTokenListValue) } },
{ "item", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionItem), (intptr_t) (1) } },
{ "contains", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionContains), (intptr_t) (1) } },
{ "add", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionAdd), (intptr_t) (0) } },
{ "remove", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionRemove), (intptr_t) (0) } },
{ "toggle", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionToggle), (intptr_t) (1) } },
{ "replace", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionReplace), (intptr_t) (2) } },
{ "toString", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsDOMTokenListPrototypeFunctionToString), (intptr_t) (0) } },
};
const ClassInfo JSDOMTokenListPrototype::s_info = { "DOMTokenListPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDOMTokenListPrototype) };
void JSDOMTokenListPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSDOMTokenListPrototypeTableValues, *this);
addValueIterableMethods(*globalObject(), *this);
}
const ClassInfo JSDOMTokenList::s_info = { "DOMTokenList", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDOMTokenList) };
JSDOMTokenList::JSDOMTokenList(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DOMTokenList>&& impl)
: JSDOMWrapper<DOMTokenList>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSDOMTokenList::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSDOMTokenListPrototype::create(vm, globalObject, JSDOMTokenListPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSDOMTokenList::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSDOMTokenList>(vm, globalObject);
}
void JSDOMTokenList::destroy(JSC::JSCell* cell)
{
JSDOMTokenList* thisObject = static_cast<JSDOMTokenList*>(cell);
thisObject->JSDOMTokenList::~JSDOMTokenList();
}
bool JSDOMTokenList::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
{
auto* thisObject = jsCast<JSDOMTokenList*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Optional<uint32_t> optionalIndex = parseIndex(propertyName);
if (optionalIndex) {
unsigned index = optionalIndex.value();
unsigned attributes = ReadOnly;
slot.setValue(thisObject, attributes, jsStringOrUndefined(state, thisObject->wrapped().item(index)));
return true;
}
if (Base::getOwnPropertySlot(thisObject, state, propertyName, slot))
return true;
return false;
}
bool JSDOMTokenList::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
{
auto* thisObject = jsCast<JSDOMTokenList*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
if (LIKELY(index <= MAX_ARRAY_INDEX)) {
unsigned attributes = DontDelete | ReadOnly;
slot.setValue(thisObject, attributes, jsStringOrUndefined(state, thisObject->wrapped().item(index)));
return true;
}
return Base::getOwnPropertySlotByIndex(thisObject, state, index, slot);
}
EncodedJSValue jsDOMTokenListLength(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSDOMTokenList*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DOMTokenList", "length");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.length());
return JSValue::encode(result);
}
EncodedJSValue jsDOMTokenListValue(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
UNUSED_PARAM(thisValue);
JSValue decodedThisValue = JSValue::decode(thisValue);
auto* castedThis = jsDynamicCast<JSDOMTokenList*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DOMTokenList", "value");
}
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.value());
return JSValue::encode(result);
}
EncodedJSValue jsDOMTokenListConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSDOMTokenListPrototype* domObject = jsDynamicCast<JSDOMTokenListPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSDOMTokenList::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSDOMTokenListConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSDOMTokenListPrototype* domObject = jsDynamicCast<JSDOMTokenListPrototype*>(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);
}
bool setJSDOMTokenListValue(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue value = JSValue::decode(encodedValue);
UNUSED_PARAM(thisValue);
JSDOMTokenList* castedThis = jsDynamicCast<JSDOMTokenList*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "DOMTokenList", "value");
}
auto& impl = castedThis->wrapped();
auto nativeValue = value.toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, false);
impl.setValue(WTFMove(nativeValue));
return true;
}
void JSDOMTokenList::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
{
auto* thisObject = jsCast<JSDOMTokenList*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i)
propertyNames.add(Identifier::from(state, i));
Base::getOwnPropertyNames(thisObject, state, propertyNames, mode);
}
JSValue JSDOMTokenList::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSDOMTokenListConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionItem(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDOMTokenList*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DOMTokenList", "item");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMTokenList::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto index = convert<uint32_t>(*state, state->uncheckedArgument(0), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsStringOrNull(state, impl.item(WTFMove(index)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionContains(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDOMTokenList*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DOMTokenList", "contains");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMTokenList::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto token = state->uncheckedArgument(0).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsBoolean(impl.contains(WTFMove(token)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionAdd(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDOMTokenList*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DOMTokenList", "add");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMTokenList::info());
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto tokens = toArguments<VariadicHelper<JSC::JSValue, String>>(*state, 0);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.add(WTFMove(tokens.arguments.value()), ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionRemove(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDOMTokenList*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DOMTokenList", "remove");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMTokenList::info());
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto tokens = toArguments<VariadicHelper<JSC::JSValue, String>>(*state, 0);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.remove(WTFMove(tokens.arguments.value()), ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToggle(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDOMTokenList*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DOMTokenList", "toggle");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMTokenList::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
auto token = state->uncheckedArgument(0).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto force = state->argument(1).isUndefined() ? Optional<bool>() : state->uncheckedArgument(1).toBoolean(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
JSValue result = jsBoolean(impl.toggle(WTFMove(token), WTFMove(force), ec));
setDOMException(state, throwScope, ec);
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionReplace(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDOMTokenList*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DOMTokenList", "replace");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMTokenList::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 2))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
auto token = state->uncheckedArgument(0).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto newToken = state->uncheckedArgument(1).toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
impl.replace(WTFMove(token), WTFMove(newToken), ec);
setDOMException(state, throwScope, ec);
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsDOMTokenListPrototypeFunctionToString(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSDOMTokenList*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "DOMTokenList", "toString");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSDOMTokenList::info());
auto& impl = castedThis->wrapped();
JSValue result = jsStringWithCache(state, impl.value());
return JSValue::encode(result);
}
bool JSDOMTokenListOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
auto* jsDOMTokenList = jsCast<JSDOMTokenList*>(handle.slot()->asCell());
Element* element = WTF::getPtr(jsDOMTokenList->wrapped().element());
if (!element)
return false;
void* root = WebCore::root(element);
return visitor.containsOpaqueRoot(root);
}
void JSDOMTokenListOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsDOMTokenList = jsCast<JSDOMTokenList*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsDOMTokenList->wrapped(), jsDOMTokenList);
}
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<DOMTokenList>&& impl)
{
return createWrapper<DOMTokenList>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, DOMTokenList& impl)
{
return wrap(state, globalObject, impl);
}
DOMTokenList* JSDOMTokenList::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSDOMTokenList*>(value))
return &wrapper->wrapped();
return nullptr;
}
}