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

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

Generated by: LCOV version 1.13