Coverage Report

Created: 2018-09-25 14:53

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