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

Generated by: LCOV version 1.13