gecko/intl/uconv/ucvcn/nsISO2022CNToUnicode.h
Ehsan Akhgari 0fd9123eac Bug 579517 - Part 1: Automated conversion of NSPR numeric types to stdint types in Gecko; r=bsmedberg
This patch was generated by a script.  Here's the source of the script for
future reference:

function convert() {
echo "Converting $1 to $2..."
find . ! -wholename "*nsprpub*" \
       ! -wholename "*security/nss*" \
       ! -wholename "*/.hg*" \
       ! -wholename "obj-ff-dbg*" \
       ! -name nsXPCOMCID.h \
       ! -name prtypes.h \
         -type f \
      \( -iname "*.cpp" \
         -o -iname "*.h" \
         -o -iname "*.c" \
         -o -iname "*.cc" \
         -o -iname "*.idl" \
         -o -iname "*.ipdl" \
         -o -iname "*.ipdlh" \
         -o -iname "*.mm" \) | \
    xargs -n 1 sed -i -e "s/\b$1\b/$2/g"
}

convert PRInt8 int8_t
convert PRUint8 uint8_t
convert PRInt16 int16_t
convert PRUint16 uint16_t
convert PRInt32 int32_t
convert PRUint32 uint32_t
convert PRInt64 int64_t
convert PRUint64 uint64_t

convert PRIntn int
convert PRUintn unsigned

convert PRSize size_t

convert PROffset32 int32_t
convert PROffset64 int64_t

convert PRPtrdiff ptrdiff_t

convert PRFloat64 double
2012-08-22 11:56:38 -04:00

104 lines
3.2 KiB
C++

/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsISO2022CNToUnicode_h__
#define nsISO2022CNToUnicode_h__
#include "nsCOMPtr.h"
#include "nsISupports.h"
#include "nsUCSupport.h"
#define MBYTE 0x8e
#undef PMASK
#define PMASK 0xa0
#define SI 0x0f
#define SO 0x0e
#define ESC 0x1b
#define SS2 0x4e
#define SS3 0x4f
class nsISO2022CNToUnicode : public nsBasicDecoderSupport
{
public:
nsISO2022CNToUnicode() :
mState(eState_ASCII),
mPlaneID(0),
mRunLength(0) { }
virtual ~nsISO2022CNToUnicode() {}
NS_IMETHOD Convert(const char *aSrc, int32_t * aSrcLength,
PRUnichar * aDest, int32_t * aDestLength) ;
NS_IMETHOD GetMaxLength(const char * aSrc, int32_t aSrcLength,
int32_t * aDestLength)
{
*aDestLength = aSrcLength;
return NS_OK;
}
NS_IMETHOD Reset()
{
mState = eState_ASCII;
mPlaneID = 0;
mRunLength = 0;
return NS_OK;
}
private:
// State Machine ID
enum {
eState_ASCII,
eState_ESC, // ESC
eState_ESC_24, // ESC $
eState_ESC_24_29, // ESC $ )
eState_ESC_24_29_A, // ESC $ ) A
eState_GB2312_1980, // ESC $ ) A SO
eState_GB2312_1980_2ndbyte, // ESC $ ) A SO
eState_ESC_24_29_A_SO_SI, // ESC $ ) A SO SI
eState_ESC_24_29_G, // ESC $ ) G or H
eState_CNS11643_1, // ESC $ ) G SO
eState_CNS11643_1_2ndbyte, // ESC $ ) G SO
eState_ESC_24_29_G_SO_SI, // ESC $ ) G SO SI
eState_ESC_24_2A, // ESC $ *
eState_ESC_24_2A_H, // ESC $ * H
eState_ESC_24_2A_H_ESC, // ESC $ * H ESC
eState_CNS11643_2, // ESC $ * H ESC SS2
eState_CNS11643_2_2ndbyte, // ESC $ * H ESC SS2
eState_ESC_24_2A_H_ESC_SS2_SI, // ESC $ * H ESC SS2 SI
eState_ESC_24_2A_H_ESC_SS2_SI_ESC, // ESC $ * H ESC SS2 SI ESC
eState_ESC_24_2B, // ESC $ +
eState_ESC_24_2B_I, // ESC $ + I
eState_ESC_24_2B_I_ESC, // ESC $ + I ESC
eState_CNS11643_3, // ESC $ + I ESC SS3
eState_CNS11643_3_2ndbyte, // ESC $ + I ESC SS3
eState_ESC_24_2B_I_ESC_SS3_SI, // ESC $ + I ESC SI
eState_ESC_24_2B_I_ESC_SS3_SI_ESC, // ESC $ + I ESC SI ESC
eState_ERROR
} mState;
char mData;
// Plane number for CNS11643 code
int mPlaneID;
// Length of non-ASCII run
uint32_t mRunLength;
// Decoder handler
nsCOMPtr<nsIUnicodeDecoder> mGB2312_Decoder;
nsCOMPtr<nsIUnicodeDecoder> mEUCTW_Decoder;
NS_IMETHOD GB2312_To_Unicode(unsigned char *aSrc, int32_t aSrcLength,
PRUnichar * aDest, int32_t * aDestLength) ;
NS_IMETHOD EUCTW_To_Unicode(unsigned char *aSrc, int32_t aSrcLength,
PRUnichar * aDest, int32_t * aDestLength) ;
};
#endif // nsISO2022CNToUnicode_h__