Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/ConvolverNodeBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM ConvolverNode.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AtomList.h"
4
#include "AudioNodeBinding.h"
5
#include "ConvolverNodeBinding.h"
6
#include "WrapperFactory.h"
7
#include "mozilla/OwningNonNull.h"
8
#include "mozilla/Preferences.h"
9
#include "mozilla/dom/AudioBuffer.h"
10
#include "mozilla/dom/AudioContext.h"
11
#include "mozilla/dom/BindingUtils.h"
12
#include "mozilla/dom/ConvolverNode.h"
13
#include "mozilla/dom/DOMJSClass.h"
14
#include "mozilla/dom/NonRefcountedDOMObject.h"
15
#include "mozilla/dom/Nullable.h"
16
#include "mozilla/dom/PrimitiveConversions.h"
17
#include "mozilla/dom/ScriptSettings.h"
18
#include "mozilla/dom/XrayExpandoClass.h"
19
#include "nsContentUtils.h"
20
21
namespace mozilla {
22
namespace dom {
23
24
namespace binding_detail {}; // Just to make sure it's known as a namespace
25
using namespace mozilla::dom::binding_detail;
26
27
28
29
ConvolverOptions::ConvolverOptions()
30
  : AudioNodeOptions(FastDictionaryInitializer())
31
0
{
32
0
  // Safe to pass a null context if we pass a null value
33
0
  Init(nullptr, JS::NullHandleValue);
34
0
}
35
36
37
38
bool
39
ConvolverOptions::InitIds(JSContext* cx, ConvolverOptionsAtoms* atomsCache)
40
0
{
41
0
  MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
42
0
43
0
  // Initialize these in reverse order so that any failure leaves the first one
44
0
  // uninitialized.
45
0
  if (!atomsCache->disableNormalization_id.init(cx, "disableNormalization") ||
46
0
      !atomsCache->buffer_id.init(cx, "buffer")) {
47
0
    return false;
48
0
  }
49
0
  return true;
50
0
}
51
52
bool
53
ConvolverOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
54
0
{
55
0
  // Passing a null JSContext is OK only if we're initing from null,
56
0
  // Since in that case we will not have to do any property gets
57
0
  // Also evaluate isNullOrUndefined in order to avoid false-positive
58
0
  // checkers by static analysis tools
59
0
  MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
60
0
  ConvolverOptionsAtoms* atomsCache = nullptr;
61
0
  if (cx) {
62
0
    atomsCache = GetAtomCache<ConvolverOptionsAtoms>(cx);
63
0
    if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
64
0
      return false;
65
0
    }
66
0
  }
67
0
68
0
  // Per spec, we init the parent's members first
69
0
  if (!AudioNodeOptions::Init(cx, val)) {
70
0
    return false;
71
0
  }
72
0
73
0
  bool isNull = val.isNullOrUndefined();
74
0
  // We only need these if !isNull, in which case we have |cx|.
75
0
  Maybe<JS::Rooted<JSObject *> > object;
76
0
  Maybe<JS::Rooted<JS::Value> > temp;
77
0
  if (!isNull) {
78
0
    MOZ_ASSERT(cx);
79
0
    object.emplace(cx, &val.toObject());
80
0
    temp.emplace(cx);
81
0
  }
82
0
  if (!isNull) {
83
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->buffer_id, temp.ptr())) {
84
0
      return false;
85
0
    }
86
0
  }
87
0
  if (!isNull && !temp->isUndefined()) {
88
0
    mBuffer.Construct();
89
0
    if (temp.ref().isObject()) {
90
0
      static_assert(IsRefcounted<mozilla::dom::AudioBuffer>::value, "We can only store refcounted classes.");{
91
0
        nsresult rv = UnwrapObject<prototypes::id::AudioBuffer, mozilla::dom::AudioBuffer>(temp.ptr(), (mBuffer.Value()));
92
0
        if (NS_FAILED(rv)) {
93
0
          ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'buffer' member of ConvolverOptions", "AudioBuffer");
94
0
          return false;
95
0
        }
96
0
      }
97
0
    } else if (temp.ref().isNullOrUndefined()) {
98
0
      (mBuffer.Value()) = nullptr;
99
0
    } else {
100
0
      ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'buffer' member of ConvolverOptions");
101
0
      return false;
102
0
    }
103
0
    mIsAnyMemberPresent = true;
104
0
  }
