Bug 1019191 part 14. Remove the now-unused HasBitInInterfacesBitmap and all the interfaces bitmap machinery that ends up unused as a result. r=peterv

This commit is contained in:
Boris Zbarsky 2014-10-22 11:40:49 -04:00
parent 3e71ea9acc
commit 462b510da8
10 changed files with 17 additions and 190 deletions

View File

@ -151,27 +151,6 @@ static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
// nothing
#endif
/**
* To generate the bitmap for a class that we're sure doesn't implement any of
* the interfaces in DOMCI_CASTABLE_INTERFACES.
*/
#define DOMCI_DATA_NO_CLASS(_dom_class) \
const uint32_t kDOMClassInfo_##_dom_class##_interfaces = \
0;
DOMCI_DATA_NO_CLASS(ContentFrameMessageManager)
DOMCI_DATA_NO_CLASS(ChromeMessageBroadcaster)
DOMCI_DATA_NO_CLASS(ChromeMessageSender)
DOMCI_DATA_NO_CLASS(DOMPrototype)
DOMCI_DATA_NO_CLASS(DOMConstructor)
DOMCI_DATA_NO_CLASS(XULControlElement)
DOMCI_DATA_NO_CLASS(XULLabeledControlElement)
DOMCI_DATA_NO_CLASS(XULButtonElement)
DOMCI_DATA_NO_CLASS(XULCheckboxElement)
DOMCI_DATA_NO_CLASS(XULPopupElement)
#define NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags, \
_chromeOnly, _allowXBL) \
{ #_class, \
@ -182,7 +161,6 @@ DOMCI_DATA_NO_CLASS(XULPopupElement)
nullptr, \
_flags, \
true, \
0, \
_chromeOnly, \
_allowXBL, \
false, \
@ -588,7 +566,6 @@ nsDOMClassInfo::RegisterExternalClasses()
nsDOMClassInfoData &d = sClassInfoData[eDOMClassInfo_##_class##_id]; \
d.mProtoChainInterface = _ifptr; \
d.mHasClassInterface = _has_class_if; \
d.mInterfacesBitmap = kDOMClassInfo_##_class##_interfaces; \
static const nsIID *interface_list[] = {
#define DOM_CLASSINFO_MAP_BEGIN(_class, _interface) \

View File

@ -46,7 +46,6 @@ struct nsDOMClassInfoData
const nsIID **mInterfaces;
uint32_t mScriptableFlags : 31; // flags must not use more than 31 bits!
uint32_t mHasClassInterface : 1;
uint32_t mInterfacesBitmap;
bool mChromeOnly : 1;
bool mAllowXBL : 1;
bool mDisabled : 1;
@ -137,11 +136,6 @@ protected:
{
}
virtual uint32_t GetInterfacesBitmap() MOZ_OVERRIDE
{
return mData->mInterfacesBitmap;
}
static nsresult RegisterClassProtos(int32_t aDOMClassInfoID);
static nsresult RegisterExternalClasses();
nsresult ResolveConstructor(JSContext *cx, JSObject *obj,

View File

@ -30,117 +30,9 @@ enum nsDOMClassInfoID {
* nsIClassInfo helper macros
*/
/**
* !! THIS MECHANISM IS DEPRECATED, DO NOT ADD MORE INTERFACE TO THESE LISTS !!
*
* DOMCI_CASTABLE_INTERFACES contains the list of interfaces that we have a bit
* for in nsDOMClassInfo's mInterfacesBitmap. To use it you need to define
* DOMCI_CASTABLE_INTERFACE(interface, bit, extra) and then call
* DOMCI_CASTABLE_INTERFACES(extra). For every interface there will be one
* call to DOMCI_CASTABLE_INTERFACE with the bit that it corresponds to and
* the extra argument that was passed in to DOMCI_CASTABLE_INTERFACES.
*
* WARNING: Be very careful when adding interfaces to this list. Every object
* that implements one of these interfaces must be directly castable
* to that interface from the *canonical* nsISupports! Also, none of
* the objects that implement these interfaces may use the new DOM
* bindings.
*/
#undef DOMCI_CASTABLE_INTERFACE
#define DOMCI_CASTABLE_INTERFACES(_extra) \
DOMCI_CASTABLE_INTERFACE(nsINode, nsINode, 0, _extra) \
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::Element, mozilla::dom::Element,\
1, _extra) \
/* If this is ever removed, the IID for EventTarget can go away */ \
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::EventTarget, \
mozilla::dom::EventTarget, 2, _extra) \
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::Event, nsIDOMEvent, 3, _extra) \
DOMCI_CASTABLE_INTERFACE(nsIDocument, nsIDocument, 4, _extra) \
DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 5, _extra) \
DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsIContent, 6, _extra) \
DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 7, _extra) \
DOMCI_CASTABLE_INTERFACE(nsStyledElement, nsStyledElement, 8, _extra) \
DOMCI_CASTABLE_INTERFACE(nsSVGElement, nsIContent, 9, _extra) \
/* NOTE: When removing the casts below, remove the dom::EventBase class */ \
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::MouseEvent, \
mozilla::dom::EventBase, 10, _extra) \
DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::UIEvent, \
mozilla::dom::EventBase, 11, _extra) \
DOMCI_CASTABLE_INTERFACE(nsGlobalWindow, nsIDOMEventTarget, 12, _extra)
// Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
// have been declared.
#define DOMCI_CASTABLE_NODECL_INTERFACE(_interface, _u1, _u2, _u3) /* Nothing */
#define DOMCI_CASTABLE_INTERFACE(_interface, _u1, _u2, _u3) class _interface;
DOMCI_CASTABLE_INTERFACES(unused)
#undef DOMCI_CASTABLE_INTERFACE
#undef DOMCI_CASTABLE_NODECL_INTERFACE
namespace mozilla {
namespace dom {
class Element;
class Event;
class EventTarget;
class MouseEvent;
class UIEvent;
} // namespace dom
} // namespace mozilla
#define DOMCI_CASTABLE_NODECL_INTERFACE DOMCI_CASTABLE_INTERFACE
#ifdef MOZILLA_INTERNAL_API
#define DOMCI_CLASS(_dom_class) \
extern const uint32_t kDOMClassInfo_##_dom_class##_interfaces;
#include "nsDOMClassInfoClasses.h"
#undef DOMCI_CLASS
/**
* Provide a general "does class C implement interface I" predicate.
* This is not as sophisticated as e.g. boost's is_base_of template,
* but it does the job adequately for our purposes.
*/
#if defined(__GNUC__) || _MSC_FULL_VER >= 140050215
/* Use a compiler intrinsic if one is available. */
#define DOMCI_CASTABLE_TO(_interface, _class) __is_base_of(_interface, _class)
#else
/* The generic version of this predicate relies on the overload resolution
* rules. If |_class| inherits from |_interface|, the |_interface*|
* overload of DOMCI_CastableTo<_interface>::p() will be chosen, otherwise
* the |void*| overload will be chosen. There is no definition of these
* functions; we determine which overload was selected by inspecting the
* size of the return type.
*/
template <typename Interface> struct DOMCI_CastableTo {
struct false_type { int x[1]; };
struct true_type { int x[2]; };
static false_type p(void*);
static true_type p(Interface*);
};
#define DOMCI_CASTABLE_TO(_interface, _class) \
(sizeof(DOMCI_CastableTo<_interface>::p(static_cast<_class*>(0))) == \
sizeof(DOMCI_CastableTo<_interface>::true_type))
#endif
/**
* Here we calculate the bitmap for a given class.
*/
#define DOMCI_CASTABLE_INTERFACE(_interface, _base, _bit, _class) \
(DOMCI_CASTABLE_TO(_interface, _class) ? 1 << _bit : 0) +
#define DOMCI_DATA(_dom_class, _class) \
const uint32_t kDOMClassInfo_##_dom_class##_interfaces = \
DOMCI_CASTABLE_INTERFACES(_class) \
0;
#define DOMCI_DATA(_dom_class, _class) /* nothing */
class nsIClassInfo;
class nsXPCClassInfo;

