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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM TCPServerSocketEvent.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "AtomList.h"
       4             : #include "EventBinding.h"
       5             : #include "TCPServerSocketEventBinding.h"
       6             : #include "WrapperFactory.h"
       7             : #include "mozilla/OwningNonNull.h"
       8             : #include "mozilla/dom/BindingUtils.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/PrimitiveConversions.h"
      12             : #include "mozilla/dom/ScriptSettings.h"
      13             : #include "mozilla/dom/TCPServerSocketEvent.h"
      14             : #include "mozilla/dom/TCPSocket.h"
      15             : #include "mozilla/dom/XrayExpandoClass.h"
      16             : 
      17             : namespace mozilla {
      18             : namespace dom {
      19             : 
      20             : 
      21           0 : TCPServerSocketEventInit::TCPServerSocketEventInit()
      22           0 :   : EventInit(FastDictionaryInitializer())
      23             : {
      24             :   // Safe to pass a null context if we pass a null value
      25           0 :   Init(nullptr, JS::NullHandleValue);
      26           0 : }
      27             : 
      28             : 
      29             : 
      30             : bool
      31           0 : TCPServerSocketEventInit::InitIds(JSContext* cx, TCPServerSocketEventInitAtoms* atomsCache)
      32             : {
      33           0 :   MOZ_ASSERT(!*reinterpret_cast<jsid**>(atomsCache));
      34             : 
      35             :   // Initialize these in reverse order so that any failure leaves the first one
      36             :   // uninitialized.
      37           0 :   if (!atomsCache->socket_id.init(cx, "socket")) {
      38           0 :     return false;
      39             :   }
      40           0 :   return true;
      41             : }
      42             : 
      43             : bool
      44           0 : TCPServerSocketEventInit::Init(JSContext* cx, JS::Handle<JS::Value> val, const char* sourceDescription, bool passedToJSImpl)
      45             : {
      46             :   // Passing a null JSContext is OK only if we're initing from null,
      47             :   // Since in that case we will not have to do any property gets
      48             :   // Also evaluate isNullOrUndefined in order to avoid false-positive
      49             :   // checkers by static analysis tools
      50           0 :   MOZ_ASSERT_IF(!cx, val.isNull() && val.isNullOrUndefined());
      51           0 :   TCPServerSocketEventInitAtoms* atomsCache = nullptr;
      52           0 :   if (cx) {
      53           0 :     atomsCache = GetAtomCache<TCPServerSocketEventInitAtoms>(cx);
      54           0 :     if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
      55           0 :       return false;
      56             :     }
      57             :   }
      58             : 
      59             :   // Per spec, we init the parent's members first
      60           0 :   if (!EventInit::Init(cx, val)) {
      61           0 :     return false;
      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->socket_id, temp.ptr())) {
      75           0 :       return false;
      76             :     }
      77             :   }
      78           0 :   if (!isNull && !temp->isUndefined()) {
      79           0 :     if (temp.ref().isObject()) {
      80             :       static_assert(IsRefcounted<mozilla::dom::TCPSocket>::value, "We can only store refcounted classes.");{
      81           0 :         nsresult rv = UnwrapObject<prototypes::id::TCPSocket, mozilla::dom::TCPSocket>(temp.ptr(), mSocket);
      82           0 :         if (NS_FAILED(rv)) {
      83           0 :           ThrowErrorMessage(cx, MSG_DOES_NOT_IMPLEMENT_INTERFACE, "'socket' member of TCPServerSocketEventInit", "TCPSocket");
      84           0 :           return false;
      85             :         }
      86             :       }
      87           0 :     } else if (temp.ref().isNullOrUndefined()) {
      88           0 :       mSocket = nullptr;
      89             :     } else {
      90           0 :       ThrowErrorMessage(cx, MSG_NOT_OBJECT, "'socket' member of TCPServerSocketEventInit");
      91           0 :       return false;
      92             :     }
      93             :   } else {
      94           0 :     mSocket = nullptr;
      95             :   }
      96           0 :   mIsAnyMemberPresent = true;
      97           0 :   return true;
      98             : }
      99             : 
     100             : bool
     101           0 : TCPServerSocketEventInit::ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const
     102             : {
     103           0 :   TCPServerSocketEventInitAtoms* atomsCache = GetAtomCache<TCPServerSocketEventInitAtoms>(cx);
     104           0 :   if (!*reinterpret_cast<jsid**>(atomsCache) && !InitIds(cx, atomsCache)) {
     105           0 :     return false;
     106             :   }
     107             : 
     108             :   // Per spec, we define the parent's members first
     109           0 :   if (!EventInit::ToObjectInternal(cx, rval)) {
     110           0 :     return false;
     111             :   }
     112           0 :   JS::Rooted<JSObject*> obj(cx, &rval.toObject());
     113             : 
     114             :   do {
     115             :     // block for our 'break' successCode and scope for 'temp' and 'currentValue'
     116           0 :     JS::Rooted<JS::Value> temp(cx);
     117           0 :     RefPtr<mozilla::dom::TCPSocket> const & currentValue = mSocket;
     118           0 :     if (!currentValue) {
     119           0 :       temp.setNull();
     120           0 :       if (!JS_DefinePropertyById(cx, obj, atomsCache->socket_id, temp, JSPROP_ENUMERATE)) {
     121           0 :         return false;
     122             :       }
     123           0 :       break;
     124             :     }
     125           0 :     if (!GetOrCreateDOMReflector(cx, currentValue, &temp)) {
     126           0 :       MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     127           0 :       return false;
     128             :     }
     129           0 :     if (!JS_DefinePropertyById(cx, obj, atomsCache->socket_id, temp, JSPROP_ENUMERATE)) {
     130           0 :       return false;
     131             :     }
     132           0 :     break;
     133             :   } while(0);
     134             : 
     135           0 :   return true;
     136             : }
     137             : 
     138             : void
     139           0 : TCPServerSocketEventInit::TraceDictionary(JSTracer* trc)
     140             : {
     141           0 :   EventInit::TraceDictionary(trc);
     142           0 : }
     143             : 
     144             : TCPServerSocketEventInit&
     145           0 : TCPServerSocketEventInit::operator=(const TCPServerSocketEventInit& aOther)
     146             : {
     147           0 :   EventInit::operator=(aOther);
     148           0 :   mSocket = aOther.mSocket;
     149           0 :   return *this;
     150             : }
     151             : 
     152             : namespace binding_detail {
     153             : } // namespace binding_detail
     154             : 
     155             : 
     156             : namespace TCPServerSocketEventBinding {
     157             : 
     158             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<EventBinding::NativeType>::value,
     159             :               "Can't inherit from an interface with a different ownership model.");
     160             : 
     161             : static bool
     162           0 : get_socket(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TCPServerSocketEvent* self, JSJitGetterCallArgs args)
     163             : {
     164           0 :   auto result(StrongOrRawPtr<mozilla::dom::TCPSocket>(self->Socket()));
     165           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     166           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval())) {
     167           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     168           0 :     return false;
     169             :   }
     170           0 :   return true;
     171             : }
     172             : 
     173             : static const JSJitInfo socket_getterinfo = {
     174             :   { (JSJitGetterOp)get_socket },
     175             :   { prototypes::id::TCPServerSocketEvent },
     176             :   { PrototypeTraits<prototypes::id::TCPServerSocketEvent>::Depth },
     177             :   JSJitInfo::Getter,
     178             :   JSJitInfo::AliasEverything, /* aliasSet.  Not relevant for setters. */
     179             :   JSVAL_TYPE_OBJECT,  /* returnType.  Not relevant for setters. */
     180             :   false,  /* isInfallible. False in setters. */
     181             :   false,  /* isMovable.  Not relevant for setters. */
     182             :   false, /* isEliminatable.  Not relevant for setters. */
     183             :   false, /* isAlwaysInSlot.  Only relevant for getters. */
     184             :   false, /* isLazilyCachedInSlot.  Only relevant for getters. */
     185             :   false,  /* isTypedMethod.  Only relevant for methods. */
     186             :   0   /* Reserved slot index, if we're stored in a slot, else 0. */
     187             : };
     188             : static_assert(0 <= JSJitInfo::maxSlotIndex, "We won't fit");
     189             : static_assert(0 < 1, "There is no slot for us");
     190             : 
     191             : static bool
     192           0 : get_isTrusted(JSContext* cx, JS::Handle<JSObject*> obj, mozilla::dom::TCPServerSocketEvent* self, JSJitGetterCallArgs args)
     193             : {
     194           0 :   bool result(self->IsTrusted());
     195           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     196           0 :   args.rval().setBoolean(result);
     197           0 :   return true;
     198             : }
     199             : 
     200             : static const JSJitInfo isTrusted_getterinfo = {
     201             :   { (JSJitGetterOp)get_isTrusted },
     202             :   { prototypes::id::TCPServerSocketEvent },
     203             :   { PrototypeTraits<prototypes::id::TCPServerSocketEvent>::Depth },
     204             :   JSJitInfo::Getter,
     205             :   JSJitInfo::AliasDOMSets, /* aliasSet.  Not relevant for setters. */
     206             :   JSVAL_TYPE_BOOLEAN,  /* returnType.  Not relevant for setters. */
     207             :   true,  /* isInfallible. False in setters. */
     208             :   true,  /* isMovable.  Not relevant for setters. */
     209             :   true, /* 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             : 
     218             : static bool
     219           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
     220             : {
     221           0 :   mozilla::dom::TCPServerSocketEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TCPServerSocketEvent>(obj);
     222             :   // We don't want to preserve if we don't have a wrapper, and we
     223             :   // obviously can't preserve if we're not initialized.
     224           0 :   if (self && self->GetWrapperPreserveColor()) {
     225           0 :     PreserveWrapper(self);
     226             :   }
     227           0 :   return true;
     228             : }
     229             : 
     230             : static void
     231           0 : _finalize(js::FreeOp* fop, JSObject* obj)
     232             : {
     233           0 :   mozilla::dom::TCPServerSocketEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TCPServerSocketEvent>(obj);
     234           0 :   if (self) {
     235           0 :     ClearWrapper(self, self, obj);
     236           0 :     AddForDeferredFinalization<mozilla::dom::TCPServerSocketEvent>(self);
     237             :   }
     238           0 : }
     239             : 
     240             : static void
     241           0 : _objectMoved(JSObject* obj, const JSObject* old)
     242             : {
     243           0 :   mozilla::dom::TCPServerSocketEvent* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::TCPServerSocketEvent>(obj);
     244           0 :   if (self) {
     245           0 :     UpdateWrapper(self, self, obj, old);
     246             :   }
     247           0 : }
     248             : 
     249             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     250             : #if defined(__clang__)
     251             : #pragma clang diagnostic push
     252             : #pragma clang diagnostic ignored "-Wmissing-braces"
     253             : #endif
     254             : static const JSPropertySpec sAttributes_specs[] = {
     255             :   { "socket", JSPROP_SHARED | JSPROP_ENUMERATE, GenericBindingGetter, &socket_getterinfo, nullptr, nullptr },
     256             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     257             : };
     258             : #if defined(__clang__)
     259             : #pragma clang diagnostic pop
     260             : #endif
     261             : 
     262             : 
     263             : // Can't be const because the pref-enabled boolean needs to be writable
     264             : static Prefable<const JSPropertySpec> sAttributes[] = {
     265             :   { nullptr, &sAttributes_specs[0] },
     266             :   { nullptr, nullptr }
     267             : };
     268             : 
     269             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     270             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     271             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     272             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     273             : 
     274             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
     275             : #if defined(__clang__)
     276             : #pragma clang diagnostic push
     277             : #pragma clang diagnostic ignored "-Wmissing-braces"
     278             : #endif
     279             : static const JSPropertySpec sUnforgeableAttributes_specs[] = {
     280             :   { "isTrusted", JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_PERMANENT, GenericBindingGetter, &isTrusted_getterinfo, nullptr, nullptr },
     281             :   { nullptr, 0, nullptr, nullptr, nullptr, nullptr }
     282             : };
     283             : #if defined(__clang__)
     284             : #pragma clang diagnostic pop
     285             : #endif
     286             : 
     287             : 
     288             : // Can't be const because the pref-enabled boolean needs to be writable
     289             : static Prefable<const JSPropertySpec> sUnforgeableAttributes[] = {
     290             :   { nullptr, &sUnforgeableAttributes_specs[0] },
     291             :   { nullptr, nullptr }
     292             : };
     293             : 
     294             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
     295             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
     296             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
     297             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
     298             : 
     299             : 
     300             : static uint16_t sNativeProperties_sortedPropertyIndices[2];
     301             : static PropertyInfo sNativeProperties_propertyInfos[2];
     302             : 
     303             : static const NativePropertiesN<2> sNativeProperties = {
     304             :   false, 0,
     305             :   false, 0,
     306             :   false, 0,
     307             :   true,  0 /* sAttributes */,
     308             :   false, 0,
     309             :   true,  1 /* sUnforgeableAttributes */,
     310             :   false, 0,
     311             :   -1,
     312             :   2,
     313             :   sNativeProperties_sortedPropertyIndices,
     314             :   {
     315             :     { sAttributes, &sNativeProperties_propertyInfos[0] },
     316             :     { sUnforgeableAttributes, &sNativeProperties_propertyInfos[1] }
     317             :   }
     318             : };
     319             : static_assert(2 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     320             :     "We have a property info count that is oversized");
     321             : 
     322             : static bool
     323           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     324             : {
     325           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     326           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     327           0 :   if (!args.isConstructing()) {
     328             :     // XXXbz wish I could get the name from the callee instead of
     329             :     // Adding more relocations
     330           0 :     return ThrowConstructorWithoutNew(cx, "TCPServerSocketEvent");
     331             :   }
     332             : 
     333           0 :   GlobalObject global(cx, obj);
     334           0 :   if (global.Failed()) {
     335           0 :     return false;
     336             :   }
     337             : 
     338           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     339           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     340           0 :     return false;
     341             :   }
     342             : 
     343           0 :   if (MOZ_UNLIKELY(args.length() < 1)) {
     344           0 :     return ThrowErrorMessage(cx, MSG_MISSING_ARGUMENTS, "TCPServerSocketEvent");
     345             :   }
     346           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     347           0 :   binding_detail::FakeString arg0;
     348           0 :   if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     349           0 :     return false;
     350             :   }
     351           0 :   binding_detail::FastTCPServerSocketEventInit arg1;
     352           0 :   if (!arg1.Init(cx, (args.hasDefined(1)) ? args[1] : JS::NullHandleValue,  "Argument 2 of TCPServerSocketEvent.constructor", false)) {
     353           0 :     return false;
     354             :   }
     355           0 :   Maybe<JSAutoCompartment> ac;
     356           0 :   if (objIsXray) {
     357           0 :     obj = js::CheckedUnwrap(obj);
     358           0 :     if (!obj) {
     359           0 :       return false;
     360             :     }
     361           0 :     ac.emplace(cx, obj);
     362           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     363           0 :       return false;
     364             :     }
     365             :   }
     366           0 :   binding_detail::FastErrorResult rv;
     367           0 :   auto result(StrongOrRawPtr<mozilla::dom::TCPServerSocketEvent>(mozilla::dom::TCPServerSocketEvent::Constructor(global, NonNullHelper(Constify(arg0)), Constify(arg1), rv)));
     368           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     369           0 :     return false;
     370             :   }
     371           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     372             :   static_assert(!IsPointer<decltype(result)>::value,
     373             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     374           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     375           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     376           0 :     return false;
     377             :   }
     378           0 :   return true;
     379             : }
     380             : 
     381             : static const js::ClassOps sInterfaceObjectClassOps = {
     382             :     nullptr,               /* addProperty */
     383             :     nullptr,               /* delProperty */
     384             :     nullptr,               /* getProperty */
     385             :     nullptr,               /* setProperty */
     386             :     nullptr,               /* enumerate */
     387             :     nullptr,               /* newEnumerate */
     388             :     nullptr,               /* resolve */
     389             :     nullptr,               /* mayResolve */
     390             :     nullptr,               /* finalize */
     391             :     _constructor, /* call */
     392             :     nullptr,               /* hasInstance */
     393             :     _constructor, /* construct */
     394             :     nullptr,               /* trace */
     395             : };
     396             : 
     397             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     398             :   {
     399             :     "Function",
     400             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     401             :     &sInterfaceObjectClassOps,
     402             :     JS_NULL_CLASS_SPEC,
     403             :     JS_NULL_CLASS_EXT,
     404             :     &sInterfaceObjectClassObjectOps
     405             :   },
     406             :   eInterface,
     407             :   true,
     408             :   prototypes::id::TCPServerSocketEvent,
     409             :   PrototypeTraits<prototypes::id::TCPServerSocketEvent>::Depth,
     410             :   sNativePropertyHooks,
     411             :   "function TCPServerSocketEvent() {\n    [native code]\n}",
     412             :   EventBinding::GetConstructorObject
     413             : };
     414             : 
     415             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     416             :   {
     417             :     "TCPServerSocketEventPrototype",
     418             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE + 1 /* slot for the JSObject holding the unforgeable properties */),
     419             :     JS_NULL_CLASS_OPS,
     420             :     JS_NULL_CLASS_SPEC,
     421             :     JS_NULL_CLASS_EXT,
     422             :     JS_NULL_OBJECT_OPS
     423             :   },
     424             :   eInterfacePrototype,
     425             :   false,
     426             :   prototypes::id::TCPServerSocketEvent,
     427             :   PrototypeTraits<prototypes::id::TCPServerSocketEvent>::Depth,
     428             :   sNativePropertyHooks,
     429             :   "[object TCPServerSocketEventPrototype]",
     430             :   EventBinding::GetProtoObject
     431             : };
     432             : 
     433             : bool
     434           0 : ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj)
     435             : {
     436           0 :   return mozilla::dom::TCPSocket::ShouldTCPSocketExist(aCx, aObj);
     437             : }
     438             : 
     439             : JSObject*
     440           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     441             : {
     442           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     443             : }
     444             : 
     445             : static const js::ClassOps sClassOps = {
     446             :   _addProperty, /* addProperty */
     447             :   nullptr,               /* delProperty */
     448             :   nullptr,               /* getProperty */
     449             :   nullptr,               /* setProperty */
     450             :   nullptr,               /* enumerate */
     451             :   nullptr, /* newEnumerate */
     452             :   nullptr, /* resolve */
     453             :   nullptr, /* mayResolve */
     454             :   _finalize, /* finalize */
     455             :   nullptr, /* call */
     456             :   nullptr,               /* hasInstance */
     457             :   nullptr,               /* construct */
     458             :   nullptr, /* trace */
     459             : };
     460             : 
     461             : static const js::ClassExtension sClassExtension = {
     462             :   nullptr, /* weakmapKeyDelegateOp */
     463             :   _objectMoved /* objectMovedOp */
     464             : };
     465             : 
     466             : static const DOMJSClass sClass = {
     467             :   { "TCPServerSocketEvent",
     468             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_SKIP_NURSERY_FINALIZE,
     469             :     &sClassOps,
     470             :     JS_NULL_CLASS_SPEC,
     471             :     &sClassExtension,
     472             :     JS_NULL_OBJECT_OPS
     473             :   },
     474             :   { prototypes::id::Event, prototypes::id::TCPServerSocketEvent, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     475             :   IsBaseOf<nsISupports, mozilla::dom::TCPServerSocketEvent >::value,
     476             :   sNativePropertyHooks,
     477             :   FindAssociatedGlobalForNative<mozilla::dom::TCPServerSocketEvent>::Get,
     478             :   GetProtoObjectHandle,
     479             :   GetCCParticipant<mozilla::dom::TCPServerSocketEvent>::Get()
     480             : };
     481             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     482             :               "Must have the right minimal number of reserved slots.");
     483             : static_assert(1 >= 1,
     484             :               "Must have enough reserved slots.");
     485             : 
     486             : const JSClass*
     487           0 : GetJSClass()
     488             : {
     489           0 :   return sClass.ToJSClass();
     490             : }
     491             : 
     492             : bool
     493           0 : Wrap(JSContext* aCx, mozilla::dom::TCPServerSocketEvent* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     494             : {
     495             :   MOZ_ASSERT(static_cast<mozilla::dom::TCPServerSocketEvent*>(aObject) ==
     496             :              reinterpret_cast<mozilla::dom::TCPServerSocketEvent*>(aObject),
     497             :              "Multiple inheritance for mozilla::dom::TCPServerSocketEvent is broken.");
     498             :   MOZ_ASSERT(static_cast<mozilla::dom::Event*>(aObject) ==
     499             :              reinterpret_cast<mozilla::dom::Event*>(aObject),
     500             :              "Multiple inheritance for mozilla::dom::Event is broken.");
     501           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     502           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     503           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     504             :              "You should probably not be using Wrap() directly; use "
     505             :              "GetOrCreateDOMReflector instead");
     506             : 
     507           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     508             :              "nsISupports must be on our primary inheritance chain");
     509             : 
     510           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     511           0 :   if (!global) {
     512           0 :     return false;
     513             :   }
     514           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     515           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     516             : 
     517             :   // That might have ended up wrapping us already, due to the wonders
     518             :   // of XBL.  Check for that, and bail out as needed.
     519           0 :   aReflector.set(aCache->GetWrapper());
     520           0 :   if (aReflector) {
     521             : #ifdef DEBUG
     522           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     523             : #endif // DEBUG
     524           0 :     return true;
     525             :   }
     526             : 
     527           0 :   JSAutoCompartment ac(aCx, global);
     528           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     529           0 :   if (!canonicalProto) {
     530           0 :     return false;
     531             :   }
     532           0 :   JS::Rooted<JSObject*> proto(aCx);
     533           0 :   if (aGivenProto) {
     534           0 :     proto = aGivenProto;
     535             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     536             :     // coming in, we changed compartments to that of "parent" so may need
     537             :     // to wrap the proto here.
     538           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     539           0 :       if (!JS_WrapObject(aCx, &proto)) {
     540           0 :         return false;
     541             :       }
     542             :     }
     543             :   } else {
     544           0 :     proto = canonicalProto;
     545             :   }
     546             : 
     547           0 :   BindingJSObjectCreator<mozilla::dom::TCPServerSocketEvent> creator(aCx);
     548           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     549           0 :   if (!aReflector) {
     550           0 :     return false;
     551             :   }
     552             : 
     553           0 :   aCache->SetWrapper(aReflector);
     554             : 
     555             :   // Important: do unforgeable property setup after we have handed
     556             :   // over ownership of the C++ object to obj as needed, so that if
     557             :   // we fail and it ends up GCed it won't have problems in the
     558             :   // finalizer trying to drop its ownership of the C++ object.
     559             :   JS::Rooted<JSObject*> unforgeableHolder(aCx,
     560           0 :     &js::GetReservedSlot(canonicalProto, DOM_INTERFACE_PROTO_SLOTS_BASE).toObject());
     561           0 :   if (!JS_InitializePropertiesFromCompatibleNativeObject(aCx, aReflector, unforgeableHolder)) {
     562           0 :     aCache->ReleaseWrapper(aObject);
     563           0 :     aCache->ClearWrapper();
     564           0 :     return false;
     565             :   }
     566           0 :   creator.InitializationSucceeded();
     567             : 
     568           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     569             :              aCache->GetWrapperPreserveColor() == aReflector);
     570             :   // If proto != canonicalProto, we have to preserve our wrapper;
     571             :   // otherwise we won't be able to properly recreate it later, since
     572             :   // we won't know what proto to use.  Note that we don't check
     573             :   // aGivenProto here, since it's entirely possible (and even
     574             :   // somewhat common) to have a non-null aGivenProto which is the
     575             :   // same as canonicalProto.
     576           0 :   if (proto != canonicalProto) {
     577           0 :     PreserveWrapper(aObject);
     578             :   }
     579             : 
     580           0 :   return true;
     581             : }
     582             : 
     583             : const NativePropertyHooks sNativePropertyHooks[] = { {
     584             :   nullptr,
     585             :   nullptr,
     586             :   nullptr,
     587             :   { sNativeProperties.Upcast(), nullptr },
     588             :   prototypes::id::TCPServerSocketEvent,
     589             :   constructors::id::TCPServerSocketEvent,
     590             :   EventBinding::sNativePropertyHooks,
     591             :   &DefaultXrayExpandoObjectClass
     592             : } };
     593             : 
     594             : void
     595           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     596             : {
     597           0 :   JS::Handle<JSObject*> parentProto(EventBinding::GetProtoObjectHandle(aCx));
     598           0 :   if (!parentProto) {
     599           0 :     return;
     600             :   }
     601             : 
     602           0 :   JS::Handle<JSObject*> constructorProto(EventBinding::GetConstructorObjectHandle(aCx));
     603           0 :   if (!constructorProto) {
     604           0 :     return;
     605             :   }
     606             : 
     607             :   static bool sIdsInited = false;
     608           0 :   if (!sIdsInited && NS_IsMainThread()) {
     609           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     610           0 :       return;
     611             :     }
     612           0 :     sIdsInited = true;
     613             :   }
     614             : 
     615           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::TCPServerSocketEvent);
     616           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::TCPServerSocketEvent);
     617           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     618             :                               &sPrototypeClass.mBase, protoCache,
     619             :                               constructorProto, &sInterfaceObjectClass.mBase, 1, nullptr,
     620             :                               interfaceCache,
     621             :                               sNativeProperties.Upcast(),
     622             :                               nullptr,
     623             :                               "TCPServerSocketEvent", aDefineOnGlobal,
     624             :                               nullptr,
     625           0 :                               false);
     626             : 
     627           0 :   JS::Rooted<JSObject*> unforgeableHolder(aCx);
     628             :   {
     629           0 :     JS::Rooted<JSObject*> holderProto(aCx, *protoCache);
     630           0 :     unforgeableHolder = JS_NewObjectWithoutMetadata(aCx, sClass.ToJSClass(), holderProto);
     631           0 :     if (!unforgeableHolder) {
     632           0 :       *protoCache = nullptr;
     633           0 :       if (interfaceCache) {
     634           0 :         *interfaceCache = nullptr;
     635             :       }
     636           0 :       return;
     637             :     }
     638             :   }
     639             : 
     640           0 :   if (!DefineUnforgeableAttributes(aCx, unforgeableHolder, sUnforgeableAttributes)) {
     641           0 :     *protoCache = nullptr;
     642           0 :     if (interfaceCache) {
     643           0 :       *interfaceCache = nullptr;
     644             :     }
     645           0 :     return;
     646             :   }
     647             : 
     648           0 :   if (*protoCache) {
     649           0 :     js::SetReservedSlot(*protoCache, DOM_INTERFACE_PROTO_SLOTS_BASE,
     650           0 :                         JS::ObjectValue(*unforgeableHolder));
     651             :   }
     652             : }
     653             : 
     654             : JS::Handle<JSObject*>
     655           0 : GetProtoObjectHandle(JSContext* aCx)
     656             : {
     657             :   /* Get the interface prototype object for this class.  This will create the
     658             :      object as needed. */
     659           0 :   bool aDefineOnGlobal = true;
     660             : 
     661             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     662           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     663           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     664           0 :     return nullptr;
     665             :   }
     666             : 
     667             :   /* Check to see whether the interface objects are already installed */
     668           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     669           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::TCPServerSocketEvent)) {
     670           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     671           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     672             :   }
     673             : 
     674             :   /*
     675             :    * The object might _still_ be null, but that's OK.
     676             :    *
     677             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     678             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     679             :    * changed after they have been set.
     680             :    *
     681             :    * Calling address() avoids the read read barrier that does gray
     682             :    * unmarking, but it's not possible for the object to be gray here.
     683             :    */
     684             : 
     685           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::TCPServerSocketEvent);
     686           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     687           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     688             : }
     689             : 
     690             : JS::Handle<JSObject*>
     691           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     692             : {
     693             :   /* Get the interface object for this class.  This will create the object as
     694             :      needed. */
     695             : 
     696             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     697           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     698           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     699           0 :     return nullptr;
     700             :   }
     701             : 
     702             :   /* Check to see whether the interface objects are already installed */
     703           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     704           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::TCPServerSocketEvent)) {
     705           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     706           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     707             :   }
     708             : 
     709             :   /*
     710             :    * The object might _still_ be null, but that's OK.
     711             :    *
     712             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     713             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     714             :    * changed after they have been set.
     715             :    *
     716             :    * Calling address() avoids the read read barrier that does gray
     717             :    * unmarking, but it's not possible for the object to be gray here.
     718             :    */
     719             : 
     720           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::TCPServerSocketEvent);
     721           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     722           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     723             : }
     724             : 
     725             : JSObject*
     726           0 : GetConstructorObject(JSContext* aCx)
     727             : {
     728           0 :   return GetConstructorObjectHandle(aCx);
     729             : }
     730             : 
     731             : } // namespace TCPServerSocketEventBinding
     732             : 
     733             : 
     734             : 
     735             : } // namespace dom
     736             : } // namespace mozilla

Generated by: LCOV version 1.13