add FillInfo
git-svn-id: svn://10.0.0.236/trunk@34057 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -65,6 +65,9 @@ public:
|
||||
NS_IMETHOD CreateCache(nsMappingCacheType aType, nsIMappingCache* aResult);
|
||||
|
||||
NS_IMETHOD DestroyCache(nsIMappingCache aCache);
|
||||
|
||||
NS_IMETHOD FillInfo(PRUint32* aInfo, uMappingTable * aMappingTable);
|
||||
NS_IMETHOD FillInfo(PRUint32* aInfo, PRInt32 aTableCount, uMappingTable ** aMappingTable);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -180,6 +183,18 @@ NS_IMETHODIMP nsUnicodeEncodeHelper::DestroyCache(nsIMappingCache aCache)
|
||||
{
|
||||
return nsMappingCache::DestroyCache(aCache);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::FillInfo(PRUint32 *aInfo, uMappingTable * aMappingTable)
|
||||
{
|
||||
uFillInfo((uTable*) aMappingTable, aInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::FillInfo(PRUint32 *aInfo, PRInt32 aTableCount, uMappingTable ** aMappingTable)
|
||||
{
|
||||
for (PRInt32 i=0; i<aTableCount; i++)
|
||||
uFillInfo((uTable*) aMappingTable[i], aInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsEncodeHelperFactory [implementation]
|
||||
|
||||
|
||||
@@ -21,14 +21,17 @@
|
||||
|
||||
typedef PRUint16 (* MapFormatFunc)(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
||||
typedef PRBool (* HitFormateFunc)(PRUint16 in,const uMapCell *cell);
|
||||
typedef void (* FillInfoFormateFunc)(const uTable *uT, const uMapCell *cell, PRUint32* info);
|
||||
|
||||
|
||||
PRIVATE PRBool uHitFormate0(PRUint16 in,const uMapCell *cell);
|
||||
PRIVATE PRBool uHitFormate1(PRUint16 in,const uMapCell *cell);
|
||||
PRIVATE PRBool uHitFormate2(PRUint16 in,const uMapCell *cell);
|
||||
PRIVATE PRUint16 uMapFormate0(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
||||
PRIVATE PRUint16 uMapFormate1(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
||||
PRIVATE PRUint16 uMapFormate2(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
||||
PRIVATE void uFillInfoFormate0(const uTable *uT,const uMapCell *cell,PRUint32* aInfo);
|
||||
PRIVATE void uFillInfoFormate1(const uTable *uT,const uMapCell *cell,PRUint32* aInfo);
|
||||
PRIVATE void uFillInfoFormate2(const uTable *uT,const uMapCell *cell,PRUint32* aInfo);
|
||||
|
||||
|
||||
PRIVATE const uMapCell *uGetMapCell(const uTable *uT, PRInt16 item);
|
||||
@@ -47,23 +50,49 @@ PRIVATE const MapFormatFunc m_map[uNumFormatTag] =
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE const FillInfoFormateFunc m_fillinfo[uNumFormatTag] =
|
||||
{
|
||||
uFillInfoFormate0,
|
||||
uFillInfoFormate1,
|
||||
uFillInfoFormate2,
|
||||
};
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE const HitFormateFunc m_hit[uNumFormatTag] =
|
||||
{
|
||||
uHitFormate0,
|
||||
uHitFormate1,
|
||||
uHitFormate0,
|
||||
uHitFormate2,
|
||||
};
|
||||
|
||||
#define uHit(format,in,cell) (* m_hit[(format)])((in),(cell))
|
||||
#define uMap(format,in,uT,cell) (* m_map[(format)])((in),(uT),(cell))
|
||||
#define uFillInfoCell(format,uT,cell,info) (* m_fillinfo[(format)])((uT),(cell),(info))
|
||||
#define uGetMapCell(uT, item) ((uMapCell *)(((PRUint16 *)uT) + (uT)->offsetToMapCellArray) + (item))
|
||||
#define uGetFormat(uT, item) (((((PRUint16 *)uT) + (uT)->offsetToFormatArray)[(item)>> 2 ] >> (((item)% 4 ) << 2)) & 0x0f)
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
MODULE_PRIVATE PRBool uMapCode(uTable *uT, PRUint16 in, PRUint16* out)
|
||||
MODULE_PRIVATE void uFillInfo(const uTable *uT, PRUint32* aInfo)
|
||||
{
|
||||
PRUint16 itemOfList = uT->itemOfList;
|
||||
PRUint16 i;
|
||||
for(i=0;i<itemOfList;i++)
|
||||
{
|
||||
const uMapCell* uCell;
|
||||
PRInt8 format = uGetFormat(uT,i);
|
||||
uCell = uGetMapCell(uT,i);
|
||||
uFillInfoCell(format, uT, uCell, aInfo);
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
MODULE_PRIVATE PRBool uMapCode(const uTable *uT, PRUint16 in, PRUint16* out)
|
||||
{
|
||||
PRBool done = PR_FALSE;
|
||||
PRUint16 itemOfList = uT->itemOfList;
|
||||
@@ -98,13 +127,6 @@ PRIVATE PRBool uHitFormate0(PRUint16 in,const uMapCell *cell)
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uHitFormate1(PRUint16 in,const uMapCell *cell)
|
||||
{
|
||||
return uHitFormate0(in,cell);
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uHitFormate2(PRUint16 in,const uMapCell *cell)
|
||||
{
|
||||
@@ -133,3 +155,49 @@ PRIVATE PRUint16 uMapFormate2(PRUint16 in,const uTable *uT,const uMapCell *cell)
|
||||
return (cell->fmt.format2.destBegin);
|
||||
}
|
||||
|
||||
#define SET_REPRESENTABLE(info, c) (info)[(c) >> 5] |= (1L << ((c) & 0x1f))
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE void uFillInfoFormate0(const uTable *uT,const uMapCell *cell,PRUint32* info)
|
||||
{
|
||||
PRUint16 begin, end, i;
|
||||
begin = cell->fmt.format0.srcBegin;
|
||||
end = cell->fmt.format0.srcEnd;
|
||||
if( (begin >> 5) == (end >> 5)) // High 17 bits are the same
|
||||
{
|
||||
for(i = begin; i <= end; i++)
|
||||
SET_REPRESENTABLE(info, i);
|
||||
} else {
|
||||
PRUint32 b = begin >> 5;
|
||||
PRUint32 e = end >> 5;
|
||||
info[ b ] |= (0xFFFFFFFFL << ((begin) & 0x1f));
|
||||
info[ e ] |= (0xFFFFFFFFL >> (31 - ((end) & 0x1f)));
|
||||
for(b++ ; b < e ; b++)
|
||||
info[b] |= 0xFFFFFFFFL;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE void uFillInfoFormate1(const uTable *uT,const uMapCell *cell,PRUint32* info)
|
||||
{
|
||||
PRUint16 begin, end, i;
|
||||
PRUint16 *base;
|
||||
begin = cell->fmt.format0.srcBegin;
|
||||
end = cell->fmt.format0.srcEnd;
|
||||
base = (((PRUint16 *)uT) + uT->offsetToMappingTable + cell->fmt.format1.mappingOffset);
|
||||
for(i = begin; i <= end; i++)
|
||||
{
|
||||
if(0xFFFD != base[i - begin]) /* check every item */
|
||||
SET_REPRESENTABLE(info, i);
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE void uFillInfoFormate2(const uTable *uT,const uMapCell *cell,PRUint32* info)
|
||||
{
|
||||
SET_REPRESENTABLE(info, cell->fmt.format2.srcBegin);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PRBool uMapCode( uTable *uT,
|
||||
void uFillInfo(const uTable *uT,
|
||||
PRUint32 *info);
|
||||
|
||||
PRBool uMapCode(const uTable *uT,
|
||||
PRUint16 in,
|
||||
PRUint16* out);
|
||||
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
#include "pratom.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
#include "nsUCvCnSupport.h"
|
||||
#include "nsUCvCnDll.h"
|
||||
#include "nsUCVCnDll.h"
|
||||
|
||||
#define DEFAULT_BUFFER_CAPACITY 16
|
||||
|
||||
@@ -492,8 +493,13 @@ nsresult nsEncoderSupport::QueryInterface(REFNSIID aIID,
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsICharRepresentable::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsICharRepresentable*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)this);
|
||||
*aInstancePtr = (void*) ((nsISupports*)((nsIUnicodeEncoder*)this));
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -630,6 +636,20 @@ nsTableEncoderSupport::~nsTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
@@ -673,6 +693,20 @@ nsMultiTableEncoderSupport::~nsMultiTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMultiTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo,mTableCount, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncodeHelper.h"
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
|
||||
#define ONE_BYTE_TABLE_SIZE 256
|
||||
|
||||
@@ -264,7 +265,7 @@ protected:
|
||||
* @created 17/Feb/1999
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder, public nsICharRepresentable
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
@@ -330,6 +331,10 @@ public:
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
|
||||
nsIUnicharEncoder * aEncoder, PRUnichar aChar);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsICharRepresentable [declaration]
|
||||
NS_IMETHOD FillInfo(PRUint32 *aInfo) = 0;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -355,6 +360,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -392,6 +398,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsMultiTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -43,8 +43,12 @@ nsUnicodeToGB2312::nsUnicodeToGB2312()
|
||||
|
||||
nsresult nsUnicodeToGB2312::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsUnicodeToGB2312();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToGB2312();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "pratom.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
#include "nsUCvJaSupport.h"
|
||||
#include "nsUCVJADll.h"
|
||||
|
||||
@@ -492,8 +493,13 @@ nsresult nsEncoderSupport::QueryInterface(REFNSIID aIID,
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsICharRepresentable::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsICharRepresentable*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)this);
|
||||
*aInstancePtr = (void*) ((nsISupports*)((nsIUnicodeEncoder*)this));
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -630,6 +636,20 @@ nsTableEncoderSupport::~nsTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
@@ -673,6 +693,20 @@ nsMultiTableEncoderSupport::~nsMultiTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMultiTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo,mTableCount, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncodeHelper.h"
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
|
||||
#define ONE_BYTE_TABLE_SIZE 256
|
||||
|
||||
@@ -264,7 +265,7 @@ protected:
|
||||
* @created 17/Feb/1999
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder, public nsICharRepresentable
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
@@ -330,6 +331,10 @@ public:
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
|
||||
nsIUnicharEncoder * aEncoder, PRUnichar aChar);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsICharRepresentable [declaration]
|
||||
NS_IMETHOD FillInfo(PRUint32 *aInfo) = 0;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -355,6 +360,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -392,6 +398,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsMultiTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -45,8 +45,12 @@ nsUnicodeToSJIS::nsUnicodeToSJIS()
|
||||
|
||||
nsresult nsUnicodeToSJIS::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsUnicodeToSJIS();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToSJIS();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "pratom.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
#include "nsUCvJa2Support.h"
|
||||
#include "nsUCVJA2Dll.h"
|
||||
|
||||
@@ -492,8 +493,13 @@ nsresult nsEncoderSupport::QueryInterface(REFNSIID aIID,
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsICharRepresentable::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsICharRepresentable*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)this);
|
||||
*aInstancePtr = (void*) ((nsISupports*)((nsIUnicodeEncoder*)this));
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -630,6 +636,20 @@ nsTableEncoderSupport::~nsTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
@@ -673,6 +693,20 @@ nsMultiTableEncoderSupport::~nsMultiTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMultiTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo,mTableCount, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncodeHelper.h"
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
|
||||
#define ONE_BYTE_TABLE_SIZE 256
|
||||
|
||||
@@ -264,7 +265,7 @@ protected:
|
||||
* @created 17/Feb/1999
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder, public nsICharRepresentable
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
@@ -330,6 +331,10 @@ public:
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
|
||||
nsIUnicharEncoder * aEncoder, PRUnichar aChar);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsICharRepresentable [declaration]
|
||||
NS_IMETHOD FillInfo(PRUint32 *aInfo) = 0;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -355,6 +360,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -392,6 +398,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsMultiTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -64,8 +64,12 @@ nsUnicodeToEUCJP::nsUnicodeToEUCJP()
|
||||
|
||||
nsresult nsUnicodeToEUCJP::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsUnicodeToEUCJP();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToEUCJP();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -75,8 +75,12 @@ nsUnicodeToISO2022JP::~nsUnicodeToISO2022JP()
|
||||
|
||||
nsresult nsUnicodeToISO2022JP::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsUnicodeToISO2022JP();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToISO2022JP();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToISO2022JP::ChangeCharset(PRInt32 aCharset,
|
||||
@@ -124,6 +128,19 @@ nsresult nsUnicodeToISO2022JP::ChangeCharset(PRInt32 aCharset,
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
NS_IMETHODIMP nsUnicodeToISO2022JP::FillInfo(PRUint32* aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
return mHelper->FillInfo(aInfo, 4, (uMappingTable **) g_ufMappingTables);
|
||||
|
||||
}
|
||||
NS_IMETHODIMP nsUnicodeToISO2022JP::ConvertNoBuffNoErr(
|
||||
const PRUnichar * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
|
||||
@@ -67,6 +67,7 @@ protected:
|
||||
NS_IMETHOD GetMaxLength(const PRUnichar * aSrc, PRInt32 aSrcLength,
|
||||
PRInt32 * aDestLength);
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD FillInfo(PRUint32 *aInfo);
|
||||
};
|
||||
|
||||
#endif /* nsUnicodeToISO2022JP_h___ */
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
#include "pratom.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
#include "nsUCvKOSupport.h"
|
||||
#include "nsUCvKODll.h"
|
||||
#include "nsUCVKODll.h"
|
||||
|
||||
#define DEFAULT_BUFFER_CAPACITY 16
|
||||
|
||||
@@ -492,8 +493,13 @@ nsresult nsEncoderSupport::QueryInterface(REFNSIID aIID,
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsICharRepresentable::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsICharRepresentable*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)this);
|
||||
*aInstancePtr = (void*) ((nsISupports*)((nsIUnicodeEncoder*)this));
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -630,6 +636,20 @@ nsTableEncoderSupport::~nsTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
@@ -673,6 +693,20 @@ nsMultiTableEncoderSupport::~nsMultiTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMultiTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo,mTableCount, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncodeHelper.h"
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
|
||||
#define ONE_BYTE_TABLE_SIZE 256
|
||||
|
||||
@@ -264,7 +265,7 @@ protected:
|
||||
* @created 17/Feb/1999
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder, public nsICharRepresentable
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
@@ -330,6 +331,10 @@ public:
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
|
||||
nsIUnicharEncoder * aEncoder, PRUnichar aChar);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsICharRepresentable [declaration]
|
||||
NS_IMETHOD FillInfo(PRUint32 *aInfo) = 0;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -355,6 +360,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -392,6 +398,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsMultiTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -43,8 +43,12 @@ nsUnicodeToEUCKR::nsUnicodeToEUCKR()
|
||||
|
||||
nsresult nsUnicodeToEUCKR::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsUnicodeToEUCKR();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToEUCKR();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
#include "pratom.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
#include "nsUCvTWSupport.h"
|
||||
#include "nsUCvTWDll.h"
|
||||
#include "nsUCVTWDll.h"
|
||||
|
||||
#define DEFAULT_BUFFER_CAPACITY 16
|
||||
|
||||
@@ -492,8 +493,13 @@ nsresult nsEncoderSupport::QueryInterface(REFNSIID aIID,
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsICharRepresentable::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsICharRepresentable*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)this);
|
||||
*aInstancePtr = (void*) ((nsISupports*)((nsIUnicodeEncoder*)this));
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -630,6 +636,20 @@ nsTableEncoderSupport::~nsTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
@@ -673,6 +693,20 @@ nsMultiTableEncoderSupport::~nsMultiTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMultiTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo,mTableCount, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncodeHelper.h"
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
|
||||
#define ONE_BYTE_TABLE_SIZE 256
|
||||
|
||||
@@ -264,7 +265,7 @@ protected:
|
||||
* @created 17/Feb/1999
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder, public nsICharRepresentable
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
@@ -330,6 +331,10 @@ public:
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
|
||||
nsIUnicharEncoder * aEncoder, PRUnichar aChar);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsICharRepresentable [declaration]
|
||||
NS_IMETHOD FillInfo(PRUint32 *aInfo) = 0;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -355,6 +360,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -392,6 +398,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsMultiTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -43,8 +43,12 @@ nsUnicodeToBIG5::nsUnicodeToBIG5()
|
||||
|
||||
nsresult nsUnicodeToBIG5::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsUnicodeToBIG5();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToBIG5();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -19,8 +19,9 @@
|
||||
|
||||
#include "pratom.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
#include "nsUCvTW2Support.h"
|
||||
#include "nsUCvTW2Dll.h"
|
||||
#include "nsUCVTW2Dll.h"
|
||||
|
||||
#define DEFAULT_BUFFER_CAPACITY 16
|
||||
|
||||
@@ -492,8 +493,13 @@ nsresult nsEncoderSupport::QueryInterface(REFNSIID aIID,
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(nsICharRepresentable::GetIID())) {
|
||||
*aInstancePtr = (void*) ((nsICharRepresentable*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)this);
|
||||
*aInstancePtr = (void*) ((nsISupports*)((nsIUnicodeEncoder*)this));
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
@@ -630,6 +636,20 @@ nsTableEncoderSupport::~nsTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
@@ -673,6 +693,20 @@ nsMultiTableEncoderSupport::~nsMultiTableEncoderSupport()
|
||||
NS_IF_RELEASE(mHelper);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMultiTableEncoderSupport::FillInfo(PRUint32 *aInfo)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
if (mHelper == nsnull) {
|
||||
res = nsComponentManager::CreateInstance(kUnicodeEncodeHelperCID, NULL,
|
||||
kIUnicodeEncodeHelperIID, (void**) & mHelper);
|
||||
|
||||
if (NS_FAILED(res)) return NS_ERROR_UENC_NOHELPER;
|
||||
}
|
||||
|
||||
res = mHelper->FillInfo(aInfo,mTableCount, mMappingTable);
|
||||
return res;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsEncoderSupport class [implementation]
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIUnicodeEncodeHelper.h"
|
||||
#include "nsIUnicodeDecodeHelper.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
|
||||
#define ONE_BYTE_TABLE_SIZE 256
|
||||
|
||||
@@ -264,7 +265,7 @@ protected:
|
||||
* @created 17/Feb/1999
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder
|
||||
class nsEncoderSupport : public nsIUnicodeEncoder, public nsICharRepresentable
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
@@ -330,6 +331,10 @@ public:
|
||||
NS_IMETHOD Reset();
|
||||
NS_IMETHOD SetOutputErrorBehavior(PRInt32 aBehavior,
|
||||
nsIUnicharEncoder * aEncoder, PRUnichar aChar);
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
// Interface nsICharRepresentable [declaration]
|
||||
NS_IMETHOD FillInfo(PRUint32 *aInfo) = 0;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -355,6 +360,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -392,6 +398,7 @@ public:
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsMultiTableEncoderSupport();
|
||||
NS_IMETHOD FillInfo( PRUint32 *aInfo);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -43,8 +43,12 @@ nsUnicodeToEUCTW::nsUnicodeToEUCTW()
|
||||
|
||||
nsresult nsUnicodeToEUCTW::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsUnicodeToEUCTW();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToEUCTW();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
@@ -65,6 +65,9 @@ public:
|
||||
NS_IMETHOD CreateCache(nsMappingCacheType aType, nsIMappingCache* aResult);
|
||||
|
||||
NS_IMETHOD DestroyCache(nsIMappingCache aCache);
|
||||
|
||||
NS_IMETHOD FillInfo(PRUint32* aInfo, uMappingTable * aMappingTable);
|
||||
NS_IMETHOD FillInfo(PRUint32* aInfo, PRInt32 aTableCount, uMappingTable ** aMappingTable);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -180,6 +183,18 @@ NS_IMETHODIMP nsUnicodeEncodeHelper::DestroyCache(nsIMappingCache aCache)
|
||||
{
|
||||
return nsMappingCache::DestroyCache(aCache);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::FillInfo(PRUint32 *aInfo, uMappingTable * aMappingTable)
|
||||
{
|
||||
uFillInfo((uTable*) aMappingTable, aInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::FillInfo(PRUint32 *aInfo, PRInt32 aTableCount, uMappingTable ** aMappingTable)
|
||||
{
|
||||
for (PRInt32 i=0; i<aTableCount; i++)
|
||||
uFillInfo((uTable*) aMappingTable[i], aInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsEncodeHelperFactory [implementation]
|
||||
|
||||
|
||||
@@ -21,14 +21,17 @@
|
||||
|
||||
typedef PRUint16 (* MapFormatFunc)(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
||||
typedef PRBool (* HitFormateFunc)(PRUint16 in,const uMapCell *cell);
|
||||
typedef void (* FillInfoFormateFunc)(const uTable *uT, const uMapCell *cell, PRUint32* info);
|
||||
|
||||
|
||||
PRIVATE PRBool uHitFormate0(PRUint16 in,const uMapCell *cell);
|
||||
PRIVATE PRBool uHitFormate1(PRUint16 in,const uMapCell *cell);
|
||||
PRIVATE PRBool uHitFormate2(PRUint16 in,const uMapCell *cell);
|
||||
PRIVATE PRUint16 uMapFormate0(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
||||
PRIVATE PRUint16 uMapFormate1(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
||||
PRIVATE PRUint16 uMapFormate2(PRUint16 in,const uTable *uT,const uMapCell *cell);
|
||||
PRIVATE void uFillInfoFormate0(const uTable *uT,const uMapCell *cell,PRUint32* aInfo);
|
||||
PRIVATE void uFillInfoFormate1(const uTable *uT,const uMapCell *cell,PRUint32* aInfo);
|
||||
PRIVATE void uFillInfoFormate2(const uTable *uT,const uMapCell *cell,PRUint32* aInfo);
|
||||
|
||||
|
||||
PRIVATE const uMapCell *uGetMapCell(const uTable *uT, PRInt16 item);
|
||||
@@ -47,23 +50,49 @@ PRIVATE const MapFormatFunc m_map[uNumFormatTag] =
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE const FillInfoFormateFunc m_fillinfo[uNumFormatTag] =
|
||||
{
|
||||
uFillInfoFormate0,
|
||||
uFillInfoFormate1,
|
||||
uFillInfoFormate2,
|
||||
};
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE const HitFormateFunc m_hit[uNumFormatTag] =
|
||||
{
|
||||
uHitFormate0,
|
||||
uHitFormate1,
|
||||
uHitFormate0,
|
||||
uHitFormate2,
|
||||
};
|
||||
|
||||
#define uHit(format,in,cell) (* m_hit[(format)])((in),(cell))
|
||||
#define uMap(format,in,uT,cell) (* m_map[(format)])((in),(uT),(cell))
|
||||
#define uFillInfoCell(format,uT,cell,info) (* m_fillinfo[(format)])((uT),(cell),(info))
|
||||
#define uGetMapCell(uT, item) ((uMapCell *)(((PRUint16 *)uT) + (uT)->offsetToMapCellArray) + (item))
|
||||
#define uGetFormat(uT, item) (((((PRUint16 *)uT) + (uT)->offsetToFormatArray)[(item)>> 2 ] >> (((item)% 4 ) << 2)) & 0x0f)
|
||||
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
MODULE_PRIVATE PRBool uMapCode(uTable *uT, PRUint16 in, PRUint16* out)
|
||||
MODULE_PRIVATE void uFillInfo(const uTable *uT, PRUint32* aInfo)
|
||||
{
|
||||
PRUint16 itemOfList = uT->itemOfList;
|
||||
PRUint16 i;
|
||||
for(i=0;i<itemOfList;i++)
|
||||
{
|
||||
const uMapCell* uCell;
|
||||
PRInt8 format = uGetFormat(uT,i);
|
||||
uCell = uGetMapCell(uT,i);
|
||||
uFillInfoCell(format, uT, uCell, aInfo);
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
MODULE_PRIVATE PRBool uMapCode(const uTable *uT, PRUint16 in, PRUint16* out)
|
||||
{
|
||||
PRBool done = PR_FALSE;
|
||||
PRUint16 itemOfList = uT->itemOfList;
|
||||
@@ -98,13 +127,6 @@ PRIVATE PRBool uHitFormate0(PRUint16 in,const uMapCell *cell)
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uHitFormate1(PRUint16 in,const uMapCell *cell)
|
||||
{
|
||||
return uHitFormate0(in,cell);
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE PRBool uHitFormate2(PRUint16 in,const uMapCell *cell)
|
||||
{
|
||||
@@ -133,3 +155,49 @@ PRIVATE PRUint16 uMapFormate2(PRUint16 in,const uTable *uT,const uMapCell *cell)
|
||||
return (cell->fmt.format2.destBegin);
|
||||
}
|
||||
|
||||
#define SET_REPRESENTABLE(info, c) (info)[(c) >> 5] |= (1L << ((c) & 0x1f))
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE void uFillInfoFormate0(const uTable *uT,const uMapCell *cell,PRUint32* info)
|
||||
{
|
||||
PRUint16 begin, end, i;
|
||||
begin = cell->fmt.format0.srcBegin;
|
||||
end = cell->fmt.format0.srcEnd;
|
||||
if( (begin >> 5) == (end >> 5)) // High 17 bits are the same
|
||||
{
|
||||
for(i = begin; i <= end; i++)
|
||||
SET_REPRESENTABLE(info, i);
|
||||
} else {
|
||||
PRUint32 b = begin >> 5;
|
||||
PRUint32 e = end >> 5;
|
||||
info[ b ] |= (0xFFFFFFFFL << ((begin) & 0x1f));
|
||||
info[ e ] |= (0xFFFFFFFFL >> (31 - ((end) & 0x1f)));
|
||||
for(b++ ; b < e ; b++)
|
||||
info[b] |= 0xFFFFFFFFL;
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE void uFillInfoFormate1(const uTable *uT,const uMapCell *cell,PRUint32* info)
|
||||
{
|
||||
PRUint16 begin, end, i;
|
||||
PRUint16 *base;
|
||||
begin = cell->fmt.format0.srcBegin;
|
||||
end = cell->fmt.format0.srcEnd;
|
||||
base = (((PRUint16 *)uT) + uT->offsetToMappingTable + cell->fmt.format1.mappingOffset);
|
||||
for(i = begin; i <= end; i++)
|
||||
{
|
||||
if(0xFFFD != base[i - begin]) /* check every item */
|
||||
SET_REPRESENTABLE(info, i);
|
||||
}
|
||||
}
|
||||
/*=================================================================================
|
||||
|
||||
=================================================================================*/
|
||||
PRIVATE void uFillInfoFormate2(const uTable *uT,const uMapCell *cell,PRUint32* info)
|
||||
{
|
||||
SET_REPRESENTABLE(info, cell->fmt.format2.srcBegin);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,10 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PRBool uMapCode( uTable *uT,
|
||||
void uFillInfo(const uTable *uT,
|
||||
PRUint32 *info);
|
||||
|
||||
PRBool uMapCode(const uTable *uT,
|
||||
PRUint16 in,
|
||||
PRUint16* out);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user