Hacky ASCII encoder elliminated.

This commit is contained in:
cata%netscape.com 1999-02-18 00:54:13 +00:00
Родитель 3ca3e64f0e
Коммит eb1cfb8c0d
1 изменённых файлов: 10 добавлений и 81 удалений

Просмотреть файл

@ -26,12 +26,13 @@
#include "nsICharsetConverterInfo.h"
#include "nsIUnicodeEncoder.h"
#include "nsIUnicodeDecoder.h"
#include "nsIUnicodeDecodeUtil.h"
#include "nsUnicodeDecodeUtil.h"
#include "nsCharsetConverterManager.h"
#include "nsUConvDll.h"
#include "registryhack1.h"
// XXX to be moved with its own factory
#include "nsIUnicodeDecodeUtil.h"
#include "nsUnicodeDecodeUtil.h"
//----------------------------------------------------------------------
// Global functions and data [declaration]
@ -68,10 +69,10 @@ struct ConverterInfo
* implementation, the headers inclusion and IDs declaration vs. definition
* becomes quite tricky.
*
* XXX What happens in a multithreaded environment?!
* XXX Make this a service; use the service manager; etc.
* XXX Have a clear and consistent extensibility model.
* XXX Charset names are case-insensitive!
* XXX make this component thread safe
*
* XXX Use the more general xpcom extensibility model when it will be ready.
* That means: Component Categories + Monikers. Better performance!
*
* @created 17/Nov/1998
* @author Catalin Rotaru [CATA]
@ -204,8 +205,8 @@ nsresult nsCharsetConverterManager::CreateMapping()
}
// XXX Hack! These lists should be obtained from the Repository, in a Component
// Category fashion. Hoever, for now this is the place where you should add
// new converters. Just increase the array Sizes and place the CIDs in the
// Category fashion. However, for now this is the place where you should add
// new converters. Just increase the array Sizes and place those CIDs in the
// slots.
nsresult nsCharsetConverterManager::CreateConvertersList()
{
@ -302,7 +303,7 @@ nsresult nsCharsetConverterManager::GetCharsetConverter(
// well, we didn't found any converter. Damn, life sucks!
if ((*aResult == NULL) && (NS_SUCCEEDED(res)))
res = NS_CONVERTER_NOT_FOUND;
res = NS_ERROR_UCONV_NOCONV;
return res;
}
@ -310,81 +311,10 @@ nsresult nsCharsetConverterManager::GetCharsetConverter(
//----------------------------------------------------------------------
// Interface nsICharsetConverterManager [implementation]
//***************************************************
// XXX begin of hack
class nsHackyAsciiEncoder : public nsIUnicodeEncoder
{
NS_DECL_ISUPPORTS
public:
nsHackyAsciiEncoder();
~nsHackyAsciiEncoder();
NS_IMETHOD Convert(const PRUnichar * aSrc, PRInt32 aSrcOffset, PRInt32 * aSrcLength, char * aDest, PRInt32 aDestOffset, PRInt32 * aDestLength);
NS_IMETHOD Finish(char * aDest, PRInt32 aDestOffset, PRInt32 * aDestLength);
NS_IMETHOD Length(const PRUnichar * aSrc, PRInt32 aSrcOffset, PRInt32 aSrcLength, PRInt32 * aDestLength);
NS_IMETHOD Reset();
};
NS_IMPL_ISUPPORTS(nsHackyAsciiEncoder, kIUnicodeEncoderIID);
nsHackyAsciiEncoder::nsHackyAsciiEncoder()
{
NS_INIT_REFCNT();
PR_AtomicIncrement(&g_InstanceCount);
}
nsHackyAsciiEncoder::~nsHackyAsciiEncoder()
{
PR_AtomicDecrement(&g_InstanceCount);
}
NS_IMETHODIMP nsHackyAsciiEncoder::Convert(const PRUnichar * aSrc, PRInt32 aSrcOffset, PRInt32 * aSrcLength, char * aDest, PRInt32 aDestOffset, PRInt32 * aDestLength)
{
if (aDest == NULL) return NS_ERROR_NULL_POINTER;
PRInt32 len = PR_MIN(*aSrcLength, *aDestLength);
for (PRInt32 i=0; i<len; i++) *aDest++ = ((char)*aSrc++);
nsresult res = (*aSrcLength > len)? NS_PARTIAL_MORE_OUTPUT : NS_OK;
*aSrcLength = *aDestLength = len;
return res;
}
NS_IMETHODIMP nsHackyAsciiEncoder::Finish(char * aDest, PRInt32 aDestOffset, PRInt32 * aDestLength)
{
return NS_OK;
}
NS_IMETHODIMP nsHackyAsciiEncoder::Length(const PRUnichar * aSrc, PRInt32 aSrcOffset, PRInt32 aSrcLength, PRInt32 * aDestLength)
{
*aDestLength = aSrcLength;
return NS_OK;
}
NS_IMETHODIMP nsHackyAsciiEncoder::Reset()
{
return NS_OK;
}
// XXX end of hack
//***************************************************
NS_IMETHODIMP nsCharsetConverterManager::GetUnicodeEncoder(
const nsString * aDest,
nsIUnicodeEncoder ** aResult)
{
nsIUnicodeEncoder * enc = new nsHackyAsciiEncoder();
NS_ADDREF(enc);
*aResult = enc;
return NS_OK;
/*
nsresult res;
if (!mMappingDone) {
res = CreateMapping();
@ -393,7 +323,6 @@ NS_IMETHODIMP nsCharsetConverterManager::GetUnicodeEncoder(
return GetCharsetConverter(aDest, (void **) aResult, &kIUnicodeEncoderIID,
mEncArray, mEncSize);
*/
}
NS_IMETHODIMP nsCharsetConverterManager::GetUnicodeDecoder(