View File

@ -146,8 +146,8 @@ interface nsIXPCScriptable : nsISupports
#include "nsAutoPtr.h"
#define NS_XPCCLASSINFO_IID \
{ 0x9a5b0342, 0x0f70, 0x4d31, \
{ 0xb7, 0xd7, 0x29, 0x68, 0xa5, 0x70, 0x4b, 0xd8 } }
{ 0x43b67f01, 0xd4ce, 0x4b82, \
{ 0xb3, 0xf8, 0xeb, 0xf2, 0x13, 0x60, 0xfb, 0x7e } }
class NS_NO_VTABLE nsXPCClassInfo : public nsIClassInfo,
public nsIXPCScriptable
@ -159,8 +159,6 @@ public:
NS_IMETHOD_(MozExternalRefCountType) Release() = 0;
virtual void PreserveWrapper(nsISupports *aNative) = 0;
virtual uint32_t GetInterfacesBitmap() = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsXPCClassInfo, NS_XPCCLASSINFO_IID)

View File

@ -587,10 +587,9 @@ XPCNativeScriptableSharedMap::Entry::Match(PLDHashTable *table,
XPCNativeScriptableShared* obj2 =
(XPCNativeScriptableShared*) key;
// match the flags, the classname string and the interfaces bitmap
// match the flags and the classname string
if (obj1->GetFlags() != obj2->GetFlags() ||
obj1->GetInterfacesBitmap() != obj2->GetInterfacesBitmap())
if (obj1->GetFlags() != obj2->GetFlags())
return false;
const char* name1 = obj1->GetJSClass()->name;
@ -639,13 +638,12 @@ XPCNativeScriptableSharedMap::~XPCNativeScriptableSharedMap()
bool
XPCNativeScriptableSharedMap::GetNewOrUsed(uint32_t flags,
char* name,
uint32_t interfacesBitmap,
XPCNativeScriptableInfo* si)
{
NS_PRECONDITION(name,"bad param");
NS_PRECONDITION(si,"bad param");
XPCNativeScriptableShared key(flags, name, interfacesBitmap);
XPCNativeScriptableShared key(flags, name);
Entry* entry = (Entry*)
PL_DHashTableOperate(mTable, &key, PL_DHASH_ADD);
if (!entry)
@ -655,8 +653,7 @@ XPCNativeScriptableSharedMap::GetNewOrUsed(uint32_t flags,
if (!shared) {
entry->key = shared =
new XPCNativeScriptableShared(flags, key.TransferNameOwnership(),
interfacesBitmap);
new XPCNativeScriptableShared(flags, key.TransferNameOwnership());
if (!shared)
return false;
shared->PopulateJSClass();

View File

@ -559,8 +559,7 @@ public:
static XPCNativeScriptableSharedMap* newMap(int length);
bool GetNewOrUsed(uint32_t flags, char* name, uint32_t interfacesBitmap,
XPCNativeScriptableInfo* si);
bool GetNewOrUsed(uint32_t flags, char* name, XPCNativeScriptableInfo* si);
inline uint32_t Count() { return mTable->EntryCount(); }
inline uint32_t Enumerate(PLDHashEnumerator f, void *arg)

View File

@ -19,16 +19,6 @@
using namespace mozilla;
using namespace JS;
static MOZ_ALWAYS_INLINE bool
HasBitInInterfacesBitmap(JSObject *obj, uint32_t interfaceBit)
{
MOZ_ASSERT(IS_WN_REFLECTOR(obj), "Not a wrapper?");
const XPCWrappedNativeJSClass *clasp =
(const XPCWrappedNativeJSClass*)js::GetObjectClass(obj);
return (clasp->interfacesBitmap & (1 << interfaceBit)) != 0;
}
static nsresult
getNative(nsISupports *idobj,
HandleObject obj,

View File

@ -681,7 +681,6 @@ XPCWrappedNative::GatherProtoScriptableCreateInfo(nsIClassInfo* classInfo,
uint32_t flags = classInfoHelper->GetScriptableFlags();
sciProto.SetCallback(helper.forget());
sciProto.SetFlags(XPCNativeScriptableFlags(flags));
sciProto.SetInterfacesBitmap(classInfoHelper->GetInterfacesBitmap());
return;
}

View File

@ -696,8 +696,7 @@ const XPCWrappedNativeJSClass XPC_WN_NoHelper_JSClass = {
XPC_WN_JSOp_Enumerate,
XPC_WN_JSOp_ThisObject,
}
},
0 // interfacesBitmap
}
};
@ -1077,8 +1076,7 @@ XPCNativeScriptableInfo::Construct(const XPCNativeScriptableCreateInfo* sci)
XPCJSRuntime* rt = XPCJSRuntime::Get();
XPCNativeScriptableSharedMap* map = rt->GetNativeScriptableSharedMap();
success = map->GetNewOrUsed(sci->GetFlags(), name,
sci->GetInterfacesBitmap(), newObj);
success = map->GetNewOrUsed(sci->GetFlags(), name, newObj);
if (!success) {
delete newObj;

View File

@ -1648,27 +1648,24 @@ public:
// We maintain the invariant that every JSClass for which ext.isWrappedNative
// is true is a contained in an instance of this struct, and can thus be cast
// to it.
//
// XXXbz Do we still need this struct at all?
struct XPCWrappedNativeJSClass
{
js::Class base;
uint32_t interfacesBitmap;
};
class XPCNativeScriptableShared
{
public:
const XPCNativeScriptableFlags& GetFlags() const {return mFlags;}
uint32_t GetInterfacesBitmap() const
{return mJSClass.interfacesBitmap;}
const JSClass* GetJSClass()
{return Jsvalify(&mJSClass.base);}
XPCNativeScriptableShared(uint32_t aFlags, char* aName,
uint32_t interfacesBitmap)
XPCNativeScriptableShared(uint32_t aFlags, char* aName)
: mFlags(aFlags)
{memset(&mJSClass, 0, sizeof(mJSClass));
mJSClass.base.name = aName; // take ownership
mJSClass.interfacesBitmap = interfacesBitmap;
MOZ_COUNT_CTOR(XPCNativeScriptableShared);}
~XPCNativeScriptableShared()
@ -1706,9 +1703,6 @@ public:
const XPCNativeScriptableFlags&
GetFlags() const {return mShared->GetFlags();}
uint32_t
GetInterfacesBitmap() const {return mShared->GetInterfacesBitmap();}
const JSClass*
GetJSClass() {return mShared->GetJSClass();}
@ -1759,17 +1753,14 @@ class MOZ_STACK_CLASS XPCNativeScriptableCreateInfo
public:
explicit XPCNativeScriptableCreateInfo(const XPCNativeScriptableInfo& si)
: mCallback(si.GetCallback()), mFlags(si.GetFlags()),
mInterfacesBitmap(si.GetInterfacesBitmap()) {}
: mCallback(si.GetCallback()), mFlags(si.GetFlags()) {}
XPCNativeScriptableCreateInfo(already_AddRefed<nsIXPCScriptable>&& callback,
XPCNativeScriptableFlags flags,
uint32_t interfacesBitmap)
: mCallback(callback), mFlags(flags),
mInterfacesBitmap(interfacesBitmap) {}
XPCNativeScriptableFlags flags)
: mCallback(callback), mFlags(flags) {}
XPCNativeScriptableCreateInfo()
: mFlags(0), mInterfacesBitmap(0) {}
: mFlags(0) {}
nsIXPCScriptable*
@ -1778,9 +1769,6 @@ public:
const XPCNativeScriptableFlags&
GetFlags() const {return mFlags;}
uint32_t
GetInterfacesBitmap() const {return mInterfacesBitmap;}
void
SetCallback(already_AddRefed<nsIXPCScriptable>&& callback)
{mCallback = callback;}
@ -1788,14 +1776,9 @@ public:
void
SetFlags(const XPCNativeScriptableFlags& flags) {mFlags = flags;}
void
SetInterfacesBitmap(uint32_t interfacesBitmap)
{mInterfacesBitmap = interfacesBitmap;}
private:
nsCOMPtr<nsIXPCScriptable> mCallback;
XPCNativeScriptableFlags mFlags;
uint32_t mInterfacesBitmap;
};
/***********************************************/