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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM AudioScheduledSourceNode.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AudioNodeBinding.h"
       4             : #include "AudioScheduledSourceNodeBinding.h"
       5             : #include "EventHandlerBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/FloatingPoint.h"
       8             : #include "mozilla/OwningNonNull.h"
       9             : #include "mozilla/dom/AudioScheduledSourceNode.h"
      10             : #include "mozilla/dom/BindingUtils.h"
      11             : #include "mozilla/dom/DOMJSClass.h"
      12             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      13             : #include "mozilla/dom/Nullable.h"
      14             : #include "mozilla/dom/PrimitiveConversions.h"
      15             : #include "mozilla/dom/XrayExpandoClass.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : namespace AudioScheduledSourceNodeBinding {
      21             : 
      22             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AudioNodeBinding::NativeType>::value,
      23             :               "Can't inherit from an interface with a different ownership model.");
      24             : 
      25             : static bool
      26           0 : get_onended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioScheduledSourceNode* self, JSJitGetterCallArgs args)
      27             : {
      28           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnended());
      29           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      30           0 :   if (result) {
      31           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
      32           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
      33           0 :       return false;
      34             :     }
      35           0 :     return true;
      36             :   } else {
      37           0 :     args.rval().setNull();
      38           0 :     return true;
      39             :   }
      40             : }
      41             : 
      42             : static bool
      43           0 : set_onended(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioScheduledSourceNode* self, JSJitSetterCallArgs args)
      44             : {
      45           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
      46           0 :   if (args[0].isObject()) {
      47             :     { // scope for tempRoot
      48           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
      49           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
      50             :     }
      51             :   } else {
      52           0 :     arg0 = nullptr;
      53             :   }
      54           0 :   self->SetOnended(Constify(arg0));
      55           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      56             : 
      57           0 :   return true;
      58             : }
      59             : 
      60             : static const JSJitInfo onended_getterinfo = {
      61             :   { (JSJitGetterOp)get_onended },
      62             :   { prototypes::id::AudioScheduledSourceNode },
      63             :   { PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth },
      64             :   JSJitInfo::Getter,
      65             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      66             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
      67             :   false,  /* isInfallible. False in setters. */
      68             :   false,  /* isMovable.  Not relevant for setters. */
      69             :   false, /* isEliminatable.  Not relevant for setters. */
      70             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      71             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      72             :   false,  /* isTypedMethod.  Only relevant for methods. */
      73             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      74             : };
      75             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      76             : static_assert(0 < 1, "There is no slot for us");
      77             : static const JSJitInfo onended_setterinfo = {
      78             :   { (JSJitGetterOp)set_onended },
      79             :   { prototypes::id::AudioScheduledSourceNode },
      80             :   { PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth },
      81             :   JSJitInfo::Setter,
      82             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      83             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
      84             :   false,  /* isInfallible. False in setters. */
      85             :   false,  /* isMovable.  Not relevant for setters. */
      86             :   false, /* isEliminatable.  Not relevant for setters. */
      87             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      88             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      89             :   false,  /* isTypedMethod.  Only relevant for methods. */
      90             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      91             : };
      92             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      93             : static_assert(0 < 1, "There is no slot for us");
      94             : 
      95             : static bool
      96           0 : start(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioScheduledSourceNode* self, const JSJitMethodCallArgs& args)
      97             : {
      98           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
      99             :       // Return false from the JSNative in order to trigger
     100             :       // an uncatchable exception.
     101           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     102           0 :       return false;
     103             :   }
     104             :   double arg0;
     105           0 :   if (args.hasDefined(0)) {
     106           0 :     if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
     107           0 :       return false;
     108           0 :     } else if (!mozilla::IsFinite(arg0)) {
     109           0 :       ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of AudioScheduledSourceNode.start");
     110           0 :       return false;
     111             :     }
     112             :   } else {
     113           0 :     arg0 = 0.0;
     114             :   }
     115           0 :   binding_detail::FastErrorResult rv;
     116           0 :   self->Start(arg0, rv);
     117           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     118           0 :     return false;
     119             :   }
     120           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     121           0 :   args.rval().setUndefined();
     122           0 :   return true;
     123             : }
     124             : 
     125             : static const JSJitInfo start_methodinfo = {
     126             :   { (JSJitGetterOp)start },
     127             :   { prototypes::id::AudioScheduledSourceNode },
     128             :   { PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth },
     129             :   JSJitInfo::Method,
     130             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     131             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     132             :   false,  /* isInfallible. False in setters. */
     133             :   false,  /* isMovable.  Not relevant for setters. */
     134             :   false, /* isEliminatable.  Not relevant for setters. */
     135             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     136             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     137             :   false,  /* isTypedMethod.  Only relevant for methods. */
     138             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     139             : };
     140             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     141             : static_assert(0 < 1, "There is no slot for us");
     142             : 
     143             : static bool
     144           0 : stop(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioScheduledSourceNode* self, const JSJitMethodCallArgs& args)
     145             : {
     146           0 :   if (!mozilla::dom::EnforceNotInPrerendering(cx, obj)) {
     147             :       // Return false from the JSNative in order to trigger
     148             :       // an uncatchable exception.
     149           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     150           0 :       return false;
     151             :   }
     152             :   double arg0;
     153           0 :   if (args.hasDefined(0)) {
     154           0 :     if (!ValueToPrimitive<double, eDefault>(cx, args[0], &arg0)) {
     155           0 :       return false;
     156           0 :     } else if (!mozilla::IsFinite(arg0)) {
     157           0 :       ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 1 of AudioScheduledSourceNode.stop");
     158           0 :       return false;
     159             :     }
     160             :   } else {
     161           0 :     arg0 = 0.0;
     162             :   }
     163           0 :   binding_detail::FastErrorResult rv;
     164           0 :   self->Stop(arg0, rv);
     165           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     166           0 :     return false;
     167             :   }
     168           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     169           0 :   args.rval().setUndefined();
     170           0 :   return true;
     171             : }
     172             : 
     173             : static const JSJitInfo stop_methodinfo = {
     174             :   { (JSJitGetterOp)stop },
     175             :   { prototypes::id::AudioScheduledSourceNode },
     176             :   { PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth },
     177             :   JSJitInfo::Method,
     178             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     179             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     180             :   false,  /* isInfallible. False in setters. */
     181             :   false,  /* isMovable.  Not relevant for setters. */
     182             :   false, /* isEliminatable.  Not relevant for setters. */
     183             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     184             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     185             :   false,  /* isTypedMethod.  Only relevant for methods. */
     186             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     187             : };
     188             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     189             : static_assert(0 < 1, "There is no slot for us");
     190             : 
     191             : static bool
     192           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     193             : {
     194           0 :   mozilla::dom::AudioScheduledSourceNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioScheduledSourceNode>(obj);
     195             :   // We don't want to preserve if we don't have a wrapper, and we
     196             :   // obviously can't preserve if we're not initialized.
     197           0 :   if (self && self->GetWrapperPreserveColor()) {
     198           0 :     PreserveWrapper(self);
     199             :   }
     200           0 :   return true;
     201             : }
     202             : 
     203             : static void
     204           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     205             : {
     206           0 :   mozilla::dom::AudioScheduledSourceNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioScheduledSourceNode>(obj);
     207           0 :   if (self) {
     208           0 :     ClearWrapper(self, self, obj);
     209           0 :     AddForDeferredFinalization<mozilla::dom::AudioScheduledSourceNode>(self);
     210             :   }
     211           0 : }
     212             : 
     213             : static void
     214           0 : _objectMoved(JSObject* obj, const JSObject* old)
     215             : {
     216           0 :   mozilla::dom::AudioScheduledSourceNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioScheduledSourceNode>(obj);
     217           0 :   if (self) {
     218           0 :     UpdateWrapper(self, self, obj, old);
     219             :   }
     220           0 : }
     221             : 
     222             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     223             : #if defined(__clang__)
     224             : #pragma clang diagnostic push
     225             : #pragma clang diagnostic ignored "-Wmissing-braces"
     226             : #endif
     227             : static const JSFunctionSpec sMethods_specs[] = {
     228             :   JS_FNSPEC("start", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&start_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     229             :   JS_FNSPEC("stop", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&stop_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     230             :   JS_FS_END
     231             : };
     232             : #if defined(__clang__)
     233             : #pragma clang diagnostic pop
     234             : #endif
     235             : 
     236             : 
     237             : // Can't be const because the pref-enabled boolean needs to be writable
     238             : static Prefable<const JSFunctionSpec> sMethods[] = {
     239             :   { nullptr, &sMethods_specs[0] },
     240             :   { nullptr, nullptr }
     241             : };
     242             : 
     243             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     244             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     245             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     246             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     247             : 
     248             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     249             : #if defined(__clang__)
     250             : #pragma clang diagnostic push
     251             : #pragma clang diagnostic ignored "-Wmissing-braces"
     252             : #endif
     253             : static const JSPropertySpec sAttributes_specs[] = {
     254             :   { "onended", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onended_getterinfo, GenericBindingSetter, &onended_setterinfo },
     255             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     256             : };
     257             : #if defined(__clang__)
     258             : #pragma clang diagnostic pop
     259             : #endif
     260             : 
     261             : 
     262             : // Can't be const because the pref-enabled boolean needs to be writable
     263             : static Prefable<const JSPropertySpec> sAttributes[] = {
     264             :   { nullptr, &sAttributes_specs[0] },
     265             :   { nullptr, nullptr }
     266             : };
     267             : 
     268             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     269             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     270             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     271             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     272             : 
     273             : 
     274             : static uint16_t sNativeProperties_sortedPropertyIndices[3];
     275             : static PropertyInfo sNativeProperties_propertyInfos[3];
     276             : 
     277             : static const NativePropertiesN<2> sNativeProperties = {
     278             :   false, 0,
     279             :   false, 0,
     280             :   true,  0 /* sMethods */,
     281             :   true,  1 /* sAttributes */,
     282             :   false, 0,
     283             :   false, 0,
     284             :   false, 0,
     285             :   -1,
     286             :   3,
     287             :   sNativeProperties_sortedPropertyIndices,
     288             :   {
     289             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     290             :     { sAttributes, &sNativeProperties_propertyInfos[2] }
     291             :   }
     292             : };
     293             : static_assert(3 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     294             :     "We have a property info count that is oversized");
     295             : 
     296             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     297             :   {
     298             :     "Function",
     299             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     300             :     &sBoringInterfaceObjectClassClassOps,
     301             :     JS_NULL_CLASS_SPEC,
     302             :     JS_NULL_CLASS_EXT,
     303             :     &sInterfaceObjectClassObjectOps
     304             :   },
     305             :   eInterface,
     306             :   true,
     307             :   prototypes::id::AudioScheduledSourceNode,
     308             :   PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth,
     309             :   sNativePropertyHooks,
     310             :   "function AudioScheduledSourceNode() {\n    [native code]\n}",
     311             :   AudioNodeBinding::GetConstructorObject
     312             : };
     313             : 
     314             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     315             :   {
     316             :     "AudioScheduledSourceNodePrototype",
     317             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     318             :     JS_NULL_CLASS_OPS,
     319             :     JS_NULL_CLASS_SPEC,
     320             :     JS_NULL_CLASS_EXT,
     321             :     JS_NULL_OBJECT_OPS
     322             :   },
     323             :   eInterfacePrototype,
     324             :   false,
     325             :   prototypes::id::AudioScheduledSourceNode,
     326             :   PrototypeTraits<prototypes::id::AudioScheduledSourceNode>::Depth,
     327             :   sNativePropertyHooks,
     328             :   "[object AudioScheduledSourceNodePrototype]",
     329             :   AudioNodeBinding::GetProtoObject
     330             : };
     331             : 
     332             : JSObject*
     333           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     334             : {
     335           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     336             : }
     337             : 
     338             : static const js::ClassOps sClassOps = {
     339             :   _addProperty, /* addProperty */
     340             :   nullptr,               /* delProperty */
     341             :   nullptr,               /* getProperty */
     342             :   nullptr,               /* setProperty */
     343             :   nullptr,               /* enumerate */
     344             :   nullptr, /* newEnumerate */
     345             :   nullptr, /* resolve */
     346             :   nullptr, /* mayResolve */
     347             :   _finalize, /* finalize */
     348             :   nullptr, /* call */
     349             :   nullptr,               /* hasInstance */
     350             :   nullptr,               /* construct */
     351             :   nullptr, /* trace */
     352             : };
     353             : 
     354             : static const js::ClassExtension sClassExtension = {
     355             :   nullptr, /* weakmapKeyDelegateOp */
     356             :   _objectMoved /* objectMovedOp */
     357             : };
     358             : 
     359             : static const DOMJSClass sClass = {
     360             :   { "AudioScheduledSourceNode",
     361             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     362             :     &sClassOps,
     363             :     JS_NULL_CLASS_SPEC,
     364             :     &sClassExtension,
     365             :     JS_NULL_OBJECT_OPS
     366             :   },
     367             :   { prototypes::id::EventTarget, prototypes::id::AudioNode, prototypes::id::AudioScheduledSourceNode, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     368             :   IsBaseOf<nsISupports, mozilla::dom::AudioScheduledSourceNode >::value,
     369             :   sNativePropertyHooks,
     370             :   FindAssociatedGlobalForNative<mozilla::dom::AudioScheduledSourceNode>::Get,
     371             :   GetProtoObjectHandle,
     372             :   GetCCParticipant<mozilla::dom::AudioScheduledSourceNode>::Get()
     373             : };
     374             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     375             :               "Must have the right minimal number of reserved slots.");
     376             : static_assert(1 >= 1,
     377             :               "Must have enough reserved slots.");
     378             : 
     379             : const JSClass*
     380           0 : GetJSClass()
     381             : {
     382           0 :   return sClass.ToJSClass();
     383             : }
     384             : 
     385             : bool
     386           0 : Wrap(JSContext* aCx, mozilla::dom::AudioScheduledSourceNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     387             : {
     388             :   MOZ_ASSERT(static_cast<mozilla::dom::AudioScheduledSourceNode*>(aObject) ==
     389             :              reinterpret_cast<mozilla::dom::AudioScheduledSourceNode*>(aObject),
     390             :              "Multiple inheritance for mozilla::dom::AudioScheduledSourceNode is broken.");
     391             :   MOZ_ASSERT(static_cast<mozilla::dom::AudioNode*>(aObject) ==
     392             :              reinterpret_cast<mozilla::dom::AudioNode*>(aObject),
     393             :              "Multiple inheritance for mozilla::dom::AudioNode is broken.");
     394             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     395             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     396             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     397           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     398           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     399           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     400             :              "You should probably not be using Wrap() directly; use "
     401             :              "GetOrCreateDOMReflector instead");
     402             : 
     403           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     404             :              "nsISupports must be on our primary inheritance chain");
     405             : 
     406           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     407           0 :   if (!global) {
     408           0 :     return false;
     409             :   }
     410           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     411           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     412             : 
     413             :   // That might have ended up wrapping us already, due to the wonders
     414             :   // of XBL.  Check for that, and bail out as needed.
     415           0 :   aReflector.set(aCache->GetWrapper());
     416           0 :   if (aReflector) {
     417             : #ifdef DEBUG
     418           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     419             : #endif // DEBUG
     420           0 :     return true;
     421             :   }
     422             : 
     423           0 :   JSAutoCompartment ac(aCx, global);
     424           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     425           0 :   if (!canonicalProto) {
     426           0 :     return false;
     427             :   }
     428           0 :   JS::Rooted<JSObject*> proto(aCx);
     429           0 :   if (aGivenProto) {
     430           0 :     proto = aGivenProto;
     431             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     432             :     // coming in, we changed compartments to that of "parent" so may need
     433             :     // to wrap the proto here.
     434           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     435           0 :       if (!JS_WrapObject(aCx, &proto)) {
     436           0 :         return false;
     437             :       }
     438             :     }
     439             :   } else {
     440           0 :     proto = canonicalProto;
     441             :   }
     442             : 
     443           0 :   BindingJSObjectCreator<mozilla::dom::AudioScheduledSourceNode> creator(aCx);
     444           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     445           0 :   if (!aReflector) {
     446           0 :     return false;
     447             :   }
     448             : 
     449           0 :   aCache->SetWrapper(aReflector);
     450           0 :   creator.InitializationSucceeded();
     451             : 
     452           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     453             :              aCache->GetWrapperPreserveColor() == aReflector);
     454             :   // If proto != canonicalProto, we have to preserve our wrapper;
     455             :   // otherwise we won't be able to properly recreate it later, since
     456             :   // we won't know what proto to use.  Note that we don't check
     457             :   // aGivenProto here, since it's entirely possible (and even
     458             :   // somewhat common) to have a non-null aGivenProto which is the
     459             :   // same as canonicalProto.
     460           0 :   if (proto != canonicalProto) {
     461           0 :     PreserveWrapper(aObject);
     462             :   }
     463             : 
     464           0 :   return true;
     465             : }
     466             : 
     467             : const NativePropertyHooks sNativePropertyHooks[] = { {
     468             :   nullptr,
     469             :   nullptr,
     470             :   nullptr,
     471             :   { sNativeProperties.Upcast(), nullptr },
     472             :   prototypes::id::AudioScheduledSourceNode,
     473             :   constructors::id::AudioScheduledSourceNode,
     474             :   AudioNodeBinding::sNativePropertyHooks,
     475             :   &DefaultXrayExpandoObjectClass
     476             : } };
     477             : 
     478             : void
     479           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     480             : {
     481           0 :   JS::Handle<JSObject*> parentProto(AudioNodeBinding::GetProtoObjectHandle(aCx));
     482           0 :   if (!parentProto) {
     483           0 :     return;
     484             :   }
     485             : 
     486           0 :   JS::Handle<JSObject*> constructorProto(AudioNodeBinding::GetConstructorObjectHandle(aCx));
     487           0 :   if (!constructorProto) {
     488           0 :     return;
     489             :   }
     490             : 
     491             :   static bool sIdsInited = false;
     492           0 :   if (!sIdsInited && NS_IsMainThread()) {
     493           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     494           0 :       return;
     495             :     }
     496           0 :     sIdsInited = true;
     497             :   }
     498             : 
     499           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioScheduledSourceNode);
     500           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AudioScheduledSourceNode);
     501           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     502             :                               &sPrototypeClass.mBase, protoCache,
     503             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     504             :                               interfaceCache,
     505             :                               sNativeProperties.Upcast(),
     506             :                               nullptr,
     507             :                               "AudioScheduledSourceNode", aDefineOnGlobal,
     508             :                               nullptr,
     509           0 :                               false);
     510             : }
     511             : 
     512             : JS::Handle<JSObject*>
     513           0 : GetProtoObjectHandle(JSContext* aCx)
     514             : {
     515             :   /* Get the interface prototype object for this class.  This will create the
     516             :      object as needed. */
     517           0 :   bool aDefineOnGlobal = true;
     518             : 
     519             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     520           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     521           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     522           0 :     return nullptr;
     523             :   }
     524             : 
     525             :   /* Check to see whether the interface objects are already installed */
     526           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     527           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::AudioScheduledSourceNode)) {
     528           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     529           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     530             :   }
     531             : 
     532             :   /*
     533             :    * The object might _still_ be null, but that's OK.
     534             :    *
     535             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     536             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     537             :    * changed after they have been set.
     538             :    *
     539             :    * Calling address() avoids the read read barrier that does gray
     540             :    * unmarking, but it's not possible for the object to be gray here.
     541             :    */
     542             : 
     543           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::AudioScheduledSourceNode);
     544           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     545           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     546             : }
     547             : 
     548             : JSObject*
     549           0 : GetProtoObject(JSContext* aCx)
     550             : {
     551           0 :   return GetProtoObjectHandle(aCx);
     552             : }
     553             : 
     554             : JS::Handle<JSObject*>
     555           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     556             : {
     557             :   /* Get the interface object for this class.  This will create the object as
     558             :      needed. */
     559             : 
     560             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     561           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     562           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     563           0 :     return nullptr;
     564             :   }
     565             : 
     566             :   /* Check to see whether the interface objects are already installed */
     567           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     568           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::AudioScheduledSourceNode)) {
     569           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     570           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     571             :   }
     572             : 
     573             :   /*
     574             :    * The object might _still_ be null, but that's OK.
     575             :    *
     576             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     577             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     578             :    * changed after they have been set.
     579             :    *
     580             :    * Calling address() avoids the read read barrier that does gray
     581             :    * unmarking, but it's not possible for the object to be gray here.
     582             :    */
     583             : 
     584           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::AudioScheduledSourceNode);
     585           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     586           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     587             : }
     588             : 
     589             : JSObject*
     590           0 : GetConstructorObject(JSContext* aCx)
     591             : {
     592           0 :   return GetConstructorObjectHandle(aCx);
     593             : }
     594             : 
     595             : } // namespace AudioScheduledSourceNodeBinding
     596             : 
     597             : 
     598             : 
     599             : } // namespace dom
     600             : } // namespace mozilla

Generated by: LCOV version 1.13