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

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

Generated by: LCOV version 1.13