mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
fixes bug 263360 "Make CallCreateInstance use NS_GetComponentManager instead of nonfrozen/deprecated nsComponentManager symbols" r=bsmedberg sr=dbaron
This commit is contained in:
parent
36264e9bde
commit
6d8591d85f
@ -37,6 +37,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsCSSScanner.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsString.h"
|
||||
|
@ -88,9 +88,10 @@ RegisterComponents()
|
||||
nsIGenericFactory* fact;
|
||||
|
||||
// Register the factory for all supporting interfaces.
|
||||
nsCOMPtr<nsIComponentManager> compMgr = do_GetService(kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIComponentRegistrar> registrar(do_QueryInterface(compMgr));
|
||||
nsCOMPtr<nsIComponentRegistrar> registrar;
|
||||
rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Register nsQABrowserView
|
||||
rv = NS_NewGenericFactory(&fact, gQAEmbeddingModuleViewInfo);
|
||||
@ -196,4 +197,4 @@ NSGetFactory(nsISupports* aServMgr,
|
||||
return rv;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIComponentLoader.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIComponentManagerObsolete.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsIModule.h"
|
||||
|
@ -47,6 +47,7 @@
|
||||
{0xa1, 0xf5, 0xc8, 0x24, 0xef, 0xa4, 0x23, 0x1b} }
|
||||
|
||||
struct nsModuleComponentInfo;
|
||||
class nsIFile;
|
||||
|
||||
class nsContentHTTPStartup : public nsIObserver
|
||||
{
|
||||
|
@ -37,6 +37,7 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsCSSScanner.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIUnicharInputStream.h"
|
||||
#include "nsString.h"
|
||||
|
@ -74,7 +74,6 @@
|
||||
#include "nsIExternalProtocolService.h"
|
||||
|
||||
static NS_DEFINE_CID(kTransactionManagerCID, NS_TRANSACTIONMANAGER_CID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS3(nsMsgWindow,
|
||||
nsIMsgWindow,
|
||||
@ -95,24 +94,20 @@ nsMsgWindow::~nsMsgWindow()
|
||||
nsresult nsMsgWindow::Init()
|
||||
{
|
||||
// register ourselves as a content listener with the uri dispatcher service
|
||||
nsresult rv = NS_OK;
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURILoader> dispatcher =
|
||||
do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = dispatcher->RegisterContentListener(this);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = dispatcher->RegisterContentListener(this);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// create Undo/Redo Transaction Manager
|
||||
nsCOMPtr<nsIComponentManager> compMgr =
|
||||
do_GetService(kComponentManagerCID, &rv);
|
||||
|
||||
mTransactionManager = do_CreateInstance(kTransactionManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = compMgr->CreateInstance(kTransactionManagerCID, nsnull,
|
||||
NS_GET_IID(nsITransactionManager),
|
||||
getter_AddRefs(mTransactionManager));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
mTransactionManager->SetMaxTransactionCount(-1);
|
||||
}
|
||||
mTransactionManager->SetMaxTransactionCount(-1);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -70,7 +70,6 @@
|
||||
|
||||
PRLogModuleInfo *IMPORTLOGMODULE = nsnull;
|
||||
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static nsIImportService * gImportService = nsnull;
|
||||
static const char * kWhitespace = "\b\t\r\n ";
|
||||
|
||||
@ -533,14 +532,11 @@ nsresult nsImportService::LoadModuleInfo( const char *pClsId, const char *pSuppo
|
||||
// load the component and get all of the info we need from it....
|
||||
// then call AddModule
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIComponentManager> compMgr =
|
||||
do_GetService(kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
nsCID clsId;
|
||||
clsId.Parse( pClsId);
|
||||
nsIImportModule * module;
|
||||
rv = compMgr->CreateInstance( clsId, nsnull, NS_GET_IID(nsIImportModule), (void **) &module);
|
||||
rv = CallCreateInstance( clsId, &module);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsString theTitle;
|
||||
@ -579,11 +575,7 @@ nsIImportModule *ImportModuleDesc::GetModule( PRBool keepLoaded)
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIComponentManager> compMgr =
|
||||
do_GetService(kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return nsnull;
|
||||
|
||||
rv = compMgr->CreateInstance( m_cid, nsnull, NS_GET_IID(nsIImportModule), (void **) &m_pModule);
|
||||
rv = CallCreateInstance( m_cid, &m_pModule);
|
||||
if (NS_FAILED(rv)) {
|
||||
m_pModule = nsnull;
|
||||
return nsnull;
|
||||
|
@ -220,7 +220,6 @@ static NS_DEFINE_CID(kStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
static const char kDirectoryServiceContractID[] = "@mozilla.org/file/directory_service;1";
|
||||
// for the dialog
|
||||
static NS_DEFINE_IID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kCPluginManagerCID, NS_PLUGINMANAGER_CID); // needed for NS_TRY_SAFE_CALL
|
||||
|
||||
@ -5029,7 +5028,8 @@ nsresult nsPluginHostImpl::FindPlugins(PRBool aCreatePluginList, PRBool * aPlugi
|
||||
// Read cached plugins info
|
||||
ReadPluginInfo();
|
||||
|
||||
nsCOMPtr<nsIComponentManager> compManager = do_GetService(kComponentManagerCID, &rv);
|
||||
nsCOMPtr<nsIComponentManager> compManager;
|
||||
NS_GetComponentManager(getter_AddRefs(compManager));
|
||||
if (compManager)
|
||||
LoadXPCOMPlugins(compManager);
|
||||
|
||||
@ -6508,7 +6508,8 @@ nsPluginHostImpl::ScanForRealInComponentsFolder(nsIComponentManager * aCompManag
|
||||
if (NS_FAILED(pluginFile.GetPluginInfo(info)))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIComponentManager> compManager = do_GetService(kComponentManagerCID, &rv);
|
||||
nsCOMPtr<nsIComponentManager> compManager;
|
||||
NS_GetComponentManager(getter_AddRefs(compManager));
|
||||
|
||||
// finally, create our "plugin tag" and add it to the list
|
||||
if (info.fMimeTypeArray) {
|
||||
|
@ -72,6 +72,7 @@
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFRemoteDataSource.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
@ -187,10 +187,10 @@ void XXXNeverCalled()
|
||||
NS_CopyUnicodeToNative(str1, str2);
|
||||
{
|
||||
nsID id;
|
||||
nsComponentManager::CreateInstance(id, nsnull, id, nsnull);
|
||||
nsComponentManager::CreateInstance("", nsnull, id, nsnull);
|
||||
nsComponentManager::GetClassObject(id, id, nsnull);
|
||||
nsComponentManager::GetClassObjectByContractID("", id, nsnull);
|
||||
CallCreateInstance(id, nsnull, id, nsnull);
|
||||
CallCreateInstance("", nsnull, id, nsnull);
|
||||
CallGetClassObject(id, id, nsnull);
|
||||
CallGetClassObjectByContractID("", id, nsnull);
|
||||
|
||||
nsServiceManager::GetGlobalServiceManager(nsnull);
|
||||
}
|
||||
|
@ -65,7 +65,6 @@ endif
|
||||
|
||||
EXPORTS = \
|
||||
nsCategoryManagerUtils.h \
|
||||
nsComponentManagerUtils.h \
|
||||
nsComponentManagerObsolete.h \
|
||||
nsIServiceManagerUtils.h \
|
||||
nsIServiceManagerObsolete.h \
|
||||
|
@ -2769,7 +2769,6 @@ nsComponentManagerImpl::RegisterComponentCommon(const nsCID &aClass,
|
||||
|
||||
// Normalize proid and classname
|
||||
const char *contractID = (aContractID && *aContractID) ? aContractID : nsnull;
|
||||
const char *className = (aClassName && *aClassName) ? aClassName : nsnull;
|
||||
#ifdef PR_LOGGING
|
||||
if (PR_LOG_TEST(nsComponentManagerLog, PR_LOG_WARNING))
|
||||
{
|
||||
|
@ -65,6 +65,21 @@ class nsFactoryEntry;
|
||||
class nsDll;
|
||||
class nsIServiceManager;
|
||||
|
||||
#define NS_COMPONENTMANAGER_CID \
|
||||
{ /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \
|
||||
0x91775d60, \
|
||||
0xd5dc, \
|
||||
0x11d2, \
|
||||
{0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
|
||||
}
|
||||
|
||||
/* keys for registry use */
|
||||
extern const char xpcomKeyName[];
|
||||
extern const char xpcomComponentsKeyName[];
|
||||
extern const char lastModValueName[];
|
||||
extern const char fileSizeValueName[];
|
||||
extern const char nativeComponentType[];
|
||||
extern const char staticComponentType[];
|
||||
|
||||
// Predefined loader types. Do not change the numbers.
|
||||
// NATIVE should be 0 as it is being used as the first array index.
|
||||
|
@ -67,7 +67,7 @@ nsresult
|
||||
nsComponentManager::GetClassObject(const nsCID &aClass, const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
// XXX still in use by nsComponentManagerUtils.h
|
||||
NS_NOTREACHED("nsComponentManager::GetClassObject is deprecated");
|
||||
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
@ -80,7 +80,7 @@ nsComponentManager::GetClassObjectByContractID(const char *aContractID,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
// XXX still in use by nsComponentManagerUtils.h
|
||||
NS_NOTREACHED("nsComponentManager::GetClassObjectByContractID is deprecated");
|
||||
|
||||
nsCOMPtr<nsIComponentManager> cm;
|
||||
nsresult rv = NS_GetComponentManager(getter_AddRefs(cm));
|
||||
@ -119,7 +119,7 @@ nsComponentManager::CreateInstance(const nsCID &aClass,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
// XXX still in use by nsComponentManagerUtils.h
|
||||
NS_NOTREACHED("nsComponentManager::CreateInstance is deprecated");
|
||||
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
@ -133,7 +133,7 @@ nsComponentManager::CreateInstance(const char *aContractID,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
// XXX still in use by nsComponentManagerUtils.h
|
||||
NS_NOTREACHED("nsComponentManager::CreateInstance is deprecated");
|
||||
|
||||
nsIComponentManagerObsolete* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager((nsIComponentManager**)&cm);
|
||||
|
@ -1,337 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org Code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsComponentManagerUtils_h__
|
||||
#define nsComponentManagerUtils_h__
|
||||
|
||||
/*
|
||||
* Do not include this file directly. Instead,
|
||||
* |#include "nsIComponentManager.h"|.
|
||||
*/
|
||||
|
||||
#ifndef nsCOMPtr_h__
|
||||
#include "nsCOMPtr.h"
|
||||
#endif
|
||||
|
||||
#ifndef nsComponentManagerObsolete_h___
|
||||
#include "nsComponentManagerObsolete.h"
|
||||
#endif
|
||||
|
||||
#define NS_COMPONENTMANAGER_CID \
|
||||
{ /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \
|
||||
0x91775d60, \
|
||||
0xd5dc, \
|
||||
0x11d2, \
|
||||
{0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
|
||||
}
|
||||
|
||||
class NS_COM nsCreateInstanceByCID : public nsCOMPtr_helper
|
||||
{
|
||||
public:
|
||||
nsCreateInstanceByCID( const nsCID& aCID, nsISupports* aOuter, nsresult* aErrorPtr )
|
||||
: mCID(aCID),
|
||||
mOuter(aOuter),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
|
||||
|
||||
private:
|
||||
const nsCID& mCID;
|
||||
nsISupports* mOuter;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
class NS_COM nsCreateInstanceByContractID : public nsCOMPtr_helper
|
||||
{
|
||||
public:
|
||||
nsCreateInstanceByContractID( const char* aContractID, nsISupports* aOuter, nsresult* aErrorPtr )
|
||||
: mContractID(aContractID),
|
||||
mOuter(aOuter),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
|
||||
|
||||
private:
|
||||
const char* mContractID;
|
||||
nsISupports* mOuter;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
class NS_COM nsCreateInstanceFromFactory : public nsCOMPtr_helper
|
||||
{
|
||||
public:
|
||||
nsCreateInstanceFromFactory( nsIFactory* aFactory, nsISupports* aOuter, nsresult* aErrorPtr )
|
||||
: mFactory(aFactory),
|
||||
mOuter(aOuter),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
|
||||
|
||||
private:
|
||||
nsIFactory* mFactory;
|
||||
nsISupports* mOuter;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
const nsCreateInstanceByCID
|
||||
do_CreateInstance( const nsCID& aCID, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceByCID(aCID, 0, error);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsCreateInstanceByCID
|
||||
do_CreateInstance( const nsCID& aCID, nsISupports* aOuter, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceByCID(aCID, aOuter, error);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsCreateInstanceByContractID
|
||||
do_CreateInstance( const char* aContractID, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceByContractID(aContractID, 0, error);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsCreateInstanceByContractID
|
||||
do_CreateInstance( const char* aContractID, nsISupports* aOuter, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceByContractID(aContractID, aOuter, error);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsCreateInstanceFromFactory
|
||||
do_CreateInstance( nsIFactory* aFactory, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceFromFactory(aFactory, 0, error);
|
||||
}
|
||||
|
||||
inline
|
||||
const nsCreateInstanceFromFactory
|
||||
do_CreateInstance( nsIFactory* aFactory, nsISupports* aOuter, nsresult* error = 0 )
|
||||
{
|
||||
return nsCreateInstanceFromFactory(aFactory, aOuter, error);
|
||||
}
|
||||
|
||||
|
||||
class NS_COM nsGetClassObjectByCID : public nsCOMPtr_helper
|
||||
{
|
||||
public:
|
||||
nsGetClassObjectByCID( const nsCID& aCID, nsresult* aErrorPtr )
|
||||
: mCID(aCID),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
|
||||
|
||||
private:
|
||||
const nsCID& mCID;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
class NS_COM nsGetClassObjectByContractID : public nsCOMPtr_helper
|
||||
{
|
||||
public:
|
||||
nsGetClassObjectByContractID( const char* aContractID, nsresult* aErrorPtr )
|
||||
: mContractID(aContractID),
|
||||
mErrorPtr(aErrorPtr)
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
|
||||
|
||||
private:
|
||||
const char* mContractID;
|
||||
nsresult* mErrorPtr;
|
||||
};
|
||||
|
||||
/**
|
||||
* do_GetClassObject can be used to improve performance of callers
|
||||
* that call |CreateInstance| many times. They can cache the factory
|
||||
* and call do_CreateInstance or CallCreateInstance with the cached
|
||||
* factory rather than having the component manager retrieve it every
|
||||
* time.
|
||||
*/
|
||||
inline const nsGetClassObjectByCID
|
||||
do_GetClassObject( const nsCID& aCID, nsresult* error = 0 )
|
||||
{
|
||||
return nsGetClassObjectByCID(aCID, error);
|
||||
}
|
||||
|
||||
inline const nsGetClassObjectByContractID
|
||||
do_GetClassObject( const char* aContractID, nsresult* error = 0 )
|
||||
{
|
||||
return nsGetClassObjectByContractID(aContractID, error);
|
||||
}
|
||||
|
||||
// type-safe shortcuts for calling |CreateInstance|
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( const nsCID &aClass,
|
||||
nsISupports *aDelegate,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aClass, aDelegate,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( const nsCID &aClass,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aClass, nsnull,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( const char *aContractID,
|
||||
nsISupports *aDelegate,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aContractID, "null parameter");
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aContractID,
|
||||
aDelegate,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( const char *aContractID,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aContractID, "null parameter");
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aContractID, nsnull,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( nsIFactory *aFactory,
|
||||
nsISupports *aDelegate,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aFactory, "null parameter");
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return aFactory->CreateInstance(aDelegate,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallCreateInstance( nsIFactory *aFactory,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aFactory, "null parameter");
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return aFactory->CreateInstance(nsnull,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallGetClassObject( const nsCID &aClass,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::GetClassObject(aClass,
|
||||
NS_GET_IID(DestinationType), NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
inline
|
||||
nsresult
|
||||
CallGetClassObject( const char* aContractID,
|
||||
DestinationType** aDestination )
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::GetClassObjectByContractID(aContractID,
|
||||
NS_GET_IID(DestinationType), NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
/* keys for registry use */
|
||||
extern const char xpcomKeyName[];
|
||||
extern const char xpcomComponentsKeyName[];
|
||||
extern const char lastModValueName[];
|
||||
extern const char fileSizeValueName[];
|
||||
extern const char nativeComponentType[];
|
||||
extern const char staticComponentType[];
|
||||
|
||||
#endif /* nsComponentManagerUtils_h__ */
|
||||
|
||||
|
@ -106,6 +106,5 @@ interface nsIComponentManager : nsISupports
|
||||
%{ C++
|
||||
#ifndef MOZILLA_STRICT_API
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsComponentManagerObsolete.h"
|
||||
#endif
|
||||
%} C++
|
||||
|
@ -1,43 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is XPCOM.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsIComponentManagerUtils_h__
|
||||
#define nsIComponentManagerUtils_h__
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -42,6 +42,8 @@
|
||||
#include NEW_H
|
||||
#include <stdio.h>
|
||||
|
||||
extern const char staticComponentType[];
|
||||
|
||||
struct StaticModuleInfo : public PLDHashEntryHdr {
|
||||
nsStaticModuleInfo info;
|
||||
nsCOMPtr<nsIModule> module;
|
||||
|
@ -45,20 +45,111 @@
|
||||
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsIServiceManagerUtils.h"
|
||||
#include "nsIFactory.h"
|
||||
|
||||
#ifdef MOZILLA_STRICT_API
|
||||
|
||||
nsresult
|
||||
nsCreateInstanceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
||||
CallCreateInstance(const nsCID &aCID, nsISupports *aDelegate,
|
||||
const nsIID &aIID, void **aResult)
|
||||
{
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
if (compMgr)
|
||||
status = compMgr->CreateInstance(mCID, mOuter, aIID, aInstancePtr);
|
||||
else if (NS_SUCCEEDED(status))
|
||||
status = NS_ERROR_UNEXPECTED;
|
||||
status = compMgr->CreateInstance(aCID, aDelegate, aIID, aResult);
|
||||
return status;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CallCreateInstance(const char *aContractID, nsISupports *aDelegate,
|
||||
const nsIID &aIID, void **aResult)
|
||||
{
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
if (compMgr)
|
||||
status = compMgr->CreateInstanceByContractID(aContractID, aDelegate,
|
||||
aIID, aResult);
|
||||
return status;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CallGetClassObject(const nsCID &aCID, const nsIID &aIID, void **aResult)
|
||||
{
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
if (compMgr)
|
||||
status = compMgr->GetClassObject(aCID, aIID, aResult);
|
||||
return status;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CallGetClassObject(const char *aContractID, const nsIID &aIID, void **aResult)
|
||||
{
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
if (compMgr)
|
||||
status = compMgr->GetClassObjectByContractID(aContractID, aIID,
|
||||
aResult);
|
||||
return status;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "nsComponentManager.h"
|
||||
|
||||
nsresult
|
||||
CallCreateInstance(const nsCID &aCID, nsISupports *aDelegate,
|
||||
const nsIID &aIID, void **aResult)
|
||||
{
|
||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
return compMgr->
|
||||
nsComponentManagerImpl::CreateInstance(aCID, aDelegate, aIID, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CallCreateInstance(const char *aContractID, nsISupports *aDelegate,
|
||||
const nsIID &aIID, void **aResult)
|
||||
{
|
||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
return compMgr->
|
||||
nsComponentManagerImpl::CreateInstanceByContractID(aContractID,
|
||||
aDelegate, aIID,
|
||||
aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CallGetClassObject(const nsCID &aCID, const nsIID &aIID, void **aResult)
|
||||
{
|
||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
return compMgr->
|
||||
nsComponentManagerImpl::GetClassObject(aCID, aIID, aResult);
|
||||
}
|
||||
|
||||
nsresult
|
||||
CallGetClassObject(const char *aContractID, const nsIID &aIID, void **aResult)
|
||||
{
|
||||
nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
|
||||
NS_ENSURE_TRUE(compMgr, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
return compMgr->
|
||||
nsComponentManagerImpl::GetClassObjectByContractID(aContractID, aIID,
|
||||
aResult);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
nsresult
|
||||
nsCreateInstanceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
||||
{
|
||||
nsresult status = CallCreateInstance(mCID, mOuter, aIID, aInstancePtr);
|
||||
if ( NS_FAILED(status) )
|
||||
*aInstancePtr = 0;
|
||||
|
||||
if ( mErrorPtr )
|
||||
*mErrorPtr = status;
|
||||
return status;
|
||||
@ -67,19 +158,7 @@ nsCreateInstanceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) cons
|
||||
nsresult
|
||||
nsCreateInstanceByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
||||
{
|
||||
nsresult status;
|
||||
if ( mContractID ) {
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
status = NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
if (compMgr)
|
||||
status = compMgr->CreateInstanceByContractID(mContractID, mOuter,
|
||||
aIID, aInstancePtr);
|
||||
else if (NS_SUCCEEDED(status))
|
||||
status = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
else
|
||||
status = NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult status = CallCreateInstance(mContractID, mOuter, aIID, aInstancePtr);
|
||||
if (NS_FAILED(status))
|
||||
*aInstancePtr = 0;
|
||||
if ( mErrorPtr )
|
||||
@ -90,12 +169,7 @@ nsCreateInstanceByContractID::operator()( const nsIID& aIID, void** aInstancePtr
|
||||
nsresult
|
||||
nsCreateInstanceFromFactory::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
||||
{
|
||||
nsresult status;
|
||||
if ( mFactory )
|
||||
status = mFactory->CreateInstance(mOuter, aIID, aInstancePtr);
|
||||
else
|
||||
status = NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult status = mFactory->CreateInstance(mOuter, aIID, aInstancePtr);
|
||||
if ( NS_FAILED(status) )
|
||||
*aInstancePtr = 0;
|
||||
if ( mErrorPtr )
|
||||
@ -107,16 +181,9 @@ nsCreateInstanceFromFactory::operator()( const nsIID& aIID, void** aInstancePtr
|
||||
nsresult
|
||||
nsGetClassObjectByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
||||
{
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
nsresult status = NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
if (compMgr)
|
||||
status = compMgr->GetClassObject(mCID, aIID, aInstancePtr);
|
||||
else if (NS_SUCCEEDED(status))
|
||||
status = NS_ERROR_UNEXPECTED;
|
||||
|
||||
nsresult status = CallGetClassObject(mCID, aIID, aInstancePtr);
|
||||
if ( NS_FAILED(status) )
|
||||
*aInstancePtr = 0;
|
||||
|
||||
if ( mErrorPtr )
|
||||
*mErrorPtr = status;
|
||||
return status;
|
||||
@ -125,19 +192,7 @@ nsGetClassObjectByCID::operator()( const nsIID& aIID, void** aInstancePtr ) cons
|
||||
nsresult
|
||||
nsGetClassObjectByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) const
|
||||
{
|
||||
nsresult status;
|
||||
if ( mContractID ) {
|
||||
nsCOMPtr<nsIComponentManager> compMgr;
|
||||
status = NS_GetComponentManager(getter_AddRefs(compMgr));
|
||||
if (compMgr)
|
||||
status = compMgr->GetClassObjectByContractID(mContractID,
|
||||
aIID, aInstancePtr);
|
||||
else if (NS_SUCCEEDED(status))
|
||||
status = NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
else
|
||||
status = NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsresult status = CallGetClassObject(mContractID, aIID, aInstancePtr);
|
||||
if ( NS_FAILED(status) )
|
||||
*aInstancePtr = 0;
|
||||
if ( mErrorPtr )
|
||||
@ -190,6 +245,3 @@ nsGetServiceByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) c
|
||||
*mErrorPtr = status;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -38,26 +38,35 @@
|
||||
#ifndef nsComponentManagerUtils_h__
|
||||
#define nsComponentManagerUtils_h__
|
||||
|
||||
/*
|
||||
* Do not include this file directly. Instead,
|
||||
* |#include "nsIComponentManager.h"|.
|
||||
*/
|
||||
#ifndef nscore_h__
|
||||
#include "nscore.h"
|
||||
#endif
|
||||
|
||||
#ifndef nsCOMPtr_h__
|
||||
#include "nsCOMPtr.h"
|
||||
#endif
|
||||
|
||||
#ifndef nsComponentManagerObsolete_h___
|
||||
#include "nsComponentManagerObsolete.h"
|
||||
#endif
|
||||
class nsIFactory;
|
||||
|
||||
|
||||
NS_COM_GLUE nsresult
|
||||
CallCreateInstance
|
||||
(const nsCID &aClass, nsISupports *aDelegate, const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_COM_GLUE nsresult
|
||||
CallCreateInstance
|
||||
(const char *aContractID, nsISupports *aDelegate, const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_COM_GLUE nsresult
|
||||
CallGetClassObject
|
||||
(const nsCID &aClass, const nsIID &aIID, void **aResult);
|
||||
|
||||
NS_COM_GLUE nsresult
|
||||
CallGetClassObject
|
||||
(const char *aContractID, const nsIID &aIID, void **aResult);
|
||||
|
||||
#define NS_COMPONENTMANAGER_CID \
|
||||
{ /* 91775d60-d5dc-11d2-92fb-00e09805570f */ \
|
||||
0x91775d60, \
|
||||
0xd5dc, \
|
||||
0x11d2, \
|
||||
{0x92, 0xfb, 0x00, 0xe0, 0x98, 0x05, 0x57, 0x0f} \
|
||||
}
|
||||
|
||||
class NS_COM nsCreateInstanceByCID : public nsCOMPtr_helper
|
||||
{
|
||||
@ -223,9 +232,9 @@ CallCreateInstance( const nsCID &aClass,
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aClass, aDelegate,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
return CallCreateInstance(aClass, aDelegate,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
@ -236,9 +245,9 @@ CallCreateInstance( const nsCID &aClass,
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aClass, nsnull,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
return CallCreateInstance(aClass, nsnull,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
@ -251,10 +260,10 @@ CallCreateInstance( const char *aContractID,
|
||||
NS_PRECONDITION(aContractID, "null parameter");
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aContractID,
|
||||
aDelegate,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
return CallCreateInstance(aContractID,
|
||||
aDelegate,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
@ -266,9 +275,9 @@ CallCreateInstance( const char *aContractID,
|
||||
NS_PRECONDITION(aContractID, "null parameter");
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::CreateInstance(aContractID, nsnull,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
return CallCreateInstance(aContractID, nsnull,
|
||||
NS_GET_IID(DestinationType),
|
||||
NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
template <class DestinationType>
|
||||
@ -308,7 +317,7 @@ CallGetClassObject( const nsCID &aClass,
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::GetClassObject(aClass,
|
||||
return CallGetClassObject(aClass,
|
||||
NS_GET_IID(DestinationType), NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
@ -320,18 +329,8 @@ CallGetClassObject( const char* aContractID,
|
||||
{
|
||||
NS_PRECONDITION(aDestination, "null parameter");
|
||||
|
||||
return nsComponentManager::GetClassObjectByContractID(aContractID,
|
||||
return CallGetClassObject(aContractID,
|
||||
NS_GET_IID(DestinationType), NS_REINTERPRET_CAST(void**, aDestination));
|
||||
}
|
||||
|
||||
/* keys for registry use */
|
||||
extern const char xpcomKeyName[];
|
||||
extern const char xpcomComponentsKeyName[];
|
||||
extern const char lastModValueName[];
|
||||
extern const char fileSizeValueName[];
|
||||
extern const char nativeComponentType[];
|
||||
extern const char staticComponentType[];
|
||||
|
||||
#endif /* nsComponentManagerUtils_h__ */
|
||||
|
||||
|
||||
|
@ -53,6 +53,7 @@ XPCOM_GLUE_SRC_LEXPORTS = \
|
||||
nsMemory.h \
|
||||
nsTraceRefcnt.h \
|
||||
nsWeakReference.h \
|
||||
nsComponentManagerUtils.h \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user