1/*
2 This file is part of the WebKit open source project.
3 This file has been generated by generate-bindings.pl. DO NOT MODIFY!
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "config.h"
22
23#if ENABLE(STREAMS_API)
24
25#include "JSReadableStreamDefaultController.h"
26
27#include "JSDOMAttribute.h"
28#include "JSDOMBinding.h"
29#include "JSDOMBuiltinConstructor.h"
30#include "JSDOMExceptionHandling.h"
31#include "JSDOMOperation.h"
32#include "JSDOMWrapperCache.h"
33#include "ReadableStreamDefaultControllerBuiltins.h"
34#include <JavaScriptCore/FunctionPrototype.h>
35#include <JavaScriptCore/JSCInlines.h>
36#include <wtf/GetPtr.h>
37#include <wtf/PointerPreparations.h>
38
39
40namespace WebCore {
41using namespace JSC;
42
43// Functions
44
45
46// Attributes
47
48JSC::EncodedJSValue jsReadableStreamDefaultControllerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49bool setJSReadableStreamDefaultControllerConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
50
51class JSReadableStreamDefaultControllerPrototype : public JSC::JSNonFinalObject {
52public:
53 using Base = JSC::JSNonFinalObject;
54 static JSReadableStreamDefaultControllerPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
55 {
56 JSReadableStreamDefaultControllerPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamDefaultControllerPrototype>(vm.heap)) JSReadableStreamDefaultControllerPrototype(vm, globalObject, structure);
57 ptr->finishCreation(vm);
58 return ptr;
59 }
60
61 DECLARE_INFO;
62 static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
63 {
64 return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
65 }
66
67private:
68 JSReadableStreamDefaultControllerPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
69 : JSC::JSNonFinalObject(vm, structure)
70 {
71 }
72
73 void finishCreation(JSC::VM&);
74};
75
76using JSReadableStreamDefaultControllerConstructor = JSDOMBuiltinConstructor<JSReadableStreamDefaultController>;
77
78template<> JSValue JSReadableStreamDefaultControllerConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
79{
80 UNUSED_PARAM(vm);
81 return globalObject.functionPrototype();
82}
83
84template<> void JSReadableStreamDefaultControllerConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
85{
86 putDirect(vm, vm.propertyNames->prototype, JSReadableStreamDefaultController::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
87 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("ReadableStreamDefaultController"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
88 putDirect(vm, vm.propertyNames->length, jsNumber(4), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89}
90
91template<> FunctionExecutable* JSReadableStreamDefaultControllerConstructor::initializeExecutable(VM& vm)
92{
93 return readableStreamDefaultControllerInitializeReadableStreamDefaultControllerCodeGenerator(vm);
94}
95
96template<> const ClassInfo JSReadableStreamDefaultControllerConstructor::s_info = { "ReadableStreamDefaultController", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultControllerConstructor) };
97
98/* Hash table for prototype */
99
100static const HashTableValue JSReadableStreamDefaultControllerPrototypeTableValues[] =
101{
102 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamDefaultControllerConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSReadableStreamDefaultControllerConstructor) } },
103 { "desiredSize", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultControllerDesiredSizeCodeGenerator), (intptr_t) (0) } },
104 { "enqueue", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultControllerEnqueueCodeGenerator), (intptr_t) (0) } },
105 { "close", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultControllerCloseCodeGenerator), (intptr_t) (0) } },
106 { "error", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamDefaultControllerErrorCodeGenerator), (intptr_t) (0) } },
107};
108
109const ClassInfo JSReadableStreamDefaultControllerPrototype::s_info = { "ReadableStreamDefaultControllerPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultControllerPrototype) };
110
111void JSReadableStreamDefaultControllerPrototype::finishCreation(VM& vm)
112{
113 Base::finishCreation(vm);
114 reifyStaticProperties(vm, JSReadableStreamDefaultController::info(), JSReadableStreamDefaultControllerPrototypeTableValues, *this);
115}
116
117const ClassInfo JSReadableStreamDefaultController::s_info = { "ReadableStreamDefaultController", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamDefaultController) };
118
119JSReadableStreamDefaultController::JSReadableStreamDefaultController(Structure* structure, JSDOMGlobalObject& globalObject)
120 : JSDOMObject(structure, globalObject) { }
121
122void JSReadableStreamDefaultController::finishCreation(VM& vm)
123{
124 Base::finishCreation(vm);
125 ASSERT(inherits(vm, info()));
126
127}
128
129JSObject* JSReadableStreamDefaultController::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
130{
131 return JSReadableStreamDefaultControllerPrototype::create(vm, &globalObject, JSReadableStreamDefaultControllerPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
132}
133
134JSObject* JSReadableStreamDefaultController::prototype(VM& vm, JSDOMGlobalObject& globalObject)
135{
136 return getDOMPrototype<JSReadableStreamDefaultController>(vm, globalObject);
137}
138
139JSValue JSReadableStreamDefaultController::getConstructor(VM& vm, const JSGlobalObject* globalObject)
140{
141 return getDOMConstructor<JSReadableStreamDefaultControllerConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
142}
143
144void JSReadableStreamDefaultController::destroy(JSC::JSCell* cell)
145{
146 JSReadableStreamDefaultController* thisObject = static_cast<JSReadableStreamDefaultController*>(cell);
147 thisObject->JSReadableStreamDefaultController::~JSReadableStreamDefaultController();
148}
149
150template<> inline JSReadableStreamDefaultController* IDLAttribute<JSReadableStreamDefaultController>::cast(ExecState& state, EncodedJSValue thisValue)
151{
152 return jsDynamicCast<JSReadableStreamDefaultController*>(state.vm(), JSValue::decode(thisValue));
153}
154
155template<> inline JSReadableStreamDefaultController* IDLOperation<JSReadableStreamDefaultController>::cast(ExecState& state)
156{
157 return jsDynamicCast<JSReadableStreamDefaultController*>(state.vm(), state.thisValue());
158}
159
160EncodedJSValue jsReadableStreamDefaultControllerConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
161{
162 VM& vm = state->vm();
163 auto throwScope = DECLARE_THROW_SCOPE(vm);
164 auto* prototype = jsDynamicCast<JSReadableStreamDefaultControllerPrototype*>(vm, JSValue::decode(thisValue));
165 if (UNLIKELY(!prototype))
166 return throwVMTypeError(state, throwScope);
167 return JSValue::encode(JSReadableStreamDefaultController::getConstructor(state->vm(), prototype->globalObject()));
168}
169
170bool setJSReadableStreamDefaultControllerConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
171{
172 VM& vm = state->vm();
173 auto throwScope = DECLARE_THROW_SCOPE(vm);
174 auto* prototype = jsDynamicCast<JSReadableStreamDefaultControllerPrototype*>(vm, JSValue::decode(thisValue));
175 if (UNLIKELY(!prototype)) {
176 throwVMTypeError(state, throwScope);
177 return false;
178 }
179 // Shadowing a built-in constructor
180 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
181}
182
183
184}
185
186#endif // ENABLE(STREAMS_API)
187