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 "JSReadableStreamSource.h" |
26 | |
27 | #include "JSDOMAttribute.h" |
28 | #include "JSDOMBinding.h" |
29 | #include "JSDOMConvertAny.h" |
30 | #include "JSDOMExceptionHandling.h" |
31 | #include "JSDOMOperation.h" |
32 | #include "JSDOMOperationReturningPromise.h" |
33 | #include "JSDOMWrapperCache.h" |
34 | #include "ScriptExecutionContext.h" |
35 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
36 | #include <JavaScriptCore/JSCInlines.h> |
37 | #include <wtf/GetPtr.h> |
38 | #include <wtf/PointerPreparations.h> |
39 | #include <wtf/URL.h> |
40 | |
41 | |
42 | namespace WebCore { |
43 | using namespace JSC; |
44 | |
45 | // Functions |
46 | |
47 | JSC::EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionStart(JSC::ExecState*); |
48 | JSC::EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionPull(JSC::ExecState*); |
49 | JSC::EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionCancel(JSC::ExecState*); |
50 | |
51 | // Attributes |
52 | |
53 | JSC::EncodedJSValue jsReadableStreamSourceController(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
54 | |
55 | class JSReadableStreamSourcePrototype : public JSC::JSNonFinalObject { |
56 | public: |
57 | using Base = JSC::JSNonFinalObject; |
58 | static JSReadableStreamSourcePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
59 | { |
60 | JSReadableStreamSourcePrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamSourcePrototype>(vm.heap)) JSReadableStreamSourcePrototype(vm, globalObject, structure); |
61 | ptr->finishCreation(vm); |
62 | return ptr; |
63 | } |
64 | |
65 | DECLARE_INFO; |
66 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
67 | { |
68 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
69 | } |
70 | |
71 | private: |
72 | JSReadableStreamSourcePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
73 | : JSC::JSNonFinalObject(vm, structure) |
74 | { |
75 | } |
76 | |
77 | void finishCreation(JSC::VM&); |
78 | }; |
79 | |
80 | /* Hash table for prototype */ |
81 | |
82 | static const HashTableValue JSReadableStreamSourcePrototypeTableValues[] = |
83 | { |
84 | { "controller" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsReadableStreamSourceController), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
85 | { "start" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadableStreamSourcePrototypeFunctionStart), (intptr_t) (1) } }, |
86 | { "pull" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadableStreamSourcePrototypeFunctionPull), (intptr_t) (1) } }, |
87 | { "cancel" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadableStreamSourcePrototypeFunctionCancel), (intptr_t) (1) } }, |
88 | }; |
89 | |
90 | const ClassInfo JSReadableStreamSourcePrototype::s_info = { "ReadableStreamSourcePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamSourcePrototype) }; |
91 | |
92 | void JSReadableStreamSourcePrototype::finishCreation(VM& vm) |
93 | { |
94 | Base::finishCreation(vm); |
95 | reifyStaticProperties(vm, JSReadableStreamSource::info(), JSReadableStreamSourcePrototypeTableValues, *this); |
96 | } |
97 | |
98 | const ClassInfo JSReadableStreamSource::s_info = { "ReadableStreamSource" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamSource) }; |
99 | |
100 | JSReadableStreamSource::JSReadableStreamSource(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ReadableStreamSource>&& impl) |
101 | : JSDOMWrapper<ReadableStreamSource>(structure, globalObject, WTFMove(impl)) |
102 | { |
103 | } |
104 | |
105 | void JSReadableStreamSource::finishCreation(VM& vm) |
106 | { |
107 | Base::finishCreation(vm); |
108 | ASSERT(inherits(vm, info())); |
109 | |
110 | } |
111 | |
112 | JSObject* JSReadableStreamSource::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
113 | { |
114 | return JSReadableStreamSourcePrototype::create(vm, &globalObject, JSReadableStreamSourcePrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
115 | } |
116 | |
117 | JSObject* JSReadableStreamSource::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
118 | { |
119 | return getDOMPrototype<JSReadableStreamSource>(vm, globalObject); |
120 | } |
121 | |
122 | void JSReadableStreamSource::destroy(JSC::JSCell* cell) |
123 | { |
124 | JSReadableStreamSource* thisObject = static_cast<JSReadableStreamSource*>(cell); |
125 | thisObject->JSReadableStreamSource::~JSReadableStreamSource(); |
126 | } |
127 | |
128 | template<> inline JSReadableStreamSource* IDLAttribute<JSReadableStreamSource>::cast(ExecState& state, EncodedJSValue thisValue) |
129 | { |
130 | return jsDynamicCast<JSReadableStreamSource*>(state.vm(), JSValue::decode(thisValue)); |
131 | } |
132 | |
133 | template<> inline JSReadableStreamSource* IDLOperation<JSReadableStreamSource>::cast(ExecState& state) |
134 | { |
135 | return jsDynamicCast<JSReadableStreamSource*>(state.vm(), state.thisValue()); |
136 | } |
137 | |
138 | static inline JSValue jsReadableStreamSourceControllerGetter(ExecState& state, JSReadableStreamSource& thisObject, ThrowScope& throwScope) |
139 | { |
140 | UNUSED_PARAM(throwScope); |
141 | UNUSED_PARAM(state); |
142 | return thisObject.controller(state); |
143 | } |
144 | |
145 | EncodedJSValue jsReadableStreamSourceController(ExecState* state, EncodedJSValue thisValue, PropertyName) |
146 | { |
147 | return IDLAttribute<JSReadableStreamSource>::get<jsReadableStreamSourceControllerGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "controller" ); |
148 | } |
149 | |
150 | static inline JSC::EncodedJSValue jsReadableStreamSourcePrototypeFunctionStartBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSReadableStreamSource>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
151 | { |
152 | UNUSED_PARAM(state); |
153 | UNUSED_PARAM(throwScope); |
154 | return JSValue::encode(castedThis->start(*state, WTFMove(promise))); |
155 | } |
156 | |
157 | EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionStart(ExecState* state) |
158 | { |
159 | return IDLOperationReturningPromise<JSReadableStreamSource>::call<jsReadableStreamSourcePrototypeFunctionStartBody, PromiseExecutionScope::WindowOnly>(*state, "start" ); |
160 | } |
161 | |
162 | static inline JSC::EncodedJSValue jsReadableStreamSourcePrototypeFunctionPullBody(JSC::ExecState* state, typename IDLOperationReturningPromise<JSReadableStreamSource>::ClassParameter castedThis, Ref<DeferredPromise>&& promise, JSC::ThrowScope& throwScope) |
163 | { |
164 | UNUSED_PARAM(state); |
165 | UNUSED_PARAM(throwScope); |
166 | return JSValue::encode(castedThis->pull(*state, WTFMove(promise))); |
167 | } |
168 | |
169 | EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionPull(ExecState* state) |
170 | { |
171 | return IDLOperationReturningPromise<JSReadableStreamSource>::call<jsReadableStreamSourcePrototypeFunctionPullBody, PromiseExecutionScope::WindowOnly>(*state, "pull" ); |
172 | } |
173 | |
174 | static inline JSC::EncodedJSValue jsReadableStreamSourcePrototypeFunctionCancelBody(JSC::ExecState* state, typename IDLOperation<JSReadableStreamSource>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
175 | { |
176 | UNUSED_PARAM(state); |
177 | UNUSED_PARAM(throwScope); |
178 | auto& impl = castedThis->wrapped(); |
179 | if (UNLIKELY(state->argumentCount() < 1)) |
180 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
181 | auto reason = convert<IDLAny>(*state, state->uncheckedArgument(0)); |
182 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
183 | impl.cancel(WTFMove(reason)); |
184 | return JSValue::encode(jsUndefined()); |
185 | } |
186 | |
187 | EncodedJSValue JSC_HOST_CALL jsReadableStreamSourcePrototypeFunctionCancel(ExecState* state) |
188 | { |
189 | return IDLOperation<JSReadableStreamSource>::call<jsReadableStreamSourcePrototypeFunctionCancelBody>(*state, "cancel" ); |
190 | } |
191 | |
192 | void JSReadableStreamSource::visitChildren(JSCell* cell, SlotVisitor& visitor) |
193 | { |
194 | auto* thisObject = jsCast<JSReadableStreamSource*>(cell); |
195 | ASSERT_GC_OBJECT_INHERITS(thisObject, info()); |
196 | Base::visitChildren(thisObject, visitor); |
197 | visitor.append(thisObject->m_controller); |
198 | } |
199 | |
200 | void JSReadableStreamSource::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
201 | { |
202 | auto* thisObject = jsCast<JSReadableStreamSource*>(cell); |
203 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
204 | if (thisObject->scriptExecutionContext()) |
205 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
206 | Base::heapSnapshot(cell, builder); |
207 | } |
208 | |
209 | bool JSReadableStreamSourceOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
210 | { |
211 | UNUSED_PARAM(handle); |
212 | UNUSED_PARAM(visitor); |
213 | UNUSED_PARAM(reason); |
214 | return false; |
215 | } |
216 | |
217 | void JSReadableStreamSourceOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
218 | { |
219 | auto* jsReadableStreamSource = static_cast<JSReadableStreamSource*>(handle.slot()->asCell()); |
220 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
221 | uncacheWrapper(world, &jsReadableStreamSource->wrapped(), jsReadableStreamSource); |
222 | } |
223 | |
224 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ReadableStreamSource>&& impl) |
225 | { |
226 | return createWrapper<ReadableStreamSource>(globalObject, WTFMove(impl)); |
227 | } |
228 | |
229 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ReadableStreamSource& impl) |
230 | { |
231 | return wrap(state, globalObject, impl); |
232 | } |
233 | |
234 | ReadableStreamSource* JSReadableStreamSource::toWrapped(JSC::VM& vm, JSC::JSValue value) |
235 | { |
236 | if (auto* wrapper = jsDynamicCast<JSReadableStreamSource*>(vm, value)) |
237 | return &wrapper->wrapped(); |
238 | return nullptr; |
239 | } |
240 | |
241 | } |
242 | |
243 | #endif // ENABLE(STREAMS_API) |
244 | |