mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Chamnges to allow for making every module's nsModuleComponentInfo data const; bug 74803. r=dp, sr=waterson
This commit is contained in:
parent
7cb3b6dd58
commit
dd30842c5a
@ -44,7 +44,8 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
nsGenericFactory::nsGenericFactory(nsModuleComponentInfo *info)
|
||||
|
||||
nsGenericFactory::nsGenericFactory(const nsModuleComponentInfo *info)
|
||||
: mInfo(info)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
@ -159,7 +160,7 @@ NS_IMETHODIMP nsGenericFactory::GetFlags(PRUint32 *flagsp)
|
||||
}
|
||||
|
||||
// nsIGenericFactory: component-info accessors
|
||||
NS_IMETHODIMP nsGenericFactory::SetComponentInfo(nsModuleComponentInfo *info)
|
||||
NS_IMETHODIMP nsGenericFactory::SetComponentInfo(const nsModuleComponentInfo *info)
|
||||
{
|
||||
if (mInfo && mInfo->mClassInfoGlobal)
|
||||
*mInfo->mClassInfoGlobal = 0;
|
||||
@ -169,7 +170,7 @@ NS_IMETHODIMP nsGenericFactory::SetComponentInfo(nsModuleComponentInfo *info)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetComponentInfo(nsModuleComponentInfo **infop)
|
||||
NS_IMETHODIMP nsGenericFactory::GetComponentInfo(const nsModuleComponentInfo **infop)
|
||||
{
|
||||
*infop = mInfo;
|
||||
return NS_OK;
|
||||
@ -194,7 +195,7 @@ NS_METHOD nsGenericFactory::Create(nsISupports* outer, const nsIID& aIID, void*
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewGenericFactory(nsIGenericFactory* *result,
|
||||
nsModuleComponentInfo *info)
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIGenericFactory* fact;
|
||||
@ -213,7 +214,7 @@ NS_NewGenericFactory(nsIGenericFactory* *result,
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsGenericModule::nsGenericModule(const char* moduleName, PRUint32 componentCount,
|
||||
nsModuleComponentInfo* components,
|
||||
const nsModuleComponentInfo* components,
|
||||
nsModuleConstructorProc ctor,
|
||||
nsModuleDestructorProc dtor)
|
||||
: mInitialized(PR_FALSE),
|
||||
@ -255,7 +256,7 @@ nsGenericModule::Initialize()
|
||||
// This allows objects to be created (within their modules)
|
||||
// via operator new rather than CreateInstance, yet still be
|
||||
// QI'able to nsIClassInfo.
|
||||
nsModuleComponentInfo* desc = mComponents;
|
||||
const nsModuleComponentInfo* desc = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
if (!desc->mConstructor ||
|
||||
(desc->mFlags & nsIClassInfo::EAGER_CLASSINFO)) {
|
||||
@ -317,7 +318,7 @@ nsGenericModule::GetClassObject(nsIComponentManager *aCompMgr,
|
||||
nsIDKey key(aClass);
|
||||
nsCOMPtr<nsIGenericFactory> fact = getter_AddRefs(NS_REINTERPRET_CAST(nsIGenericFactory *, mFactories.Get(&key)));
|
||||
if (fact == nsnull) {
|
||||
nsModuleComponentInfo* desc = mComponents;
|
||||
const nsModuleComponentInfo* desc = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
if (desc->mCID.Equals(aClass)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), desc);
|
||||
@ -354,7 +355,7 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr,
|
||||
printf("*** Registering %s components (all right -- a generic module!)\n", mModuleName);
|
||||
#endif
|
||||
|
||||
nsModuleComponentInfo* cp = mComponents;
|
||||
const nsModuleComponentInfo* cp = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
// Register the component only if it has a constructor
|
||||
if (cp->mConstructor) {
|
||||
@ -401,7 +402,7 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr,
|
||||
#ifdef DEBUG
|
||||
printf("*** Unregistering %s components (all right -- a generic module!)\n", mModuleName);
|
||||
#endif
|
||||
nsModuleComponentInfo* cp = mComponents;
|
||||
const nsModuleComponentInfo* cp = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
// Call the unregistration hook of the component, if any
|
||||
if (cp->mUnregisterSelfProc)
|
||||
|
@ -49,15 +49,15 @@ class nsGenericFactory : public nsIGenericFactory, public nsIClassInfo {
|
||||
public:
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_GENERICFACTORY_CID);
|
||||
|
||||
nsGenericFactory(nsModuleComponentInfo *info = NULL);
|
||||
nsGenericFactory(const nsModuleComponentInfo *info = NULL);
|
||||
virtual ~nsGenericFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
/* nsIGenericFactory methods */
|
||||
NS_IMETHOD SetComponentInfo(nsModuleComponentInfo *info);
|
||||
NS_IMETHOD GetComponentInfo(nsModuleComponentInfo **infop);
|
||||
NS_IMETHOD SetComponentInfo(const nsModuleComponentInfo *info);
|
||||
NS_IMETHOD GetComponentInfo(const nsModuleComponentInfo **infop);
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
@ -65,7 +65,7 @@ public:
|
||||
|
||||
static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||
private:
|
||||
nsModuleComponentInfo *mInfo;
|
||||
const nsModuleComponentInfo *mInfo;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -77,7 +77,7 @@ class nsGenericModule : public nsIModule
|
||||
{
|
||||
public:
|
||||
nsGenericModule(const char* moduleName, PRUint32 componentCount,
|
||||
nsModuleComponentInfo* components,
|
||||
const nsModuleComponentInfo* components,
|
||||
nsModuleConstructorProc ctor,
|
||||
nsModuleDestructorProc dtor);
|
||||
virtual ~nsGenericModule();
|
||||
@ -94,7 +94,7 @@ protected:
|
||||
PRBool mInitialized;
|
||||
const char* mModuleName;
|
||||
PRUint32 mComponentCount;
|
||||
nsModuleComponentInfo* mComponents;
|
||||
const nsModuleComponentInfo* mComponents;
|
||||
nsSupportsHashtable mFactories;
|
||||
nsModuleConstructorProc mCtor;
|
||||
nsModuleDestructorProc mDtor;
|
||||
|
@ -63,13 +63,13 @@ class nsIGenericFactory : public nsIFactory {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IGENERICFACTORY_IID)
|
||||
|
||||
NS_IMETHOD SetComponentInfo(nsModuleComponentInfo *info) = 0;
|
||||
NS_IMETHOD GetComponentInfo(nsModuleComponentInfo **infop) = 0;
|
||||
NS_IMETHOD SetComponentInfo(const nsModuleComponentInfo *info) = 0;
|
||||
NS_IMETHOD GetComponentInfo(const nsModuleComponentInfo **infop) = 0;
|
||||
};
|
||||
|
||||
extern NS_COM nsresult
|
||||
NS_NewGenericFactory(nsIGenericFactory **result,
|
||||
nsModuleComponentInfo *info);
|
||||
const nsModuleComponentInfo *info);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -132,7 +132,7 @@ typedef void (PR_CALLBACK *nsModuleDestructorProc) (nsIModule *self);
|
||||
struct nsModuleInfo {
|
||||
PRUint32 mVersion;
|
||||
const char* mModuleName;
|
||||
nsModuleComponentInfo* mComponents;
|
||||
const nsModuleComponentInfo* mComponents;
|
||||
PRUint32 mCount;
|
||||
nsModuleConstructorProc mCtor;
|
||||
nsModuleDestructorProc mDtor;
|
||||
|
@ -44,7 +44,8 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
nsGenericFactory::nsGenericFactory(nsModuleComponentInfo *info)
|
||||
|
||||
nsGenericFactory::nsGenericFactory(const nsModuleComponentInfo *info)
|
||||
: mInfo(info)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
@ -159,7 +160,7 @@ NS_IMETHODIMP nsGenericFactory::GetFlags(PRUint32 *flagsp)
|
||||
}
|
||||
|
||||
// nsIGenericFactory: component-info accessors
|
||||
NS_IMETHODIMP nsGenericFactory::SetComponentInfo(nsModuleComponentInfo *info)
|
||||
NS_IMETHODIMP nsGenericFactory::SetComponentInfo(const nsModuleComponentInfo *info)
|
||||
{
|
||||
if (mInfo && mInfo->mClassInfoGlobal)
|
||||
*mInfo->mClassInfoGlobal = 0;
|
||||
@ -169,7 +170,7 @@ NS_IMETHODIMP nsGenericFactory::SetComponentInfo(nsModuleComponentInfo *info)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetComponentInfo(nsModuleComponentInfo **infop)
|
||||
NS_IMETHODIMP nsGenericFactory::GetComponentInfo(const nsModuleComponentInfo **infop)
|
||||
{
|
||||
*infop = mInfo;
|
||||
return NS_OK;
|
||||
@ -194,7 +195,7 @@ NS_METHOD nsGenericFactory::Create(nsISupports* outer, const nsIID& aIID, void*
|
||||
|
||||
NS_COM nsresult
|
||||
NS_NewGenericFactory(nsIGenericFactory* *result,
|
||||
nsModuleComponentInfo *info)
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIGenericFactory* fact;
|
||||
@ -213,7 +214,7 @@ NS_NewGenericFactory(nsIGenericFactory* *result,
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsGenericModule::nsGenericModule(const char* moduleName, PRUint32 componentCount,
|
||||
nsModuleComponentInfo* components,
|
||||
const nsModuleComponentInfo* components,
|
||||
nsModuleConstructorProc ctor,
|
||||
nsModuleDestructorProc dtor)
|
||||
: mInitialized(PR_FALSE),
|
||||
@ -255,7 +256,7 @@ nsGenericModule::Initialize()
|
||||
// This allows objects to be created (within their modules)
|
||||
// via operator new rather than CreateInstance, yet still be
|
||||
// QI'able to nsIClassInfo.
|
||||
nsModuleComponentInfo* desc = mComponents;
|
||||
const nsModuleComponentInfo* desc = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
if (!desc->mConstructor ||
|
||||
(desc->mFlags & nsIClassInfo::EAGER_CLASSINFO)) {
|
||||
@ -317,7 +318,7 @@ nsGenericModule::GetClassObject(nsIComponentManager *aCompMgr,
|
||||
nsIDKey key(aClass);
|
||||
nsCOMPtr<nsIGenericFactory> fact = getter_AddRefs(NS_REINTERPRET_CAST(nsIGenericFactory *, mFactories.Get(&key)));
|
||||
if (fact == nsnull) {
|
||||
nsModuleComponentInfo* desc = mComponents;
|
||||
const nsModuleComponentInfo* desc = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
if (desc->mCID.Equals(aClass)) {
|
||||
rv = NS_NewGenericFactory(getter_AddRefs(fact), desc);
|
||||
@ -354,7 +355,7 @@ nsGenericModule::RegisterSelf(nsIComponentManager *aCompMgr,
|
||||
printf("*** Registering %s components (all right -- a generic module!)\n", mModuleName);
|
||||
#endif
|
||||
|
||||
nsModuleComponentInfo* cp = mComponents;
|
||||
const nsModuleComponentInfo* cp = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
// Register the component only if it has a constructor
|
||||
if (cp->mConstructor) {
|
||||
@ -401,7 +402,7 @@ nsGenericModule::UnregisterSelf(nsIComponentManager* aCompMgr,
|
||||
#ifdef DEBUG
|
||||
printf("*** Unregistering %s components (all right -- a generic module!)\n", mModuleName);
|
||||
#endif
|
||||
nsModuleComponentInfo* cp = mComponents;
|
||||
const nsModuleComponentInfo* cp = mComponents;
|
||||
for (PRUint32 i = 0; i < mComponentCount; i++) {
|
||||
// Call the unregistration hook of the component, if any
|
||||
if (cp->mUnregisterSelfProc)
|
||||
|
@ -49,15 +49,15 @@ class nsGenericFactory : public nsIGenericFactory, public nsIClassInfo {
|
||||
public:
|
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_GENERICFACTORY_CID);
|
||||
|
||||
nsGenericFactory(nsModuleComponentInfo *info = NULL);
|
||||
nsGenericFactory(const nsModuleComponentInfo *info = NULL);
|
||||
virtual ~nsGenericFactory();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
/* nsIGenericFactory methods */
|
||||
NS_IMETHOD SetComponentInfo(nsModuleComponentInfo *info);
|
||||
NS_IMETHOD GetComponentInfo(nsModuleComponentInfo **infop);
|
||||
NS_IMETHOD SetComponentInfo(const nsModuleComponentInfo *info);
|
||||
NS_IMETHOD GetComponentInfo(const nsModuleComponentInfo **infop);
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
@ -65,7 +65,7 @@ public:
|
||||
|
||||
static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
|
||||
private:
|
||||
nsModuleComponentInfo *mInfo;
|
||||
const nsModuleComponentInfo *mInfo;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -77,7 +77,7 @@ class nsGenericModule : public nsIModule
|
||||
{
|
||||
public:
|
||||
nsGenericModule(const char* moduleName, PRUint32 componentCount,
|
||||
nsModuleComponentInfo* components,
|
||||
const nsModuleComponentInfo* components,
|
||||
nsModuleConstructorProc ctor,
|
||||
nsModuleDestructorProc dtor);
|
||||
virtual ~nsGenericModule();
|
||||
@ -94,7 +94,7 @@ protected:
|
||||
PRBool mInitialized;
|
||||
const char* mModuleName;
|
||||
PRUint32 mComponentCount;
|
||||
nsModuleComponentInfo* mComponents;
|
||||
const nsModuleComponentInfo* mComponents;
|
||||
nsSupportsHashtable mFactories;
|
||||
nsModuleConstructorProc mCtor;
|
||||
nsModuleDestructorProc mDtor;
|
||||
|
@ -63,13 +63,13 @@ class nsIGenericFactory : public nsIFactory {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IGENERICFACTORY_IID)
|
||||
|
||||
NS_IMETHOD SetComponentInfo(nsModuleComponentInfo *info) = 0;
|
||||
NS_IMETHOD GetComponentInfo(nsModuleComponentInfo **infop) = 0;
|
||||
NS_IMETHOD SetComponentInfo(const nsModuleComponentInfo *info) = 0;
|
||||
NS_IMETHOD GetComponentInfo(const nsModuleComponentInfo **infop) = 0;
|
||||
};
|
||||
|
||||
extern NS_COM nsresult
|
||||
NS_NewGenericFactory(nsIGenericFactory **result,
|
||||
nsModuleComponentInfo *info);
|
||||
const nsModuleComponentInfo *info);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -132,7 +132,7 @@ typedef void (PR_CALLBACK *nsModuleDestructorProc) (nsIModule *self);
|
||||
struct nsModuleInfo {
|
||||
PRUint32 mVersion;
|
||||
const char* mModuleName;
|
||||
nsModuleComponentInfo* mComponents;
|
||||
const nsModuleComponentInfo* mComponents;
|
||||
PRUint32 mCount;
|
||||
nsModuleConstructorProc mCtor;
|
||||
nsModuleDestructorProc mDtor;
|
||||
|
Loading…
Reference in New Issue
Block a user