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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM AppInfo.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AppInfoBinding.h"
       4             : #include "AtomList.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/dom/BindingUtils.h"
       7             : #include "mozilla/dom/NonRefcountedDOMObject.h"
       8             : #include "mozilla/dom/PrimitiveConversions.h"
       9             : #include "mozilla/dom/ScriptSettings.h"
      10             : #include "mozilla/dom/SimpleGlobalObject.h"
      11             : 
      12             : namespace mozilla {
      13             : namespace dom {
      14             : 
      15             : 
      16           0 : AppInfo::AppInfo()
      17             : {
      18             :   // Safe to pass a null context if we pass a null value
      19           0 :   Init(nullptr, JS::NullHandleValue);
      20           0 : }
      21             : 
      22             : 
      23             : 
      24             : bool
      25           0 : AppInfo::InitIds(JSContext* cx, AppInfoAtoms* atomsCache)
      26             : {
      27           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      28             : 
      29             :   // Initialize these in reverse order so that any failure leaves the first one
      30             :   // uninitialized.
      31           0 :   if (!atomsCache->path_id.init(cx, "path") ||
      32           0 :       !atomsCache->isCoreApp_id.init(cx, "isCoreApp")) {
      33           0 :     return false;
      34             :   }
      35           0 :   return true;
      36             : }
      37             : 
      38             : bool
      39           0 : AppInfo::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      40             : {
      41             :   // Passing a null JSContext is OK only if we're initing from null,
      42             :   // Since in that case we will not have to do any property gets
      43             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      44             :   // checkers by static analysis tools
      45           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      46           0 :   AppInfoAtoms* atomsCache = nullptr;
      47           0 :   if (cx) {
      48           0 :     atomsCache = GetAtomCache<AppInfoAtoms>(cx);
      49           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      50           0 :       return false;
      51             :     }
      52             :   }
      53             : 
      54           0 :   if (!IsConvertibleToDictionary(val)) {
      55           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      56             :   }
      57             : 
      58           0 :   bool isNull = val.isNullOrUndefined();
      59             :   // We only need these if !isNull, in which case we have |cx|.
      60           0 :   Maybe<JS::Rooted<JSObject *> > object;
      61           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      62           0 :   if (!isNull) {
      63           0 :     MOZ_ASSERT(cx);
      64           0 :     object.emplace(cx, &val.toObject());
      65           0 :     temp.emplace(cx);
      66             :   }
      67           0 :   if (!isNull) {
      68           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->isCoreApp_id, temp.ptr())) {
      69           0 :       return false;
      70             :     }
      71             :   }
      72           0 :   if (!isNull && !temp->isUndefined()) {
      73           0 :     if (!ValueToPrimitive<bool, eDefault>(cx, temp.ref(), &mIsCoreApp)) {
      74           0 :       return false;
      75             :     }
      76             :   } else {
      77           0 :     mIsCoreApp = false;
      78             :   }
      79           0 :   mIsAnyMemberPresent = true;
      80             : 
      81           0 :   if (!isNull) {
      82           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->path_id, temp.ptr())) {
      83           0 :       return false;
      84             :     }
      85             :   }
      86           0 :   if (!isNull && !temp->isUndefined()) {
      87           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mPath)) {
      88           0 :       return false;
      89             :     }
      90             :   } else {
      91             :     static const char16_t data[] = { 0 };
      92           0 :     mPath.Rebind(data, ArrayLength(data) - 1);
      93             :   }
      94           0 :   mIsAnyMemberPresent = true;
      95           0 :   return true;
      96             : }
      97             : 
      98             : bool
      99           0 : AppInfo::Init(const nsAString& aJSON)
     100             : {
     101           0 :   AutoJSAPI jsapi;
     102           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     103           0 :   if (!cleanGlobal) {
     104           0 :     return false;
     105             :   }
     106           0 :   if (!jsapi.Init(cleanGlobal)) {
     107           0 :     return false;
     108             :   }
     109           0 :   JSContext* cx = jsapi.cx();
     110           0 :   JS::Rooted<JS::Value> json(cx);
     111           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     112           0 :   NS_ENSURE_TRUE(ok, false);
     113           0 :   return Init(cx, json);
     114             : }
     115             : 
     116             : bool
     117           0 : AppInfo::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     118             : {
     119           0 :   AppInfoAtoms* atomsCache = GetAtomCache<AppInfoAtoms>(cx);
     120           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     121           0 :     return false;
     122             :   }
     123             : 
     124           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     125           0 :   if (!obj) {
     126           0 :     return false;
     127             :   }
     128           0 :   rval.set(JS::ObjectValue(*obj));
     129             : 
     130             :   do {
     131             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     132           0 :     JS::Rooted<JS::Value> temp(cx);
     133           0 :     bool const & currentValue = mIsCoreApp;
     134           0 :     temp.setBoolean(currentValue);
     135           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->isCoreApp_id, temp, JSPROP_ENUMERATE)) {
     136           0 :       return false;
     137             :     }
     138           0 :     break;
     139             :   } while(0);
     140             : 
     141             :   do {
     142             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     143           0 :     JS::Rooted<JS::Value> temp(cx);
     144           0 :     nsString const & currentValue = mPath;
     145           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     146           0 :       return false;
     147             :     }
     148           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->path_id, temp, JSPROP_ENUMERATE)) {
     149           0 :       return false;
     150             :     }
     151           0 :     break;
     152             :   } while(0);
     153             : 
     154           0 :   return true;
     155             : }
     156             : 
     157             : bool
     158           0 : AppInfo::ToJSON(nsAString& aJSON) const
     159             : {
     160           0 :   AutoJSAPI jsapi;
     161           0 :   jsapi.Init();
     162           0 :   JSContext *cx = jsapi.cx();
     163             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     164             :   // because we'll only be creating objects, in ways that have no
     165             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     166             :   // which likewise guarantees no side-effects for the sorts of
     167             :   // things we will pass it.
     168           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     169           0 :   JS::Rooted<JS::Value> val(cx);
     170           0 :   if (!ToObjectInternal(cx, &val)) {
     171           0 :     return false;
     172             :   }
     173           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     174           0 :   return StringifyToJSON(cx, obj, aJSON);
     175             : }
     176             : 
     177             : void
     178           0 : AppInfo::TraceDictionary(JSTracer* trc)
     179             : {
     180           0 : }
     181             : 
     182             : AppInfo&
     183           0 : AppInfo::operator=(const AppInfo& aOther)
     184             : {
     185           0 :   mIsCoreApp = aOther.mIsCoreApp;
     186           0 :   mPath = aOther.mPath;
     187           0 :   return *this;
     188             : }
     189             : 
     190             : namespace binding_detail {
     191             : } // namespace binding_detail
     192             : 
     193             : 
     194             : } // namespace dom
     195             : } // namespace mozilla

Generated by: LCOV version 1.13