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 "JSReadableStreamSink.h" |
26 | |
27 | #include "JSDOMBinding.h" |
28 | #include "JSDOMConvertBufferSource.h" |
29 | #include "JSDOMConvertStrings.h" |
30 | #include "JSDOMConvertUnion.h" |
31 | #include "JSDOMExceptionHandling.h" |
32 | #include "JSDOMOperation.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 | #include <wtf/Variant.h> |
41 | |
42 | |
43 | namespace WebCore { |
44 | using namespace JSC; |
45 | |
46 | // Functions |
47 | |
48 | JSC::EncodedJSValue JSC_HOST_CALL jsReadableStreamSinkPrototypeFunctionEnqueue(JSC::ExecState*); |
49 | JSC::EncodedJSValue JSC_HOST_CALL jsReadableStreamSinkPrototypeFunctionClose(JSC::ExecState*); |
50 | JSC::EncodedJSValue JSC_HOST_CALL jsReadableStreamSinkPrototypeFunctionError(JSC::ExecState*); |
51 | |
52 | class JSReadableStreamSinkPrototype : public JSC::JSNonFinalObject { |
53 | public: |
54 | using Base = JSC::JSNonFinalObject; |
55 | static JSReadableStreamSinkPrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
56 | { |
57 | JSReadableStreamSinkPrototype* ptr = new (NotNull, JSC::allocateCell<JSReadableStreamSinkPrototype>(vm.heap)) JSReadableStreamSinkPrototype(vm, globalObject, structure); |
58 | ptr->finishCreation(vm); |
59 | return ptr; |
60 | } |
61 | |
62 | DECLARE_INFO; |
63 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
64 | { |
65 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
66 | } |
67 | |
68 | private: |
69 | JSReadableStreamSinkPrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
70 | : JSC::JSNonFinalObject(vm, structure) |
71 | { |
72 | } |
73 | |
74 | void finishCreation(JSC::VM&); |
75 | }; |
76 | |
77 | /* Hash table for prototype */ |
78 | |
79 | static const HashTableValue JSReadableStreamSinkPrototypeTableValues[] = |
80 | { |
81 | { "enqueue" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadableStreamSinkPrototypeFunctionEnqueue), (intptr_t) (1) } }, |
82 | { "close" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadableStreamSinkPrototypeFunctionClose), (intptr_t) (0) } }, |
83 | { "error" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsReadableStreamSinkPrototypeFunctionError), (intptr_t) (1) } }, |
84 | }; |
85 | |
86 | const ClassInfo JSReadableStreamSinkPrototype::s_info = { "ReadableStreamSinkPrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamSinkPrototype) }; |
87 | |
88 | void JSReadableStreamSinkPrototype::finishCreation(VM& vm) |
89 | { |
90 | Base::finishCreation(vm); |
91 | reifyStaticProperties(vm, JSReadableStreamSink::info(), JSReadableStreamSinkPrototypeTableValues, *this); |
92 | } |
93 | |
94 | const ClassInfo JSReadableStreamSink::s_info = { "ReadableStreamSink" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSReadableStreamSink) }; |
95 | |
96 | JSReadableStreamSink::JSReadableStreamSink(Structure* structure, JSDOMGlobalObject& globalObject, Ref<ReadableStreamSink>&& impl) |
97 | : JSDOMWrapper<ReadableStreamSink>(structure, globalObject, WTFMove(impl)) |
98 | { |
99 | } |
100 | |
101 | void JSReadableStreamSink::finishCreation(VM& vm) |
102 | { |
103 | Base::finishCreation(vm); |
104 | ASSERT(inherits(vm, info())); |
105 | |
106 | } |
107 | |
108 | JSObject* JSReadableStreamSink::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
109 | { |
110 | return JSReadableStreamSinkPrototype::create(vm, &globalObject, JSReadableStreamSinkPrototype::createStructure(vm, &globalObject, globalObject.objectPrototype())); |
111 | } |
112 | |
113 | JSObject* JSReadableStreamSink::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
114 | { |
115 | return getDOMPrototype<JSReadableStreamSink>(vm, globalObject); |
116 | } |
117 | |
118 | void JSReadableStreamSink::destroy(JSC::JSCell* cell) |
119 | { |
120 | JSReadableStreamSink* thisObject = static_cast<JSReadableStreamSink*>(cell); |
121 | thisObject->JSReadableStreamSink::~JSReadableStreamSink(); |
122 | } |
123 | |
124 | template<> inline JSReadableStreamSink* IDLOperation<JSReadableStreamSink>::cast(ExecState& state) |
125 | { |
126 | return jsDynamicCast<JSReadableStreamSink*>(state.vm(), state.thisValue()); |
127 | } |
128 | |
129 | static inline JSC::EncodedJSValue jsReadableStreamSinkPrototypeFunctionEnqueueBody(JSC::ExecState* state, typename IDLOperation<JSReadableStreamSink>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
130 | { |
131 | UNUSED_PARAM(state); |
132 | UNUSED_PARAM(throwScope); |
133 | auto& impl = castedThis->wrapped(); |
134 | if (UNLIKELY(state->argumentCount() < 1)) |
135 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
136 | auto chunk = convert<IDLUnion<IDLArrayBufferView, IDLArrayBuffer>>(*state, state->uncheckedArgument(0)); |
137 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
138 | impl.enqueue(WTFMove(chunk)); |
139 | return JSValue::encode(jsUndefined()); |
140 | } |
141 | |
142 | EncodedJSValue JSC_HOST_CALL jsReadableStreamSinkPrototypeFunctionEnqueue(ExecState* state) |
143 | { |
144 | return IDLOperation<JSReadableStreamSink>::call<jsReadableStreamSinkPrototypeFunctionEnqueueBody>(*state, "enqueue" ); |
145 | } |
146 | |
147 | static inline JSC::EncodedJSValue jsReadableStreamSinkPrototypeFunctionCloseBody(JSC::ExecState* state, typename IDLOperation<JSReadableStreamSink>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
148 | { |
149 | UNUSED_PARAM(state); |
150 | UNUSED_PARAM(throwScope); |
151 | auto& impl = castedThis->wrapped(); |
152 | impl.close(); |
153 | return JSValue::encode(jsUndefined()); |
154 | } |
155 | |
156 | EncodedJSValue JSC_HOST_CALL jsReadableStreamSinkPrototypeFunctionClose(ExecState* state) |
157 | { |
158 | return IDLOperation<JSReadableStreamSink>::call<jsReadableStreamSinkPrototypeFunctionCloseBody>(*state, "close" ); |
159 | } |
160 | |
161 | static inline JSC::EncodedJSValue jsReadableStreamSinkPrototypeFunctionErrorBody(JSC::ExecState* state, typename IDLOperation<JSReadableStreamSink>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
162 | { |
163 | UNUSED_PARAM(state); |
164 | UNUSED_PARAM(throwScope); |
165 | auto& impl = castedThis->wrapped(); |
166 | if (UNLIKELY(state->argumentCount() < 1)) |
167 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
168 | auto message = convert<IDLDOMString>(*state, state->uncheckedArgument(0)); |
169 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
170 | impl.error(WTFMove(message)); |
171 | return JSValue::encode(jsUndefined()); |
172 | } |
173 | |
174 | EncodedJSValue JSC_HOST_CALL jsReadableStreamSinkPrototypeFunctionError(ExecState* state) |
175 | { |
176 | return IDLOperation<JSReadableStreamSink>::call<jsReadableStreamSinkPrototypeFunctionErrorBody>(*state, "error" ); |
177 | } |
178 | |
179 | void JSReadableStreamSink::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
180 | { |
181 | auto* thisObject = jsCast<JSReadableStreamSink*>(cell); |
182 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
183 | if (thisObject->scriptExecutionContext()) |
184 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
185 | Base::heapSnapshot(cell, builder); |
186 | } |
187 | |
188 | bool JSReadableStreamSinkOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor, const char** reason) |
189 | { |
190 | UNUSED_PARAM(handle); |
191 | UNUSED_PARAM(visitor); |
192 | UNUSED_PARAM(reason); |
193 | return false; |
194 | } |
195 | |
196 | void JSReadableStreamSinkOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context) |
197 | { |
198 | auto* jsReadableStreamSink = static_cast<JSReadableStreamSink*>(handle.slot()->asCell()); |
199 | auto& world = *static_cast<DOMWrapperWorld*>(context); |
200 | uncacheWrapper(world, &jsReadableStreamSink->wrapped(), jsReadableStreamSink); |
201 | } |
202 | |
203 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<ReadableStreamSink>&& impl) |
204 | { |
205 | return createWrapper<ReadableStreamSink>(globalObject, WTFMove(impl)); |
206 | } |
207 | |
208 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, ReadableStreamSink& impl) |
209 | { |
210 | return wrap(state, globalObject, impl); |
211 | } |
212 | |
213 | ReadableStreamSink* JSReadableStreamSink::toWrapped(JSC::VM& vm, JSC::JSValue value) |
214 | { |
215 | if (auto* wrapper = jsDynamicCast<JSReadableStreamSink*>(vm, value)) |
216 | return &wrapper->wrapped(); |
217 | return nullptr; |
218 | } |
219 | |
220 | } |
221 | |
222 | #endif // ENABLE(STREAMS_API) |
223 | |