Line data Source code
1 : /* THIS FILE IS AUTOGENERATED FROM AudioNode.webidl BY Codegen.py - DO NOT EDIT */
2 :
3 : #include "AtomList.h"
4 : #include "AudioNodeBinding.h"
5 : #include "EventTargetBinding.h"
6 : #include "WrapperFactory.h"
7 : #include "jsapi.h"
8 : #include "mozilla/OwningNonNull.h"
9 : #include "mozilla/Preferences.h"
10 : #include "mozilla/dom/AudioContext.h"
11 : #include "mozilla/dom/AudioNode.h"
12 : #include "mozilla/dom/AudioParam.h"
13 : #include "mozilla/dom/BindingUtils.h"
14 : #include "mozilla/dom/DOMJSClass.h"
15 : #include "mozilla/dom/NonRefcountedDOMObject.h"
16 : #include "mozilla/dom/PrimitiveConversions.h"
17 : #include "mozilla/dom/ScriptSettings.h"
18 : #include "mozilla/dom/SimpleGlobalObject.h"
19 : #include "mozilla/dom/XrayExpandoClass.h"
20 : #include "nsContentUtils.h"
21 :
22 : namespace mozilla {
23 : namespace dom {
24 :
25 : namespace ChannelCountModeValues {
26 : extern const EnumEntry strings[4] = {
27 : {"max", 3},
28 : {"clamped-max", 11},
29 : {"explicit", 8},
30 : { nullptr, 0 }
31 : };
32 : } // namespace ChannelCountModeValues
33 :
34 : bool
35 0 : ToJSValue(JSContext* aCx, ChannelCountMode aArgument, JS::MutableHandle<JS::Value> aValue)
36 : {
37 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ChannelCountModeValues::strings));
38 : JSString* resultStr =
39 0 : JS_NewStringCopyN(aCx, ChannelCountModeValues::strings[uint32_t(aArgument)].value,
40 0 : ChannelCountModeValues::strings[uint32_t(aArgument)].length);
41 0 : if (!resultStr) {
42 0 : return false;
43 : }
44 0 : aValue.setString(resultStr);
45 0 : return true;
46 : }
47 :
48 :
49 : namespace ChannelInterpretationValues {
50 : extern const EnumEntry strings[3] = {
51 : {"speakers", 8},
52 : {"discrete", 8},
53 : { nullptr, 0 }
54 : };
55 : } // namespace ChannelInterpretationValues
56 :
57 : bool
58 0 : ToJSValue(JSContext* aCx, ChannelInterpretation aArgument, JS::MutableHandle<JS::Value> aValue)
59 : {
60 0 : MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(ChannelInterpretationValues::strings));
61 : JSString* resultStr =
62 0 : JS_NewStringCopyN(aCx, ChannelInterpretationValues::strings[uint32_t(aArgument)].value,
63 0 : ChannelInterpretationValues::strings[uint32_t(aArgument)].length);
64 0 : if (!resultStr) {
65 0 : return false;
66 : }
67 0 : aValue.setString(resultStr);
68 0 : return true;
69 : }
70 :
71 :
72 :
73 0 : AudioNodeOptions::AudioNodeOptions()
74 : {
75 : // Safe to pass a null context if we pass a null value
76 0 : Init(nullptr, JS::NullHandleValue);
77 0 : }
78 :
79 :
80 :
81 : bool
82 0 : AudioNodeOptions::InitIds(JSContext* cx, AudioNodeOptionsAtoms* atomsCache)
83 : {
84 0 : MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
85 :
86 : // Initialize these in reverse order so that any failure leaves the first one
87 : // uninitialized.
88 0 : if (!atomsCache->channelInterpretation_id.init(cx, "channelInterpretation") ||
89 0 : !atomsCache->channelCountMode_id.init(cx, "channelCountMode") ||
90 0 : !atomsCache->channelCount_id.init(cx, "channelCount")) {
91 0 : return false;
92 : }
93 0 : return true;
94 : }
95 :
96 : bool
97 0 : AudioNodeOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
98 : {
99 : // Passing a null JSContext is OK only if we're initing from null,
100 : // Since in that case we will not have to do any property gets
101 : // Also evaluate isNullOrUndefined in order to avoid false-positive
102 : // checkers by static analysis tools
103 0 : MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
104 0 : AudioNodeOptionsAtoms* atomsCache = nullptr;
105 0 : if (cx) {
106 0 : atomsCache = GetAtomCache<AudioNodeOptionsAtoms>(cx);
107 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
108 0 : return false;
109 : }
110 : }
111 :
112 0 : if (!IsConvertibleToDictionary(val)) {
113 0 : return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
114 : }
115 :
116 0 : bool isNull = val.isNullOrUndefined();
117 : // We only need these if !isNull, in which case we have |cx|.
118 0 : Maybe<JS::Rooted<JSObject *> > object;
119 0 : Maybe<JS::Rooted<JS::Value> > temp;
120 0 : if (!isNull) {
121 0 : MOZ_ASSERT(cx);
122 0 : object.emplace(cx, &val.toObject());
123 0 : temp.emplace(cx);
124 : }
125 0 : if (!isNull) {
126 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->channelCount_id, temp.ptr())) {
127 0 : return false;
128 : }
129 : }
130 0 : if (!isNull && !temp->isUndefined()) {
131 0 : mChannelCount.Construct();
132 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &(mChannelCount.Value()))) {
133 0 : return false;
134 : }
135 0 : mIsAnyMemberPresent = true;
136 : }
137 :
138 0 : if (!isNull) {
139 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->channelCountMode_id, temp.ptr())) {
140 0 : return false;
141 : }
142 : }
143 0 : if (!isNull && !temp->isUndefined()) {
144 0 : mChannelCountMode.Construct();
145 : {
146 : int index;
147 0 : if (!FindEnumStringIndex<true>(cx, temp.ref(), ChannelCountModeValues::strings, "ChannelCountMode", "'channelCountMode' member of AudioNodeOptions", &index)) {
148 0 : return false;
149 : }
150 0 : MOZ_ASSERT(index >= 0);
151 0 : (mChannelCountMode.Value()) = static_cast<ChannelCountMode>(index);
152 : }
153 0 : mIsAnyMemberPresent = true;
154 : }
155 :
156 0 : if (!isNull) {
157 0 : if (!JS_GetPropertyById(cx, *object, atomsCache->channelInterpretation_id, temp.ptr())) {
158 0 : return false;
159 : }
160 : }
161 0 : if (!isNull && !temp->isUndefined()) {
162 0 : mChannelInterpretation.Construct();
163 : {
164 : int index;
165 0 : if (!FindEnumStringIndex<true>(cx, temp.ref(), ChannelInterpretationValues::strings, "ChannelInterpretation", "'channelInterpretation' member of AudioNodeOptions", &index)) {
166 0 : return false;
167 : }
168 0 : MOZ_ASSERT(index >= 0);
169 0 : (mChannelInterpretation.Value()) = static_cast<ChannelInterpretation>(index);
170 : }
171 0 : mIsAnyMemberPresent = true;
172 : }
173 0 : return true;
174 : }
175 :
176 : bool
177 0 : AudioNodeOptions::Init(const nsAString& aJSON)
178 : {
179 0 : AutoJSAPI jsapi;
180 0 : JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
181 0 : if (!cleanGlobal) {
182 0 : return false;
183 : }
184 0 : if (!jsapi.Init(cleanGlobal)) {
185 0 : return false;
186 : }
187 0 : JSContext* cx = jsapi.cx();
188 0 : JS::Rooted<JS::Value> json(cx);
189 0 : bool ok = ParseJSON(cx, aJSON, &json);
190 0 : NS_ENSURE_TRUE(ok, false);
191 0 : return Init(cx, json);
192 : }
193 :
194 : bool
195 0 : AudioNodeOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
196 : {
197 0 : AudioNodeOptionsAtoms* atomsCache = GetAtomCache<AudioNodeOptionsAtoms>(cx);
198 0 : if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
199 0 : return false;
200 : }
201 :
202 0 : JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
203 0 : if (!obj) {
204 0 : return false;
205 : }
206 0 : rval.set(JS::ObjectValue(*obj));
207 :
208 0 : if (mChannelCount.WasPassed()) {
209 : do {
210 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
211 0 : JS::Rooted<JS::Value> temp(cx);
212 0 : uint32_t const & currentValue = mChannelCount.InternalValue();
213 0 : temp.setNumber(currentValue);
214 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->channelCount_id, temp, JSPROP_ENUMERATE)) {
215 0 : return false;
216 : }
217 0 : break;
218 : } while(0);
219 : }
220 :
221 0 : if (mChannelCountMode.WasPassed()) {
222 : do {
223 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
224 0 : JS::Rooted<JS::Value> temp(cx);
225 0 : ChannelCountMode const & currentValue = mChannelCountMode.InternalValue();
226 0 : if (!ToJSValue(cx, currentValue, &temp)) {
227 0 : return false;
228 : }
229 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->channelCountMode_id, temp, JSPROP_ENUMERATE)) {
230 0 : return false;
231 : }
232 0 : break;
233 : } while(0);
234 : }
235 :
236 0 : if (mChannelInterpretation.WasPassed()) {
237 : do {
238 : // block for our 'break' successCode and scope for 'temp' and 'currentValue'
239 0 : JS::Rooted<JS::Value> temp(cx);
240 0 : ChannelInterpretation const & currentValue = mChannelInterpretation.InternalValue();
241 0 : if (!ToJSValue(cx, currentValue, &temp)) {
242 0 : return false;
243 : }
244 0 : if (!JS_DefinePropertyById(cx, obj, atomsCache->channelInterpretation_id, temp, JSPROP_ENUMERATE)) {
245 0 : return false;
246 : }
247 0 : break;
248 : } while(0);
249 : }
250 :
251 0 : return true;
252 : }
253 :
254 : bool
255 0 : AudioNodeOptions::ToJSON(nsAString& aJSON) const
256 : {
257 0 : AutoJSAPI jsapi;
258 0 : jsapi.Init();
259 0 : JSContext *cx = jsapi.cx();
260 : // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
261 : // because we'll only be creating objects, in ways that have no
262 : // side-effects, followed by a call to JS::ToJSONMaybeSafely,
263 : // which likewise guarantees no side-effects for the sorts of
264 : // things we will pass it.
265 0 : JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
266 0 : JS::Rooted<JS::Value> val(cx);
267 0 : if (!ToObjectInternal(cx, &val)) {
268 0 : return false;
269 : }
270 0 : JS::Rooted<JSObject*> obj(cx, &val.toObject());
271 0 : return StringifyToJSON(cx, obj, aJSON);
272 : }
273 :
274 : void
275 0 : AudioNodeOptions::TraceDictionary(JSTracer* trc)
276 : {
277 0 : }
278 :
279 : AudioNodeOptions&
280 0 : AudioNodeOptions::operator=(const AudioNodeOptions& aOther)
281 : {
282 0 : mChannelCount.Reset();
283 0 : if (aOther.mChannelCount.WasPassed()) {
284 0 : mChannelCount.Construct(aOther.mChannelCount.Value());
285 : }
286 0 : mChannelCountMode.Reset();
287 0 : if (aOther.mChannelCountMode.WasPassed()) {
288 0 : mChannelCountMode.Construct(aOther.mChannelCountMode.Value());
289 : }
290 0 : mChannelInterpretation.Reset();
291 0 : if (aOther.mChannelInterpretation.WasPassed()) {
292 0 : mChannelInterpretation.Construct(aOther.mChannelInterpretation.Value());
293 : }
294 0 : return *this;
295 : }
296 :
297 : namespace binding_detail {
298 : } // namespace binding_detail
299 :
300 :
301 : namespace AudioNodeBinding {
302 :
303 : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
304 : "Can't inherit from an interface with a different ownership model.");
305 :
306 : static bool
307 0 : connect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, const JSJitMethodCallArgs& args)
308 : {
309 0 : unsigned argcount = std::min(args.length(), 3u);
310 0 : switch (argcount) {
311 : case 1: {
312 : MOZ_FALLTHROUGH;
313 : }
314 : case 2: {
315 0 : if (args[0].isObject()) {
316 : do {
317 0 : NonNull<mozilla::dom::AudioNode> arg0;
318 : {
319 0 : nsresult rv = UnwrapObject<prototypes::id::AudioNode, mozilla::dom::AudioNode>(args[0], arg0);
320 0 : if (NS_FAILED(rv)) {
321 0 : break;
322 : }
323 : }
324 : uint32_t arg1;
325 0 : if (args.hasDefined(1)) {
326 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
327 0 : return false;
328 : }
329 : } else {
330 0 : arg1 = 0U;
331 : }
332 : uint32_t arg2;
333 0 : if (args.hasDefined(2)) {
334 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) {
335 0 : return false;
336 : }
337 : } else {
338 0 : arg2 = 0U;
339 : }
340 0 : binding_detail::FastErrorResult rv;
341 0 : auto result(StrongOrRawPtr<mozilla::dom::AudioNode>(self->Connect(NonNullHelper(arg0), arg1, arg2, rv)));
342 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
343 0 : return false;
344 : }
345 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
346 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
347 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
348 0 : return false;
349 : }
350 0 : return true;
351 : } while (0);
352 : do {
353 0 : NonNull<mozilla::dom::AudioParam> arg0;
354 : {
355 0 : nsresult rv = UnwrapObject<prototypes::id::AudioParam, mozilla::dom::AudioParam>(args[0], arg0);
356 0 : if (NS_FAILED(rv)) {
357 0 : break;
358 : }
359 : }
360 : uint32_t arg1;
361 0 : if (args.hasDefined(1)) {
362 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
363 0 : return false;
364 : }
365 : } else {
366 0 : arg1 = 0U;
367 : }
368 0 : binding_detail::FastErrorResult rv;
369 0 : self->Connect(NonNullHelper(arg0), arg1, rv);
370 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
371 0 : return false;
372 : }
373 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
374 0 : args.rval().setUndefined();
375 0 : return true;
376 : } while (0);
377 : }
378 0 : return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "1", "2", "AudioNode.connect");
379 : break;
380 : }
381 : case 3: {
382 0 : NonNull<mozilla::dom::AudioNode> arg0;
383 0 : if (args[0].isObject()) {
384 : {
385 0 : nsresult rv = UnwrapObject<prototypes::id::AudioNode, mozilla::dom::AudioNode>(args[0], arg0);
386 0 : if (NS_FAILED(rv)) {
387 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of AudioNode.connect", "AudioNode");
388 0 : return false;
389 : }
390 : }
391 : } else {
392 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of AudioNode.connect");
393 0 : return false;
394 : }
395 : uint32_t arg1;
396 0 : if (args.hasDefined(1)) {
397 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
398 0 : return false;
399 : }
400 : } else {
401 0 : arg1 = 0U;
402 : }
403 : uint32_t arg2;
404 0 : if (args.hasDefined(2)) {
405 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) {
406 0 : return false;
407 : }
408 : } else {
409 0 : arg2 = 0U;
410 : }
411 0 : binding_detail::FastErrorResult rv;
412 0 : auto result(StrongOrRawPtr<mozilla::dom::AudioNode>(self->Connect(NonNullHelper(arg0), arg1, arg2, rv)));
413 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
414 0 : return false;
415 : }
416 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
417 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
418 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
419 0 : return false;
420 : }
421 0 : return true;
422 : break;
423 : }
424 : default: {
425 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AudioNode.connect");
426 : break;
427 : }
428 : }
429 : MOZ_CRASH("We have an always-returning default case");
430 : return false;
431 : }
432 :
433 : static const JSJitInfo connect_methodinfo = {
434 : { (JSJitGetterOp)connect },
435 : { prototypes::id::AudioNode },
436 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
437 : JSJitInfo::Method,
438 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
439 : JSVAL_TYPE_UNKNOWN, /* returnType. Not relevant for setters. */
440 : false, /* isInfallible. False in setters. */
441 : false, /* isMovable. Not relevant for setters. */
442 : false, /* isEliminatable. Not relevant for setters. */
443 : false, /* isAlwaysInSlot. Only relevant for getters. */
444 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
445 : false, /* isTypedMethod. Only relevant for methods. */
446 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
447 : };
448 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
449 : static_assert(0 < 1, "There is no slot for us");
450 :
451 : static bool
452 0 : disconnect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, const JSJitMethodCallArgs& args)
453 : {
454 0 : unsigned argcount = std::min(args.length(), 3u);
455 0 : switch (argcount) {
456 : case 0: {
457 0 : binding_detail::FastErrorResult rv;
458 0 : self->Disconnect(rv);
459 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
460 0 : return false;
461 : }
462 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
463 0 : args.rval().setUndefined();
464 0 : return true;
465 : break;
466 : }
467 : case 1: {
468 0 : if (args[0].isObject()) {
469 : do {
470 0 : NonNull<mozilla::dom::AudioNode> arg0;
471 : {
472 0 : nsresult rv = UnwrapObject<prototypes::id::AudioNode, mozilla::dom::AudioNode>(args[0], arg0);
473 0 : if (NS_FAILED(rv)) {
474 0 : break;
475 : }
476 : }
477 0 : binding_detail::FastErrorResult rv;
478 0 : self->Disconnect(NonNullHelper(arg0), rv);
479 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
480 0 : return false;
481 : }
482 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
483 0 : args.rval().setUndefined();
484 0 : return true;
485 : } while (0);
486 : do {
487 0 : NonNull<mozilla::dom::AudioParam> arg0;
488 : {
489 0 : nsresult rv = UnwrapObject<prototypes::id::AudioParam, mozilla::dom::AudioParam>(args[0], arg0);
490 0 : if (NS_FAILED(rv)) {
491 0 : break;
492 : }
493 : }
494 0 : binding_detail::FastErrorResult rv;
495 0 : self->Disconnect(NonNullHelper(arg0), rv);
496 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
497 0 : return false;
498 : }
499 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
500 0 : args.rval().setUndefined();
501 0 : return true;
502 : } while (0);
503 : }
504 : uint32_t arg0;
505 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
506 0 : return false;
507 : }
508 0 : binding_detail::FastErrorResult rv;
509 0 : self->Disconnect(arg0, rv);
510 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
511 0 : return false;
512 : }
513 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
514 0 : args.rval().setUndefined();
515 0 : return true;
516 : break;
517 : }
518 : case 2: {
519 0 : if (args[0].isObject()) {
520 : do {
521 0 : NonNull<mozilla::dom::AudioNode> arg0;
522 : {
523 0 : nsresult rv = UnwrapObject<prototypes::id::AudioNode, mozilla::dom::AudioNode>(args[0], arg0);
524 0 : if (NS_FAILED(rv)) {
525 0 : break;
526 : }
527 : }
528 : uint32_t arg1;
529 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
530 0 : return false;
531 : }
532 0 : binding_detail::FastErrorResult rv;
533 0 : self->Disconnect(NonNullHelper(arg0), arg1, rv);
534 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
535 0 : return false;
536 : }
537 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
538 0 : args.rval().setUndefined();
539 0 : return true;
540 : } while (0);
541 : do {
542 0 : NonNull<mozilla::dom::AudioParam> arg0;
543 : {
544 0 : nsresult rv = UnwrapObject<prototypes::id::AudioParam, mozilla::dom::AudioParam>(args[0], arg0);
545 0 : if (NS_FAILED(rv)) {
546 0 : break;
547 : }
548 : }
549 : uint32_t arg1;
550 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
551 0 : return false;
552 : }
553 0 : binding_detail::FastErrorResult rv;
554 0 : self->Disconnect(NonNullHelper(arg0), arg1, rv);
555 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
556 0 : return false;
557 : }
558 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
559 0 : args.rval().setUndefined();
560 0 : return true;
561 : } while (0);
562 : }
563 0 : return ThrowErrorMessage(cx, MSG_OVERLOAD_RESOLUTION_FAILED, "1", "2", "AudioNode.disconnect");
564 : break;
565 : }
566 : case 3: {
567 0 : NonNull<mozilla::dom::AudioNode> arg0;
568 0 : if (args[0].isObject()) {
569 : {
570 0 : nsresult rv = UnwrapObject<prototypes::id::AudioNode, mozilla::dom::AudioNode>(args[0], arg0);
571 0 : if (NS_FAILED(rv)) {
572 0 : ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of AudioNode.disconnect", "AudioNode");
573 0 : return false;
574 : }
575 : }
576 : } else {
577 0 : ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of AudioNode.disconnect");
578 0 : return false;
579 : }
580 : uint32_t arg1;
581 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[1], &arg1)) {
582 0 : return false;
583 : }
584 : uint32_t arg2;
585 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[2], &arg2)) {
586 0 : return false;
587 : }
588 0 : binding_detail::FastErrorResult rv;
589 0 : self->Disconnect(NonNullHelper(arg0), arg1, arg2, rv);
590 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
591 0 : return false;
592 : }
593 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
594 0 : args.rval().setUndefined();
595 0 : return true;
596 : break;
597 : }
598 : default: {
599 0 : return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "AudioNode.disconnect");
600 : break;
601 : }
602 : }
603 : MOZ_CRASH("We have an always-returning default case");
604 : return false;
605 : }
606 :
607 : static const JSJitInfo disconnect_methodinfo = {
608 : { (JSJitGetterOp)disconnect },
609 : { prototypes::id::AudioNode },
610 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
611 : JSJitInfo::Method,
612 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
613 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
614 : false, /* isInfallible. False in setters. */
615 : false, /* isMovable. Not relevant for setters. */
616 : false, /* isEliminatable. Not relevant for setters. */
617 : false, /* isAlwaysInSlot. Only relevant for getters. */
618 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
619 : false, /* isTypedMethod. Only relevant for methods. */
620 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
621 : };
622 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
623 : static_assert(0 < 1, "There is no slot for us");
624 :
625 : static bool
626 0 : get_context(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitGetterCallArgs args)
627 : {
628 0 : auto result(StrongOrRawPtr<mozilla::dom::AudioContext>(self->Context()));
629 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
630 0 : if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
631 0 : MOZ_ASSERT(true || JS_IsExceptionPending(cx));
632 0 : return false;
633 : }
634 0 : return true;
635 : }
636 :
637 : static const JSJitInfo context_getterinfo = {
638 : { (JSJitGetterOp)get_context },
639 : { prototypes::id::AudioNode },
640 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
641 : JSJitInfo::Getter,
642 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
643 : JSVAL_TYPE_OBJECT, /* returnType. Not relevant for setters. */
644 : false, /* isInfallible. False in setters. */
645 : false, /* isMovable. Not relevant for setters. */
646 : false, /* isEliminatable. Not relevant for setters. */
647 : false, /* isAlwaysInSlot. Only relevant for getters. */
648 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
649 : false, /* isTypedMethod. Only relevant for methods. */
650 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
651 : };
652 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
653 : static_assert(0 < 1, "There is no slot for us");
654 :
655 : static bool
656 0 : get_numberOfInputs(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitGetterCallArgs args)
657 : {
658 0 : uint32_t result(self->NumberOfInputs());
659 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
660 0 : args.rval().setNumber(result);
661 0 : return true;
662 : }
663 :
664 : static const JSJitInfo numberOfInputs_getterinfo = {
665 : { (JSJitGetterOp)get_numberOfInputs },
666 : { prototypes::id::AudioNode },
667 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
668 : JSJitInfo::Getter,
669 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
670 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
671 : true, /* isInfallible. False in setters. */
672 : false, /* isMovable. Not relevant for setters. */
673 : false, /* isEliminatable. Not relevant for setters. */
674 : false, /* isAlwaysInSlot. Only relevant for getters. */
675 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
676 : false, /* isTypedMethod. Only relevant for methods. */
677 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
678 : };
679 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
680 : static_assert(0 < 1, "There is no slot for us");
681 :
682 : static bool
683 0 : get_numberOfOutputs(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitGetterCallArgs args)
684 : {
685 0 : uint32_t result(self->NumberOfOutputs());
686 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
687 0 : args.rval().setNumber(result);
688 0 : return true;
689 : }
690 :
691 : static const JSJitInfo numberOfOutputs_getterinfo = {
692 : { (JSJitGetterOp)get_numberOfOutputs },
693 : { prototypes::id::AudioNode },
694 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
695 : JSJitInfo::Getter,
696 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
697 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
698 : true, /* isInfallible. False in setters. */
699 : false, /* isMovable. Not relevant for setters. */
700 : false, /* isEliminatable. Not relevant for setters. */
701 : false, /* isAlwaysInSlot. Only relevant for getters. */
702 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
703 : false, /* isTypedMethod. Only relevant for methods. */
704 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
705 : };
706 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
707 : static_assert(0 < 1, "There is no slot for us");
708 :
709 : static bool
710 0 : get_channelCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitGetterCallArgs args)
711 : {
712 0 : uint32_t result(self->ChannelCount());
713 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
714 0 : args.rval().setNumber(result);
715 0 : return true;
716 : }
717 :
718 : static bool
719 0 : set_channelCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitSetterCallArgs args)
720 : {
721 : uint32_t arg0;
722 0 : if (!ValueToPrimitive<uint32_t, eDefault>(cx, args[0], &arg0)) {
723 0 : return false;
724 : }
725 0 : binding_detail::FastErrorResult rv;
726 0 : self->SetChannelCount(arg0, rv);
727 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
728 0 : return false;
729 : }
730 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
731 :
732 0 : return true;
733 : }
734 :
735 : static const JSJitInfo channelCount_getterinfo = {
736 : { (JSJitGetterOp)get_channelCount },
737 : { prototypes::id::AudioNode },
738 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
739 : JSJitInfo::Getter,
740 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
741 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
742 : true, /* isInfallible. False in setters. */
743 : false, /* isMovable. Not relevant for setters. */
744 : false, /* isEliminatable. Not relevant for setters. */
745 : false, /* isAlwaysInSlot. Only relevant for getters. */
746 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
747 : false, /* isTypedMethod. Only relevant for methods. */
748 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
749 : };
750 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
751 : static_assert(0 < 1, "There is no slot for us");
752 : static const JSJitInfo channelCount_setterinfo = {
753 : { (JSJitGetterOp)set_channelCount },
754 : { prototypes::id::AudioNode },
755 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
756 : JSJitInfo::Setter,
757 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
758 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
759 : false, /* isInfallible. False in setters. */
760 : false, /* isMovable. Not relevant for setters. */
761 : false, /* isEliminatable. Not relevant for setters. */
762 : false, /* isAlwaysInSlot. Only relevant for getters. */
763 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
764 : false, /* isTypedMethod. Only relevant for methods. */
765 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
766 : };
767 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
768 : static_assert(0 < 1, "There is no slot for us");
769 :
770 : static bool
771 0 : get_channelCountMode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitGetterCallArgs args)
772 : {
773 0 : ChannelCountMode result(self->ChannelCountModeValue());
774 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
775 0 : if (!ToJSValue(cx, result, args.rval())) {
776 0 : return false;
777 : }
778 0 : return true;
779 : }
780 :
781 : static bool
782 0 : set_channelCountMode(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitSetterCallArgs args)
783 : {
784 : ChannelCountMode arg0;
785 : {
786 : int index;
787 0 : if (!FindEnumStringIndex<false>(cx, args[0], ChannelCountModeValues::strings, "ChannelCountMode", "Value being assigned to AudioNode.channelCountMode", &index)) {
788 0 : return false;
789 : }
790 0 : if (index < 0) {
791 0 : return true;
792 : }
793 0 : arg0 = static_cast<ChannelCountMode>(index);
794 : }
795 0 : binding_detail::FastErrorResult rv;
796 0 : self->SetChannelCountModeValue(arg0, rv);
797 0 : if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
798 0 : return false;
799 : }
800 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
801 :
802 0 : return true;
803 : }
804 :
805 : static const JSJitInfo channelCountMode_getterinfo = {
806 : { (JSJitGetterOp)get_channelCountMode },
807 : { prototypes::id::AudioNode },
808 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
809 : JSJitInfo::Getter,
810 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
811 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
812 : false, /* isInfallible. False in setters. */
813 : false, /* isMovable. Not relevant for setters. */
814 : false, /* isEliminatable. Not relevant for setters. */
815 : false, /* isAlwaysInSlot. Only relevant for getters. */
816 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
817 : false, /* isTypedMethod. Only relevant for methods. */
818 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
819 : };
820 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
821 : static_assert(0 < 1, "There is no slot for us");
822 : static const JSJitInfo channelCountMode_setterinfo = {
823 : { (JSJitGetterOp)set_channelCountMode },
824 : { prototypes::id::AudioNode },
825 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
826 : JSJitInfo::Setter,
827 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
828 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
829 : false, /* isInfallible. False in setters. */
830 : false, /* isMovable. Not relevant for setters. */
831 : false, /* isEliminatable. Not relevant for setters. */
832 : false, /* isAlwaysInSlot. Only relevant for getters. */
833 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
834 : false, /* isTypedMethod. Only relevant for methods. */
835 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
836 : };
837 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
838 : static_assert(0 < 1, "There is no slot for us");
839 :
840 : static bool
841 0 : get_channelInterpretation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitGetterCallArgs args)
842 : {
843 0 : ChannelInterpretation result(self->ChannelInterpretationValue());
844 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
845 0 : if (!ToJSValue(cx, result, args.rval())) {
846 0 : return false;
847 : }
848 0 : return true;
849 : }
850 :
851 : static bool
852 0 : set_channelInterpretation(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitSetterCallArgs args)
853 : {
854 : ChannelInterpretation arg0;
855 : {
856 : int index;
857 0 : if (!FindEnumStringIndex<false>(cx, args[0], ChannelInterpretationValues::strings, "ChannelInterpretation", "Value being assigned to AudioNode.channelInterpretation", &index)) {
858 0 : return false;
859 : }
860 0 : if (index < 0) {
861 0 : return true;
862 : }
863 0 : arg0 = static_cast<ChannelInterpretation>(index);
864 : }
865 0 : self->SetChannelInterpretationValue(arg0);
866 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
867 :
868 0 : return true;
869 : }
870 :
871 : static const JSJitInfo channelInterpretation_getterinfo = {
872 : { (JSJitGetterOp)get_channelInterpretation },
873 : { prototypes::id::AudioNode },
874 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
875 : JSJitInfo::Getter,
876 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
877 : JSVAL_TYPE_STRING, /* returnType. Not relevant for setters. */
878 : false, /* isInfallible. False in setters. */
879 : false, /* isMovable. Not relevant for setters. */
880 : false, /* isEliminatable. Not relevant for setters. */
881 : false, /* isAlwaysInSlot. Only relevant for getters. */
882 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
883 : false, /* isTypedMethod. Only relevant for methods. */
884 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
885 : };
886 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
887 : static_assert(0 < 1, "There is no slot for us");
888 : static const JSJitInfo channelInterpretation_setterinfo = {
889 : { (JSJitGetterOp)set_channelInterpretation },
890 : { prototypes::id::AudioNode },
891 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
892 : JSJitInfo::Setter,
893 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
894 : JSVAL_TYPE_UNDEFINED, /* returnType. Not relevant for setters. */
895 : false, /* isInfallible. False in setters. */
896 : false, /* isMovable. Not relevant for setters. */
897 : false, /* isEliminatable. Not relevant for setters. */
898 : false, /* isAlwaysInSlot. Only relevant for getters. */
899 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
900 : false, /* isTypedMethod. Only relevant for methods. */
901 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
902 : };
903 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
904 : static_assert(0 < 1, "There is no slot for us");
905 :
906 : static bool
907 0 : get_id(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioNode* self, JSJitGetterCallArgs args)
908 : {
909 0 : uint32_t result(self->Id());
910 0 : MOZ_ASSERT(!JS_IsExceptionPending(cx));
911 0 : args.rval().setNumber(result);
912 0 : return true;
913 : }
914 :
915 : static const JSJitInfo id_getterinfo = {
916 : { (JSJitGetterOp)get_id },
917 : { prototypes::id::AudioNode },
918 : { PrototypeTraits<prototypes::id::AudioNode>::Depth },
919 : JSJitInfo::Getter,
920 : JSJitInfo::AliasEverything, /* aliasSet. Not relevant for setters. */
921 : JSVAL_TYPE_DOUBLE, /* returnType. Not relevant for setters. */
922 : true, /* isInfallible. False in setters. */
923 : false, /* isMovable. Not relevant for setters. */
924 : false, /* isEliminatable. Not relevant for setters. */
925 : false, /* isAlwaysInSlot. Only relevant for getters. */
926 : false, /* isLazilyCachedInSlot. Only relevant for getters. */
927 : false, /* isTypedMethod. Only relevant for methods. */
928 : 0 /* Reserved slot index, if we're stored in a slot, else 0. */
929 : };
930 : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
931 : static_assert(0 < 1, "There is no slot for us");
932 :
933 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
934 : #if defined(__clang__)
935 : #pragma clang diagnostic push
936 : #pragma clang diagnostic ignored "-Wmissing-braces"
937 : #endif
938 : static const JSFunctionSpec sMethods_specs[] = {
939 : JS_FNSPEC("connect", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&connect_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
940 : JS_FNSPEC("disconnect", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&disconnect_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
941 : JS_FS_END
942 : };
943 : #if defined(__clang__)
944 : #pragma clang diagnostic pop
945 : #endif
946 :
947 :
948 : // Can't be const because the pref-enabled boolean needs to be writable
949 : static Prefable<const JSFunctionSpec> sMethods[] = {
950 : { nullptr, &sMethods_specs[0] },
951 : { nullptr, nullptr }
952 : };
953 :
954 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
955 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
956 : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
957 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
958 :
959 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
960 : #if defined(__clang__)
961 : #pragma clang diagnostic push
962 : #pragma clang diagnostic ignored "-Wmissing-braces"
963 : #endif
964 : static const JSPropertySpec sAttributes_specs[] = {
965 : { "context", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &context_getterinfo, nullptr, nullptr },
966 : { "numberOfInputs", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &numberOfInputs_getterinfo, nullptr, nullptr },
967 : { "numberOfOutputs", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &numberOfOutputs_getterinfo, nullptr, nullptr },
968 : { "channelCount", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &channelCount_getterinfo, GenericBindingSetter, &channelCount_setterinfo },
969 : { "channelCountMode", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &channelCountMode_getterinfo, GenericBindingSetter, &channelCountMode_setterinfo },
970 : { "channelInterpretation", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &channelInterpretation_getterinfo, GenericBindingSetter, &channelInterpretation_setterinfo },
971 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
972 : };
973 : #if defined(__clang__)
974 : #pragma clang diagnostic pop
975 : #endif
976 :
977 :
978 : // Can't be const because the pref-enabled boolean needs to be writable
979 : static Prefable<const JSPropertySpec> sAttributes[] = {
980 : { nullptr, &sAttributes_specs[0] },
981 : { nullptr, nullptr }
982 : };
983 :
984 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
985 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
986 : static_assert(6 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
987 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
988 :
989 : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
990 : #if defined(__clang__)
991 : #pragma clang diagnostic push
992 : #pragma clang diagnostic ignored "-Wmissing-braces"
993 : #endif
994 : static const JSPropertySpec sChromeAttributes_specs[] = {
995 : { "id", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &id_getterinfo, nullptr, nullptr },
996 : { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
997 : };
998 : #if defined(__clang__)
999 : #pragma clang diagnostic pop
1000 : #endif
1001 :
1002 :
1003 : // Can't be const because the pref-enabled boolean needs to be writable
1004 : static Prefable<const JSPropertySpec> sChromeAttributes[] = {
1005 : { nullptr, &sChromeAttributes_specs[0] },
1006 : { nullptr, nullptr }
1007 : };
1008 :
1009 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
1010 : "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
1011 : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
1012 : "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
1013 :
1014 :
1015 : static uint16_t sNativeProperties_sortedPropertyIndices[8];
1016 : static PropertyInfo sNativeProperties_propertyInfos[8];
1017 :
1018 : static const NativePropertiesN<2> sNativeProperties = {
1019 : false, 0,
1020 : false, 0,
1021 : true, 0 /* sMethods */,
1022 : true, 1 /* sAttributes */,
1023 : false, 0,
1024 : false, 0,
1025 : false, 0,
1026 : -1,
1027 : 8,
1028 : sNativeProperties_sortedPropertyIndices,
1029 : {
1030 : { sMethods, &sNativeProperties_propertyInfos[0] },
1031 : { sAttributes, &sNativeProperties_propertyInfos[2] }
1032 : }
1033 : };
1034 : static_assert(8 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
1035 : "We have a property info count that is oversized");
1036 :
1037 : static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
1038 : static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
1039 :
1040 : static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
1041 : false, 0,
1042 : false, 0,
1043 : false, 0,
1044 : true, 0 /* sChromeAttributes */,
1045 : false, 0,
1046 : false, 0,
1047 : false, 0,
1048 : -1,
1049 : 1,
1050 : sChromeOnlyNativeProperties_sortedPropertyIndices,
1051 : {
1052 : { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
1053 : }
1054 : };
1055 : static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
1056 : "We have a property info count that is oversized");
1057 :
1058 : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
1059 : {
1060 : "Function",
1061 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
1062 : &sBoringInterfaceObjectClassClassOps,
1063 : JS_NULL_CLASS_SPEC,
1064 : JS_NULL_CLASS_EXT,
1065 : &sInterfaceObjectClassObjectOps
1066 : },
1067 : eInterface,
1068 : true,
1069 : prototypes::id::AudioNode,
1070 : PrototypeTraits<prototypes::id::AudioNode>::Depth,
1071 : sNativePropertyHooks,
1072 : "function AudioNode() {\n [native code]\n}",
1073 : EventTargetBinding::GetConstructorObject
1074 : };
1075 :
1076 : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
1077 : {
1078 : "AudioNodePrototype",
1079 : JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
1080 : JS_NULL_CLASS_OPS,
1081 : JS_NULL_CLASS_SPEC,
1082 : JS_NULL_CLASS_EXT,
1083 : JS_NULL_OBJECT_OPS
1084 : },
1085 : eInterfacePrototype,
1086 : false,
1087 : prototypes::id::AudioNode,
1088 : PrototypeTraits<prototypes::id::AudioNode>::Depth,
1089 : sNativePropertyHooks,
1090 : "[object AudioNodePrototype]",
1091 : EventTargetBinding::GetProtoObject
1092 : };
1093 :
1094 : bool
1095 0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
1096 : {
1097 : static bool sPrefValue;
1098 : static bool sPrefCacheSetUp = false;
1099 0 : if (!sPrefCacheSetUp) {
1100 0 : sPrefCacheSetUp = true;
1101 0 : Preferences::AddBoolVarCache(&sPrefValue, "dom.webaudio.enabled");
1102 : }
1103 :
1104 0 : return sPrefValue;
1105 : }
1106 :
1107 : JSObject*
1108 0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
1109 : {
1110 0 : return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
1111 : }
1112 :
1113 : const NativePropertyHooks sNativePropertyHooks[] = { {
1114 : nullptr,
1115 : nullptr,
1116 : nullptr,
1117 : { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
1118 : prototypes::id::AudioNode,
1119 : constructors::id::AudioNode,
1120 : EventTargetBinding::sNativePropertyHooks,
1121 : &DefaultXrayExpandoObjectClass
1122 : } };
1123 :
1124 : void
1125 0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
1126 : {
1127 0 : JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
1128 0 : if (!parentProto) {
1129 0 : return;
1130 : }
1131 :
1132 0 : JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
1133 0 : if (!constructorProto) {
1134 0 : return;
1135 : }
1136 :
1137 : static bool sIdsInited = false;
1138 0 : if (!sIdsInited && NS_IsMainThread()) {
1139 0 : if (!InitIds(aCx, sNativeProperties.Upcast())) {
1140 0 : return;
1141 : }
1142 0 : if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
1143 0 : return;
1144 : }
1145 0 : sIdsInited = true;
1146 : }
1147 :
1148 0 : JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioNode);
1149 0 : JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AudioNode);
1150 0 : dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
1151 : &sPrototypeClass.mBase, protoCache,
1152 : constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
1153 : interfaceCache,
1154 : sNativeProperties.Upcast(),
1155 0 : nsContentUtils::ThreadsafeIsSystemCaller(aCx) ? sChromeOnlyNativeProperties.Upcast() : nullptr,
1156 : "AudioNode", aDefineOnGlobal,
1157 : nullptr,
1158 0 : false);
1159 : }
1160 :
1161 : JS::Handle<JSObject*>
1162 0 : GetProtoObjectHandle(JSContext* aCx)
1163 : {
1164 : /* Get the interface prototype object for this class. This will create the
1165 : object as needed. */
1166 0 : bool aDefineOnGlobal = true;
1167 :
1168 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1169 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1170 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1171 0 : return nullptr;
1172 : }
1173 :
1174 : /* Check to see whether the interface objects are already installed */
1175 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1176 0 : if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::AudioNode)) {
1177 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1178 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1179 : }
1180 :
1181 : /*
1182 : * The object might _still_ be null, but that's OK.
1183 : *
1184 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1185 : * traced by TraceProtoAndIfaceCache() and its contents are never
1186 : * changed after they have been set.
1187 : *
1188 : * Calling address() avoids the read read barrier that does gray
1189 : * unmarking, but it's not possible for the object to be gray here.
1190 : */
1191 :
1192 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::AudioNode);
1193 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1194 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1195 : }
1196 :
1197 : JSObject*
1198 0 : GetProtoObject(JSContext* aCx)
1199 : {
1200 0 : return GetProtoObjectHandle(aCx);
1201 : }
1202 :
1203 : JS::Handle<JSObject*>
1204 0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
1205 : {
1206 : /* Get the interface object for this class. This will create the object as
1207 : needed. */
1208 :
1209 : /* Make sure our global is sane. Hopefully we can remove this sometime */
1210 0 : JSObject* global = JS::CurrentGlobalOrNull(aCx);
1211 0 : if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
1212 0 : return nullptr;
1213 : }
1214 :
1215 : /* Check to see whether the interface objects are already installed */
1216 0 : ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
1217 0 : if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::AudioNode)) {
1218 0 : JS::Rooted<JSObject*> rootedGlobal(aCx, global);
1219 0 : CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
1220 : }
1221 :
1222 : /*
1223 : * The object might _still_ be null, but that's OK.
1224 : *
1225 : * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
1226 : * traced by TraceProtoAndIfaceCache() and its contents are never
1227 : * changed after they have been set.
1228 : *
1229 : * Calling address() avoids the read read barrier that does gray
1230 : * unmarking, but it's not possible for the object to be gray here.
1231 : */
1232 :
1233 0 : const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::AudioNode);
1234 0 : MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
1235 0 : return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
1236 : }
1237 :
1238 : JSObject*
1239 0 : GetConstructorObject(JSContext* aCx)
1240 : {
1241 0 : return GetConstructorObjectHandle(aCx);
1242 : }
1243 :
1244 : } // namespace AudioNodeBinding
1245 :
1246 :
1247 :
1248 : } // namespace dom
1249 : } // namespace mozilla
|