105
0
106
0
  if (!isNull) {
107
0
    if (!JS_GetPropertyById(cx, *object, atomsCache->disableNormalization_id, temp.ptr())) {
108
0
      return false;
109
0
    }
110
0
  }
111
0
  if (!isNull && !temp->isUndefined()) {
112
0
    if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mDisableNormalization)) {
113
0
      return false;
114
0
    }
115
0
  } else {
116
0
    mDisableNormalization = false;
117
0
  }
118
0
  mIsAnyMemberPresent = true;
119
0
  return true;
120
0
}
121
122
bool
123
ConvolverOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
124
0
{
125
0
  ConvolverOptionsAtoms* atomsCache = GetAtomCache<ConvolverOptionsAtoms>(cx);
126
0
  if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
127
0
    return false;
128
0
  }
129
0
130
0
  // Per spec, we define the parent's members first
131
0
  if (!AudioNodeOptions::ToObjectInternal(cx, rval)) {
132
0
    return false;
133
0
  }
134
0
  JS::Rooted<JSObject*> obj(cx, &rval.toObject());
135
0
136
0
  if (mBuffer.WasPassed()) {
137
0
    do {
138
0
      // block for our 'break' successCode and scope for 'temp' and 'currentValue'
139
0
      JS::Rooted<JS::Value> temp(cx);
140
0
      RefPtr<mozilla::dom::AudioBuffer> const & currentValue = mBuffer.InternalValue();
141
0
      if (!currentValue) {
142
0
        temp.setNull();
143
0
        if (!JS_DefinePropertyById(cx, obj, atomsCache->buffer_id, temp, JSPROP_ENUMERATE)) {
144
0
          return false;
145
0
        }
146
0
        break;
147
0
      }
148
0
      if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
149
0
        MOZ_ASSERT(JS_IsExceptionPending(cx));
150
0
        return false;
151
0
      }
152
0
      if (!JS_DefinePropertyById(cx, obj, atomsCache->buffer_id, temp, JSPROP_ENUMERATE)) {
153
0
        return false;
154
0
      }
155
0
      break;
156
0
    } while(false);
157
0
  }
158
0
159
0
  do {
160
0
    // block for our 'break' successCode and scope for 'temp' and 'currentValue'
161
0
    JS::Rooted<JS::Value> temp(cx);
162
0
    bool const & currentValue = mDisableNormalization;
163
0
    temp.setBoolean(currentValue);
164
0
    if (!JS_DefinePropertyById(cx, obj, atomsCache->disableNormalization_id, temp, JSPROP_ENUMERATE)) {
165
0
      return false;
166
0
    }
167
0
    break;
168
0
  } while(false);
169
0
170
0
  return true;
171
0
}
172
173
void
174
ConvolverOptions::TraceDictionary(JSTracer* trc)
175
0
{
176
0
  AudioNodeOptions::TraceDictionary(trc);
177
0
}
178
179
180
181
ConvolverOptions&
182
ConvolverOptions::operator=(const ConvolverOptions& aOther)
183
0
{
184
0
  AudioNodeOptions::operator=(aOther);
185
0
  mBuffer.Reset();
186
0
  if (aOther.mBuffer.WasPassed()) {
187
0
    mBuffer.Construct(aOther.mBuffer.Value());
188
0
  }
189
0
  mDisableNormalization = aOther.mDisableNormalization;
190
0
  return *this;
191
0
}
192
193
namespace binding_detail {
194
} // namespace binding_detail
195
196
197
namespace ConvolverNode_Binding {
198
199
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AudioNode_Binding::NativeType>::value,
200
              "Can't inherit from an interface with a different ownership model.");
