зеркало из https://github.com/mozilla/gecko-dev.git
Method renamed for clarity.
This commit is contained in:
Родитель
d3f42df326
Коммит
db8fc54478
|
@ -59,13 +59,35 @@ public:
|
|||
|
||||
/**
|
||||
* Converts data using a set of lookup tables.
|
||||
*
|
||||
* XXX deprecated
|
||||
*/
|
||||
NS_IMETHOD ConvertByTables(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uRange * aRangeArray, uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable) = 0;
|
||||
|
||||
/**
|
||||
* Converts data using a set of lookup tables.
|
||||
*/
|
||||
NS_IMETHOD ConvertByMultiTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uRange * aRangeArray, uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable) = 0;
|
||||
|
||||
/**
|
||||
* Converts data using a fast lookup table.
|
||||
*/
|
||||
NS_IMETHOD ConvertByFastTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize) = 0;
|
||||
|
||||
/**
|
||||
* Create a cache-like fast lookup table from a normal one.
|
||||
*/
|
||||
NS_IMETHOD CreateFastTable( uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* nsIUnicodeDecodeHelper_h___ */
|
||||
|
|
|
@ -59,10 +59,19 @@ public:
|
|||
|
||||
/**
|
||||
* Converts data using a set of lookup tables.
|
||||
*
|
||||
* XXX deprecated
|
||||
*/
|
||||
NS_IMETHOD ConvertByTables(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable) = 0;
|
||||
|
||||
/**
|
||||
* Converts data using a set of lookup tables.
|
||||
*/
|
||||
NS_IMETHOD ConvertByMultiTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -60,6 +60,19 @@ public:
|
|||
PRUnichar * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uRange * aRangeArray, uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByMultiTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uRange * aRangeArray, uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByFastTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize);
|
||||
|
||||
NS_IMETHOD CreateFastTable( uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -81,12 +94,13 @@ nsUnicodeDecodeHelper::~nsUnicodeDecodeHelper()
|
|||
//----------------------------------------------------------------------
|
||||
// Interface nsIUnicodeDecodeHelper [implementation]
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTable(const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable)
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTable(
|
||||
const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable)
|
||||
{
|
||||
const char * src = aSrc;
|
||||
PRInt32 srcLen = *aSrcLength;
|
||||
|
@ -126,14 +140,30 @@ NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTable(const char * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTables(const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uRange * aRangeArray,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTables(
|
||||
const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uRange * aRangeArray,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
// XXX deprecated
|
||||
return ConvertByMultiTable(aSrc, aSrcLength, aDest, aDestLength,
|
||||
aTableCount, aRangeArray, aShiftTable, aMappingTable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByMultiTable(
|
||||
const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uRange * aRangeArray,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
PRUint8 * src = (PRUint8 *)aSrc;
|
||||
PRInt32 srcLen = *aSrcLength;
|
||||
|
@ -183,6 +213,54 @@ NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTables(const char * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByFastTable(
|
||||
const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize)
|
||||
{
|
||||
PRUint8 * src = (PRUint8 *)aSrc;
|
||||
PRUint8 * srcEnd = src;
|
||||
PRUnichar * dest = aDest;
|
||||
|
||||
nsresult res;
|
||||
if (*aSrcLength > *aDestLength) {
|
||||
srcEnd += (*aDestLength);
|
||||
res = NS_PARTIAL_MORE_OUTPUT;
|
||||
} else {
|
||||
srcEnd += (*aSrcLength);
|
||||
res = NS_OK;
|
||||
}
|
||||
|
||||
for (; src<srcEnd;) *dest++ = aFastTable[*src++];
|
||||
|
||||
*aSrcLength = src - (PRUint8 *)aSrc;
|
||||
*aDestLength = dest - aDest;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::CreateFastTable(
|
||||
uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable,
|
||||
PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize)
|
||||
{
|
||||
PRInt32 tableSize = aTableSize;
|
||||
PRInt32 buffSize = aTableSize;
|
||||
char * buff = new char [buffSize];
|
||||
if (buff == NULL) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
char * p = buff;
|
||||
for (PRInt32 i=0; i<aTableSize; i++) *(p++) = i;
|
||||
nsresult res = ConvertByTable(buff, &buffSize, aFastTable, &tableSize,
|
||||
aShiftTable, aMappingTable);
|
||||
|
||||
delete [] buff;
|
||||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsDecodeHelperFactory [implementation]
|
||||
|
||||
|
|
|
@ -59,6 +59,10 @@ public:
|
|||
NS_IMETHOD ConvertByTables(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByMultiTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -118,13 +122,28 @@ NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTable(const PRUnichar * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTables(const PRUnichar * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
char * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTables(
|
||||
const PRUnichar * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
char * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
// XXX deprecated
|
||||
return ConvertByMultiTable(aSrc, aSrcLength, aDest, aDestLength, aTableCount,
|
||||
aShiftTable, aMappingTable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByMultiTable(
|
||||
const PRUnichar * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
char * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
const PRUnichar * src = aSrc;
|
||||
const PRUnichar * srcEnd = aSrc + *aSrcLength;
|
||||
|
|
|
@ -60,6 +60,19 @@ public:
|
|||
PRUnichar * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uRange * aRangeArray, uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByMultiTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uRange * aRangeArray, uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByFastTable(const char * aSrc, PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest, PRInt32 * aDestLength, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize);
|
||||
|
||||
NS_IMETHOD CreateFastTable( uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable, PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -81,12 +94,13 @@ nsUnicodeDecodeHelper::~nsUnicodeDecodeHelper()
|
|||
//----------------------------------------------------------------------
|
||||
// Interface nsIUnicodeDecodeHelper [implementation]
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTable(const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable)
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTable(
|
||||
const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable)
|
||||
{
|
||||
const char * src = aSrc;
|
||||
PRInt32 srcLen = *aSrcLength;
|
||||
|
@ -126,14 +140,30 @@ NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTable(const char * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTables(const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uRange * aRangeArray,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTables(
|
||||
const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uRange * aRangeArray,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
// XXX deprecated
|
||||
return ConvertByMultiTable(aSrc, aSrcLength, aDest, aDestLength,
|
||||
aTableCount, aRangeArray, aShiftTable, aMappingTable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByMultiTable(
|
||||
const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uRange * aRangeArray,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
PRUint8 * src = (PRUint8 *)aSrc;
|
||||
PRInt32 srcLen = *aSrcLength;
|
||||
|
@ -183,6 +213,54 @@ NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByTables(const char * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::ConvertByFastTable(
|
||||
const char * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
PRUnichar * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize)
|
||||
{
|
||||
PRUint8 * src = (PRUint8 *)aSrc;
|
||||
PRUint8 * srcEnd = src;
|
||||
PRUnichar * dest = aDest;
|
||||
|
||||
nsresult res;
|
||||
if (*aSrcLength > *aDestLength) {
|
||||
srcEnd += (*aDestLength);
|
||||
res = NS_PARTIAL_MORE_OUTPUT;
|
||||
} else {
|
||||
srcEnd += (*aSrcLength);
|
||||
res = NS_OK;
|
||||
}
|
||||
|
||||
for (; src<srcEnd;) *dest++ = aFastTable[*src++];
|
||||
|
||||
*aSrcLength = src - (PRUint8 *)aSrc;
|
||||
*aDestLength = dest - aDest;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeDecodeHelper::CreateFastTable(
|
||||
uShiftTable * aShiftTable,
|
||||
uMappingTable * aMappingTable,
|
||||
PRUnichar * aFastTable,
|
||||
PRInt32 aTableSize)
|
||||
{
|
||||
PRInt32 tableSize = aTableSize;
|
||||
PRInt32 buffSize = aTableSize;
|
||||
char * buff = new char [buffSize];
|
||||
if (buff == NULL) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
char * p = buff;
|
||||
for (PRInt32 i=0; i<aTableSize; i++) *(p++) = i;
|
||||
nsresult res = ConvertByTable(buff, &buffSize, aFastTable, &tableSize,
|
||||
aShiftTable, aMappingTable);
|
||||
|
||||
delete [] buff;
|
||||
return res;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsDecodeHelperFactory [implementation]
|
||||
|
||||
|
|
|
@ -59,6 +59,10 @@ public:
|
|||
NS_IMETHOD ConvertByTables(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable);
|
||||
|
||||
NS_IMETHOD ConvertByMultiTable(const PRUnichar * aSrc, PRInt32 * aSrcLength,
|
||||
char * aDest, PRInt32 * aDestLength, PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable, uMappingTable ** aMappingTable);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
@ -118,13 +122,28 @@ NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTable(const PRUnichar * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTables(const PRUnichar * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
char * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByTables(
|
||||
const PRUnichar * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
char * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
// XXX deprecated
|
||||
return ConvertByMultiTable(aSrc, aSrcLength, aDest, aDestLength, aTableCount,
|
||||
aShiftTable, aMappingTable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsUnicodeEncodeHelper::ConvertByMultiTable(
|
||||
const PRUnichar * aSrc,
|
||||
PRInt32 * aSrcLength,
|
||||
char * aDest,
|
||||
PRInt32 * aDestLength,
|
||||
PRInt32 aTableCount,
|
||||
uShiftTable ** aShiftTable,
|
||||
uMappingTable ** aMappingTable)
|
||||
{
|
||||
const PRUnichar * src = aSrc;
|
||||
const PRUnichar * srcEnd = aSrc + *aSrcLength;
|
||||
|
|
Загрузка…
Ссылка в новой задаче