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

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

Generated by: LCOV version 1.13