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 | |
40 | namespace WebCore { |
41 | using namespace JSC; |
42 | |
43 | // Functions |
44 | |
45 | |
46 | // Attributes |
47 | |
48 | JSC::EncodedJSValue jsReadableStreamConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
49 | bool setJSReadableStreamConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
50 | |
51 | class JSReadableStreamPrototype : public JSC::JSNonFinalObject { |
52 | public: |
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 | |
67 | private: |
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 | |
76 | using JSReadableStreamConstructor = JSDOMBuiltinConstructor<JSReadableStream>; |
77 | |
78 | template<> JSValue JSReadableStreamConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
79 | { |
80 | UNUSED_PARAM(vm); |
81 | return globalObject.functionPrototype(); |
82 | } |
83 | |
84 | template<> 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 | |
91 | template<> FunctionExecutable* JSReadableStreamConstructor::initializeExecutable(VM& vm) |
92 | { |
93 | return readableStreamInitializeReadableStreamCodeGenerator(vm); |
94 | } |
95 | |
96 | template<> const ClassInfo JSReadableStreamConstructor::s_info = { "ReadableStream" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamConstructor) }; |
97 | |
98 | /* Hash table for prototype */ |
99 | |
100 | static 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 | |
111 | const ClassInfo JSReadableStreamPrototype::s_info = { "ReadableStreamPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamPrototype) }; |
112 | |
113 | void JSReadableStreamPrototype::finishCreation(VM& vm) |
114 | { |
115 | Base::finishCreation(vm); |
116 | reifyStaticProperties(vm, JSReadableStream::info(), JSReadableStreamPrototypeTableValues, *this); |
117 | } |
118 | |
119 | const ClassInfo JSReadableStream::s_info = { "ReadableStream" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStream) }; |
120 | |
121 | JSReadableStream::JSReadableStream(Structure* structure, JSDOMGlobalObject& globalObject) |
122 | : JSDOMObject(structure, globalObject) { } |
123 | |
124 | void JSReadableStream::finishCreation(VM& vm) |
125 | { |
126 | Base::finishCreation(vm); |
127 | ASSERT(inherits(vm, info())); |
128 | |
129 | } |
130 | |
131 | JSObject* JSReadableStream::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
132 | { |
133 | return JSReadableStreamPrototype::create(vm, &globalObject, JSReadableStreamPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
134 | } |
135 | |
136 | JSObject* JSReadableStream::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
137 | { |
138 | return getDOMPrototype<JSReadableStream>(vm, globalObject); |
139 | } |
140 | |
141 | JSValue JSReadableStream::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
142 | { |
143 | return getDOMConstructor<JSReadableStreamConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
144 | } |
145 | |
146 | void JSReadableStream::destroy(JSC::JSCell* cell) |
147 | { |
148 | JSReadableStream* thisObject = static_cast<JSReadableStream*>(cell); |
149 | thisObject->JSReadableStream::~JSReadableStream(); |
150 | } |
151 | |
152 | template<> inline JSReadableStream* IDLAttribute<JSReadableStream>::cast(ExecState& state, EncodedJSValue thisValue) |
153 | { |
154 | return jsDynamicCast<JSReadableStream*>(state.vm(), JSValue::decode(thisValue)); |
155 | } |
156 | |
157 | template<> inline JSReadableStream* IDLOperation<JSReadableStream>::cast(ExecState& state) |
158 | { |
159 | return jsDynamicCast<JSReadableStream*>(state.vm(), state.thisValue()); |
160 | } |
161 | |
162 | EncodedJSValue 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 | |
172 | bool 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 | |