From 0f4e9dc5d61c72790221bd6fffc5357ed601d640 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Thu, 30 Sep 1999 21:11:05 +0000 Subject: [PATCH] Convert to module from component git-svn-id: svn://10.0.0.236/trunk@49461 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/intl/uconv/src/Makefile.in | 2 +- mozilla/intl/uconv/src/makefile.win | 8 +- .../intl/uconv/src/nsCharsetAliasFactory.h | 28 ------- mozilla/intl/uconv/src/nsCharsetAliasImp.cpp | 73 +++++-------------- .../uconv/src/nsCharsetConverterManager.cpp | 56 ++++---------- .../uconv/src/nsCharsetConverterManager.h | 61 ---------------- mozilla/intl/uconv/src/nsCharsetMenu.cpp | 60 ++++++--------- mozilla/intl/uconv/src/nsCharsetMenu.h | 33 --------- mozilla/intl/uconv/src/nsMacCharset.cpp | 67 +++++------------ mozilla/intl/uconv/src/nsOS2Charset.cpp | 69 ++++++------------ .../intl/uconv/src/nsPlatformCharsetFactory.h | 28 ------- mozilla/intl/uconv/src/nsTextToSubURI.cpp | 73 +++++-------------- mozilla/intl/uconv/src/nsTextToSubURI.h | 28 ------- mozilla/intl/uconv/src/nsUConvDll.h | 32 +++++++- mozilla/intl/uconv/src/nsUNIXCharset.cpp | 67 +++++------------ .../intl/uconv/src/nsUnicodeDecodeHelper.cpp | 60 ++++++--------- .../intl/uconv/src/nsUnicodeDecodeHelper.h | 61 ---------------- .../intl/uconv/src/nsUnicodeEncodeHelper.cpp | 59 ++++++--------- .../intl/uconv/src/nsUnicodeEncodeHelper.h | 61 ---------------- mozilla/intl/uconv/src/nsWinCharset.cpp | 67 +++++------------ .../intl/uconv/util/nsUnicodeDecodeHelper.cpp | 60 ++++++--------- .../intl/uconv/util/nsUnicodeDecodeHelper.h | 61 ---------------- .../intl/uconv/util/nsUnicodeEncodeHelper.cpp | 59 ++++++--------- .../intl/uconv/util/nsUnicodeEncodeHelper.h | 61 ---------------- 24 files changed, 274 insertions(+), 960 deletions(-) delete mode 100644 mozilla/intl/uconv/src/nsCharsetAliasFactory.h delete mode 100644 mozilla/intl/uconv/src/nsCharsetConverterManager.h delete mode 100644 mozilla/intl/uconv/src/nsPlatformCharsetFactory.h delete mode 100644 mozilla/intl/uconv/src/nsTextToSubURI.h delete mode 100644 mozilla/intl/uconv/src/nsUnicodeDecodeHelper.h delete mode 100644 mozilla/intl/uconv/src/nsUnicodeEncodeHelper.h delete mode 100644 mozilla/intl/uconv/util/nsUnicodeDecodeHelper.h delete mode 100644 mozilla/intl/uconv/util/nsUnicodeEncodeHelper.h diff --git a/mozilla/intl/uconv/src/Makefile.in b/mozilla/intl/uconv/src/Makefile.in index 9dbd03aca3b..d17d76a891a 100644 --- a/mozilla/intl/uconv/src/Makefile.in +++ b/mozilla/intl/uconv/src/Makefile.in @@ -42,10 +42,10 @@ CPPSRCS = \ nsUnicodeEncodeHelper.cpp \ nsUNIXCharset.cpp \ nsCharsetAliasImp.cpp \ - nsUConvDll.cpp \ nsURLProperties.cpp \ nsMappingCache.cpp \ nsCharsetMenu.cpp \ + nsUConvModule.cpp \ $(NULL) EXPORT_RESOURCE = \ diff --git a/mozilla/intl/uconv/src/makefile.win b/mozilla/intl/uconv/src/makefile.win index f0e945df1ad..2fc72787765 100644 --- a/mozilla/intl/uconv/src/makefile.win +++ b/mozilla/intl/uconv/src/makefile.win @@ -28,28 +28,28 @@ DLLNAME = uconv DLL=.\$(OBJDIR)\$(DLLNAME).dll CPPSRCS = \ - nsTextToSubURI.cpp \ + nsTextToSubURI.cpp \ nsCharsetConverterManager.cpp \ nsUnicodeDecodeUtil.cpp \ nsUnicodeDecodeHelper.cpp \ nsUnicodeEncodeHelper.cpp \ nsWinCharset.cpp \ nsCharsetAliasImp.cpp \ - nsUConvDll.cpp \ + nsUConvModule.cpp \ nsMappingCache.cpp \ nsURLProperties.cpp \ nsCharsetMenu.cpp \ $(NULL) CPP_OBJS= \ - .\$(OBJDIR)\nsTextToSubURI.obj \ + .\$(OBJDIR)\nsTextToSubURI.obj \ .\$(OBJDIR)\nsCharsetConverterManager.obj \ .\$(OBJDIR)\nsUnicodeDecodeUtil.obj \ .\$(OBJDIR)\nsUnicodeDecodeHelper.obj \ .\$(OBJDIR)\nsUnicodeEncodeHelper.obj \ .\$(OBJDIR)\nsWinCharset.obj \ .\$(OBJDIR)\nsCharsetAliasImp.obj \ - .\$(OBJDIR)\nsUConvDll.obj \ + .\$(OBJDIR)\nsUConvModule.obj \ .\$(OBJDIR)\nsMappingCache.obj \ .\$(OBJDIR)\nsURLProperties.obj \ .\$(OBJDIR)\nsCharsetMenu.obj \ diff --git a/mozilla/intl/uconv/src/nsCharsetAliasFactory.h b/mozilla/intl/uconv/src/nsCharsetAliasFactory.h deleted file mode 100644 index a1f1aa313b9..00000000000 --- a/mozilla/intl/uconv/src/nsCharsetAliasFactory.h +++ /dev/null @@ -1,28 +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 "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/NPL/ - * - * 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 Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifndef nsCharsetAliasFactory_h__ -#define nsCharsetAliasFactory_h__ - - -#include "nsIFactory.h" - -nsIFactory* NEW_CHARSETALIASFACTORY(); - -#endif /* nsCharsetAliasFactory_h__ */ diff --git a/mozilla/intl/uconv/src/nsCharsetAliasImp.cpp b/mozilla/intl/uconv/src/nsCharsetAliasImp.cpp index efb7c4d0656..e41a4259e7f 100644 --- a/mozilla/intl/uconv/src/nsCharsetAliasImp.cpp +++ b/mozilla/intl/uconv/src/nsCharsetAliasImp.cpp @@ -22,7 +22,6 @@ #include "nsICharsetAlias.h" -#include "nsCharsetAliasFactory.h" #include "pratom.h" // for NS_IMPL_IDS only @@ -133,64 +132,30 @@ NS_IMETHODIMP nsCharsetAlias2::Equals(const char* aCharset1, const char* aCharse return NS_ERROR_NOT_IMPLEMENTED; } -//============================================================== -class nsCharsetAliasFactory : public nsIFactory { - NS_DECL_ISUPPORTS -public: - nsCharsetAliasFactory() { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); - } - virtual ~nsCharsetAliasFactory() { - PR_AtomicDecrement(&g_InstanceCount); - } +//---------------------------------------------------------------------- - NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult); - NS_IMETHOD LockFactory(PRBool aLock); - -}; - -//-------------------------------------------------------------- -NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS( nsCharsetAliasFactory , kIFactoryIID); - -NS_IMETHODIMP nsCharsetAliasFactory::CreateInstance( - nsISupports* aDelegate, const nsIID &aIID, void** aResult) +NS_IMETHODIMP +NS_NewCharsetAlias(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - if(NULL == aResult) - return NS_ERROR_NULL_POINTER; - if(NULL != aDelegate) - return NS_ERROR_NO_AGGREGATION; - - *aResult = NULL; - - nsISupports *inst = new nsCharsetAlias2(); - - - if(NULL == inst) { + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsCharsetAlias2* inst = new nsCharsetAlias2(); + if (!inst) { + *aResult = nsnull; return NS_ERROR_OUT_OF_MEMORY; } - nsresult res =inst->QueryInterface(aIID, aResult); - if(NS_FAILED(res)) { - delete inst; + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; } - return res; } -//-------------------------------------------------------------- -NS_IMETHODIMP nsCharsetAliasFactory::LockFactory(PRBool aLock) -{ - if(aLock) - PR_AtomicIncrement( &g_LockCount ); - else - PR_AtomicDecrement( &g_LockCount ); - return NS_OK; -} - -//============================================================== -nsIFactory* NEW_CHARSETALIASFACTORY() -{ - return new nsCharsetAliasFactory(); -} - diff --git a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp index d618438860f..b80fa05816f 100644 --- a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp +++ b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp @@ -29,7 +29,6 @@ #include "nsICharsetConverterInfo.h" #include "nsIUnicodeEncoder.h" #include "nsIUnicodeDecoder.h" -#include "nsCharsetConverterManager.h" #include "nsUConvDll.h" // just for CIDs @@ -498,45 +497,22 @@ NS_IMETHODIMP nsCharsetConverterManager::GetCharsetNames( } //---------------------------------------------------------------------- -// Class nsManagerFactory [implementation] -NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS(nsManagerFactory, kIFactoryIID); - -nsManagerFactory::nsManagerFactory() +NS_IMETHODIMP +NS_NewCharsetConverterManager(nsISupports* aOuter, const nsIID& aIID, + void** aResult) { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); -} - -nsManagerFactory::~nsManagerFactory() -{ - PR_AtomicDecrement(&g_InstanceCount); -} - -//---------------------------------------------------------------------- -// Interface nsIFactory [implementation] - -NS_IMETHODIMP nsManagerFactory::CreateInstance(nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) -{ - if (aResult == NULL) return NS_ERROR_NULL_POINTER; - if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION; - - nsICharsetConverterManager * t = nsCharsetConverterManager::GetInstance(); - if (t == NULL) return NS_ERROR_OUT_OF_MEMORY; - - nsresult res = t->QueryInterface(aIID, aResult); - if (NS_FAILED(res)) delete t; - - return res; -} - -NS_IMETHODIMP nsManagerFactory::LockFactory(PRBool aLock) -{ - if (aLock) PR_AtomicIncrement(&g_LockCount); - else PR_AtomicDecrement(&g_LockCount); - - return NS_OK; + if (!aResult) { + return NS_ERROR_INVALID_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsICharsetConverterManager* inst = nsCharsetConverterManager::GetInstance(); + if (!inst) { + *aResult = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } + return inst->QueryInterface(aIID, aResult); } diff --git a/mozilla/intl/uconv/src/nsCharsetConverterManager.h b/mozilla/intl/uconv/src/nsCharsetConverterManager.h deleted file mode 100644 index ba2a440fdeb..00000000000 --- a/mozilla/intl/uconv/src/nsCharsetConverterManager.h +++ /dev/null @@ -1,61 +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 "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/NPL/ - * - * 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 Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifndef nsCharsetConverterManager_h___ -#define nsCharsetConverterManager_h___ - -#include "nsIFactory.h" - -//---------------------------------------------------------------------- -// Class nsManagerFactory [declaration] - -/** - * Factory class for the nsICharsetConverterManager objects. - * - * @created 18/Nov/1998 - * @author Catalin Rotaru [CATA] - */ -class nsManagerFactory : public nsIFactory -{ - NS_DECL_ISUPPORTS - -public: - - /** - * Class constructor. - */ - nsManagerFactory(); - - /** - * Class destructor. - */ - virtual ~nsManagerFactory(); - - //-------------------------------------------------------------------- - // Interface nsIFactory [declaration] - - NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); -}; - - - -#endif /* nsCharsetConverterManager_h___ */ diff --git a/mozilla/intl/uconv/src/nsCharsetMenu.cpp b/mozilla/intl/uconv/src/nsCharsetMenu.cpp index f6676d728fb..4caef3e38bc 100644 --- a/mozilla/intl/uconv/src/nsCharsetMenu.cpp +++ b/mozilla/intl/uconv/src/nsCharsetMenu.cpp @@ -557,45 +557,29 @@ NS_IMETHODIMP nsCharsetMenu::DoCommand(nsISupportsArray* aSources, return NS_ERROR_NOT_IMPLEMENTED; } -//---------------------------------------------------------------------------- -// Class nsCharsetMenuFactory [implementation] +//---------------------------------------------------------------------- -NS_IMPL_ISUPPORTS(nsCharsetMenuFactory, nsCOMTypeInfo::GetIID()); - -nsCharsetMenuFactory::nsCharsetMenuFactory() +NS_IMETHODIMP +NS_NewCharsetMenu(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); -} - -nsCharsetMenuFactory::~nsCharsetMenuFactory() -{ - PR_AtomicDecrement(&g_InstanceCount); -} - -//---------------------------------------------------------------------------- -// Interface nsIFactory [implementation] - -NS_IMETHODIMP nsCharsetMenuFactory::CreateInstance(nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) -{ - if (aResult == NULL) return NS_ERROR_NULL_POINTER; - if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION; - - nsCharsetMenu * t = new nsCharsetMenu; - if (t == NULL) return NS_ERROR_OUT_OF_MEMORY; - - nsresult res = t->QueryInterface(aIID, aResult); - if (NS_FAILED(res)) delete t; - + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsCharsetMenu* inst = new nsCharsetMenu(); + if (!inst) { + *aResult = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; + } return res; } - -NS_IMETHODIMP nsCharsetMenuFactory::LockFactory(PRBool aLock) -{ - if (aLock) PR_AtomicIncrement(&g_LockCount); - else PR_AtomicDecrement(&g_LockCount); - - return NS_OK; -} diff --git a/mozilla/intl/uconv/src/nsCharsetMenu.h b/mozilla/intl/uconv/src/nsCharsetMenu.h index f70d164ba93..f67579d08f1 100644 --- a/mozilla/intl/uconv/src/nsCharsetMenu.h +++ b/mozilla/intl/uconv/src/nsCharsetMenu.h @@ -30,37 +30,4 @@ #define NS_CHARSETMENU_PID "charset-menu" -//---------------------------------------------------------------------------- -// Class nsCharsetMenuFactory [declaration] - -/** - * Factory class for the nsCharsetMenu objects. - * - * @created 17/Sep/1999 - * @author Catalin Rotaru [CATA] - */ -class nsCharsetMenuFactory : public nsIFactory -{ - NS_DECL_ISUPPORTS - -public: - - /** - * Class constructor. - */ - nsCharsetMenuFactory(); - - /** - * Class destructor. - */ - virtual ~nsCharsetMenuFactory(); - - //-------------------------------------------------------------------------- - // Interface nsIFactory [declaration] - - NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID, - void **aResult); - NS_IMETHOD LockFactory(PRBool aLock); -}; - #endif /* nsCharsetMenu_h___ */ diff --git a/mozilla/intl/uconv/src/nsMacCharset.cpp b/mozilla/intl/uconv/src/nsMacCharset.cpp index 1dda628fd8a..12b2d97839b 100644 --- a/mozilla/intl/uconv/src/nsMacCharset.cpp +++ b/mozilla/intl/uconv/src/nsMacCharset.cpp @@ -18,7 +18,6 @@ */ #include "nsIPlatformCharset.h" -#include "nsPlatformCharsetFactory.h" #include "pratom.h" #include "nsURLProperties.h" #include @@ -127,57 +126,29 @@ nsMacCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar* return rv; } -class nsMacCharsetFactory : public nsIFactory { - NS_DECL_ISUPPORTS +//---------------------------------------------------------------------- -public: - nsMacCharsetFactory() { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); - } - virtual ~nsMacCharsetFactory() { - PR_AtomicDecrement(&g_InstanceCount); - } - - NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult); - NS_IMETHOD LockFactory(PRBool aLock); - -}; - -NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS( nsMacCharsetFactory , kIFactoryIID); - -NS_IMETHODIMP nsMacCharsetFactory::CreateInstance( - nsISupports* aDelegate, const nsIID &aIID, void** aResult) +NS_IMETHODIMP +NS_NewPlatformCharset(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - if(NULL == aResult) - return NS_ERROR_NULL_POINTER; - if(NULL != aDelegate) - return NS_ERROR_NO_AGGREGATION; - - *aResult = NULL; - nsISupports *inst = new nsMacCharset(); - if(NULL == inst) { + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsMacCharset* inst = new nsMacCharset(); + if (!inst) { + *aResult = nsnull; return NS_ERROR_OUT_OF_MEMORY; } - nsresult res =inst->QueryInterface(aIID, aResult); - if(NS_FAILED(res)) { - delete inst; + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; } - return res; } -NS_IMETHODIMP nsMacCharsetFactory::LockFactory(PRBool aLock) -{ - if(aLock) - PR_AtomicIncrement( &g_LockCount ); - else - PR_AtomicDecrement( &g_LockCount ); - return NS_OK; -} - -nsIFactory* NEW_PLATFORMCHARSETFACTORY() -{ - return new nsMacCharsetFactory(); -} - diff --git a/mozilla/intl/uconv/src/nsOS2Charset.cpp b/mozilla/intl/uconv/src/nsOS2Charset.cpp index 52ff6de0759..6f837c5b619 100644 --- a/mozilla/intl/uconv/src/nsOS2Charset.cpp +++ b/mozilla/intl/uconv/src/nsOS2Charset.cpp @@ -20,7 +20,6 @@ */ #include "nsIPlatformCharset.h" -#include "nsPlatformCharsetFactory.h" #include "nsUConvDll.h" #include "pratom.h" #include @@ -77,55 +76,29 @@ nsOS2Charset::GetCharset(nsPlatformCharsetSel selector, nsString& oResult) return NS_OK; } -class nsOS2CharsetFactory : public nsIFactory { - NS_DECL_ISUPPORTS +//---------------------------------------------------------------------- -public: - nsOS2CharsetFactory() { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); - } - virtual ~nsOS2CharsetFactory() { - PR_AtomicDecrement(&g_InstanceCount); - } - - NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult); - NS_IMETHOD LockFactory(PRBool aLock); - -}; - -NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS( nsOS2CharsetFactory , kIFactoryIID); - -NS_IMETHODIMP nsOS2CharsetFactory::CreateInstance( - nsISupports* aDelegate, const nsIID &aIID, void** aResult) +NS_IMETHODIMP +NS_NewPlatformCharset(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - if( !aResult) - return NS_ERROR_NULL_POINTER; - if( aDelegate) - return NS_ERROR_NO_AGGREGATION; - - *aResult = NULL; - nsISupports *inst = new nsOS2Charset; - if( !inst) + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsOS2Charset* inst = new nsOS2Charset(); + if (!inst) { + *aResult = nsnull; return NS_ERROR_OUT_OF_MEMORY; - - nsresult res =inst->QueryInterface(aIID, aResult); - if(NS_FAILED(res)) - delete inst; - + } + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; + } return res; } -NS_IMETHODIMP nsOS2CharsetFactory::LockFactory(PRBool aLock) -{ - if(aLock) - PR_AtomicIncrement( &g_LockCount ); - else - PR_AtomicDecrement( &g_LockCount ); - return NS_OK; -} - -nsIFactory* NEW_PLATFORMCHARSETFACTORY() -{ - return new nsOS2CharsetFactory(); -} diff --git a/mozilla/intl/uconv/src/nsPlatformCharsetFactory.h b/mozilla/intl/uconv/src/nsPlatformCharsetFactory.h deleted file mode 100644 index 6c301679fe7..00000000000 --- a/mozilla/intl/uconv/src/nsPlatformCharsetFactory.h +++ /dev/null @@ -1,28 +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 "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/NPL/ - * - * 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 Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifndef nsPlatformCharsetFactory_h__ -#define nsPlatformCharsetFactory_h__ - - -#include "nsIFactory.h" - -nsIFactory* NEW_PLATFORMCHARSETFACTORY(); - -#endif /* nsPlatformCharsetFactory_h__ */ diff --git a/mozilla/intl/uconv/src/nsTextToSubURI.cpp b/mozilla/intl/uconv/src/nsTextToSubURI.cpp index 0bc5a92f9ce..09d64d6df39 100644 --- a/mozilla/intl/uconv/src/nsTextToSubURI.cpp +++ b/mozilla/intl/uconv/src/nsTextToSubURI.cpp @@ -15,8 +15,6 @@ * Copyright (C) 1998 Netscape Communications Corporation. All Rights * Reserved. */ - -#include "nsTextToSubURI.h" #include "nsString.h" #include "nsIUnicodeEncoder.h" #include "nsICharsetConverterManager.h" @@ -95,63 +93,30 @@ NS_IMETHODIMP nsTextToSubURI::ConvertAndEscape( return rv; } -//============================================================== -class nsTextToSubURIFactory : public nsIFactory { - NS_DECL_ISUPPORTS -public: - nsTextToSubURIFactory() { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); - } - virtual ~nsTextToSubURIFactory() { - PR_AtomicDecrement(&g_InstanceCount); - } +//---------------------------------------------------------------------- - NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult); - NS_IMETHOD LockFactory(PRBool aLock); - -}; - -//-------------------------------------------------------------- -NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS( nsTextToSubURIFactory , kIFactoryIID); - -NS_IMETHODIMP nsTextToSubURIFactory::CreateInstance( - nsISupports* aDelegate, const nsIID &aIID, void** aResult) +NS_IMETHODIMP +NS_NewTextToSubURI(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - if(NULL == aResult) - return NS_ERROR_NULL_POINTER; - if(NULL != aDelegate) - return NS_ERROR_NO_AGGREGATION; - - *aResult = NULL; - - nsISupports *inst = new nsTextToSubURI(); - - - if(NULL == inst) { + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsTextToSubURI* inst = new nsTextToSubURI(); + if (!inst) { + *aResult = nsnull; return NS_ERROR_OUT_OF_MEMORY; } - nsresult res =inst->QueryInterface(aIID, aResult); - if(NS_FAILED(res)) { - delete inst; + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; } - return res; } -//-------------------------------------------------------------- -NS_IMETHODIMP nsTextToSubURIFactory::LockFactory(PRBool aLock) -{ - if(aLock) - PR_AtomicIncrement( &g_LockCount ); - else - PR_AtomicDecrement( &g_LockCount ); - return NS_OK; -} - -//============================================================== -nsIFactory* NEW_TEXTTOSUBURI_FACTORY() -{ - return new nsTextToSubURIFactory(); -} diff --git a/mozilla/intl/uconv/src/nsTextToSubURI.h b/mozilla/intl/uconv/src/nsTextToSubURI.h deleted file mode 100644 index 8485104a5ab..00000000000 --- a/mozilla/intl/uconv/src/nsTextToSubURI.h +++ /dev/null @@ -1,28 +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 "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/NPL/ - * - * 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 Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifndef nsTextToSubURI_h__ -#define nsTextToSubURI_h__ - - -#include "nsIFactory.h" - -nsIFactory* NEW_TEXTTOSUBURI_FACTORY(); - -#endif /* nsTextToSubURI_h__ */ diff --git a/mozilla/intl/uconv/src/nsUConvDll.h b/mozilla/intl/uconv/src/nsUConvDll.h index 503192735e2..55dbd9509b6 100644 --- a/mozilla/intl/uconv/src/nsUConvDll.h +++ b/mozilla/intl/uconv/src/nsUConvDll.h @@ -20,9 +20,39 @@ #ifndef nsUConvDll_h___ #define nsUConvDll_h___ -#include "prtypes.h" +#include "nsISupports.h" extern "C" PRInt32 g_InstanceCount; extern "C" PRInt32 g_LockCount; +// Factory methods + +NS_IMETHODIMP +NS_NewCharsetConverterManager(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + +NS_IMETHODIMP +NS_NewUnicodeDecodeHelper(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + +NS_IMETHODIMP +NS_NewUnicodeEncodeHelper(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + +NS_IMETHODIMP +NS_NewPlatformCharset(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + +NS_IMETHODIMP +NS_NewCharsetAlias(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + +NS_IMETHODIMP +NS_NewCharsetMenu(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + +NS_IMETHODIMP +NS_NewTextToSubURI(nsISupports* aOuter, const nsIID& aIID, + void** aResult); + #endif /* nsUConvDll_h___ */ diff --git a/mozilla/intl/uconv/src/nsUNIXCharset.cpp b/mozilla/intl/uconv/src/nsUNIXCharset.cpp index 04db89e7856..307a9387f1c 100644 --- a/mozilla/intl/uconv/src/nsUNIXCharset.cpp +++ b/mozilla/intl/uconv/src/nsUNIXCharset.cpp @@ -19,7 +19,6 @@ #include #include "nsIPlatformCharset.h" -#include "nsPlatformCharsetFactory.h" #include "pratom.h" #include "nsURLProperties.h" #include "nsCOMPtr.h" @@ -138,57 +137,29 @@ nsUNIXCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar } -class nsUNIXCharsetFactory : public nsIFactory { - NS_DECL_ISUPPORTS +//---------------------------------------------------------------------- -public: - nsUNIXCharsetFactory() { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); - } - virtual ~nsUNIXCharsetFactory() { - PR_AtomicDecrement(&g_InstanceCount); - } - - NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult); - NS_IMETHOD LockFactory(PRBool aLock); - -}; - -NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS( nsUNIXCharsetFactory , kIFactoryIID); - -NS_IMETHODIMP nsUNIXCharsetFactory::CreateInstance( - nsISupports* aDelegate, const nsIID &aIID, void** aResult) +NS_IMETHODIMP +NS_NewPlatformCharset(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - if(NULL == aResult) - return NS_ERROR_NULL_POINTER; - if(NULL != aDelegate) - return NS_ERROR_NO_AGGREGATION; - - *aResult = NULL; - nsISupports *inst = new nsUNIXCharset(); - if(NULL == inst) { + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsUNIXCharset* inst = new nsUNIXCharset(); + if (!inst) { + *aResult = nsnull; return NS_ERROR_OUT_OF_MEMORY; } - nsresult res =inst->QueryInterface(aIID, aResult); - if(NS_FAILED(res)) { - delete inst; + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; } - return res; } -NS_IMETHODIMP nsUNIXCharsetFactory::LockFactory(PRBool aLock) -{ - if(aLock) - PR_AtomicIncrement( &g_LockCount ); - else - PR_AtomicDecrement( &g_LockCount ); - return NS_OK; -} - -nsIFactory* NEW_PLATFORMCHARSETFACTORY() -{ - return new nsUNIXCharsetFactory(); -} - diff --git a/mozilla/intl/uconv/src/nsUnicodeDecodeHelper.cpp b/mozilla/intl/uconv/src/nsUnicodeDecodeHelper.cpp index be378ff8b19..3ed1824cae3 100644 --- a/mozilla/intl/uconv/src/nsUnicodeDecodeHelper.cpp +++ b/mozilla/intl/uconv/src/nsUnicodeDecodeHelper.cpp @@ -23,7 +23,6 @@ #include "nsIMappingCache.h" #include "nsMappingCache.h" #include "nsIUnicodeDecodeHelper.h" -#include "nsUnicodeDecodeHelper.h" #include "nsIUnicodeDecoder.h" //---------------------------------------------------------------------- @@ -258,45 +257,28 @@ NS_IMETHODIMP nsUnicodeDecodeHelper::CreateFastTable( } //---------------------------------------------------------------------- -// Class nsDecodeHelperFactory [implementation] -NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS(nsDecodeHelperFactory, kIFactoryIID); - -nsDecodeHelperFactory::nsDecodeHelperFactory() +NS_IMETHODIMP +NS_NewUnicodeDecodeHelper(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); -} - -nsDecodeHelperFactory::~nsDecodeHelperFactory() -{ - PR_AtomicDecrement(&g_InstanceCount); -} - -//---------------------------------------------------------------------- -// Interface nsIFactory [implementation] - -NS_IMETHODIMP nsDecodeHelperFactory::CreateInstance(nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) -{ - if (aResult == NULL) return NS_ERROR_NULL_POINTER; - if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION; - - nsIUnicodeDecodeHelper * t = new nsUnicodeDecodeHelper; - if (t == NULL) return NS_ERROR_OUT_OF_MEMORY; - - nsresult res = t->QueryInterface(aIID, aResult); - if (NS_FAILED(res)) delete t; - + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsUnicodeDecodeHelper* inst = new nsUnicodeDecodeHelper(); + if (!inst) { + *aResult = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; + } return res; } - -NS_IMETHODIMP nsDecodeHelperFactory::LockFactory(PRBool aLock) -{ - if (aLock) PR_AtomicIncrement(&g_LockCount); - else PR_AtomicDecrement(&g_LockCount); - - return NS_OK; -} diff --git a/mozilla/intl/uconv/src/nsUnicodeDecodeHelper.h b/mozilla/intl/uconv/src/nsUnicodeDecodeHelper.h deleted file mode 100644 index 7e7eb0a0345..00000000000 --- a/mozilla/intl/uconv/src/nsUnicodeDecodeHelper.h +++ /dev/null @@ -1,61 +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 "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/NPL/ - * - * 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 Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifndef nsUnicodeDecodeHelper_h___ -#define nsUnicodeDecodeHelper_h___ - -#include "nsIFactory.h" - -//---------------------------------------------------------------------- -// Class nsDecodeHelperFactory [declaration] - -/** - * Factory class for the nsUnicodeDecodeHelper objects. - * - * @created 18/Mar/1999 - * @author Catalin Rotaru [CATA] - */ -class nsDecodeHelperFactory : public nsIFactory -{ - NS_DECL_ISUPPORTS - -public: - - /** - * Class constructor. - */ - nsDecodeHelperFactory(); - - /** - * Class destructor. - */ - virtual ~nsDecodeHelperFactory(); - - //-------------------------------------------------------------------- - // Interface nsIFactory [declaration] - - NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); -}; - - - -#endif /* nsUnicodeDecodeHelper_h___ */ diff --git a/mozilla/intl/uconv/src/nsUnicodeEncodeHelper.cpp b/mozilla/intl/uconv/src/nsUnicodeEncodeHelper.cpp index e78fccf126a..53f1d1227c0 100644 --- a/mozilla/intl/uconv/src/nsUnicodeEncodeHelper.cpp +++ b/mozilla/intl/uconv/src/nsUnicodeEncodeHelper.cpp @@ -21,7 +21,6 @@ #include "unicpriv.h" #include "nsIUnicodeEncoder.h" #include "nsIUnicodeEncodeHelper.h" -#include "nsUnicodeEncodeHelper.h" #include "nsUConvDll.h" #include "nsIMappingCache.h" #include "nsMappingCache.h" @@ -195,46 +194,30 @@ NS_IMETHODIMP nsUnicodeEncodeHelper::FillInfo(PRUint32 *aInfo, PRInt32 aTableCou uFillInfo((uTable*) aMappingTable[i], aInfo); return NS_OK; } -//---------------------------------------------------------------------- -// Class nsEncodeHelperFactory [implementation] - -NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS(nsEncodeHelperFactory, kIFactoryIID); - -nsEncodeHelperFactory::nsEncodeHelperFactory() -{ - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); -} - -nsEncodeHelperFactory::~nsEncodeHelperFactory() -{ - PR_AtomicDecrement(&g_InstanceCount); -} //---------------------------------------------------------------------- -// Interface nsIFactory [implementation] -NS_IMETHODIMP nsEncodeHelperFactory::CreateInstance(nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) +NS_IMETHODIMP +NS_NewUnicodeEncodeHelper(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - if (aResult == NULL) return NS_ERROR_NULL_POINTER; - if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION; - - nsIUnicodeEncodeHelper * t = new nsUnicodeEncodeHelper; - if (t == NULL) return NS_ERROR_OUT_OF_MEMORY; - - nsresult res = t->QueryInterface(aIID, aResult); - if (NS_FAILED(res)) delete t; - + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsUnicodeEncodeHelper* inst = new nsUnicodeEncodeHelper(); + if (!inst) { + *aResult = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; + } return res; } - -NS_IMETHODIMP nsEncodeHelperFactory::LockFactory(PRBool aLock) -{ - if (aLock) PR_AtomicIncrement(&g_LockCount); - else PR_AtomicDecrement(&g_LockCount); - - return NS_OK; -} diff --git a/mozilla/intl/uconv/src/nsUnicodeEncodeHelper.h b/mozilla/intl/uconv/src/nsUnicodeEncodeHelper.h deleted file mode 100644 index fa437a0b329..00000000000 --- a/mozilla/intl/uconv/src/nsUnicodeEncodeHelper.h +++ /dev/null @@ -1,61 +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 "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/NPL/ - * - * 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 Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifndef nsUnicodeEncodeHelper_h___ -#define nsUnicodeEncodeHelper_h___ - -#include "nsIFactory.h" - -//---------------------------------------------------------------------- -// Class nsEncodeHelperFactory [declaration] - -/** - * Factory class for the nsUnicodeEncodeHelper objects. - * - * @created 18/Feb/1999 - * @author Catalin Rotaru [CATA] - */ -class nsEncodeHelperFactory : public nsIFactory -{ - NS_DECL_ISUPPORTS - -public: - - /** - * Class constructor. - */ - nsEncodeHelperFactory(); - - /** - * Class destructor. - */ - virtual ~nsEncodeHelperFactory(); - - //-------------------------------------------------------------------- - // Interface nsIFactory [declaration] - - NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); -}; - - - -#endif /* nsUnicodeEncodeHelper_h___ */ diff --git a/mozilla/intl/uconv/src/nsWinCharset.cpp b/mozilla/intl/uconv/src/nsWinCharset.cpp index 6b3c5ddcece..dacb1f2286e 100644 --- a/mozilla/intl/uconv/src/nsWinCharset.cpp +++ b/mozilla/intl/uconv/src/nsWinCharset.cpp @@ -22,7 +22,6 @@ #include "pratom.h" #include #include "nsUConvDll.h" -#include "nsPlatformCharsetFactory.h" #include "nsIWin32Locale.h" #include "nsCOMPtr.h" #include "nsLocaleCID.h" @@ -121,57 +120,29 @@ nsWinCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar* return result; } -class nsWinCharsetFactory : public nsIFactory { - NS_DECL_ISUPPORTS +//---------------------------------------------------------------------- -public: - nsWinCharsetFactory() { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); - } - virtual ~nsWinCharsetFactory() { - PR_AtomicDecrement(&g_InstanceCount); - } - - NS_IMETHOD CreateInstance(nsISupports* aDelegate, const nsIID& aIID, void** aResult); - NS_IMETHOD LockFactory(PRBool aLock); - -}; - -NS_DEFINE_IID( kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS( nsWinCharsetFactory , kIFactoryIID); - -NS_IMETHODIMP nsWinCharsetFactory::CreateInstance( - nsISupports* aDelegate, const nsIID &aIID, void** aResult) +NS_IMETHODIMP +NS_NewPlatformCharset(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - if(NULL == aResult) - return NS_ERROR_NULL_POINTER; - if(NULL != aDelegate) - return NS_ERROR_NO_AGGREGATION; - - *aResult = NULL; - nsISupports *inst = new nsWinCharset(); - if(NULL == inst) { + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsWinCharset* inst = new nsWinCharset(); + if (!inst) { + *aResult = nsnull; return NS_ERROR_OUT_OF_MEMORY; } - nsresult res =inst->QueryInterface(aIID, aResult); - if(NS_FAILED(res)) { - delete inst; + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; } - return res; } -NS_IMETHODIMP nsWinCharsetFactory::LockFactory(PRBool aLock) -{ - if(aLock) - PR_AtomicIncrement( &g_LockCount ); - else - PR_AtomicDecrement( &g_LockCount ); - return NS_OK; -} - -nsIFactory* NEW_PLATFORMCHARSETFACTORY() -{ - return new nsWinCharsetFactory(); -} - diff --git a/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.cpp b/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.cpp index be378ff8b19..3ed1824cae3 100644 --- a/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.cpp +++ b/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.cpp @@ -23,7 +23,6 @@ #include "nsIMappingCache.h" #include "nsMappingCache.h" #include "nsIUnicodeDecodeHelper.h" -#include "nsUnicodeDecodeHelper.h" #include "nsIUnicodeDecoder.h" //---------------------------------------------------------------------- @@ -258,45 +257,28 @@ NS_IMETHODIMP nsUnicodeDecodeHelper::CreateFastTable( } //---------------------------------------------------------------------- -// Class nsDecodeHelperFactory [implementation] -NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS(nsDecodeHelperFactory, kIFactoryIID); - -nsDecodeHelperFactory::nsDecodeHelperFactory() +NS_IMETHODIMP +NS_NewUnicodeDecodeHelper(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); -} - -nsDecodeHelperFactory::~nsDecodeHelperFactory() -{ - PR_AtomicDecrement(&g_InstanceCount); -} - -//---------------------------------------------------------------------- -// Interface nsIFactory [implementation] - -NS_IMETHODIMP nsDecodeHelperFactory::CreateInstance(nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) -{ - if (aResult == NULL) return NS_ERROR_NULL_POINTER; - if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION; - - nsIUnicodeDecodeHelper * t = new nsUnicodeDecodeHelper; - if (t == NULL) return NS_ERROR_OUT_OF_MEMORY; - - nsresult res = t->QueryInterface(aIID, aResult); - if (NS_FAILED(res)) delete t; - + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsUnicodeDecodeHelper* inst = new nsUnicodeDecodeHelper(); + if (!inst) { + *aResult = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; + } return res; } - -NS_IMETHODIMP nsDecodeHelperFactory::LockFactory(PRBool aLock) -{ - if (aLock) PR_AtomicIncrement(&g_LockCount); - else PR_AtomicDecrement(&g_LockCount); - - return NS_OK; -} diff --git a/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.h b/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.h deleted file mode 100644 index 7e7eb0a0345..00000000000 --- a/mozilla/intl/uconv/util/nsUnicodeDecodeHelper.h +++ /dev/null @@ -1,61 +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 "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/NPL/ - * - * 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 Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifndef nsUnicodeDecodeHelper_h___ -#define nsUnicodeDecodeHelper_h___ - -#include "nsIFactory.h" - -//---------------------------------------------------------------------- -// Class nsDecodeHelperFactory [declaration] - -/** - * Factory class for the nsUnicodeDecodeHelper objects. - * - * @created 18/Mar/1999 - * @author Catalin Rotaru [CATA] - */ -class nsDecodeHelperFactory : public nsIFactory -{ - NS_DECL_ISUPPORTS - -public: - - /** - * Class constructor. - */ - nsDecodeHelperFactory(); - - /** - * Class destructor. - */ - virtual ~nsDecodeHelperFactory(); - - //-------------------------------------------------------------------- - // Interface nsIFactory [declaration] - - NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); -}; - - - -#endif /* nsUnicodeDecodeHelper_h___ */ diff --git a/mozilla/intl/uconv/util/nsUnicodeEncodeHelper.cpp b/mozilla/intl/uconv/util/nsUnicodeEncodeHelper.cpp index e78fccf126a..53f1d1227c0 100644 --- a/mozilla/intl/uconv/util/nsUnicodeEncodeHelper.cpp +++ b/mozilla/intl/uconv/util/nsUnicodeEncodeHelper.cpp @@ -21,7 +21,6 @@ #include "unicpriv.h" #include "nsIUnicodeEncoder.h" #include "nsIUnicodeEncodeHelper.h" -#include "nsUnicodeEncodeHelper.h" #include "nsUConvDll.h" #include "nsIMappingCache.h" #include "nsMappingCache.h" @@ -195,46 +194,30 @@ NS_IMETHODIMP nsUnicodeEncodeHelper::FillInfo(PRUint32 *aInfo, PRInt32 aTableCou uFillInfo((uTable*) aMappingTable[i], aInfo); return NS_OK; } -//---------------------------------------------------------------------- -// Class nsEncodeHelperFactory [implementation] - -NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID); -NS_IMPL_ISUPPORTS(nsEncodeHelperFactory, kIFactoryIID); - -nsEncodeHelperFactory::nsEncodeHelperFactory() -{ - NS_INIT_REFCNT(); - PR_AtomicIncrement(&g_InstanceCount); -} - -nsEncodeHelperFactory::~nsEncodeHelperFactory() -{ - PR_AtomicDecrement(&g_InstanceCount); -} //---------------------------------------------------------------------- -// Interface nsIFactory [implementation] -NS_IMETHODIMP nsEncodeHelperFactory::CreateInstance(nsISupports *aDelegate, - const nsIID &aIID, - void **aResult) +NS_IMETHODIMP +NS_NewUnicodeEncodeHelper(nsISupports* aOuter, + const nsIID &aIID, + void **aResult) { - if (aResult == NULL) return NS_ERROR_NULL_POINTER; - if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION; - - nsIUnicodeEncodeHelper * t = new nsUnicodeEncodeHelper; - if (t == NULL) return NS_ERROR_OUT_OF_MEMORY; - - nsresult res = t->QueryInterface(aIID, aResult); - if (NS_FAILED(res)) delete t; - + if (!aResult) { + return NS_ERROR_NULL_POINTER; + } + if (aOuter) { + *aResult = nsnull; + return NS_ERROR_NO_AGGREGATION; + } + nsUnicodeEncodeHelper* inst = new nsUnicodeEncodeHelper(); + if (!inst) { + *aResult = nsnull; + return NS_ERROR_OUT_OF_MEMORY; + } + nsresult res = inst->QueryInterface(aIID, aResult); + if (NS_FAILED(res)) { + *aResult = nsnull; + delete inst; + } return res; } - -NS_IMETHODIMP nsEncodeHelperFactory::LockFactory(PRBool aLock) -{ - if (aLock) PR_AtomicIncrement(&g_LockCount); - else PR_AtomicDecrement(&g_LockCount); - - return NS_OK; -} diff --git a/mozilla/intl/uconv/util/nsUnicodeEncodeHelper.h b/mozilla/intl/uconv/util/nsUnicodeEncodeHelper.h deleted file mode 100644 index fa437a0b329..00000000000 --- a/mozilla/intl/uconv/util/nsUnicodeEncodeHelper.h +++ /dev/null @@ -1,61 +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 "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/NPL/ - * - * 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 Communicator client code. - * - * The Initial Developer of the Original Code is Netscape Communications - * Corporation. Portions created by Netscape are Copyright (C) 1998 - * Netscape Communications Corporation. All Rights Reserved. - */ - -#ifndef nsUnicodeEncodeHelper_h___ -#define nsUnicodeEncodeHelper_h___ - -#include "nsIFactory.h" - -//---------------------------------------------------------------------- -// Class nsEncodeHelperFactory [declaration] - -/** - * Factory class for the nsUnicodeEncodeHelper objects. - * - * @created 18/Feb/1999 - * @author Catalin Rotaru [CATA] - */ -class nsEncodeHelperFactory : public nsIFactory -{ - NS_DECL_ISUPPORTS - -public: - - /** - * Class constructor. - */ - nsEncodeHelperFactory(); - - /** - * Class destructor. - */ - virtual ~nsEncodeHelperFactory(); - - //-------------------------------------------------------------------- - // Interface nsIFactory [declaration] - - NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID, - void **aResult); - - NS_IMETHOD LockFactory(PRBool aLock); -}; - - - -#endif /* nsUnicodeEncodeHelper_h___ */