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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM AudioDestinationNode.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AudioDestinationNodeBinding.h"
       4             : #include "AudioNodeBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/Preferences.h"
       8             : #include "mozilla/dom/AudioDestinationNode.h"
       9             : #include "mozilla/dom/BindingUtils.h"
      10             : #include "mozilla/dom/DOMJSClass.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/PrimitiveConversions.h"
      13             : #include "mozilla/dom/XrayExpandoClass.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : namespace AudioDestinationNodeBinding {
      19             : 
      20             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<AudioNodeBinding::NativeType>::value,
      21             :               "Can't inherit from an interface with a different ownership model.");
      22             : 
      23             : static bool
      24           0 : get_maxChannelCount(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::AudioDestinationNode* self, JSJitGetterCallArgs args)
      25             : {
      26           0 :   uint32_t result(self->MaxChannelCount());
      27           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      28           0 :   args.rval().setNumber(result);
      29           0 :   return true;
      30             : }
      31             : 
      32             : static const JSJitInfo maxChannelCount_getterinfo = {
      33             :   { (JSJitGetterOp)get_maxChannelCount },
      34             :   { prototypes::id::AudioDestinationNode },
      35             :   { PrototypeTraits<prototypes::id::AudioDestinationNode>::Depth },
      36             :   JSJitInfo::Getter,
      37             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      38             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      39             :   true,  /* isInfallible. False in setters. */
      40             :   false,  /* isMovable.  Not relevant for setters. */
      41             :   false, /* isEliminatable.  Not relevant for setters. */
      42             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      43             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      44             :   false,  /* isTypedMethod.  Only relevant for methods. */
      45             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      46             : };
      47             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      48             : static_assert(0 < 1, "There is no slot for us");
      49             : 
      50             : static bool
      51           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
      52             : {
      53           0 :   mozilla::dom::AudioDestinationNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioDestinationNode>(obj);
      54             :   // We don't want to preserve if we don't have a wrapper, and we
      55             :   // obviously can't preserve if we're not initialized.
      56           0 :   if (self && self->GetWrapperPreserveColor()) {
      57           0 :     PreserveWrapper(self);
      58             :   }
      59           0 :   return true;
      60             : }
      61             : 
      62             : static void
      63           0 : _finalize(js::FreeOp* fop, JSObject* obj)
      64             : {
      65           0 :   mozilla::dom::AudioDestinationNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioDestinationNode>(obj);
      66           0 :   if (self) {
      67           0 :     ClearWrapper(self, self, obj);
      68           0 :     AddForDeferredFinalization<mozilla::dom::AudioDestinationNode>(self);
      69             :   }
      70           0 : }
      71             : 
      72             : static void
      73           0 : _objectMoved(JSObject* obj, const JSObject* old)
      74             : {
      75           0 :   mozilla::dom::AudioDestinationNode* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::AudioDestinationNode>(obj);
      76           0 :   if (self) {
      77           0 :     UpdateWrapper(self, self, obj, old);
      78             :   }
      79           0 : }
      80             : 
      81             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
      82             : #if defined(__clang__)
      83             : #pragma clang diagnostic push
      84             : #pragma clang diagnostic ignored "-Wmissing-braces"
      85             : #endif
      86             : static const JSPropertySpec sAttributes_specs[] = {
      87             :   { "maxChannelCount", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &maxChannelCount_getterinfo, nullptr, nullptr },
      88             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
      89             : };
      90             : #if defined(__clang__)
      91             : #pragma clang diagnostic pop
      92             : #endif
      93             : 
      94             : 
      95             : // Can't be const because the pref-enabled boolean needs to be writable
      96             : static Prefable<const JSPropertySpec> sAttributes[] = {
      97             :   { nullptr, &sAttributes_specs[0] },
      98             :   { nullptr, nullptr }
      99             : };
     100             : 
     101             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     102             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     103             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     104             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     105             : 
     106             : 
     107             : static uint16_t sNativeProperties_sortedPropertyIndices[1];
     108             : static PropertyInfo sNativeProperties_propertyInfos[1];
     109             : 
     110             : static const NativePropertiesN<1> sNativeProperties = {
     111             :   false, 0,
     112             :   false, 0,
     113             :   false, 0,
     114             :   true,  0 /* sAttributes */,
     115             :   false, 0,
     116             :   false, 0,
     117             :   false, 0,
     118             :   -1,
     119             :   1,
     120             :   sNativeProperties_sortedPropertyIndices,
     121             :   {
     122             :     { sAttributes, &sNativeProperties_propertyInfos[0] }
     123             :   }
     124             : };
     125             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     126             :     "We have a property info count that is oversized");
     127             : 
     128             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     129             :   {
     130             :     "Function",
     131             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     132             :     &sBoringInterfaceObjectClassClassOps,
     133             :     JS_NULL_CLASS_SPEC,
     134             :     JS_NULL_CLASS_EXT,
     135             :     &sInterfaceObjectClassObjectOps
     136             :   },
     137             :   eInterface,
     138             :   true,
     139             :   prototypes::id::AudioDestinationNode,
     140             :   PrototypeTraits<prototypes::id::AudioDestinationNode>::Depth,
     141             :   sNativePropertyHooks,
     142             :   "function AudioDestinationNode() {\n    [native code]\n}",
     143             :   AudioNodeBinding::GetConstructorObject
     144             : };
     145             : 
     146             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     147             :   {
     148             :     "AudioDestinationNodePrototype",
     149             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     150             :     JS_NULL_CLASS_OPS,
     151             :     JS_NULL_CLASS_SPEC,
     152             :     JS_NULL_CLASS_EXT,
     153             :     JS_NULL_OBJECT_OPS
     154             :   },
     155             :   eInterfacePrototype,
     156             :   false,
     157             :   prototypes::id::AudioDestinationNode,
     158             :   PrototypeTraits<prototypes::id::AudioDestinationNode>::Depth,
     159             :   sNativePropertyHooks,
     160             :   "[object AudioDestinationNodePrototype]",
     161             :   AudioNodeBinding::GetProtoObject
     162             : };
     163             : 
     164             : bool
     165           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     166             : {
     167             :   static bool sPrefValue;
     168             :   static bool sPrefCacheSetUp = false;
     169           0 :   if (!sPrefCacheSetUp) {
     170           0 :     sPrefCacheSetUp = true;
     171           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.webaudio.enabled");
     172             :   }
     173             : 
     174           0 :   return sPrefValue;
     175             : }
     176             : 
     177             : JSObject*
     178           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     179             : {
     180           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     181             : }
     182             : 
     183             : static const js::ClassOps sClassOps = {
     184             :   _addProperty, /* addProperty */
     185             :   nullptr,               /* delProperty */
     186             :   nullptr,               /* getProperty */
     187             :   nullptr,               /* setProperty */
     188             :   nullptr,               /* enumerate */
     189             :   nullptr, /* newEnumerate */
     190             :   nullptr, /* resolve */
     191             :   nullptr, /* mayResolve */
     192             :   _finalize, /* finalize */
     193             :   nullptr, /* call */
     194             :   nullptr,               /* hasInstance */
     195             :   nullptr,               /* construct */
     196             :   nullptr, /* trace */
     197             : };
     198             : 
     199             : static const js::ClassExtension sClassExtension = {
     200             :   nullptr, /* weakmapKeyDelegateOp */
     201             :   _objectMoved /* objectMovedOp */
     202             : };
     203             : 
     204             : static const DOMJSClass sClass = {
     205             :   { "AudioDestinationNode",
     206             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     207             :     &sClassOps,
     208             :     JS_NULL_CLASS_SPEC,
     209             :     &sClassExtension,
     210             :     JS_NULL_OBJECT_OPS
     211             :   },
     212             :   { prototypes::id::EventTarget, prototypes::id::AudioNode, prototypes::id::AudioDestinationNode, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     213             :   IsBaseOf<nsISupports, mozilla::dom::AudioDestinationNode >::value,
     214             :   sNativePropertyHooks,
     215             :   FindAssociatedGlobalForNative<mozilla::dom::AudioDestinationNode>::Get,
     216             :   GetProtoObjectHandle,
     217             :   GetCCParticipant<mozilla::dom::AudioDestinationNode>::Get()
     218             : };
     219             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     220             :               "Must have the right minimal number of reserved slots.");
     221             : static_assert(1 >= 1,
     222             :               "Must have enough reserved slots.");
     223             : 
     224             : const JSClass*
     225           0 : GetJSClass()
     226             : {
     227           0 :   return sClass.ToJSClass();
     228             : }
     229             : 
     230             : bool
     231           0 : Wrap(JSContext* aCx, mozilla::dom::AudioDestinationNode* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     232             : {
     233             :   MOZ_ASSERT(static_cast<mozilla::dom::AudioDestinationNode*>(aObject) ==
     234             :              reinterpret_cast<mozilla::dom::AudioDestinationNode*>(aObject),
     235             :              "Multiple inheritance for mozilla::dom::AudioDestinationNode is broken.");
     236             :   MOZ_ASSERT(static_cast<mozilla::dom::AudioNode*>(aObject) ==
     237             :              reinterpret_cast<mozilla::dom::AudioNode*>(aObject),
     238             :              "Multiple inheritance for mozilla::dom::AudioNode is broken.");
     239             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     240             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     241             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     242           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     243           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     244           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     245             :              "You should probably not be using Wrap() directly; use "
     246             :              "GetOrCreateDOMReflector instead");
     247             : 
     248           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     249             :              "nsISupports must be on our primary inheritance chain");
     250             : 
     251           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     252           0 :   if (!global) {
     253           0 :     return false;
     254             :   }
     255           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     256           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     257             : 
     258             :   // That might have ended up wrapping us already, due to the wonders
     259             :   // of XBL.  Check for that, and bail out as needed.
     260           0 :   aReflector.set(aCache->GetWrapper());
     261           0 :   if (aReflector) {
     262             : #ifdef DEBUG
     263           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     264             : #endif // DEBUG
     265           0 :     return true;
     266             :   }
     267             : 
     268           0 :   JSAutoCompartment ac(aCx, global);
     269           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     270           0 :   if (!canonicalProto) {
     271           0 :     return false;
     272             :   }
     273           0 :   JS::Rooted<JSObject*> proto(aCx);
     274           0 :   if (aGivenProto) {
     275           0 :     proto = aGivenProto;
     276             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     277             :     // coming in, we changed compartments to that of "parent" so may need
     278             :     // to wrap the proto here.
     279           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     280           0 :       if (!JS_WrapObject(aCx, &proto)) {
     281           0 :         return false;
     282             :       }
     283             :     }
     284             :   } else {
     285           0 :     proto = canonicalProto;
     286             :   }
     287             : 
     288           0 :   BindingJSObjectCreator<mozilla::dom::AudioDestinationNode> creator(aCx);
     289           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     290           0 :   if (!aReflector) {
     291           0 :     return false;
     292             :   }
     293             : 
     294           0 :   aCache->SetWrapper(aReflector);
     295           0 :   creator.InitializationSucceeded();
     296             : 
     297           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     298             :              aCache->GetWrapperPreserveColor() == aReflector);
     299             :   // If proto != canonicalProto, we have to preserve our wrapper;
     300             :   // otherwise we won't be able to properly recreate it later, since
     301             :   // we won't know what proto to use.  Note that we don't check
     302             :   // aGivenProto here, since it's entirely possible (and even
     303             :   // somewhat common) to have a non-null aGivenProto which is the
     304             :   // same as canonicalProto.
     305           0 :   if (proto != canonicalProto) {
     306           0 :     PreserveWrapper(aObject);
     307             :   }
     308             : 
     309           0 :   return true;
     310             : }
     311             : 
     312             : const NativePropertyHooks sNativePropertyHooks[] = { {
     313             :   nullptr,
     314             :   nullptr,
     315             :   nullptr,
     316             :   { sNativeProperties.Upcast(), nullptr },
     317             :   prototypes::id::AudioDestinationNode,
     318             :   constructors::id::AudioDestinationNode,
     319             :   AudioNodeBinding::sNativePropertyHooks,
     320             :   &DefaultXrayExpandoObjectClass
     321             : } };
     322             : 
     323             : void
     324           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     325             : {
     326           0 :   JS::Handle<JSObject*> parentProto(AudioNodeBinding::GetProtoObjectHandle(aCx));
     327           0 :   if (!parentProto) {
     328           0 :     return;
     329             :   }
     330             : 
     331           0 :   JS::Handle<JSObject*> constructorProto(AudioNodeBinding::GetConstructorObjectHandle(aCx));
     332           0 :   if (!constructorProto) {
     333           0 :     return;
     334             :   }
     335             : 
     336             :   static bool sIdsInited = false;
     337           0 :   if (!sIdsInited && NS_IsMainThread()) {
     338           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     339           0 :       return;
     340             :     }
     341           0 :     sIdsInited = true;
     342             :   }
     343             : 
     344           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::AudioDestinationNode);
     345           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::AudioDestinationNode);
     346           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     347             :                               &sPrototypeClass.mBase, protoCache,
     348             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     349             :                               interfaceCache,
     350             :                               sNativeProperties.Upcast(),
     351             :                               nullptr,
     352             :                               "AudioDestinationNode", aDefineOnGlobal,
     353             :                               nullptr,
     354           0 :                               false);
     355             : }
     356             : 
     357             : JS::Handle<JSObject*>
     358           0 : GetProtoObjectHandle(JSContext* aCx)
     359             : {
     360             :   /* Get the interface prototype object for this class.  This will create the
     361             :      object as needed. */
     362           0 :   bool aDefineOnGlobal = true;
     363             : 
     364             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     365           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     366           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     367           0 :     return nullptr;
     368             :   }
     369             : 
     370             :   /* Check to see whether the interface objects are already installed */
     371           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     372           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::AudioDestinationNode)) {
     373           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     374           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     375             :   }
     376             : 
     377             :   /*
     378             :    * The object might _still_ be null, but that's OK.
     379             :    *
     380             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     381             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     382             :    * changed after they have been set.
     383             :    *
     384             :    * Calling address() avoids the read read barrier that does gray
     385             :    * unmarking, but it's not possible for the object to be gray here.
     386             :    */
     387             : 
     388           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::AudioDestinationNode);
     389           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     390           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     391             : }
     392             : 
     393             : JS::Handle<JSObject*>
     394           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     395             : {
     396             :   /* Get the interface object for this class.  This will create the object as
     397             :      needed. */
     398             : 
     399             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     400           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     401           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     402           0 :     return nullptr;
     403             :   }
     404             : 
     405             :   /* Check to see whether the interface objects are already installed */
     406           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     407           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::AudioDestinationNode)) {
     408           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     409           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     410             :   }
     411             : 
     412             :   /*
     413             :    * The object might _still_ be null, but that's OK.
     414             :    *
     415             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     416             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     417             :    * changed after they have been set.
     418             :    *
     419             :    * Calling address() avoids the read read barrier that does gray
     420             :    * unmarking, but it's not possible for the object to be gray here.
     421             :    */
     422             : 
     423           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::AudioDestinationNode);
     424           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     425           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     426             : }
     427             : 
     428             : JSObject*
     429           0 : GetConstructorObject(JSContext* aCx)
     430             : {
     431           0 :   return GetConstructorObjectHandle(aCx);
     432             : }
     433             : 
     434             : } // namespace AudioDestinationNodeBinding
     435             : 
     436             : 
     437             : 
     438             : } // namespace dom
     439             : } // namespace mozilla

Generated by: LCOV version 1.13