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

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

Generated by: LCOV version 1.13