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

Generated by: LCOV version 1.13