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(WEB_AUDIO) |
24 | |
25 | #include "JSOscillatorNode.h" |
26 | |
27 | #include "EventNames.h" |
28 | #include "JSAudioParam.h" |
29 | #include "JSDOMAttribute.h" |
30 | #include "JSDOMBinding.h" |
31 | #include "JSDOMConstructorNotConstructable.h" |
32 | #include "JSDOMConvertInterface.h" |
33 | #include "JSDOMConvertNullable.h" |
34 | #include "JSDOMConvertNumbers.h" |
35 | #include "JSDOMExceptionHandling.h" |
36 | #include "JSDOMGlobalObject.h" |
37 | #include "JSDOMOperation.h" |
38 | #include "JSDOMWrapperCache.h" |
39 | #include "JSEventListener.h" |
40 | #include "JSPeriodicWave.h" |
41 | #include "ScriptExecutionContext.h" |
42 | #include <JavaScriptCore/HeapSnapshotBuilder.h> |
43 | #include <JavaScriptCore/JSCInlines.h> |
44 | #include <JavaScriptCore/JSString.h> |
45 | #include <wtf/GetPtr.h> |
46 | #include <wtf/NeverDestroyed.h> |
47 | #include <wtf/PointerPreparations.h> |
48 | #include <wtf/URL.h> |
49 | |
50 | |
51 | namespace WebCore { |
52 | using namespace JSC; |
53 | |
54 | String convertEnumerationToString(OscillatorNode::Type enumerationValue) |
55 | { |
56 | static const NeverDestroyed<String> values[] = { |
57 | MAKE_STATIC_STRING_IMPL("sine" ), |
58 | MAKE_STATIC_STRING_IMPL("square" ), |
59 | MAKE_STATIC_STRING_IMPL("sawtooth" ), |
60 | MAKE_STATIC_STRING_IMPL("triangle" ), |
61 | MAKE_STATIC_STRING_IMPL("custom" ), |
62 | }; |
63 | static_assert(static_cast<size_t>(OscillatorNode::Type::Sine) == 0, "OscillatorNode::Type::Sine is not 0 as expected" ); |
64 | static_assert(static_cast<size_t>(OscillatorNode::Type::Square) == 1, "OscillatorNode::Type::Square is not 1 as expected" ); |
65 | static_assert(static_cast<size_t>(OscillatorNode::Type::Sawtooth) == 2, "OscillatorNode::Type::Sawtooth is not 2 as expected" ); |
66 | static_assert(static_cast<size_t>(OscillatorNode::Type::Triangle) == 3, "OscillatorNode::Type::Triangle is not 3 as expected" ); |
67 | static_assert(static_cast<size_t>(OscillatorNode::Type::Custom) == 4, "OscillatorNode::Type::Custom is not 4 as expected" ); |
68 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
69 | return values[static_cast<size_t>(enumerationValue)]; |
70 | } |
71 | |
72 | template<> JSString* convertEnumerationToJS(ExecState& state, OscillatorNode::Type enumerationValue) |
73 | { |
74 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
75 | } |
76 | |
77 | template<> Optional<OscillatorNode::Type> parseEnumeration<OscillatorNode::Type>(ExecState& state, JSValue value) |
78 | { |
79 | auto stringValue = value.toWTFString(&state); |
80 | if (stringValue == "sine" ) |
81 | return OscillatorNode::Type::Sine; |
82 | if (stringValue == "square" ) |
83 | return OscillatorNode::Type::Square; |
84 | if (stringValue == "sawtooth" ) |
85 | return OscillatorNode::Type::Sawtooth; |
86 | if (stringValue == "triangle" ) |
87 | return OscillatorNode::Type::Triangle; |
88 | if (stringValue == "custom" ) |
89 | return OscillatorNode::Type::Custom; |
90 | return WTF::nullopt; |
91 | } |
92 | |
93 | template<> const char* expectedEnumerationValues<OscillatorNode::Type>() |
94 | { |
95 | return "\"sine\", \"square\", \"sawtooth\", \"triangle\", \"custom\"" ; |
96 | } |
97 | |
98 | // Functions |
99 | |
100 | JSC::EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionStart(JSC::ExecState*); |
101 | JSC::EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionStop(JSC::ExecState*); |
102 | JSC::EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionSetPeriodicWave(JSC::ExecState*); |
103 | |
104 | // Attributes |
105 | |
106 | JSC::EncodedJSValue jsOscillatorNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
107 | bool setJSOscillatorNodeConstructor(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
108 | JSC::EncodedJSValue jsOscillatorNodeType(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
109 | bool setJSOscillatorNodeType(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
110 | JSC::EncodedJSValue jsOscillatorNodePlaybackState(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
111 | JSC::EncodedJSValue jsOscillatorNodeFrequency(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
112 | JSC::EncodedJSValue jsOscillatorNodeDetune(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
113 | JSC::EncodedJSValue jsOscillatorNodeOnended(JSC::ExecState*, JSC::EncodedJSValue, JSC::PropertyName); |
114 | bool setJSOscillatorNodeOnended(JSC::ExecState*, JSC::EncodedJSValue, JSC::EncodedJSValue); |
115 | |
116 | class JSOscillatorNodePrototype : public JSC::JSNonFinalObject { |
117 | public: |
118 | using Base = JSC::JSNonFinalObject; |
119 | static JSOscillatorNodePrototype* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure) |
120 | { |
121 | JSOscillatorNodePrototype* ptr = new (NotNull, JSC::allocateCell<JSOscillatorNodePrototype>(vm.heap)) JSOscillatorNodePrototype(vm, globalObject, structure); |
122 | ptr->finishCreation(vm); |
123 | return ptr; |
124 | } |
125 | |
126 | DECLARE_INFO; |
127 | static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) |
128 | { |
129 | return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); |
130 | } |
131 | |
132 | private: |
133 | JSOscillatorNodePrototype(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure) |
134 | : JSC::JSNonFinalObject(vm, structure) |
135 | { |
136 | } |
137 | |
138 | void finishCreation(JSC::VM&); |
139 | }; |
140 | |
141 | using JSOscillatorNodeConstructor = JSDOMConstructorNotConstructable<JSOscillatorNode>; |
142 | |
143 | /* Hash table for constructor */ |
144 | |
145 | static const HashTableValue JSOscillatorNodeConstructorTableValues[] = |
146 | { |
147 | { "UNSCHEDULED_STATE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
148 | { "SCHEDULED_STATE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
149 | { "PLAYING_STATE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
150 | { "FINISHED_STATE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
151 | }; |
152 | |
153 | static_assert(OscillatorNode::UNSCHEDULED_STATE == 0, "UNSCHEDULED_STATE in OscillatorNode does not match value from IDL" ); |
154 | static_assert(OscillatorNode::SCHEDULED_STATE == 1, "SCHEDULED_STATE in OscillatorNode does not match value from IDL" ); |
155 | static_assert(OscillatorNode::PLAYING_STATE == 2, "PLAYING_STATE in OscillatorNode does not match value from IDL" ); |
156 | static_assert(OscillatorNode::FINISHED_STATE == 3, "FINISHED_STATE in OscillatorNode does not match value from IDL" ); |
157 | |
158 | template<> JSValue JSOscillatorNodeConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject) |
159 | { |
160 | return JSAudioNode::getConstructor(vm, &globalObject); |
161 | } |
162 | |
163 | template<> void JSOscillatorNodeConstructor::initializeProperties(VM& vm, JSDOMGlobalObject& globalObject) |
164 | { |
165 | putDirect(vm, vm.propertyNames->prototype, JSOscillatorNode::prototype(vm, globalObject), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
166 | putDirect(vm, vm.propertyNames->name, jsNontrivialString(&vm, String("OscillatorNode"_s )), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
167 | putDirect(vm, vm.propertyNames->length, jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum); |
168 | reifyStaticProperties(vm, JSOscillatorNode::info(), JSOscillatorNodeConstructorTableValues, *this); |
169 | } |
170 | |
171 | template<> const ClassInfo JSOscillatorNodeConstructor::s_info = { "OscillatorNode" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSOscillatorNodeConstructor) }; |
172 | |
173 | /* Hash table for prototype */ |
174 | |
175 | static const HashTableValue JSOscillatorNodePrototypeTableValues[] = |
176 | { |
177 | { "constructor" , static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOscillatorNodeConstructor) } }, |
178 | { "type" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeType), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOscillatorNodeType) } }, |
179 | { "playbackState" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodePlaybackState), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
180 | { "frequency" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeFrequency), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
181 | { "detune" , static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeDetune), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, |
182 | { "onended" , static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsOscillatorNodeOnended), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSOscillatorNodeOnended) } }, |
183 | { "start" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsOscillatorNodePrototypeFunctionStart), (intptr_t) (0) } }, |
184 | { "stop" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsOscillatorNodePrototypeFunctionStop), (intptr_t) (0) } }, |
185 | { "setPeriodicWave" , static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsOscillatorNodePrototypeFunctionSetPeriodicWave), (intptr_t) (1) } }, |
186 | { "UNSCHEDULED_STATE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, |
187 | { "SCHEDULED_STATE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, |
188 | { "PLAYING_STATE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, |
189 | { "FINISHED_STATE" , JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, |
190 | }; |
191 | |
192 | const ClassInfo JSOscillatorNodePrototype::s_info = { "OscillatorNodePrototype" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSOscillatorNodePrototype) }; |
193 | |
194 | void JSOscillatorNodePrototype::finishCreation(VM& vm) |
195 | { |
196 | Base::finishCreation(vm); |
197 | reifyStaticProperties(vm, JSOscillatorNode::info(), JSOscillatorNodePrototypeTableValues, *this); |
198 | } |
199 | |
200 | const ClassInfo JSOscillatorNode::s_info = { "OscillatorNode" , &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSOscillatorNode) }; |
201 | |
202 | JSOscillatorNode::JSOscillatorNode(Structure* structure, JSDOMGlobalObject& globalObject, Ref<OscillatorNode>&& impl) |
203 | : JSAudioNode(structure, globalObject, WTFMove(impl)) |
204 | { |
205 | } |
206 | |
207 | void JSOscillatorNode::finishCreation(VM& vm) |
208 | { |
209 | Base::finishCreation(vm); |
210 | ASSERT(inherits(vm, info())); |
211 | |
212 | } |
213 | |
214 | JSObject* JSOscillatorNode::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) |
215 | { |
216 | return JSOscillatorNodePrototype::create(vm, &globalObject, JSOscillatorNodePrototype::createStructure(vm, &globalObject, JSAudioNode::prototype(vm, globalObject))); |
217 | } |
218 | |
219 | JSObject* JSOscillatorNode::prototype(VM& vm, JSDOMGlobalObject& globalObject) |
220 | { |
221 | return getDOMPrototype<JSOscillatorNode>(vm, globalObject); |
222 | } |
223 | |
224 | JSValue JSOscillatorNode::getConstructor(VM& vm, const JSGlobalObject* globalObject) |
225 | { |
226 | return getDOMConstructor<JSOscillatorNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); |
227 | } |
228 | |
229 | template<> inline JSOscillatorNode* IDLAttribute<JSOscillatorNode>::cast(ExecState& state, EncodedJSValue thisValue) |
230 | { |
231 | return jsDynamicCast<JSOscillatorNode*>(state.vm(), JSValue::decode(thisValue)); |
232 | } |
233 | |
234 | template<> inline JSOscillatorNode* IDLOperation<JSOscillatorNode>::cast(ExecState& state) |
235 | { |
236 | return jsDynamicCast<JSOscillatorNode*>(state.vm(), state.thisValue()); |
237 | } |
238 | |
239 | EncodedJSValue jsOscillatorNodeConstructor(ExecState* state, EncodedJSValue thisValue, PropertyName) |
240 | { |
241 | VM& vm = state->vm(); |
242 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
243 | auto* prototype = jsDynamicCast<JSOscillatorNodePrototype*>(vm, JSValue::decode(thisValue)); |
244 | if (UNLIKELY(!prototype)) |
245 | return throwVMTypeError(state, throwScope); |
246 | return JSValue::encode(JSOscillatorNode::getConstructor(state->vm(), prototype->globalObject())); |
247 | } |
248 | |
249 | bool setJSOscillatorNodeConstructor(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
250 | { |
251 | VM& vm = state->vm(); |
252 | auto throwScope = DECLARE_THROW_SCOPE(vm); |
253 | auto* prototype = jsDynamicCast<JSOscillatorNodePrototype*>(vm, JSValue::decode(thisValue)); |
254 | if (UNLIKELY(!prototype)) { |
255 | throwVMTypeError(state, throwScope); |
256 | return false; |
257 | } |
258 | // Shadowing a built-in constructor |
259 | return prototype->putDirect(vm, vm.propertyNames->constructor, JSValue::decode(encodedValue)); |
260 | } |
261 | |
262 | static inline JSValue jsOscillatorNodeTypeGetter(ExecState& state, JSOscillatorNode& thisObject, ThrowScope& throwScope) |
263 | { |
264 | UNUSED_PARAM(throwScope); |
265 | UNUSED_PARAM(state); |
266 | auto& impl = thisObject.wrapped(); |
267 | JSValue result = toJS<IDLEnumeration<OscillatorNode::Type>>(state, throwScope, impl.type()); |
268 | return result; |
269 | } |
270 | |
271 | EncodedJSValue jsOscillatorNodeType(ExecState* state, EncodedJSValue thisValue, PropertyName) |
272 | { |
273 | return IDLAttribute<JSOscillatorNode>::get<jsOscillatorNodeTypeGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "type" ); |
274 | } |
275 | |
276 | static inline bool setJSOscillatorNodeTypeSetter(ExecState& state, JSOscillatorNode& thisObject, JSValue value, ThrowScope& throwScope) |
277 | { |
278 | UNUSED_PARAM(throwScope); |
279 | auto& impl = thisObject.wrapped(); |
280 | auto optionalNativeValue = parseEnumeration<OscillatorNode::Type>(state, value); |
281 | RETURN_IF_EXCEPTION(throwScope, false); |
282 | if (UNLIKELY(!optionalNativeValue)) |
283 | return false; |
284 | auto nativeValue = optionalNativeValue.value(); |
285 | AttributeSetter::call(state, throwScope, [&] { |
286 | return impl.setType(WTFMove(nativeValue)); |
287 | }); |
288 | return true; |
289 | } |
290 | |
291 | bool setJSOscillatorNodeType(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
292 | { |
293 | return IDLAttribute<JSOscillatorNode>::set<setJSOscillatorNodeTypeSetter>(*state, thisValue, encodedValue, "type" ); |
294 | } |
295 | |
296 | static inline JSValue jsOscillatorNodePlaybackStateGetter(ExecState& state, JSOscillatorNode& thisObject, ThrowScope& throwScope) |
297 | { |
298 | UNUSED_PARAM(throwScope); |
299 | UNUSED_PARAM(state); |
300 | auto& impl = thisObject.wrapped(); |
301 | JSValue result = toJS<IDLUnsignedShort>(state, throwScope, impl.playbackState()); |
302 | return result; |
303 | } |
304 | |
305 | EncodedJSValue jsOscillatorNodePlaybackState(ExecState* state, EncodedJSValue thisValue, PropertyName) |
306 | { |
307 | return IDLAttribute<JSOscillatorNode>::get<jsOscillatorNodePlaybackStateGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "playbackState" ); |
308 | } |
309 | |
310 | static inline JSValue jsOscillatorNodeFrequencyGetter(ExecState& state, JSOscillatorNode& thisObject, ThrowScope& throwScope) |
311 | { |
312 | UNUSED_PARAM(throwScope); |
313 | UNUSED_PARAM(state); |
314 | auto& impl = thisObject.wrapped(); |
315 | JSValue result = toJS<IDLInterface<AudioParam>>(state, *thisObject.globalObject(), throwScope, impl.frequency()); |
316 | return result; |
317 | } |
318 | |
319 | EncodedJSValue jsOscillatorNodeFrequency(ExecState* state, EncodedJSValue thisValue, PropertyName) |
320 | { |
321 | return IDLAttribute<JSOscillatorNode>::get<jsOscillatorNodeFrequencyGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "frequency" ); |
322 | } |
323 | |
324 | static inline JSValue jsOscillatorNodeDetuneGetter(ExecState& state, JSOscillatorNode& thisObject, ThrowScope& throwScope) |
325 | { |
326 | UNUSED_PARAM(throwScope); |
327 | UNUSED_PARAM(state); |
328 | auto& impl = thisObject.wrapped(); |
329 | JSValue result = toJS<IDLInterface<AudioParam>>(state, *thisObject.globalObject(), throwScope, impl.detune()); |
330 | return result; |
331 | } |
332 | |
333 | EncodedJSValue jsOscillatorNodeDetune(ExecState* state, EncodedJSValue thisValue, PropertyName) |
334 | { |
335 | return IDLAttribute<JSOscillatorNode>::get<jsOscillatorNodeDetuneGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "detune" ); |
336 | } |
337 | |
338 | static inline JSValue jsOscillatorNodeOnendedGetter(ExecState& state, JSOscillatorNode& thisObject, ThrowScope& throwScope) |
339 | { |
340 | UNUSED_PARAM(throwScope); |
341 | UNUSED_PARAM(state); |
342 | return eventHandlerAttribute(thisObject.wrapped(), eventNames().endedEvent, worldForDOMObject(thisObject)); |
343 | } |
344 | |
345 | EncodedJSValue jsOscillatorNodeOnended(ExecState* state, EncodedJSValue thisValue, PropertyName) |
346 | { |
347 | return IDLAttribute<JSOscillatorNode>::get<jsOscillatorNodeOnendedGetter, CastedThisErrorBehavior::Assert>(*state, thisValue, "onended" ); |
348 | } |
349 | |
350 | static inline bool setJSOscillatorNodeOnendedSetter(ExecState& state, JSOscillatorNode& thisObject, JSValue value, ThrowScope& throwScope) |
351 | { |
352 | UNUSED_PARAM(throwScope); |
353 | setEventHandlerAttribute(state, thisObject, thisObject.wrapped(), eventNames().endedEvent, value); |
354 | return true; |
355 | } |
356 | |
357 | bool setJSOscillatorNodeOnended(ExecState* state, EncodedJSValue thisValue, EncodedJSValue encodedValue) |
358 | { |
359 | return IDLAttribute<JSOscillatorNode>::set<setJSOscillatorNodeOnendedSetter>(*state, thisValue, encodedValue, "onended" ); |
360 | } |
361 | |
362 | static inline JSC::EncodedJSValue jsOscillatorNodePrototypeFunctionStartBody(JSC::ExecState* state, typename IDLOperation<JSOscillatorNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
363 | { |
364 | UNUSED_PARAM(state); |
365 | UNUSED_PARAM(throwScope); |
366 | auto& impl = castedThis->wrapped(); |
367 | auto when = state->argument(0).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
368 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
369 | propagateException(*state, throwScope, impl.start(WTFMove(when))); |
370 | return JSValue::encode(jsUndefined()); |
371 | } |
372 | |
373 | EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionStart(ExecState* state) |
374 | { |
375 | return IDLOperation<JSOscillatorNode>::call<jsOscillatorNodePrototypeFunctionStartBody>(*state, "start" ); |
376 | } |
377 | |
378 | static inline JSC::EncodedJSValue jsOscillatorNodePrototypeFunctionStopBody(JSC::ExecState* state, typename IDLOperation<JSOscillatorNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
379 | { |
380 | UNUSED_PARAM(state); |
381 | UNUSED_PARAM(throwScope); |
382 | auto& impl = castedThis->wrapped(); |
383 | auto when = state->argument(0).isUndefined() ? 0 : convert<IDLUnrestrictedDouble>(*state, state->uncheckedArgument(0)); |
384 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
385 | propagateException(*state, throwScope, impl.stop(WTFMove(when))); |
386 | return JSValue::encode(jsUndefined()); |
387 | } |
388 | |
389 | EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionStop(ExecState* state) |
390 | { |
391 | return IDLOperation<JSOscillatorNode>::call<jsOscillatorNodePrototypeFunctionStopBody>(*state, "stop" ); |
392 | } |
393 | |
394 | static inline JSC::EncodedJSValue jsOscillatorNodePrototypeFunctionSetPeriodicWaveBody(JSC::ExecState* state, typename IDLOperation<JSOscillatorNode>::ClassParameter castedThis, JSC::ThrowScope& throwScope) |
395 | { |
396 | UNUSED_PARAM(state); |
397 | UNUSED_PARAM(throwScope); |
398 | auto& impl = castedThis->wrapped(); |
399 | if (UNLIKELY(state->argumentCount() < 1)) |
400 | return throwVMError(state, throwScope, createNotEnoughArgumentsError(state)); |
401 | auto wave = convert<IDLNullable<IDLInterface<PeriodicWave>>>(*state, state->uncheckedArgument(0), [](JSC::ExecState& state, JSC::ThrowScope& scope) { throwArgumentTypeError(state, scope, 0, "wave" , "OscillatorNode" , "setPeriodicWave" , "PeriodicWave" ); }); |
402 | RETURN_IF_EXCEPTION(throwScope, encodedJSValue()); |
403 | impl.setPeriodicWave(WTFMove(wave)); |
404 | return JSValue::encode(jsUndefined()); |
405 | } |
406 | |
407 | EncodedJSValue JSC_HOST_CALL jsOscillatorNodePrototypeFunctionSetPeriodicWave(ExecState* state) |
408 | { |
409 | return IDLOperation<JSOscillatorNode>::call<jsOscillatorNodePrototypeFunctionSetPeriodicWaveBody>(*state, "setPeriodicWave" ); |
410 | } |
411 | |
412 | void JSOscillatorNode::heapSnapshot(JSCell* cell, HeapSnapshotBuilder& builder) |
413 | { |
414 | auto* thisObject = jsCast<JSOscillatorNode*>(cell); |
415 | builder.setWrappedObjectForCell(cell, &thisObject->wrapped()); |
416 | if (thisObject->scriptExecutionContext()) |
417 | builder.setLabelForCell(cell, "url " + thisObject->scriptExecutionContext()->url().string()); |
418 | Base::heapSnapshot(cell, builder); |
419 | } |
420 | |
421 | #if ENABLE(BINDING_INTEGRITY) |
422 | #if PLATFORM(WIN) |
423 | #pragma warning(disable: 4483) |
424 | extern "C" { extern void (*const __identifier("??_7OscillatorNode@WebCore@@6B@" )[])(); } |
425 | #else |
426 | extern "C" { extern void* _ZTVN7WebCore14OscillatorNodeE[]; } |
427 | #endif |
428 | #endif |
429 | |
430 | JSC::JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<OscillatorNode>&& impl) |
431 | { |
432 | |
433 | #if ENABLE(BINDING_INTEGRITY) |
434 | void* actualVTablePointer = *(reinterpret_cast<void**>(impl.ptr())); |
435 | #if PLATFORM(WIN) |
436 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(__identifier("??_7OscillatorNode@WebCore@@6B@" )); |
437 | #else |
438 | void* expectedVTablePointer = WTF_PREPARE_VTBL_POINTER_FOR_INSPECTION(&_ZTVN7WebCore14OscillatorNodeE[2]); |
439 | #endif |
440 | |
441 | // If this fails OscillatorNode does not have a vtable, so you need to add the |
442 | // ImplementationLacksVTable attribute to the interface definition |
443 | static_assert(std::is_polymorphic<OscillatorNode>::value, "OscillatorNode is not polymorphic" ); |
444 | |
445 | // If you hit this assertion you either have a use after free bug, or |
446 | // OscillatorNode has subclasses. If OscillatorNode has subclasses that get passed |
447 | // to toJS() we currently require OscillatorNode you to opt out of binding hardening |
448 | // by adding the SkipVTableValidation attribute to the interface IDL definition |
449 | RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); |
450 | #endif |
451 | return createWrapper<OscillatorNode>(globalObject, WTFMove(impl)); |
452 | } |
453 | |
454 | JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, OscillatorNode& impl) |
455 | { |
456 | return wrap(state, globalObject, impl); |
457 | } |
458 | |
459 | |
460 | } |
461 | |
462 | #endif // ENABLE(WEB_AUDIO) |
463 | |