201
202
MOZ_CAN_RUN_SCRIPT static bool
203
get_buffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConvolverNode* self, JSJitGetterCallArgs args)
204
0
{
205
0
  AUTO_PROFILER_LABEL_FAST("get ConvolverNode.buffer", DOM, cx);
206
0
207
0
  auto result(StrongOrRawPtr<mozilla::dom::AudioBuffer>(self->GetBuffer(cx)));
208
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
209
0
  if (!result) {
210
0
    args.rval().setNull();
211
0
    return true;
212
0
  }
213
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
214
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
215
0
    return false;
216
0
  }
217
0
  return true;
218
0
}
219
220
MOZ_CAN_RUN_SCRIPT static bool
221
set_buffer(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConvolverNode* self, JSJitSetterCallArgs args)
222
0
{
223
0
  AUTO_PROFILER_LABEL_FAST("set ConvolverNode.buffer", DOM, cx);
224
0
225
0
  mozilla::dom::AudioBuffer* arg0;
226
0
  if (args[0].isObject()) {
227
0
    {
228
0
      nsresult rv = UnwrapObject<prototypes::id::AudioBuffer, mozilla::dom::AudioBuffer>(args[0], arg0);
229
0
      if (NS_FAILED(rv)) {
230
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Value being assigned to ConvolverNode.buffer", "AudioBuffer");
231
0
        return false;
232
0
      }
233
0
    }
234
0
  } else if (args[0].isNullOrUndefined()) {
235
0
    arg0 = nullptr;
236
0
  } else {
237
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Value being assigned to ConvolverNode.buffer");
238
0
    return false;
239
0
  }
240
0
  FastErrorResult rv;
241
0
  self->SetBuffer(cx, MOZ_KnownLive(Constify(arg0)), rv);
242
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
243
0
    return false;
244
0
  }
245
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
246
0
247
0
  return true;
248
0
}
249
250
static const JSJitInfo buffer_getterinfo = {
251
  { (JSJitGetterOp)get_buffer },
252
  { prototypes::id::ConvolverNode },
253
  { PrototypeTraits<prototypes::id::ConvolverNode>::Depth },
254
  JSJitInfo::Getter,
255
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
256
  JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
257
  false,  /* isInfallible. False in setters. */
258
  false,  /* isMovable.  Not relevant for setters. */
259
  false, /* isEliminatable.  Not relevant for setters. */
260
  false, /* isAlwaysInSlot.  Only relevant for getters. */
261
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
262
  false,  /* isTypedMethod.  Only relevant for methods. */
263
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
264
};
265
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
266
static_assert(0 < 1, "There is no slot for us");
267
static const JSJitInfo buffer_setterinfo = {
268
  { (JSJitGetterOp)set_buffer },
269
  { prototypes::id::ConvolverNode },
270
  { PrototypeTraits<prototypes::id::ConvolverNode>::Depth },
271
  JSJitInfo::Setter,
272
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
273
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
274
  false,  /* isInfallible. False in setters. */
275
  false,  /* isMovable.  Not relevant for setters. */
276
  false, /* isEliminatable.  Not relevant for setters. */
277
  false, /* isAlwaysInSlot.  Only relevant for getters. */
278
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
279
  false,  /* isTypedMethod.  Only relevant for methods. */
280
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
281
};
282
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
283
static_assert(0 < 1, "There is no slot for us");
284
285
MOZ_CAN_RUN_SCRIPT static bool
286
get_normalize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConvolverNode* self, JSJitGetterCallArgs args)
287
0
{
288
0
  AUTO_PROFILER_LABEL_FAST("get ConvolverNode.normalize", DOM, cx);
289
0
290
0
  bool result(self->Normalize());
291
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
292
0
  args.rval().setBoolean(result);
293
0
  return true;
294
0
}
295
296
MOZ_CAN_RUN_SCRIPT static bool
297
set_normalize(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConvolverNode* self, JSJitSetterCallArgs args)
298
0
{
299
0
  AUTO_PROFILER_LABEL_FAST("set ConvolverNode.normalize", DOM, cx);
300
0
301
0
  bool arg0;
302
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
303
0
    return false;
304
0
  }
305
0
  self->SetNormalize(arg0);
