blob: 0582c3e0065d3458a5816e04f83b52e8b89dd1cf [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(BATTERY_STATUS)
#include "JSBatteryManager.h"
#include "EventNames.h"
#include "JSDOMBinding.h"
#include "JSEventListener.h"
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Attributes
JSC::EncodedJSValue jsBatteryManagerCharging(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsBatteryManagerChargingTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsBatteryManagerDischargingTime(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsBatteryManagerLevel(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsBatteryManagerOnchargingchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSBatteryManagerOnchargingchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsBatteryManagerOnchargingtimechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSBatteryManagerOnchargingtimechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsBatteryManagerOndischargingtimechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSBatteryManagerOndischargingtimechange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsBatteryManagerOnlevelchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSBatteryManagerOnlevelchange(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
bool setJSBatteryManagerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSBatteryManagerPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSBatteryManagerPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSBatteryManagerPrototype* ptr = new (NotNull, JSC::allocateCell<JSBatteryManagerPrototype>(vm.heap)) JSBatteryManagerPrototype(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:
JSBatteryManagerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
/* Hash table for prototype */
static const HashTableValue JSBatteryManagerPrototypeTableValues[] =
{
{ "charging", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBatteryManagerCharging), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "chargingTime", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBatteryManagerChargingTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "dischargingTime", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBatteryManagerDischargingTime), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "level", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBatteryManagerLevel), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "onchargingchange", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBatteryManagerOnchargingchange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBatteryManagerOnchargingchange) } },
{ "onchargingtimechange", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBatteryManagerOnchargingtimechange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBatteryManagerOnchargingtimechange) } },
{ "ondischargingtimechange", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBatteryManagerOndischargingtimechange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBatteryManagerOndischargingtimechange) } },
{ "onlevelchange", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsBatteryManagerOnlevelchange), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSBatteryManagerOnlevelchange) } },
};
const ClassInfo JSBatteryManagerPrototype::s_info = { "BatteryManagerPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSBatteryManagerPrototype) };
void JSBatteryManagerPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSBatteryManagerPrototypeTableValues, *this);
}
const ClassInfo JSBatteryManager::s_info = { "BatteryManager", &Base::s_info, 0, CREATE_METHOD_TABLE(JSBatteryManager) };
JSBatteryManager::JSBatteryManager(Structure* structure, JSDOMGlobalObject& globalObject, Ref<BatteryManager>&& impl)
: JSEventTarget(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSBatteryManager::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSBatteryManagerPrototype::create(vm, globalObject, JSBatteryManagerPrototype::createStructure(vm, globalObject, JSEventTarget::prototype(vm, globalObject)));
}
JSObject* JSBatteryManager::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSBatteryManager>(vm, globalObject);
}
EncodedJSValue jsBatteryManagerCharging(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<JSBatteryManager*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BatteryManager", "charging");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.charging());
return JSValue::encode(result);
}
EncodedJSValue jsBatteryManagerChargingTime(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<JSBatteryManager*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BatteryManager", "chargingTime");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.chargingTime());
return JSValue::encode(result);
}
EncodedJSValue jsBatteryManagerDischargingTime(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<JSBatteryManager*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BatteryManager", "dischargingTime");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.dischargingTime());
return JSValue::encode(result);
}
EncodedJSValue jsBatteryManagerLevel(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<JSBatteryManager*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BatteryManager", "level");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.level());
return JSValue::encode(result);
}
EncodedJSValue jsBatteryManagerOnchargingchange(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<JSBatteryManager*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BatteryManager", "onchargingchange");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().chargingchangeEvent));
}
EncodedJSValue jsBatteryManagerOnchargingtimechange(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<JSBatteryManager*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BatteryManager", "onchargingtimechange");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().chargingtimechangeEvent));
}
EncodedJSValue jsBatteryManagerOndischargingtimechange(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<JSBatteryManager*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BatteryManager", "ondischargingtimechange");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().dischargingtimechangeEvent));
}
EncodedJSValue jsBatteryManagerOnlevelchange(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<JSBatteryManager*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "BatteryManager", "onlevelchange");
}
UNUSED_PARAM(state);
return JSValue::encode(eventHandlerAttribute(castedThis->wrapped(), eventNames().levelchangeEvent));
}
bool setJSBatteryManagerConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSBatteryManagerPrototype* domObject = jsDynamicCast<JSBatteryManagerPrototype*>(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 setJSBatteryManagerOnchargingchange(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);
JSBatteryManager* castedThis = jsDynamicCast<JSBatteryManager*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "BatteryManager", "onchargingchange");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().chargingchangeEvent, value);
return true;
}
bool setJSBatteryManagerOnchargingtimechange(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);
JSBatteryManager* castedThis = jsDynamicCast<JSBatteryManager*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "BatteryManager", "onchargingtimechange");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().chargingtimechangeEvent, value);
return true;
}
bool setJSBatteryManagerOndischargingtimechange(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);
JSBatteryManager* castedThis = jsDynamicCast<JSBatteryManager*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "BatteryManager", "ondischargingtimechange");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().dischargingtimechangeEvent, value);
return true;
}
bool setJSBatteryManagerOnlevelchange(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);
JSBatteryManager* castedThis = jsDynamicCast<JSBatteryManager*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "BatteryManager", "onlevelchange");
}
setEventHandlerAttribute(*state, *castedThis, castedThis->wrapped(), eventNames().levelchangeEvent, value);
return true;
}
void JSBatteryManager::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSBatteryManager*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
thisObject->wrapped().visitJSEventListeners(visitor);
}
bool JSBatteryManagerOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
auto* jsBatteryManager = jsCast<JSBatteryManager*>(handle.slot()->asCell());
if (jsBatteryManager->wrapped().hasPendingActivity())
return true;
if (jsBatteryManager->wrapped().isFiringEventListeners())
return true;
UNUSED_PARAM(visitor);
return false;
}
void JSBatteryManagerOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsBatteryManager = jsCast<JSBatteryManager*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsBatteryManager->wrapped(), jsBatteryManager);
}
#if ENABLE(BINDING_INTEGRITY)
#if PLATFORM(WIN)
#pragma warning(disable: 4483)
extern "C" { extern void (*const __identifier("??_7BatteryManager@WebCore@@6B@")[])(); }
#else
extern "C" { extern void* _ZTVN7WebCore14BatteryManagerE[]; }
#endif
#endif
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<BatteryManager>&& impl)
{
#if ENABLE(BINDING_INTEGRITY)
void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr()));
#if PLATFORM(WIN)
void* expectedVTablePointer = reinterpret_cast<void*>(__identifier("??_7BatteryManager@WebCore@@6B@"));
#else
void* expectedVTablePointer = &_ZTVN7WebCore14BatteryManagerE[2];
#if COMPILER(CLANG)
// If this fails BatteryManager does not have a vtable, so you need to add the
// ImplementationLacksVTable attribute to the interface definition
static_assert(__is_polymorphic(BatteryManager), "BatteryManager is not polymorphic");
#endif
#endif
// If you hit this assertion you either have a use after free bug, or
// BatteryManager has subclasses. If BatteryManager has subclasses that get passed
// to toJS() we currently require BatteryManager you to opt out of binding hardening
// by adding the SkipVTableValidation attribute to the interface IDL definition
RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer);
#endif
return createWrapper<BatteryManager>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, BatteryManager& impl)
{
return wrap(state, globalObject, impl);
}
BatteryManager* JSBatteryManager::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSBatteryManager*>(value))
return &wrapper->wrapped();
return nullptr;
}
}
#endif // ENABLE(BATTERY_STATUS)