mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1176462 - Remove nsTableDecoderSupport. r=smontagu
This commit is contained in:
parent
4161a5ac2b
commit
9d935bbe8f
@ -149,43 +149,6 @@ public:
|
||||
int32_t* aDestLength);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsTableDecoderSupport [declaration]
|
||||
|
||||
/**
|
||||
* Support class for a single-table-driven Unicode decoder.
|
||||
*
|
||||
* @created 15/Mar/1999
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsTableDecoderSupport : public nsBufferDecoderSupport
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
nsTableDecoderSupport(uScanClassID aScanClass, uShiftInTable * aShiftInTable,
|
||||
uMappingTable * aMappingTable, uint32_t aMaxLengthFactor);
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsTableDecoderSupport();
|
||||
|
||||
protected:
|
||||
|
||||
uScanClassID mScanClass;
|
||||
uShiftInTable * mShiftInTable;
|
||||
uMappingTable * mMappingTable;
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Subclassing of nsBufferDecoderSupport class [declaration]
|
||||
|
||||
NS_IMETHOD ConvertNoBuff(const char * aSrc, int32_t * aSrcLength,
|
||||
char16_t * aDest, int32_t * aDestLength);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsMultiTableDecoderSupport [declaration]
|
||||
|
||||
|
@ -12,55 +12,21 @@
|
||||
|
||||
#include "nsGBKToUnicode.h"
|
||||
#include "gbku.h"
|
||||
|
||||
//------------------------------------------------------------
|
||||
// nsGB18030Unique2BytesToUnicode
|
||||
//------------------------------------------------------------
|
||||
class nsGB18030Unique2BytesToUnicode : public nsTableDecoderSupport
|
||||
{
|
||||
public:
|
||||
nsGB18030Unique2BytesToUnicode();
|
||||
virtual ~nsGB18030Unique2BytesToUnicode()
|
||||
{ }
|
||||
protected:
|
||||
};
|
||||
#include "nsUnicodeDecodeHelper.h"
|
||||
|
||||
static const uint16_t g_utGB18030Unique2Bytes[] = {
|
||||
#include "gb18030uniq2b.ut"
|
||||
};
|
||||
nsGB18030Unique2BytesToUnicode::nsGB18030Unique2BytesToUnicode()
|
||||
: nsTableDecoderSupport(u2BytesCharset, nullptr,
|
||||
(uMappingTable*) &g_utGB18030Unique2Bytes, 1)
|
||||
{
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
// nsGB18030Unique4BytesToUnicode
|
||||
//------------------------------------------------------------
|
||||
class nsGB18030Unique4BytesToUnicode : public nsTableDecoderSupport
|
||||
{
|
||||
public:
|
||||
nsGB18030Unique4BytesToUnicode();
|
||||
virtual ~nsGB18030Unique4BytesToUnicode()
|
||||
{ }
|
||||
protected:
|
||||
};
|
||||
|
||||
static const uint16_t g_utGB18030Unique4Bytes[] = {
|
||||
#include "gb180304bytes.ut"
|
||||
};
|
||||
nsGB18030Unique4BytesToUnicode::nsGB18030Unique4BytesToUnicode()
|
||||
: nsTableDecoderSupport(u4BytesGB18030Charset, nullptr,
|
||||
(uMappingTable*) &g_utGB18030Unique4Bytes, 1)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsGBKToUnicode [implementation]
|
||||
// Class nsGB18030ToUnicode [implementation]
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTablesDecoderSupport class [implementation]
|
||||
// Subclassing of nsBufferDecoderSupport class [implementation]
|
||||
|
||||
#define LEGAL_GBK_MULTIBYTE_FIRST_BYTE(c) \
|
||||
(UINT8_IN_RANGE(0x81, (c), 0xFE))
|
||||
@ -207,14 +173,6 @@ NS_IMETHODIMP nsGB18030ToUnicode::ConvertNoBuff(const char* aSrc,
|
||||
return rv;
|
||||
}
|
||||
|
||||
void nsGB18030ToUnicode::CreateExtensionDecoder()
|
||||
{
|
||||
mExtensionDecoder = new nsGB18030Unique2BytesToUnicode();
|
||||
}
|
||||
void nsGB18030ToUnicode::Create4BytesDecoder()
|
||||
{
|
||||
m4BytesDecoder = new nsGB18030Unique4BytesToUnicode();
|
||||
}
|
||||
bool nsGB18030ToUnicode::DecodeToSurrogate(const char* aSrc, char16_t* aOut)
|
||||
{
|
||||
NS_ASSERTION(FIRST_BYTE_IS_SURROGATE(aSrc[0]), "illegal first byte");
|
||||
@ -250,43 +208,32 @@ bool nsGB18030ToUnicode::DecodeToSurrogate(const char* aSrc, char16_t* aOut)
|
||||
}
|
||||
bool nsGB18030ToUnicode::TryExtensionDecoder(const char* aSrc, char16_t* aOut)
|
||||
{
|
||||
if(!mExtensionDecoder)
|
||||
CreateExtensionDecoder();
|
||||
NS_ASSERTION(mExtensionDecoder, "cannot creqte 2 bytes unique converter");
|
||||
if(mExtensionDecoder)
|
||||
{
|
||||
nsresult res = mExtensionDecoder->Reset();
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "2 bytes unique conversoin reset failed");
|
||||
int32_t len = 2;
|
||||
int32_t dstlen = 1;
|
||||
res = mExtensionDecoder->Convert(aSrc,&len, aOut, &dstlen);
|
||||
NS_ASSERTION(NS_FAILED(res) || ((len==2) && (dstlen == 1)),
|
||||
"some strange conversion result");
|
||||
// if we failed, we then just use the 0xfffd
|
||||
// therefore, we ignore the res here.
|
||||
if(NS_SUCCEEDED(res))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
int32_t len = 2;
|
||||
int32_t dstlen = 1;
|
||||
nsresult res =
|
||||
nsUnicodeDecodeHelper::ConvertByTable(aSrc, &len, aOut, &dstlen,
|
||||
u2BytesCharset, nullptr,
|
||||
(uMappingTable*) &g_utGB18030Unique2Bytes,
|
||||
false);
|
||||
NS_ASSERTION(NS_FAILED(res) || ((len==2) && (dstlen == 1)),
|
||||
"some strange conversion result");
|
||||
// if we failed, we then just use the 0xfffd
|
||||
// therefore, we ignore the res here.
|
||||
return NS_SUCCEEDED(res);
|
||||
}
|
||||
|
||||
bool nsGB18030ToUnicode::Try4BytesDecoder(const char* aSrc, char16_t* aOut)
|
||||
{
|
||||
if(!m4BytesDecoder)
|
||||
Create4BytesDecoder();
|
||||
if(m4BytesDecoder)
|
||||
{
|
||||
nsresult res = m4BytesDecoder->Reset();
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "4 bytes unique conversoin reset failed");
|
||||
int32_t len = 4;
|
||||
int32_t dstlen = 1;
|
||||
res = m4BytesDecoder->Convert(aSrc,&len, aOut, &dstlen);
|
||||
NS_ASSERTION(NS_FAILED(res) || ((len==4) && (dstlen == 1)),
|
||||
"some strange conversion result");
|
||||
// if we failed, we then just use the 0xfffd
|
||||
// therefore, we ignore the res here.
|
||||
if(NS_SUCCEEDED(res))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
int32_t len = 4;
|
||||
int32_t dstlen = 1;
|
||||
nsresult res =
|
||||
nsUnicodeDecodeHelper::ConvertByTable(aSrc, &len, aOut, &dstlen,
|
||||
u4BytesGB18030Charset, nullptr,
|
||||
(uMappingTable*) &g_utGB18030Unique4Bytes,
|
||||
false);
|
||||
NS_ASSERTION(NS_FAILED(res) || ((len==4) && (dstlen == 1)),
|
||||
"some strange conversion result");
|
||||
// if we failed, we then just use the 0xfffd
|
||||
// therefore, we ignore the res here.
|
||||
return NS_SUCCEEDED(res);
|
||||
}
|
||||
|
@ -29,23 +29,17 @@ public:
|
||||
*/
|
||||
nsGB18030ToUnicode() : nsBufferDecoderSupport(1)
|
||||
{
|
||||
mExtensionDecoder = nullptr;
|
||||
m4BytesDecoder = nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Subclassing of nsDecoderSupport class [declaration]
|
||||
// Subclassing of nsBufferDecoderSupport class [declaration]
|
||||
NS_IMETHOD ConvertNoBuff(const char* aSrc, int32_t * aSrcLength, char16_t *aDest, int32_t * aDestLength);
|
||||
|
||||
protected:
|
||||
nsGBKConvUtil mUtil;
|
||||
nsCOMPtr<nsIUnicodeDecoder> mExtensionDecoder;
|
||||
nsCOMPtr<nsIUnicodeDecoder> m4BytesDecoder;
|
||||
|
||||
void CreateExtensionDecoder();
|
||||
void Create4BytesDecoder();
|
||||
bool TryExtensionDecoder(const char* aSrc, char16_t* aDest);
|
||||
bool Try4BytesDecoder(const char* aSrc, char16_t* aDest);
|
||||
bool DecodeToSurrogate(const char* aSrc, char16_t* aDest);
|
||||
|
@ -198,39 +198,6 @@ NS_IMETHODIMP nsBufferDecoderSupport::GetMaxLength(const char* aSrc,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsTableDecoderSupport [implementation]
|
||||
|
||||
nsTableDecoderSupport::nsTableDecoderSupport(uScanClassID aScanClass,
|
||||
uShiftInTable* aShiftInTable,
|
||||
uMappingTable* aMappingTable,
|
||||
uint32_t aMaxLengthFactor)
|
||||
: nsBufferDecoderSupport(aMaxLengthFactor)
|
||||
{
|
||||
mScanClass = aScanClass;
|
||||
mShiftInTable = aShiftInTable;
|
||||
mMappingTable = aMappingTable;
|
||||
}
|
||||
|
||||
nsTableDecoderSupport::~nsTableDecoderSupport()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsBufferDecoderSupport class [implementation]
|
||||
|
||||
NS_IMETHODIMP nsTableDecoderSupport::ConvertNoBuff(const char* aSrc,
|
||||
int32_t* aSrcLength,
|
||||
char16_t* aDest,
|
||||
int32_t* aDestLength)
|
||||
{
|
||||
return nsUnicodeDecodeHelper::ConvertByTable(aSrc, aSrcLength,
|
||||
aDest, aDestLength,
|
||||
mScanClass,
|
||||
mShiftInTable, mMappingTable,
|
||||
mErrBehavior == kOnError_Signal);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsMultiTableDecoderSupport [implementation]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user