306
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
307
0
308
0
  return true;
309
0
}
310
311
static const JSJitInfo normalize_getterinfo = {
312
  { (JSJitGetterOp)get_normalize },
313
  { prototypes::id::ConvolverNode },
314
  { PrototypeTraits<prototypes::id::ConvolverNode>::Depth },
315
  JSJitInfo::Getter,
316
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
317
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
318
  true,  /* isInfallible. False in setters. */
319
  false,  /* isMovable.  Not relevant for setters. */
320
  false, /* isEliminatable.  Not relevant for setters. */
321
  false, /* isAlwaysInSlot.  Only relevant for getters. */
322
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
323
  false,  /* isTypedMethod.  Only relevant for methods. */
324
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
325
};
326
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
327
static_assert(0 < 1, "There is no slot for us");
328
static const JSJitInfo normalize_setterinfo = {
329
  { (JSJitGetterOp)set_normalize },
330
  { prototypes::id::ConvolverNode },
331
  { PrototypeTraits<prototypes::id::ConvolverNode>::Depth },
332
  JSJitInfo::Setter,
333
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
334
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
335
  false,  /* isInfallible. False in setters. */
336
  false,  /* isMovable.  Not relevant for setters. */
337
  false, /* isEliminatable.  Not relevant for setters. */
338
  false, /* isAlwaysInSlot.  Only relevant for getters. */
339
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
340
  false,  /* isTypedMethod.  Only relevant for methods. */
341
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
342
};
343
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
344
static_assert(0 < 1, "There is no slot for us");
345
346
MOZ_CAN_RUN_SCRIPT static bool
347
get_passThrough(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConvolverNode* self, JSJitGetterCallArgs args)
348
0
{
349
0
  AUTO_PROFILER_LABEL_FAST("get ConvolverNode.passThrough", DOM, cx);
350
0
351
0
  bool result(self->PassThrough());
352
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
353
0
  args.rval().setBoolean(result);
354
0
  return true;
355
0
}
356
357
MOZ_CAN_RUN_SCRIPT static bool
358
set_passThrough(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::ConvolverNode* self, JSJitSetterCallArgs args)
359
0
{
360
0
  AUTO_PROFILER_LABEL_FAST("set ConvolverNode.passThrough", DOM, cx);
361
0
362
0
  bool arg0;
363
0
  if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
364
0
    return false;
365
0
  }
366
0
  self->SetPassThrough(arg0);
367
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
368
0
369
0
  return true;
