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

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

Generated by: LCOV version 1.13