зеркало из https://github.com/mozilla/pjs.git
fix bug 9841
This commit is contained in:
Родитель
f6f06aa9f1
Коммит
1c92b7642b
|
@ -67,7 +67,10 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr,
|
||||||
nsIFactory* factoryInstance;
|
nsIFactory* factoryInstance;
|
||||||
nsresult res;
|
nsresult res;
|
||||||
|
|
||||||
if (aFactory == NULL) return NS_ERROR_NULL_POINTER;
|
if (aFactory == NULL)
|
||||||
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
|
*aFactory = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
// first check for the nsILocaleFactory interfaces
|
// first check for the nsILocaleFactory interfaces
|
||||||
|
@ -75,6 +78,9 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr,
|
||||||
if (aClass.Equals(kLocaleFactoryCID))
|
if (aClass.Equals(kLocaleFactoryCID))
|
||||||
{
|
{
|
||||||
nsLocaleFactory *factory = new nsLocaleFactory();
|
nsLocaleFactory *factory = new nsLocaleFactory();
|
||||||
|
if(nsnull == factory)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
res = factory->QueryInterface(kILocaleFactoryIID, (void **) aFactory);
|
res = factory->QueryInterface(kILocaleFactoryIID, (void **) aFactory);
|
||||||
|
|
||||||
if (NS_FAILED(res))
|
if (NS_FAILED(res))
|
||||||
|
@ -88,6 +94,10 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* serviceMgr,
|
||||||
if (aClass.Equals(kPosixLocaleFactoryCID))
|
if (aClass.Equals(kPosixLocaleFactoryCID))
|
||||||
{
|
{
|
||||||
nsPosixLocaleFactory *posix_factory = new nsPosixLocaleFactory();
|
nsPosixLocaleFactory *posix_factory = new nsPosixLocaleFactory();
|
||||||
|
|
||||||
|
if(nsnull == posix_factory)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
res = posix_factory->QueryInterface(kIFactoryIID,(void**)aFactory);
|
res = posix_factory->QueryInterface(kIFactoryIID,(void**)aFactory);
|
||||||
if (NS_FAILED(res))
|
if (NS_FAILED(res))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,151 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Netscape Public License
|
|
||||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
|
||||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
|
||||||
* http://www.mozilla.org/NPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* NPL.
|
|
||||||
*
|
|
||||||
* The Initial Developer of this code under the NPL is Netscape
|
|
||||||
* Communications Corporation. Portions created by Netscape are
|
|
||||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
|
||||||
* Reserved.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pratom.h"
|
|
||||||
#include "nsISupports.h"
|
|
||||||
#include "nsIComponentManager.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nsIFactory.h"
|
|
||||||
#include "nsLWBrkCIID.h"
|
|
||||||
#include "nsILineBreakerFactory.h"
|
|
||||||
#include "nsIWordBreakerFactory.h"
|
|
||||||
#include "nsLWBreakerFImp.h"
|
|
||||||
#include "nsLWBRKDll.h"
|
|
||||||
#include "nsIServiceManager.h"
|
|
||||||
|
|
||||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
|
||||||
|
|
||||||
NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID);
|
|
||||||
|
|
||||||
NS_DEFINE_IID(kFactoryIID, NS_IFACTORY_IID);
|
|
||||||
|
|
||||||
PRInt32 g_InstanceCount = 0;
|
|
||||||
PRInt32 g_LockCount = 0;
|
|
||||||
|
|
||||||
class nsLWBrkFactory : public nsIFactory {
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
nsLWBrkFactory() {
|
|
||||||
NS_INIT_REFCNT();
|
|
||||||
PR_AtomicIncrement(&g_InstanceCount);
|
|
||||||
};
|
|
||||||
virtual ~nsLWBrkFactory() {
|
|
||||||
PR_AtomicDecrement(&g_InstanceCount);
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMETHOD CreateInstance(nsISupports *aDelegate,
|
|
||||||
const nsIID &aIID,
|
|
||||||
void **aResult);
|
|
||||||
|
|
||||||
NS_IMETHOD LockFactory(PRBool aLock) {
|
|
||||||
if (aLock) {
|
|
||||||
PR_AtomicIncrement(&g_LockCount);
|
|
||||||
} else {
|
|
||||||
PR_AtomicDecrement(&g_LockCount);
|
|
||||||
}
|
|
||||||
return NS_OK;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsLWBrkFactory, kFactoryIID);
|
|
||||||
|
|
||||||
nsresult nsLWBrkFactory::CreateInstance(nsISupports *aDelegate,
|
|
||||||
const nsIID &aIID,
|
|
||||||
void **aResult)
|
|
||||||
{
|
|
||||||
if(NULL == aResult ) {
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
*aResult = NULL;
|
|
||||||
|
|
||||||
nsLWBreakerFImp *imp = new nsLWBreakerFImp() ;
|
|
||||||
|
|
||||||
nsresult res = imp->QueryInterface(aIID, aResult);
|
|
||||||
|
|
||||||
if(NS_FAILED(res)) {
|
|
||||||
delete imp;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
|
||||||
const nsCID &aClass,
|
|
||||||
const char *aClassName,
|
|
||||||
const char *aProgID,
|
|
||||||
nsIFactory **aFactory)
|
|
||||||
{
|
|
||||||
if (aFactory == NULL) {
|
|
||||||
return NS_ERROR_NULL_POINTER;
|
|
||||||
}
|
|
||||||
if (aClass.Equals(kLWBrkCID)) {
|
|
||||||
nsLWBrkFactory *factory = new nsLWBrkFactory();
|
|
||||||
nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory);
|
|
||||||
if (NS_FAILED(res)) {
|
|
||||||
*aFactory = NULL;
|
|
||||||
delete factory;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
return NS_NOINTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" NS_EXPORT PRBool NSCanUnload(nsISupports* aServMgr) {
|
|
||||||
return PRBool(g_InstanceCount == 0 && g_LockCount == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *path)
|
|
||||||
{
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
nsIComponentManager* compMgr;
|
|
||||||
rv = servMgr->GetService(kComponentManagerCID,
|
|
||||||
nsIComponentManager::GetIID(),
|
|
||||||
(nsISupports**)&compMgr);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
rv = compMgr->RegisterComponent(kLWBrkCID,
|
|
||||||
"Line and Word Breaker",
|
|
||||||
NS_LWBRK_PROGID,
|
|
||||||
path,
|
|
||||||
PR_TRUE, PR_TRUE);
|
|
||||||
|
|
||||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char *path)
|
|
||||||
{
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
nsIComponentManager* compMgr;
|
|
||||||
rv = servMgr->GetService(kComponentManagerCID,
|
|
||||||
nsIComponentManager::GetIID(),
|
|
||||||
(nsISupports**)&compMgr);
|
|
||||||
if (NS_FAILED(rv)) return rv;
|
|
||||||
|
|
||||||
rv = compMgr->UnregisterComponent(kLWBrkCID, path);
|
|
||||||
|
|
||||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
|
||||||
return rv;
|
|
||||||
}
|
|
|
@ -56,11 +56,17 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||||
const char *aProgID,
|
const char *aProgID,
|
||||||
nsIFactory **aFactory)
|
nsIFactory **aFactory)
|
||||||
{
|
{
|
||||||
if (aFactory == NULL) return NS_ERROR_NULL_POINTER;
|
if (aFactory == NULL)
|
||||||
|
return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
|
*aFactory = NULL;
|
||||||
// the converter manager
|
// the converter manager
|
||||||
if (aClass.Equals(kCharsetConverterManagerCID)) {
|
if (aClass.Equals(kCharsetConverterManagerCID)) {
|
||||||
nsManagerFactory *factory = new nsManagerFactory();
|
nsManagerFactory *factory = new nsManagerFactory();
|
||||||
|
|
||||||
|
if(nsnull == factory)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
|
|
||||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
||||||
|
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
|
@ -74,6 +80,8 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||||
// the Unicode Decode helper
|
// the Unicode Decode helper
|
||||||
if (aClass.Equals(kUnicodeDecodeHelperCID)) {
|
if (aClass.Equals(kUnicodeDecodeHelperCID)) {
|
||||||
nsDecodeHelperFactory *factory = new nsDecodeHelperFactory();
|
nsDecodeHelperFactory *factory = new nsDecodeHelperFactory();
|
||||||
|
if(nsnull == factory)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
||||||
|
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
|
@ -87,6 +95,8 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||||
// the Unicode Encode helper
|
// the Unicode Encode helper
|
||||||
if (aClass.Equals(kUnicodeEncodeHelperCID)) {
|
if (aClass.Equals(kUnicodeEncodeHelperCID)) {
|
||||||
nsEncodeHelperFactory *factory = new nsEncodeHelperFactory();
|
nsEncodeHelperFactory *factory = new nsEncodeHelperFactory();
|
||||||
|
if(nsnull == factory)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
nsresult res = factory->QueryInterface(kIFactoryIID, (void **) aFactory);
|
||||||
|
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
|
|
|
@ -97,8 +97,11 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||||
if (aFactory == NULL) {
|
if (aFactory == NULL) {
|
||||||
return NS_ERROR_NULL_POINTER;
|
return NS_ERROR_NULL_POINTER;
|
||||||
}
|
}
|
||||||
|
*aFactory = NULL;
|
||||||
if (aClass.Equals(kUnicharUtilCID)) {
|
if (aClass.Equals(kUnicharUtilCID)) {
|
||||||
nsUnicharUtilFactory *factory = new nsUnicharUtilFactory();
|
nsUnicharUtilFactory *factory = new nsUnicharUtilFactory();
|
||||||
|
if(nsnull == factory)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory);
|
nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory);
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
*aFactory = NULL;
|
*aFactory = NULL;
|
||||||
|
@ -108,6 +111,8 @@ extern "C" NS_EXPORT nsresult NSGetFactory(nsISupports* aServMgr,
|
||||||
}
|
}
|
||||||
if (aClass.Equals(kHankakuToZenkakuCID)) {
|
if (aClass.Equals(kHankakuToZenkakuCID)) {
|
||||||
nsIFactory *factory = NEW_HANKAKU_TO_ZENKAKU_FACTORY();
|
nsIFactory *factory = NEW_HANKAKU_TO_ZENKAKU_FACTORY();
|
||||||
|
if(nsnull == factory)
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory);
|
nsresult res = factory->QueryInterface(kFactoryIID, (void **) aFactory);
|
||||||
if (NS_FAILED(res)) {
|
if (NS_FAILED(res)) {
|
||||||
*aFactory = NULL;
|
*aFactory = NULL;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче