Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dom/bindings/AudioDestinationNodeBinding.cpp
Line
Count
Source (jump to first uncovered line)
1
/* THIS FILE IS AUTOGENERATED FROM AudioDestinationNode.webidl BY Codegen.py - DO NOT EDIT */
2
3
#include "AudioDestinationNodeBinding.h"
4
#include "AudioNodeBinding.h"
5
#include "WrapperFactory.h"
6
#include "mozilla/OwningNonNull.h"
7
#include "mozilla/Preferences.h"
8
#include "mozilla/dom/AudioDestinationNode.h"
9
#include "mozilla/dom/BindingUtils.h"
10
#include "mozilla/dom/DOMJSClass.h"
11
#include "mozilla/dom/NonRefcountedDOMObject.h"
12
#include "mozilla/dom/PrimitiveConversions.h"
13
#include "mozilla/dom/XrayExpandoClass.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
namespace binding_detail {}; // Just to make sure it's known as a namespace
19
using namespace mozilla::dom::binding_detail;
20
21
22
namespace AudioDestinationNode_Binding {
23
24
static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AudioNode_Binding::NativeType>::value,
25
              "Can't inherit from an interface with a different ownership model.");
26
27
MOZ_CAN_RUN_SCRIPT static bool
28
get_maxChannelCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioDestinationNode* self, JSJitGetterCallArgs args)
29
0
{
30
0
  AUTO_PROFILER_LABEL_FAST("get AudioDestinationNode.maxChannelCount", DOM, cx);
31
0
32
0
  uint32_t result(self->MaxChannelCount());
33
0
  MOZ_ASSERT(!JS_IsExceptionPending(cx));
34
0
  args.rval().setNumber(result);
35
0
  return true;
36
0
}
37
38
static const JSJitInfo maxChannelCount_getterinfo = {
39
  { (JSJitGetterOp)get_maxChannelCount },
40
  { prototypes::id::AudioDestinationNode },
41
  { PrototypeTraits<prototypes::id::AudioDestinationNode>::Depth },
42
  JSJitInfo::Getter,
43
  JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
44
  JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
45
  true,  /* isInfallible. False in setters. */
46
  false,  /* isMovable.  Not relevant for setters. */
47
  false, /* isEliminatable.  Not relevant for setters. */
48
  false, /* isAlwaysInSlot.  Only relevant for getters. */
49
  false, /* isLazilyCachedInSlot.  Only relevant for getters. */
50
  false,  /* isTypedMethod.  Only relevant for methods. */
51
  0   /* Reserved slot index, if we're stored in a slot, else 0. */
52
};
53
static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
54
static_assert(0 < 1, "There is no slot for us");
55
56
static bool
57
_addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
58
0
{
59
0
  mozilla::dom::AudioDestinationNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioDestinationNode>(obj);
60
0
  // We don't want to preserve if we don't have a wrapper, and we
61
0
  // obviously can't preserve if we're not initialized.
62
0
  if (self && self->GetWrapperPreserveColor()) {
63
0
    PreserveWrapper(self);
64
0
  }
65
0
  return true;
66
0
}
67
68
static void
69
_finalize(js::FreeOp* fop, JSObject* obj)
70
0
{
71
0
  mozilla::dom::AudioDestinationNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioDestinationNode>(obj);
72
0
  if (self) {
73
0
    ClearWrapper(self, self, obj);
74
0
    AddForDeferredFinalization<mozilla::dom::AudioDestinationNode>(self);
75
0
  }
76
0
}
77
78
static size_t
79
_objectMoved(JSObject* obj, JSObject* old)
80
0
{
81
0
  mozilla::dom::AudioDestinationNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioDestinationNode>(obj);
82
0
  if (self) {
83
0
    UpdateWrapper(self, self, obj, old);
84
0
  }
85
0
86
0
  return 0;
87
0
}
88
89
// We deliberately use brace-elision to make Visual Studio produce better initalization code.
90
#if defined(__clang__)
91
#pragma clang diagnostic push
92
#pragma clang diagnostic ignored "-Wmissing-braces"
93
#endif
94
static const JSPropertySpec sAttributes_specs[] = {
95
  { "maxChannelCount", JSPROP_ENUMERATE, GenericGetter<NormalThisPolicy, ThrowExceptions>, &maxChannelCount_getterinfo, nullptr, nullptr },
96
  { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
97
};
98
#if defined(__clang__)
99
#pragma clang diagnostic pop
100
#endif
101
102
103
static const Prefable<const JSPropertySpec> sAttributes[] = {
104
  { nullptr, &sAttributes_specs[0] },
105
  { nullptr, nullptr }
106
};
107
108
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
109
    "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
110
static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
111
    "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
112
113
114
static uint16_t sNativeProperties_sortedPropertyIndices[1];
115
static PropertyInfo sNativeProperties_propertyInfos[1];
116
117
static const NativePropertiesN<1> sNativeProperties = {
118
  false, 0,
119
  false, 0,
120
  false, 0,
121
  true,  0 /* sAttributes */,
122
  false, 0,
123
  false, 0,
124
  false, 0,
125
  -1,
126
  1,
127
  sNativeProperties_sortedPropertyIndices,
128
  {
129
    { sAttributes, &sNativeProperties_propertyInfos[0] }
130
  }
131
};
132
static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
133
    "We have a property info count that is oversized");
