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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM CheckerboardReportService.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "CheckerboardReportServiceBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "jsapi.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/CheckerboardReportService.h"
      10             : #include "mozilla/dom/DOMJSClass.h"
      11             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      12             : #include "mozilla/dom/PrimitiveConversions.h"
      13             : #include "mozilla/dom/ScriptSettings.h"
      14             : #include "mozilla/dom/SimpleGlobalObject.h"
      15             : #include "mozilla/dom/XrayExpandoClass.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : namespace CheckerboardReasonValues {
      21             : extern const EnumEntry strings[3] = {
      22             :   {"severe", 6},
      23             :   {"recent", 6},
      24             :   { nullptr, 0 }
      25             : };
      26             : } // namespace CheckerboardReasonValues
      27             : 
      28             : bool
      29           0 : ToJSValue(JSContext* aCx, CheckerboardReason aArgument, JS::MutableHandle<JS::Value> aValue)
      30             : {
      31           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(CheckerboardReasonValues::strings));
      32             :   JSString* resultStr =
      33           0 :     JS_NewStringCopyN(aCx, CheckerboardReasonValues::strings[uint32_t(aArgument)].value,
      34           0 :                       CheckerboardReasonValues::strings[uint32_t(aArgument)].length);
      35           0 :   if (!resultStr) {
      36           0 :     return false;
      37             :   }
      38           0 :   aValue.setString(resultStr);
      39           0 :   return true;
      40             : }
      41             : 
      42             : 
      43             : 
      44           0 : CheckerboardReport::CheckerboardReport()
      45             : {
      46             :   // Safe to pass a null context if we pass a null value
      47           0 :   Init(nullptr, JS::NullHandleValue);
      48           0 : }
      49             : 
      50             : 
      51             : 
      52             : bool
      53           0 : CheckerboardReport::InitIds(JSContext* cx, CheckerboardReportAtoms* atomsCache)
      54             : {
      55           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      56             : 
      57             :   // Initialize these in reverse order so that any failure leaves the first one
      58             :   // uninitialized.
      59           0 :   if (!atomsCache->timestamp_id.init(cx, "timestamp") ||
      60           0 :       !atomsCache->severity_id.init(cx, "severity") ||
      61           0 :       !atomsCache->reason_id.init(cx, "reason") ||
      62           0 :       !atomsCache->log_id.init(cx, "log")) {
      63           0 :     return false;
      64             :   }
      65           0 :   return true;
      66             : }
      67             : 
      68             : bool
      69           0 : CheckerboardReport::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      70             : {
      71             :   // Passing a null JSContext is OK only if we're initing from null,
      72             :   // Since in that case we will not have to do any property gets
      73             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      74             :   // checkers by static analysis tools
      75           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      76           0 :   CheckerboardReportAtoms* atomsCache = nullptr;
      77           0 :   if (cx) {
      78           0 :     atomsCache = GetAtomCache<CheckerboardReportAtoms>(cx);
      79           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      80           0 :       return false;
      81             :     }
      82             :   }
      83             : 
      84           0 :   if (!IsConvertibleToDictionary(val)) {
      85           0 :     return ThrowErrorMessage(cx, MSG_NOT_DICTIONARY, sourceDescription);
      86             :   }
      87             : 
      88           0 :   bool isNull = val.isNullOrUndefined();
      89             :   // We only need these if !isNull, in which case we have |cx|.
      90           0 :   Maybe<JS::Rooted<JSObject *> > object;
      91           0 :   Maybe<JS::Rooted<JS::Value> > temp;
      92           0 :   if (!isNull) {
      93           0 :     MOZ_ASSERT(cx);
      94           0 :     object.emplace(cx, &val.toObject());
      95           0 :     temp.emplace(cx);
      96             :   }
      97           0 :   if (!isNull) {
      98           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->log_id, temp.ptr())) {
      99           0 :       return false;
     100             :     }
     101             :   }
     102           0 :   if (!isNull && !temp->isUndefined()) {
     103           0 :     mLog.Construct();
     104           0 :     if (!ConvertJSValueToString(cx, temp.ref(), eStringify, eStringify, (mLog.Value()))) {
     105           0 :       return false;
     106             :     }
     107           0 :     mIsAnyMemberPresent = true;
     108             :   }
     109             : 
     110           0 :   if (!isNull) {
     111           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->reason_id, temp.ptr())) {
     112           0 :       return false;
     113             :     }
     114             :   }
     115           0 :   if (!isNull && !temp->isUndefined()) {
     116           0 :     mReason.Construct();
     117             :     {
     118             :       int index;
     119           0 :       if (!FindEnumStringIndex<true>(cx, temp.ref(), CheckerboardReasonValues::strings, "CheckerboardReason", "'reason' member of CheckerboardReport", &index)) {
     120           0 :         return false;
     121             :       }
     122           0 :       MOZ_ASSERT(index >= 0);
     123           0 :       (mReason.Value()) = static_cast<CheckerboardReason>(index);
     124             :     }
     125           0 :     mIsAnyMemberPresent = true;
     126             :   }
     127             : 
     128           0 :   if (!isNull) {
     129           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->severity_id, temp.ptr())) {
     130           0 :       return false;
     131             :     }
     132             :   }
     133           0 :   if (!isNull && !temp->isUndefined()) {
     134           0 :     mSeverity.Construct();
     135           0 :     if (!ValueToPrimitive<uint32_t, eDefault>(cx, temp.ref(), &(mSeverity.Value()))) {
     136           0 :       return false;
     137             :     }
     138           0 :     mIsAnyMemberPresent = true;
     139             :   }
     140             : 
     141           0 :   if (!isNull) {
     142           0 :     if (!JS_GetPropertyById(cx, *object, atomsCache->timestamp_id, temp.ptr())) {
     143           0 :       return false;
     144             :     }
     145             :   }
     146           0 :   if (!isNull && !temp->isUndefined()) {
     147           0 :     mTimestamp.Construct();
     148           0 :     if (!ValueToPrimitive<uint64_t, eDefault>(cx, temp.ref(), &(mTimestamp.Value()))) {
     149           0 :       return false;
     150             :     }
     151           0 :     mIsAnyMemberPresent = true;
     152             :   }
     153           0 :   return true;
     154             : }
     155             : 
     156             : bool
     157           0 : CheckerboardReport::Init(const nsAString& aJSON)
     158             : {
     159           0 :   AutoJSAPI jsapi;
     160           0 :   JSObject* cleanGlobal = SimpleGlobalObject::Create(SimpleGlobalObject::GlobalType::BindingDetail);
     161           0 :   if (!cleanGlobal) {
     162           0 :     return false;
     163             :   }
     164           0 :   if (!jsapi.Init(cleanGlobal)) {
     165           0 :     return false;
     166             :   }
     167           0 :   JSContext* cx = jsapi.cx();
     168           0 :   JS::Rooted<JS::Value> json(cx);
     169           0 :   bool ok = ParseJSON(cx, aJSON, &json);
     170           0 :   NS_ENSURE_TRUE(ok, false);
     171           0 :   return Init(cx, json);
     172             : }
     173             : 
     174             : bool
     175           0 : CheckerboardReport::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     176             : {
     177           0 :   CheckerboardReportAtoms* atomsCache = GetAtomCache<CheckerboardReportAtoms>(cx);
     178           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     179           0 :     return false;
     180             :   }
     181             : 
     182           0 :   JS::Rooted<JSObject*> obj(cx, JS_NewPlainObject(cx));
     183           0 :   if (!obj) {
     184           0 :     return false;
     185             :   }
     186           0 :   rval.set(JS::ObjectValue(*obj));
     187             : 
     188           0 :   if (mLog.WasPassed()) {
     189             :     do {
     190             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     191           0 :       JS::Rooted<JS::Value> temp(cx);
     192           0 :       nsString const & currentValue = mLog.InternalValue();
     193           0 :       if (!xpc::NonVoidStringToJsval(cx, currentValue, &temp)) {
     194           0 :         return false;
     195             :       }
     196           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->log_id, temp, JSPROP_ENUMERATE)) {
     197           0 :         return false;
     198             :       }
     199           0 :       break;
     200             :     } while(0);
     201             :   }
     202             : 
     203           0 :   if (mReason.WasPassed()) {
     204             :     do {
     205             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     206           0 :       JS::Rooted<JS::Value> temp(cx);
     207           0 :       CheckerboardReason const & currentValue = mReason.InternalValue();
     208           0 :       if (!ToJSValue(cx, currentValue, &temp)) {
     209           0 :         return false;
     210             :       }
     211           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->reason_id, temp, JSPROP_ENUMERATE)) {
     212           0 :         return false;
     213             :       }
     214           0 :       break;
     215             :     } while(0);
     216             :   }
     217             : 
     218           0 :   if (mSeverity.WasPassed()) {
     219             :     do {
     220             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     221           0 :       JS::Rooted<JS::Value> temp(cx);
     222           0 :       uint32_t const & currentValue = mSeverity.InternalValue();
     223           0 :       temp.setNumber(currentValue);
     224           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->severity_id, temp, JSPROP_ENUMERATE)) {
     225           0 :         return false;
     226             :       }
     227           0 :       break;
     228             :     } while(0);
     229             :   }
     230             : 
     231           0 :   if (mTimestamp.WasPassed()) {
     232             :     do {
     233             :       // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     234           0 :       JS::Rooted<JS::Value> temp(cx);
     235           0 :       uint64_t const & currentValue = mTimestamp.InternalValue();
     236           0 :       temp.set(JS_NumberValue(double(currentValue)));
     237           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->timestamp_id, temp, JSPROP_ENUMERATE)) {
     238           0 :         return false;
     239             :       }
     240           0 :       break;
     241             :     } while(0);
     242             :   }
     243             : 
     244           0 :   return true;
     245             : }
     246             : 
     247             : bool
     248           0 : CheckerboardReport::ToJSON(nsAString& aJSON) const
     249             : {
     250           0 :   AutoJSAPI jsapi;
     251           0 :   jsapi.Init();
     252           0 :   JSContext *cx = jsapi.cx();
     253             :   // It's safe to use UnprivilegedJunkScopeOrWorkerGlobal here
     254             :   // because we'll only be creating objects, in ways that have no
     255             :   // side-effects, followed by a call to JS::ToJSONMaybeSafely,
     256             :   // which likewise guarantees no side-effects for the sorts of
     257             :   // things we will pass it.
     258           0 :   JSAutoCompartment ac(cx, binding_detail::UnprivilegedJunkScopeOrWorkerGlobal());
     259           0 :   JS::Rooted<JS::Value> val(cx);
     260           0 :   if (!ToObjectInternal(cx, &val)) {
     261           0 :     return false;
     262             :   }
     263           0 :   JS::Rooted<JSObject*> obj(cx, &val.toObject());
     264           0 :   return StringifyToJSON(cx, obj, aJSON);
     265             : }
     266             : 
     267             : void
     268           0 : CheckerboardReport::TraceDictionary(JSTracer* trc)
     269             : {
     270           0 : }
     271             : 
     272             : CheckerboardReport&
     273           0 : CheckerboardReport::operator=(const CheckerboardReport& aOther)
     274             : {
     275           0 :   mLog.Reset();
     276           0 :   if (aOther.mLog.WasPassed()) {
     277           0 :     mLog.Construct(aOther.mLog.Value());
     278             :   }
     279           0 :   mReason.Reset();
     280           0 :   if (aOther.mReason.WasPassed()) {
     281           0 :     mReason.Construct(aOther.mReason.Value());
     282             :   }
     283           0 :   mSeverity.Reset();
     284           0 :   if (aOther.mSeverity.WasPassed()) {
     285           0 :     mSeverity.Construct(aOther.mSeverity.Value());
     286             :   }
     287           0 :   mTimestamp.Reset();
     288           0 :   if (aOther.mTimestamp.WasPassed()) {
     289           0 :     mTimestamp.Construct(aOther.mTimestamp.Value());
     290             :   }
     291           0 :   return *this;
     292             : }
     293             : 
     294             : namespace binding_detail {
     295             : } // namespace binding_detail
     296             : 
     297             : 
     298             : namespace CheckerboardReportServiceBinding {
     299             : 
     300             : static bool
     301           0 : getReports(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CheckerboardReportService* self, const JSJitMethodCallArgs& args)
     302             : {
     303           0 :   nsTArray<CheckerboardReport> result;
     304           0 :   self->GetReports(result);
     305           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     306             : 
     307           0 :   uint32_t length = result.Length();
     308           0 :   JS::Rooted<JSObject*> returnArray(cx, JS_NewArrayObject(cx, length));
     309           0 :   if (!returnArray) {
     310           0 :     return false;
     311             :   }
     312             :   // Scope for 'tmp'
     313             :   {
     314           0 :     JS::Rooted<JS::Value> tmp(cx);
     315           0 :     for (uint32_t sequenceIdx0 = 0; sequenceIdx0 < length; ++sequenceIdx0) {
     316             :       // Control block to let us common up the JS_DefineElement calls when there
     317             :       // are different ways to succeed at wrapping the object.
     318             :       do {
     319           0 :         if (!result[sequenceIdx0].ToObjectInternal(cx, &tmp)) {
     320           0 :           return false;
     321             :         }
     322           0 :         break;
     323             :       } while (0);
     324           0 :       if (!JS_DefineElement(cx, returnArray, sequenceIdx0, tmp,
     325             :                             JSPROP_ENUMERATE)) {
     326           0 :         return false;
     327             :       }
     328             :     }
     329             :   }
     330           0 :   args.rval().setObject(*returnArray);
     331           0 :   return true;
     332             : }
     333             : 
     334             : static const JSJitInfo getReports_methodinfo = {
     335             :   { (JSJitGetterOp)getReports },
     336             :   { prototypes::id::CheckerboardReportService },
     337             :   { PrototypeTraits<prototypes::id::CheckerboardReportService>::Depth },
     338             :   JSJitInfo::Method,
     339             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     340             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     341             :   false,  /* isInfallible. False in setters. */
     342             :   false,  /* isMovable.  Not relevant for setters. */
     343             :   false, /* isEliminatable.  Not relevant for setters. */
     344             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     345             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     346             :   false,  /* isTypedMethod.  Only relevant for methods. */
     347             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     348             : };
     349             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     350             : static_assert(0 < 1, "There is no slot for us");
     351             : 
     352             : static bool
     353           0 : isRecordingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CheckerboardReportService* self, const JSJitMethodCallArgs& args)
     354             : {
     355           0 :   bool result(self->IsRecordingEnabled());
     356           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     357           0 :   args.rval().setBoolean(result);
     358           0 :   return true;
     359             : }
     360             : 
     361             : static const JSJitInfo isRecordingEnabled_methodinfo = {
     362             :   { (JSJitGetterOp)isRecordingEnabled },
     363             :   { prototypes::id::CheckerboardReportService },
     364             :   { PrototypeTraits<prototypes::id::CheckerboardReportService>::Depth },
     365             :   JSJitInfo::Method,
     366             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     367             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     368             :   true,  /* isInfallible. False in setters. */
     369             :   false,  /* isMovable.  Not relevant for setters. */
     370             :   false, /* isEliminatable.  Not relevant for setters. */
     371             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     372             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     373             :   false,  /* isTypedMethod.  Only relevant for methods. */
     374             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     375             : };
     376             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     377             : static_assert(0 < 1, "There is no slot for us");
     378             : 
     379             : static bool
     380           0 : setRecordingEnabled(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CheckerboardReportService* self, const JSJitMethodCallArgs& args)
     381             : {
     382           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     383           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "CheckerboardReportService.setRecordingEnabled");
     384             :   }
     385             :   bool arg0;
     386           0 :   if (!ValueToPrimitive<bool, eDefault>(cx, args[0], &arg0)) {
     387           0 :     return false;
     388             :   }
     389           0 :   self->SetRecordingEnabled(arg0);
     390           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     391           0 :   args.rval().setUndefined();
     392           0 :   return true;
     393             : }
     394             : 
     395             : static const JSJitInfo setRecordingEnabled_methodinfo = {
     396             :   { (JSJitGetterOp)setRecordingEnabled },
     397             :   { prototypes::id::CheckerboardReportService },
     398             :   { PrototypeTraits<prototypes::id::CheckerboardReportService>::Depth },
     399             :   JSJitInfo::Method,
     400             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     401             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     402             :   false,  /* isInfallible. False in setters. */
     403             :   false,  /* isMovable.  Not relevant for setters. */
     404             :   false, /* isEliminatable.  Not relevant for setters. */
     405             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     406             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     407             :   false,  /* isTypedMethod.  Only relevant for methods. */
     408             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     409             : };
     410             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     411             : static_assert(0 < 1, "There is no slot for us");
     412             : 
     413             : static bool
     414           0 : flushActiveReports(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::CheckerboardReportService* self, const JSJitMethodCallArgs& args)
     415             : {
     416           0 :   self->FlushActiveReports();
     417           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     418           0 :   args.rval().setUndefined();
     419           0 :   return true;
     420             : }
     421             : 
     422             : static const JSJitInfo flushActiveReports_methodinfo = {
     423             :   { (JSJitGetterOp)flushActiveReports },
     424             :   { prototypes::id::CheckerboardReportService },
     425             :   { PrototypeTraits<prototypes::id::CheckerboardReportService>::Depth },
     426             :   JSJitInfo::Method,
     427             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     428             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     429             :   true,  /* isInfallible. False in setters. */
     430             :   false,  /* isMovable.  Not relevant for setters. */
     431             :   false, /* isEliminatable.  Not relevant for setters. */
     432             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     433             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     434             :   false,  /* isTypedMethod.  Only relevant for methods. */
     435             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     436             : };
     437             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     438             : static_assert(0 < 1, "There is no slot for us");
     439             : 
     440             : static bool
     441           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     442             : {
     443           0 :   mozilla::dom::CheckerboardReportService* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CheckerboardReportService>(obj);
     444             :   // We don't want to preserve if we don't have a wrapper, and we
     445             :   // obviously can't preserve if we're not initialized.
     446           0 :   if (self && self->GetWrapperPreserveColor()) {
     447           0 :     PreserveWrapper(self);
     448             :   }
     449           0 :   return true;
     450             : }
     451             : 
     452             : static void
     453           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     454             : {
     455           0 :   mozilla::dom::CheckerboardReportService* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CheckerboardReportService>(obj);
     456           0 :   if (self) {
     457           0 :     ClearWrapper(self, self, obj);
     458           0 :     AddForDeferredFinalization<mozilla::dom::CheckerboardReportService>(self);
     459             :   }
     460           0 : }
     461             : 
     462             : static void
     463           0 : _objectMoved(JSObject* obj, const JSObject* old)
     464             : {
     465           0 :   mozilla::dom::CheckerboardReportService* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::CheckerboardReportService>(obj);
     466           0 :   if (self) {
     467           0 :     UpdateWrapper(self, self, obj, old);
     468             :   }
     469           0 : }
     470             : 
     471             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     472             : #if defined(__clang__)
     473             : #pragma clang diagnostic push
     474             : #pragma clang diagnostic ignored "-Wmissing-braces"
     475             : #endif
     476             : static const JSFunctionSpec sMethods_specs[] = {
     477             :   JS_FNSPEC("getReports", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&getReports_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     478             :   JS_FNSPEC("isRecordingEnabled", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&isRecordingEnabled_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     479             :   JS_FNSPEC("setRecordingEnabled", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&setRecordingEnabled_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     480             :   JS_FNSPEC("flushActiveReports", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&flushActiveReports_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     481             :   JS_FS_END
     482             : };
     483             : #if defined(__clang__)
     484             : #pragma clang diagnostic pop
     485             : #endif
     486             : 
     487             : 
     488             : // Can't be const because the pref-enabled boolean needs to be writable
     489             : static Prefable<const JSFunctionSpec> sMethods[] = {
     490             :   { nullptr, &sMethods_specs[0] },
     491             :   { nullptr, nullptr }
     492             : };
     493             : 
     494             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     495             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     496             : static_assert(4 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     497             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     498             : 
     499             : 
     500             : static uint16_t sNativeProperties_sortedPropertyIndices[4];
     501             : static PropertyInfo sNativeProperties_propertyInfos[4];
     502             : 
     503             : static const NativePropertiesN<1> sNativeProperties = {
     504             :   false, 0,
     505             :   false, 0,
     506             :   true,  0 /* sMethods */,
     507             :   false, 0,
     508             :   false, 0,
     509             :   false, 0,
     510             :   false, 0,
     511             :   -1,
     512             :   4,
     513             :   sNativeProperties_sortedPropertyIndices,
     514             :   {
     515             :     { sMethods, &sNativeProperties_propertyInfos[0] }
     516             :   }
     517             : };
     518             : static_assert(4 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     519             :     "We have a property info count that is oversized");
     520             : 
     521             : static bool
     522           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     523             : {
     524           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     525           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     526           0 :   if (!args.isConstructing()) {
     527             :     // XXXbz wish I could get the name from the callee instead of
     528             :     // Adding more relocations
     529           0 :     return ThrowConstructorWithoutNew(cx, "CheckerboardReportService");
     530             :   }
     531             : 
     532           0 :   GlobalObject global(cx, obj);
     533           0 :   if (global.Failed()) {
     534           0 :     return false;
     535             :   }
     536             : 
     537           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     538           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     539           0 :     return false;
     540             :   }
     541             : 
     542           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     543           0 :   Maybe<JSAutoCompartment> ac;
     544           0 :   if (objIsXray) {
     545           0 :     obj = js::CheckedUnwrap(obj);
     546           0 :     if (!obj) {
     547           0 :       return false;
     548             :     }
     549           0 :     ac.emplace(cx, obj);
     550           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     551           0 :       return false;
     552             :     }
     553             :   }
     554           0 :   binding_detail::FastErrorResult rv;
     555           0 :   auto result(StrongOrRawPtr<mozilla::dom::CheckerboardReportService>(mozilla::dom::CheckerboardReportService::Constructor(global, rv)));
     556           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     557           0 :     return false;
     558             :   }
     559           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     560             :   static_assert(!IsPointer<decltype(result)>::value,
     561             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     562           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     563           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     564           0 :     return false;
     565             :   }
     566           0 :   return true;
     567             : }
     568             : 
     569             : static const js::ClassOps sInterfaceObjectClassOps = {
     570             :     nullptr,               /* addProperty */
     571             :     nullptr,               /* delProperty */
     572             :     nullptr,               /* getProperty */
     573             :     nullptr,               /* setProperty */
     574             :     nullptr,               /* enumerate */
     575             :     nullptr,               /* newEnumerate */
     576             :     nullptr,               /* resolve */
     577             :     nullptr,               /* mayResolve */
     578             :     nullptr,               /* finalize */
     579             :     _constructor, /* call */
     580             :     nullptr,               /* hasInstance */
     581             :     _constructor, /* construct */
     582             :     nullptr,               /* trace */
     583             : };
     584             : 
     585             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     586             :   {
     587             :     "Function",
     588             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     589             :     &sInterfaceObjectClassOps,
     590             :     JS_NULL_CLASS_SPEC,
     591             :     JS_NULL_CLASS_EXT,
     592             :     &sInterfaceObjectClassObjectOps
     593             :   },
     594             :   eInterface,
     595             :   true,
     596             :   prototypes::id::CheckerboardReportService,
     597             :   PrototypeTraits<prototypes::id::CheckerboardReportService>::Depth,
     598             :   sNativePropertyHooks,
     599             :   "function CheckerboardReportService() {\n    [native code]\n}",
     600             :   JS::GetRealmFunctionPrototype
     601             : };
     602             : 
     603             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     604             :   {
     605             :     "CheckerboardReportServicePrototype",
     606             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     607             :     JS_NULL_CLASS_OPS,
     608             :     JS_NULL_CLASS_SPEC,
     609             :     JS_NULL_CLASS_EXT,
     610             :     JS_NULL_OBJECT_OPS
     611             :   },
     612             :   eInterfacePrototype,
     613             :   false,
     614             :   prototypes::id::CheckerboardReportService,
     615             :   PrototypeTraits<prototypes::id::CheckerboardReportService>::Depth,
     616             :   sNativePropertyHooks,
     617             :   "[object CheckerboardReportServicePrototype]",
     618             :   JS::GetRealmObjectPrototype
     619             : };
     620             : 
     621             : bool
     622           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     623             : {
     624           0 :   return mozilla::dom::CheckerboardReportService::IsEnabled(aCx, aObj);
     625             : }
     626             : 
     627             : JSObject*
     628           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     629             : {
     630           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     631             : }
     632             : 
     633             : static const js::ClassOps sClassOps = {
     634             :   _addProperty, /* addProperty */
     635             :   nullptr,               /* delProperty */
     636             :   nullptr,               /* getProperty */
     637             :   nullptr,               /* setProperty */
     638             :   nullptr,               /* enumerate */
     639             :   nullptr, /* newEnumerate */
     640             :   nullptr, /* resolve */
     641             :   nullptr, /* mayResolve */
     642             :   _finalize, /* finalize */
     643             :   nullptr, /* call */
     644             :   nullptr,               /* hasInstance */
     645             :   nullptr,               /* construct */
     646             :   nullptr, /* trace */
     647             : };
     648             : 
     649             : static const js::ClassExtension sClassExtension = {
     650             :   nullptr, /* weakmapKeyDelegateOp */
     651             :   _objectMoved /* objectMovedOp */
     652             : };
     653             : 
     654             : static const DOMJSClass sClass = {
     655             :   { "CheckerboardReportService",
     656             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     657             :     &sClassOps,
     658             :     JS_NULL_CLASS_SPEC,
     659             :     &sClassExtension,
     660             :     JS_NULL_OBJECT_OPS
     661             :   },
     662             :   { prototypes::id::CheckerboardReportService, 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 },
     663             :   IsBaseOf<nsISupports, mozilla::dom::CheckerboardReportService >::value,
     664             :   sNativePropertyHooks,
     665             :   FindAssociatedGlobalForNative<mozilla::dom::CheckerboardReportService>::Get,
     666             :   GetProtoObjectHandle,
     667             :   GetCCParticipant<mozilla::dom::CheckerboardReportService>::Get()
     668             : };
     669             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     670             :               "Must have the right minimal number of reserved slots.");
     671             : static_assert(1 >= 1,
     672             :               "Must have enough reserved slots.");
     673             : 
     674             : const JSClass*
     675           0 : GetJSClass()
     676             : {
     677           0 :   return sClass.ToJSClass();
     678             : }
     679             : 
     680             : bool
     681           0 : Wrap(JSContext* aCx, mozilla::dom::CheckerboardReportService* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     682             : {
     683             :   MOZ_ASSERT(static_cast<mozilla::dom::CheckerboardReportService*>(aObject) ==
     684             :              reinterpret_cast<mozilla::dom::CheckerboardReportService*>(aObject),
     685             :              "Multiple inheritance for mozilla::dom::CheckerboardReportService is broken.");
     686           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     687           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     688           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     689             :              "You should probably not be using Wrap() directly; use "
     690             :              "GetOrCreateDOMReflector instead");
     691             : 
     692           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     693             :              "nsISupports must be on our primary inheritance chain");
     694             : 
     695           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     696           0 :   if (!global) {
     697           0 :     return false;
     698             :   }
     699           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     700           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     701             : 
     702             :   // That might have ended up wrapping us already, due to the wonders
     703             :   // of XBL.  Check for that, and bail out as needed.
     704           0 :   aReflector.set(aCache->GetWrapper());
     705           0 :   if (aReflector) {
     706             : #ifdef DEBUG
     707           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     708             : #endif // DEBUG
     709           0 :     return true;
     710             :   }
     711             : 
     712           0 :   JSAutoCompartment ac(aCx, global);
     713           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     714           0 :   if (!canonicalProto) {
     715           0 :     return false;
     716             :   }
     717           0 :   JS::Rooted<JSObject*> proto(aCx);
     718           0 :   if (aGivenProto) {
     719           0 :     proto = aGivenProto;
     720             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     721             :     // coming in, we changed compartments to that of "parent" so may need
     722             :     // to wrap the proto here.
     723           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     724           0 :       if (!JS_WrapObject(aCx, &proto)) {
     725           0 :         return false;
     726             :       }
     727             :     }
     728             :   } else {
     729           0 :     proto = canonicalProto;
     730             :   }
     731             : 
     732           0 :   BindingJSObjectCreator<mozilla::dom::CheckerboardReportService> creator(aCx);
     733           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     734           0 :   if (!aReflector) {
     735           0 :     return false;
     736             :   }
     737             : 
     738           0 :   aCache->SetWrapper(aReflector);
     739           0 :   creator.InitializationSucceeded();
     740             : 
     741           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     742             :              aCache->GetWrapperPreserveColor() == aReflector);
     743             :   // If proto != canonicalProto, we have to preserve our wrapper;
     744             :   // otherwise we won't be able to properly recreate it later, since
     745             :   // we won't know what proto to use.  Note that we don't check
     746             :   // aGivenProto here, since it's entirely possible (and even
     747             :   // somewhat common) to have a non-null aGivenProto which is the
     748             :   // same as canonicalProto.
     749           0 :   if (proto != canonicalProto) {
     750           0 :     PreserveWrapper(aObject);
     751             :   }
     752             : 
     753           0 :   return true;
     754             : }
     755             : 
     756             : const NativePropertyHooks sNativePropertyHooks[] = { {
     757             :   nullptr,
     758             :   nullptr,
     759             :   nullptr,
     760             :   { sNativeProperties.Upcast(), nullptr },
     761             :   prototypes::id::CheckerboardReportService,
     762             :   constructors::id::CheckerboardReportService,
     763             :   nullptr,
     764             :   &DefaultXrayExpandoObjectClass
     765             : } };
     766             : 
     767             : void
     768           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     769             : {
     770           0 :   JS::Rooted<JSObject*> parentProto(aCx, JS::GetRealmObjectPrototype(aCx));
     771           0 :   if (!parentProto) {
     772           0 :     return;
     773             :   }
     774             : 
     775           0 :   JS::Rooted<JSObject*> constructorProto(aCx, JS::GetRealmFunctionPrototype(aCx));
     776           0 :   if (!constructorProto) {
     777           0 :     return;
     778             :   }
     779             : 
     780             :   static bool sIdsInited = false;
     781           0 :   if (!sIdsInited && NS_IsMainThread()) {
     782           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     783           0 :       return;
     784             :     }
     785           0 :     sIdsInited = true;
     786             :   }
     787             : 
     788           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::CheckerboardReportService);
     789           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::CheckerboardReportService);
     790           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     791             :                               &sPrototypeClass.mBase, protoCache,
     792             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     793             :                               interfaceCache,
     794             :                               sNativeProperties.Upcast(),
     795             :                               nullptr,
     796             :                               "CheckerboardReportService", aDefineOnGlobal,
     797             :                               nullptr,
     798           0 :                               false);
     799             : }
     800             : 
     801             : JS::Handle<JSObject*>
     802           0 : GetProtoObjectHandle(JSContext* aCx)
     803             : {
     804             :   /* Get the interface prototype object for this class.  This will create the
     805             :      object as needed. */
     806           0 :   bool aDefineOnGlobal = true;
     807             : 
     808             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     809           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     810           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     811           0 :     return nullptr;
     812             :   }
     813             : 
     814             :   /* Check to see whether the interface objects are already installed */
     815           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     816           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::CheckerboardReportService)) {
     817           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     818           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     819             :   }
     820             : 
     821             :   /*
     822             :    * The object might _still_ be null, but that's OK.
     823             :    *
     824             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     825             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     826             :    * changed after they have been set.
     827             :    *
     828             :    * Calling address() avoids the read read barrier that does gray
     829             :    * unmarking, but it's not possible for the object to be gray here.
     830             :    */
     831             : 
     832           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::CheckerboardReportService);
     833           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     834           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     835             : }
     836             : 
     837             : JS::Handle<JSObject*>
     838           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     839             : {
     840             :   /* Get the interface object for this class.  This will create the object as
     841             :      needed. */
     842             : 
     843             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     844           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     845           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     846           0 :     return nullptr;
     847             :   }
     848             : 
     849             :   /* Check to see whether the interface objects are already installed */
     850           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     851           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::CheckerboardReportService)) {
     852           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     853           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     854             :   }
     855             : 
     856             :   /*
     857             :    * The object might _still_ be null, but that's OK.
     858             :    *
     859             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     860             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     861             :    * changed after they have been set.
     862             :    *
     863             :    * Calling address() avoids the read read barrier that does gray
     864             :    * unmarking, but it's not possible for the object to be gray here.
     865             :    */
     866             : 
     867           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::CheckerboardReportService);
     868           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     869           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     870             : }
     871             : 
     872             : JSObject*
     873           0 : GetConstructorObject(JSContext* aCx)
     874             : {
     875           0 :   return GetConstructorObjectHandle(aCx);
     876             : }
     877             : 
     878             : } // namespace CheckerboardReportServiceBinding
     879             : 
     880             : 
     881             : 
     882             : } // namespace dom
     883             : } // namespace mozilla

Generated by: LCOV version 1.13