LCOV - code coverage report
Current view: top level - obj-x86_64-pc-linux-gnu/dom/bindings - WorkerLocationBinding.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 21 159 13.2 %
Date: 2017-07-14 16:53:18 Functions: 3 19 15.8 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.13