134
135
static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
136
  {
137
    "Function",
138
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
139
    &sBoringInterfaceObjectClassClassOps,
140
    JS_NULL_CLASS_SPEC,
141
    JS_NULL_CLASS_EXT,
142
    &sInterfaceObjectClassObjectOps
143
  },
144
  eInterface,
145
  true,
146
  prototypes::id::AudioDestinationNode,
147
  PrototypeTraits<prototypes::id::AudioDestinationNode>::Depth,
148
  sNativePropertyHooks,
149
  "function AudioDestinationNode() {\n    [native code]\n}",
150
  AudioNode_Binding::GetConstructorObject
151
};
152
153
static const DOMIfaceAndProtoJSClass sPrototypeClass = {
154
  {
155
    "AudioDestinationNodePrototype",
156
    JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
157
    JS_NULL_CLASS_OPS,
158
    JS_NULL_CLASS_SPEC,
159
    JS_NULL_CLASS_EXT,
160
    JS_NULL_OBJECT_OPS
161
  },
162
  eInterfacePrototype,
163
  false,
164
  prototypes::id::AudioDestinationNode,
165
  PrototypeTraits<prototypes::id::AudioDestinationNode>::Depth,
166
  sNativePropertyHooks,
167
  "[object AudioDestinationNodePrototype]",
168
  AudioNode_Binding::GetProtoObject
169
};
170
171
bool
172
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
173
0
{
174
0
  static bool sPrefValue;
175
0
  static bool sPrefCacheSetUp = false;
176
0
  if (!sPrefCacheSetUp) {
177
0
    sPrefCacheSetUp = true;
178
0
    Preferences::AddBoolVarCache(&sPrefValue, "dom.webaudio.enabled");
179
0
  }
180
0
181
0
  return sPrefValue;
182
0
}
183
184
static const js::ClassOps sClassOps = {
185
  _addProperty, /* addProperty */
186
  nullptr,               /* delProperty */
187
  nullptr,               /* enumerate */
188
  nullptr, /* newEnumerate */
189
  nullptr, /* resolve */
190
  nullptr, /* mayResolve */
191
  _finalize, /* finalize */
192
  nullptr, /* call */
193
  nullptr,               /* hasInstance */
194
  nullptr,               /* construct */
195
  nullptr, /* trace */
196
};
197
198
static const js::ClassExtension sClassExtension = {
199
  nullptr, /* weakmapKeyDelegateOp */
200
  _objectMoved /* objectMovedOp */
201
};
202
203
static const DOMJSClass sClass = {
204
  { "AudioDestinationNode",
205
    JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
206
    &sClassOps,
207
    JS_NULL_CLASS_SPEC,
208
    &sClassExtension,
209
    JS_NULL_OBJECT_OPS
210
  },
211
  { prototypes::id::EventTarget, prototypes::id::AudioNode, prototypes::id::AudioDestinationNode, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
212
  IsBaseOf<nsISupports, mozilla::dom::AudioDestinationNode >::value,
213
  sNativePropertyHooks,
214
  FindAssociatedGlobalForNative<mozilla::dom::AudioDestinationNode>::Get,
215
  GetProtoObjectHandle,
216
  GetCCParticipant<mozilla::dom::AudioDestinationNode>::Get()
217
};
218
static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
219
              "Must have the right minimal number of reserved slots.");
220
static_assert(1 >= 1,
221
              "Must have enough reserved slots.");
222
223
const JSClass*
224
GetJSClass()
225
0
{
226
0
  return sClass.ToJSClass();
227
0
}
228
229
bool
230
Wrap(JSContext* aCx, mozilla::dom::AudioDestinationNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
231
0
{
232
0
  static_assert(!IsBaseOf<NonRefcountedDOMObject, mozilla::dom::AudioDestinationNode>::value,
233
0
                "Shouldn't have wrappercached things that are not refcounted.");
234
0
  MOZ_ASSERT(static_cast<mozilla::dom::AudioDestinationNode*>(aObject) ==
235
0
             reinterpret_cast<mozilla::dom::AudioDestinationNode*>(aObject),
236
0
             "Multiple inheritance for mozilla::dom::AudioDestinationNode is broken.");
237
0
  MOZ_ASSERT(static_cast<mozilla::dom::AudioNode*>(aObject) ==
238
0
             reinterpret_cast<mozilla::dom::AudioNode*>(aObject),
239
0
             "Multiple inheritance for mozilla::dom::AudioNode is broken.");
240
0
  MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
241
0
             reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
242
0
             "Multiple inheritance for mozilla::dom::EventTarget is broken.");
243
0
  MOZ_ASSERT(ToSupportsIsCorrect(aObject));
244
0
  MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
245
0
  MOZ_ASSERT(!aCache->GetWrapper(),
246
0
             "You should probably not be using Wrap() directly; use "
247
0
             "GetOrCreateDOMReflector instead");
248
0
249
0
  MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
250
0
             "nsISupports must be on our primary inheritance chain");
