LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - SVGLengthBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 183 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 SVGLength.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "DOMSVGLength.h"
       4             : #include "SVGLengthBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/FloatingPoint.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/PrimitiveConversions.h"
      12             : #include "mozilla/dom/XrayExpandoClass.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace dom {
      16             : 
      17             : namespace SVGLengthBinding {
      18             : 
      19             : static bool
      20           0 : get_unitType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitGetterCallArgs args)
      21             : {
      22           0 :   uint16_t result(self->UnitType());
      23           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      24           0 :   args.rval().setInt32(int32_t(result));
      25           0 :   return true;
      26             : }
      27             : 
      28             : static const JSJitInfo unitType_getterinfo = {
      29             :   { (JSJitGetterOp)get_unitType },
      30             :   { prototypes::id::SVGLength },
      31             :   { PrototypeTraits<prototypes::id::SVGLength>::Depth },
      32             :   JSJitInfo::Getter,
      33             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      34             :   JSVAL_TYPE_INT32,  /* returnType.  Not relevant for setters. */
      35             :   true,  /* isInfallible. False in setters. */
      36             :   false,  /* isMovable.  Not relevant for setters. */
      37             :   false, /* isEliminatable.  Not relevant for setters. */
      38             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      39             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      40             :   false,  /* isTypedMethod.  Only relevant for methods. */
      41             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      42             : };
      43             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      44             : static_assert(0 < 1, "There is no slot for us");
      45             : 
      46             : static bool
      47           0 : get_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitGetterCallArgs args)
      48             : {
      49           0 :   binding_detail::FastErrorResult rv;
      50           0 :   float result(self->GetValue(rv));
      51           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      52           0 :     return false;
      53             :   }
      54           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      55           0 :   args.rval().set(JS_NumberValue(double(result)));
      56           0 :   return true;
      57             : }
      58             : 
      59             : static bool
      60           0 : set_value(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitSetterCallArgs args)
      61             : {
      62             :   float arg0;
      63           0 :   if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
      64           0 :     return false;
      65           0 :   } else if (!mozilla::IsFinite(arg0)) {
      66           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGLength.value");
      67           0 :     return false;
      68             :   }
      69           0 :   binding_detail::FastErrorResult rv;
      70           0 :   self->SetValue(arg0, rv);
      71           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
      72           0 :     return false;
      73             :   }
      74           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      75             : 
      76           0 :   return true;
      77             : }
      78             : 
      79             : static const JSJitInfo value_getterinfo = {
      80             :   { (JSJitGetterOp)get_value },
      81             :   { prototypes::id::SVGLength },
      82             :   { PrototypeTraits<prototypes::id::SVGLength>::Depth },
      83             :   JSJitInfo::Getter,
      84             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
      85             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
      86             :   false,  /* isInfallible. False in setters. */
      87             :   false,  /* isMovable.  Not relevant for setters. */
      88             :   false, /* isEliminatable.  Not relevant for setters. */
      89             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      90             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
      91             :   false,  /* isTypedMethod.  Only relevant for methods. */
      92             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
      93             : };
      94             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
      95             : static_assert(0 < 1, "There is no slot for us");
      96             : static const JSJitInfo value_setterinfo = {
      97             :   { (JSJitGetterOp)set_value },
      98             :   { prototypes::id::SVGLength },
      99             :   { PrototypeTraits<prototypes::id::SVGLength>::Depth },
     100             :   JSJitInfo::Setter,
     101             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     102             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     103             :   false,  /* isInfallible. False in setters. */
     104             :   false,  /* isMovable.  Not relevant for setters. */
     105             :   false, /* isEliminatable.  Not relevant for setters. */
     106             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     107             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     108             :   false,  /* isTypedMethod.  Only relevant for methods. */
     109             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     110             : };
     111             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     112             : static_assert(0 < 1, "There is no slot for us");
     113             : 
     114             : static bool
     115           0 : get_valueInSpecifiedUnits(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitGetterCallArgs args)
     116             : {
     117           0 :   float result(self->ValueInSpecifiedUnits());
     118           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     119           0 :   args.rval().set(JS_NumberValue(double(result)));
     120           0 :   return true;
     121             : }
     122             : 
     123             : static bool
     124           0 : set_valueInSpecifiedUnits(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitSetterCallArgs args)
     125             : {
     126             :   float arg0;
     127           0 :   if (!ValueToPrimitive<float, eDefault>(cx, args[0], &arg0)) {
     128           0 :     return false;
     129           0 :   } else if (!mozilla::IsFinite(arg0)) {
     130           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Value being assigned to SVGLength.valueInSpecifiedUnits");
     131           0 :     return false;
     132             :   }
     133           0 :   binding_detail::FastErrorResult rv;
     134           0 :   self->SetValueInSpecifiedUnits(arg0, rv);
     135           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     136           0 :     return false;
     137             :   }
     138           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     139             : 
     140           0 :   return true;
     141             : }
     142             : 
     143             : static const JSJitInfo valueInSpecifiedUnits_getterinfo = {
     144             :   { (JSJitGetterOp)get_valueInSpecifiedUnits },
     145             :   { prototypes::id::SVGLength },
     146             :   { PrototypeTraits<prototypes::id::SVGLength>::Depth },
     147             :   JSJitInfo::Getter,
     148             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     149             :   JSVAL_TYPE_DOUBLE,  /* returnType.  Not relevant for setters. */
     150             :   true,  /* isInfallible. False in setters. */
     151             :   false,  /* isMovable.  Not relevant for setters. */
     152             :   false, /* isEliminatable.  Not relevant for setters. */
     153             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     154             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     155             :   false,  /* isTypedMethod.  Only relevant for methods. */
     156             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     157             : };
     158             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     159             : static_assert(0 < 1, "There is no slot for us");
     160             : static const JSJitInfo valueInSpecifiedUnits_setterinfo = {
     161             :   { (JSJitGetterOp)set_valueInSpecifiedUnits },
     162             :   { prototypes::id::SVGLength },
     163             :   { PrototypeTraits<prototypes::id::SVGLength>::Depth },
     164             :   JSJitInfo::Setter,
     165             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     166             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     167             :   false,  /* isInfallible. False in setters. */
     168             :   false,  /* isMovable.  Not relevant for setters. */
     169             :   false, /* isEliminatable.  Not relevant for setters. */
     170             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     171             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     172             :   false,  /* isTypedMethod.  Only relevant for methods. */
     173             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     174             : };
     175             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     176             : static_assert(0 < 1, "There is no slot for us");
     177             : 
     178             : static bool
     179           0 : get_valueAsString(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitGetterCallArgs args)
     180             : {
     181           0 :   DOMString result;
     182           0 :   self->GetValueAsString(result);
     183           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     184           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     185           0 :     return false;
     186             :   }
     187           0 :   return true;
     188             : }
     189             : 
     190             : static bool
     191           0 : set_valueAsString(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, JSJitSetterCallArgs args)
     192             : {
     193           0 :   binding_detail::FakeString arg0;
     194           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     195           0 :     return false;
     196             :   }
     197           0 :   binding_detail::FastErrorResult rv;
     198           0 :   self->SetValueAsString(NonNullHelper(Constify(arg0)), rv);
     199           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     200           0 :     return false;
     201             :   }
     202           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     203             : 
     204           0 :   return true;
     205             : }
     206             : 
     207             : static const JSJitInfo valueAsString_getterinfo = {
     208             :   { (JSJitGetterOp)get_valueAsString },
     209             :   { prototypes::id::SVGLength },
     210             :   { PrototypeTraits<prototypes::id::SVGLength>::Depth },
     211             :   JSJitInfo::Getter,
     212             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     213             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     214             :   false,  /* isInfallible. False in setters. */
     215             :   false,  /* isMovable.  Not relevant for setters. */
     216             :   false, /* isEliminatable.  Not relevant for setters. */
     217             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     218             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     219             :   false,  /* isTypedMethod.  Only relevant for methods. */
     220             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     221             : };
     222             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     223             : static_assert(0 < 1, "There is no slot for us");
     224             : static const JSJitInfo valueAsString_setterinfo = {
     225             :   { (JSJitGetterOp)set_valueAsString },
     226             :   { prototypes::id::SVGLength },
     227             :   { PrototypeTraits<prototypes::id::SVGLength>::Depth },
     228             :   JSJitInfo::Setter,
     229             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     230             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     231             :   false,  /* isInfallible. False in setters. */
     232             :   false,  /* isMovable.  Not relevant for setters. */
     233             :   false, /* isEliminatable.  Not relevant for setters. */
     234             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     235             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     236             :   false,  /* isTypedMethod.  Only relevant for methods. */
     237             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     238             : };
     239             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     240             : static_assert(0 < 1, "There is no slot for us");
     241             : 
     242             : static bool
     243           0 : newValueSpecifiedUnits(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, const JSJitMethodCallArgs& args)
     244             : {
     245           0 :   if (MOZ_UNLIKELY(args.length() < 2)) {
     246           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGLength.newValueSpecifiedUnits");
     247             :   }
     248             :   uint16_t arg0;
     249           0 :   if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[0], &arg0)) {
     250           0 :     return false;
     251             :   }
     252             :   float arg1;
     253           0 :   if (!ValueToPrimitive<float, eDefault>(cx, args[1], &arg1)) {
     254           0 :     return false;
     255           0 :   } else if (!mozilla::IsFinite(arg1)) {
     256           0 :     ThrowErrorMessage(cx, MSG_NOT_FINITE, "Argument 2 of SVGLength.newValueSpecifiedUnits");
     257           0 :     return false;
     258             :   }
     259           0 :   binding_detail::FastErrorResult rv;
     260           0 :   self->NewValueSpecifiedUnits(arg0, arg1, rv);
     261           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     262           0 :     return false;
     263             :   }
     264           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     265           0 :   args.rval().setUndefined();
     266           0 :   return true;
     267             : }
     268             : 
     269             : static const JSJitInfo newValueSpecifiedUnits_methodinfo = {
     270             :   { (JSJitGetterOp)newValueSpecifiedUnits },
     271             :   { prototypes::id::SVGLength },
     272             :   { PrototypeTraits<prototypes::id::SVGLength>::Depth },
     273             :   JSJitInfo::Method,
     274             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     275             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     276             :   false,  /* isInfallible. False in setters. */
     277             :   false,  /* isMovable.  Not relevant for setters. */
     278             :   false, /* isEliminatable.  Not relevant for setters. */
     279             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     280             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     281             :   false,  /* isTypedMethod.  Only relevant for methods. */
     282             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     283             : };
     284             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     285             : static_assert(0 < 1, "There is no slot for us");
     286             : 
     287             : static bool
     288           0 : convertToSpecifiedUnits(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::DOMSVGLength* self, const JSJitMethodCallArgs& args)
     289             : {
     290           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     291           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "SVGLength.convertToSpecifiedUnits");
     292             :   }
     293             :   uint16_t arg0;
     294           0 :   if (!ValueToPrimitive<uint16_t, eDefault>(cx, args[0], &arg0)) {
     295           0 :     return false;
     296             :   }
     297           0 :   binding_detail::FastErrorResult rv;
     298           0 :   self->ConvertToSpecifiedUnits(arg0, rv);
     299           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     300           0 :     return false;
     301             :   }
     302           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     303           0 :   args.rval().setUndefined();
     304           0 :   return true;
     305             : }
     306             : 
     307             : static const JSJitInfo convertToSpecifiedUnits_methodinfo = {
     308             :   { (JSJitGetterOp)convertToSpecifiedUnits },
     309             :   { prototypes::id::SVGLength },
     310             :   { PrototypeTraits<prototypes::id::SVGLength>::Depth },
     311             :   JSJitInfo::Method,
     312             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     313             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     314             :   false,  /* isInfallible. False in setters. */
     315             :   false,  /* isMovable.  Not relevant for setters. */
     316             :   false, /* isEliminatable.  Not relevant for setters. */
     317             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     318             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     319             :   false,  /* isTypedMethod.  Only relevant for methods. */
     320             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     321             : };
     322             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     323             : static_assert(0 < 1, "There is no slot for us");
     324             : 
     325             : static bool
     326           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     327             : {
     328           0 :   mozilla::DOMSVGLength* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMSVGLength>(obj);
     329             :   // We don't want to preserve if we don't have a wrapper, and we
     330             :   // obviously can't preserve if we're not initialized.
     331           0 :   if (self && self->GetWrapperPreserveColor()) {
     332           0 :     PreserveWrapper(self);
     333             :   }
     334           0 :   return true;
     335             : }
     336             : 
     337             : static void
     338           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     339             : {
     340           0 :   mozilla::DOMSVGLength* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMSVGLength>(obj);
     341           0 :   if (self) {
     342           0 :     ClearWrapper(self, self, obj);
     343           0 :     AddForDeferredFinalization<mozilla::DOMSVGLength>(self);
     344             :   }
     345           0 : }
     346             : 
     347             : static void
     348           0 : _objectMoved(JSObject* obj, const JSObject* old)
     349             : {
     350           0 :   mozilla::DOMSVGLength* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::DOMSVGLength>(obj);
     351           0 :   if (self) {
     352           0 :     UpdateWrapper(self, self, obj, old);
     353             :   }
     354           0 : }
     355             : 
     356             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     357             : #if defined(__clang__)
     358             : #pragma clang diagnostic push
     359             : #pragma clang diagnostic ignored "-Wmissing-braces"
     360             : #endif
     361             : static const JSFunctionSpec sMethods_specs[] = {
     362             :   JS_FNSPEC("newValueSpecifiedUnits", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&newValueSpecifiedUnits_methodinfo), 2, JSPROP_ENUMERATE, nullptr),
     363             :   JS_FNSPEC("convertToSpecifiedUnits", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&convertToSpecifiedUnits_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     364             :   JS_FS_END
     365             : };
     366             : #if defined(__clang__)
     367             : #pragma clang diagnostic pop
     368             : #endif
     369             : 
     370             : 
     371             : // Can't be const because the pref-enabled boolean needs to be writable
     372             : static Prefable<const JSFunctionSpec> sMethods[] = {
     373             :   { nullptr, &sMethods_specs[0] },
     374             :   { nullptr, nullptr }
     375             : };
     376             : 
     377             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     378             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     379             : static_assert(2 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     380             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     381             : 
     382             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     383             : #if defined(__clang__)
     384             : #pragma clang diagnostic push
     385             : #pragma clang diagnostic ignored "-Wmissing-braces"
     386             : #endif
     387             : static const JSPropertySpec sAttributes_specs[] = {
     388             :   { "unitType", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &unitType_getterinfo, nullptr, nullptr },
     389             :   { "value", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &value_getterinfo, GenericBindingSetter, &value_setterinfo },
     390             :   { "valueInSpecifiedUnits", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &valueInSpecifiedUnits_getterinfo, GenericBindingSetter, &valueInSpecifiedUnits_setterinfo },
     391             :   { "valueAsString", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &valueAsString_getterinfo, GenericBindingSetter, &valueAsString_setterinfo },
     392             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     393             : };
     394             : #if defined(__clang__)
     395             : #pragma clang diagnostic pop
     396             : #endif
     397             : 
     398             : 
     399             : // Can't be const because the pref-enabled boolean needs to be writable
     400             : static Prefable<const JSPropertySpec> sAttributes[] = {
     401             :   { nullptr, &sAttributes_specs[0] },
     402             :   { nullptr, nullptr }
     403             : };
     404             : 
     405             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     406             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     407             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     408             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     409             : 
     410             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     411             : #if defined(__clang__)
     412             : #pragma clang diagnostic push
     413             : #pragma clang diagnostic ignored "-Wmissing-braces"
     414             : #endif
     415             : static const ConstantSpec sConstants_specs[] = {
     416             :   { "SVG_LENGTHTYPE_UNKNOWN", JS::Int32Value(0) },
     417             :   { "SVG_LENGTHTYPE_NUMBER", JS::Int32Value(1) },
     418             :   { "SVG_LENGTHTYPE_PERCENTAGE", JS::Int32Value(2) },
     419             :   { "SVG_LENGTHTYPE_EMS", JS::Int32Value(3) },
     420             :   { "SVG_LENGTHTYPE_EXS", JS::Int32Value(4) },
     421             :   { "SVG_LENGTHTYPE_PX", JS::Int32Value(5) },
     422             :   { "SVG_LENGTHTYPE_CM", JS::Int32Value(6) },
     423             :   { "SVG_LENGTHTYPE_MM", JS::Int32Value(7) },
     424             :   { "SVG_LENGTHTYPE_IN", JS::Int32Value(8) },
     425             :   { "SVG_LENGTHTYPE_PT", JS::Int32Value(9) },
     426             :   { "SVG_LENGTHTYPE_PC", JS::Int32Value(10) },
     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(11 <= 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[17];
     447             : static PropertyInfo sNativeProperties_propertyInfos[17];
     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             :   17,
     459             :   sNativeProperties_sortedPropertyIndices,
     460             :   {
     461             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     462             :     { sAttributes, &sNativeProperties_propertyInfos[2] },
     463             :     { sConstants, &sNativeProperties_propertyInfos[6] }
     464             :   }
     465             : };
     466             : static_assert(17 < 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::SVGLength,
     481             :   PrototypeTraits<prototypes::id::SVGLength>::Depth,
     482             :   sNativePropertyHooks,
     483             :   "function SVGLength() {\n    [native code]\n}",
     484             :   JS::GetRealmFunctionPrototype
     485             : };
     486             : 
     487             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     488             :   {
     489             :     "SVGLengthPrototype",
     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::SVGLength,
     499             :   PrototypeTraits<prototypes::id::SVGLength>::Depth,
     500             :   sNativePropertyHooks,
     501             :   "[object SVGLengthPrototype]",
     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             :   { "SVGLength",
     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::SVGLength, 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::DOMSVGLength >::value,
     542             :   sNativePropertyHooks,
     543             :   FindAssociatedGlobalForNative<mozilla::DOMSVGLength>::Get,
     544             :   GetProtoObjectHandle,
     545             :   GetCCParticipant<mozilla::DOMSVGLength>::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::DOMSVGLength* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     560             : {
     561             :   MOZ_ASSERT(static_cast<mozilla::DOMSVGLength*>(aObject) ==
     562             :              reinterpret_cast<mozilla::DOMSVGLength*>(aObject),
     563             :              "Multiple inheritance for mozilla::DOMSVGLength 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::DOMSVGLength> 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::SVGLength,
     640             :   constructors::id::SVGLength,
     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::SVGLength);
     667           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::SVGLength);
     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             :                               "SVGLength", 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::SVGLength)) {
     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::SVGLength);
     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::SVGLength)) {
     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::SVGLength);
     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 SVGLengthBinding
     757             : 
     758             : 
     759             : 
     760             : } // namespace dom
     761             : } // namespace mozilla

Generated by: LCOV version 1.13