370
0
}
371
372
static const JSJitInfo passThrough_getterinfo = {
373
  { (JSJitGetterOp)get_passThrough },
374
  { prototypes::id::ConvolverNode },
375
  { PrototypeTraits<prototypes::id::ConvolverNode>::Depth },
376
  JSJitInfo::Getter,
377
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
378
  JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
379
  true,  /* isInfallible. False in setters. */
380
  false,  /* isMovable.  Not relevant for setters. */
381
  false, /* isEliminatable.  Not relevant for setters. */
382
  false, /* isAlwaysInSlot.  Only relevant for getters. */
383
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
384
  false,  /* isTypedMethod.  Only relevant for methods. */
385
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
386
};
387
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
388
static_assert(0 < 1, "There is no slot for us");
389
static const JSJitInfo passThrough_setterinfo = {
390
  { (JSJitGetterOp)set_passThrough },
391
  { prototypes::id::ConvolverNode },
392
  { PrototypeTraits<prototypes::id::ConvolverNode>::Depth },
393
  JSJitInfo::Setter,
394
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
395
  JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
396
  false,  /* isInfallible. False in setters. */
397
  false,  /* isMovable.  Not relevant for setters. */
398
  false, /* isEliminatable.  Not relevant for setters. */
399
  false, /* isAlwaysInSlot.  Only relevant for getters. */
400
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
401
  false,  /* isTypedMethod.  Only relevant for methods. */
402
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
403
};
404
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
405
static_assert(0 < 1, "There is no slot for us");
406
407
static bool
408
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
409
0
{
410
0
  mozilla::dom::ConvolverNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ConvolverNode>(obj);
411
0
  // We don't want to preserve if we don't have a wrapper, and we
412
0
  // obviously can't preserve if we're not initialized.
413
0
  if (self && self->GetWrapperPreserveColor()) {
414
0
    PreserveWrapper(self);
415
0
  }
416
0
  return true;
417
0
}
418
419
static void
420
_finalize(js::FreeOp* fop, JSObject* obj)
421
0
{
422
0
  mozilla::dom::ConvolverNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ConvolverNode>(obj);
423
0
  if (self) {
424
0
    ClearWrapper(self, self, obj);
425
0
    AddForDeferredFinalization<mozilla::dom::ConvolverNode>(self);
426
0
  }
427
0
}
428
429
static size_t
430
_objectMoved(JSObject* obj, JSObject* old)
431
0
{
432
0
  mozilla::dom::ConvolverNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ConvolverNode>(obj);
433
0
  if (self) {
434
0
    UpdateWrapper(self, self, obj, old);
435
0
  }
436
0
437
0
  return 0;
438
0
}
439
440
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
441
#if defined(__clang__)
442
#pragma clang diagnostic push
443
#pragma clang diagnostic ignored "-Wmissing-braces"
444
#endif
445
static const JSPropertySpec sAttributes_specs[] = {
446
  { "buffer", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &buffer_getterinfo, GenericSetter<NormalThisPolicy>, &buffer_setterinfo },
447
  { "normalize", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &normalize_getterinfo, GenericSetter<NormalThisPolicy>, &normalize_setterinfo },
448
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
449
};
450
#if defined(__clang__)
451
#pragma clang diagnostic pop
452
#endif
453
454
455
static const Prefable<const JSPropertySpec> sAttributes[] = {
456
  { nullptr, &sAttributes_specs[0] },
457
  { nullptr, nullptr }
458
};
459
460
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
461
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
462
static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
463
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
464
465
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
466
#if defined(__clang__)
467
#pragma clang diagnostic push
468
#pragma clang diagnostic ignored "-Wmissing-braces"
469
#endif
470
static const JSPropertySpec sChromeAttributes_specs[] = {
471
  { "passThrough", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &passThrough_getterinfo, GenericSetter<NormalThisPolicy>, &passThrough_setterinfo },
472
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
473
};
474
#if defined(__clang__)
475
#pragma clang diagnostic pop
476
#endif
477
478
479
static const Prefable<const JSPropertySpec> sChromeAttributes[] = {
480
  { nullptr, &sChromeAttributes_specs[0] },
481
  { nullptr, nullptr }
482
};
483
484
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
485
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
486
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
487
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
488
489
490
static uint16_t sNativeProperties_sortedPropertyIndices[2];
491
static PropertyInfo sNativeProperties_propertyInfos[2];
492
493
static const NativePropertiesN<1> sNativeProperties = {
494
  false, 0,
495
  false, 0,
496
  false, 0,
497
  true,  0 /* sAttributes */,
498
  false, 0,
499
  false, 0,
500
  false, 0,
501
  -1,
502
  2,
503
  sNativeProperties_sortedPropertyIndices,
504
  {
505
    { sAttributes, &sNativeProperties_propertyInfos[0] }
506
  }
507
};
508
static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
509
    "We have a property info count that is oversized");
510
511
static uint16_t sChromeOnlyNativeProperties_sortedPropertyIndices[1];
512
static PropertyInfo sChromeOnlyNativeProperties_propertyInfos[1];
513
514
static const NativePropertiesN<1> sChromeOnlyNativeProperties = {
515
  false, 0,
516
  false, 0,
517
  false, 0,
518
  true,  0 /* sChromeAttributes */,
519
  false, 0,
520
  false, 0,
521
  false, 0,
522
  -1,
523
  1,
524
  sChromeOnlyNativeProperties_sortedPropertyIndices,
525
  {
526
    { sChromeAttributes, &sChromeOnlyNativeProperties_propertyInfos[0] }
527
  }
528
};
529
static_assert(1 < 1ull << CHAR_BIT * sizeof(sChromeOnlyNativeProperties.propertyInfoCount),
530
    "We have a property info count that is oversized");