251
0
252
0
  JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
253
0
  if (!global) {
254
0
    return false;
255
0
  }
256
0
  MOZ_ASSERT(JS_IsGlobalObject(global));
257
0
  MOZ_ASSERT(JS::ObjectIsNotGray(global));
258
0
259
0
  // That might have ended up wrapping us already, due to the wonders
260
0
  // of XBL.  Check for that, and bail out as needed.
261
0
  aReflector.set(aCache->GetWrapper());
262
0
  if (aReflector) {
263
#ifdef DEBUG
264
    AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
265
#endif // DEBUG
266
    return true;
267
0
  }
268
0
269
0
  JSAutoRealm ar(aCx, global);
270
0
  JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
271
0
  if (!canonicalProto) {
272
0
    return false;
273
0
  }
274
0
  JS::Rooted<JSObject*> proto(aCx);
275
0
  if (aGivenProto) {
276
0
    proto = aGivenProto;
277
0
    // Unfortunately, while aGivenProto was in the compartment of aCx
278
0
    // coming in, we changed compartments to that of "parent" so may need
279
0
    // to wrap the proto here.
280
0
    if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
281
0
      if (!JS_WrapObject(aCx, &proto)) {
282
0
        return false;
283
0
      }
284
0
    }
285
0
  } else {
286
0
    proto = canonicalProto;
287
0
  }
288
0
289
0
  BindingJSObjectCreator<mozilla::dom::AudioDestinationNode> creator(aCx);
290
0
  creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
291
0
  if (!aReflector) {
292
0
    return false;
293
0
  }
294
0
295
0
  aCache->SetWrapper(aReflector);
296
0
  creator.InitializationSucceeded();
297
0
298
0
  MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
299
0
             aCache->GetWrapperPreserveColor() == aReflector);
300
0
  // If proto != canonicalProto, we have to preserve our wrapper;
301
0
  // otherwise we won't be able to properly recreate it later, since
302
0
  // we won't know what proto to use.  Note that we don't check
303
0
  // aGivenProto here, since it's entirely possible (and even
304
0
  // somewhat common) to have a non-null aGivenProto which is the
305
0
  // same as canonicalProto.
306
0
  if (proto != canonicalProto) {
307
0
    PreserveWrapper(aObject);
308
0
  }
309
0
310
0
  return true;
311
0
}
312
313
const NativePropertyHooks sNativePropertyHooks[] = { {
314
  nullptr,
315
  nullptr,
316
  nullptr,
317
  { sNativeProperties.Upcast(), nullptr },
318
  prototypes::id::AudioDestinationNode,
319
  constructors::id::AudioDestinationNode,
320
  AudioNode_Binding::sNativePropertyHooks,
321
  &DefaultXrayExpandoObjectClass
322
} };
323
324
void
325
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
326
0
{
327
0
  JS::Handle<JSObject*> parentProto(AudioNode_Binding::GetProtoObjectHandle(aCx));
328
0
  if (!parentProto) {
329
0
    return;
330
0
  }
331
0
332
0
  JS::Handle<JSObject*> constructorProto(AudioNode_Binding::GetConstructorObjectHandle(aCx));
333
0
  if (!constructorProto) {
334
0
    return;
335
0
  }
336
0
337
0
  static bool sIdsInited = false;
338
0
  if (!sIdsInited && NS_IsMainThread()) {
339
0
    if (!InitIds(aCx, sNativeProperties.Upcast())) {
340
0
      return;
341
0
    }
342
0
    sIdsInited = true;
343
0
  }
344
0
345
0
  JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioDestinationNode);
346
0
  JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AudioDestinationNode);
347
0
  dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
348
0
                              &sPrototypeClass.mBase, protoCache,
349
0
                              nullptr,
350
0
                              constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
351
0
                              interfaceCache,
352
0
                              sNativeProperties.Upcast(),
353
0
                              nullptr,
354
0
                              "AudioDestinationNode", aDefineOnGlobal,
355
0
                              nullptr,
356
0
                              false);
357
0
}
358
359
JSObject*
360
GetConstructorObject(JSContext* aCx)
361
0
{
362
0
  return GetConstructorObjectHandle(aCx);
363
0
}
364
365
} // namespace AudioDestinationNode_Binding
366
367
368
369
} // namespace dom
370
} // namespace mozilla