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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM PresentationConnection.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "EventHandlerBinding.h"
       4             : #include "EventTargetBinding.h"
       5             : #include "PresentationConnectionBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "jsapi.h"
       8             : #include "jsfriendapi.h"
       9             : #include "mozilla/OwningNonNull.h"
      10             : #include "mozilla/Preferences.h"
      11             : #include "mozilla/dom/BindingUtils.h"
      12             : #include "mozilla/dom/Blob.h"
      13             : #include "mozilla/dom/DOMJSClass.h"
      14             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      15             : #include "mozilla/dom/Nullable.h"
      16             : #include "mozilla/dom/PresentationConnection.h"
      17             : #include "mozilla/dom/TypedArray.h"
      18             : #include "mozilla/dom/XrayExpandoClass.h"
      19             : 
      20             : namespace mozilla {
      21             : namespace dom {
      22             : 
      23             : namespace PresentationConnectionStateValues {
      24             : extern const EnumEntry strings[5] = {
      25             :   {"connecting", 10},
      26             :   {"connected", 9},
      27             :   {"closed", 6},
      28             :   {"terminated", 10},
      29             :   { nullptr, 0 }
      30             : };
      31             : } // namespace PresentationConnectionStateValues
      32             : 
      33             : bool
      34           0 : ToJSValue(JSContext* aCx, PresentationConnectionState aArgument, JS::MutableHandle<JS::Value> aValue)
      35             : {
      36           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(PresentationConnectionStateValues::strings));
      37             :   JSString* resultStr =
      38           0 :     JS_NewStringCopyN(aCx, PresentationConnectionStateValues::strings[uint32_t(aArgument)].value,
      39           0 :                       PresentationConnectionStateValues::strings[uint32_t(aArgument)].length);
      40           0 :   if (!resultStr) {
      41           0 :     return false;
      42             :   }
      43           0 :   aValue.setString(resultStr);
      44           0 :   return true;
      45             : }
      46             : 
      47             : 
      48             : namespace PresentationConnectionBinaryTypeValues {
      49             : extern const EnumEntry strings[3] = {
      50             :   {"blob", 4},
      51             :   {"arraybuffer", 11},
      52             :   { nullptr, 0 }
      53             : };
      54             : } // namespace PresentationConnectionBinaryTypeValues
      55             : 
      56             : bool
      57           0 : ToJSValue(JSContext* aCx, PresentationConnectionBinaryType aArgument, JS::MutableHandle<JS::Value> aValue)
      58             : {
      59           0 :   MOZ_ASSERT(uint32_t(aArgument) < ArrayLength(PresentationConnectionBinaryTypeValues::strings));
      60             :   JSString* resultStr =
      61           0 :     JS_NewStringCopyN(aCx, PresentationConnectionBinaryTypeValues::strings[uint32_t(aArgument)].value,
      62           0 :                       PresentationConnectionBinaryTypeValues::strings[uint32_t(aArgument)].length);
      63           0 :   if (!resultStr) {
      64           0 :     return false;
      65             :   }
      66           0 :   aValue.setString(resultStr);
      67           0 :   return true;
      68             : }
      69             : 
      70             : 
      71             : namespace PresentationConnectionBinding {
      72             : 
      73             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventTargetBinding::NativeType>::value,
      74             :               "Can't inherit from an interface with a different ownership model.");
      75             : 
      76             : static bool
      77           0 : get_id(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitGetterCallArgs args)
      78             : {
      79           0 :   DOMString result;
      80           0 :   self->GetId(result);
      81           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
      82           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
      83           0 :     return false;
      84             :   }
      85           0 :   return true;
      86             : }
      87             : 
      88             : static const JSJitInfo id_getterinfo = {
      89             :   { (JSJitGetterOp)get_id },
      90             :   { prototypes::id::PresentationConnection },
      91             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
      92             :   JSJitInfo::Getter,
      93             :   JSJitInfo::AliasNone, /* aliasSet.  Not relevant for setters. */
      94             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
      95             :   false,  /* isInfallible. False in setters. */
      96             :   true,  /* isMovable.  Not relevant for setters. */
      97             :   true, /* isEliminatable.  Not relevant for setters. */
      98             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
      99             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     100             :   false,  /* isTypedMethod.  Only relevant for methods. */
     101             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     102             : };
     103             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     104             : static_assert(0 < 1, "There is no slot for us");
     105             : 
     106             : static bool
     107           0 : get_url(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitGetterCallArgs args)
     108             : {
     109           0 :   DOMString result;
     110           0 :   self->GetUrl(result);
     111           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     112           0 :   if (!xpc::NonVoidStringToJsval(cx, result, args.rval())) {
     113           0 :     return false;
     114             :   }
     115           0 :   return true;
     116             : }
     117             : 
     118             : static const JSJitInfo url_getterinfo = {
     119             :   { (JSJitGetterOp)get_url },
     120             :   { prototypes::id::PresentationConnection },
     121             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     122             :   JSJitInfo::Getter,
     123             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     124             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     125             :   false,  /* isInfallible. False in setters. */
     126             :   false,  /* isMovable.  Not relevant for setters. */
     127             :   false, /* isEliminatable.  Not relevant for setters. */
     128             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     129             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     130             :   false,  /* isTypedMethod.  Only relevant for methods. */
     131             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     132             : };
     133             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     134             : static_assert(0 < 1, "There is no slot for us");
     135             : 
     136             : static bool
     137           0 : get_state(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitGetterCallArgs args)
     138             : {
     139           0 :   PresentationConnectionState result(self->State());
     140           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     141           0 :   if (!ToJSValue(cx, result, args.rval())) {
     142           0 :     return false;
     143             :   }
     144           0 :   return true;
     145             : }
     146             : 
     147             : static const JSJitInfo state_getterinfo = {
     148             :   { (JSJitGetterOp)get_state },
     149             :   { prototypes::id::PresentationConnection },
     150             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     151             :   JSJitInfo::Getter,
     152             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     153             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     154             :   false,  /* isInfallible. False in setters. */
     155             :   false,  /* isMovable.  Not relevant for setters. */
     156             :   false, /* isEliminatable.  Not relevant for setters. */
     157             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     158             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     159             :   false,  /* isTypedMethod.  Only relevant for methods. */
     160             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     161             : };
     162             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     163             : static_assert(0 < 1, "There is no slot for us");
     164             : 
     165             : static bool
     166           0 : get_onconnect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitGetterCallArgs args)
     167             : {
     168           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnconnect());
     169           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     170           0 :   if (result) {
     171           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     172           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     173           0 :       return false;
     174             :     }
     175           0 :     return true;
     176             :   } else {
     177           0 :     args.rval().setNull();
     178           0 :     return true;
     179             :   }
     180             : }
     181             : 
     182             : static bool
     183           0 : set_onconnect(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitSetterCallArgs args)
     184             : {
     185           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     186           0 :   if (args[0].isObject()) {
     187             :     { // scope for tempRoot
     188           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     189           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     190             :     }
     191             :   } else {
     192           0 :     arg0 = nullptr;
     193             :   }
     194           0 :   self->SetOnconnect(Constify(arg0));
     195           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     196             : 
     197           0 :   return true;
     198             : }
     199             : 
     200             : static const JSJitInfo onconnect_getterinfo = {
     201             :   { (JSJitGetterOp)get_onconnect },
     202             :   { prototypes::id::PresentationConnection },
     203             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     204             :   JSJitInfo::Getter,
     205             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     206             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     207             :   false,  /* isInfallible. False in setters. */
     208             :   false,  /* isMovable.  Not relevant for setters. */
     209             :   false, /* isEliminatable.  Not relevant for setters. */
     210             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     211             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     212             :   false,  /* isTypedMethod.  Only relevant for methods. */
     213             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     214             : };
     215             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     216             : static_assert(0 < 1, "There is no slot for us");
     217             : static const JSJitInfo onconnect_setterinfo = {
     218             :   { (JSJitGetterOp)set_onconnect },
     219             :   { prototypes::id::PresentationConnection },
     220             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     221             :   JSJitInfo::Setter,
     222             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     223             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     224             :   false,  /* isInfallible. False in setters. */
     225             :   false,  /* isMovable.  Not relevant for setters. */
     226             :   false, /* isEliminatable.  Not relevant for setters. */
     227             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     228             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     229             :   false,  /* isTypedMethod.  Only relevant for methods. */
     230             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     231             : };
     232             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     233             : static_assert(0 < 1, "There is no slot for us");
     234             : 
     235             : static bool
     236           0 : get_onclose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitGetterCallArgs args)
     237             : {
     238           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnclose());
     239           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     240           0 :   if (result) {
     241           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     242           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     243           0 :       return false;
     244             :     }
     245           0 :     return true;
     246             :   } else {
     247           0 :     args.rval().setNull();
     248           0 :     return true;
     249             :   }
     250             : }
     251             : 
     252             : static bool
     253           0 : set_onclose(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitSetterCallArgs args)
     254             : {
     255           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     256           0 :   if (args[0].isObject()) {
     257             :     { // scope for tempRoot
     258           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     259           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     260             :     }
     261             :   } else {
     262           0 :     arg0 = nullptr;
     263             :   }
     264           0 :   self->SetOnclose(Constify(arg0));
     265           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     266             : 
     267           0 :   return true;
     268             : }
     269             : 
     270             : static const JSJitInfo onclose_getterinfo = {
     271             :   { (JSJitGetterOp)get_onclose },
     272             :   { prototypes::id::PresentationConnection },
     273             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     274             :   JSJitInfo::Getter,
     275             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     276             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     277             :   false,  /* isInfallible. False in setters. */
     278             :   false,  /* isMovable.  Not relevant for setters. */
     279             :   false, /* isEliminatable.  Not relevant for setters. */
     280             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     281             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     282             :   false,  /* isTypedMethod.  Only relevant for methods. */
     283             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     284             : };
     285             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     286             : static_assert(0 < 1, "There is no slot for us");
     287             : static const JSJitInfo onclose_setterinfo = {
     288             :   { (JSJitGetterOp)set_onclose },
     289             :   { prototypes::id::PresentationConnection },
     290             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     291             :   JSJitInfo::Setter,
     292             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     293             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     294             :   false,  /* isInfallible. False in setters. */
     295             :   false,  /* isMovable.  Not relevant for setters. */
     296             :   false, /* isEliminatable.  Not relevant for setters. */
     297             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     298             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     299             :   false,  /* isTypedMethod.  Only relevant for methods. */
     300             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     301             : };
     302             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     303             : static_assert(0 < 1, "There is no slot for us");
     304             : 
     305             : static bool
     306           0 : get_onterminate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitGetterCallArgs args)
     307             : {
     308           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnterminate());
     309           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     310           0 :   if (result) {
     311           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     312           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     313           0 :       return false;
     314             :     }
     315           0 :     return true;
     316             :   } else {
     317           0 :     args.rval().setNull();
     318           0 :     return true;
     319             :   }
     320             : }
     321             : 
     322             : static bool
     323           0 : set_onterminate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitSetterCallArgs args)
     324             : {
     325           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     326           0 :   if (args[0].isObject()) {
     327             :     { // scope for tempRoot
     328           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     329           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     330             :     }
     331             :   } else {
     332           0 :     arg0 = nullptr;
     333             :   }
     334           0 :   self->SetOnterminate(Constify(arg0));
     335           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     336             : 
     337           0 :   return true;
     338             : }
     339             : 
     340             : static const JSJitInfo onterminate_getterinfo = {
     341             :   { (JSJitGetterOp)get_onterminate },
     342             :   { prototypes::id::PresentationConnection },
     343             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     344             :   JSJitInfo::Getter,
     345             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     346             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     347             :   false,  /* isInfallible. False in setters. */
     348             :   false,  /* isMovable.  Not relevant for setters. */
     349             :   false, /* isEliminatable.  Not relevant for setters. */
     350             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     351             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     352             :   false,  /* isTypedMethod.  Only relevant for methods. */
     353             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     354             : };
     355             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     356             : static_assert(0 < 1, "There is no slot for us");
     357             : static const JSJitInfo onterminate_setterinfo = {
     358             :   { (JSJitGetterOp)set_onterminate },
     359             :   { prototypes::id::PresentationConnection },
     360             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     361             :   JSJitInfo::Setter,
     362             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     363             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     364             :   false,  /* isInfallible. False in setters. */
     365             :   false,  /* isMovable.  Not relevant for setters. */
     366             :   false, /* isEliminatable.  Not relevant for setters. */
     367             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     368             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     369             :   false,  /* isTypedMethod.  Only relevant for methods. */
     370             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     371             : };
     372             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     373             : static_assert(0 < 1, "There is no slot for us");
     374             : 
     375             : static bool
     376           0 : get_binaryType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitGetterCallArgs args)
     377             : {
     378           0 :   PresentationConnectionBinaryType result(self->BinaryType());
     379           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     380           0 :   if (!ToJSValue(cx, result, args.rval())) {
     381           0 :     return false;
     382             :   }
     383           0 :   return true;
     384             : }
     385             : 
     386             : static bool
     387           0 : set_binaryType(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitSetterCallArgs args)
     388             : {
     389             :   PresentationConnectionBinaryType arg0;
     390             :   {
     391             :     int index;
     392           0 :     if (!FindEnumStringIndex<false>(cx, args[0], PresentationConnectionBinaryTypeValues::strings, "PresentationConnectionBinaryType", "Value being assigned to PresentationConnection.binaryType", &index)) {
     393           0 :       return false;
     394             :     }
     395           0 :     if (index < 0) {
     396           0 :       return true;
     397             :     }
     398           0 :     arg0 = static_cast<PresentationConnectionBinaryType>(index);
     399             :   }
     400           0 :   self->SetBinaryType(arg0);
     401           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     402             : 
     403           0 :   return true;
     404             : }
     405             : 
     406             : static const JSJitInfo binaryType_getterinfo = {
     407             :   { (JSJitGetterOp)get_binaryType },
     408             :   { prototypes::id::PresentationConnection },
     409             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     410             :   JSJitInfo::Getter,
     411             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     412             :   JSVAL_TYPE_STRING,  /* returnType.  Not relevant for setters. */
     413             :   false,  /* isInfallible. False in setters. */
     414             :   false,  /* isMovable.  Not relevant for setters. */
     415             :   false, /* isEliminatable.  Not relevant for setters. */
     416             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     417             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     418             :   false,  /* isTypedMethod.  Only relevant for methods. */
     419             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     420             : };
     421             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     422             : static_assert(0 < 1, "There is no slot for us");
     423             : static const JSJitInfo binaryType_setterinfo = {
     424             :   { (JSJitGetterOp)set_binaryType },
     425             :   { prototypes::id::PresentationConnection },
     426             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     427             :   JSJitInfo::Setter,
     428             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     429             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     430             :   false,  /* isInfallible. False in setters. */
     431             :   false,  /* isMovable.  Not relevant for setters. */
     432             :   false, /* isEliminatable.  Not relevant for setters. */
     433             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     434             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     435             :   false,  /* isTypedMethod.  Only relevant for methods. */
     436             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     437             : };
     438             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     439             : static_assert(0 < 1, "There is no slot for us");
     440             : 
     441             : static bool
     442           0 : send(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, const JSJitMethodCallArgs& args)
     443             : {
     444           0 :   unsigned argcount = std::min(args.length(), 1u);
     445           0 :   switch (argcount) {
     446             :     case 1: {
     447           0 :       if (args[0].isObject()) {
     448             :         do {
     449           0 :           NonNull<mozilla::dom::Blob> arg0;
     450             :           {
     451           0 :             nsresult rv = UnwrapObject<prototypes::id::Blob, mozilla::dom::Blob>(args[0], arg0);
     452           0 :             if (NS_FAILED(rv)) {
     453           0 :               break;
     454             :             }
     455             :           }
     456           0 :           binding_detail::FastErrorResult rv;
     457           0 :           self->Send(NonNullHelper(arg0), rv);
     458           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     459           0 :             return false;
     460             :           }
     461           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     462           0 :           args.rval().setUndefined();
     463           0 :           return true;
     464             :         } while (0);
     465             :         do {
     466           0 :           RootedTypedArray<ArrayBuffer> arg0(cx);
     467           0 :           if (!arg0.Init(&args[0].toObject())) {
     468           0 :             break;
     469             :           }
     470           0 :           binding_detail::FastErrorResult rv;
     471           0 :           self->Send(Constify(arg0), rv);
     472           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     473           0 :             return false;
     474             :           }
     475           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     476           0 :           args.rval().setUndefined();
     477           0 :           return true;
     478             :         } while (0);
     479             :         do {
     480           0 :           RootedTypedArray<ArrayBufferView> arg0(cx);
     481           0 :           if (!arg0.Init(&args[0].toObject())) {
     482           0 :             break;
     483             :           }
     484           0 :           binding_detail::FastErrorResult rv;
     485           0 :           self->Send(Constify(arg0), rv);
     486           0 :           if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     487           0 :             return false;
     488             :           }
     489           0 :           MOZ_ASSERT(!JS_IsExceptionPending(cx));
     490           0 :           args.rval().setUndefined();
     491           0 :           return true;
     492             :         } while (0);
     493             :       }
     494           0 :       binding_detail::FakeString arg0;
     495           0 :       if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     496           0 :         return false;
     497             :       }
     498           0 :       binding_detail::FastErrorResult rv;
     499           0 :       self->Send(NonNullHelper(Constify(arg0)), rv);
     500           0 :       if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     501           0 :         return false;
     502             :       }
     503           0 :       MOZ_ASSERT(!JS_IsExceptionPending(cx));
     504           0 :       args.rval().setUndefined();
     505           0 :       return true;
     506             :       break;
     507             :     }
     508             :     default: {
     509           0 :       return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "PresentationConnection.send");
     510             :       break;
     511             :     }
     512             :   }
     513             :   MOZ_CRASH("We have an always-returning default case");
     514             :   return false;
     515             : }
     516             : 
     517             : static const JSJitInfo send_methodinfo = {
     518             :   { (JSJitGetterOp)send },
     519             :   { prototypes::id::PresentationConnection },
     520             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     521             :   JSJitInfo::Method,
     522             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     523             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     524             :   false,  /* isInfallible. False in setters. */
     525             :   false,  /* isMovable.  Not relevant for setters. */
     526             :   false, /* isEliminatable.  Not relevant for setters. */
     527             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     528             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     529             :   false,  /* isTypedMethod.  Only relevant for methods. */
     530             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     531             : };
     532             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     533             : static_assert(0 < 1, "There is no slot for us");
     534             : 
     535             : static bool
     536           0 : get_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitGetterCallArgs args)
     537             : {
     538           0 :   RefPtr<EventHandlerNonNull> result(self->GetOnmessage());
     539           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     540           0 :   if (result) {
     541           0 :     args.rval().setObjectOrNull(GetCallbackFromCallbackObject(result));
     542           0 :     if (!MaybeWrapObjectOrNullValue(cx, args.rval())) {
     543           0 :       return false;
     544             :     }
     545           0 :     return true;
     546             :   } else {
     547           0 :     args.rval().setNull();
     548           0 :     return true;
     549             :   }
     550             : }
     551             : 
     552             : static bool
     553           0 : set_onmessage(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, JSJitSetterCallArgs args)
     554             : {
     555           0 :   RootedCallback<RefPtr<binding_detail::FastEventHandlerNonNull>> arg0(cx);
     556           0 :   if (args[0].isObject()) {
     557             :     { // scope for tempRoot
     558           0 :       JS::Rooted<JSObject*> tempRoot(cx, &args[0].toObject());
     559           0 :       arg0 = new binding_detail::FastEventHandlerNonNull(tempRoot);
     560             :     }
     561             :   } else {
     562           0 :     arg0 = nullptr;
     563             :   }
     564           0 :   self->SetOnmessage(Constify(arg0));
     565           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     566             : 
     567           0 :   return true;
     568             : }
     569             : 
     570             : static const JSJitInfo onmessage_getterinfo = {
     571             :   { (JSJitGetterOp)get_onmessage },
     572             :   { prototypes::id::PresentationConnection },
     573             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     574             :   JSJitInfo::Getter,
     575             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     576             :   JSVAL_TYPE_UNKNOWN,  /* returnType.  Not relevant for setters. */
     577             :   false,  /* isInfallible. False in setters. */
     578             :   false,  /* isMovable.  Not relevant for setters. */
     579             :   false, /* isEliminatable.  Not relevant for setters. */
     580             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     581             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     582             :   false,  /* isTypedMethod.  Only relevant for methods. */
     583             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     584             : };
     585             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     586             : static_assert(0 < 1, "There is no slot for us");
     587             : static const JSJitInfo onmessage_setterinfo = {
     588             :   { (JSJitGetterOp)set_onmessage },
     589             :   { prototypes::id::PresentationConnection },
     590             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     591             :   JSJitInfo::Setter,
     592             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     593             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     594             :   false,  /* isInfallible. False in setters. */
     595             :   false,  /* isMovable.  Not relevant for setters. */
     596             :   false, /* isEliminatable.  Not relevant for setters. */
     597             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     598             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     599             :   false,  /* isTypedMethod.  Only relevant for methods. */
     600             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     601             : };
     602             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     603             : static_assert(0 < 1, "There is no slot for us");
     604             : 
     605             : static bool
     606           0 : close(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, const JSJitMethodCallArgs& args)
     607             : {
     608           0 :   binding_detail::FastErrorResult rv;
     609           0 :   self->Close(rv);
     610           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     611           0 :     return false;
     612             :   }
     613           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     614           0 :   args.rval().setUndefined();
     615           0 :   return true;
     616             : }
     617             : 
     618             : static const JSJitInfo close_methodinfo = {
     619             :   { (JSJitGetterOp)close },
     620             :   { prototypes::id::PresentationConnection },
     621             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     622             :   JSJitInfo::Method,
     623             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     624             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     625             :   false,  /* isInfallible. False in setters. */
     626             :   false,  /* isMovable.  Not relevant for setters. */
     627             :   false, /* isEliminatable.  Not relevant for setters. */
     628             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     629             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     630             :   false,  /* isTypedMethod.  Only relevant for methods. */
     631             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     632             : };
     633             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     634             : static_assert(0 < 1, "There is no slot for us");
     635             : 
     636             : static bool
     637           0 : terminate(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::PresentationConnection* self, const JSJitMethodCallArgs& args)
     638             : {
     639           0 :   binding_detail::FastErrorResult rv;
     640           0 :   self->Terminate(rv);
     641           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     642           0 :     return false;
     643             :   }
     644           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     645           0 :   args.rval().setUndefined();
     646           0 :   return true;
     647             : }
     648             : 
     649             : static const JSJitInfo terminate_methodinfo = {
     650             :   { (JSJitGetterOp)terminate },
     651             :   { prototypes::id::PresentationConnection },
     652             :   { PrototypeTraits<prototypes::id::PresentationConnection>::Depth },
     653             :   JSJitInfo::Method,
     654             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     655             :   JSVAL_TYPE_UNDEFINED,  /* returnType.  Not relevant for setters. */
     656             :   false,  /* isInfallible. False in setters. */
     657             :   false,  /* isMovable.  Not relevant for setters. */
     658             :   false, /* isEliminatable.  Not relevant for setters. */
     659             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     660             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     661             :   false,  /* isTypedMethod.  Only relevant for methods. */
     662             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     663             : };
     664             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     665             : static_assert(0 < 1, "There is no slot for us");
     666             : 
     667             : static bool
     668           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     669             : {
     670           0 :   mozilla::dom::PresentationConnection* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationConnection>(obj);
     671             :   // We don't want to preserve if we don't have a wrapper, and we
     672             :   // obviously can't preserve if we're not initialized.
     673           0 :   if (self && self->GetWrapperPreserveColor()) {
     674           0 :     PreserveWrapper(self);
     675             :   }
     676           0 :   return true;
     677             : }
     678             : 
     679             : static void
     680           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     681             : {
     682           0 :   mozilla::dom::PresentationConnection* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationConnection>(obj);
     683           0 :   if (self) {
     684           0 :     ClearWrapper(self, self, obj);
     685           0 :     AddForDeferredFinalization<mozilla::dom::PresentationConnection>(self);
     686             :   }
     687           0 : }
     688             : 
     689             : static void
     690           0 : _objectMoved(JSObject* obj, const JSObject* old)
     691             : {
     692           0 :   mozilla::dom::PresentationConnection* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::PresentationConnection>(obj);
     693           0 :   if (self) {
     694           0 :     UpdateWrapper(self, self, obj, old);
     695             :   }
     696           0 : }
     697             : 
     698             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     699             : #if defined(__clang__)
     700             : #pragma clang diagnostic push
     701             : #pragma clang diagnostic ignored "-Wmissing-braces"
     702             : #endif
     703             : static const JSFunctionSpec sMethods_specs[] = {
     704             :   JS_FNSPEC("send", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&send_methodinfo), 1, JSPROP_ENUMERATE, nullptr),
     705             :   JS_FNSPEC("close", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&close_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     706             :   JS_FNSPEC("terminate", GenericBindingMethod, reinterpret_cast<const JSJitInfo*>(&terminate_methodinfo), 0, JSPROP_ENUMERATE, nullptr),
     707             :   JS_FS_END
     708             : };
     709             : #if defined(__clang__)
     710             : #pragma clang diagnostic pop
     711             : #endif
     712             : 
     713             : 
     714             : // Can't be const because the pref-enabled boolean needs to be writable
     715             : static Prefable<const JSFunctionSpec> sMethods[] = {
     716             :   { nullptr, &sMethods_specs[0] },
     717             :   { nullptr, nullptr }
     718             : };
     719             : 
     720             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     721             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     722             : static_assert(3 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     723             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     724             : 
     725             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     726             : #if defined(__clang__)
     727             : #pragma clang diagnostic push
     728             : #pragma clang diagnostic ignored "-Wmissing-braces"
     729             : #endif
     730             : static const JSPropertySpec sAttributes_specs[] = {
     731             :   { "id", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &id_getterinfo, nullptr, nullptr },
     732             :   { "url", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &url_getterinfo, nullptr, nullptr },
     733             :   { "state", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &state_getterinfo, nullptr, nullptr },
     734             :   { "onconnect", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onconnect_getterinfo, GenericBindingSetter, &onconnect_setterinfo },
     735             :   { "onclose", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onclose_getterinfo, GenericBindingSetter, &onclose_setterinfo },
     736             :   { "onterminate", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onterminate_getterinfo, GenericBindingSetter, &onterminate_setterinfo },
     737             :   { "binaryType", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &binaryType_getterinfo, GenericBindingSetter, &binaryType_setterinfo },
     738             :   { "onmessage", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &onmessage_getterinfo, GenericBindingSetter, &onmessage_setterinfo },
     739             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     740             : };
     741             : #if defined(__clang__)
     742             : #pragma clang diagnostic pop
     743             : #endif
     744             : 
     745             : 
     746             : // Can't be const because the pref-enabled boolean needs to be writable
     747             : static Prefable<const JSPropertySpec> sAttributes[] = {
     748             :   { nullptr, &sAttributes_specs[0] },
     749             :   { nullptr, nullptr }
     750             : };
     751             : 
     752             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     753             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     754             : static_assert(8 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     755             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     756             : 
     757             : 
     758             : static uint16_t sNativeProperties_sortedPropertyIndices[11];
     759             : static PropertyInfo sNativeProperties_propertyInfos[11];
     760             : 
     761             : static const NativePropertiesN<2> sNativeProperties = {
     762             :   false, 0,
     763             :   false, 0,
     764             :   true,  0 /* sMethods */,
     765             :   true,  1 /* sAttributes */,
     766             :   false, 0,
     767             :   false, 0,
     768             :   false, 0,
     769             :   -1,
     770             :   11,
     771             :   sNativeProperties_sortedPropertyIndices,
     772             :   {
     773             :     { sMethods, &sNativeProperties_propertyInfos[0] },
     774             :     { sAttributes, &sNativeProperties_propertyInfos[3] }
     775             :   }
     776             : };
     777             : static_assert(11 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     778             :     "We have a property info count that is oversized");
     779             : 
     780             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     781             :   {
     782             :     "Function",
     783             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     784             :     &sBoringInterfaceObjectClassClassOps,
     785             :     JS_NULL_CLASS_SPEC,
     786             :     JS_NULL_CLASS_EXT,
     787             :     &sInterfaceObjectClassObjectOps
     788             :   },
     789             :   eInterface,
     790             :   true,
     791             :   prototypes::id::PresentationConnection,
     792             :   PrototypeTraits<prototypes::id::PresentationConnection>::Depth,
     793             :   sNativePropertyHooks,
     794             :   "function PresentationConnection() {\n    [native code]\n}",
     795             :   EventTargetBinding::GetConstructorObject
     796             : };
     797             : 
     798             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     799             :   {
     800             :     "PresentationConnectionPrototype",
     801             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     802             :     JS_NULL_CLASS_OPS,
     803             :     JS_NULL_CLASS_SPEC,
     804             :     JS_NULL_CLASS_EXT,
     805             :     JS_NULL_OBJECT_OPS
     806             :   },
     807             :   eInterfacePrototype,
     808             :   false,
     809             :   prototypes::id::PresentationConnection,
     810             :   PrototypeTraits<prototypes::id::PresentationConnection>::Depth,
     811             :   sNativePropertyHooks,
     812             :   "[object PresentationConnectionPrototype]",
     813             :   EventTargetBinding::GetProtoObject
     814             : };
     815             : 
     816             : bool
     817           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     818             : {
     819             :   static bool sPrefValue;
     820             :   static bool sPrefCacheSetUp = false;
     821           0 :   if (!sPrefCacheSetUp) {
     822           0 :     sPrefCacheSetUp = true;
     823           0 :     Preferences::AddBoolVarCache(&sPrefValue, "dom.presentation.enabled");
     824             :   }
     825             : 
     826           0 :   return sPrefValue;
     827             : }
     828             : 
     829             : JSObject*
     830           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     831             : {
     832           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     833             : }
     834             : 
     835             : static const js::ClassOps sClassOps = {
     836             :   _addProperty, /* addProperty */
     837             :   nullptr,               /* delProperty */
     838             :   nullptr,               /* getProperty */
     839             :   nullptr,               /* setProperty */
     840             :   nullptr,               /* enumerate */
     841             :   nullptr, /* newEnumerate */
     842             :   nullptr, /* resolve */
     843             :   nullptr, /* mayResolve */
     844             :   _finalize, /* finalize */
     845             :   nullptr, /* call */
     846             :   nullptr,               /* hasInstance */
     847             :   nullptr,               /* construct */
     848             :   nullptr, /* trace */
     849             : };
     850             : 
     851             : static const js::ClassExtension sClassExtension = {
     852             :   nullptr, /* weakmapKeyDelegateOp */
     853             :   _objectMoved /* objectMovedOp */
     854             : };
     855             : 
     856             : static const DOMJSClass sClass = {
     857             :   { "PresentationConnection",
     858             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     859             :     &sClassOps,
     860             :     JS_NULL_CLASS_SPEC,
     861             :     &sClassExtension,
     862             :     JS_NULL_OBJECT_OPS
     863             :   },
     864             :   { prototypes::id::EventTarget, prototypes::id::PresentationConnection, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     865             :   IsBaseOf<nsISupports, mozilla::dom::PresentationConnection >::value,
     866             :   sNativePropertyHooks,
     867             :   FindAssociatedGlobalForNative<mozilla::dom::PresentationConnection>::Get,
     868             :   GetProtoObjectHandle,
     869             :   GetCCParticipant<mozilla::dom::PresentationConnection>::Get()
     870             : };
     871             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     872             :               "Must have the right minimal number of reserved slots.");
     873             : static_assert(1 >= 1,
     874             :               "Must have enough reserved slots.");
     875             : 
     876             : const JSClass*
     877           0 : GetJSClass()
     878             : {
     879           0 :   return sClass.ToJSClass();
     880             : }
     881             : 
     882             : bool
     883           0 : Wrap(JSContext* aCx, mozilla::dom::PresentationConnection* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     884             : {
     885             :   MOZ_ASSERT(static_cast<mozilla::dom::PresentationConnection*>(aObject) ==
     886             :              reinterpret_cast<mozilla::dom::PresentationConnection*>(aObject),
     887             :              "Multiple inheritance for mozilla::dom::PresentationConnection is broken.");
     888             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     889             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     890             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     891           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     892           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     893           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     894             :              "You should probably not be using Wrap() directly; use "
     895             :              "GetOrCreateDOMReflector instead");
     896             : 
     897           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     898             :              "nsISupports must be on our primary inheritance chain");
     899             : 
     900           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     901           0 :   if (!global) {
     902           0 :     return false;
     903             :   }
     904           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     905           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     906             : 
     907             :   // That might have ended up wrapping us already, due to the wonders
     908             :   // of XBL.  Check for that, and bail out as needed.
     909           0 :   aReflector.set(aCache->GetWrapper());
     910           0 :   if (aReflector) {
     911             : #ifdef DEBUG
     912           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     913             : #endif // DEBUG
     914           0 :     return true;
     915             :   }
     916             : 
     917           0 :   JSAutoCompartment ac(aCx, global);
     918           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     919           0 :   if (!canonicalProto) {
     920           0 :     return false;
     921             :   }
     922           0 :   JS::Rooted<JSObject*> proto(aCx);
     923           0 :   if (aGivenProto) {
     924           0 :     proto = aGivenProto;
     925             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     926             :     // coming in, we changed compartments to that of "parent" so may need
     927             :     // to wrap the proto here.
     928           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     929           0 :       if (!JS_WrapObject(aCx, &proto)) {
     930           0 :         return false;
     931             :       }
     932             :     }
     933             :   } else {
     934           0 :     proto = canonicalProto;
     935             :   }
     936             : 
     937           0 :   BindingJSObjectCreator<mozilla::dom::PresentationConnection> creator(aCx);
     938           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     939           0 :   if (!aReflector) {
     940           0 :     return false;
     941             :   }
     942             : 
     943           0 :   aCache->SetWrapper(aReflector);
     944           0 :   creator.InitializationSucceeded();
     945             : 
     946           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     947             :              aCache->GetWrapperPreserveColor() == aReflector);
     948             :   // If proto != canonicalProto, we have to preserve our wrapper;
     949             :   // otherwise we won't be able to properly recreate it later, since
     950             :   // we won't know what proto to use.  Note that we don't check
     951             :   // aGivenProto here, since it's entirely possible (and even
     952             :   // somewhat common) to have a non-null aGivenProto which is the
     953             :   // same as canonicalProto.
     954           0 :   if (proto != canonicalProto) {
     955           0 :     PreserveWrapper(aObject);
     956             :   }
     957             : 
     958           0 :   return true;
     959             : }
     960             : 
     961             : const NativePropertyHooks sNativePropertyHooks[] = { {
     962             :   nullptr,
     963             :   nullptr,
     964             :   nullptr,
     965             :   { sNativeProperties.Upcast(), nullptr },
     966             :   prototypes::id::PresentationConnection,
     967             :   constructors::id::PresentationConnection,
     968             :   EventTargetBinding::sNativePropertyHooks,
     969             :   &DefaultXrayExpandoObjectClass
     970             : } };
     971             : 
     972             : void
     973           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     974             : {
     975           0 :   JS::Handle<JSObject*> parentProto(EventTargetBinding::GetProtoObjectHandle(aCx));
     976           0 :   if (!parentProto) {
     977           0 :     return;
     978             :   }
     979             : 
     980           0 :   JS::Handle<JSObject*> constructorProto(EventTargetBinding::GetConstructorObjectHandle(aCx));
     981           0 :   if (!constructorProto) {
     982           0 :     return;
     983             :   }
     984             : 
     985             :   static bool sIdsInited = false;
     986           0 :   if (!sIdsInited && NS_IsMainThread()) {
     987           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     988           0 :       return;
     989             :     }
     990           0 :     sIdsInited = true;
     991             :   }
     992             : 
     993           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::PresentationConnection);
     994           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::PresentationConnection);
     995           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     996             :                               &sPrototypeClass.mBase, protoCache,
     997             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     998             :                               interfaceCache,
     999             :                               sNativeProperties.Upcast(),
    1000             :                               nullptr,
    1001             :                               "PresentationConnection", aDefineOnGlobal,
    1002             :                               nullptr,
    1003           0 :                               false);
    1004             : }
    1005             : 
    1006             : JS::Handle<JSObject*>
    1007           0 : GetProtoObjectHandle(JSContext* aCx)
    1008             : {
    1009             :   /* Get the interface prototype object for this class.  This will create the
    1010             :      object as needed. */
    1011           0 :   bool aDefineOnGlobal = true;
    1012             : 
    1013             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1014           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1015           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1016           0 :     return nullptr;
    1017             :   }
    1018             : 
    1019             :   /* Check to see whether the interface objects are already installed */
    1020           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1021           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::PresentationConnection)) {
    1022           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1023           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1024             :   }
    1025             : 
    1026             :   /*
    1027             :    * The object might _still_ be null, but that's OK.
    1028             :    *
    1029             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1030             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1031             :    * changed after they have been set.
    1032             :    *
    1033             :    * Calling address() avoids the read read barrier that does gray
    1034             :    * unmarking, but it's not possible for the object to be gray here.
    1035             :    */
    1036             : 
    1037           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::PresentationConnection);
    1038           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1039           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1040             : }
    1041             : 
    1042             : JS::Handle<JSObject*>
    1043           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
    1044             : {
    1045             :   /* Get the interface object for this class.  This will create the object as
    1046             :      needed. */
    1047             : 
    1048             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
    1049           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
    1050           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
    1051           0 :     return nullptr;
    1052             :   }
    1053             : 
    1054             :   /* Check to see whether the interface objects are already installed */
    1055           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
    1056           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::PresentationConnection)) {
    1057           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
    1058           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
    1059             :   }
    1060             : 
    1061             :   /*
    1062             :    * The object might _still_ be null, but that's OK.
    1063             :    *
    1064             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
    1065             :    * traced by TraceProtoAndIfaceCache() and its contents are never
    1066             :    * changed after they have been set.
    1067             :    *
    1068             :    * Calling address() avoids the read read barrier that does gray
    1069             :    * unmarking, but it's not possible for the object to be gray here.
    1070             :    */
    1071             : 
    1072           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::PresentationConnection);
    1073           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
    1074           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
    1075             : }
    1076             : 
    1077             : JSObject*
    1078           0 : GetConstructorObject(JSContext* aCx)
    1079             : {
    1080           0 :   return GetConstructorObjectHandle(aCx);
    1081             : }
    1082             : 
    1083             : } // namespace PresentationConnectionBinding
    1084             : 
    1085             : 
    1086             : 
    1087             : } // namespace dom
    1088             : } // namespace mozilla

Generated by: LCOV version 1.13