531
532
static bool
533
_constructor(JSContext* cx, unsigned argc, JS::Value* vp)
534
0
{
535
0
  AUTO_PROFILER_LABEL_FAST("ConvolverNode constructor", DOM, cx);
536
0
537
0
  JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
538
0
  JS::Rooted<JSObject*> obj(cx, &args.callee());
539
0
  if (!args.isConstructing()) {
540
0
    // XXXbz wish I could get the name from the callee instead of
541
0
    // Adding more relocations
542
0
    return ThrowConstructorWithoutNew(cx, "ConvolverNode");
543
0
  }
544
0
545
0
  JS::Rooted<JSObject*> desiredProto(cx);
546
0
  if (!GetDesiredProto(cx, args, &desiredProto)) {
547
0
    return false;
548
0
  }
549
0
550
0
  if (MOZ_UNLIKELY(args.length() < 1)) {
551
0
    return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ConvolverNode");
552
0
  }
553
0
  GlobalObject global(cx, obj);
554
0
  if (global.Failed()) {
555
0
    return false;
556
0
  }
557
0
558
0
  bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
559
0
  NonNull<mozilla::dom::AudioContext> arg0;
560
0
  if (args[0].isObject()) {
561
0
    {
562
0
      nsresult rv = UnwrapObject<prototypes::id::BaseAudioContext, mozilla::dom::AudioContext>(args[0], arg0);
563
0
      if (NS_FAILED(rv)) {
564
0
        ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ConvolverNode.constructor", "BaseAudioContext");
565
0
        return false;
566
0
      }
567
0
    }
568
0
  } else {
569
0
    ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of ConvolverNode.constructor");
570
0
    return false;
571
0
  }
572
0
  binding_detail::FastConvolverOptions arg1;
573
0
  if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of ConvolverNode.constructor", false)) {
574
0
    return false;
575
0
  }
576
0
  Maybe<JSAutoRealm> ar;
577
0
  if (objIsXray) {
578
0
    obj = js::CheckedUnwrap(obj);
579
0
    if (!obj) {
580
0
      return false;
581
0
    }
582
0
    ar.emplace(cx, obj);
583
0
    if (!JS_WrapObject(cx, &desiredProto)) {
584
0
      return false;
585
0
    }
586
0
  }
587
0
  FastErrorResult rv;
588
0
  auto result(StrongOrRawPtr<mozilla::dom::ConvolverNode>(mozilla::dom::ConvolverNode::Constructor(global, MOZ_KnownLive(NonNullHelper(arg0)), Constify(arg1), rv)));
589
0
  if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
590
0
    return false;
591
0
  }
592
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
593
0
  static_assert(!IsPointer<decltype(result)>::value,
594
0
                "NewObject implies that we need to keep the object alive with a strong reference.");
595
0
  if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
596
0
    MOZ_ASSERT(JS_IsExceptionPending(cx));
597
0
    return false;
598
0
  }
599
0
  return true;
600
0
}
601
602
static const js::ClassOps sInterfaceObjectClassOps = {
603
    nullptr,               /* addProperty */
604
    nullptr,               /* delProperty */
605
    nullptr,               /* enumerate */
606
    nullptr,               /* newEnumerate */
607
    nullptr,               /* resolve */
608
    nullptr,               /* mayResolve */
609
    nullptr,               /* finalize */
610
    _constructor, /* call */
611
    nullptr,               /* hasInstance */
612
    _constructor, /* construct */
613
    nullptr,               /* trace */
614
};
615
616
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
617
  {
618
    "Function",
619
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
620
    &sInterfaceObjectClassOps,
621
    JS_NULL_CLASS_SPEC,
622
    JS_NULL_CLASS_EXT,
623
    &sInterfaceObjectClassObjectOps
624
  },
625
  eInterface,
626
  true,
627
  prototypes::id::ConvolverNode,
628
  PrototypeTraits<prototypes::id::ConvolverNode>::Depth,
