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

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

Generated by: LCOV version 1.13