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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM IDBMutableFile.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "EventHandlerBinding.h"
       4             : #include "EventTargetBinding.h"
       5             : #include "IDBMutableFileBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/UseCounter.h"
       9             : #include "mozilla/dom/BindingUtils.h"
      10             : #include "mozilla/dom/DOMJSClass.h"
      11             : #include "mozilla/dom/DOMRequest.h"
      12             : #include "mozilla/dom/IDBDatabase.h"
      13             : #include "mozilla/dom/IDBFileHandle.h"
      14             : #include "mozilla/dom/IDBMutableFile.h"
      15             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      16             : #include "mozilla/dom/Nullable.h"
      17             : #include "mozilla/dom/XrayExpandoClass.h"
      18             : 
      19             : namespace mozilla {
      20             : namespace dom {
      21             : 
      22             : namespace IDBMutableFileBinding {
      23             : 
      24             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
      25             :               "Can't inherit from an interface with a different ownership model.");
      26             : 
      27             : static bool
      28           0 : get_name(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
      29             : {
      30           0 :   DOMString result;
      31           0 :   self->GetName(result);
      32           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      33           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      34           0 :     return false;
      35             :   }
      36           0 :   return true;
      37             : }
      38             : 
      39             : static const JSJitInfo name_getterinfo = {
      40             :   { (JSJitGetterOp)get_name },
      41             :   { prototypes::id::IDBMutableFile },
      42             :   { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
      43             :   JSJitInfo::Getter,
      44             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      45             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      46             :   false,  /* isInfallible. False in setters. */
      47             :   false,  /* isMovable.  Not relevant for setters. */
      48             :   false, /* isEliminatable.  Not relevant for setters. */
      49             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      50             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      51             :   false,  /* isTypedMethod.  Only relevant for methods. */
      52             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      53             : };
      54             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      55             : static_assert(0 < 1, "There is no slot for us");
      56             : 
      57             : static bool
      58           0 : get_type(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
      59             : {
      60           0 :   DOMString result;
      61           0 :   self->GetType(result);
      62           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      63           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      64           0 :     return false;
      65             :   }
      66           0 :   return true;
      67             : }
      68             : 
      69             : static const JSJitInfo type_getterinfo = {
      70             :   { (JSJitGetterOp)get_type },
      71             :   { prototypes::id::IDBMutableFile },
      72             :   { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
      73             :   JSJitInfo::Getter,
      74             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      75             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      76             :   false,  /* isInfallible. False in setters. */
      77             :   false,  /* isMovable.  Not relevant for setters. */
      78             :   false, /* isEliminatable.  Not relevant for setters. */
      79             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      80             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      81             :   false,  /* isTypedMethod.  Only relevant for methods. */
      82             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      83             : };
      84             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      85             : static_assert(0 < 1, "There is no slot for us");
      86             : 
      87             : static bool
      88           0 : get_database(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
      89             : {
      90           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBDatabase>(self->Database()));
      91           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      92           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
      93           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
      94           0 :     return false;
      95             :   }
      96           0 :   return true;
      97             : }
      98             : 
      99             : static const JSJitInfo database_getterinfo = {
     100             :   { (JSJitGetterOp)get_database },
     101             :   { prototypes::id::IDBMutableFile },
     102             :   { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
     103             :   JSJitInfo::Getter,
     104             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     105             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     106             :   false,  /* isInfallible. False in setters. */
     107             :   false,  /* isMovable.  Not relevant for setters. */
     108             :   false, /* isEliminatable.  Not relevant for setters. */
     109             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     110             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     111             :   false,  /* isTypedMethod.  Only relevant for methods. */
     112             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     113             : };
     114             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     115             : static_assert(0 < 1, "There is no slot for us");
     116             : 
     117             : static bool
     118           0 : open(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, const JSJitMethodCallArgs& args)
     119             : {
     120             :   FileMode arg0;
     121           0 :   if (args.hasDefined(0)) {
     122             :     {
     123             :       int index;
     124           0 :       if (!FindEnumStringIndex<true>(cx, args[0], FileModeValues::strings, "FileMode", "Argument 1 of IDBMutableFile.open", &index)) {
     125           0 :         return false;
     126             :       }
     127           0 :       MOZ_ASSERT(index >= 0);
     128           0 :       arg0 = static_cast<FileMode>(index);
     129             :     }
     130             :   } else {
     131           0 :     arg0 = FileMode::Readonly;
     132             :   }
     133           0 :   binding_detail::FastErrorResult rv;
     134           0 :   auto result(StrongOrRawPtr<mozilla::dom::IDBFileHandle>(self->Open(arg0, rv)));
     135           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     136           0 :     return false;
     137             :   }
     138           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     139           0 :   SetDocumentAndPageUseCounter(cx, obj, eUseCounter_IDBMutableFile_open);
     140           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     141           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     142           0 :     return false;
     143             :   }
     144           0 :   return true;
     145             : }
     146             : 
     147             : static const JSJitInfo open_methodinfo = {
     148             :   { (JSJitGetterOp)open },
     149             :   { prototypes::id::IDBMutableFile },
     150             :   { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
     151             :   JSJitInfo::Method,
     152             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     153             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     154             :   false,  /* isInfallible. False in setters. */
     155             :   false,  /* isMovable.  Not relevant for setters. */
     156             :   false, /* isEliminatable.  Not relevant for setters. */
     157             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     158             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     159             :   false,  /* isTypedMethod.  Only relevant for methods. */
     160             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     161             : };
     162             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     163             : static_assert(0 < 1, "There is no slot for us");
     164             : 
     165             : static bool
     166           0 : getFile(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, const JSJitMethodCallArgs& args)
     167             : {
     168           0 :   binding_detail::FastErrorResult rv;
     169           0 :   auto result(StrongOrRawPtr<mozilla::dom::DOMRequest>(self->GetFile(rv)));
     170           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     171           0 :     return false;
     172             :   }
     173           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     174           0 :   SetDocumentAndPageUseCounter(cx, obj, eUseCounter_IDBMutableFile_getFile);
     175           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     176           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     177           0 :     return false;
     178             :   }
     179           0 :   return true;
     180             : }
     181             : 
     182             : static const JSJitInfo getFile_methodinfo = {
     183             :   { (JSJitGetterOp)getFile },
     184             :   { prototypes::id::IDBMutableFile },
     185             :   { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
     186             :   JSJitInfo::Method,
     187             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     188             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     189             :   false,  /* isInfallible. False in setters. */
     190             :   false,  /* isMovable.  Not relevant for setters. */
     191             :   false, /* isEliminatable.  Not relevant for setters. */
     192             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     193             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     194             :   false,  /* isTypedMethod.  Only relevant for methods. */
     195             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     196             : };
     197             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     198             : static_assert(0 < 1, "There is no slot for us");
     199             : 
     200             : static bool
     201           0 : get_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
     202             : {
     203           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnabort());
     204           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     205           0 :   if (result) {
     206           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     207           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     208           0 :       return false;
     209             :     }
     210           0 :     return true;
     211             :   } else {
     212           0 :     args.rval().setNull();
     213           0 :     return true;
     214             :   }
     215             : }
     216             : 
     217             : static bool
     218           0 : set_onabort(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitSetterCallArgs args)
     219             : {
     220           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     221           0 :   if (args[0].isObject()) {
     222             :     { // scope for tempRoot
     223           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     224           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     225             :     }
     226             :   } else {
     227           0 :     arg0 = nullptr;
     228             :   }
     229           0 :   self->SetOnabort(Constify(arg0));
     230           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     231             : 
     232           0 :   return true;
     233             : }
     234             : 
     235             : static const JSJitInfo onabort_getterinfo = {
     236             :   { (JSJitGetterOp)get_onabort },
     237             :   { prototypes::id::IDBMutableFile },
     238             :   { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
     239             :   JSJitInfo::Getter,
     240             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     241             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     242             :   false,  /* isInfallible. False in setters. */
     243             :   false,  /* isMovable.  Not relevant for setters. */
     244             :   false, /* isEliminatable.  Not relevant for setters. */
     245             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     246             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     247             :   false,  /* isTypedMethod.  Only relevant for methods. */
     248             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     249             : };
     250             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     251             : static_assert(0 < 1, "There is no slot for us");
     252             : static const JSJitInfo onabort_setterinfo = {
     253             :   { (JSJitGetterOp)set_onabort },
     254             :   { prototypes::id::IDBMutableFile },
     255             :   { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
     256             :   JSJitInfo::Setter,
     257             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     258             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     259             :   false,  /* isInfallible. False in setters. */
     260             :   false,  /* isMovable.  Not relevant for setters. */
     261             :   false, /* isEliminatable.  Not relevant for setters. */
     262             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     263             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     264             :   false,  /* isTypedMethod.  Only relevant for methods. */
     265             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     266             : };
     267             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     268             : static_assert(0 < 1, "There is no slot for us");
     269             : 
     270             : static bool
     271           0 : get_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitGetterCallArgs args)
     272             : {
     273           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnerror());
     274           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     275           0 :   if (result) {
     276           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     277           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     278           0 :       return false;
     279             :     }
     280           0 :     return true;
     281             :   } else {
     282           0 :     args.rval().setNull();
     283           0 :     return true;
     284             :   }
     285             : }
     286             : 
     287             : static bool
     288           0 : set_onerror(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::IDBMutableFile* self, JSJitSetterCallArgs args)
     289             : {
     290           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     291           0 :   if (args[0].isObject()) {
     292             :     { // scope for tempRoot
     293           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     294           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     295             :     }
     296             :   } else {
     297           0 :     arg0 = nullptr;
     298             :   }
     299           0 :   self->SetOnerror(Constify(arg0));
     300           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     301             : 
     302           0 :   return true;
     303             : }
     304             : 
     305             : static const JSJitInfo onerror_getterinfo = {
     306             :   { (JSJitGetterOp)get_onerror },
     307             :   { prototypes::id::IDBMutableFile },
     308             :   { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
     309             :   JSJitInfo::Getter,
     310             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     311             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     312             :   false,  /* isInfallible. False in setters. */
     313             :   false,  /* isMovable.  Not relevant for setters. */
     314             :   false, /* isEliminatable.  Not relevant for setters. */
     315             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     316             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     317             :   false,  /* isTypedMethod.  Only relevant for methods. */
     318             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     319             : };
     320             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     321             : static_assert(0 < 1, "There is no slot for us");
     322             : static const JSJitInfo onerror_setterinfo = {
     323             :   { (JSJitGetterOp)set_onerror },
     324             :   { prototypes::id::IDBMutableFile },
     325             :   { PrototypeTraits<prototypes::id::IDBMutableFile>::Depth },
     326             :   JSJitInfo::Setter,
     327             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     328             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     329             :   false,  /* isInfallible. False in setters. */
     330             :   false,  /* isMovable.  Not relevant for setters. */
     331             :   false, /* isEliminatable.  Not relevant for setters. */
     332             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     333             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     334             :   false,  /* isTypedMethod.  Only relevant for methods. */
     335             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     336             : };
     337             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     338             : static_assert(0 < 1, "There is no slot for us");
     339             : 
     340             : static bool
     341           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     342             : {
     343           0 :   mozilla::dom::IDBMutableFile* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBMutableFile>(obj);
     344             :   // We don't want to preserve if we don't have a wrapper, and we
     345             :   // obviously can't preserve if we're not initialized.
     346           0 :   if (self && self->GetWrapperPreserveColor()) {
     347           0 :     PreserveWrapper(self);
     348             :   }
     349           0 :   return true;
     350             : }
     351             : 
     352             : static void
     353           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     354             : {
     355           0 :   mozilla::dom::IDBMutableFile* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBMutableFile>(obj);
     356           0 :   if (self) {
     357           0 :     ClearWrapper(self, self, obj);
     358           0 :     AddForDeferredFinalization<mozilla::dom::IDBMutableFile>(self);
     359             :   }
     360           0 : }
     361             : 
     362             : static void
     363           0 : _objectMoved(JSObject* obj, const JSObject* old)
     364             : {
     365           0 :   mozilla::dom::IDBMutableFile* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::IDBMutableFile>(obj);
     366           0 :   if (self) {
     367           0 :     UpdateWrapper(self, self, obj, old);
     368             :   }
     369           0 : }
     370             : 
     371             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     372             : #if defined(__clang__)
     373             : #pragma clang diagnostic push
     374             : #pragma clang diagnostic ignored "-Wmissing-braces"
     375             : #endif
     376             : static const JSFunctionSpec sMethods_specs[] = {
     377             :   JS_FNSPEC("open", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&open_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     378             :   JS_FNSPEC("getFile", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getFile_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     379             :   JS_FS_END
     380             : };
     381             : #if defined(__clang__)
     382             : #pragma clang diagnostic pop
     383             : #endif
     384             : 
     385             : 
     386             : // Can't be const because the pref-enabled boolean needs to be writable
     387             : static Prefable<const JSFunctionSpec> sMethods[] = {
     388             :   { nullptr, &sMethods_specs[0] },
     389             :   { nullptr, nullptr }
     390             : };
     391             : 
     392             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     393             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     394             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     395             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     396             : 
     397             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     398             : #if defined(__clang__)
     399             : #pragma clang diagnostic push
     400             : #pragma clang diagnostic ignored "-Wmissing-braces"
     401             : #endif
     402             : static const JSPropertySpec sAttributes_specs[] = {
     403             :   { "name", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &name_getterinfo, nullptr, nullptr },
     404             :   { "type", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &type_getterinfo, nullptr, nullptr },
     405             :   { "database", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &database_getterinfo, nullptr, nullptr },
     406             :   { "onabort", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onabort_getterinfo, GenericBindingSetter, &onabort_setterinfo },
     407             :   { "onerror", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onerror_getterinfo, GenericBindingSetter, &onerror_setterinfo },
     408             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     409             : };
     410             : #if defined(__clang__)
     411             : #pragma clang diagnostic pop
     412             : #endif
     413             : 
     414             : 
     415             : // Can't be const because the pref-enabled boolean needs to be writable
     416             : static Prefable<const JSPropertySpec> sAttributes[] = {
     417             :   { nullptr, &sAttributes_specs[0] },
     418             :   { nullptr, nullptr }
     419             : };
     420             : 
     421             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     422             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     423             : static_assert(5 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     424             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     425             : 
     426             : 
     427             : static uint16_t sNativeProperties_sortedPropertyIndices[7];
     428             : static PropertyInfo sNativeProperties_propertyInfos[7];
     429             : 
     430             : static const NativePropertiesN<2> sNativeProperties = {
     431             :   false, 0,
     432             :   false, 0,
     433             :   true,  0 /* sMethods */,
     434             :   true,  1 /* sAttributes */,
     435             :   false, 0,
     436             :   false, 0,
     437             :   false, 0,
     438             :   -1,
     439             :   7,
     440             :   sNativeProperties_sortedPropertyIndices,
     441             :   {
     442             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     443             :     { sAttributes, &sNativeProperties_propertyInfos[2] }
     444             :   }
     445             : };
     446             : static_assert(7 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     447             :     "We have a property info count that is oversized");
     448             : 
     449             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     450             :   {
     451             :     "Function",
     452             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     453             :     &sBoringInterfaceObjectClassClassOps,
     454             :     JS_NULL_CLASS_SPEC,
     455             :     JS_NULL_CLASS_EXT,
     456             :     &sInterfaceObjectClassObjectOps
     457             :   },
     458             :   eInterface,
     459             :   true,
     460             :   prototypes::id::IDBMutableFile,
     461             :   PrototypeTraits<prototypes::id::IDBMutableFile>::Depth,
     462             :   sNativePropertyHooks,
     463             :   "function IDBMutableFile() {\n    [native code]\n}",
     464             :   EventTargetBinding::GetConstructorObject
     465             : };
     466             : 
     467             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     468             :   {
     469             :     "IDBMutableFilePrototype",
     470             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     471             :     JS_NULL_CLASS_OPS,
     472             :     JS_NULL_CLASS_SPEC,
     473             :     JS_NULL_CLASS_EXT,
     474             :     JS_NULL_OBJECT_OPS
     475             :   },
     476             :   eInterfacePrototype,
     477             :   false,
     478             :   prototypes::id::IDBMutableFile,
     479             :   PrototypeTraits<prototypes::id::IDBMutableFile>::Depth,
     480             :   sNativePropertyHooks,
     481             :   "[object IDBMutableFilePrototype]",
     482             :   EventTargetBinding::GetProtoObject
     483             : };
     484             : 
     485             : JSObject*
     486           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     487             : {
     488           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     489             : }
     490             : 
     491             : static const js::ClassOps sClassOps = {
     492             :   _addProperty, /* addProperty */
     493             :   nullptr,               /* delProperty */
     494             :   nullptr,               /* getProperty */
     495             :   nullptr,               /* setProperty */
     496             :   nullptr,               /* enumerate */
     497             :   nullptr, /* newEnumerate */
     498             :   nullptr, /* resolve */
     499             :   nullptr, /* mayResolve */
     500             :   _finalize, /* finalize */
     501             :   nullptr, /* call */
     502             :   nullptr,               /* hasInstance */
     503             :   nullptr,               /* construct */
     504             :   nullptr, /* trace */
     505             : };
     506             : 
     507             : static const js::ClassExtension sClassExtension = {
     508             :   nullptr, /* weakmapKeyDelegateOp */
     509             :   _objectMoved /* objectMovedOp */
     510             : };
     511             : 
     512             : static const DOMJSClass sClass = {
     513             :   { "IDBMutableFile",
     514             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     515             :     &sClassOps,
     516             :     JS_NULL_CLASS_SPEC,
     517             :     &sClassExtension,
     518             :     JS_NULL_OBJECT_OPS
     519             :   },
     520             :   { prototypes::id::EventTarget, prototypes::id::IDBMutableFile, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     521             :   IsBaseOf<nsISupports, mozilla::dom::IDBMutableFile >::value,
     522             :   sNativePropertyHooks,
     523             :   FindAssociatedGlobalForNative<mozilla::dom::IDBMutableFile>::Get,
     524             :   GetProtoObjectHandle,
     525             :   GetCCParticipant<mozilla::dom::IDBMutableFile>::Get()
     526             : };
     527             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     528             :               "Must have the right minimal number of reserved slots.");
     529             : static_assert(1 >= 1,
     530             :               "Must have enough reserved slots.");
     531             : 
     532             : const JSClass*
     533           0 : GetJSClass()
     534             : {
     535           0 :   return sClass.ToJSClass();
     536             : }
     537             : 
     538             : bool
     539           0 : Wrap(JSContext* aCx, mozilla::dom::IDBMutableFile* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     540             : {
     541             :   MOZ_ASSERT(static_cast<mozilla::dom::IDBMutableFile*>(aObject) ==
     542             :              reinterpret_cast<mozilla::dom::IDBMutableFile*>(aObject),
     543             :              "Multiple inheritance for mozilla::dom::IDBMutableFile is broken.");
     544             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     545             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     546             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     547           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     548           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     549           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     550             :              "You should probably not be using Wrap() directly; use "
     551             :              "GetOrCreateDOMReflector instead");
     552             : 
     553           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     554             :              "nsISupports must be on our primary inheritance chain");
     555             : 
     556           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     557           0 :   if (!global) {
     558           0 :     return false;
     559             :   }
     560           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     561           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     562             : 
     563             :   // That might have ended up wrapping us already, due to the wonders
     564             :   // of XBL.  Check for that, and bail out as needed.
     565           0 :   aReflector.set(aCache->GetWrapper());
     566           0 :   if (aReflector) {
     567             : #ifdef DEBUG
     568           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     569             : #endif // DEBUG
     570           0 :     return true;
     571             :   }
     572             : 
     573           0 :   JSAutoCompartment ac(aCx, global);
     574           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     575           0 :   if (!canonicalProto) {
     576           0 :     return false;
     577             :   }
     578           0 :   JS::Rooted<JSObject*> proto(aCx);
     579           0 :   if (aGivenProto) {
     580           0 :     proto = aGivenProto;
     581             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     582             :     // coming in, we changed compartments to that of "parent" so may need
     583             :     // to wrap the proto here.
     584           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     585           0 :       if (!JS_WrapObject(aCx, &proto)) {
     586           0 :         return false;
     587             :       }
     588             :     }
     589             :   } else {
     590           0 :     proto = canonicalProto;
     591             :   }
     592             : 
     593           0 :   BindingJSObjectCreator<mozilla::dom::IDBMutableFile> creator(aCx);
     594           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     595           0 :   if (!aReflector) {
     596           0 :     return false;
     597             :   }
     598             : 
     599           0 :   aCache->SetWrapper(aReflector);
     600           0 :   creator.InitializationSucceeded();
     601             : 
     602           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     603             :              aCache->GetWrapperPreserveColor() == aReflector);
     604             :   // If proto != canonicalProto, we have to preserve our wrapper;
     605             :   // otherwise we won't be able to properly recreate it later, since
     606             :   // we won't know what proto to use.  Note that we don't check
     607             :   // aGivenProto here, since it's entirely possible (and even
     608             :   // somewhat common) to have a non-null aGivenProto which is the
     609             :   // same as canonicalProto.
     610           0 :   if (proto != canonicalProto) {
     611           0 :     PreserveWrapper(aObject);
     612             :   }
     613             : 
     614           0 :   return true;
     615             : }
     616             : 
     617             : const NativePropertyHooks sNativePropertyHooks[] = { {
     618             :   nullptr,
     619             :   nullptr,
     620             :   nullptr,
     621             :   { sNativeProperties.Upcast(), nullptr },
     622             :   prototypes::id::IDBMutableFile,
     623             :   constructors::id::IDBMutableFile,
     624             :   EventTargetBinding::sNativePropertyHooks,
     625             :   &DefaultXrayExpandoObjectClass
     626             : } };
     627             : 
     628             : void
     629          14 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     630             : {
     631          14 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
     632          14 :   if (!parentProto) {
     633           0 :     return;
     634             :   }
     635             : 
     636          14 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
     637          14 :   if (!constructorProto) {
     638           0 :     return;
     639             :   }
     640             : 
     641             :   static bool sIdsInited = false;
     642          14 :   if (!sIdsInited && NS_IsMainThread()) {
     643           1 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     644           0 :       return;
     645             :     }
     646           1 :     sIdsInited = true;
     647             :   }
     648             : 
     649          14 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::IDBMutableFile);
     650          14 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::IDBMutableFile);
     651          14 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     652             :                               &sPrototypeClass.mBase, protoCache,
     653             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     654             :                               interfaceCache,
     655             :                               sNativeProperties.Upcast(),
     656             :                               nullptr,
     657             :                               "IDBMutableFile", aDefineOnGlobal,
     658             :                               nullptr,
     659          14 :                               false);
     660             : }
     661             : 
     662             : JS::Handle<JSObject*>
     663           0 : GetProtoObjectHandle(JSContext* aCx)
     664             : {
     665             :   /* Get the interface prototype object for this class.  This will create the
     666             :      object as needed. */
     667           0 :   bool aDefineOnGlobal = true;
     668             : 
     669             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     670           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     671           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     672           0 :     return nullptr;
     673             :   }
     674             : 
     675             :   /* Check to see whether the interface objects are already installed */
     676           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     677           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::IDBMutableFile)) {
     678           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     679           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     680             :   }
     681             : 
     682             :   /*
     683             :    * The object might _still_ be null, but that's OK.
     684             :    *
     685             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     686             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     687             :    * changed after they have been set.
     688             :    *
     689             :    * Calling address() avoids the read read barrier that does gray
     690             :    * unmarking, but it's not possible for the object to be gray here.
     691             :    */
     692             : 
     693           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::IDBMutableFile);
     694           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     695           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     696             : }
     697             : 
     698             : JS::Handle<JSObject*>
     699          14 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     700             : {
     701             :   /* Get the interface object for this class.  This will create the object as
     702             :      needed. */
     703             : 
     704             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     705          14 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     706          14 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     707           0 :     return nullptr;
     708             :   }
     709             : 
     710             :   /* Check to see whether the interface objects are already installed */
     711          14 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     712          14 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::IDBMutableFile)) {
     713          28 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     714          14 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     715             :   }
     716             : 
     717             :   /*
     718             :    * The object might _still_ be null, but that's OK.
     719             :    *
     720             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     721             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     722             :    * changed after they have been set.
     723             :    *
     724             :    * Calling address() avoids the read read barrier that does gray
     725             :    * unmarking, but it's not possible for the object to be gray here.
     726             :    */
     727             : 
     728          14 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::IDBMutableFile);
     729          14 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     730          14 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     731             : }
     732             : 
     733             : JSObject*
     734          14 : GetConstructorObject(JSContext* aCx)
     735             : {
     736          14 :   return GetConstructorObjectHandle(aCx);
     737             : }
     738             : 
     739             : } // namespace IDBMutableFileBinding
     740             : 
     741             : 
     742             : 
     743             : } // namespace dom
     744             : } // namespace mozilla

Generated by: LCOV version 1.13