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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM InspectorUtils.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "InspectorUtilsBinding.h"
       5             : #include "mozilla/FloatingPoint.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/NonRefcountedDOMObject.h"
       9             : #include "mozilla/dom/PrimitiveConversions.h"
      10             : #include "mozilla/dom/ScriptSettings.h"
      11             : #include "mozilla/dom/SimpleGlobalObject.h"
      12             : 
      13             : namespace mozilla {
      14             : namespace dom {
      15             : 
      16             : 
      17           0 : InspectorRGBATuple::InspectorRGBATuple()
      18             : {
      19             :   // Safe to pass a null context if we pass a null value
      20           0 :   Init(nullptr, JS::NullHandleValue);
      21           0 : }
      22             : 
      23             : 
      24             : 
      25             : bool
      26           0 : InspectorRGBATuple::InitIds(JSContext* cx, InspectorRGBATupleAtoms* atomsCache)
      27             : {
      28           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      29             : 
      30             :   // Initialize these in reverse order so that any failure leaves the first one
      31             :   // uninitialized.
      32           0 :   if (!atomsCache->r_id.init(cx, "r") ||
      33           0 :       !atomsCache->g_id.init(cx, "g") ||
      34           0 :       !atomsCache->b_id.init(cx, "b") ||
      35           0 :       !atomsCache->a_id.init(cx, "a")) {
      36           0 :     return false;
      37             :   }
      38           0 :   return true;
      39             : }
      40             : 
      41             : bool
      42           0 : InspectorRGBATuple::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      43             : {
      44             :   // Passing a null JSContext is OK only if we're initing from null,
      45             :   // Since in that case we will not have to do any property gets
      46             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      47             :   // checkers by static analysis tools
      48           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      49           0 :   InspectorRGBATupleAtoms* atomsCache = nullptr;
      50           0 :   if (cx) {
      51           0 :     atomsCache = GetAtomCache<InspectorRGBATupleAtoms>(cx);
      52           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      53           0 :       return false;
      54             :     }
      55             :   }
      56             : 
      57           0 :   if (!IsConvertibleToDictionary(val)) {
      58           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      59             :   }
      60             : 
      61           0 :   bool isNull = val.isNullOrUndefined();
      62             :   // We only need these if !isNull, in which case we have |cx|.
      63           0 :   Maybe<JS::Rooted<JSObject *> > object;
      64           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      65           0 :   if (!isNull) {
      66           0 :     MOZ_ASSERT(cx);
      67           0 :     object.emplace(cx, &val.toObject());
      68           0 :     temp.emplace(cx);
      69             :   }
      70           0 :   if (!isNull) {
      71           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->a_id, temp.ptr())) {
      72           0 :       return false;
      73             :     }
      74             :   }
      75           0 :   if (!isNull && !temp->isUndefined()) {
      76           0 :     if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mA)) {
      77           0 :       return false;
      78           0 :     } else if (!mozilla::IsFinite(mA)) {
      79           0 :       ThrowErrorMessage(cx, MSG_NOT_FINITE, "'a' member of InspectorRGBATuple");
      80           0 :       return false;
      81             :     }
      82             :   } else {
      83           0 :     mA = 1.0;
      84             :   }
      85           0 :   mIsAnyMemberPresent = true;
      86             : 
      87           0 :   if (!isNull) {
      88           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->b_id, temp.ptr())) {
      89           0 :       return false;
      90             :     }
      91             :   }
      92           0 :   if (!isNull && !temp->isUndefined()) {
      93           0 :     if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mB)) {
      94           0 :       return false;
      95           0 :     } else if (!mozilla::IsFinite(mB)) {
      96           0 :       ThrowErrorMessage(cx, MSG_NOT_FINITE, "'b' member of InspectorRGBATuple");
      97           0 :       return false;
      98             :     }
      99             :   } else {
     100           0 :     mB = 0.0;
     101             :   }
     102           0 :   mIsAnyMemberPresent = true;
     103             : 
     104           0 :   if (!isNull) {
     105           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->g_id, temp.ptr())) {
     106           0 :       return false;
     107             :     }
     108             :   }
     109           0 :   if (!isNull && !temp->isUndefined()) {
     110           0 :     if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mG)) {
     111           0 :       return false;
     112           0 :     } else if (!mozilla::IsFinite(mG)) {
     113           0 :       ThrowErrorMessage(cx, MSG_NOT_FINITE, "'g' member of InspectorRGBATuple");
     114           0 :       return false;
     115             :     }
     116             :   } else {
     117           0 :     mG = 0.0;
     118             :   }
     119           0 :   mIsAnyMemberPresent = true;
     120             : 
     121           0 :   if (!isNull) {
     122           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->r_id, temp.ptr())) {
     123           0 :       return false;
     124             :     }
     125             :   }
     126           0 :   if (!isNull && !temp->isUndefined()) {
     127           0 :     if (!ValueToPrimitive<double, eDefault>(cx, temp.ref(), &mR)) {
     128           0 :       return false;
     129           0 :     } else if (!mozilla::IsFinite(mR)) {
     130           0 :       ThrowErrorMessage(cx, MSG_NOT_FINITE, "'r' member of InspectorRGBATuple");
     131           0 :       return false;
     132             :     }
     133             :   } else {
     134           0 :     mR = 0.0;
     135             :   }
     136           0 :   mIsAnyMemberPresent = true;
     137           0 :   return true;
     138             : }
     139             : 
     140             : bool
     141           0 : InspectorRGBATuple::Init(const nsAString& aJSON)
     142             : {
     143           0 :   AutoJSAPI jsapi;
     144           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     145           0 :   if (!cleanGlobal) {
     146           0 :     return false;
     147             :   }
     148           0 :   if (!jsapi.Init(cleanGlobal)) {
     149           0 :     return false;
     150             :   }
     151           0 :   JSContext* cx = jsapi.cx();
     152           0 :   JS::Rooted<JS::Value> json(cx);
     153           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     154           0 :   NS_ENSURE_TRUE(ok, false);
     155           0 :   return Init(cx, json);
     156             : }
     157             : 
     158             : bool
     159           0 : InspectorRGBATuple::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     160             : {
     161           0 :   InspectorRGBATupleAtoms* atomsCache = GetAtomCache<InspectorRGBATupleAtoms>(cx);
     162           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     163           0 :     return false;
     164             :   }
     165             : 
     166           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     167           0 :   if (!obj) {
     168           0 :     return false;
     169             :   }
     170           0 :   rval.set(JS::ObjectValue(*obj));
     171             : 
     172             :   do {
     173             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     174           0 :     JS::Rooted<JS::Value> temp(cx);
     175           0 :     double const & currentValue = mA;
     176           0 :     temp.set(JS_NumberValue(double(currentValue)));
     177           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->a_id, temp, JSPROP_ENUMERATE)) {
     178           0 :       return false;
     179             :     }
     180           0 :     break;
     181             :   } while(0);
     182             : 
     183             :   do {
     184             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     185           0 :     JS::Rooted<JS::Value> temp(cx);
     186           0 :     double const & currentValue = mB;
     187           0 :     temp.set(JS_NumberValue(double(currentValue)));
     188           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->b_id, temp, JSPROP_ENUMERATE)) {
     189           0 :       return false;
     190             :     }
     191           0 :     break;
     192             :   } while(0);
     193             : 
     194             :   do {
     195             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     196           0 :     JS::Rooted<JS::Value> temp(cx);
     197           0 :     double const & currentValue = mG;
     198           0 :     temp.set(JS_NumberValue(double(currentValue)));
     199           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->g_id, temp, JSPROP_ENUMERATE)) {
     200           0 :       return false;
     201             :     }
     202           0 :     break;
     203             :   } while(0);
     204             : 
     205             :   do {
     206             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     207           0 :     JS::Rooted<JS::Value> temp(cx);
     208           0 :     double const & currentValue = mR;
     209           0 :     temp.set(JS_NumberValue(double(currentValue)));
     210           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->r_id, temp, JSPROP_ENUMERATE)) {
     211           0 :       return false;
     212             :     }
     213           0 :     break;
     214             :   } while(0);
     215             : 
     216           0 :   return true;
     217             : }
     218             : 
     219             : bool
     220           0 : InspectorRGBATuple::ToJSON(nsAString& aJSON) const
     221             : {
     222           0 :   AutoJSAPI jsapi;
     223           0 :   jsapi.Init();
     224           0 :   JSContext *cx = jsapi.cx();
     225             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     226             :   // because we'll only be creating objects, in ways that have no
     227             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     228             :   // which likewise guarantees no side-effects for the sorts of
     229             :   // things we will pass it.
     230           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     231           0 :   JS::Rooted<JS::Value> val(cx);
     232           0 :   if (!ToObjectInternal(cx, &val)) {
     233           0 :     return false;
     234             :   }
     235           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     236           0 :   return StringifyToJSON(cx, obj, aJSON);
     237             : }
     238             : 
     239             : void
     240           0 : InspectorRGBATuple::TraceDictionary(JSTracer* trc)
     241             : {
     242           0 : }
     243             : 
     244             : InspectorRGBATuple&
     245           0 : InspectorRGBATuple::operator=(const InspectorRGBATuple& aOther)
     246             : {
     247           0 :   mA = aOther.mA;
     248           0 :   mB = aOther.mB;
     249           0 :   mG = aOther.mG;
     250           0 :   mR = aOther.mR;
     251           0 :   return *this;
     252             : }
     253             : 
     254             : namespace binding_detail {
     255             : } // namespace binding_detail
     256             : 
     257             : 
     258             : 
     259           0 : InspectorRGBTriple::InspectorRGBTriple()
     260             : {
     261             :   // Safe to pass a null context if we pass a null value
     262           0 :   Init(nullptr, JS::NullHandleValue);
     263           0 : }
     264             : 
     265             : 
     266             : 
     267             : bool
     268           0 : InspectorRGBTriple::InitIds(JSContext* cx, InspectorRGBTripleAtoms* atomsCache)
     269             : {
     270           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
     271             : 
     272             :   // Initialize these in reverse order so that any failure leaves the first one
     273             :   // uninitialized.
     274           0 :   if (!atomsCache->r_id.init(cx, "r") ||
     275           0 :       !atomsCache->g_id.init(cx, "g") ||
     276           0 :       !atomsCache->b_id.init(cx, "b")) {
     277           0 :     return false;
     278             :   }
     279           0 :   return true;
     280             : }
     281             : 
     282             : bool
     283           0 : InspectorRGBTriple::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
     284             : {
     285             :   // Passing a null JSContext is OK only if we're initing from null,
     286             :   // Since in that case we will not have to do any property gets
     287             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
     288             :   // checkers by static analysis tools
     289           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
     290           0 :   InspectorRGBTripleAtoms* atomsCache = nullptr;
     291           0 :   if (cx) {
     292           0 :     atomsCache = GetAtomCache<InspectorRGBTripleAtoms>(cx);
     293           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     294           0 :       return false;
     295             :     }
     296             :   }
     297             : 
     298           0 :   if (!IsConvertibleToDictionary(val)) {
     299           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
     300             :   }
     301             : 
     302           0 :   bool isNull = val.isNullOrUndefined();
     303             :   // We only need these if !isNull, in which case we have |cx|.
     304           0 :   Maybe<JS::Rooted<JSObject *> > object;
     305           0 :   Maybe<JS::Rooted<JS::Value> > temp;
     306           0 :   if (!isNull) {
     307           0 :     MOZ_ASSERT(cx);
     308           0 :     object.emplace(cx, &val.toObject());
     309           0 :     temp.emplace(cx);
     310             :   }
     311           0 :   if (!isNull) {
     312           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->b_id, temp.ptr())) {
     313           0 :       return false;
     314             :     }
     315             :   }
     316           0 :   if (!isNull && !temp->isUndefined()) {
     317           0 :     if (!ValueToPrimitive<uint8_t, eDefault>(cx, temp.ref(), &mB)) {
     318           0 :       return false;
     319             :     }
     320             :   } else {
     321           0 :     mB = 0;
     322             :   }
     323           0 :   mIsAnyMemberPresent = true;
     324             : 
     325           0 :   if (!isNull) {
     326           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->g_id, temp.ptr())) {
     327           0 :       return false;
     328             :     }
     329             :   }
     330           0 :   if (!isNull && !temp->isUndefined()) {
     331           0 :     if (!ValueToPrimitive<uint8_t, eDefault>(cx, temp.ref(), &mG)) {
     332           0 :       return false;
     333             :     }
     334             :   } else {
     335           0 :     mG = 0;
     336             :   }
     337           0 :   mIsAnyMemberPresent = true;
     338             : 
     339           0 :   if (!isNull) {
     340           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->r_id, temp.ptr())) {
     341           0 :       return false;
     342             :     }
     343             :   }
     344           0 :   if (!isNull && !temp->isUndefined()) {
     345           0 :     if (!ValueToPrimitive<uint8_t, eDefault>(cx, temp.ref(), &mR)) {
     346           0 :       return false;
     347             :     }
     348             :   } else {
     349           0 :     mR = 0;
     350             :   }
     351           0 :   mIsAnyMemberPresent = true;
     352           0 :   return true;
     353             : }
     354             : 
     355             : bool
     356           0 : InspectorRGBTriple::Init(const nsAString& aJSON)
     357             : {
     358           0 :   AutoJSAPI jsapi;
     359           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     360           0 :   if (!cleanGlobal) {
     361           0 :     return false;
     362             :   }
     363           0 :   if (!jsapi.Init(cleanGlobal)) {
     364           0 :     return false;
     365             :   }
     366           0 :   JSContext* cx = jsapi.cx();
     367           0 :   JS::Rooted<JS::Value> json(cx);
     368           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     369           0 :   NS_ENSURE_TRUE(ok, false);
     370           0 :   return Init(cx, json);
     371             : }
     372             : 
     373             : bool
     374           0 : InspectorRGBTriple::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     375             : {
     376           0 :   InspectorRGBTripleAtoms* atomsCache = GetAtomCache<InspectorRGBTripleAtoms>(cx);
     377           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     378           0 :     return false;
     379             :   }
     380             : 
     381           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     382           0 :   if (!obj) {
     383           0 :     return false;
     384             :   }
     385           0 :   rval.set(JS::ObjectValue(*obj));
     386             : 
     387             :   do {
     388             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     389           0 :     JS::Rooted<JS::Value> temp(cx);
     390           0 :     uint8_t const & currentValue = mB;
     391           0 :     temp.setInt32(int32_t(currentValue));
     392           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->b_id, temp, JSPROP_ENUMERATE)) {
     393           0 :       return false;
     394             :     }
     395           0 :     break;
     396             :   } while(0);
     397             : 
     398             :   do {
     399             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     400           0 :     JS::Rooted<JS::Value> temp(cx);
     401           0 :     uint8_t const & currentValue = mG;
     402           0 :     temp.setInt32(int32_t(currentValue));
     403           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->g_id, temp, JSPROP_ENUMERATE)) {
     404           0 :       return false;
     405             :     }
     406           0 :     break;
     407             :   } while(0);
     408             : 
     409             :   do {
     410             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     411           0 :     JS::Rooted<JS::Value> temp(cx);
     412           0 :     uint8_t const & currentValue = mR;
     413           0 :     temp.setInt32(int32_t(currentValue));
     414           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->r_id, temp, JSPROP_ENUMERATE)) {
     415           0 :       return false;
     416             :     }
     417           0 :     break;
     418             :   } while(0);
     419             : 
     420           0 :   return true;
     421             : }
     422             : 
     423             : bool
     424           0 : InspectorRGBTriple::ToJSON(nsAString& aJSON) const
     425             : {
     426           0 :   AutoJSAPI jsapi;
     427           0 :   jsapi.Init();
     428           0 :   JSContext *cx = jsapi.cx();
     429             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     430             :   // because we'll only be creating objects, in ways that have no
     431             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     432             :   // which likewise guarantees no side-effects for the sorts of
     433             :   // things we will pass it.
     434           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     435           0 :   JS::Rooted<JS::Value> val(cx);
     436           0 :   if (!ToObjectInternal(cx, &val)) {
     437           0 :     return false;
     438             :   }
     439           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     440           0 :   return StringifyToJSON(cx, obj, aJSON);
     441             : }
     442             : 
     443             : void
     444           0 : InspectorRGBTriple::TraceDictionary(JSTracer* trc)
     445             : {
     446           0 : }
     447             : 
     448             : InspectorRGBTriple&
     449           0 : InspectorRGBTriple::operator=(const InspectorRGBTriple& aOther)
     450             : {
     451           0 :   mB = aOther.mB;
     452           0 :   mG = aOther.mG;
     453           0 :   mR = aOther.mR;
     454           0 :   return *this;
     455             : }
     456             : 
     457             : namespace binding_detail {
     458             : } // namespace binding_detail
     459             : 
     460             : 
     461             : } // namespace dom
     462             : } // namespace mozilla

Generated by: LCOV version 1.13