629
  sNativePropertyHooks,
630
  "function ConvolverNode() {\n    [native code]\n}",
631
  AudioNode_Binding::GetConstructorObject
632
};
633
634
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
635
  {
636
    "ConvolverNodePrototype",
637
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
638
    JS_NULL_CLASS_OPS,
639
    JS_NULL_CLASS_SPEC,
640
    JS_NULL_CLASS_EXT,
641
    JS_NULL_OBJECT_OPS
642
  },
643
  eInterfacePrototype,
644
  false,
645
  prototypes::id::ConvolverNode,
646
  PrototypeTraits<prototypes::id::ConvolverNode>::Depth,
647
  sNativePropertyHooks,
648
  "[object ConvolverNodePrototype]",
649
  AudioNode_Binding::GetProtoObject
650
};
651
652
bool
653
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
654
0
{
655
0
  static bool sPrefValue;
656
0
  static bool sPrefCacheSetUp = false;
657
0
  if (!sPrefCacheSetUp) {
658
0
    sPrefCacheSetUp = true;
659
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.webaudio.enabled");
660
0
  }
661
0
662
0
  return sPrefValue;
663
0
}
664
665
static const js::ClassOps sClassOps = {
666
  _addProperty, /* addProperty */
667
  nullptr,               /* delProperty */
668
  nullptr,               /* enumerate */
669
  nullptr, /* newEnumerate */
670
  nullptr, /* resolve */
671
  nullptr, /* mayResolve */
672
  _finalize, /* finalize */
673
  nullptr, /* call */
674
  nullptr,               /* hasInstance */
675
  nullptr,               /* construct */
676
  nullptr, /* trace */
677
};
678
679
static const js::ClassExtension sClassExtension = {
680
  nullptr, /* weakmapKeyDelegateOp */
681
  _objectMoved /* objectMovedOp */
682
};
683
684
static const DOMJSClass sClass = {
685
  { "ConvolverNode",
686
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
687
    &sClassOps,
688
    JS_NULL_CLASS_SPEC,
689
    &sClassExtension,
690
    JS_NULL_OBJECT_OPS
691
  },
692
  { prototypes::id::EventTarget, prototypes::id::AudioNode, prototypes::id::ConvolverNode, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
693
  IsBaseOf<nsISupports, mozilla::dom::ConvolverNode >::value,
694
  sNativePropertyHooks,
695
  FindAssociatedGlobalForNative<mozilla::dom::ConvolverNode>::Get,
696
  GetProtoObjectHandle,
697
  GetCCParticipant<mozilla::dom::ConvolverNode>::Get()
698
};
699
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
700
              "Must have the right minimal number of reserved slots.");
701
static_assert(1 >= 1,
702
              "Must have enough reserved slots.");
703
704
const JSClass*
705
GetJSClass()
706
0
{
707
0
  return sClass.ToJSClass();
708
0
}
709
710
bool
711
Wrap(JSContext* aCx, mozilla::dom::ConvolverNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
712
0
{
713
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::ConvolverNode>::value,
714
0
                "Shouldn't have wrappercached things that are not refcounted.");
715
0
  MOZ_ASSERT(static_cast<mozilla::dom::ConvolverNode*>(aObject) ==
716
0
             reinterpret_cast<mozilla::dom::ConvolverNode*>(aObject),
717
0
             "Multiple inheritance for mozilla::dom::ConvolverNode is broken.");
718
0
  MOZ_ASSERT(static_cast<mozilla::dom::AudioNode*>(aObject) ==
719
0
             reinterpret_cast<mozilla::dom::AudioNode*>(aObject),
720
0
             "Multiple inheritance for mozilla::dom::AudioNode is broken.");
721
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
722
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
723
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
724
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
725
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
726
0
  MOZ_ASSERT(!aCache->GetWrapper(),
727
0
             "You should probably not be using Wrap() directly; use "
728
0
             "GetOrCreateDOMReflector instead");
729
0
730
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
731
0
             "nsISupports must be on our primary inheritance chain");
732
0
733
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
734
0
  if (!global) {
735
0
    return false;
736
0
  }
