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

          Line data    Source code
       1             : /* THIS FILE IS AUTOGENERATED FROM Comment.webidl BY Codegen.py - DO NOT EDIT */
       2             : 
       3             : #include "CharacterDataBinding.h"
       4             : #include "CommentBinding.h"
       5             : #include "WrapperFactory.h"
       6             : #include "mozilla/OwningNonNull.h"
       7             : #include "mozilla/dom/BindingUtils.h"
       8             : #include "mozilla/dom/Comment.h"
       9             : #include "mozilla/dom/DOMJSClass.h"
      10             : #include "mozilla/dom/NonRefcountedDOMObject.h"
      11             : #include "mozilla/dom/XrayExpandoClass.h"
      12             : #include "nsISupports.h"
      13             : #include "xpcjsid.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : namespace CommentBinding {
      19             : 
      20             : static_assert(IsRefcounted<NativeType>::value == IsRefcounted<CharacterDataBinding::NativeType>::value,
      21             :               "Can't inherit from an interface with a different ownership model.");
      22             : 
      23             : static bool
      24           0 : _addProperty(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JS::Handle<JS::Value> val)
      25             : {
      26           0 :   mozilla::dom::Comment* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Comment>(obj);
      27             :   // We don't want to preserve if we don't have a wrapper, and we
      28             :   // obviously can't preserve if we're not initialized.
      29           0 :   if (self && self->GetWrapperPreserveColor()) {
      30           0 :     PreserveWrapper(self);
      31             :   }
      32           0 :   return true;
      33             : }
      34             : 
      35             : static void
      36           0 : _finalize(js::FreeOp* fop, JSObject* obj)
      37             : {
      38           0 :   mozilla::dom::Comment* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Comment>(obj);
      39           0 :   if (self) {
      40           0 :     ClearWrapper(self, self, obj);
      41           0 :     AddForDeferredFinalization<mozilla::dom::Comment>(self);
      42             :   }
      43           0 : }
      44             : 
      45             : static void
      46           0 : _objectMoved(JSObject* obj, const JSObject* old)
      47             : {
      48           0 :   mozilla::dom::Comment* self = UnwrapPossiblyNotInitializedDOMObject<mozilla::dom::Comment>(obj);
      49           0 :   if (self) {
      50           0 :     UpdateWrapper(self, self, obj, old);
      51             :   }
      52           0 : }
      53             : 
      54             : // We deliberately use brace-elision to make Visual Studio produce better initalization code.
      55             : #if defined(__clang__)
      56             : #pragma clang diagnostic push
      57             : #pragma clang diagnostic ignored "-Wmissing-braces"
      58             : #endif
      59             : static const JSFunctionSpec sMethods_specs[] = {
      60             :   JS_FNSPEC("QueryInterface", QueryInterface, nullptr, 1, 0, nullptr),
      61             :   JS_FS_END
      62             : };
      63             : #if defined(__clang__)
      64             : #pragma clang diagnostic pop
      65             : #endif
      66             : 
      67             : static PrefableDisablers sMethods_disablers0 = {
      68             :   true, false, 0, &WantsQueryInterface<mozilla::dom::Comment>::Enabled
      69             : };
      70             : 
      71             : // Can't be const because the pref-enabled boolean needs to be writable
      72             : static Prefable<const JSFunctionSpec> sMethods[] = {
      73             :   { &sMethods_disablers0, &sMethods_specs[0] },
      74             :   { nullptr, nullptr }
      75             : };
      76             : 
      77             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_PREF_INDEX,
      78             :     "We have a prefable index that is >= (1 << NUM_BITS_PROPERTY_INFO_PREF_INDEX)");
      79             : static_assert(1 <= 1ull << NUM_BITS_PROPERTY_INFO_SPEC_INDEX,
      80             :     "We have a spec index that is >= (1 << NUM_BITS_PROPERTY_INFO_SPEC_INDEX)");
      81             : 
      82             : 
      83             : static uint16_t sNativeProperties_sortedPropertyIndices[1];
      84             : static PropertyInfo sNativeProperties_propertyInfos[1];
      85             : 
      86             : static const NativePropertiesN<1> sNativeProperties = {
      87             :   false, 0,
      88             :   false, 0,
      89             :   true,  0 /* sMethods */,
      90             :   false, 0,
      91             :   false, 0,
      92             :   false, 0,
      93             :   false, 0,
      94             :   -1,
      95             :   1,
      96             :   sNativeProperties_sortedPropertyIndices,
      97             :   {
      98             :     { sMethods, &sNativeProperties_propertyInfos[0] }
      99             :   }
     100             : };
     101             : static_assert(1 < 1ull << CHAR_BIT * sizeof(sNativeProperties.propertyInfoCount),
     102             :     "We have a property info count that is oversized");
     103             : 
     104             : static bool
     105           0 : _constructor(JSContext* cx, unsigned argc, JS::Value* vp)
     106             : {
     107           0 :   JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
     108           0 :   JS::Rooted<JSObject*> obj(cx, &args.callee());
     109           0 :   if (!args.isConstructing()) {
     110             :     // XXXbz wish I could get the name from the callee instead of
     111             :     // Adding more relocations
     112           0 :     return ThrowConstructorWithoutNew(cx, "Comment");
     113             :   }
     114             : 
     115           0 :   GlobalObject global(cx, obj);
     116           0 :   if (global.Failed()) {
     117           0 :     return false;
     118             :   }
     119             : 
     120           0 :   JS::Rooted<JSObject*> desiredProto(cx);
     121           0 :   if (!GetDesiredProto(cx, args, &desiredProto)) {
     122           0 :     return false;
     123             :   }
     124             : 
     125           0 :   bool objIsXray = xpc::WrapperFactory::IsXrayWrapper(obj);
     126           0 :   binding_detail::FakeString arg0;
     127           0 :   if (args.hasDefined(0)) {
     128           0 :     if (!ConvertJSValueToString(cx, args[0], eStringify, eStringify, arg0)) {
     129           0 :       return false;
     130             :     }
     131             :   } else {
     132             :     static const char16_t data[] = { 0 };
     133           0 :     arg0.Rebind(data, ArrayLength(data) - 1);
     134             :   }
     135           0 :   Maybe<JSAutoCompartment> ac;
     136           0 :   if (objIsXray) {
     137           0 :     obj = js::CheckedUnwrap(obj);
     138           0 :     if (!obj) {
     139           0 :       return false;
     140             :     }
     141           0 :     ac.emplace(cx, obj);
     142           0 :     if (!JS_WrapObject(cx, &desiredProto)) {
     143           0 :       return false;
     144             :     }
     145             :   }
     146           0 :   binding_detail::FastErrorResult rv;
     147           0 :   auto result(StrongOrRawPtr<mozilla::dom::Comment>(mozilla::dom::Comment::Constructor(global, NonNullHelper(Constify(arg0)), rv)));
     148           0 :   if (MOZ_UNLIKELY(rv.MaybeSetPendingException(cx))) {
     149           0 :     return false;
     150             :   }
     151           0 :   MOZ_ASSERT(!JS_IsExceptionPending(cx));
     152             :   static_assert(!IsPointer<decltype(result)>::value,
     153             :                 "NewObject implies that we need to keep the object alive with a strong reference.");
     154           0 :   if (!GetOrCreateDOMReflector(cx, result, args.rval(), desiredProto)) {
     155           0 :     MOZ_ASSERT(true || JS_IsExceptionPending(cx));
     156           0 :     return false;
     157             :   }
     158           0 :   return true;
     159             : }
     160             : 
     161             : static const js::ClassOps sInterfaceObjectClassOps = {
     162             :     nullptr,               /* addProperty */
     163             :     nullptr,               /* delProperty */
     164             :     nullptr,               /* getProperty */
     165             :     nullptr,               /* setProperty */
     166             :     nullptr,               /* enumerate */
     167             :     nullptr,               /* newEnumerate */
     168             :     nullptr,               /* resolve */
     169             :     nullptr,               /* mayResolve */
     170             :     nullptr,               /* finalize */
     171             :     _constructor, /* call */
     172             :     nullptr,               /* hasInstance */
     173             :     _constructor, /* construct */
     174             :     nullptr,               /* trace */
     175             : };
     176             : 
     177             : static const DOMIfaceAndProtoJSClass sInterfaceObjectClass = {
     178             :   {
     179             :     "Function",
     180             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_SLOTS_BASE),
     181             :     &sInterfaceObjectClassOps,
     182             :     JS_NULL_CLASS_SPEC,
     183             :     JS_NULL_CLASS_EXT,
     184             :     &sInterfaceObjectClassObjectOps
     185             :   },
     186             :   eInterface,
     187             :   true,
     188             :   prototypes::id::Comment,
     189             :   PrototypeTraits<prototypes::id::Comment>::Depth,
     190             :   sNativePropertyHooks,
     191             :   "function Comment() {\n    [native code]\n}",
     192             :   CharacterDataBinding::GetConstructorObject
     193             : };
     194             : 
     195             : static const DOMIfaceAndProtoJSClass sPrototypeClass = {
     196             :   {
     197             :     "CommentPrototype",
     198             :     JSCLASS_IS_DOMIFACEANDPROTOJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(DOM_INTERFACE_PROTO_SLOTS_BASE),
     199             :     JS_NULL_CLASS_OPS,
     200             :     JS_NULL_CLASS_SPEC,
     201             :     JS_NULL_CLASS_EXT,
     202             :     JS_NULL_OBJECT_OPS
     203             :   },
     204             :   eInterfacePrototype,
     205             :   false,
     206             :   prototypes::id::Comment,
     207             :   PrototypeTraits<prototypes::id::Comment>::Depth,
     208             :   sNativePropertyHooks,
     209             :   "[object CommentPrototype]",
     210             :   CharacterDataBinding::GetProtoObject
     211             : };
     212             : 
     213             : JSObject*
     214           0 : DefineDOMInterface(JSContext* aCx, JS::Handle<JSObject*> aGlobal, JS::Handle<jsid> id, bool aDefineOnGlobal)
     215             : {
     216           0 :   return GetConstructorObjectHandle(aCx, aDefineOnGlobal);
     217             : }
     218             : 
     219             : static const js::ClassOps sClassOps = {
     220             :   _addProperty, /* addProperty */
     221             :   nullptr,               /* delProperty */
     222             :   nullptr,               /* getProperty */
     223             :   nullptr,               /* setProperty */
     224             :   nullptr,               /* enumerate */
     225             :   nullptr, /* newEnumerate */
     226             :   nullptr, /* resolve */
     227             :   nullptr, /* mayResolve */
     228             :   _finalize, /* finalize */
     229             :   nullptr, /* call */
     230             :   nullptr,               /* hasInstance */
     231             :   nullptr,               /* construct */
     232             :   nullptr, /* trace */
     233             : };
     234             : 
     235             : static const js::ClassExtension sClassExtension = {
     236             :   nullptr, /* weakmapKeyDelegateOp */
     237             :   _objectMoved /* objectMovedOp */
     238             : };
     239             : 
     240             : static const DOMJSClass sClass = {
     241             :   { "Comment",
     242             :     JSCLASS_IS_DOMJSCLASS | JSCLASS_FOREGROUND_FINALIZE | JSCLASS_HAS_RESERVED_SLOTS(1),
     243             :     &sClassOps,
     244             :     JS_NULL_CLASS_SPEC,
     245             :     &sClassExtension,
     246             :     JS_NULL_OBJECT_OPS
     247             :   },
     248             :   { prototypes::id::EventTarget, prototypes::id::Node, prototypes::id::CharacterData, prototypes::id::Comment, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count, prototypes::id::_ID_Count },
     249             :   IsBaseOf<nsISupports, mozilla::dom::Comment >::value,
     250             :   sNativePropertyHooks,
     251             :   FindAssociatedGlobalForNative<mozilla::dom::Comment>::Get,
     252             :   GetProtoObjectHandle,
     253             :   GetCCParticipant<mozilla::dom::Comment>::Get()
     254             : };
     255             : static_assert(1 == DOM_INSTANCE_RESERVED_SLOTS,
     256             :               "Must have the right minimal number of reserved slots.");
     257             : static_assert(1 >= 1,
     258             :               "Must have enough reserved slots.");
     259             : 
     260             : const JSClass*
     261           0 : GetJSClass()
     262             : {
     263           0 :   return sClass.ToJSClass();
     264             : }
     265             : 
     266             : bool
     267           0 : Wrap(JSContext* aCx, mozilla::dom::Comment* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector)
     268             : {
     269             :   MOZ_ASSERT(static_cast<mozilla::dom::Comment*>(aObject) ==
     270             :              reinterpret_cast<mozilla::dom::Comment*>(aObject),
     271             :              "Multiple inheritance for mozilla::dom::Comment is broken.");
     272             :   MOZ_ASSERT(static_cast<nsGenericDOMDataNode*>(aObject) ==
     273             :              reinterpret_cast<nsGenericDOMDataNode*>(aObject),
     274             :              "Multiple inheritance for nsGenericDOMDataNode is broken.");
     275             :   MOZ_ASSERT(static_cast<nsINode*>(aObject) ==
     276             :              reinterpret_cast<nsINode*>(aObject),
     277             :              "Multiple inheritance for nsINode is broken.");
     278             :   MOZ_ASSERT(static_cast<mozilla::dom::EventTarget*>(aObject) ==
     279             :              reinterpret_cast<mozilla::dom::EventTarget*>(aObject),
     280             :              "Multiple inheritance for mozilla::dom::EventTarget is broken.");
     281           0 :   MOZ_ASSERT(ToSupportsIsCorrect(aObject));
     282           0 :   MOZ_ASSERT_IF(aGivenProto, js::IsObjectInContextCompartment(aGivenProto, aCx));
     283           0 :   MOZ_ASSERT(!aCache->GetWrapper(),
     284             :              "You should probably not be using Wrap() directly; use "
     285             :              "GetOrCreateDOMReflector instead");
     286             : 
     287           0 :   MOZ_ASSERT(ToSupportsIsOnPrimaryInheritanceChain(aObject, aCache),
     288             :              "nsISupports must be on our primary inheritance chain");
     289             : 
     290           0 :   JS::Rooted<JSObject*> global(aCx, FindAssociatedGlobal(aCx, aObject->GetParentObject()));
     291           0 :   if (!global) {
     292           0 :     return false;
     293             :   }
     294           0 :   MOZ_ASSERT(JS_IsGlobalObject(global));
     295           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(global));
     296             : 
     297             :   // That might have ended up wrapping us already, due to the wonders
     298             :   // of XBL.  Check for that, and bail out as needed.
     299           0 :   aReflector.set(aCache->GetWrapper());
     300           0 :   if (aReflector) {
     301             : #ifdef DEBUG
     302           0 :     binding_detail::AssertReflectorHasGivenProto(aCx, aReflector, aGivenProto);
     303             : #endif // DEBUG
     304           0 :     return true;
     305             :   }
     306             : 
     307           0 :   JSAutoCompartment ac(aCx, global);
     308           0 :   JS::Handle<JSObject*> canonicalProto = GetProtoObjectHandle(aCx);
     309           0 :   if (!canonicalProto) {
     310           0 :     return false;
     311             :   }
     312           0 :   JS::Rooted<JSObject*> proto(aCx);
     313           0 :   if (aGivenProto) {
     314           0 :     proto = aGivenProto;
     315             :     // Unfortunately, while aGivenProto was in the compartment of aCx
     316             :     // coming in, we changed compartments to that of "parent" so may need
     317             :     // to wrap the proto here.
     318           0 :     if (js::GetContextCompartment(aCx) != js::GetObjectCompartment(proto)) {
     319           0 :       if (!JS_WrapObject(aCx, &proto)) {
     320           0 :         return false;
     321             :       }
     322             :     }
     323             :   } else {
     324           0 :     proto = canonicalProto;
     325             :   }
     326             : 
     327           0 :   BindingJSObjectCreator<mozilla::dom::Comment> creator(aCx);
     328           0 :   creator.CreateObject(aCx, sClass.ToJSClass(), proto, aObject, aReflector);
     329           0 :   if (!aReflector) {
     330           0 :     return false;
     331             :   }
     332             : 
     333           0 :   aCache->SetWrapper(aReflector);
     334           0 :   creator.InitializationSucceeded();
     335             : 
     336           0 :   MOZ_ASSERT(aCache->GetWrapperPreserveColor() &&
     337             :              aCache->GetWrapperPreserveColor() == aReflector);
     338             :   // If proto != canonicalProto, we have to preserve our wrapper;
     339             :   // otherwise we won't be able to properly recreate it later, since
     340             :   // we won't know what proto to use.  Note that we don't check
     341             :   // aGivenProto here, since it's entirely possible (and even
     342             :   // somewhat common) to have a non-null aGivenProto which is the
     343             :   // same as canonicalProto.
     344           0 :   if (proto != canonicalProto) {
     345           0 :     PreserveWrapper(aObject);
     346             :   }
     347             : 
     348           0 :   return true;
     349             : }
     350             : 
     351             : const NativePropertyHooks sNativePropertyHooks[] = { {
     352             :   nullptr,
     353             :   nullptr,
     354             :   nullptr,
     355             :   { sNativeProperties.Upcast(), nullptr },
     356             :   prototypes::id::Comment,
     357             :   constructors::id::Comment,
     358             :   CharacterDataBinding::sNativePropertyHooks,
     359             :   &DefaultXrayExpandoObjectClass
     360             : } };
     361             : 
     362             : void
     363           0 : CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, bool aDefineOnGlobal)
     364             : {
     365           0 :   JS::Handle<JSObject*> parentProto(CharacterDataBinding::GetProtoObjectHandle(aCx));
     366           0 :   if (!parentProto) {
     367           0 :     return;
     368             :   }
     369             : 
     370           0 :   JS::Handle<JSObject*> constructorProto(CharacterDataBinding::GetConstructorObjectHandle(aCx));
     371           0 :   if (!constructorProto) {
     372           0 :     return;
     373             :   }
     374             : 
     375             :   static bool sIdsInited = false;
     376           0 :   if (!sIdsInited && NS_IsMainThread()) {
     377           0 :     if (!InitIds(aCx, sNativeProperties.Upcast())) {
     378           0 :       return;
     379             :     }
     380           0 :     sIdsInited = true;
     381             :   }
     382             : 
     383           0 :   JS::Heap<JSObject*>* protoCache = &aProtoAndIfaceCache.EntrySlotOrCreate(prototypes::id::Comment);
     384           0 :   JS::Heap<JSObject*>* interfaceCache = &aProtoAndIfaceCache.EntrySlotOrCreate(constructors::id::Comment);
     385           0 :   dom::CreateInterfaceObjects(aCx, aGlobal, parentProto,
     386             :                               &sPrototypeClass.mBase, protoCache,
     387             :                               constructorProto, &sInterfaceObjectClass.mBase, 0, nullptr,
     388             :                               interfaceCache,
     389             :                               sNativeProperties.Upcast(),
     390             :                               nullptr,
     391             :                               "Comment", aDefineOnGlobal,
     392             :                               nullptr,
     393           0 :                               false);
     394             : }
     395             : 
     396             : JS::Handle<JSObject*>
     397           0 : GetProtoObjectHandle(JSContext* aCx)
     398             : {
     399             :   /* Get the interface prototype object for this class.  This will create the
     400             :      object as needed. */
     401           0 :   bool aDefineOnGlobal = true;
     402             : 
     403             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     404           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     405           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     406           0 :     return nullptr;
     407             :   }
     408             : 
     409             :   /* Check to see whether the interface objects are already installed */
     410           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     411           0 :   if (!protoAndIfaceCache.HasEntryInSlot(prototypes::id::Comment)) {
     412           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     413           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     414             :   }
     415             : 
     416             :   /*
     417             :    * The object might _still_ be null, but that's OK.
     418             :    *
     419             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     420             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     421             :    * changed after they have been set.
     422             :    *
     423             :    * Calling address() avoids the read read barrier that does gray
     424             :    * unmarking, but it's not possible for the object to be gray here.
     425             :    */
     426             : 
     427           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(prototypes::id::Comment);
     428           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     429           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     430             : }
     431             : 
     432             : JS::Handle<JSObject*>
     433           0 : GetConstructorObjectHandle(JSContext* aCx, bool aDefineOnGlobal)
     434             : {
     435             :   /* Get the interface object for this class.  This will create the object as
     436             :      needed. */
     437             : 
     438             :   /* Make sure our global is sane.  Hopefully we can remove this sometime */
     439           0 :   JSObject* global = JS::CurrentGlobalOrNull(aCx);
     440           0 :   if (!(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL)) {
     441           0 :     return nullptr;
     442             :   }
     443             : 
     444             :   /* Check to see whether the interface objects are already installed */
     445           0 :   ProtoAndIfaceCache& protoAndIfaceCache = *GetProtoAndIfaceCache(global);
     446           0 :   if (!protoAndIfaceCache.HasEntryInSlot(constructors::id::Comment)) {
     447           0 :     JS::Rooted<JSObject*> rootedGlobal(aCx, global);
     448           0 :     CreateInterfaceObjects(aCx, rootedGlobal, protoAndIfaceCache, aDefineOnGlobal);
     449             :   }
     450             : 
     451             :   /*
     452             :    * The object might _still_ be null, but that's OK.
     453             :    *
     454             :    * Calling fromMarkedLocation() is safe because protoAndIfaceCache is
     455             :    * traced by TraceProtoAndIfaceCache() and its contents are never
     456             :    * changed after they have been set.
     457             :    *
     458             :    * Calling address() avoids the read read barrier that does gray
     459             :    * unmarking, but it's not possible for the object to be gray here.
     460             :    */
     461             : 
     462           0 :   const JS::Heap<JSObject*>& entrySlot = protoAndIfaceCache.EntrySlotMustExist(constructors::id::Comment);
     463           0 :   MOZ_ASSERT(JS::ObjectIsNotGray(entrySlot));
     464           0 :   return JS::Handle<JSObject*>::fromMarkedLocation(entrySlot.address());
     465             : }
     466             : 
     467             : JSObject*
     468           0 : GetConstructorObject(JSContext* aCx)
     469             : {
     470           0 :   return GetConstructorObjectHandle(aCx);
     471             : }
     472             : 
     473             : } // namespace CommentBinding
     474             : 
     475             : 
     476             : 
     477             : } // namespace dom
     478             : } // namespace mozilla

Generated by: LCOV version 1.13