Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM BaseAudioContext.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "BaseAudioContextBinding.h"
4 : #include "EventHandlerBinding.h"
5 : #include "EventTargetBinding.h"
6 : #include "PeriodicWaveBinding.h"
7 : #include "WrapperFactory.h"
8 : #include "jsapi.h"
9 : #include "jsfriendapi.h"
10 : #include "mozilla/FloatingPoint.h"
11 : #include "mozilla/OwningNonNull.h"
12 : #include "mozilla/dom/AnalyserNode.h"
13 : #include "mozilla/dom/AudioBuffer.h"
14 : #include "mozilla/dom/AudioBufferSourceNode.h"
15 : #include "mozilla/dom/AudioContext.h"
16 : #include "mozilla/dom/AudioDestinationNode.h"
17 : #include "mozilla/dom/AudioListener.h"
18 : #include "mozilla/dom/BindingUtils.h"
19 : #include "mozilla/dom/BiquadFilterNode.h"
20 : #include "mozilla/dom/ChannelMergerNode.h"
21 : #include "mozilla/dom/ChannelSplitterNode.h"
22 : #include "mozilla/dom/ConstantSourceNode.h"
23 : #include "mozilla/dom/ConvolverNode.h"
24 : #include "mozilla/dom/DOMException.h"
25 : #include "mozilla/dom/DOMJSClass.h"
26 : #include "mozilla/dom/DelayNode.h"
27 : #include "mozilla/dom/DynamicsCompressorNode.h"
28 : #include "mozilla/dom/GainNode.h"
29 : #include "mozilla/dom/IIRFilterNode.h"
30 : #include "mozilla/dom/NonRefcountedDOMObject.h"
31 : #include "mozilla/dom/Nullable.h"
32 : #include "mozilla/dom/OscillatorNode.h"
33 : #include "mozilla/dom/PannerNode.h"
34 : #include "mozilla/dom/PeriodicWave.h"
35 : #include "mozilla/dom/PrimitiveConversions.h"
36 : #include "mozilla/dom/Promise.h"
37 : #include "mozilla/dom/ScriptProcessorNode.h"
38 : #include "mozilla/dom/StereoPannerNode.h"
39 : #include "mozilla/dom/ToJSValue.h"
40 : #include "mozilla/dom/TypedArray.h"
41 : #include "mozilla/dom/WaveShaperNode.h"
42 : #include "mozilla/dom/XrayExpandoClass.h"
43 :
44 : namespace mozilla {
45 : namespace dom {
46 :
47 : namespace AudioContextStateValues {
48 : extern const EnumEntry strings[4] = {
49 : {"suspended", 9},
50 : {"running", 7},
51 : {"closed", 6},
52 : { nullptr, 0 }
53 : };
54 : } // namespace AudioContextStateValues
55 :
56 : bool
57 0 : ToJSValue(JSContext* aCx, AudioContextState aArgument, JS::MutableHandle<JS::Value> aValue)
58 : {
59 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(AudioContextStateValues::strings));
60 : JSString* resultStr =
61 0 : JS_NewStringCopyN(aCx, AudioContextStateValues::strings[uint32_t(aArgument)].value,
62 0 : AudioContextStateValues::strings[uint32_t(aArgument)].length);
63 0 : if (!resultStr) {
64 0 : return false;
65 : }
66 0 : aValue.setString(resultStr);
67 0 : return true;
68 : }
69 :
70 :
71 : void
72 0 : DecodeSuccessCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, AudioBuffer& decodedData, ErrorResult& aRv)
73 : {
74 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
75 0 : JS::AutoValueVector argv(cx);
76 0 : if (!argv.resize(1)) {
77 0 : aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
78 0 : return;
79 : }
80 0 : unsigned argc = 1;
81 :
82 : do {
83 0 : if (!GetOrCreateDOMReflector(cx, decodedData, argv[0])) {
84 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
85 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
86 0 : return;
87 : }
88 0 : break;
89 : } while (0);
90 :
91 0 : JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
92 0 : if (!JS::Call(cx, aThisVal, callable,
93 0 : JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
94 0 : aRv.NoteJSContextException(cx);
95 0 : return;
96 : }
97 : }
98 :
99 :
100 :
101 : void
102 0 : DecodeErrorCallback::Call(JSContext* cx, JS::Handle<JS::Value> aThisVal, DOMException& error, ErrorResult& aRv)
103 : {
104 0 : JS::Rooted<JS::Value> rval(cx, JS::UndefinedValue());
105 0 : JS::AutoValueVector argv(cx);
106 0 : if (!argv.resize(1)) {
107 0 : aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
108 0 : return;
109 : }
110 0 : unsigned argc = 1;
111 :
112 : do {
113 0 : if (!GetOrCreateDOMReflector(cx, error, argv[0])) {
114 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
115 0 : aRv.Throw(NS_ERROR_UNEXPECTED);
116 0 : return;
117 : }
118 0 : break;
119 : } while (0);
120 :
121 0 : JS::Rooted<JS::Value> callable(cx, JS::ObjectValue(*mCallback));
122 0 : if (!JS::Call(cx, aThisVal, callable,
123 0 : JS::HandleValueArray::subarray(argv, 0, argc), &rval)) {
124 0 : aRv.NoteJSContextException(cx);
125 0 : return;
126 : }
127 : }
128 :
129 :
130 :
131 : namespace binding_detail {
132 : } // namespace binding_detail
133 :
134 :
135 : namespace binding_detail {
136 : } // namespace binding_detail
137 :
138 :
139 : namespace BaseAudioContextBinding {
140 :
141 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
142 : "Can't inherit from an interface with a different ownership model.");
143 :
144 : static bool
145 0 : get_destination(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
146 : {
147 0 : auto result(StrongOrRawPtr<mozilla::dom::AudioDestinationNode>(self->Destination()));
148 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
149 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
150 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
151 0 : return false;
152 : }
153 0 : return true;
154 : }
155 :
156 : static const JSJitInfo destination_getterinfo = {
157 : { (JSJitGetterOp)get_destination },
158 : { prototypes::id::BaseAudioContext },
159 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
160 : JSJitInfo::Getter,
161 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
162 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
163 : false, /* isInfallible. False in setters. */
164 : false, /* isMovable. Not relevant for setters. */
165 : false, /* isEliminatable. Not relevant for setters. */
166 : false, /* isAlwaysInSlot. Only relevant for getters. */
167 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
168 : false, /* isTypedMethod. Only relevant for methods. */
169 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
170 : };
171 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
172 : static_assert(0 < 1, "There is no slot for us");
173 :
174 : static bool
175 0 : get_sampleRate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
176 : {
177 0 : float result(self->SampleRate());
178 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
179 0 : args.rval().set(JS_NumberValue(double(result)));
180 0 : return true;
181 : }
182 :
183 : static const JSJitInfo sampleRate_getterinfo = {
184 : { (JSJitGetterOp)get_sampleRate },
185 : { prototypes::id::BaseAudioContext },
186 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
187 : JSJitInfo::Getter,
188 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
189 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
190 : true, /* isInfallible. False in setters. */
191 : false, /* isMovable. Not relevant for setters. */
192 : false, /* isEliminatable. Not relevant for setters. */
193 : false, /* isAlwaysInSlot. Only relevant for getters. */
194 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
195 : false, /* isTypedMethod. Only relevant for methods. */
196 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
197 : };
198 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
199 : static_assert(0 < 1, "There is no slot for us");
200 :
201 : static bool
202 0 : get_currentTime(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
203 : {
204 0 : double result(self->CurrentTime());
205 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
206 0 : args.rval().set(JS_NumberValue(double(result)));
207 0 : return true;
208 : }
209 :
210 : static const JSJitInfo currentTime_getterinfo = {
211 : { (JSJitGetterOp)get_currentTime },
212 : { prototypes::id::BaseAudioContext },
213 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
214 : JSJitInfo::Getter,
215 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
216 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
217 : true, /* isInfallible. False in setters. */
218 : false, /* isMovable. Not relevant for setters. */
219 : false, /* isEliminatable. Not relevant for setters. */
220 : false, /* isAlwaysInSlot. Only relevant for getters. */
221 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
222 : false, /* isTypedMethod. Only relevant for methods. */
223 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
224 : };
225 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
226 : static_assert(0 < 1, "There is no slot for us");
227 :
228 : static bool
229 0 : get_listener(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
230 : {
231 0 : auto result(StrongOrRawPtr<mozilla::dom::AudioListener>(self->Listener()));
232 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
233 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
234 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
235 0 : return false;
236 : }
237 0 : return true;
238 : }
239 :
240 : static const JSJitInfo listener_getterinfo = {
241 : { (JSJitGetterOp)get_listener },
242 : { prototypes::id::BaseAudioContext },
243 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
244 : JSJitInfo::Getter,
245 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
246 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
247 : false, /* isInfallible. False in setters. */
248 : false, /* isMovable. Not relevant for setters. */
249 : false, /* isEliminatable. Not relevant for setters. */
250 : false, /* isAlwaysInSlot. Only relevant for getters. */
251 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
252 : false, /* isTypedMethod. Only relevant for methods. */
253 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
254 : };
255 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
256 : static_assert(0 < 1, "There is no slot for us");
257 :
258 : static bool
259 0 : get_state(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
260 : {
261 0 : AudioContextState result(self->State());
262 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
263 0 : if (!ToJSValue(cx, result, args.rval())) {
264 0 : return false;
265 : }
266 0 : return true;
267 : }
268 :
269 : static const JSJitInfo state_getterinfo = {
270 : { (JSJitGetterOp)get_state },
271 : { prototypes::id::BaseAudioContext },
272 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
273 : JSJitInfo::Getter,
274 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
275 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
276 : false, /* isInfallible. False in setters. */
277 : false, /* isMovable. Not relevant for setters. */
278 : false, /* isEliminatable. Not relevant for setters. */
279 : false, /* isAlwaysInSlot. Only relevant for getters. */
280 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
281 : false, /* isTypedMethod. Only relevant for methods. */
282 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
283 : };
284 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
285 : static_assert(0 < 1, "There is no slot for us");
286 :
287 : static bool
288 0 : resume(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
289 : {
290 0 : binding_detail::FastErrorResult rv;
291 0 : auto result(StrongOrRawPtr<Promise>(self->Resume(rv)));
292 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
293 0 : return false;
294 : }
295 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
296 0 : if (!ToJSValue(cx, result, args.rval())) {
297 0 : return false;
298 : }
299 0 : return true;
300 : }
301 :
302 : static bool
303 0 : resume_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
304 : {
305 : // Make sure to save the callee before someone maybe messes
306 : // with rval().
307 0 : JS::Rooted<JSObject*> callee(cx, &args.callee());
308 0 : bool ok = resume(cx, obj, self, args);
309 0 : if (ok) {
310 0 : return true;
311 : }
312 0 : return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
313 0 : args.rval());
314 : }
315 :
316 : static const JSJitInfo resume_methodinfo = {
317 : { (JSJitGetterOp)resume_promiseWrapper },
318 : { prototypes::id::BaseAudioContext },
319 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
320 : JSJitInfo::Method,
321 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
322 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
323 : false, /* isInfallible. False in setters. */
324 : false, /* isMovable. Not relevant for setters. */
325 : false, /* isEliminatable. Not relevant for setters. */
326 : false, /* isAlwaysInSlot. Only relevant for getters. */
327 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
328 : false, /* isTypedMethod. Only relevant for methods. */
329 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
330 : };
331 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
332 : static_assert(0 < 1, "There is no slot for us");
333 :
334 : static bool
335 0 : get_onstatechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitGetterCallArgs args)
336 : {
337 0 : RefPtr<EventHandlerNonNull> result(self->GetOnstatechange());
338 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
339 0 : if (result) {
340 0 : args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
341 0 : if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
342 0 : return false;
343 : }
344 0 : return true;
345 : } else {
346 0 : args.rval().setNull();
347 0 : return true;
348 : }
349 : }
350 :
351 : static bool
352 0 : set_onstatechange(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, JSJitSetterCallArgs args)
353 : {
354 0 : RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
355 0 : if (args[0].isObject()) {
356 : { // scope for tempRoot
357 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
358 0 : arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
359 : }
360 : } else {
361 0 : arg0 = nullptr;
362 : }
363 0 : self->SetOnstatechange(Constify(arg0));
364 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
365 :
366 0 : return true;
367 : }
368 :
369 : static const JSJitInfo onstatechange_getterinfo = {
370 : { (JSJitGetterOp)get_onstatechange },
371 : { prototypes::id::BaseAudioContext },
372 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
373 : JSJitInfo::Getter,
374 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
375 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
376 : false, /* isInfallible. False in setters. */
377 : false, /* isMovable. Not relevant for setters. */
378 : false, /* isEliminatable. Not relevant for setters. */
379 : false, /* isAlwaysInSlot. Only relevant for getters. */
380 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
381 : false, /* isTypedMethod. Only relevant for methods. */
382 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
383 : };
384 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
385 : static_assert(0 < 1, "There is no slot for us");
386 : static const JSJitInfo onstatechange_setterinfo = {
387 : { (JSJitGetterOp)set_onstatechange },
388 : { prototypes::id::BaseAudioContext },
389 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
390 : JSJitInfo::Setter,
391 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
392 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
393 : false, /* isInfallible. False in setters. */
394 : false, /* isMovable. Not relevant for setters. */
395 : false, /* isEliminatable. Not relevant for setters. */
396 : false, /* isAlwaysInSlot. Only relevant for getters. */
397 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
398 : false, /* isTypedMethod. Only relevant for methods. */
399 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
400 : };
401 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
402 : static_assert(0 < 1, "There is no slot for us");
403 :
404 : static bool
405 0 : createBuffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
406 : {
407 0 : if (MOZ_UNLIKELY(args.length() < 3)) {
408 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BaseAudioContext.createBuffer");
409 : }
410 : uint32_t arg0;
411 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
412 0 : return false;
413 : }
414 : uint32_t arg1;
415 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
416 0 : return false;
417 : }
418 : float arg2;
419 0 : if (!ValueToPrimitive<float, eDefault>(cx, args[2], &arg2)) {
420 0 : return false;
421 0 : } else if (!mozilla::IsFinite(arg2)) {
422 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 3 of BaseAudioContext.createBuffer");
423 0 : return false;
424 : }
425 0 : binding_detail::FastErrorResult rv;
426 0 : auto result(StrongOrRawPtr<mozilla::dom::AudioBuffer>(self->CreateBuffer(arg0, arg1, arg2, rv)));
427 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
428 0 : return false;
429 : }
430 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
431 : static_assert(!IsPointer<decltype(result)>::value,
432 : "NewObject implies that we need to keep the object alive with a strong reference.");
433 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
434 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
435 0 : return false;
436 : }
437 0 : return true;
438 : }
439 :
440 : static const JSJitInfo createBuffer_methodinfo = {
441 : { (JSJitGetterOp)createBuffer },
442 : { prototypes::id::BaseAudioContext },
443 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
444 : JSJitInfo::Method,
445 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
446 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
447 : false, /* isInfallible. False in setters. */
448 : false, /* isMovable. Not relevant for setters. */
449 : false, /* isEliminatable. Not relevant for setters. */
450 : false, /* isAlwaysInSlot. Only relevant for getters. */
451 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
452 : false, /* isTypedMethod. Only relevant for methods. */
453 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
454 : };
455 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
456 : static_assert(0 < 1, "There is no slot for us");
457 :
458 : static bool
459 0 : decodeAudioData(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
460 : {
461 0 : if (MOZ_UNLIKELY(args.length() < 1)) {
462 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BaseAudioContext.decodeAudioData");
463 : }
464 0 : RootedTypedArray<ArrayBuffer> arg0(cx);
465 0 : if (args[0].isObject()) {
466 0 : if (!arg0.Init(&args[0].toObject())) {
467 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of BaseAudioContext.decodeAudioData", "ArrayBuffer");
468 0 : return false;
469 : }
470 : } else {
471 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of BaseAudioContext.decodeAudioData");
472 0 : return false;
473 : }
474 0 : Optional<OwningNonNull<DecodeSuccessCallback>> arg1;
475 0 : if (args.hasDefined(1)) {
476 0 : arg1.Construct();
477 0 : if (args[1].isObject()) {
478 0 : if (JS::IsCallable(&args[1].toObject())) {
479 : { // scope for tempRoot
480 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[1].toObject());
481 0 : arg1.Value() = new DecodeSuccessCallback(cx, tempRoot, GetIncumbentGlobal());
482 : }
483 : } else {
484 0 : ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 2 of BaseAudioContext.decodeAudioData");
485 0 : return false;
486 : }
487 : } else {
488 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of BaseAudioContext.decodeAudioData");
489 0 : return false;
490 : }
491 : }
492 0 : Optional<OwningNonNull<DecodeErrorCallback>> arg2;
493 0 : if (args.hasDefined(2)) {
494 0 : arg2.Construct();
495 0 : if (args[2].isObject()) {
496 0 : if (JS::IsCallable(&args[2].toObject())) {
497 : { // scope for tempRoot
498 0 : JS::Rooted<JSObject*> tempRoot(cx, &args[2].toObject());
499 0 : arg2.Value() = new DecodeErrorCallback(cx, tempRoot, GetIncumbentGlobal());
500 : }
501 : } else {
502 0 : ThrowErrorMessage(cx, MSG_NOT_CALLABLE, "Argument 3 of BaseAudioContext.decodeAudioData");
503 0 : return false;
504 : }
505 : } else {
506 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 3 of BaseAudioContext.decodeAudioData");
507 0 : return false;
508 : }
509 : }
510 0 : binding_detail::FastErrorResult rv;
511 0 : auto result(StrongOrRawPtr<Promise>(self->DecodeAudioData(Constify(arg0), NonNullHelper(Constify(arg1)), NonNullHelper(Constify(arg2)), rv)));
512 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
513 0 : return false;
514 : }
515 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
516 0 : if (!ToJSValue(cx, result, args.rval())) {
517 0 : return false;
518 : }
519 0 : return true;
520 : }
521 :
522 : static bool
523 0 : decodeAudioData_promiseWrapper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
524 : {
525 : // Make sure to save the callee before someone maybe messes
526 : // with rval().
527 0 : JS::Rooted<JSObject*> callee(cx, &args.callee());
528 0 : bool ok = decodeAudioData(cx, obj, self, args);
529 0 : if (ok) {
530 0 : return true;
531 : }
532 0 : return ConvertExceptionToPromise(cx, xpc::XrayAwareCalleeGlobal(callee),
533 0 : args.rval());
534 : }
535 :
536 : static const JSJitInfo decodeAudioData_methodinfo = {
537 : { (JSJitGetterOp)decodeAudioData_promiseWrapper },
538 : { prototypes::id::BaseAudioContext },
539 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
540 : JSJitInfo::Method,
541 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
542 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
543 : false, /* isInfallible. False in setters. */
544 : false, /* isMovable. Not relevant for setters. */
545 : false, /* isEliminatable. Not relevant for setters. */
546 : false, /* isAlwaysInSlot. Only relevant for getters. */
547 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
548 : false, /* isTypedMethod. Only relevant for methods. */
549 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
550 : };
551 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
552 : static_assert(0 < 1, "There is no slot for us");
553 :
554 : static bool
555 0 : createBufferSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
556 : {
557 0 : binding_detail::FastErrorResult rv;
558 0 : auto result(StrongOrRawPtr<mozilla::dom::AudioBufferSourceNode>(self->CreateBufferSource(rv)));
559 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
560 0 : return false;
561 : }
562 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
563 : static_assert(!IsPointer<decltype(result)>::value,
564 : "NewObject implies that we need to keep the object alive with a strong reference.");
565 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
566 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
567 0 : return false;
568 : }
569 0 : return true;
570 : }
571 :
572 : static const JSJitInfo createBufferSource_methodinfo = {
573 : { (JSJitGetterOp)createBufferSource },
574 : { prototypes::id::BaseAudioContext },
575 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
576 : JSJitInfo::Method,
577 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
578 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
579 : false, /* isInfallible. False in setters. */
580 : false, /* isMovable. Not relevant for setters. */
581 : false, /* isEliminatable. Not relevant for setters. */
582 : false, /* isAlwaysInSlot. Only relevant for getters. */
583 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
584 : false, /* isTypedMethod. Only relevant for methods. */
585 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
586 : };
587 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
588 : static_assert(0 < 1, "There is no slot for us");
589 :
590 : static bool
591 0 : createConstantSource(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
592 : {
593 0 : binding_detail::FastErrorResult rv;
594 0 : auto result(StrongOrRawPtr<mozilla::dom::ConstantSourceNode>(self->CreateConstantSource(rv)));
595 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
596 0 : return false;
597 : }
598 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
599 : static_assert(!IsPointer<decltype(result)>::value,
600 : "NewObject implies that we need to keep the object alive with a strong reference.");
601 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
602 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
603 0 : return false;
604 : }
605 0 : return true;
606 : }
607 :
608 : static const JSJitInfo createConstantSource_methodinfo = {
609 : { (JSJitGetterOp)createConstantSource },
610 : { prototypes::id::BaseAudioContext },
611 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
612 : JSJitInfo::Method,
613 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
614 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
615 : false, /* isInfallible. False in setters. */
616 : false, /* isMovable. Not relevant for setters. */
617 : false, /* isEliminatable. Not relevant for setters. */
618 : false, /* isAlwaysInSlot. Only relevant for getters. */
619 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
620 : false, /* isTypedMethod. Only relevant for methods. */
621 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
622 : };
623 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
624 : static_assert(0 < 1, "There is no slot for us");
625 :
626 : static bool
627 0 : createScriptProcessor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
628 : {
629 : uint32_t arg0;
630 0 : if (args.hasDefined(0)) {
631 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
632 0 : return false;
633 : }
634 : } else {
635 0 : arg0 = 0U;
636 : }
637 : uint32_t arg1;
638 0 : if (args.hasDefined(1)) {
639 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
640 0 : return false;
641 : }
642 : } else {
643 0 : arg1 = 2U;
644 : }
645 : uint32_t arg2;
646 0 : if (args.hasDefined(2)) {
647 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) {
648 0 : return false;
649 : }
650 : } else {
651 0 : arg2 = 2U;
652 : }
653 0 : binding_detail::FastErrorResult rv;
654 0 : auto result(StrongOrRawPtr<mozilla::dom::ScriptProcessorNode>(self->CreateScriptProcessor(arg0, arg1, arg2, rv)));
655 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
656 0 : return false;
657 : }
658 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
659 : static_assert(!IsPointer<decltype(result)>::value,
660 : "NewObject implies that we need to keep the object alive with a strong reference.");
661 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
662 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
663 0 : return false;
664 : }
665 0 : return true;
666 : }
667 :
668 : static const JSJitInfo createScriptProcessor_methodinfo = {
669 : { (JSJitGetterOp)createScriptProcessor },
670 : { prototypes::id::BaseAudioContext },
671 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
672 : JSJitInfo::Method,
673 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
674 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
675 : false, /* isInfallible. False in setters. */
676 : false, /* isMovable. Not relevant for setters. */
677 : false, /* isEliminatable. Not relevant for setters. */
678 : false, /* isAlwaysInSlot. Only relevant for getters. */
679 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
680 : false, /* isTypedMethod. Only relevant for methods. */
681 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
682 : };
683 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
684 : static_assert(0 < 1, "There is no slot for us");
685 :
686 : static bool
687 0 : createAnalyser(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
688 : {
689 0 : binding_detail::FastErrorResult rv;
690 0 : auto result(StrongOrRawPtr<mozilla::dom::AnalyserNode>(self->CreateAnalyser(rv)));
691 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
692 0 : return false;
693 : }
694 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
695 : static_assert(!IsPointer<decltype(result)>::value,
696 : "NewObject implies that we need to keep the object alive with a strong reference.");
697 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
698 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
699 0 : return false;
700 : }
701 0 : return true;
702 : }
703 :
704 : static const JSJitInfo createAnalyser_methodinfo = {
705 : { (JSJitGetterOp)createAnalyser },
706 : { prototypes::id::BaseAudioContext },
707 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
708 : JSJitInfo::Method,
709 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
710 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
711 : false, /* isInfallible. False in setters. */
712 : false, /* isMovable. Not relevant for setters. */
713 : false, /* isEliminatable. Not relevant for setters. */
714 : false, /* isAlwaysInSlot. Only relevant for getters. */
715 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
716 : false, /* isTypedMethod. Only relevant for methods. */
717 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
718 : };
719 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
720 : static_assert(0 < 1, "There is no slot for us");
721 :
722 : static bool
723 0 : createGain(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
724 : {
725 0 : binding_detail::FastErrorResult rv;
726 0 : auto result(StrongOrRawPtr<mozilla::dom::GainNode>(self->CreateGain(rv)));
727 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
728 0 : return false;
729 : }
730 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
731 : static_assert(!IsPointer<decltype(result)>::value,
732 : "NewObject implies that we need to keep the object alive with a strong reference.");
733 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
734 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
735 0 : return false;
736 : }
737 0 : return true;
738 : }
739 :
740 : static const JSJitInfo createGain_methodinfo = {
741 : { (JSJitGetterOp)createGain },
742 : { prototypes::id::BaseAudioContext },
743 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
744 : JSJitInfo::Method,
745 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
746 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
747 : false, /* isInfallible. False in setters. */
748 : false, /* isMovable. Not relevant for setters. */
749 : false, /* isEliminatable. Not relevant for setters. */
750 : false, /* isAlwaysInSlot. Only relevant for getters. */
751 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
752 : false, /* isTypedMethod. Only relevant for methods. */
753 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
754 : };
755 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
756 : static_assert(0 < 1, "There is no slot for us");
757 :
758 : static bool
759 0 : createDelay(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
760 : {
761 : double arg0;
762 0 : if (args.hasDefined(0)) {
763 0 : if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
764 0 : return false;
765 0 : } else if (!mozilla::IsFinite(arg0)) {
766 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of BaseAudioContext.createDelay");
767 0 : return false;
768 : }
769 : } else {
770 0 : arg0 = 1.0;
771 : }
772 0 : binding_detail::FastErrorResult rv;
773 0 : auto result(StrongOrRawPtr<mozilla::dom::DelayNode>(self->CreateDelay(arg0, rv)));
774 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
775 0 : return false;
776 : }
777 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
778 : static_assert(!IsPointer<decltype(result)>::value,
779 : "NewObject implies that we need to keep the object alive with a strong reference.");
780 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
781 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
782 0 : return false;
783 : }
784 0 : return true;
785 : }
786 :
787 : static const JSJitInfo createDelay_methodinfo = {
788 : { (JSJitGetterOp)createDelay },
789 : { prototypes::id::BaseAudioContext },
790 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
791 : JSJitInfo::Method,
792 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
793 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
794 : false, /* isInfallible. False in setters. */
795 : false, /* isMovable. Not relevant for setters. */
796 : false, /* isEliminatable. Not relevant for setters. */
797 : false, /* isAlwaysInSlot. Only relevant for getters. */
798 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
799 : false, /* isTypedMethod. Only relevant for methods. */
800 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
801 : };
802 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
803 : static_assert(0 < 1, "There is no slot for us");
804 :
805 : static bool
806 0 : createBiquadFilter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
807 : {
808 0 : binding_detail::FastErrorResult rv;
809 0 : auto result(StrongOrRawPtr<mozilla::dom::BiquadFilterNode>(self->CreateBiquadFilter(rv)));
810 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
811 0 : return false;
812 : }
813 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
814 : static_assert(!IsPointer<decltype(result)>::value,
815 : "NewObject implies that we need to keep the object alive with a strong reference.");
816 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
817 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
818 0 : return false;
819 : }
820 0 : return true;
821 : }
822 :
823 : static const JSJitInfo createBiquadFilter_methodinfo = {
824 : { (JSJitGetterOp)createBiquadFilter },
825 : { prototypes::id::BaseAudioContext },
826 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
827 : JSJitInfo::Method,
828 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
829 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
830 : false, /* isInfallible. False in setters. */
831 : false, /* isMovable. Not relevant for setters. */
832 : false, /* isEliminatable. Not relevant for setters. */
833 : false, /* isAlwaysInSlot. Only relevant for getters. */
834 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
835 : false, /* isTypedMethod. Only relevant for methods. */
836 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
837 : };
838 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
839 : static_assert(0 < 1, "There is no slot for us");
840 :
841 : static bool
842 0 : createIIRFilter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
843 : {
844 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
845 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BaseAudioContext.createIIRFilter");
846 : }
847 0 : binding_detail::AutoSequence<double> arg0;
848 0 : if (args[0].isObject()) {
849 0 : JS::ForOfIterator iter(cx);
850 0 : if (!iter.init(args[0], JS::ForOfIterator::AllowNonIterable)) {
851 0 : return false;
852 : }
853 0 : if (!iter.valueIsIterable()) {
854 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of BaseAudioContext.createIIRFilter");
855 0 : return false;
856 : }
857 0 : binding_detail::AutoSequence<double> &arr = arg0;
858 0 : JS::Rooted<JS::Value> temp(cx);
859 : while (true) {
860 : bool done;
861 0 : if (!iter.next(&temp, &done)) {
862 0 : return false;
863 : }
864 0 : if (done) {
865 0 : break;
866 : }
867 0 : double* slotPtr = arr.AppendElement(mozilla::fallible);
868 0 : if (!slotPtr) {
869 0 : JS_ReportOutOfMemory(cx);
870 0 : return false;
871 : }
872 0 : double& slot = *slotPtr;
873 0 : if (!ValueToPrimitive<double, eDefault>(cx, temp, &slot)) {
874 0 : return false;
875 0 : } else if (!mozilla::IsFinite(slot)) {
876 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Element of argument 1 of BaseAudioContext.createIIRFilter");
877 0 : return false;
878 : }
879 0 : }
880 : } else {
881 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 1 of BaseAudioContext.createIIRFilter");
882 0 : return false;
883 : }
884 0 : binding_detail::AutoSequence<double> arg1;
885 0 : if (args[1].isObject()) {
886 0 : JS::ForOfIterator iter(cx);
887 0 : if (!iter.init(args[1], JS::ForOfIterator::AllowNonIterable)) {
888 0 : return false;
889 : }
890 0 : if (!iter.valueIsIterable()) {
891 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of BaseAudioContext.createIIRFilter");
892 0 : return false;
893 : }
894 0 : binding_detail::AutoSequence<double> &arr = arg1;
895 0 : JS::Rooted<JS::Value> temp(cx);
896 : while (true) {
897 : bool done;
898 0 : if (!iter.next(&temp, &done)) {
899 0 : return false;
900 : }
901 0 : if (done) {
902 0 : break;
903 : }
904 0 : double* slotPtr = arr.AppendElement(mozilla::fallible);
905 0 : if (!slotPtr) {
906 0 : JS_ReportOutOfMemory(cx);
907 0 : return false;
908 : }
909 0 : double& slot = *slotPtr;
910 0 : if (!ValueToPrimitive<double, eDefault>(cx, temp, &slot)) {
911 0 : return false;
912 0 : } else if (!mozilla::IsFinite(slot)) {
913 0 : ThrowErrorMessage(cx, MSG_NOT_FINITE, "Element of argument 2 of BaseAudioContext.createIIRFilter");
914 0 : return false;
915 : }
916 0 : }
917 : } else {
918 0 : ThrowErrorMessage(cx, MSG_NOT_SEQUENCE, "Argument 2 of BaseAudioContext.createIIRFilter");
919 0 : return false;
920 : }
921 0 : binding_detail::FastErrorResult rv;
922 0 : auto result(StrongOrRawPtr<mozilla::dom::IIRFilterNode>(self->CreateIIRFilter(Constify(arg0), Constify(arg1), rv)));
923 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
924 0 : return false;
925 : }
926 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
927 : static_assert(!IsPointer<decltype(result)>::value,
928 : "NewObject implies that we need to keep the object alive with a strong reference.");
929 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
930 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
931 0 : return false;
932 : }
933 0 : return true;
934 : }
935 :
936 : static const JSJitInfo createIIRFilter_methodinfo = {
937 : { (JSJitGetterOp)createIIRFilter },
938 : { prototypes::id::BaseAudioContext },
939 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
940 : JSJitInfo::Method,
941 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
942 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
943 : false, /* isInfallible. False in setters. */
944 : false, /* isMovable. Not relevant for setters. */
945 : false, /* isEliminatable. Not relevant for setters. */
946 : false, /* isAlwaysInSlot. Only relevant for getters. */
947 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
948 : false, /* isTypedMethod. Only relevant for methods. */
949 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
950 : };
951 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
952 : static_assert(0 < 1, "There is no slot for us");
953 :
954 : static bool
955 0 : createWaveShaper(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
956 : {
957 0 : binding_detail::FastErrorResult rv;
958 0 : auto result(StrongOrRawPtr<mozilla::dom::WaveShaperNode>(self->CreateWaveShaper(rv)));
959 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
960 0 : return false;
961 : }
962 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
963 : static_assert(!IsPointer<decltype(result)>::value,
964 : "NewObject implies that we need to keep the object alive with a strong reference.");
965 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
966 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
967 0 : return false;
968 : }
969 0 : return true;
970 : }
971 :
972 : static const JSJitInfo createWaveShaper_methodinfo = {
973 : { (JSJitGetterOp)createWaveShaper },
974 : { prototypes::id::BaseAudioContext },
975 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
976 : JSJitInfo::Method,
977 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
978 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
979 : false, /* isInfallible. False in setters. */
980 : false, /* isMovable. Not relevant for setters. */
981 : false, /* isEliminatable. Not relevant for setters. */
982 : false, /* isAlwaysInSlot. Only relevant for getters. */
983 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
984 : false, /* isTypedMethod. Only relevant for methods. */
985 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
986 : };
987 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
988 : static_assert(0 < 1, "There is no slot for us");
989 :
990 : static bool
991 0 : createPanner(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
992 : {
993 0 : binding_detail::FastErrorResult rv;
994 0 : auto result(StrongOrRawPtr<mozilla::dom::PannerNode>(self->CreatePanner(rv)));
995 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
996 0 : return false;
997 : }
998 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
999 : static_assert(!IsPointer<decltype(result)>::value,
1000 : "NewObject implies that we need to keep the object alive with a strong reference.");
1001 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1002 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1003 0 : return false;
1004 : }
1005 0 : return true;
1006 : }
1007 :
1008 : static const JSJitInfo createPanner_methodinfo = {
1009 : { (JSJitGetterOp)createPanner },
1010 : { prototypes::id::BaseAudioContext },
1011 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1012 : JSJitInfo::Method,
1013 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1014 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1015 : false, /* isInfallible. False in setters. */
1016 : false, /* isMovable. Not relevant for setters. */
1017 : false, /* isEliminatable. Not relevant for setters. */
1018 : false, /* isAlwaysInSlot. Only relevant for getters. */
1019 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1020 : false, /* isTypedMethod. Only relevant for methods. */
1021 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1022 : };
1023 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1024 : static_assert(0 < 1, "There is no slot for us");
1025 :
1026 : static bool
1027 0 : createStereoPanner(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1028 : {
1029 0 : binding_detail::FastErrorResult rv;
1030 0 : auto result(StrongOrRawPtr<mozilla::dom::StereoPannerNode>(self->CreateStereoPanner(rv)));
1031 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1032 0 : return false;
1033 : }
1034 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1035 : static_assert(!IsPointer<decltype(result)>::value,
1036 : "NewObject implies that we need to keep the object alive with a strong reference.");
1037 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1038 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1039 0 : return false;
1040 : }
1041 0 : return true;
1042 : }
1043 :
1044 : static const JSJitInfo createStereoPanner_methodinfo = {
1045 : { (JSJitGetterOp)createStereoPanner },
1046 : { prototypes::id::BaseAudioContext },
1047 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1048 : JSJitInfo::Method,
1049 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1050 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1051 : false, /* isInfallible. False in setters. */
1052 : false, /* isMovable. Not relevant for setters. */
1053 : false, /* isEliminatable. Not relevant for setters. */
1054 : false, /* isAlwaysInSlot. Only relevant for getters. */
1055 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1056 : false, /* isTypedMethod. Only relevant for methods. */
1057 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1058 : };
1059 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1060 : static_assert(0 < 1, "There is no slot for us");
1061 :
1062 : static bool
1063 0 : createConvolver(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1064 : {
1065 0 : binding_detail::FastErrorResult rv;
1066 0 : auto result(StrongOrRawPtr<mozilla::dom::ConvolverNode>(self->CreateConvolver(rv)));
1067 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1068 0 : return false;
1069 : }
1070 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1071 : static_assert(!IsPointer<decltype(result)>::value,
1072 : "NewObject implies that we need to keep the object alive with a strong reference.");
1073 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1074 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1075 0 : return false;
1076 : }
1077 0 : return true;
1078 : }
1079 :
1080 : static const JSJitInfo createConvolver_methodinfo = {
1081 : { (JSJitGetterOp)createConvolver },
1082 : { prototypes::id::BaseAudioContext },
1083 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1084 : JSJitInfo::Method,
1085 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1086 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1087 : false, /* isInfallible. False in setters. */
1088 : false, /* isMovable. Not relevant for setters. */
1089 : false, /* isEliminatable. Not relevant for setters. */
1090 : false, /* isAlwaysInSlot. Only relevant for getters. */
1091 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1092 : false, /* isTypedMethod. Only relevant for methods. */
1093 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1094 : };
1095 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1096 : static_assert(0 < 1, "There is no slot for us");
1097 :
1098 : static bool
1099 0 : createChannelSplitter(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1100 : {
1101 : uint32_t arg0;
1102 0 : if (args.hasDefined(0)) {
1103 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
1104 0 : return false;
1105 : }
1106 : } else {
1107 0 : arg0 = 6U;
1108 : }
1109 0 : binding_detail::FastErrorResult rv;
1110 0 : auto result(StrongOrRawPtr<mozilla::dom::ChannelSplitterNode>(self->CreateChannelSplitter(arg0, rv)));
1111 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1112 0 : return false;
1113 : }
1114 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1115 : static_assert(!IsPointer<decltype(result)>::value,
1116 : "NewObject implies that we need to keep the object alive with a strong reference.");
1117 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1118 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1119 0 : return false;
1120 : }
1121 0 : return true;
1122 : }
1123 :
1124 : static const JSJitInfo createChannelSplitter_methodinfo = {
1125 : { (JSJitGetterOp)createChannelSplitter },
1126 : { prototypes::id::BaseAudioContext },
1127 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1128 : JSJitInfo::Method,
1129 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1130 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1131 : false, /* isInfallible. False in setters. */
1132 : false, /* isMovable. Not relevant for setters. */
1133 : false, /* isEliminatable. Not relevant for setters. */
1134 : false, /* isAlwaysInSlot. Only relevant for getters. */
1135 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1136 : false, /* isTypedMethod. Only relevant for methods. */
1137 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1138 : };
1139 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1140 : static_assert(0 < 1, "There is no slot for us");
1141 :
1142 : static bool
1143 0 : createChannelMerger(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1144 : {
1145 : uint32_t arg0;
1146 0 : if (args.hasDefined(0)) {
1147 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
1148 0 : return false;
1149 : }
1150 : } else {
1151 0 : arg0 = 6U;
1152 : }
1153 0 : binding_detail::FastErrorResult rv;
1154 0 : auto result(StrongOrRawPtr<mozilla::dom::ChannelMergerNode>(self->CreateChannelMerger(arg0, rv)));
1155 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1156 0 : return false;
1157 : }
1158 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1159 : static_assert(!IsPointer<decltype(result)>::value,
1160 : "NewObject implies that we need to keep the object alive with a strong reference.");
1161 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1162 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1163 0 : return false;
1164 : }
1165 0 : return true;
1166 : }
1167 :
1168 : static const JSJitInfo createChannelMerger_methodinfo = {
1169 : { (JSJitGetterOp)createChannelMerger },
1170 : { prototypes::id::BaseAudioContext },
1171 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1172 : JSJitInfo::Method,
1173 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1174 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1175 : false, /* isInfallible. False in setters. */
1176 : false, /* isMovable. Not relevant for setters. */
1177 : false, /* isEliminatable. Not relevant for setters. */
1178 : false, /* isAlwaysInSlot. Only relevant for getters. */
1179 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1180 : false, /* isTypedMethod. Only relevant for methods. */
1181 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1182 : };
1183 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1184 : static_assert(0 < 1, "There is no slot for us");
1185 :
1186 : static bool
1187 0 : createDynamicsCompressor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1188 : {
1189 0 : binding_detail::FastErrorResult rv;
1190 0 : auto result(StrongOrRawPtr<mozilla::dom::DynamicsCompressorNode>(self->CreateDynamicsCompressor(rv)));
1191 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1192 0 : return false;
1193 : }
1194 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1195 : static_assert(!IsPointer<decltype(result)>::value,
1196 : "NewObject implies that we need to keep the object alive with a strong reference.");
1197 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1198 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1199 0 : return false;
1200 : }
1201 0 : return true;
1202 : }
1203 :
1204 : static const JSJitInfo createDynamicsCompressor_methodinfo = {
1205 : { (JSJitGetterOp)createDynamicsCompressor },
1206 : { prototypes::id::BaseAudioContext },
1207 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1208 : JSJitInfo::Method,
1209 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1210 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1211 : false, /* isInfallible. False in setters. */
1212 : false, /* isMovable. Not relevant for setters. */
1213 : false, /* isEliminatable. Not relevant for setters. */
1214 : false, /* isAlwaysInSlot. Only relevant for getters. */
1215 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1216 : false, /* isTypedMethod. Only relevant for methods. */
1217 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1218 : };
1219 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1220 : static_assert(0 < 1, "There is no slot for us");
1221 :
1222 : static bool
1223 0 : createOscillator(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1224 : {
1225 0 : binding_detail::FastErrorResult rv;
1226 0 : auto result(StrongOrRawPtr<mozilla::dom::OscillatorNode>(self->CreateOscillator(rv)));
1227 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1228 0 : return false;
1229 : }
1230 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1231 : static_assert(!IsPointer<decltype(result)>::value,
1232 : "NewObject implies that we need to keep the object alive with a strong reference.");
1233 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1234 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1235 0 : return false;
1236 : }
1237 0 : return true;
1238 : }
1239 :
1240 : static const JSJitInfo createOscillator_methodinfo = {
1241 : { (JSJitGetterOp)createOscillator },
1242 : { prototypes::id::BaseAudioContext },
1243 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1244 : JSJitInfo::Method,
1245 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1246 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1247 : false, /* isInfallible. False in setters. */
1248 : false, /* isMovable. Not relevant for setters. */
1249 : false, /* isEliminatable. Not relevant for setters. */
1250 : false, /* isAlwaysInSlot. Only relevant for getters. */
1251 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1252 : false, /* isTypedMethod. Only relevant for methods. */
1253 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1254 : };
1255 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1256 : static_assert(0 < 1, "There is no slot for us");
1257 :
1258 : static bool
1259 0 : createPeriodicWave(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioContext* self, const JSJitMethodCallArgs& args)
1260 : {
1261 0 : if (MOZ_UNLIKELY(args.length() < 2)) {
1262 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "BaseAudioContext.createPeriodicWave");
1263 : }
1264 0 : RootedTypedArray<Float32Array> arg0(cx);
1265 0 : if (args[0].isObject()) {
1266 0 : if (!arg0.Init(&args[0].toObject())) {
1267 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of BaseAudioContext.createPeriodicWave", "Float32Array");
1268 0 : return false;
1269 : }
1270 : } else {
1271 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of BaseAudioContext.createPeriodicWave");
1272 0 : return false;
1273 : }
1274 0 : RootedTypedArray<Float32Array> arg1(cx);
1275 0 : if (args[1].isObject()) {
1276 0 : if (!arg1.Init(&args[1].toObject())) {
1277 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 2 of BaseAudioContext.createPeriodicWave", "Float32Array");
1278 0 : return false;
1279 : }
1280 : } else {
1281 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 2 of BaseAudioContext.createPeriodicWave");
1282 0 : return false;
1283 : }
1284 0 : binding_detail::FastPeriodicWaveConstraints arg2;
1285 0 : if (!arg2.Init(cx, (args.hasDefined(2)) ? args[2] : JS::NullHandleValue, "Argument 3 of BaseAudioContext.createPeriodicWave", false)) {
1286 0 : return false;
1287 : }
1288 0 : binding_detail::FastErrorResult rv;
1289 0 : auto result(StrongOrRawPtr<mozilla::dom::PeriodicWave>(self->CreatePeriodicWave(Constify(arg0), Constify(arg1), Constify(arg2), rv)));
1290 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
1291 0 : return false;
1292 : }
1293 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
1294 : static_assert(!IsPointer<decltype(result)>::value,
1295 : "NewObject implies that we need to keep the object alive with a strong reference.");
1296 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
1297 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
1298 0 : return false;
1299 : }
1300 0 : return true;
1301 : }
1302 :
1303 : static const JSJitInfo createPeriodicWave_methodinfo = {
1304 : { (JSJitGetterOp)createPeriodicWave },
1305 : { prototypes::id::BaseAudioContext },
1306 : { PrototypeTraits<prototypes::id::BaseAudioContext>::Depth },
1307 : JSJitInfo::Method,
1308 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
1309 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
1310 : false, /* isInfallible. False in setters. */
1311 : false, /* isMovable. Not relevant for setters. */
1312 : false, /* isEliminatable. Not relevant for setters. */
1313 : false, /* isAlwaysInSlot. Only relevant for getters. */
1314 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
1315 : false, /* isTypedMethod. Only relevant for methods. */
1316 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
1317 : };
1318 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
1319 : static_assert(0 < 1, "There is no slot for us");
1320 :
1321 : static bool
1322 0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
1323 : {
1324 0 : mozilla::dom::AudioContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioContext>(obj);
1325 : // We don't want to preserve if we don't have a wrapper, and we
1326 : // obviously can't preserve if we're not initialized.
1327 0 : if (self && self->GetWrapperPreserveColor()) {
1328 0 : PreserveWrapper(self);
1329 : }
1330 0 : return true;
1331 : }
1332 :
1333 : static void
1334 0 : _finalize(js::FreeOp* fop, JSObject* obj)
1335 : {
1336 0 : mozilla::dom::AudioContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioContext>(obj);
1337 0 : if (self) {
1338 0 : ClearWrapper(self, self, obj);
1339 0 : AddForDeferredFinalization<mozilla::dom::AudioContext>(self);
1340 : }
1341 0 : }
1342 :
1343 : static void
1344 0 : _objectMoved(JSObject* obj, const JSObject* old)
1345 : {
1346 0 : mozilla::dom::AudioContext* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioContext>(obj);
1347 0 : if (self) {
1348 0 : UpdateWrapper(self, self, obj, old);
1349 : }
1350 0 : }
1351 :
1352 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1353 : #if defined(__clang__)
1354 : #pragma clang diagnostic push
1355 : #pragma clang diagnostic ignored "-Wmissing-braces"
1356 : #endif
1357 : static const JSFunctionSpec sMethods_specs[] = {
1358 : JS_FNSPEC("resume", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&resume_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1359 : JS_FNSPEC("createBuffer", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createBuffer_methodinfo), 3, JSPROP_ENUMERATE, nullptr),
1360 : JS_FNSPEC("decodeAudioData", GenericPromiseReturningBindingMethod, reinterpret_cast<const JSJitInfo*>(&decodeAudioData_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
1361 : JS_FNSPEC("createBufferSource", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createBufferSource_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1362 : JS_FNSPEC("createConstantSource", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createConstantSource_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1363 : JS_FNSPEC("createScriptProcessor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createScriptProcessor_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1364 : JS_FNSPEC("createAnalyser", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createAnalyser_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1365 : JS_FNSPEC("createGain", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createGain_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1366 : JS_FNSPEC("createDelay", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createDelay_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1367 : JS_FNSPEC("createBiquadFilter", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createBiquadFilter_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1368 : JS_FNSPEC("createIIRFilter", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createIIRFilter_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1369 : JS_FNSPEC("createWaveShaper", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createWaveShaper_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1370 : JS_FNSPEC("createPanner", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createPanner_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1371 : JS_FNSPEC("createStereoPanner", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createStereoPanner_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1372 : JS_FNSPEC("createConvolver", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createConvolver_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1373 : JS_FNSPEC("createChannelSplitter", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createChannelSplitter_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1374 : JS_FNSPEC("createChannelMerger", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createChannelMerger_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1375 : JS_FNSPEC("createDynamicsCompressor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createDynamicsCompressor_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1376 : JS_FNSPEC("createOscillator", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createOscillator_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
1377 : JS_FNSPEC("createPeriodicWave", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&createPeriodicWave_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
1378 : JS_FS_END
1379 : };
1380 : #if defined(__clang__)
1381 : #pragma clang diagnostic pop
1382 : #endif
1383 :
1384 :
1385 : // Can't be const because the pref-enabled boolean needs to be writable
1386 : static Prefable<const JSFunctionSpec> sMethods[] = {
1387 : { nullptr, &sMethods_specs[0] },
1388 : { nullptr, nullptr }
1389 : };
1390 :
1391 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1392 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1393 : static_assert(20 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1394 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1395 :
1396 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
1397 : #if defined(__clang__)
1398 : #pragma clang diagnostic push
1399 : #pragma clang diagnostic ignored "-Wmissing-braces"
1400 : #endif
1401 : static const JSPropertySpec sAttributes_specs[] = {
1402 : { "destination", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &destination_getterinfo, nullptr, nullptr },
1403 : { "sampleRate", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &sampleRate_getterinfo, nullptr, nullptr },
1404 : { "currentTime", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, ¤tTime_getterinfo, nullptr, nullptr },
1405 : { "listener", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &listener_getterinfo, nullptr, nullptr },
1406 : { "state", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &state_getterinfo, nullptr, nullptr },
1407 : { "onstatechange", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onstatechange_getterinfo, GenericBindingSetter, &onstatechange_setterinfo },
1408 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
1409 : };
1410 : #if defined(__clang__)
1411 : #pragma clang diagnostic pop
1412 : #endif
1413 :
1414 :
1415 : // Can't be const because the pref-enabled boolean needs to be writable
1416 : static Prefable<const JSPropertySpec> sAttributes[] = {
1417 : { nullptr, &sAttributes_specs[0] },
1418 : { nullptr, nullptr }
1419 : };
1420 :
1421 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1422 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1423 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1424 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1425 :
1426 :
1427 : static uint16_t sNativeProperties_sortedPropertyIndices[26];
1428 : static PropertyInfo sNativeProperties_propertyInfos[26];
1429 :
1430 : static const NativePropertiesN<2> sNativeProperties = {
1431 : false, 0,
1432 : false, 0,
1433 : true, 0 /* sMethods */,
1434 : true, 1 /* sAttributes */,
1435 : false, 0,
1436 : false, 0,
1437 : false, 0,
1438 : -1,
1439 : 26,
1440 : sNativeProperties_sortedPropertyIndices,
1441 : {
1442 : { sMethods, &sNativeProperties_propertyInfos[0] },
1443 : { sAttributes, &sNativeProperties_propertyInfos[20] }
1444 : }
1445 : };
1446 : static_assert(26 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1447 : "We have a property info count that is oversized");
1448 :
1449 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1450 : {
1451 : "Function",
1452 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1453 : &sBoringInterfaceObjectClassClassOps,
1454 : JS_NULL_CLASS_SPEC,
1455 : JS_NULL_CLASS_EXT,
1456 : &sInterfaceObjectClassObjectOps
1457 : },
1458 : eInterface,
1459 : true,
1460 : prototypes::id::BaseAudioContext,
1461 : PrototypeTraits<prototypes::id::BaseAudioContext>::Depth,
1462 : sNativePropertyHooks,
1463 : "function BaseAudioContext() {\n [native code]\n}",
1464 : EventTargetBinding::GetConstructorObject
1465 : };
1466 :
1467 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1468 : {
1469 : "BaseAudioContextPrototype",
1470 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1471 : JS_NULL_CLASS_OPS,
1472 : JS_NULL_CLASS_SPEC,
1473 : JS_NULL_CLASS_EXT,
1474 : JS_NULL_OBJECT_OPS
1475 : },
1476 : eInterfacePrototype,
1477 : false,
1478 : prototypes::id::BaseAudioContext,
1479 : PrototypeTraits<prototypes::id::BaseAudioContext>::Depth,
1480 : sNativePropertyHooks,
1481 : "[object BaseAudioContextPrototype]",
1482 : EventTargetBinding::GetProtoObject
1483 : };
1484 :
1485 : JSObject*
1486 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1487 : {
1488 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1489 : }
1490 :
1491 : static const js::ClassOps sClassOps = {
1492 : _addProperty, /* addProperty */
1493 : nullptr, /* delProperty */
1494 : nullptr, /* getProperty */
1495 : nullptr, /* setProperty */
1496 : nullptr, /* enumerate */
1497 : nullptr, /* newEnumerate */
1498 : nullptr, /* resolve */
1499 : nullptr, /* mayResolve */
1500 : _finalize, /* finalize */
1501 : nullptr, /* call */
1502 : nullptr, /* hasInstance */
1503 : nullptr, /* construct */
1504 : nullptr, /* trace */
1505 : };
1506 :
1507 : static const js::ClassExtension sClassExtension = {
1508 : nullptr, /* weakmapKeyDelegateOp */
1509 : _objectMoved /* objectMovedOp */
1510 : };
1511 :
1512 : static const DOMJSClass sClass = {
1513 : { "BaseAudioContext",
1514 : JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
1515 : &sClassOps,
1516 : JS_NULL_CLASS_SPEC,
1517 : &sClassExtension,
1518 : JS_NULL_OBJECT_OPS
1519 : },
1520 : { prototypes::id::EventTarget, prototypes::id::BaseAudioContext, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
1521 : IsBaseOf<nsISupports, mozilla::dom::AudioContext >::value,
1522 : sNativePropertyHooks,
1523 : FindAssociatedGlobalForNative<mozilla::dom::AudioContext>::Get,
1524 : GetProtoObjectHandle,
1525 : GetCCParticipant<mozilla::dom::AudioContext>::Get()
1526 : };
1527 : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
1528 : "Must have the right minimal number of reserved slots.");
1529 : static_assert(1 >= 1,
1530 : "Must have enough reserved slots.");
1531 :
1532 : const JSClass*
1533 0 : GetJSClass()
1534 : {
1535 0 : return sClass.ToJSClass();
1536 : }
1537 :
1538 : bool
1539 0 : Wrap(JSContext* aCx, mozilla::dom::AudioContext* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
1540 : {
1541 : MOZ_ASSERT(static_cast<mozilla::dom::AudioContext*>(aObject) ==
1542 : reinterpret_cast<mozilla::dom::AudioContext*>(aObject),
1543 : "Multiple inheritance for mozilla::dom::AudioContext is broken.");
1544 : MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
1545 : reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
1546 : "Multiple inheritance for mozilla::dom::EventTarget is broken.");
1547 0 : MOZ_ASSERT(ToSupportsIsCorrect(aObject));
1548 0 : MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
1549 0 : MOZ_ASSERT(!aCache->GetWrapper(),
1550 : "You should probably not be using Wrap() directly; use "
1551 : "GetOrCreateDOMReflector instead");
1552 :
1553 0 : MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
1554 : "nsISupports must be on our primary inheritance chain");
1555 :
1556 0 : JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
1557 0 : if (!global) {
1558 0 : return false;
1559 : }
1560 0 : MOZ_ASSERT(JS_IsGlobalObject(global));
1561 0 : MOZ_ASSERT(JS::ObjectIsNotGray(global));
1562 :
1563 : // That might have ended up wrapping us already, due to the wonders
1564 : // of XBL. Check for that, and bail out as needed.
1565 0 : aReflector.set(aCache->GetWrapper());
1566 0 : if (aReflector) {
1567 : #ifdef DEBUG
1568 0 : binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
1569 : #endif // DEBUG
1570 0 : return true;
1571 : }
1572 :
1573 0 : JSAutoCompartment ac(aCx, global);
1574 0 : JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
1575 0 : if (!canonicalProto) {
1576 0 : return false;
1577 : }
1578 0 : JS::Rooted<JSObject*> proto(aCx);
1579 0 : if (aGivenProto) {
1580 0 : proto = aGivenProto;
1581 : // Unfortunately, while aGivenProto was in the compartment of aCx
1582 : // coming in, we changed compartments to that of "parent" so may need
1583 : // to wrap the proto here.
1584 0 : if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
1585 0 : if (!JS_WrapObject(aCx, &proto)) {
1586 0 : return false;
1587 : }
1588 : }
1589 : } else {
1590 0 : proto = canonicalProto;
1591 : }
1592 :
1593 0 : BindingJSObjectCreator<mozilla::dom::AudioContext> creator(aCx);
1594 0 : creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
1595 0 : if (!aReflector) {
1596 0 : return false;
1597 : }
1598 :
1599 0 : aCache->SetWrapper(aReflector);
1600 0 : creator.InitializationSucceeded();
1601 :
1602 0 : MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
1603 : aCache->GetWrapperPreserveColor() == aReflector);
1604 : // If proto != canonicalProto, we have to preserve our wrapper;
1605 : // otherwise we won't be able to properly recreate it later, since
1606 : // we won't know what proto to use. Note that we don't check
1607 : // aGivenProto here, since it's entirely possible (and even
1608 : // somewhat common) to have a non-null aGivenProto which is the
1609 : // same as canonicalProto.
1610 0 : if (proto != canonicalProto) {
1611 0 : PreserveWrapper(aObject);
1612 : }
1613 :
1614 0 : return true;
1615 : }
1616 :
1617 : const NativePropertyHooks sNativePropertyHooks[] = { {
1618 : nullptr,
1619 : nullptr,
1620 : nullptr,
1621 : { sNativeProperties.Upcast(), nullptr },
1622 : prototypes::id::BaseAudioContext,
1623 : constructors::id::BaseAudioContext,
1624 : EventTargetBinding::sNativePropertyHooks,
1625 : &DefaultXrayExpandoObjectClass
1626 : } };
1627 :
1628 : void
1629 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1630 : {
1631 0 : JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
1632 0 : if (!parentProto) {
1633 0 : return;
1634 : }
1635 :
1636 0 : JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
1637 0 : if (!constructorProto) {
1638 0 : return;
1639 : }
1640 :
1641 : static bool sIdsInited = false;
1642 0 : if (!sIdsInited && NS_IsMainThread()) {
1643 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1644 0 : return;
1645 : }
1646 0 : sIdsInited = true;
1647 : }
1648 :
1649 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::BaseAudioContext);
1650 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::BaseAudioContext);
1651 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1652 : &sPrototypeClass.mBase, protoCache,
1653 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1654 : interfaceCache,
1655 : sNativeProperties.Upcast(),
1656 : nullptr,
1657 : "BaseAudioContext", aDefineOnGlobal,
1658 : nullptr,
1659 0 : false);
1660 : }
1661 :
1662 : JS::Handle<JSObject*>
1663 0 : GetProtoObjectHandle(JSContext* aCx)
1664 : {
1665 : /* Get the interface prototype object for this class. This will create the
1666 : object as needed. */
1667 0 : bool aDefineOnGlobal = true;
1668 :
1669 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1670 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1671 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1672 0 : return nullptr;
1673 : }
1674 :
1675 : /* Check to see whether the interface objects are already installed */
1676 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1677 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::BaseAudioContext)) {
1678 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1679 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1680 : }
1681 :
1682 : /*
1683 : * The object might _still_ be null, but that's OK.
1684 : *
1685 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1686 : * traced by TraceProtoAndIfaceCache() and its contents are never
1687 : * changed after they have been set.
1688 : *
1689 : * Calling address() avoids the read read barrier that does gray
1690 : * unmarking, but it's not possible for the object to be gray here.
1691 : */
1692 :
1693 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::BaseAudioContext);
1694 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1695 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1696 : }
1697 :
1698 : JSObject*
1699 0 : GetProtoObject(JSContext* aCx)
1700 : {
1701 0 : return GetProtoObjectHandle(aCx);
1702 : }
1703 :
1704 : JS::Handle<JSObject*>
1705 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1706 : {
1707 : /* Get the interface object for this class. This will create the object as
1708 : needed. */
1709 :
1710 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1711 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1712 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1713 0 : return nullptr;
1714 : }
1715 :
1716 : /* Check to see whether the interface objects are already installed */
1717 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1718 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::BaseAudioContext)) {
1719 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1720 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1721 : }
1722 :
1723 : /*
1724 : * The object might _still_ be null, but that's OK.
1725 : *
1726 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1727 : * traced by TraceProtoAndIfaceCache() and its contents are never
1728 : * changed after they have been set.
1729 : *
1730 : * Calling address() avoids the read read barrier that does gray
1731 : * unmarking, but it's not possible for the object to be gray here.
1732 : */
1733 :
1734 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::BaseAudioContext);
1735 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1736 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1737 : }
1738 :
1739 : JSObject*
1740 0 : GetConstructorObject(JSContext* aCx)
1741 : {
1742 0 : return GetConstructorObjectHandle(aCx);
1743 : }
1744 :
1745 : } // namespace BaseAudioContextBinding
1746 :
1747 :
1748 :
1749 : } // namespace dom
1750 : } // namespace mozilla
|