LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - IDBIndexBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 24 419 5.7 %
Date: 2017-07-14 16:53:18 Functions: 3 35 8.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM IDBIndex.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "IDBIndexBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/DOMJSClass.h"
       9             : #include "mozilla/dom/IDBIndex.h"
      10             : #include "mozilla/dom/IDBObjectStore.h"
      11             : #include "mozilla/dom/IDBRequest.h"
      12             : #include "mozilla/dom/IndexedDatabaseManager.h"
      13             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      14             : #include "mozilla/dom/Nullable.h"
      15             : #include "mozilla/dom/PrimitiveConversions.h"
      16             : #include "mozilla/dom/ScriptSettings.h"
      17             : #include "mozilla/dom/SimpleGlobalObject.h"
      18             : #include "mozilla/dom/XrayExpandoClass.h"
      19             : 
      20             : namespace mozilla {
      21             : namespace dom {
      22             : 
      23             : 
      24           0 : IDBIndexParameters::IDBIndexParameters()
      25             : {
      26             :   // Safe to pass a null context if we pass a null value
      27           0 :   Init(nullptr, JS::NullHandleValue);
      28           0 : }
      29             : 
      30             : 
      31             : 
      32             : bool
      33           0 : IDBIndexParameters::InitIds(JSContext* cx, IDBIndexParametersAtoms* atomsCache)
      34             : {
      35           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      36             : 
      37             :   // Initialize these in reverse order so that any failure leaves the first one
      38             :   // uninitialized.
      39           0 :   if (!atomsCache->unique_id.init(cx, "unique") ||
      40           0 :       !atomsCache->multiEntry_id.init(cx, "multiEntry") ||
      41           0 :       !atomsCache->locale_id.init(cx, "locale")) {
      42           0 :     return false;
      43             :   }
      44           0 :   return true;
      45             : }
      46             : 
      47             : bool
      48           0 : IDBIndexParameters::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      49             : {
      50             :   // Passing a null JSContext is OK only if we're initing from null,
      51             :   // Since in that case we will not have to do any property gets
      52             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      53             :   // checkers by static analysis tools
      54           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      55           0 :   IDBIndexParametersAtoms* atomsCache = nullptr;
      56           0 :   if (cx) {
      57           0 :     atomsCache = GetAtomCache<IDBIndexParametersAtoms>(cx);
      58           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      59           0 :       return false;
      60             :     }
      61             :   }
      62             : 
      63           0 :   if (!IsConvertibleToDictionary(val)) {
      64           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      65             :   }
      66             : 
      67           0 :   bool isNull = val.isNullOrUndefined();
      68             :   // We only need these if !isNull, in which case we have |cx|.
      69           0 :   Maybe<JS::Rooted<JSObject *> > object;
      70           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      71           0 :   if (!isNull) {
      72           0 :     MOZ_ASSERT(cx);
      73           0 :     object.emplace(cx, &val.toObject());
      74           0 :     temp.emplace(cx);
      75             :   }
      76           0 :   if (!isNull) {
      77           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->locale_id, temp.ptr())) {
      78           0 :       return false;
      79             :     }
      80             :   }
      81           0 :   if (!isNull && !temp->isUndefined()) {
      82           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eNull, eNull, mLocale)) {
      83           0 :       return false;
      84             :     }
      85             :   } else {
      86           0 :     mLocale.SetIsVoid(true);
      87             :   }
      88           0 :   mIsAnyMemberPresent = true;
      89             : 
      90           0 :   if (!isNull) {
      91           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->multiEntry_id, temp.ptr())) {
      92           0 :       return false;
      93             :     }
      94             :   }
      95           0 :   if (!isNull && !temp->isUndefined()) {
      96           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mMultiEntry)) {
      97           0 :       return false;
      98             :     }
      99             :   } else {
     100           0 :     mMultiEntry = false;
     101             :   }
     102           0 :   mIsAnyMemberPresent = true;
     103             : 
     104           0 :   if (!isNull) {
     105           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->unique_id, temp.ptr())) {
     106           0 :       return false;
     107             :     }
     108             :   }
     109           0 :   if (!isNull && !temp->isUndefined()) {
     110           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mUnique)) {
     111           0 :       return false;
     112             :     }
     113             :   } else {
     114           0 :     mUnique = false;
     115             :   }
     116           0 :   mIsAnyMemberPresent = true;
     117           0 :   return true;
     118             : }
     119             : 
     120             : bool
     121           0 : IDBIndexParameters::Init(const nsAString& aJSON)
     122             : {
     123           0 :   AutoJSAPI jsapi;
     124           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     125           0 :   if (!cleanGlobal) {
     126           0 :     return false;
     127             :   }
     128           0 :   if (!jsapi.Init(cleanGlobal)) {
     129           0 :     return false;
     130             :   }
     131           0 :   JSContext* cx = jsapi.cx();
     132           0 :   JS::Rooted<JS::Value> json(cx);
     133           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     134           0 :   NS_ENSURE_TRUE(ok, false);
     135           0 :   return Init(cx, json);
     136             : }
     137             : 
     138             : bool
     139           0 : IDBIndexParameters::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     140             : {
     141           0 :   IDBIndexParametersAtoms* atomsCache = GetAtomCache<IDBIndexParametersAtoms>(cx);
     142           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     143           0 :     return false;
     144             :   }
     145             : 
     146           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     147           0 :   if (!obj) {
     148           0 :     return false;
     149             :   }
     150           0 :   rval.set(JS::ObjectValue(*obj));
     151             : 
     152             :   do {
     153             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     154           0 :     JS::Rooted<JS::Value> temp(cx);
     155           0 :     nsString const & currentValue = mLocale;
     156           0 :     if (!xpc::StringToJsval(cx, currentValue, &temp)) {
     157           0 :       return false;
     158             :     }
     159           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->locale_id, temp, JSPROP_ENUMERATE)) {
     160           0 :       return false;
     161             :     }
     162           0 :     break;
     163             :   } while(0);
     164             : 
     165             :   do {
     166             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     167           0 :     JS::Rooted<JS::Value> temp(cx);
     168           0 :     bool const & currentValue = mMultiEntry;
     169           0 :     temp.setBoolean(currentValue);
     170           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->multiEntry_id, temp, JSPROP_ENUMERATE)) {
     171           0 :       return false;
     172             :     }
     173           0 :     break;
     174             :   } while(0);
     175             : 
     176             :   do {
     177             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     178           0 :     JS::Rooted<JS::Value> temp(cx);
     179           0 :     bool const & currentValue = mUnique;
     180           0 :     temp.setBoolean(currentValue);
     181           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->unique_id, temp, JSPROP_ENUMERATE)) {
     182           0 :       return false;
     183             :     }
     184           0 :     break;
     185             :   } while(0);
     186             : 
     187           0 :   return true;
     188             : }
     189             : 
     190             : bool
     191           0 : IDBIndexParameters::ToJSON(nsAString& aJSON) const
     192             : {
     193           0 :   AutoJSAPI jsapi;
     194           0 :   jsapi.Init();
     195           0 :   JSContext *cx = jsapi.cx();
     196             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     197             :   // because we'll only be creating objects, in ways that have no
     198             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     199             :   // which likewise guarantees no side-effects for the sorts of
     200             :   // things we will pass it.
     201           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     202           0 :   JS::Rooted<JS::Value> val(cx);
     203           0 :   if (!ToObjectInternal(cx, &val)) {
     204           0 :     return false;
     205             :   }
     206           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     207           0 :   return StringifyToJSON(cx, obj, aJSON);
     208             : }
     209             : 
     210             : void
     211           0 : IDBIndexParameters::TraceDictionary(JSTracer* trc)
     212             : {
     213           0 : }
     214             : 
     215             : IDBIndexParameters&
     216           0 : IDBIndexParameters::operator=(const IDBIndexParameters& aOther)
     217             : {
     218           0 :   mLocale = aOther.mLocale;
     219           0 :   mMultiEntry = aOther.mMultiEntry;
     220           0 :   mUnique = aOther.mUnique;
     221           0 :   return *this;
     222             : }
     223             : 
     224             : namespace binding_detail {
     225             : } // namespace binding_detail
     226             : 
     227             : 
     228             : namespace IDBIndexBinding {
     229             : 
     230             : static bool
     231           0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args)
     232             : {
     233           0 :   DOMString result;
     234           0 :   self->GetName(result);
     235           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     236           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     237           0 :     return false;
     238             :   }
     239           0 :   return true;
     240             : }
     241             : 
     242             : static bool
     243           0 : set_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitSetterCallArgs args)
     244             : {
     245           0 :   binding_detail::FakeString arg0;
     246           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     247           0 :     return false;
     248             :   }
     249           0 :   binding_detail::FastErrorResult rv;
     250           0 :   self->SetName(NonNullHelper(Constify(arg0)), rv);
     251           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     252           0 :     return false;
     253             :   }
     254           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     255             : 
     256           0 :   return true;
     257             : }
     258             : 
     259             : static const JSJitInfo name_getterinfo = {
     260             :   { (JSJitGetterOp)get_name },
     261             :   { prototypes::id::IDBIndex },
     262             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     263             :   JSJitInfo::Getter,
     264             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     265             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     266             :   false,  /* isInfallible. False in setters. */
     267             :   false,  /* isMovable.  Not relevant for setters. */
     268             :   false, /* isEliminatable.  Not relevant for setters. */
     269             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     270             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     271             :   false,  /* isTypedMethod.  Only relevant for methods. */
     272             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     273             : };
     274             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     275             : static_assert(0 < 1, "There is no slot for us");
     276             : static const JSJitInfo name_setterinfo = {
     277             :   { (JSJitGetterOp)set_name },
     278             :   { prototypes::id::IDBIndex },
     279             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     280             :   JSJitInfo::Setter,
     281             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     282             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     283             :   false,  /* isInfallible. False in setters. */
     284             :   false,  /* isMovable.  Not relevant for setters. */
     285             :   false, /* isEliminatable.  Not relevant for setters. */
     286             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     287             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     288             :   false,  /* isTypedMethod.  Only relevant for methods. */
     289             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     290             : };
     291             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     292             : static_assert(0 < 1, "There is no slot for us");
     293             : 
     294             : static bool
     295           0 : get_objectStore(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args)
     296             : {
     297           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBObjectStore>(self->ObjectStore()));
     298           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     299           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     300           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     301           0 :     return false;
     302             :   }
     303           0 :   return true;
     304             : }
     305             : 
     306             : static const JSJitInfo objectStore_getterinfo = {
     307             :   { (JSJitGetterOp)get_objectStore },
     308             :   { prototypes::id::IDBIndex },
     309             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     310             :   JSJitInfo::Getter,
     311             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     312             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     313             :   false,  /* isInfallible. False in setters. */
     314             :   false,  /* isMovable.  Not relevant for setters. */
     315             :   false, /* isEliminatable.  Not relevant for setters. */
     316             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     317             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     318             :   false,  /* isTypedMethod.  Only relevant for methods. */
     319             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     320             : };
     321             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     322             : static_assert(0 < 1, "There is no slot for us");
     323             : 
     324             : static bool
     325           0 : get_keyPath(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args)
     326             : {
     327           0 :   binding_detail::FastErrorResult rv;
     328           0 :   JS::Rooted<JS::Value> result(cx);
     329           0 :   self->GetKeyPath(cx, &result, rv);
     330           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     331           0 :     return false;
     332             :   }
     333           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     334           0 :   JS::ExposeValueToActiveJS(result);
     335           0 :   args.rval().set(result);
     336           0 :   if (!MaybeWrapValue(cx, args.rval())) {
     337           0 :     return false;
     338             :   }
     339           0 :   return true;
     340             : }
     341             : 
     342             : static const JSJitInfo keyPath_getterinfo = {
     343             :   { (JSJitGetterOp)get_keyPath },
     344             :   { prototypes::id::IDBIndex },
     345             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     346             :   JSJitInfo::Getter,
     347             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     348             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     349             :   false,  /* isInfallible. False in setters. */
     350             :   false,  /* isMovable.  Not relevant for setters. */
     351             :   false, /* isEliminatable.  Not relevant for setters. */
     352             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     353             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     354             :   false,  /* isTypedMethod.  Only relevant for methods. */
     355             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     356             : };
     357             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     358             : static_assert(0 < 1, "There is no slot for us");
     359             : 
     360             : static bool
     361           0 : get_multiEntry(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args)
     362             : {
     363           0 :   bool result(self->MultiEntry());
     364           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     365           0 :   args.rval().setBoolean(result);
     366           0 :   return true;
     367             : }
     368             : 
     369             : static const JSJitInfo multiEntry_getterinfo = {
     370             :   { (JSJitGetterOp)get_multiEntry },
     371             :   { prototypes::id::IDBIndex },
     372             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     373             :   JSJitInfo::Getter,
     374             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     375             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     376             :   true,  /* isInfallible. False in setters. */
     377             :   false,  /* isMovable.  Not relevant for setters. */
     378             :   false, /* isEliminatable.  Not relevant for setters. */
     379             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     380             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     381             :   false,  /* isTypedMethod.  Only relevant for methods. */
     382             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     383             : };
     384             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     385             : static_assert(0 < 1, "There is no slot for us");
     386             : 
     387             : static bool
     388           0 : get_unique(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args)
     389             : {
     390           0 :   bool result(self->Unique());
     391           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     392           0 :   args.rval().setBoolean(result);
     393           0 :   return true;
     394             : }
     395             : 
     396             : static const JSJitInfo unique_getterinfo = {
     397             :   { (JSJitGetterOp)get_unique },
     398             :   { prototypes::id::IDBIndex },
     399             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     400             :   JSJitInfo::Getter,
     401             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     402             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     403             :   true,  /* isInfallible. False in setters. */
     404             :   false,  /* isMovable.  Not relevant for setters. */
     405             :   false, /* isEliminatable.  Not relevant for setters. */
     406             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     407             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     408             :   false,  /* isTypedMethod.  Only relevant for methods. */
     409             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     410             : };
     411             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     412             : static_assert(0 < 1, "There is no slot for us");
     413             : 
     414             : static bool
     415           0 : get_locale(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args)
     416             : {
     417           0 :   DOMString result;
     418           0 :   self->GetLocale(result);
     419           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     420           0 :   if (!xpc::StringToJsval(cx, result, args.rval())) {
     421           0 :     return false;
     422             :   }
     423           0 :   return true;
     424             : }
     425             : 
     426             : static const JSJitInfo locale_getterinfo = {
     427             :   { (JSJitGetterOp)get_locale },
     428             :   { prototypes::id::IDBIndex },
     429             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     430             :   JSJitInfo::Getter,
     431             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     432             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     433             :   false,  /* isInfallible. False in setters. */
     434             :   false,  /* isMovable.  Not relevant for setters. */
     435             :   false, /* isEliminatable.  Not relevant for setters. */
     436             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     437             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     438             :   false,  /* isTypedMethod.  Only relevant for methods. */
     439             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     440             : };
     441             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     442             : static_assert(0 < 1, "There is no slot for us");
     443             : 
     444             : static bool
     445           0 : get_isAutoLocale(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, JSJitGetterCallArgs args)
     446             : {
     447           0 :   bool result(self->IsAutoLocale());
     448           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     449           0 :   args.rval().setBoolean(result);
     450           0 :   return true;
     451             : }
     452             : 
     453             : static const JSJitInfo isAutoLocale_getterinfo = {
     454             :   { (JSJitGetterOp)get_isAutoLocale },
     455             :   { prototypes::id::IDBIndex },
     456             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     457             :   JSJitInfo::Getter,
     458             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     459             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     460             :   true,  /* isInfallible. False in setters. */
     461             :   false,  /* isMovable.  Not relevant for setters. */
     462             :   false, /* isEliminatable.  Not relevant for setters. */
     463             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     464             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     465             :   false,  /* isTypedMethod.  Only relevant for methods. */
     466             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     467             : };
     468             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     469             : static_assert(0 < 1, "There is no slot for us");
     470             : 
     471             : static bool
     472           0 : openCursor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args)
     473             : {
     474           0 :   JS::Rooted<JS::Value> arg0(cx);
     475           0 :   if (args.hasDefined(0)) {
     476           0 :     arg0 = args[0];
     477             :   } else {
     478           0 :     arg0 = JS::UndefinedValue();
     479             :   }
     480             :   IDBCursorDirection arg1;
     481           0 :   if (args.hasDefined(1)) {
     482             :     {
     483             :       int index;
     484           0 :       if (!FindEnumStringIndex<true>(cx, args[1], IDBCursorDirectionValues::strings, "IDBCursorDirection", "Argument 2 of IDBIndex.openCursor", &index)) {
     485           0 :         return false;
     486             :       }
     487           0 :       MOZ_ASSERT(index >= 0);
     488           0 :       arg1 = static_cast<IDBCursorDirection>(index);
     489             :     }
     490             :   } else {
     491           0 :     arg1 = IDBCursorDirection::Next;
     492             :   }
     493           0 :   binding_detail::FastErrorResult rv;
     494           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->OpenCursor(cx, arg0, arg1, rv)));
     495           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     496           0 :     return false;
     497             :   }
     498           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     499           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     500           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     501           0 :     return false;
     502             :   }
     503           0 :   return true;
     504             : }
     505             : 
     506             : static const JSJitInfo openCursor_methodinfo = {
     507             :   { (JSJitGetterOp)openCursor },
     508             :   { prototypes::id::IDBIndex },
     509             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     510             :   JSJitInfo::Method,
     511             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     512             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     513             :   false,  /* isInfallible. False in setters. */
     514             :   false,  /* isMovable.  Not relevant for setters. */
     515             :   false, /* isEliminatable.  Not relevant for setters. */
     516             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     517             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     518             :   false,  /* isTypedMethod.  Only relevant for methods. */
     519             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     520             : };
     521             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     522             : static_assert(0 < 1, "There is no slot for us");
     523             : 
     524             : static bool
     525           0 : openKeyCursor(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args)
     526             : {
     527           0 :   JS::Rooted<JS::Value> arg0(cx);
     528           0 :   if (args.hasDefined(0)) {
     529           0 :     arg0 = args[0];
     530             :   } else {
     531           0 :     arg0 = JS::UndefinedValue();
     532             :   }
     533             :   IDBCursorDirection arg1;
     534           0 :   if (args.hasDefined(1)) {
     535             :     {
     536             :       int index;
     537           0 :       if (!FindEnumStringIndex<true>(cx, args[1], IDBCursorDirectionValues::strings, "IDBCursorDirection", "Argument 2 of IDBIndex.openKeyCursor", &index)) {
     538           0 :         return false;
     539             :       }
     540           0 :       MOZ_ASSERT(index >= 0);
     541           0 :       arg1 = static_cast<IDBCursorDirection>(index);
     542             :     }
     543             :   } else {
     544           0 :     arg1 = IDBCursorDirection::Next;
     545             :   }
     546           0 :   binding_detail::FastErrorResult rv;
     547           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->OpenKeyCursor(cx, arg0, arg1, rv)));
     548           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     549           0 :     return false;
     550             :   }
     551           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     552           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     553           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     554           0 :     return false;
     555             :   }
     556           0 :   return true;
     557             : }
     558             : 
     559             : static const JSJitInfo openKeyCursor_methodinfo = {
     560             :   { (JSJitGetterOp)openKeyCursor },
     561             :   { prototypes::id::IDBIndex },
     562             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     563             :   JSJitInfo::Method,
     564             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     565             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     566             :   false,  /* isInfallible. False in setters. */
     567             :   false,  /* isMovable.  Not relevant for setters. */
     568             :   false, /* isEliminatable.  Not relevant for setters. */
     569             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     570             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     571             :   false,  /* isTypedMethod.  Only relevant for methods. */
     572             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     573             : };
     574             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     575             : static_assert(0 < 1, "There is no slot for us");
     576             : 
     577             : static bool
     578           0 : get(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args)
     579             : {
     580           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     581           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBIndex.get");
     582             :   }
     583           0 :   JS::Rooted<JS::Value> arg0(cx);
     584           0 :   arg0 = args[0];
     585           0 :   binding_detail::FastErrorResult rv;
     586           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Get(cx, arg0, rv)));
     587           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     588           0 :     return false;
     589             :   }
     590           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     591           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     592           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     593           0 :     return false;
     594             :   }
     595           0 :   return true;
     596             : }
     597             : 
     598             : static const JSJitInfo get_methodinfo = {
     599             :   { (JSJitGetterOp)get },
     600             :   { prototypes::id::IDBIndex },
     601             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     602             :   JSJitInfo::Method,
     603             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     604             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     605             :   false,  /* isInfallible. False in setters. */
     606             :   false,  /* isMovable.  Not relevant for setters. */
     607             :   false, /* isEliminatable.  Not relevant for setters. */
     608             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     609             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     610             :   false,  /* isTypedMethod.  Only relevant for methods. */
     611             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     612             : };
     613             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     614             : static_assert(0 < 1, "There is no slot for us");
     615             : 
     616             : static bool
     617           0 : getKey(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args)
     618             : {
     619           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     620           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "IDBIndex.getKey");
     621             :   }
     622           0 :   JS::Rooted<JS::Value> arg0(cx);
     623           0 :   arg0 = args[0];
     624           0 :   binding_detail::FastErrorResult rv;
     625           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetKey(cx, arg0, rv)));
     626           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     627           0 :     return false;
     628             :   }
     629           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     630           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     631           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     632           0 :     return false;
     633             :   }
     634           0 :   return true;
     635             : }
     636             : 
     637             : static const JSJitInfo getKey_methodinfo = {
     638             :   { (JSJitGetterOp)getKey },
     639             :   { prototypes::id::IDBIndex },
     640             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     641             :   JSJitInfo::Method,
     642             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     643             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     644             :   false,  /* isInfallible. False in setters. */
     645             :   false,  /* isMovable.  Not relevant for setters. */
     646             :   false, /* isEliminatable.  Not relevant for setters. */
     647             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     648             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     649             :   false,  /* isTypedMethod.  Only relevant for methods. */
     650             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     651             : };
     652             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     653             : static_assert(0 < 1, "There is no slot for us");
     654             : 
     655             : static bool
     656           0 : count(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args)
     657             : {
     658           0 :   JS::Rooted<JS::Value> arg0(cx);
     659           0 :   if (args.hasDefined(0)) {
     660           0 :     arg0 = args[0];
     661             :   } else {
     662           0 :     arg0 = JS::UndefinedValue();
     663             :   }
     664           0 :   binding_detail::FastErrorResult rv;
     665           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->Count(cx, arg0, rv)));
     666           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     667           0 :     return false;
     668             :   }
     669           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     670           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     671           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     672           0 :     return false;
     673             :   }
     674           0 :   return true;
     675             : }
     676             : 
     677             : static const JSJitInfo count_methodinfo = {
     678             :   { (JSJitGetterOp)count },
     679             :   { prototypes::id::IDBIndex },
     680             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     681             :   JSJitInfo::Method,
     682             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     683             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     684             :   false,  /* isInfallible. False in setters. */
     685             :   false,  /* isMovable.  Not relevant for setters. */
     686             :   false, /* isEliminatable.  Not relevant for setters. */
     687             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     688             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     689             :   false,  /* isTypedMethod.  Only relevant for methods. */
     690             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     691             : };
     692             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     693             : static_assert(0 < 1, "There is no slot for us");
     694             : 
     695             : static bool
     696           0 : mozGetAll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args)
     697             : {
     698           0 :   JS::Rooted<JS::Value> arg0(cx);
     699           0 :   if (args.hasDefined(0)) {
     700           0 :     arg0 = args[0];
     701             :   } else {
     702           0 :     arg0 = JS::UndefinedValue();
     703             :   }
     704           0 :   Optional<uint32_t> arg1;
     705           0 :   if (args.hasDefined(1)) {
     706           0 :     arg1.Construct();
     707           0 :     if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) {
     708           0 :       return false;
     709             :     }
     710             :   }
     711           0 :   binding_detail::FastErrorResult rv;
     712           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAll(cx, arg0, Constify(arg1), rv)));
     713           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     714           0 :     return false;
     715             :   }
     716           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     717           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     718           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     719           0 :     return false;
     720             :   }
     721           0 :   return true;
     722             : }
     723             : 
     724             : static const JSJitInfo mozGetAll_methodinfo = {
     725             :   { (JSJitGetterOp)mozGetAll },
     726             :   { prototypes::id::IDBIndex },
     727             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     728             :   JSJitInfo::Method,
     729             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     730             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     731             :   false,  /* isInfallible. False in setters. */
     732             :   false,  /* isMovable.  Not relevant for setters. */
     733             :   false, /* isEliminatable.  Not relevant for setters. */
     734             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     735             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     736             :   false,  /* isTypedMethod.  Only relevant for methods. */
     737             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     738             : };
     739             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     740             : static_assert(0 < 1, "There is no slot for us");
     741             : 
     742             : static bool
     743           0 : mozGetAllKeys(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args)
     744             : {
     745           0 :   JS::Rooted<JS::Value> arg0(cx);
     746           0 :   if (args.hasDefined(0)) {
     747           0 :     arg0 = args[0];
     748             :   } else {
     749           0 :     arg0 = JS::UndefinedValue();
     750             :   }
     751           0 :   Optional<uint32_t> arg1;
     752           0 :   if (args.hasDefined(1)) {
     753           0 :     arg1.Construct();
     754           0 :     if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) {
     755           0 :       return false;
     756             :     }
     757             :   }
     758           0 :   binding_detail::FastErrorResult rv;
     759           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAllKeys(cx, arg0, Constify(arg1), rv)));
     760           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     761           0 :     return false;
     762             :   }
     763           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     764           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     765           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     766           0 :     return false;
     767             :   }
     768           0 :   return true;
     769             : }
     770             : 
     771             : static const JSJitInfo mozGetAllKeys_methodinfo = {
     772             :   { (JSJitGetterOp)mozGetAllKeys },
     773             :   { prototypes::id::IDBIndex },
     774             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     775             :   JSJitInfo::Method,
     776             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     777             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     778             :   false,  /* isInfallible. False in setters. */
     779             :   false,  /* isMovable.  Not relevant for setters. */
     780             :   false, /* isEliminatable.  Not relevant for setters. */
     781             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     782             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     783             :   false,  /* isTypedMethod.  Only relevant for methods. */
     784             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     785             : };
     786             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     787             : static_assert(0 < 1, "There is no slot for us");
     788             : 
     789             : static bool
     790           0 : getAll(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args)
     791             : {
     792           0 :   JS::Rooted<JS::Value> arg0(cx);
     793           0 :   if (args.hasDefined(0)) {
     794           0 :     arg0 = args[0];
     795             :   } else {
     796           0 :     arg0 = JS::UndefinedValue();
     797             :   }
     798           0 :   Optional<uint32_t> arg1;
     799           0 :   if (args.hasDefined(1)) {
     800           0 :     arg1.Construct();
     801           0 :     if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) {
     802           0 :       return false;
     803             :     }
     804             :   }
     805           0 :   binding_detail::FastErrorResult rv;
     806           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAll(cx, arg0, Constify(arg1), rv)));
     807           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     808           0 :     return false;
     809             :   }
     810           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     811           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     812           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     813           0 :     return false;
     814             :   }
     815           0 :   return true;
     816             : }
     817             : 
     818             : static const JSJitInfo getAll_methodinfo = {
     819             :   { (JSJitGetterOp)getAll },
     820             :   { prototypes::id::IDBIndex },
     821             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     822             :   JSJitInfo::Method,
     823             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     824             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     825             :   false,  /* isInfallible. False in setters. */
     826             :   false,  /* isMovable.  Not relevant for setters. */
     827             :   false, /* isEliminatable.  Not relevant for setters. */
     828             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     829             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     830             :   false,  /* isTypedMethod.  Only relevant for methods. */
     831             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     832             : };
     833             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     834             : static_assert(0 < 1, "There is no slot for us");
     835             : 
     836             : static bool
     837           0 : getAllKeys(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBIndex* self, const JSJitMethodCallArgs& args)
     838             : {
     839           0 :   JS::Rooted<JS::Value> arg0(cx);
     840           0 :   if (args.hasDefined(0)) {
     841           0 :     arg0 = args[0];
     842             :   } else {
     843           0 :     arg0 = JS::UndefinedValue();
     844             :   }
     845           0 :   Optional<uint32_t> arg1;
     846           0 :   if (args.hasDefined(1)) {
     847           0 :     arg1.Construct();
     848           0 :     if (!ValueToPrimitive<uint32_t, eEnforceRange>(cx, args[1], &arg1.Value())) {
     849           0 :       return false;
     850             :     }
     851             :   }
     852           0 :   binding_detail::FastErrorResult rv;
     853           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBRequest>(self->GetAllKeys(cx, arg0, Constify(arg1), rv)));
     854           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     855           0 :     return false;
     856             :   }
     857           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     858           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     859           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     860           0 :     return false;
     861             :   }
     862           0 :   return true;
     863             : }
     864             : 
     865             : static const JSJitInfo getAllKeys_methodinfo = {
     866             :   { (JSJitGetterOp)getAllKeys },
     867             :   { prototypes::id::IDBIndex },
     868             :   { PrototypeTraits<prototypes::id::IDBIndex>::Depth },
     869             :   JSJitInfo::Method,
     870             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     871             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     872             :   false,  /* isInfallible. False in setters. */
     873             :   false,  /* isMovable.  Not relevant for setters. */
     874             :   false, /* isEliminatable.  Not relevant for setters. */
     875             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     876             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     877             :   false,  /* isTypedMethod.  Only relevant for methods. */
     878             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     879             : };
     880             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     881             : static_assert(0 < 1, "There is no slot for us");
     882             : 
     883             : static bool
     884           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     885             : {
     886           0 :   mozilla::dom::IDBIndex* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBIndex>(obj);
     887             :   // We don't want to preserve if we don't have a wrapper, and we
     888             :   // obviously can't preserve if we're not initialized.
     889           0 :   if (self && self->GetWrapperPreserveColor()) {
     890           0 :     PreserveWrapper(self);
     891             :   }
     892           0 :   return true;
     893             : }
     894             : 
     895             : static void
     896           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     897             : {
     898           0 :   mozilla::dom::IDBIndex* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBIndex>(obj);
     899           0 :   if (self) {
     900           0 :     ClearWrapper(self, self, obj);
     901           0 :     AddForDeferredFinalization<mozilla::dom::IDBIndex>(self);
     902             :   }
     903           0 : }
     904             : 
     905             : static void
     906           0 : _objectMoved(JSObject* obj, const JSObject* old)
     907             : {
     908           0 :   mozilla::dom::IDBIndex* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBIndex>(obj);
     909           0 :   if (self) {
     910           0 :     UpdateWrapper(self, self, obj, old);
     911             :   }
     912           0 : }
     913             : 
     914             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     915             : #if defined(__clang__)
     916             : #pragma clang diagnostic push
     917             : #pragma clang diagnostic ignored "-Wmissing-braces"
     918             : #endif
     919             : static const JSFunctionSpec sMethods_specs[] = {
     920             :   JS_FNSPEC("openCursor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&openCursor_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     921             :   JS_FNSPEC("openKeyCursor", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&openKeyCursor_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     922             :   JS_FNSPEC("get", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&get_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     923             :   JS_FNSPEC("getKey", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getKey_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     924             :   JS_FNSPEC("count", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&count_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     925             :   JS_FNSPEC("mozGetAll", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&mozGetAll_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     926             :   JS_FNSPEC("mozGetAllKeys", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&mozGetAllKeys_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     927             :   JS_FNSPEC("getAll", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getAll_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     928             :   JS_FNSPEC("getAllKeys", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getAllKeys_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     929             :   JS_FS_END
     930             : };
     931             : #if defined(__clang__)
     932             : #pragma clang diagnostic pop
     933             : #endif
     934             : 
     935             : 
     936             : // Can't be const because the pref-enabled boolean needs to be writable
     937             : static Prefable<const JSFunctionSpec> sMethods[] = {
     938             :   { nullptr, &sMethods_specs[0] },
     939             :   { nullptr, nullptr }
     940             : };
     941             : 
     942             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     943             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     944             : static_assert(9 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     945             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     946             : 
     947             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     948             : #if defined(__clang__)
     949             : #pragma clang diagnostic push
     950             : #pragma clang diagnostic ignored "-Wmissing-braces"
     951             : #endif
     952             : static const JSPropertySpec sAttributes_specs[] = {
     953             :   { "name", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &name_getterinfo, GenericBindingSetter, &name_setterinfo },
     954             :   { "objectStore", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &objectStore_getterinfo, nullptr, nullptr },
     955             :   { "keyPath", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &keyPath_getterinfo, nullptr, nullptr },
     956             :   { "multiEntry", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &multiEntry_getterinfo, nullptr, nullptr },
     957             :   { "unique", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &unique_getterinfo, nullptr, nullptr },
     958             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr },
     959             :   { "locale", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &locale_getterinfo, nullptr, nullptr },
     960             :   { "isAutoLocale", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &isAutoLocale_getterinfo, nullptr, nullptr },
     961             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     962             : };
     963             : #if defined(__clang__)
     964             : #pragma clang diagnostic pop
     965             : #endif
     966             : 
     967             : static PrefableDisablers sAttributes_disablers6 = {
     968             :   true, false, 0, &mozilla::dom::IndexedDatabaseManager::ExperimentalFeaturesEnabled
     969             : };
     970             : 
     971             : // Can't be const because the pref-enabled boolean needs to be writable
     972             : static Prefable<const JSPropertySpec> sAttributes[] = {
     973             :   { nullptr, &sAttributes_specs[0] },
     974             :   { &sAttributes_disablers6, &sAttributes_specs[6] },
     975             :   { nullptr, nullptr }
     976             : };
     977             : 
     978             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     979             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     980             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     981             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     982             : 
     983             : 
     984             : static uint16_t sNativeProperties_sortedPropertyIndices[16];
     985             : static PropertyInfo sNativeProperties_propertyInfos[16];
     986             : 
     987             : static const NativePropertiesN<2> sNativeProperties = {
     988             :   false, 0,
     989             :   false, 0,
     990             :   true,  0 /* sMethods */,
     991             :   true,  1 /* sAttributes */,
     992             :   false, 0,
     993             :   false, 0,
     994             :   false, 0,
     995             :   -1,
     996             :   16,
     997             :   sNativeProperties_sortedPropertyIndices,
     998             :   {
     999             :     { sMethods, &sNativeProperties_propertyInfos[0] },
    1000             :     { sAttributes, &sNativeProperties_propertyInfos[9] }
    1001             :   }
    1002             : };
    1003             : static_assert(16 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
    1004             :     "We have a property info count that is oversized");
    1005             : 
    1006             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
    1007             :   {
    1008             :     "Function",
    1009             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
    1010             :     &sBoringInterfaceObjectClassClassOps,
    1011             :     JS_NULL_CLASS_SPEC,
    1012             :     JS_NULL_CLASS_EXT,
    1013             :     &sInterfaceObjectClassObjectOps
    1014             :   },
    1015             :   eInterface,
    1016             :   true,
    1017             :   prototypes::id::IDBIndex,
    1018             :   PrototypeTraits<prototypes::id::IDBIndex>::Depth,
    1019             :   sNativePropertyHooks,
    1020             :   "function IDBIndex() {\n    [native code]\n}",
    1021             :   JS::GetRealmFunctionPrototype
    1022             : };
    1023             : 
    1024             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
    1025             :   {
    1026             :     "IDBIndexPrototype",
    1027             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
    1028             :     JS_NULL_CLASS_OPS,
    1029             :     JS_NULL_CLASS_SPEC,
    1030             :     JS_NULL_CLASS_EXT,
    1031             :     JS_NULL_OBJECT_OPS
    1032             :   },
    1033             :   eInterfacePrototype,
    1034             :   false,
    1035             :   prototypes::id::IDBIndex,
    1036             :   PrototypeTraits<prototypes::id::IDBIndex>::Depth,
    1037             :   sNativePropertyHooks,
    1038             :   "[object IDBIndexPrototype]",
    1039             :   JS::GetRealmObjectPrototype
    1040             : };
    1041             : 
    1042             : JSObject*
    1043           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
    1044             : {
    1045           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
    1046             : }
    1047             : 
    1048             : static const js::ClassOps sClassOps = {
    1049             :   _addProperty, /* addProperty */
    1050             :   nullptr,               /* delProperty */
    1051             :   nullptr,               /* getProperty */
    1052             :   nullptr,               /* setProperty */
    1053             :   nullptr,               /* enumerate */
    1054             :   nullptr, /* newEnumerate */
    1055             :   nullptr, /* resolve */
    1056             :   nullptr, /* mayResolve */
    1057             :   _finalize, /* finalize */
    1058             :   nullptr, /* call */
    1059             :   nullptr,               /* hasInstance */
    1060             :   nullptr,               /* construct */
    1061             :   nullptr, /* trace */
    1062             : };
    1063             : 
    1064             : static const js::ClassExtension sClassExtension = {
    1065             :   nullptr, /* weakmapKeyDelegateOp */
    1066             :   _objectMoved /* objectMovedOp */
    1067             : };
    1068             : 
    1069             : static const DOMJSClass sClass = {
    1070             :   { "IDBIndex",
    1071             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
    1072             :     &sClassOps,
    1073             :     JS_NULL_CLASS_SPEC,
    1074             :     &sClassExtension,
    1075             :     JS_NULL_OBJECT_OPS
    1076             :   },
    1077             :   { prototypes::id::IDBIndex, 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 },
    1078             :   IsBaseOf<nsISupports, mozilla::dom::IDBIndex >::value,
    1079             :   sNativePropertyHooks,
    1080             :   FindAssociatedGlobalForNative<mozilla::dom::IDBIndex>::Get,
    1081             :   GetProtoObjectHandle,
    1082             :   GetCCParticipant<mozilla::dom::IDBIndex>::Get()
    1083             : };
    1084             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
    1085             :               "Must have the right minimal number of reserved slots.");
    1086             : static_assert(1 >= 1,
    1087             :               "Must have enough reserved slots.");
    1088             : 
    1089             : const JSClass*
    1090           0 : GetJSClass()
    1091             : {
    1092           0 :   return sClass.ToJSClass();
    1093             : }
    1094             : 
    1095             : bool
    1096           0 : Wrap(JSContext* aCx, mozilla::dom::IDBIndex* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
    1097             : {
    1098             :   MOZ_ASSERT(static_cast<mozilla::dom::IDBIndex*>(aObject) ==
    1099             :              reinterpret_cast<mozilla::dom::IDBIndex*>(aObject),
    1100             :              "Multiple inheritance for mozilla::dom::IDBIndex is broken.");
    1101           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
    1102           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
    1103           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
    1104             :              "You should probably not be using Wrap() directly; use "
    1105             :              "GetOrCreateDOMReflector instead");
    1106             : 
    1107           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
    1108             :              "nsISupports must be on our primary inheritance chain");
    1109             : 
    1110           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
    1111           0 :   if (!global) {
    1112           0 :     return false;
    1113             :   }
    1114           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
    1115           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
    1116             : 
    1117             :   // That might have ended up wrapping us already, due to the wonders
    1118             :   // of XBL.  Check for that, and bail out as needed.
    1119           0 :   aReflector.set(aCache->GetWrapper());
    1120           0 :   if (aReflector) {
    1121             : #ifdef DEBUG
    1122           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
    1123             : #endif // DEBUG
    1124           0 :     return true;
    1125             :   }
    1126             : 
    1127           0 :   JSAutoCompartment ac(aCx, global);
    1128           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
    1129           0 :   if (!canonicalProto) {
    1130           0 :     return false;
    1131             :   }
    1132           0 :   JS::Rooted<JSObject*> proto(aCx);
    1133           0 :   if (aGivenProto) {
    1134           0 :     proto = aGivenProto;
    1135             :     // Unfortunately, while aGivenProto was in the compartment of aCx
    1136             :     // coming in, we changed compartments to that of "parent" so may need
    1137             :     // to wrap the proto here.
    1138           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
    1139           0 :       if (!JS_WrapObject(aCx, &proto)) {
    1140           0 :         return false;
    1141             :       }
    1142             :     }
    1143             :   } else {
    1144           0 :     proto = canonicalProto;
    1145             :   }
    1146             : 
    1147           0 :   BindingJSObjectCreator<mozilla::dom::IDBIndex> creator(aCx);
    1148           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
    1149           0 :   if (!aReflector) {
    1150           0 :     return false;
    1151             :   }
    1152             : 
    1153           0 :   aCache->SetWrapper(aReflector);
    1154           0 :   creator.InitializationSucceeded();
    1155             : 
    1156           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
    1157             :              aCache->GetWrapperPreserveColor() == aReflector);
    1158             :   // If proto != canonicalProto, we have to preserve our wrapper;
    1159             :   // otherwise we won't be able to properly recreate it later, since
    1160             :   // we won't know what proto to use.  Note that we don't check
    1161             :   // aGivenProto here, since it's entirely possible (and even
    1162             :   // somewhat common) to have a non-null aGivenProto which is the
    1163             :   // same as canonicalProto.
    1164           0 :   if (proto != canonicalProto) {
    1165           0 :     PreserveWrapper(aObject);
    1166             :   }
    1167             : 
    1168           0 :   return true;
    1169             : }
    1170             : 
    1171             : const NativePropertyHooks sNativePropertyHooks[] = { {
    1172             :   nullptr,
    1173             :   nullptr,
    1174             :   nullptr,
    1175             :   { sNativeProperties.Upcast(), nullptr },
    1176             :   prototypes::id::IDBIndex,
    1177             :   constructors::id::IDBIndex,
    1178             :   nullptr,
    1179             :   &DefaultXrayExpandoObjectClass
    1180             : } };
    1181             : 
    1182             : void
    1183          15 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
    1184             : {
    1185          30 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
    1186          15 :   if (!parentProto) {
    1187           0 :     return;
    1188             :   }
    1189             : 
    1190          30 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
    1191          15 :   if (!constructorProto) {
    1192           0 :     return;
    1193             :   }
    1194             : 
    1195             :   static bool sIdsInited = false;
    1196          15 :   if (!sIdsInited && NS_IsMainThread()) {
    1197           1 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
    1198           0 :       return;
    1199             :     }
    1200           1 :     sIdsInited = true;
    1201             :   }
    1202             : 
    1203          15 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBIndex);
    1204          15 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBIndex);
    1205          30 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
    1206             :                               &sPrototypeClass.mBase, protoCache,
    1207             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
    1208             :                               interfaceCache,
    1209             :                               sNativeProperties.Upcast(),
    1210             :                               nullptr,
    1211             :                               "IDBIndex", aDefineOnGlobal,
    1212             :                               nullptr,
    1213          15 :                               false);
    1214             : }
    1215             : 
    1216             : JS::Handle<JSObject*>
    1217           0 : GetProtoObjectHandle(JSContext* aCx)
    1218             : {
    1219             :   /* Get the interface prototype object for this class.  This will create the
    1220             :      object as needed. */
    1221           0 :   bool aDefineOnGlobal = true;
    1222             : 
    1223             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1224           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1225           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1226           0 :     return nullptr;
    1227             :   }
    1228             : 
    1229             :   /* Check to see whether the interface objects are already installed */
    1230           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1231           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::IDBIndex)) {
    1232           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1233           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1234             :   }
    1235             : 
    1236             :   /*
    1237             :    * The object might _still_ be null, but that's OK.
    1238             :    *
    1239             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1240             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1241             :    * changed after they have been set.
    1242             :    *
    1243             :    * Calling address() avoids the read read barrier that does gray
    1244             :    * unmarking, but it's not possible for the object to be gray here.
    1245             :    */
    1246             : 
    1247           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::IDBIndex);
    1248           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1249           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1250             : }
    1251             : 
    1252             : JS::Handle<JSObject*>
    1253          15 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1254             : {
    1255             :   /* Get the interface object for this class.  This will create the object as
    1256             :      needed. */
    1257             : 
    1258             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1259          15 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1260          15 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1261           0 :     return nullptr;
    1262             :   }
    1263             : 
    1264             :   /* Check to see whether the interface objects are already installed */
    1265          15 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1266          15 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::IDBIndex)) {
    1267          30 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1268          15 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1269             :   }
    1270             : 
    1271             :   /*
    1272             :    * The object might _still_ be null, but that's OK.
    1273             :    *
    1274             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1275             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1276             :    * changed after they have been set.
    1277             :    *
    1278             :    * Calling address() avoids the read read barrier that does gray
    1279             :    * unmarking, but it's not possible for the object to be gray here.
    1280             :    */
    1281             : 
    1282          15 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::IDBIndex);
    1283          15 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1284          15 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1285             : }
    1286             : 
    1287             : JSObject*
    1288          15 : GetConstructorObject(JSContext* aCx)
    1289             : {
    1290          15 :   return GetConstructorObjectHandle(aCx);
    1291             : }
    1292             : 
    1293             : } // namespace IDBIndexBinding
    1294             : 
    1295             : 
    1296             : 
    1297             : } // namespace dom
    1298             : } // namespace mozilla

Generated by: LCOV version 1.13