LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - BiquadFilterNodeBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 391 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 30 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13