blob: 62f2fe6077bbb44fb85e4003d923285a1d72ece7 [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 "JSTestEventTarget.h"
#include "Event.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSEvent.h"
#include "JSEventListener.h"
#include "JSNode.h"
#include "Node.h"
#include "wtf/text/AtomicString.h"
#include <runtime/Error.h>
#include <runtime/PropertyNameArray.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionItem(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionAddEventListener(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionRemoveEventListener(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionDispatchEvent(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsTestEventTargetConstructor(JSC::ExecState*, JSC::JSObject*, JSC::EncodedJSValue, JSC::PropertyName);
class JSTestEventTargetPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSTestEventTargetPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSTestEventTargetPrototype* ptr = new (NotNull, JSC::allocateCell<JSTestEventTargetPrototype>(vm.heap)) JSTestEventTargetPrototype(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:
JSTestEventTargetPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSTestEventTarget> JSTestEventTargetConstructor;
/* Hash table */
static const struct CompactHashIndex JSTestEventTargetTableIndex[2] = {
{ -1, -1 },
{ 0, -1 },
};
static const HashTableValue JSTestEventTargetTableValues[] =
{
{ "constructor", DontEnum | ReadOnly, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestEventTargetConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
};
static const HashTable JSTestEventTargetTable = { 1, 1, true, JSTestEventTargetTableValues, JSTestEventTargetTableIndex };
template<> void JSTestEventTargetConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSTestEventTarget::getPrototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("TestEventTarget"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
}
template<> const ClassInfo JSTestEventTargetConstructor::s_info = { "TestEventTargetConstructor", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestEventTargetConstructor) };
/* Hash table for prototype */
static const HashTableValue JSTestEventTargetPrototypeTableValues[] =
{
{ "item", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestEventTargetPrototypeFunctionItem), (intptr_t) (1) } },
{ "addEventListener", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestEventTargetPrototypeFunctionAddEventListener), (intptr_t) (2) } },
{ "removeEventListener", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestEventTargetPrototypeFunctionRemoveEventListener), (intptr_t) (2) } },
{ "dispatchEvent", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsTestEventTargetPrototypeFunctionDispatchEvent), (intptr_t) (1) } },
};
const ClassInfo JSTestEventTargetPrototype::s_info = { "TestEventTargetPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSTestEventTargetPrototype) };
void JSTestEventTargetPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSTestEventTargetPrototypeTableValues, *this);
}
const ClassInfo JSTestEventTarget::s_info = { "TestEventTarget", &Base::s_info, &JSTestEventTargetTable, CREATE_METHOD_TABLE(JSTestEventTarget) };
JSTestEventTarget::JSTestEventTarget(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestEventTarget>&& impl)
: JSDOMWrapper<TestEventTarget>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSTestEventTarget::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSTestEventTargetPrototype::create(vm, globalObject, JSTestEventTargetPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSTestEventTarget::getPrototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSTestEventTarget>(vm, globalObject);
}
void JSTestEventTarget::destroy(JSC::JSCell* cell)
{
JSTestEventTarget* thisObject = static_cast<JSTestEventTarget*>(cell);
thisObject->JSTestEventTarget::~JSTestEventTarget();
}
bool JSTestEventTarget::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
{
auto* thisObject = jsCast<JSTestEventTarget*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Optional<uint32_t> optionalIndex = parseIndex(propertyName);
if (optionalIndex && optionalIndex.value() < thisObject->wrapped().length()) {
unsigned index = optionalIndex.value();
unsigned attributes = DontDelete | ReadOnly;
slot.setValue(thisObject, attributes, toJS(state, thisObject->globalObject(), thisObject->wrapped().item(index)));
return true;
}
if (getStaticValueSlot<JSTestEventTarget, Base>(state, JSTestEventTargetTable, thisObject, propertyName, slot))
return true;
JSValue proto = thisObject->prototype();
if (proto.isObject() && jsCast<JSObject*>(proto)->hasProperty(state, propertyName))
return false;
if (!optionalIndex && thisObject->classInfo() == info()) {
JSValue value;
if (thisObject->nameGetter(state, propertyName, value)) {
slot.setValue(thisObject, ReadOnly | DontDelete | DontEnum, value);
return true;
}
}
return false;
}
bool JSTestEventTarget::getOwnPropertySlotByIndex(JSObject* object, ExecState* state, unsigned index, PropertySlot& slot)
{
auto* thisObject = jsCast<JSTestEventTarget*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
if (index < thisObject->wrapped().length()) {
unsigned attributes = DontDelete | ReadOnly;
slot.setValue(thisObject, attributes, toJS(state, thisObject->globalObject(), thisObject->wrapped().item(index)));
return true;
}
return Base::getOwnPropertySlotByIndex(thisObject, state, index, slot);
}
EncodedJSValue jsTestEventTargetConstructor(ExecState* state, JSObject*, EncodedJSValue thisValue, PropertyName)
{
JSTestEventTarget* domObject = jsDynamicCast<JSTestEventTarget*>(JSValue::decode(thisValue));
if (!domObject)
return throwVMTypeError(state);
return JSValue::encode(JSTestEventTarget::getConstructor(state->vm(), domObject->globalObject()));
}
void JSTestEventTarget::getOwnPropertyNames(JSObject* object, ExecState* state, PropertyNameArray& propertyNames, EnumerationMode mode)
{
auto* thisObject = jsCast<JSTestEventTarget*>(object);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
for (unsigned i = 0, count = thisObject->wrapped().length(); i < count; ++i)
propertyNames.add(Identifier::from(state, i));
if (mode.includeDontEnumProperties()) {
for (auto& propertyName : thisObject->wrapped().supportedPropertyNames())
propertyNames.add(Identifier::fromString(state, propertyName));
}
Base::getOwnPropertyNames(thisObject, state, propertyNames, mode);
}
JSValue JSTestEventTarget::getConstructor(VM& vm, JSGlobalObject* globalObject)
{
return getDOMConstructor<JSTestEventTargetConstructor>(vm, *jsCast<JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionItem(ExecState* state)
{
JSValue thisValue = state->thisValue();
JSTestEventTarget* castedThis = jsDynamicCast<JSTestEventTarget*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, "TestEventTarget", "item");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestEventTarget::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, createNotEnoughArgumentsError(state));
unsigned index = toUInt32(state, state->argument(0), NormalConversion);
if (UNLIKELY(state->hadException()))
return JSValue::encode(jsUndefined());
JSValue result = toJS(state, castedThis->globalObject(), WTF::getPtr(impl.item(index)));
return JSValue::encode(result);
}
EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionAddEventListener(ExecState* state)
{
JSValue thisValue = state->thisValue();
JSTestEventTarget* castedThis = jsDynamicCast<JSTestEventTarget*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, "TestEventTarget", "addEventListener");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestEventTarget::info());
auto& impl = castedThis->wrapped();
JSValue listener = state->argument(1);
if (UNLIKELY(!listener.isObject()))
return JSValue::encode(jsUndefined());
impl.addEventListener(state->argument(0).toString(state)->toAtomicString(state), createJSEventListenerForAdd(*state, *asObject(listener), *castedThis), state->argument(2).toBoolean(state));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionRemoveEventListener(ExecState* state)
{
JSValue thisValue = state->thisValue();
JSTestEventTarget* castedThis = jsDynamicCast<JSTestEventTarget*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, "TestEventTarget", "removeEventListener");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestEventTarget::info());
auto& impl = castedThis->wrapped();
JSValue listener = state->argument(1);
if (UNLIKELY(!listener.isObject()))
return JSValue::encode(jsUndefined());
impl.removeEventListener(state->argument(0).toString(state)->toAtomicString(state), createJSEventListenerForRemove(*state, *asObject(listener), *castedThis).ptr(), state->argument(2).toBoolean(state));
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsTestEventTargetPrototypeFunctionDispatchEvent(ExecState* state)
{
JSValue thisValue = state->thisValue();
JSTestEventTarget* castedThis = jsDynamicCast<JSTestEventTarget*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, "TestEventTarget", "dispatchEvent");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestEventTarget::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
Event* evt = JSEvent::toWrapped(state->argument(0));
if (UNLIKELY(state->hadException()))
return JSValue::encode(jsUndefined());
JSValue result = jsBoolean(impl.dispatchEvent(evt, ec));
setDOMException(state, ec);
return JSValue::encode(result);
}
void JSTestEventTarget::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSTestEventTarget*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
thisObject->wrapped().visitJSEventListeners(visitor);
}
bool JSTestEventTargetOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
auto* jsTestEventTarget = jsCast<JSTestEventTarget*>(handle.slot()->asCell());
if (jsTestEventTarget->wrapped().isFiringEventListeners())
return true;
UNUSED_PARAM(visitor);
return false;
}
void JSTestEventTargetOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsTestEventTarget = jsCast<JSTestEventTarget*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsTestEventTarget->wrapped(), jsTestEventTarget);
}
#if ENABLE(BINDING_INTEGRITY)
#if PLATFORM(WIN)
#pragma warning(disable: 4483)
extern "C" { extern void (*const __identifier("??_7TestEventTarget@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore15TestEventTargetE[]; }
#endif
#endif
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestEventTarget* impl)
{
if (!impl)
return jsNull();
return createNewWrapper<JSTestEventTarget>(globalObject, impl);
}
JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject* globalObject, TestEventTarget* impl)
{
if (!impl)
return jsNull();
if (JSValue result = getExistingWrapper<JSTestEventTarget>(globalObject, impl))
return result;
#if ENABLE(BINDING_INTEGRITY)
void* actualVTablePointer = *(reinterpret_cast<void**>(impl));
#if PLATFORM(WIN)
void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7TestEventTarget@WebCore@@6B@"));
#else
void* expectedVTablePointer = &_ZTVN7WebCore15TestEventTargetE[2];
#if COMPILER(CLANG)
// If this fails TestEventTarget does not have a vtable, so you need to add the
// ImplementationLacksVTable attribute to the interface definition
COMPILE_ASSERT(__is_polymorphic(TestEventTarget), TestEventTarget_is_not_polymorphic);
#endif
#endif
// If you hit this assertion you either have a use after free bug, or
// TestEventTarget has subclasses. If TestEventTarget has subclasses that get passed
// to toJS() we currently require TestEventTarget you to opt out of binding hardening
// by adding the SkipVTableValidation attribute to the interface IDL definition
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
return createNewWrapper<JSTestEventTarget>(globalObject, impl);
}
TestEventTarget* JSTestEventTarget::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSTestEventTarget*>(value))
return &wrapper->wrapped();
return nullptr;
}
}