blob: ac4a775f8b76be329045a1407a89d1cbeafe4e46 [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 "JSSVGLength.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMConstructor.h"
#include "JSDOMConvert.h"
#include "URL.h"
#include <runtime/Error.h>
#include <runtime/FunctionPrototype.h>
#include <runtime/JSString.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthPrototypeFunctionNewValueSpecifiedUnits(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsSVGLengthPrototypeFunctionConvertToSpecifiedUnits(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsSVGLengthUnitType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsSVGLengthValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSVGLengthValue(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSVGLengthValueInSpecifiedUnits(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSVGLengthValueInSpecifiedUnits(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSVGLengthValueAsString(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSVGLengthValueAsString(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
JSC::EncodedJSValue jsSVGLengthConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSSVGLengthConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSSVGLengthPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSSVGLengthPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSSVGLengthPrototype* ptr = new (NotNull, JSC::allocateCell<JSSVGLengthPrototype>(vm.heap)) JSSVGLengthPrototype(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:
JSSVGLengthPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructorNotConstructable<JSSVGLength> JSSVGLengthConstructor;
/* Hash table for constructor */
static const HashTableValue JSSVGLengthConstructorTableValues[] =
{
{ "SVG_LENGTHTYPE_UNKNOWN", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } },
{ "SVG_LENGTHTYPE_NUMBER", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } },
{ "SVG_LENGTHTYPE_PERCENTAGE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } },
{ "SVG_LENGTHTYPE_EMS", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } },
{ "SVG_LENGTHTYPE_EXS", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } },
{ "SVG_LENGTHTYPE_PX", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(5) } },
{ "SVG_LENGTHTYPE_CM", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(6) } },
{ "SVG_LENGTHTYPE_MM", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } },
{ "SVG_LENGTHTYPE_IN", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } },
{ "SVG_LENGTHTYPE_PT", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(9) } },
{ "SVG_LENGTHTYPE_PC", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(10) } },
};
static_assert(SVGLength::SVG_LENGTHTYPE_UNKNOWN == 0, "SVG_LENGTHTYPE_UNKNOWN in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_NUMBER == 1, "SVG_LENGTHTYPE_NUMBER in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_PERCENTAGE == 2, "SVG_LENGTHTYPE_PERCENTAGE in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_EMS == 3, "SVG_LENGTHTYPE_EMS in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_EXS == 4, "SVG_LENGTHTYPE_EXS in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_PX == 5, "SVG_LENGTHTYPE_PX in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_CM == 6, "SVG_LENGTHTYPE_CM in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_MM == 7, "SVG_LENGTHTYPE_MM in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_IN == 8, "SVG_LENGTHTYPE_IN in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_PT == 9, "SVG_LENGTHTYPE_PT in SVGLength does not match value from IDL");
static_assert(SVGLength::SVG_LENGTHTYPE_PC == 10, "SVG_LENGTHTYPE_PC in SVGLength does not match value from IDL");
template<> JSValue JSSVGLengthConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
UNUSED_PARAM(vm);
return globalObject.functionPrototype();
}
template<> void JSSVGLengthConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSSVGLength::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("SVGLength"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(0), ReadOnly | DontEnum);
reifyStaticProperties(vm, JSSVGLengthConstructorTableValues, *this);
}
template<> const ClassInfo JSSVGLengthConstructor::s_info = { "SVGLength", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSVGLengthConstructor) };
/* Hash table for prototype */
static const HashTableValue JSSVGLengthPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGLengthConstructor) } },
{ "unitType", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthUnitType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "value", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthValue), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGLengthValue) } },
{ "valueInSpecifiedUnits", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthValueInSpecifiedUnits), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGLengthValueInSpecifiedUnits) } },
{ "valueAsString", CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsSVGLengthValueAsString), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSSVGLengthValueAsString) } },
{ "newValueSpecifiedUnits", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsSVGLengthPrototypeFunctionNewValueSpecifiedUnits), (intptr_t) (2) } },
{ "convertToSpecifiedUnits", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsSVGLengthPrototypeFunctionConvertToSpecifiedUnits), (intptr_t) (1) } },
{ "SVG_LENGTHTYPE_UNKNOWN", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(0) } },
{ "SVG_LENGTHTYPE_NUMBER", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(1) } },
{ "SVG_LENGTHTYPE_PERCENTAGE", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(2) } },
{ "SVG_LENGTHTYPE_EMS", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(3) } },
{ "SVG_LENGTHTYPE_EXS", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(4) } },
{ "SVG_LENGTHTYPE_PX", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(5) } },
{ "SVG_LENGTHTYPE_CM", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(6) } },
{ "SVG_LENGTHTYPE_MM", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(7) } },
{ "SVG_LENGTHTYPE_IN", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(8) } },
{ "SVG_LENGTHTYPE_PT", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(9) } },
{ "SVG_LENGTHTYPE_PC", DontDelete | ReadOnly | ConstantInteger, NoIntrinsic, { (long long)(10) } },
};
const ClassInfo JSSVGLengthPrototype::s_info = { "SVGLengthPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSVGLengthPrototype) };
void JSSVGLengthPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSSVGLengthPrototypeTableValues, *this);
}
const ClassInfo JSSVGLength::s_info = { "SVGLength", &Base::s_info, 0, CREATE_METHOD_TABLE(JSSVGLength) };
JSSVGLength::JSSVGLength(Structure* structure, JSDOMGlobalObject& globalObject, Ref<SVGPropertyTearOff<SVGLength>>&& impl)
: JSDOMWrapper<SVGPropertyTearOff<SVGLength>>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSSVGLength::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSSVGLengthPrototype::create(vm, globalObject, JSSVGLengthPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSSVGLength::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSSVGLength>(vm, globalObject);
}
void JSSVGLength::destroy(JSC::JSCell* cell)
{
JSSVGLength* thisObject = static_cast<JSSVGLength*>(cell);
thisObject->JSSVGLength::~JSSVGLength();
}
EncodedJSValue jsSVGLengthUnitType(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<JSSVGLength*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SVGLength", "unitType");
}
SVGLength& impl = castedThis->wrapped().propertyReference();
JSValue result = jsNumber(impl.unitType());
return JSValue::encode(result);
}
EncodedJSValue jsSVGLengthValue(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<JSSVGLength*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SVGLength", "value");
}
return JSValue::encode(castedThis->value(*state));
}
EncodedJSValue jsSVGLengthValueInSpecifiedUnits(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<JSSVGLength*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SVGLength", "valueInSpecifiedUnits");
}
SVGLength& impl = castedThis->wrapped().propertyReference();
JSValue result = jsNumber(impl.valueInSpecifiedUnits());
return JSValue::encode(result);
}
EncodedJSValue jsSVGLengthValueAsString(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<JSSVGLength*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "SVGLength", "valueAsString");
}
SVGLength& impl = castedThis->wrapped().propertyReference();
JSValue result = jsStringWithCache(state, impl.valueAsString());
return JSValue::encode(result);
}
EncodedJSValue jsSVGLengthConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSSVGLengthPrototype* domObject = jsDynamicCast<JSSVGLengthPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSSVGLength::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSSVGLengthConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSSVGLengthPrototype* domObject = jsDynamicCast<JSSVGLengthPrototype*>(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 setJSSVGLengthValue(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);
JSSVGLength* castedThis = jsDynamicCast<JSSVGLength*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SVGLength", "value");
}
castedThis->setValue(*state, value);
return true;
}
bool setJSSVGLengthValueInSpecifiedUnits(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);
JSSVGLength* castedThis = jsDynamicCast<JSSVGLength*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SVGLength", "valueInSpecifiedUnits");
}
auto& impl = castedThis->wrapped();
auto nativeValue = convert<float>(*state, value, ShouldAllowNonFinite::Yes);
RETURN_IF_EXCEPTION(throwScope, false);
if (impl.isReadOnly()) {
setDOMException(state, throwScope, NO_MODIFICATION_ALLOWED_ERR);
return false;
}
SVGLength& podImpl = impl.propertyReference();
podImpl.setValueInSpecifiedUnits(nativeValue);
impl.commitChange();
return true;
}
bool setJSSVGLengthValueAsString(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);
JSSVGLength* castedThis = jsDynamicCast<JSSVGLength*>(JSValue::decode(thisValue));
if (UNLIKELY(!castedThis)) {
return throwSetterTypeError(*state, throwScope, "SVGLength", "valueAsString");
}
auto& impl = castedThis->wrapped();
ExceptionCode ec = 0;
auto nativeValue = value.toWTFString(state);
RETURN_IF_EXCEPTION(throwScope, false);
if (impl.isReadOnly()) {
setDOMException(state, throwScope, NO_MODIFICATION_ALLOWED_ERR);
return false;
}
SVGLength& podImpl = impl.propertyReference();
podImpl.setValueAsString(nativeValue, ec);
setDOMException(state, throwScope, ec);
if (LIKELY(!ec))
impl.commitChange();
return true;
}
JSValue JSSVGLength::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSSVGLengthConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
EncodedJSValue JSC_HOST_CALL jsSVGLengthPrototypeFunctionNewValueSpecifiedUnits(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSSVGLength*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "SVGLength", "newValueSpecifiedUnits");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSSVGLength::info());
auto& impl = castedThis->wrapped();
if (impl.isReadOnly()) {
setDOMException(state, throwScope, NO_MODIFICATION_ALLOWED_ERR);
return JSValue::encode(jsUndefined());
}
SVGLength& podImpl = impl.propertyReference();
if (UNLIKELY(state->argumentCount() < 2))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
ExceptionCode ec = 0;
auto unitType = convert<uint16_t>(*state, state->uncheckedArgument(0), NormalConversion);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
auto valueInSpecifiedUnits = convert<float>(*state, state->uncheckedArgument(1), ShouldAllowNonFinite::Yes);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
podImpl.newValueSpecifiedUnits(WTFMove(unitType), WTFMove(valueInSpecifiedUnits), ec);
setDOMException(state, throwScope, ec);
if (LIKELY(!ec))
impl.commitChange();
return JSValue::encode(jsUndefined());
}
EncodedJSValue JSC_HOST_CALL jsSVGLengthPrototypeFunctionConvertToSpecifiedUnits(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSSVGLength*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "SVGLength", "convertToSpecifiedUnits");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSSVGLength::info());
return JSValue::encode(castedThis->convertToSpecifiedUnits(*state));
}
bool JSSVGLengthOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
UNUSED_PARAM(handle);
UNUSED_PARAM(visitor);
return false;
}
void JSSVGLengthOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsSVGLength = jsCast<JSSVGLength*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsSVGLength->wrapped(), jsSVGLength);
}
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<SVGPropertyTearOff<SVGLength>>&& impl)
{
return createWrapper<SVGPropertyTearOff<SVGLength>>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, SVGPropertyTearOff<SVGLength>& impl)
{
return wrap(state, globalObject, impl);
}
SVGPropertyTearOff<SVGLength>* JSSVGLength::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSSVGLength*>(value))
return &wrapper->wrapped();
return nullptr;
}
}