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

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

Generated by: LCOV version 1.13