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

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

Generated by: LCOV version 1.13