blob: e318a3f7e5100d7d4d7e43798ce5ee8a75bc5743 [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 "JSProgressEvent.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 jsProgressEventLengthComputable(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsProgressEventLoaded(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsProgressEventTotal(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
JSC::EncodedJSValue jsProgressEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSProgressEventConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSProgressEventPrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSProgressEventPrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSProgressEventPrototype* ptr = new (NotNull, JSC::allocateCell<JSProgressEventPrototype>(vm.heap)) JSProgressEventPrototype(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:
JSProgressEventPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
typedef JSDOMConstructor<JSProgressEvent> JSProgressEventConstructor;
template<> EncodedJSValue JSC_HOST_CALL JSProgressEventConstructor::construct(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
auto* jsConstructor = jsCast<JSProgressEventConstructor*>(state->callee());
ASSERT(jsConstructor);
if (!jsConstructor->scriptExecutionContext())
return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "ProgressEvent");
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());
ProgressEventInit 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 (!fillProgressEventInit(eventInit, dictionary))
return JSValue::encode(jsUndefined());
}
Ref<ProgressEvent> event = ProgressEvent::createForBindings(eventType, eventInit);
return JSValue::encode(createWrapper<ProgressEvent>(jsConstructor->globalObject(), WTFMove(event)));
}
bool fillProgressEventInit(ProgressEventInit& eventInit, JSDictionary& dictionary)
{
if (!fillEventInit(eventInit, dictionary))
return false;
if (!dictionary.tryGetProperty("lengthComputable", eventInit.lengthComputable))
return false;
if (!dictionary.tryGetProperty("loaded", eventInit.loaded))
return false;
if (!dictionary.tryGetProperty("total", eventInit.total))
return false;
return true;
}
template<> JSValue JSProgressEventConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
{
return JSEvent::getConstructor(vm, &globalObject);
}
template<> void JSProgressEventConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
{
putDirect(vm, vm.propertyNames->prototype, JSProgressEvent::prototype(vm, &globalObject), DontDelete | ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String(ASCIILiteral("ProgressEvent"))), ReadOnly | DontEnum);
putDirect(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum);
}
template<> const ClassInfo JSProgressEventConstructor::s_info = { "ProgressEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSProgressEventConstructor) };
/* Hash table for prototype */
static const HashTableValue JSProgressEventPrototypeTableValues[] =
{
{ "constructor", DontEnum, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProgressEventConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSProgressEventConstructor) } },
{ "lengthComputable", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProgressEventLengthComputable), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "loaded", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProgressEventLoaded), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "total", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsProgressEventTotal), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
};
const ClassInfo JSProgressEventPrototype::s_info = { "ProgressEventPrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSProgressEventPrototype) };
void JSProgressEventPrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSProgressEventPrototypeTableValues, *this);
}
const ClassInfo JSProgressEvent::s_info = { "ProgressEvent", &Base::s_info, 0, CREATE_METHOD_TABLE(JSProgressEvent) };
JSProgressEvent::JSProgressEvent(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ProgressEvent>&& impl)
: JSEvent(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSProgressEvent::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSProgressEventPrototype::create(vm, globalObject, JSProgressEventPrototype::createStructure(vm, globalObject, JSEvent::prototype(vm, globalObject)));
}
JSObject* JSProgressEvent::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSProgressEvent>(vm, globalObject);
}
EncodedJSValue jsProgressEventLengthComputable(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<JSProgressEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "ProgressEvent", "lengthComputable");
}
auto& impl = castedThis->wrapped();
JSValue result = jsBoolean(impl.lengthComputable());
return JSValue::encode(result);
}
EncodedJSValue jsProgressEventLoaded(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<JSProgressEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "ProgressEvent", "loaded");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.loaded());
return JSValue::encode(result);
}
EncodedJSValue jsProgressEventTotal(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<JSProgressEvent*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "ProgressEvent", "total");
}
auto& impl = castedThis->wrapped();
JSValue result = jsNumber(impl.total());
return JSValue::encode(result);
}
EncodedJSValue jsProgressEventConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSProgressEventPrototype* domObject = jsDynamicCast<JSProgressEventPrototype*>(JSValue::decode(thisValue));
if (UNLIKELY(!domObject))
return throwVMTypeError(state, throwScope);
return JSValue::encode(JSProgressEvent::getConstructor(state->vm(), domObject->globalObject()));
}
bool setJSProgressEventConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSProgressEventPrototype* domObject = jsDynamicCast<JSProgressEventPrototype*>(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 JSProgressEvent::getConstructor(VM& vm, const JSGlobalObject* globalObject)
{
return getDOMConstructor<JSProgressEventConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
}
}