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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM ChannelSplitterNode.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "AudioNodeBinding.h"
       5             : #include "ChannelSplitterNodeBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/Preferences.h"
       9             : #include "mozilla/dom/AudioContext.h"
      10             : #include "mozilla/dom/BindingUtils.h"
      11             : #include "mozilla/dom/ChannelSplitterNode.h"
      12             : #include "mozilla/dom/DOMJSClass.h"
      13             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      14             : #include "mozilla/dom/PrimitiveConversions.h"
      15             : #include "mozilla/dom/ScriptSettings.h"
      16             : #include "mozilla/dom/SimpleGlobalObject.h"
      17             : #include "mozilla/dom/XrayExpandoClass.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : 
      23           0 : ChannelSplitterOptions::ChannelSplitterOptions()
      24           0 :   : AudioNodeOptions(FastDictionaryInitializer())
      25             : {
      26             :   // Safe to pass a null context if we pass a null value
      27           0 :   Init(nullptr, JS::NullHandleValue);
      28           0 : }
      29             : 
      30             : 
      31             : 
      32             : bool
      33           0 : ChannelSplitterOptions::InitIds(JSContext* cx, ChannelSplitterOptionsAtoms* atomsCache)
      34             : {
      35           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      36             : 
      37             :   // Initialize these in reverse order so that any failure leaves the first one
      38             :   // uninitialized.
      39           0 :   if (!atomsCache->numberOfOutputs_id.init(cx, "numberOfOutputs")) {
      40           0 :     return false;
      41             :   }
      42           0 :   return true;
      43             : }
      44             : 
      45             : bool
      46           0 : ChannelSplitterOptions::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      47             : {
      48             :   // Passing a null JSContext is OK only if we're initing from null,
      49             :   // Since in that case we will not have to do any property gets
      50             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      51             :   // checkers by static analysis tools
      52           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      53           0 :   ChannelSplitterOptionsAtoms* atomsCache = nullptr;
      54           0 :   if (cx) {
      55           0 :     atomsCache = GetAtomCache<ChannelSplitterOptionsAtoms>(cx);
      56           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      57           0 :       return false;
      58             :     }
      59             :   }
      60             : 
      61             :   // Per spec, we init the parent's members first
      62           0 :   if (!AudioNodeOptions::Init(cx, val)) {
      63           0 :     return false;
      64             :   }
      65             : 
      66           0 :   bool isNull = val.isNullOrUndefined();
      67             :   // We only need these if !isNull, in which case we have |cx|.
      68           0 :   Maybe<JS::Rooted<JSObject *> > object;
      69           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      70           0 :   if (!isNull) {
      71           0 :     MOZ_ASSERT(cx);
      72           0 :     object.emplace(cx, &val.toObject());
      73           0 :     temp.emplace(cx);
      74             :   }
      75           0 :   if (!isNull) {
      76           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->numberOfOutputs_id, temp.ptr())) {
      77           0 :       return false;
      78             :     }
      79             :   }
      80           0 :   if (!isNull && !temp->isUndefined()) {
      81           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &mNumberOfOutputs)) {
      82           0 :       return false;
      83             :     }
      84             :   } else {
      85           0 :     mNumberOfOutputs = 6U;
      86             :   }
      87           0 :   mIsAnyMemberPresent = true;
      88           0 :   return true;
      89             : }
      90             : 
      91             : bool
      92           0 : ChannelSplitterOptions::Init(const nsAString& aJSON)
      93             : {
      94           0 :   AutoJSAPI jsapi;
      95           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
      96           0 :   if (!cleanGlobal) {
      97           0 :     return false;
      98             :   }
      99           0 :   if (!jsapi.Init(cleanGlobal)) {
     100           0 :     return false;
     101             :   }
     102           0 :   JSContext* cx = jsapi.cx();
     103           0 :   JS::Rooted<JS::Value> json(cx);
     104           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     105           0 :   NS_ENSURE_TRUE(ok, false);
     106           0 :   return Init(cx, json);
     107             : }
     108             : 
     109             : bool
     110           0 : ChannelSplitterOptions::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     111             : {
     112           0 :   ChannelSplitterOptionsAtoms* atomsCache = GetAtomCache<ChannelSplitterOptionsAtoms>(cx);
     113           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     114           0 :     return false;
     115             :   }
     116             : 
     117             :   // Per spec, we define the parent's members first
     118           0 :   if (!AudioNodeOptions::ToObjectInternal(cx, rval)) {
     119           0 :     return false;
     120             :   }
     121           0 :   JS::Rooted<JSObject*> obj(cx, &rval.toObject());
     122             : 
     123             :   do {
     124             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     125           0 :     JS::Rooted<JS::Value> temp(cx);
     126           0 :     uint32_t const & currentValue = mNumberOfOutputs;
     127           0 :     temp.setNumber(currentValue);
     128           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->numberOfOutputs_id, temp, JSPROP_ENUMERATE)) {
     129           0 :       return false;
     130             :     }
     131           0 :     break;
     132             :   } while(0);
     133             : 
     134           0 :   return true;
     135             : }
     136             : 
     137             : bool
     138           0 : ChannelSplitterOptions::ToJSON(nsAString& aJSON) const
     139             : {
     140           0 :   AutoJSAPI jsapi;
     141           0 :   jsapi.Init();
     142           0 :   JSContext *cx = jsapi.cx();
     143             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     144             :   // because we'll only be creating objects, in ways that have no
     145             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     146             :   // which likewise guarantees no side-effects for the sorts of
     147             :   // things we will pass it.
     148           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     149           0 :   JS::Rooted<JS::Value> val(cx);
     150           0 :   if (!ToObjectInternal(cx, &val)) {
     151           0 :     return false;
     152             :   }
     153           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     154           0 :   return StringifyToJSON(cx, obj, aJSON);
     155             : }
     156             : 
     157             : void
     158           0 : ChannelSplitterOptions::TraceDictionary(JSTracer* trc)
     159             : {
     160           0 :   AudioNodeOptions::TraceDictionary(trc);
     161           0 : }
     162             : 
     163             : ChannelSplitterOptions&
     164           0 : ChannelSplitterOptions::operator=(const ChannelSplitterOptions& aOther)
     165             : {
     166           0 :   AudioNodeOptions::operator=(aOther);
     167           0 :   mNumberOfOutputs = aOther.mNumberOfOutputs;
     168           0 :   return *this;
     169             : }
     170             : 
     171             : namespace binding_detail {
     172             : } // namespace binding_detail
     173             : 
     174             : 
     175             : namespace ChannelSplitterNodeBinding {
     176             : 
     177             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AudioNodeBinding::NativeType>::value,
     178             :               "Can't inherit from an interface with a different ownership model.");
     179             : 
     180             : static bool
     181           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     182             : {
     183           0 :   mozilla::dom::ChannelSplitterNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ChannelSplitterNode>(obj);
     184             :   // We don't want to preserve if we don't have a wrapper, and we
     185             :   // obviously can't preserve if we're not initialized.
     186           0 :   if (self && self->GetWrapperPreserveColor()) {
     187           0 :     PreserveWrapper(self);
     188             :   }
     189           0 :   return true;
     190             : }
     191             : 
     192             : static void
     193           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     194             : {
     195           0 :   mozilla::dom::ChannelSplitterNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ChannelSplitterNode>(obj);
     196           0 :   if (self) {
     197           0 :     ClearWrapper(self, self, obj);
     198           0 :     AddForDeferredFinalization<mozilla::dom::ChannelSplitterNode>(self);
     199             :   }
     200           0 : }
     201             : 
     202             : static void
     203           0 : _objectMoved(JSObject* obj, const JSObject* old)
     204             : {
     205           0 :   mozilla::dom::ChannelSplitterNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::ChannelSplitterNode>(obj);
     206           0 :   if (self) {
     207           0 :     UpdateWrapper(self, self, obj, old);
     208             :   }
     209           0 : }
     210             : 
     211             : static bool
     212           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     213             : {
     214           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     215           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     216           0 :   if (!args.isConstructing()) {
     217             :     // XXXbz wish I could get the name from the callee instead of
     218             :     // Adding more relocations
     219           0 :     return ThrowConstructorWithoutNew(cx, "ChannelSplitterNode");
     220             :   }
     221             : 
     222           0 :   GlobalObject global(cx, obj);
     223           0 :   if (global.Failed()) {
     224           0 :     return false;
     225             :   }
     226             : 
     227           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     228           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     229           0 :     return false;
     230             :   }
     231             : 
     232           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     233           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "ChannelSplitterNode");
     234             :   }
     235           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     236           0 :   NonNull<mozilla::dom::AudioContext> arg0;
     237           0 :   if (args[0].isObject()) {
     238             :     {
     239           0 :       nsresult rv = UnwrapObject<prototypes::id::BaseAudioContext, mozilla::dom::AudioContext>(args[0], arg0);
     240           0 :       if (NS_FAILED(rv)) {
     241           0 :         ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "Argument 1 of ChannelSplitterNode.constructor", "BaseAudioContext");
     242           0 :         return false;
     243             :       }
     244             :     }
     245             :   } else {
     246           0 :     ThrowErrorMessage(cx, MSG_NOT_OBJECT, "Argument 1 of ChannelSplitterNode.constructor");
     247           0 :     return false;
     248             :   }
     249           0 :   binding_detail::FastChannelSplitterOptions arg1;
     250           0 :   if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of ChannelSplitterNode.constructor", false)) {
     251           0 :     return false;
     252             :   }
     253           0 :   Maybe<JSAutoCompartment> ac;
     254           0 :   if (objIsXray) {
     255           0 :     obj = js::CheckedUnwrap(obj);
     256           0 :     if (!obj) {
     257           0 :       return false;
     258             :     }
     259           0 :     ac.emplace(cx, obj);
     260           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     261           0 :       return false;
     262             :     }
     263             :   }
     264           0 :   binding_detail::FastErrorResult rv;
     265           0 :   auto result(StrongOrRawPtr<mozilla::dom::ChannelSplitterNode>(mozilla::dom::ChannelSplitterNode::Constructor(global, NonNullHelper(arg0), Constify(arg1), rv)));
     266           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     267           0 :     return false;
     268             :   }
     269           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     270             :   static_assert(!IsPointer<decltype(result)>::value,
     271             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     272           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     273           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     274           0 :     return false;
     275             :   }
     276           0 :   return true;
     277             : }
     278             : 
     279             : static const js::ClassOps sInterfaceObjectClassOps = {
     280             :     nullptr,               /* addProperty */
     281             :     nullptr,               /* delProperty */
     282             :     nullptr,               /* getProperty */
     283             :     nullptr,               /* setProperty */
     284             :     nullptr,               /* enumerate */
     285             :     nullptr,               /* newEnumerate */
     286             :     nullptr,               /* resolve */
     287             :     nullptr,               /* mayResolve */
     288             :     nullptr,               /* finalize */
     289             :     _constructor, /* call */
     290             :     nullptr,               /* hasInstance */
     291             :     _constructor, /* construct */
     292             :     nullptr,               /* trace */
     293             : };
     294             : 
     295             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     296             :   {
     297             :     "Function",
     298             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     299             :     &sInterfaceObjectClassOps,
     300             :     JS_NULL_CLASS_SPEC,
     301             :     JS_NULL_CLASS_EXT,
     302             :     &sInterfaceObjectClassObjectOps
     303             :   },
     304             :   eInterface,
     305             :   true,
     306             :   prototypes::id::ChannelSplitterNode,
     307             :   PrototypeTraits<prototypes::id::ChannelSplitterNode>::Depth,
     308             :   sNativePropertyHooks,
     309             :   "function ChannelSplitterNode() {\n    [native code]\n}",
     310             :   AudioNodeBinding::GetConstructorObject
     311             : };
     312             : 
     313             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     314             :   {
     315             :     "ChannelSplitterNodePrototype",
     316             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     317             :     JS_NULL_CLASS_OPS,
     318             :     JS_NULL_CLASS_SPEC,
     319             :     JS_NULL_CLASS_EXT,
     320             :     JS_NULL_OBJECT_OPS
     321             :   },
     322             :   eInterfacePrototype,
     323             :   false,
     324             :   prototypes::id::ChannelSplitterNode,
     325             :   PrototypeTraits<prototypes::id::ChannelSplitterNode>::Depth,
     326             :   sNativePropertyHooks,
     327             :   "[object ChannelSplitterNodePrototype]",
     328             :   AudioNodeBinding::GetProtoObject
     329             : };
     330             : 
     331             : bool
     332           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     333             : {
     334             :   static bool sPrefValue;
     335             :   static bool sPrefCacheSetUp = false;
     336           0 :   if (!sPrefCacheSetUp) {
     337           0 :     sPrefCacheSetUp = true;
     338           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.webaudio.enabled");
     339             :   }
     340             : 
     341           0 :   return sPrefValue;
     342             : }
     343             : 
     344             : JSObject*
     345           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     346             : {
     347           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     348             : }
     349             : 
     350             : static const js::ClassOps sClassOps = {
     351             :   _addProperty, /* addProperty */
     352             :   nullptr,               /* delProperty */
     353             :   nullptr,               /* getProperty */
     354             :   nullptr,               /* setProperty */
     355             :   nullptr,               /* enumerate */
     356             :   nullptr, /* newEnumerate */
     357             :   nullptr, /* resolve */
     358             :   nullptr, /* mayResolve */
     359             :   _finalize, /* finalize */
     360             :   nullptr, /* call */
     361             :   nullptr,               /* hasInstance */
     362             :   nullptr,               /* construct */
     363             :   nullptr, /* trace */
     364             : };
     365             : 
     366             : static const js::ClassExtension sClassExtension = {
     367             :   nullptr, /* weakmapKeyDelegateOp */
     368             :   _objectMoved /* objectMovedOp */
     369             : };
     370             : 
     371             : static const DOMJSClass sClass = {
     372             :   { "ChannelSplitterNode",
     373             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     374             :     &sClassOps,
     375             :     JS_NULL_CLASS_SPEC,
     376             :     &sClassExtension,
     377             :     JS_NULL_OBJECT_OPS
     378             :   },
     379             :   { prototypes::id::EventTarget, prototypes::id::AudioNode, prototypes::id::ChannelSplitterNode, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     380             :   IsBaseOf<nsISupports, mozilla::dom::ChannelSplitterNode >::value,
     381             :   sNativePropertyHooks,
     382             :   FindAssociatedGlobalForNative<mozilla::dom::ChannelSplitterNode>::Get,
     383             :   GetProtoObjectHandle,
     384             :   GetCCParticipant<mozilla::dom::ChannelSplitterNode>::Get()
     385             : };
     386             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     387             :               "Must have the right minimal number of reserved slots.");
     388             : static_assert(1 >= 1,
     389             :               "Must have enough reserved slots.");
     390             : 
     391             : const JSClass*
     392           0 : GetJSClass()
     393             : {
     394           0 :   return sClass.ToJSClass();
     395             : }
     396             : 
     397             : bool
     398           0 : Wrap(JSContext* aCx, mozilla::dom::ChannelSplitterNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     399             : {
     400             :   MOZ_ASSERT(static_cast<mozilla::dom::ChannelSplitterNode*>(aObject) ==
     401             :              reinterpret_cast<mozilla::dom::ChannelSplitterNode*>(aObject),
     402             :              "Multiple inheritance for mozilla::dom::ChannelSplitterNode is broken.");
     403             :   MOZ_ASSERT(static_cast<mozilla::dom::AudioNode*>(aObject) ==
     404             :              reinterpret_cast<mozilla::dom::AudioNode*>(aObject),
     405             :              "Multiple inheritance for mozilla::dom::AudioNode is broken.");
     406             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     407             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     408             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     409           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     410           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     411           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     412             :              "You should probably not be using Wrap() directly; use "
     413             :              "GetOrCreateDOMReflector instead");
     414             : 
     415           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     416             :              "nsISupports must be on our primary inheritance chain");
     417             : 
     418           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     419           0 :   if (!global) {
     420           0 :     return false;
     421             :   }
     422           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     423           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     424             : 
     425             :   // That might have ended up wrapping us already, due to the wonders
     426             :   // of XBL.  Check for that, and bail out as needed.
     427           0 :   aReflector.set(aCache->GetWrapper());
     428           0 :   if (aReflector) {
     429             : #ifdef DEBUG
     430           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     431             : #endif // DEBUG
     432           0 :     return true;
     433             :   }
     434             : 
     435           0 :   JSAutoCompartment ac(aCx, global);
     436           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     437           0 :   if (!canonicalProto) {
     438           0 :     return false;
     439             :   }
     440           0 :   JS::Rooted<JSObject*> proto(aCx);
     441           0 :   if (aGivenProto) {
     442           0 :     proto = aGivenProto;
     443             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     444             :     // coming in, we changed compartments to that of "parent" so may need
     445             :     // to wrap the proto here.
     446           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     447           0 :       if (!JS_WrapObject(aCx, &proto)) {
     448           0 :         return false;
     449             :       }
     450             :     }
     451             :   } else {
     452           0 :     proto = canonicalProto;
     453             :   }
     454             : 
     455           0 :   BindingJSObjectCreator<mozilla::dom::ChannelSplitterNode> creator(aCx);
     456           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     457           0 :   if (!aReflector) {
     458           0 :     return false;
     459             :   }
     460             : 
     461           0 :   aCache->SetWrapper(aReflector);
     462           0 :   creator.InitializationSucceeded();
     463             : 
     464           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     465             :              aCache->GetWrapperPreserveColor() == aReflector);
     466             :   // If proto != canonicalProto, we have to preserve our wrapper;
     467             :   // otherwise we won't be able to properly recreate it later, since
     468             :   // we won't know what proto to use.  Note that we don't check
     469             :   // aGivenProto here, since it's entirely possible (and even
     470             :   // somewhat common) to have a non-null aGivenProto which is the
     471             :   // same as canonicalProto.
     472           0 :   if (proto != canonicalProto) {
     473           0 :     PreserveWrapper(aObject);
     474             :   }
     475             : 
     476           0 :   return true;
     477             : }
     478             : 
     479             : const NativePropertyHooks sNativePropertyHooks[] = { {
     480             :   nullptr,
     481             :   nullptr,
     482             :   nullptr,
     483             :   { nullptr, nullptr },
     484             :   prototypes::id::ChannelSplitterNode,
     485             :   constructors::id::ChannelSplitterNode,
     486             :   AudioNodeBinding::sNativePropertyHooks,
     487             :   &DefaultXrayExpandoObjectClass
     488             : } };
     489             : 
     490             : void
     491           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     492             : {
     493           0 :   JS::Handle<JSObject*> parentProto(AudioNodeBinding::GetProtoObjectHandle(aCx));
     494           0 :   if (!parentProto) {
     495           0 :     return;
     496             :   }
     497             : 
     498           0 :   JS::Handle<JSObject*> constructorProto(AudioNodeBinding::GetConstructorObjectHandle(aCx));
     499           0 :   if (!constructorProto) {
     500           0 :     return;
     501             :   }
     502             : 
     503           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::ChannelSplitterNode);
     504           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::ChannelSplitterNode);
     505           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     506             :                               &sPrototypeClass.mBase, protoCache,
     507             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
     508             :                               interfaceCache,
     509             :                               nullptr,
     510             :                               nullptr,
     511             :                               "ChannelSplitterNode", aDefineOnGlobal,
     512             :                               nullptr,
     513           0 :                               false);
     514             : }
     515             : 
     516             : JS::Handle<JSObject*>
     517           0 : GetProtoObjectHandle(JSContext* aCx)
     518             : {
     519             :   /* Get the interface prototype object for this class.  This will create the
     520             :      object as needed. */
     521           0 :   bool aDefineOnGlobal = true;
     522             : 
     523             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     524           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     525           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     526           0 :     return nullptr;
     527             :   }
     528             : 
     529             :   /* Check to see whether the interface objects are already installed */
     530           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     531           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::ChannelSplitterNode)) {
     532           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     533           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     534             :   }
     535             : 
     536             :   /*
     537             :    * The object might _still_ be null, but that's OK.
     538             :    *
     539             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     540             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     541             :    * changed after they have been set.
     542             :    *
     543             :    * Calling address() avoids the read read barrier that does gray
     544             :    * unmarking, but it's not possible for the object to be gray here.
     545             :    */
     546             : 
     547           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::ChannelSplitterNode);
     548           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     549           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     550             : }
     551             : 
     552             : JS::Handle<JSObject*>
     553           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     554             : {
     555             :   /* Get the interface object for this class.  This will create the object as
     556             :      needed. */
     557             : 
     558             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     559           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     560           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     561           0 :     return nullptr;
     562             :   }
     563             : 
     564             :   /* Check to see whether the interface objects are already installed */
     565           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     566           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::ChannelSplitterNode)) {
     567           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     568           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     569             :   }
     570             : 
     571             :   /*
     572             :    * The object might _still_ be null, but that's OK.
     573             :    *
     574             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     575             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     576             :    * changed after they have been set.
     577             :    *
     578             :    * Calling address() avoids the read read barrier that does gray
     579             :    * unmarking, but it's not possible for the object to be gray here.
     580             :    */
     581             : 
     582           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::ChannelSplitterNode);
     583           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     584           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     585             : }
     586             : 
     587             : JSObject*
     588           0 : GetConstructorObject(JSContext* aCx)
     589             : {
     590           0 :   return GetConstructorObjectHandle(aCx);
     591             : }
     592             : 
     593             : } // namespace ChannelSplitterNodeBinding
     594             : 
     595             : 
     596             : 
     597             : } // namespace dom
     598             : } // namespace mozilla

Generated by: LCOV version 1.13