blob: 3e2598ae051081645ea32b10c4fc61376a1a8927 [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"
#if ENABLE(PROXIMITY_EVENTS)
#include "JSDeviceProximityEvent.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDictionary.h"
#include <runtime/Error.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Attributes
JSC::EncodedJSValue jsDeviceProximityEventValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsDeviceProximityEventMin(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsDeviceProximityEventMax(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsDeviceProximityEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSDeviceProximityEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSDeviceProximityEventPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSDeviceProximityEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSDeviceProximityEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSDeviceProximityEventPrototype>(vm.heap)) JSDeviceProximityEventPrototype(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:
JSDeviceProximityEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructor<JSDeviceProximityEvent> JSDeviceProximityEventConstructor;
template<> EncodedJSValue JSC_HOST_CALL JSDeviceProximityEventConstructor::construct(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto* jsConstructor = jsCast<JSDeviceProximityEventConstructor*>(state->callee());
ASSERT(jsConstructor);
if (!jsConstructor->scriptExecutionContext())
return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "DeviceProximityEvent");
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
AtomicString eventType = state->uncheckedArgument(0).toString(state)->toAtomicString(state);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
DeviceProximityEventInit eventInit;
JSValue initializerValue = state->argument(1);
if (!initializerValue.isUndefinedOrNull()) {
// Given the above test, this will always yield an object.
JSObject* initializerObject = initializerValue.toObject(state);
ASSERT(!throwScope.exception());
// Create the dictionary wrapper from the initializer object.
JSDictionary dictionary(state, initializerObject);
// Attempt to fill in the EventInit.
if (!fillDeviceProximityEventInit(eventInit, dictionary))
return JSValue::encode(jsUndefined());
}
Ref<DeviceProximityEvent> event = DeviceProximityEvent::createForBindings(eventType, eventInit);
return JSValue::encode(createWrapper<DeviceProximityEvent>(jsConstructor->globalObject(), WTFMove(event)));
}
bool fillDeviceProximityEventInit(DeviceProximityEventInit& eventInit, JSDictionary& dictionary)
{
if (!fillEventInit(eventInit, dictionary))
return false;
if (!dictionary.tryGetProperty("value", eventInit.value))
return false;
if (!dictionary.tryGetProperty("min", eventInit.min))
return false;
if (!dictionary.tryGetProperty("max", eventInit.max))
return false;
return true;
}
template<> JSValue JSDeviceProximityEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSEvent::getConstructor(vm, &globalObject);
}
template<> void JSDeviceProximityEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSDeviceProximityEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("DeviceProximityEvent"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum);
}
template<> const ClassInfo JSDeviceProximityEventConstructor::s_info = { "DeviceProximityEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDeviceProximityEventConstructor) };
/* Hash table for prototype */
static const HashTableValue JSDeviceProximityEventPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDeviceProximityEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSDeviceProximityEventConstructor) } },
{ "value", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDeviceProximityEventValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "min", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDeviceProximityEventMin), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "max", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsDeviceProximityEventMax), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
};
const ClassInfo JSDeviceProximityEventPrototype::s_info = { "DeviceProximityEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDeviceProximityEventPrototype) };
void JSDeviceProximityEventPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSDeviceProximityEventPrototypeTableValues, *this);
}
const ClassInfo JSDeviceProximityEvent::s_info = { "DeviceProximityEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSDeviceProximityEvent) };
JSDeviceProximityEvent::JSDeviceProximityEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<DeviceProximityEvent>&& impl)
: JSEvent(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSDeviceProximityEvent::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSDeviceProximityEventPrototype::create(vm, globalObject, JSDeviceProximityEventPrototype::createStructure(vm, globalObject, JSEvent::prototype(vm, globalObject)));
}
JSObject* JSDeviceProximityEvent::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSDeviceProximityEvent>(vm, globalObject);
}
EncodedJSValue jsDeviceProximityEventValue(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<JSDeviceProximityEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DeviceProximityEvent", "value");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.value());
return JSValue::encode(result);
}
EncodedJSValue jsDeviceProximityEventMin(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<JSDeviceProximityEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DeviceProximityEvent", "min");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.min());
return JSValue::encode(result);
}
EncodedJSValue jsDeviceProximityEventMax(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<JSDeviceProximityEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "DeviceProximityEvent", "max");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.max());
return JSValue::encode(result);
}
EncodedJSValue jsDeviceProximityEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSDeviceProximityEventPrototype* domObject = jsDynamicCast<JSDeviceProximityEventPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSDeviceProximityEvent::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSDeviceProximityEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSDeviceProximityEventPrototype* domObject = jsDynamicCast<JSDeviceProximityEventPrototype*>(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 JSDeviceProximityEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSDeviceProximityEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
}
#endif // ENABLE(PROXIMITY_EVENTS)