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 "JSReadableStream.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 "ReadableStreamBuiltins.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 jsReadableStreamConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName);
49bool setJSReadableStreamConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue);
50
51class JSReadableStreamPrototype : public JSC::JSNonFinalObject {
52public:
53 using Base = JSC::JSNonFinalObject;
54 static JSReadableStreamPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
55 {
56 JSReadableStreamPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamPrototype>(vm.heap)) JSReadableStreamPrototype(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 JSReadableStreamPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
69 : JSC::JSNonFinalObject(vm, structure)
70 {
71 }
72
73 void finishCreation(JSC::VM&);
74};
75
76using JSReadableStreamConstructor = JSDOMBuiltinConstructor<JSReadableStream>;
77
78template<> JSValue JSReadableStreamConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
79{
80 UNUSED_PARAM(vm);
81 return globalObject.functionPrototype();
82}
83
84template<> void JSReadableStreamConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject)
85{
86 putDirect(vm, vm.propertyNames->prototype, JSReadableStream::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
87 putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("ReadableStream"_s)), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
88 putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum);
89}
90
91template<> FunctionExecutable* JSReadableStreamConstructor::initializeExecutable(VM& vm)
92{
93 return readableStreamInitializeReadableStreamCodeGenerator(vm);
94}
95
96template<> const ClassInfo JSReadableStreamConstructor::s_info = { "ReadableStream", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamConstructor) };
97
98/* Hash table for prototype */
99
100static const HashTableValue JSReadableStreamPrototypeTableValues[] =
101{
102 { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSReadableStreamConstructor) } },
103 { "locked", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::Accessor | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamLockedCodeGenerator), (intptr_t) (0) } },
104 { "cancel", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamCancelCodeGenerator), (intptr_t) (0) } },
105 { "getReader", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamGetReaderCodeGenerator), (intptr_t) (0) } },
106 { "pipeTo", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamPipeToCodeGenerator), (intptr_t) (1) } },
107 { "pipeThrough", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamPipeThroughCodeGenerator), (intptr_t) (2) } },
108 { "tee", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::Builtin), NoIntrinsic, { (intptr_t)static_cast<BuiltinGenerator>(readableStreamTeeCodeGenerator), (intptr_t) (0) } },
109};
110
111const ClassInfo JSReadableStreamPrototype::s_info = { "ReadableStreamPrototype", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamPrototype) };
112
113void JSReadableStreamPrototype::finishCreation(VM& vm)
114{
115 Base::finishCreation(vm);
116 reifyStaticProperties(vm, JSReadableStream::info(), JSReadableStreamPrototypeTableValues, *this);
117}
118
119const ClassInfo JSReadableStream::s_info = { "ReadableStream", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStream) };
120
121JSReadableStream::JSReadableStream(Structure* structure, JSDOMGlobalObject& globalObject)
122 : JSDOMObject(structure, globalObject) { }
123
124void JSReadableStream::finishCreation(VM& vm)
125{
126 Base::finishCreation(vm);
127 ASSERT(inherits(vm, info()));
128
129}
130
131JSObject* JSReadableStream::createPrototype(VM& vm, JSDOMGlobalObject& globalObject)
132{
133 return JSReadableStreamPrototype::create(vm, &globalObject, JSReadableStreamPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype()));
134}
135
136JSObject* JSReadableStream::prototype(VM& vm, JSDOMGlobalObject& globalObject)
137{
138 return getDOMPrototype<JSReadableStream>(vm, globalObject);
139}
140
141JSValue JSReadableStream::getConstructor(VM& vm, const JSGlobalObject* globalObject)
142{
143 return getDOMConstructor<JSReadableStreamConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
144}
145
146void JSReadableStream::destroy(JSC::JSCell* cell)
147{
148 JSReadableStream* thisObject = static_cast<JSReadableStream*>(cell);
149 thisObject->JSReadableStream::~JSReadableStream();
150}
151
152template<> inline JSReadableStream* IDLAttribute<JSReadableStream>::cast(ExecState& state, EncodedJSValue thisValue)
153{
154 return jsDynamicCast<JSReadableStream*>(state.vm(), JSValue::decode(thisValue));
155}
156
157template<> inline JSReadableStream* IDLOperation<JSReadableStream>::cast(ExecState& state)
158{
159 return jsDynamicCast<JSReadableStream*>(state.vm(), state.thisValue());
160}
161
162EncodedJSValue jsReadableStreamConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName)
163{
164 VM& vm = state->vm();
165 auto throwScope = DECLARE_THROW_SCOPE(vm);
166 auto* prototype = jsDynamicCast<JSReadableStreamPrototype*>(vm, JSValue::decode(thisValue));
167 if (UNLIKELY(!prototype))
168 return throwVMTypeError(state, throwScope);
169 return JSValue::encode(JSReadableStream::getConstructor(state->vm(), prototype->globalObject()));
170}
171
172bool setJSReadableStreamConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue)
173{
174 VM& vm = state->vm();
175 auto throwScope = DECLARE_THROW_SCOPE(vm);
176 auto* prototype = jsDynamicCast<JSReadableStreamPrototype*>(vm, JSValue::decode(thisValue));
177 if (UNLIKELY(!prototype)) {
178 throwVMTypeError(state, throwScope);
179 return false;
180 }
181 // Shadowing a built-in constructor
182 return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue));
183}
184
185
186}
187
188#endif // ENABLE(STREAMS_API)
189