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

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

Generated by: LCOV version 1.13