737
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
738
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
739
0
740
0
  // That might have ended up wrapping us already, due to the wonders
741
0
  // of XBL.  Check for that, and bail out as needed.
742
0
  aReflector.set(aCache->GetWrapper());
743
0
  if (aReflector) {
744
#ifdef DEBUG
745
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
746
#endif // DEBUG
747
    return true;
748
0
  }
749
0
750
0
  JSAutoRealm ar(aCx, global);
751
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
752
0
  if (!canonicalProto) {
753
0
    return false;
754
0
  }
755
0
  JS::Rooted<JSObject*> proto(aCx);
756
0
  if (aGivenProto) {
757
0
    proto = aGivenProto;
758
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
759
0
    // coming in, we changed compartments to that of "parent" so may need
760
0
    // to wrap the proto here.
761
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
762
0
      if (!JS_WrapObject(aCx, &proto)) {
763
0
        return false;
764
0
      }
765
0
    }
766
0
  } else {
767
0
    proto = canonicalProto;
768
0
  }
769
0
770
0
  BindingJSObjectCreator<mozilla::dom::ConvolverNode> creator(aCx);
771
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
772
0
  if (!aReflector) {
773
0
    return false;
774
0
  }
775
0
776
0
  aCache->SetWrapper(aReflector);
777
0
  creator.InitializationSucceeded();
778
0
779
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
780
0
             aCache->GetWrapperPreserveColor() == aReflector);
781
0
  // If proto != canonicalProto, we have to preserve our wrapper;
782
0
  // otherwise we won't be able to properly recreate it later, since
783
0
  // we won't know what proto to use.  Note that we don't check
784
0
  // aGivenProto here, since it's entirely possible (and even
785
0
  // somewhat common) to have a non-null aGivenProto which is the
786
0
  // same as canonicalProto.
787
0
  if (proto != canonicalProto) {
788
0
    PreserveWrapper(aObject);
789
0
  }
790
0
791
0
  return true;
792
0
}
793
794
const NativePropertyHooks sNativePropertyHooks[] = { {
795
  nullptr,
796
  nullptr,
797
  nullptr,
798
  { sNativeProperties.Upcast(), sChromeOnlyNativeProperties.Upcast() },
799
  prototypes::id::ConvolverNode,
800
  constructors::id::ConvolverNode,
801
  AudioNode_Binding::sNativePropertyHooks,
802
  &DefaultXrayExpandoObjectClass
803
} };
804
805
void
806
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
807
0
{
808
0
  JS::Handle<JSObject*> parentProto(AudioNode_Binding::GetProtoObjectHandle(aCx));
809
0
  if (!parentProto) {
810
0
    return;
811
0
  }
812
0
813
0
  JS::Handle<JSObject*> constructorProto(AudioNode_Binding::GetConstructorObjectHandle(aCx));
814
0
  if (!constructorProto) {
815
0
    return;
816
0
  }
817
0
818
0
  static bool sIdsInited = false;
819
0
  if (!sIdsInited && NS_IsMainThread()) {
820
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
821
0
      return;
822
0
    }
823
0
    if (!InitIds(aCx, sChromeOnlyNativeProperties.Upcast())) {
824
0
      return;
825
0
    }
826
0
    sIdsInited = true;
827
0
  }
828
0
829
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ConvolverNode);
830
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ConvolverNode);
831
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
832
0
                              &sPrototypeClass.mBase, protoCache,
833
0
                              nullptr,
834
0
                              constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
835
0
                              interfaceCache,
836
0
                              sNativeProperties.Upcast(),
837
0
                              sChromeOnlyNativeProperties.Upcast(),
838
0
                              "ConvolverNode", aDefineOnGlobal,
839
0
                              nullptr,
840
0
                              false);
841
0
}
842
843
JSObject*
844
GetConstructorObject(JSContext* aCx)
845
0
{
846
0
  return GetConstructorObjectHandle(aCx);
847
0
}
848
849
} // namespace ConvolverNode_Binding
850
851
852
853
} // namespace dom
854
} // namespace mozilla