From db8fc5447874a1e5da2366091a62a19b4d7aa8f7 Mon Sep 17 00:00:00 2001 From: "cata%netscape.com" Date: Mon, 19 Apr 1999 20:26:26 +0000 Subject: [PATCH] Method renamed for clarity. --- intl/uconv/public/nsIUnicodeDecodeHelper.h | 26 ++++- intl/uconv/public/nsIUnicodeEncodeHelper.h | 9 ++ intl/uconv/src/nsUnicodeDecodeHelper.cpp | 106 ++++++++++++++++++--- intl/uconv/src/nsUnicodeEncodeHelper.cpp | 33 +++++-- intl/uconv/util/nsUnicodeDecodeHelper.cpp | 106 ++++++++++++++++++--- intl/uconv/util/nsUnicodeEncodeHelper.cpp | 33 +++++-- 6 files changed, 269 insertions(+), 44 deletions(-) diff --git a/intl/uconv/public/nsIUnicodeDecodeHelper.h b/intl/uconv/public/nsIUnicodeDecodeHelper.h index d896f37dae31..fc8837ec1b36 100644 --- a/intl/uconv/public/nsIUnicodeDecodeHelper.h +++ b/intl/uconv/public/nsIUnicodeDecodeHelper.h @@ -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___ */ diff --git a/intl/uconv/public/nsIUnicodeEncodeHelper.h b/intl/uconv/public/nsIUnicodeEncodeHelper.h index 60c93b7bb91e..14ca54ad6b01 100644 --- a/intl/uconv/public/nsIUnicodeEncodeHelper.h +++ b/intl/uconv/public/nsIUnicodeEncodeHelper.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; }; diff --git a/intl/uconv/src/nsUnicodeDecodeHelper.cpp b/intl/uconv/src/nsUnicodeDecodeHelper.cpp index f3b54545bdc9..8d41a2544347 100644 --- a/intl/uconv/src/nsUnicodeDecodeHelper.cpp +++ b/intl/uconv/src/nsUnicodeDecodeHelper.cpp @@ -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 *aDestLength) { + srcEnd += (*aDestLength); + res = NS_PARTIAL_MORE_OUTPUT; + } else { + srcEnd += (*aSrcLength); + res = NS_OK; + } + + for (; src