LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - AutocompleteInfoBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 127 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 AutocompleteInfo.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "AutocompleteInfoBinding.h"
       5             : #include "mozilla/OwningNonNull.h"
       6             : #include "mozilla/dom/BindingUtils.h"
       7             : #include "mozilla/dom/NonRefcountedDOMObject.h"
       8             : #include "mozilla/dom/ScriptSettings.h"
       9             : #include "mozilla/dom/SimpleGlobalObject.h"
      10             : 
      11             : namespace mozilla {
      12             : namespace dom {
      13             : 
      14             : 
      15           0 : AutocompleteInfo::AutocompleteInfo()
      16             : {
      17             :   // Safe to pass a null context if we pass a null value
      18           0 :   Init(nullptr, JS::NullHandleValue);
      19           0 : }
      20             : 
      21             : 
      22             : 
      23             : bool
      24           0 : AutocompleteInfo::InitIds(JSContext* cx, AutocompleteInfoAtoms* atomsCache)
      25             : {
      26           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      27             : 
      28             :   // Initialize these in reverse order so that any failure leaves the first one
      29             :   // uninitialized.
      30           0 :   if (!atomsCache->section_id.init(cx, "section") ||
      31           0 :       !atomsCache->fieldName_id.init(cx, "fieldName") ||
      32           0 :       !atomsCache->contactType_id.init(cx, "contactType") ||
      33           0 :       !atomsCache->addressType_id.init(cx, "addressType")) {
      34           0 :     return false;
      35             :   }
      36           0 :   return true;
      37             : }
      38             : 
      39             : bool
      40           0 : AutocompleteInfo::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      41             : {
      42             :   // Passing a null JSContext is OK only if we're initing from null,
      43             :   // Since in that case we will not have to do any property gets
      44             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      45             :   // checkers by static analysis tools
      46           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      47           0 :   AutocompleteInfoAtoms* atomsCache = nullptr;
      48           0 :   if (cx) {
      49           0 :     atomsCache = GetAtomCache<AutocompleteInfoAtoms>(cx);
      50           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      51           0 :       return false;
      52             :     }
      53             :   }
      54             : 
      55           0 :   if (!IsConvertibleToDictionary(val)) {
      56           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      57             :   }
      58             : 
      59           0 :   bool isNull = val.isNullOrUndefined();
      60             :   // We only need these if !isNull, in which case we have |cx|.
      61           0 :   Maybe<JS::Rooted<JSObject *> > object;
      62           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      63           0 :   if (!isNull) {
      64           0 :     MOZ_ASSERT(cx);
      65           0 :     object.emplace(cx, &val.toObject());
      66           0 :     temp.emplace(cx);
      67             :   }
      68           0 :   if (!isNull) {
      69           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->addressType_id, temp.ptr())) {
      70           0 :       return false;
      71             :     }
      72             :   }
      73           0 :   if (!isNull && !temp->isUndefined()) {
      74           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mAddressType)) {
      75           0 :       return false;
      76             :     }
      77             :   } else {
      78             :     static const char16_t data[] = { 0 };
      79           0 :     mAddressType.Rebind(data, ArrayLength(data) - 1);
      80             :   }
      81           0 :   mIsAnyMemberPresent = true;
      82             : 
      83           0 :   if (!isNull) {
      84           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->contactType_id, temp.ptr())) {
      85           0 :       return false;
      86             :     }
      87             :   }
      88           0 :   if (!isNull && !temp->isUndefined()) {
      89           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mContactType)) {
      90           0 :       return false;
      91             :     }
      92             :   } else {
      93             :     static const char16_t data[] = { 0 };
      94           0 :     mContactType.Rebind(data, ArrayLength(data) - 1);
      95             :   }
      96           0 :   mIsAnyMemberPresent = true;
      97             : 
      98           0 :   if (!isNull) {
      99           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->fieldName_id, temp.ptr())) {
     100           0 :       return false;
     101             :     }
     102             :   }
     103           0 :   if (!isNull && !temp->isUndefined()) {
     104           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mFieldName)) {
     105           0 :       return false;
     106             :     }
     107             :   } else {
     108             :     static const char16_t data[] = { 0 };
     109           0 :     mFieldName.Rebind(data, ArrayLength(data) - 1);
     110             :   }
     111           0 :   mIsAnyMemberPresent = true;
     112             : 
     113           0 :   if (!isNull) {
     114           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->section_id, temp.ptr())) {
     115           0 :       return false;
     116             :     }
     117             :   }
     118           0 :   if (!isNull && !temp->isUndefined()) {
     119           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, mSection)) {
     120           0 :       return false;
     121             :     }
     122             :   } else {
     123             :     static const char16_t data[] = { 0 };
     124           0 :     mSection.Rebind(data, ArrayLength(data) - 1);
     125             :   }
     126           0 :   mIsAnyMemberPresent = true;
     127           0 :   return true;
     128             : }
     129             : 
     130             : bool
     131           0 : AutocompleteInfo::Init(const nsAString& aJSON)
     132             : {
     133           0 :   AutoJSAPI jsapi;
     134           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     135           0 :   if (!cleanGlobal) {
     136           0 :     return false;
     137             :   }
     138           0 :   if (!jsapi.Init(cleanGlobal)) {
     139           0 :     return false;
     140             :   }
     141           0 :   JSContext* cx = jsapi.cx();
     142           0 :   JS::Rooted<JS::Value> json(cx);
     143           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     144           0 :   NS_ENSURE_TRUE(ok, false);
     145           0 :   return Init(cx, json);
     146             : }
     147             : 
     148             : bool
     149           0 : AutocompleteInfo::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     150             : {
     151           0 :   AutocompleteInfoAtoms* atomsCache = GetAtomCache<AutocompleteInfoAtoms>(cx);
     152           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     153           0 :     return false;
     154             :   }
     155             : 
     156           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     157           0 :   if (!obj) {
     158           0 :     return false;
     159             :   }
     160           0 :   rval.set(JS::ObjectValue(*obj));
     161             : 
     162             :   do {
     163             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     164           0 :     JS::Rooted<JS::Value> temp(cx);
     165           0 :     nsString const & currentValue = mAddressType;
     166           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     167           0 :       return false;
     168             :     }
     169           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->addressType_id, temp, JSPROP_ENUMERATE)) {
     170           0 :       return false;
     171             :     }
     172           0 :     break;
     173             :   } while(0);
     174             : 
     175             :   do {
     176             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     177           0 :     JS::Rooted<JS::Value> temp(cx);
     178           0 :     nsString const & currentValue = mContactType;
     179           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     180           0 :       return false;
     181             :     }
     182           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->contactType_id, temp, JSPROP_ENUMERATE)) {
     183           0 :       return false;
     184             :     }
     185           0 :     break;
     186             :   } while(0);
     187             : 
     188             :   do {
     189             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     190           0 :     JS::Rooted<JS::Value> temp(cx);
     191           0 :     nsString const & currentValue = mFieldName;
     192           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     193           0 :       return false;
     194             :     }
     195           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->fieldName_id, temp, JSPROP_ENUMERATE)) {
     196           0 :       return false;
     197             :     }
     198           0 :     break;
     199             :   } while(0);
     200             : 
     201             :   do {
     202             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     203           0 :     JS::Rooted<JS::Value> temp(cx);
     204           0 :     nsString const & currentValue = mSection;
     205           0 :     if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     206           0 :       return false;
     207             :     }
     208           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->section_id, temp, JSPROP_ENUMERATE)) {
     209           0 :       return false;
     210             :     }
     211           0 :     break;
     212             :   } while(0);
     213             : 
     214           0 :   return true;
     215             : }
     216             : 
     217             : bool
     218           0 : AutocompleteInfo::ToJSON(nsAString& aJSON) const
     219             : {
     220           0 :   AutoJSAPI jsapi;
     221           0 :   jsapi.Init();
     222           0 :   JSContext *cx = jsapi.cx();
     223             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     224             :   // because we'll only be creating objects, in ways that have no
     225             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     226             :   // which likewise guarantees no side-effects for the sorts of
     227             :   // things we will pass it.
     228           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     229           0 :   JS::Rooted<JS::Value> val(cx);
     230           0 :   if (!ToObjectInternal(cx, &val)) {
     231           0 :     return false;
     232             :   }
     233           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     234           0 :   return StringifyToJSON(cx, obj, aJSON);
     235             : }
     236             : 
     237             : void
     238           0 : AutocompleteInfo::TraceDictionary(JSTracer* trc)
     239             : {
     240           0 : }
     241             : 
     242             : AutocompleteInfo&
     243           0 : AutocompleteInfo::operator=(const AutocompleteInfo& aOther)
     244             : {
     245           0 :   mAddressType = aOther.mAddressType;
     246           0 :   mContactType = aOther.mContactType;
     247           0 :   mFieldName = aOther.mFieldName;
     248           0 :   mSection = aOther.mSection;
     249           0 :   return *this;
     250             : }
     251             : 
     252             : namespace binding_detail {
     253             : } // namespace binding_detail
     254             : 
     255             : 
     256             : } // namespace dom
     257             : } // namespace mozilla

Generated by: LCOV version 1.13