blob: 053813afa351e253faeff214b86fe662618b127a [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(READABLE_STREAM_API)
#include "JSReadableStreamSource.h"
#include "ExceptionCode.h"
#include "JSDOMBinding.h"
#include "JSDOMPromise.h"
#include <runtime/Error.h>
#include <wtf/GetPtr.h>
using namespace JSC;
namespace WebCore {
// Functions
JSC::EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionStart(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionPull(JSC::ExecState*);
JSC::EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionCancel(JSC::ExecState*);
// Attributes
JSC::EncodedJSValue jsReadableStreamSourceController(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
bool setJSReadableStreamSourceConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
class JSReadableStreamSourcePrototype : public JSC::JSNonFinalObject {
public:
typedef JSC::JSNonFinalObject Base;
static JSReadableStreamSourcePrototype* create(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::Structure* structure)
{
JSReadableStreamSourcePrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamSourcePrototype>(vm.heap)) JSReadableStreamSourcePrototype(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:
JSReadableStreamSourcePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
: JSC::JSNonFinalObject(vm, structure)
{
}
void finishCreation(JSC::VM&);
};
/* Hash table for prototype */
static const HashTableValue JSReadableStreamSourcePrototypeTableValues[] =
{
{ "controller", ReadOnly | CustomAccessor, NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamSourceController), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } },
{ "start", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsReadableStreamSourcePrototypeFunctionStart), (intptr_t) (1) } },
{ "pull", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsReadableStreamSourcePrototypeFunctionPull), (intptr_t) (1) } },
{ "cancel", JSC::Function, NoIntrinsic, { (intptr_t)static_cast<NativeFunction>(jsReadableStreamSourcePrototypeFunctionCancel), (intptr_t) (1) } },
};
const ClassInfo JSReadableStreamSourcePrototype::s_info = { "ReadableStreamSourcePrototype", &Base::s_info, 0, CREATE_METHOD_TABLE(JSReadableStreamSourcePrototype) };
void JSReadableStreamSourcePrototype::finishCreation(VM& vm)
{
Base::finishCreation(vm);
reifyStaticProperties(vm, JSReadableStreamSourcePrototypeTableValues, *this);
}
const ClassInfo JSReadableStreamSource::s_info = { "ReadableStreamSource", &Base::s_info, 0, CREATE_METHOD_TABLE(JSReadableStreamSource) };
JSReadableStreamSource::JSReadableStreamSource(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ReadableStreamSource>&& impl)
: JSDOMWrapper<ReadableStreamSource>(structure, globalObject, WTFMove(impl))
{
}
JSObject* JSReadableStreamSource::createPrototype(VM& vm, JSGlobalObject* globalObject)
{
return JSReadableStreamSourcePrototype::create(vm, globalObject, JSReadableStreamSourcePrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
}
JSObject* JSReadableStreamSource::prototype(VM& vm, JSGlobalObject* globalObject)
{
return getDOMPrototype<JSReadableStreamSource>(vm, globalObject);
}
void JSReadableStreamSource::destroy(JSC::JSCell* cell)
{
JSReadableStreamSource* thisObject = static_cast<JSReadableStreamSource*>(cell);
thisObject->JSReadableStreamSource::~JSReadableStreamSource();
}
EncodedJSValue jsReadableStreamSourceController(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<JSReadableStreamSource*>(decodedThisValue);
if (UNLIKELY(!castedThis)) {
return throwGetterTypeError(*state, throwScope, "ReadableStreamSource", "controller");
}
return JSValue::encode(castedThis->controller(*state));
}
bool setJSReadableStreamSourceConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSValue value = JSValue::decode(encodedValue);
JSReadableStreamSourcePrototype* domObject = jsDynamicCast<JSReadableStreamSourcePrototype*>(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);
}
EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionStart(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSReadableStreamSource*>(thisValue);
if (UNLIKELY(!castedThis))
return createRejectedPromiseWithTypeError(*state, makeThisTypeErrorMessage("ReadableStreamSource", "start"));
ASSERT_GC_OBJECT_INHERITS(castedThis, JSReadableStreamSource::info());
return JSValue::encode(castedThis->start(*state));
}
EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionPull(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSReadableStreamSource*>(thisValue);
if (UNLIKELY(!castedThis))
return createRejectedPromiseWithTypeError(*state, makeThisTypeErrorMessage("ReadableStreamSource", "pull"));
ASSERT_GC_OBJECT_INHERITS(castedThis, JSReadableStreamSource::info());
return JSValue::encode(castedThis->pull(*state));
}
EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionCancel(ExecState* state)
{
VM& vm = state->vm();
auto throwScope = DECLARE_THROW_SCOPE(vm);
UNUSED_PARAM(throwScope);
JSValue thisValue = state->thisValue();
auto castedThis = jsDynamicCast<JSReadableStreamSource*>(thisValue);
if (UNLIKELY(!castedThis))
return throwThisTypeError(*state, throwScope, "ReadableStreamSource", "cancel");
ASSERT_GC_OBJECT_INHERITS(castedThis, JSReadableStreamSource::info());
auto& impl = castedThis->wrapped();
if (UNLIKELY(state->argumentCount() < 1))
return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
auto reason = state->uncheckedArgument(0);
impl.cancel(WTFMove(reason));
return JSValue::encode(jsUndefined());
}
void JSReadableStreamSource::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
auto* thisObject = jsCast<JSReadableStreamSource*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
Base::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_controller);
}
bool JSReadableStreamSourceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
{
UNUSED_PARAM(handle);
UNUSED_PARAM(visitor);
return false;
}
void JSReadableStreamSourceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
{
auto* jsReadableStreamSource = jsCast<JSReadableStreamSource*>(handle.slot()->asCell());
auto& world = *static_cast<DOMWrapperWorld*>(context);
uncacheWrapper(world, &jsReadableStreamSource->wrapped(), jsReadableStreamSource);
}
JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ReadableStreamSource>&& impl)
{
return createWrapper<ReadableStreamSource>(globalObject, WTFMove(impl));
}
JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ReadableStreamSource& impl)
{
return wrap(state, globalObject, impl);
}
ReadableStreamSource* JSReadableStreamSource::toWrapped(JSC::JSValue value)
{
if (auto* wrapper = jsDynamicCast<JSReadableStreamSource*>(value))
return &wrapper->wrapped();
return nullptr;
}
}
#endif // ENABLE(READABLE_STREAM_API)