зеркало из https://github.com/mozilla/pjs.git
Fixed 22921; nsIModule code. /r=valeski /sr=ftang
This commit is contained in:
Родитель
7edc5ec6cf
Коммит
e2fcbd14cc
|
@ -19,3 +19,11 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
/**
|
||||
* A character set converter from CP936 to Unicode.
|
||||
*
|
||||
*
|
||||
* @created 07/Sept/1999
|
||||
* @author Yueheng Xu, Yueheng.Xu@intel.com
|
||||
*/
|
||||
|
||||
|
|
|
@ -19,3 +19,31 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsCP936ToUnicode_h___
|
||||
#define nsCP936ToUnicode_h___
|
||||
|
||||
#include "nsUCvCnSupport.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsCP936ToUnicode [declaration]
|
||||
|
||||
/**
|
||||
* A character set converter from CP936 to Unicode.
|
||||
*
|
||||
*
|
||||
* @created 07/Sept/1999
|
||||
* @author Yueheng Xu, Yueheng.Xu@intel.com
|
||||
*/
|
||||
class nsCP936ToUnicode : public nsGBKToUnicode
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
nsCP936ToUnicode(){};
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsCP936ToUnicode_h___ */
|
||||
|
||||
|
|
|
@ -63,12 +63,6 @@ nsGB2312ToUnicode::nsGB2312ToUnicode()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsGB2312ToUnicode::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsGB2312ToUnicode();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTablesDecoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -43,11 +43,6 @@ public:
|
|||
*/
|
||||
nsGB2312ToUnicode();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -45,12 +45,6 @@
|
|||
//----------------------------------------------------------------------
|
||||
// Class nsGB2312ToUnicodeV2 [implementation]
|
||||
|
||||
nsresult nsGB2312ToUnicodeV2::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsGB2312ToUnicodeV2();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTablesDecoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -42,12 +42,6 @@ public:
|
|||
* Class constructor.
|
||||
*/
|
||||
nsGB2312ToUnicodeV2(){};
|
||||
virtual ~nsGB2312ToUnicodeV2(){};
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -34,12 +34,6 @@
|
|||
//----------------------------------------------------------------------
|
||||
// Class nsGBKToUnicode [implementation]
|
||||
|
||||
nsresult nsGBKToUnicode::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsGBKToUnicode();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTablesDecoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsGBKToUnicode_h___
|
||||
#define nsGBKToUnicode_h___
|
||||
#ifndef nsGBK2312ToUnicode_h___
|
||||
#define nsGBK2312ToUnicode_h___
|
||||
|
||||
#include "nsUCvCnSupport.h"
|
||||
|
||||
|
@ -42,12 +42,6 @@ public:
|
|||
* Class constructor.
|
||||
*/
|
||||
nsGBKToUnicode(){};
|
||||
virtual ~nsGBKToUnicode(){};
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -73,5 +67,5 @@ private:
|
|||
|
||||
};
|
||||
|
||||
#endif /* nsGBKToUnicode_h___ */
|
||||
#endif /* nsGBK2312ToUnicode_h___ */
|
||||
|
||||
|
|
|
@ -55,12 +55,6 @@
|
|||
//----------------------------------------------------------------------
|
||||
// Class nsHZToUnicode [implementation]
|
||||
|
||||
nsresult nsHZToUnicode::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
*aResult = new nsHZToUnicode();
|
||||
return (*aResult == NULL)? NS_ERROR_OUT_OF_MEMORY : NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTablesDecoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -43,13 +43,6 @@ public:
|
|||
* Class constructor.
|
||||
*/
|
||||
nsHZToUnicode(){};
|
||||
virtual ~nsHZToUnicode(){};
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -25,62 +25,80 @@
|
|||
|
||||
#include "nsISupports.h"
|
||||
|
||||
// Class ID for our GB2312ToUnicode charset converter
|
||||
// {379C2774-EC77-11d2-8AAC-00600811A836}
|
||||
// Class ID for our GB2312ToUnicode charset converter// {379C2774-EC77-11d2-8AAC-00600811A836}
|
||||
NS_DECLARE_ID(kGB2312ToUnicodeCID,
|
||||
0x379c2774, 0xec77, 0x11d2, 0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36);
|
||||
#define NS_GB2312TOUNICODE_CID \
|
||||
{ 0x379c2774, 0xec77, 0x11d2, {0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36}}
|
||||
|
||||
// Class ID for our ISO2022CNToUnicode charset converter
|
||||
// {BA615199-1DFA-11d3-B3BF-00805F8A6670}
|
||||
NS_DECLARE_ID(kISO2022CNToUnicodeCID,
|
||||
0xba615199, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
0xba615199, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
#define NS_ISO2022CNTOUNICODE_CID \
|
||||
{ 0xba615199, 0x1dfa, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
|
||||
|
||||
// Class ID for our HZToUnicode charset converter
|
||||
// {BA61519A-1DFA-11d3-B3BF-00805F8A6670}
|
||||
NS_DECLARE_ID(kHZToUnicodeCID,
|
||||
0xba61519a, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
0xba61519a, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
#define NS_HZTOUNICODE_CID \
|
||||
{ 0xba61519a, 0x1dfa, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
|
||||
|
||||
// Class ID for our GBKToUnicode charset converter
|
||||
// {BA61519E-1DFA-11d3-B3BF-00805F8A6670}
|
||||
NS_DECLARE_ID(kGBKToUnicodeCID,
|
||||
0xba61519e, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
|
||||
0xba61519e, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
#define NS_GBKTOUNICODE_CID \
|
||||
{ 0xba61519e, 0x1dfa, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
|
||||
|
||||
// Class ID for our UnicodeToGB2312 charset converter
|
||||
// {379C2777-EC77-11d2-8AAC-00600811A836}
|
||||
NS_DECLARE_ID(kUnicodeToGB2312CID,
|
||||
0x379c2777, 0xec77, 0x11d2, 0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36);
|
||||
#define NS_UNICODETOGB2312_CID \
|
||||
{ 0x379c2777, 0xec77, 0x11d2, {0x8a, 0xac, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36}}
|
||||
|
||||
// Class ID for our UnicodeToGB2312GL charset converter
|
||||
// {BA615196-1DFA-11d3-B3BF-00805F8A6670}
|
||||
NS_DECLARE_ID(kUnicodeToGB2312GLCID,
|
||||
0xba615196, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
0xba615196, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
#define NS_UNICODETOGB2312GL_CID \
|
||||
{ 0xba615196, 0x1dfa, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
|
||||
|
||||
// Class ID for our UnicodeToGBK charset converter
|
||||
// {BA61519B-1DFA-11d3-B3BF-00805F8A6670}
|
||||
NS_DECLARE_ID(kUnicodeToGBKCID,
|
||||
0xba61519b, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
0xba61519b, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
#define NS_UNICODETOGBK_CID \
|
||||
{ 0xba61519b, 0x1dfa, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
|
||||
|
||||
// Class ID for our UnicodeToISO2022CN charset converter
|
||||
// {BA61519C-1DFA-11d3-B3BF-00805F8A6670}
|
||||
NS_DECLARE_ID(kUnicodeToISO2022CNCID,
|
||||
0xba61519c, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
0xba61519c, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
#define NS_UNICODETOISO2022CN_CID \
|
||||
{ 0xba61519c, 0x1dfa, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
|
||||
|
||||
// Class ID for our UnicodeToHZ charset converter
|
||||
// {BA61519D-1DFA-11d3-B3BF-00805F8A6670}
|
||||
NS_DECLARE_ID(kUnicodeToHZCID,
|
||||
0xba61519d, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
0xba61519d, 0x1dfa, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
#define NS_UNICODETOHZ_CID \
|
||||
{ 0xba61519d, 0x1dfa, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
|
||||
|
||||
// Class ID for our CP936ToUnicode charset converter
|
||||
NS_DECLARE_ID(kCP936ToUnicodeCID,
|
||||
// {9416BFC0-1F93-11d3-B3BF-00805F8A6670}
|
||||
0x9416bfc0, 0x1f93, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
|
||||
0x9416bfc0, 0x1f93, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
#define NS_CP936TOUNICODE_CID \
|
||||
{ 0x9416bfc0, 0x1f93, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
|
||||
|
||||
// Class ID for our UnicodeToCP936 charset converter
|
||||
NS_DECLARE_ID(kUnicodeToCP936CID,
|
||||
// {9416BFC1-1F93-11d3-B3BF-00805F8A6670}
|
||||
0x9416bfc1, 0x1f93, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
|
||||
0x9416bfc1, 0x1f93, 0x11d3, 0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70);
|
||||
#define NS_UNICODETOCP936_CID \
|
||||
{ 0x9416bfc1, 0x1f93, 0x11d3, {0xb3, 0xbf, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0x70}}
|
||||
|
||||
#endif /* nsUCvCnCID_h___ */
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
#include "nsCOMPtr.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIRegistry.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsIModule.h"
|
||||
#include "nsUCvCnCID.h"
|
||||
#include "nsUCvCnDll.h"
|
||||
|
@ -38,6 +40,8 @@
|
|||
#include "nsUnicodeToHZ.h"
|
||||
#include "nsGBKToUnicode.h"
|
||||
#include "nsUnicodeToGBK.h"
|
||||
#include "nsCP936ToUnicode.h"
|
||||
#include "nsUnicodeToCP936.h"
|
||||
#include "nsGB2312ToUnicodeV2.h"
|
||||
#include "nsUnicodeToGB2312V2.h"
|
||||
#include "nsGB2312ToUnicode.h"
|
||||
|
@ -67,370 +71,85 @@ PRUint16 g_ufGB2312Mapping[] = {
|
|||
#include "gb2312.uf"
|
||||
};
|
||||
|
||||
typedef nsresult (* fpCreateInstance) (nsISupports **);
|
||||
NS_IMPL_NSUCONVERTERREGSELF
|
||||
|
||||
struct FactoryData
|
||||
{
|
||||
const nsCID * mCID;
|
||||
fpCreateInstance CreateInstance;
|
||||
char * mCharsetSrc;
|
||||
char * mCharsetDest;
|
||||
};
|
||||
NS_UCONV_REG_UNREG(nsGB2312ToUnicodeV2, "GB2312", "Unicode" , NS_GB2312TOUNICODE_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToGB2312V2, "Unicode", "GB2312", NS_UNICODETOGB2312_CID);
|
||||
NS_UCONV_REG_UNREG(nsCP936ToUnicode, "windows-936", "Unicode" , NS_CP936TOUNICODE_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToCP936, "Unicode", "windows-936", NS_UNICODETOCP936_CID);
|
||||
NS_UCONV_REG_UNREG(nsGBKToUnicode, "x-gbk", "Unicode" , NS_GBKTOUNICODE_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToGBK, "Unicode", "x-gbk", NS_UNICODETOGBK_CID);
|
||||
NS_UCONV_REG_UNREG(nsHZToUnicode, "HZ-GB-2312", "Unicode" , NS_HZTOUNICODE_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToHZ, "Unicode", "HZ-GB-2312", NS_UNICODETOHZ_CID);
|
||||
NS_UCONV_REG_UNREG(nsUnicodeToGB2312GL, "Unicode", "gb_2312-80", NS_UNICODETOGB2312GL_CID);
|
||||
|
||||
static FactoryData g_FactoryData[] =
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsGB2312ToUnicodeV2);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToGB2312V2);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsCP936ToUnicode);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToCP936);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsGBKToUnicode);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToGBK);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHZToUnicode);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToHZ);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUnicodeToGB2312GL);
|
||||
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
&kGB2312ToUnicodeCID,
|
||||
nsGBKToUnicode::CreateInstance,
|
||||
"GB2312",
|
||||
"Unicode"
|
||||
{
|
||||
DECODER_NAME_BASE "GB2312" , NS_GB2312TOUNICODE_CID,
|
||||
NS_UNICODEDECODER_CONTRACTID_BASE "GB2312",
|
||||
nsGB2312ToUnicodeV2Constructor ,
|
||||
nsGB2312ToUnicodeV2RegSelf , nsGB2312ToUnicodeV2UnRegSelf
|
||||
},
|
||||
{
|
||||
&kUnicodeToGB2312CID,
|
||||
nsUnicodeToGB2312V2::CreateInstance,
|
||||
"Unicode",
|
||||
"GB2312"
|
||||
{
|
||||
ENCODER_NAME_BASE "GB2312" , NS_UNICODETOGB2312_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "GB2312",
|
||||
nsUnicodeToGB2312V2Constructor,
|
||||
nsUnicodeToGB2312V2RegSelf, nsUnicodeToGB2312V2UnRegSelf
|
||||
},
|
||||
{
|
||||
&kCP936ToUnicodeCID,
|
||||
nsGBKToUnicode::CreateInstance,
|
||||
"windows-936",
|
||||
"Unicode"
|
||||
{
|
||||
DECODER_NAME_BASE "windows-936" , NS_CP936TOUNICODE_CID,
|
||||
NS_UNICODEDECODER_CONTRACTID_BASE "windows-936",
|
||||
nsCP936ToUnicodeConstructor ,
|
||||
nsCP936ToUnicodeRegSelf , nsCP936ToUnicodeUnRegSelf
|
||||
},
|
||||
{
|
||||
&kUnicodeToCP936CID,
|
||||
nsUnicodeToGB2312V2::CreateInstance,
|
||||
"Unicode",
|
||||
"windows-936"
|
||||
{
|
||||
ENCODER_NAME_BASE "windows-936" , NS_UNICODETOCP936_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "windows-936",
|
||||
nsUnicodeToCP936Constructor,
|
||||
nsUnicodeToCP936RegSelf, nsUnicodeToCP936UnRegSelf
|
||||
},
|
||||
{
|
||||
&kGBKToUnicodeCID,
|
||||
nsGBKToUnicode::CreateInstance,
|
||||
"x-gbk",
|
||||
"Unicode"
|
||||
{
|
||||
DECODER_NAME_BASE "x-gbk" , NS_GBKTOUNICODE_CID,
|
||||
NS_UNICODEDECODER_CONTRACTID_BASE "x-gbk",
|
||||
nsGBKToUnicodeConstructor ,
|
||||
nsGBKToUnicodeRegSelf , nsGBKToUnicodeUnRegSelf
|
||||
},
|
||||
{
|
||||
&kUnicodeToGBKCID,
|
||||
nsUnicodeToGBK::CreateInstance,
|
||||
"Unicode",
|
||||
"x-gbk"
|
||||
},
|
||||
{
|
||||
&kHZToUnicodeCID,
|
||||
nsHZToUnicode::CreateInstance,
|
||||
"HZ-GB-2312",
|
||||
"Unicode"
|
||||
},
|
||||
{
|
||||
&kUnicodeToHZCID,
|
||||
nsUnicodeToHZ::CreateInstance,
|
||||
"Unicode",
|
||||
"HZ-GB-2312"
|
||||
},
|
||||
{
|
||||
&kUnicodeToGB2312GLCID,
|
||||
nsUnicodeToGB2312GL::CreateInstance,
|
||||
"Unicode",
|
||||
"gb_2312-80"
|
||||
{
|
||||
ENCODER_NAME_BASE "x-gbk" , NS_UNICODETOGBK_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "x-gbk",
|
||||
nsUnicodeToGBKConstructor,
|
||||
nsUnicodeToGBKRegSelf, nsUnicodeToGBKUnRegSelf
|
||||
},
|
||||
{
|
||||
DECODER_NAME_BASE "HZ-GB-2312" , NS_HZTOUNICODE_CID,
|
||||
NS_UNICODEDECODER_CONTRACTID_BASE "HZ-GB-2312",
|
||||
nsHZToUnicodeConstructor ,
|
||||
nsHZToUnicodeRegSelf , nsHZToUnicodeUnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "HZ-GB-2312" , NS_UNICODETOHZ_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "HZ-GB-2312",
|
||||
nsUnicodeToHZConstructor,
|
||||
nsUnicodeToHZRegSelf, nsUnicodeToHZUnRegSelf
|
||||
},
|
||||
{
|
||||
ENCODER_NAME_BASE "gb_2312-80" , NS_UNICODETOGB2312GL_CID,
|
||||
NS_UNICODEENCODER_CONTRACTID_BASE "gb_2312-80",
|
||||
nsUnicodeToGB2312GLConstructor,
|
||||
nsUnicodeToGB2312GLRegSelf, nsUnicodeToGB2312GLUnRegSelf
|
||||
}
|
||||
};
|
||||
|
||||
#define ARRAY_SIZE(_array) \
|
||||
(sizeof(_array) / sizeof(_array[0]))
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsConverterFactory [declaration]
|
||||
|
||||
/**
|
||||
* General factory class for converter objects.
|
||||
*
|
||||
* @created 24/Feb/1998
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsConverterFactory : public nsIFactory
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
private:
|
||||
|
||||
FactoryData * mData;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
nsConverterFactory(FactoryData * aData);
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
*/
|
||||
virtual ~nsConverterFactory();
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Interface nsIFactory [declaration]
|
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aDelegate, const nsIID &aIID,
|
||||
void **aResult);
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsConverterModule [declaration]
|
||||
|
||||
class nsConverterModule : public nsIModule
|
||||
{
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMODULE
|
||||
|
||||
private:
|
||||
|
||||
PRBool mInitialized;
|
||||
|
||||
void Shutdown();
|
||||
|
||||
public:
|
||||
|
||||
nsConverterModule();
|
||||
|
||||
virtual ~nsConverterModule();
|
||||
|
||||
nsresult Initialize();
|
||||
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Global functions and data [implementation]
|
||||
|
||||
static nsConverterModule * gModule = NULL;
|
||||
|
||||
extern "C" NS_EXPORT nsresult NSGetModule(nsIComponentManager * compMgr,
|
||||
nsIFile* location,
|
||||
nsIModule** return_cobj)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
NS_ENSURE_ARG_POINTER(return_cobj);
|
||||
NS_ENSURE_FALSE(gModule, NS_ERROR_FAILURE);
|
||||
|
||||
// Create an initialize the module instance
|
||||
nsConverterModule * m = new nsConverterModule();
|
||||
if (!m) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Increase refcnt and store away nsIModule interface to m in return_cobj
|
||||
rv = m->QueryInterface(NS_GET_IID(nsIModule), (void**)return_cobj);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete m;
|
||||
m = nsnull;
|
||||
}
|
||||
gModule = m; // WARNING: Weak Reference
|
||||
return rv;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsConverterFactory [implementation]
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsConverterFactory, nsIFactory)
|
||||
|
||||
nsConverterFactory::nsConverterFactory(FactoryData * aData)
|
||||
{
|
||||
mData = aData;
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
PR_AtomicIncrement(&g_InstanceCount);
|
||||
}
|
||||
|
||||
nsConverterFactory::~nsConverterFactory()
|
||||
{
|
||||
PR_AtomicDecrement(&g_InstanceCount);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Interface nsIFactory [implementation]
|
||||
|
||||
NS_IMETHODIMP nsConverterFactory::CreateInstance(nsISupports *aDelegate,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (aResult == NULL) return NS_ERROR_NULL_POINTER;
|
||||
if (aDelegate != NULL) return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsISupports * t;
|
||||
mData->CreateInstance(&t);
|
||||
if (t == NULL) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(t); // Stabilize
|
||||
|
||||
nsresult res = t->QueryInterface(aIID, aResult);
|
||||
|
||||
NS_RELEASE(t); // Destabilize and avoid leaks. Avoid calling delete <interface pointer>
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsConverterFactory::LockFactory(PRBool aLock)
|
||||
{
|
||||
if (aLock) PR_AtomicIncrement(&g_LockCount);
|
||||
else PR_AtomicDecrement(&g_LockCount);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Class nsConverterModule [implementation]
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsConverterModule, nsIModule)
|
||||
|
||||
nsConverterModule::nsConverterModule()
|
||||
: mInitialized(PR_FALSE)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsConverterModule::~nsConverterModule()
|
||||
{
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
nsresult nsConverterModule::Initialize()
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsConverterModule::Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Interface nsIModule [implementation]
|
||||
|
||||
NS_IMETHODIMP nsConverterModule::GetClassObject(nsIComponentManager *aCompMgr,
|
||||
const nsCID& aClass,
|
||||
const nsIID& aIID,
|
||||
void ** r_classObj)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// Defensive programming: Initialize *r_classObj in case of error below
|
||||
if (!r_classObj) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
*r_classObj = NULL;
|
||||
|
||||
if (!mInitialized) {
|
||||
rv = Initialize();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mInitialized = PR_TRUE;
|
||||
}
|
||||
|
||||
FactoryData * data;
|
||||
nsConverterFactory * fact;
|
||||
|
||||
// XXX cache these factories
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
data = &(g_FactoryData[i]);
|
||||
if (aClass.Equals(*(data->mCID))) {
|
||||
fact = new nsConverterFactory(data);
|
||||
if (fact == NULL) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
rv = fact->QueryInterface(aIID, (void **) r_classObj);
|
||||
if (NS_FAILED(rv)) delete fact;
|
||||
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsConverterModule::RegisterSelf(nsIComponentManager *aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* registryLocation,
|
||||
const char* componentType)
|
||||
{
|
||||
nsresult res;
|
||||
PRUint32 i;
|
||||
nsIRegistry * registry = NULL;
|
||||
nsRegistryKey key;
|
||||
char buff[1024];
|
||||
|
||||
// get the registry
|
||||
res = nsServiceManager::GetService(NS_REGISTRY_CONTRACTID,
|
||||
NS_GET_IID(nsIRegistry), (nsISupports**)®istry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
// open the registry
|
||||
res = registry->OpenWellKnownRegistry(
|
||||
nsIRegistry::ApplicationComponentRegistry);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
|
||||
char name[128];
|
||||
char contractid[128];
|
||||
char * cid_string;
|
||||
for (i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
if(0==PL_strcmp(g_FactoryData[i].mCharsetSrc,"Unicode"))
|
||||
{
|
||||
PL_strcpy(name, ENCODER_NAME_BASE);
|
||||
PL_strcat(name, g_FactoryData[i].mCharsetDest);
|
||||
PL_strcpy(contractid, NS_UNICODEENCODER_CONTRACTID_BASE);
|
||||
PL_strcat(contractid, g_FactoryData[i].mCharsetDest);
|
||||
} else {
|
||||
PL_strcpy(name, DECODER_NAME_BASE);
|
||||
PL_strcat(name, g_FactoryData[i].mCharsetSrc);
|
||||
PL_strcpy(contractid, NS_UNICODEDECODER_CONTRACTID_BASE);
|
||||
PL_strcat(contractid, g_FactoryData[i].mCharsetSrc);
|
||||
}
|
||||
// register component
|
||||
res = aCompMgr->RegisterComponentSpec(*(g_FactoryData[i].mCID), name,
|
||||
contractid, aPath, PR_TRUE, PR_TRUE);
|
||||
if(NS_FAILED(res) && (NS_ERROR_FACTORY_EXISTS != res)) goto done;
|
||||
|
||||
// register component info
|
||||
// XXX take these KONSTANTS out of here; refine this code
|
||||
cid_string = g_FactoryData[i].mCID->ToString();
|
||||
sprintf(buff, "%s/%s", "software/netscape/intl/uconv", cid_string);
|
||||
nsCRT::free(cid_string);
|
||||
res = registry -> AddSubtree(nsIRegistry::Common, buff, &key);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetStringUTF8(key, "source", g_FactoryData[i].mCharsetSrc);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
res = registry -> SetStringUTF8(key, "destination", g_FactoryData[i].mCharsetDest);
|
||||
if (NS_FAILED(res)) goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
if (registry != NULL) {
|
||||
nsServiceManager::ReleaseService(NS_REGISTRY_CONTRACTID, registry);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsConverterModule::UnregisterSelf(nsIComponentManager *aCompMgr,
|
||||
nsIFile* aPath,
|
||||
const char* registryLocation)
|
||||
{
|
||||
// XXX also delete the stuff I added to the registry
|
||||
nsresult rv;
|
||||
|
||||
for (PRUint32 i=0; i<ARRAY_SIZE(g_FactoryData); i++) {
|
||||
rv = aCompMgr->UnregisterComponentSpec(*(g_FactoryData[i].mCID), aPath);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsConverterModule::CanUnload(nsIComponentManager *aCompMgr,
|
||||
PRBool *okToUnload)
|
||||
{
|
||||
if (!okToUnload) {
|
||||
return NS_ERROR_INVALID_POINTER;
|
||||
}
|
||||
*okToUnload = (g_InstanceCount == 0 && g_LockCount == 0);
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMPL_NSGETMODULE("nsUCvCnModule", components);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
|
@ -10,12 +10,13 @@
|
|||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Yueheng Xu, yueheng.xu@intel.com
|
||||
*/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
|
@ -10,12 +10,40 @@
|
|||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
* The Original Code is Mozilla Communicator client code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* The Initial Developer of the Original Code is Netscape Communications
|
||||
* Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#ifndef nsUnicodeToCP936_h___
|
||||
#define nsUnicodeToCP936_h___
|
||||
|
||||
#include "nsUCvCnSupport.h"
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Class nsUnicodeToCP936 [declaration]
|
||||
|
||||
/**
|
||||
* A character set converter from Unicode to GB2312.
|
||||
*
|
||||
* @created 06/Apr/1999
|
||||
* @author Catalin Rotaru [CATA]
|
||||
*/
|
||||
class nsUnicodeToCP936 : public nsUnicodeToGBK
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
nsUnicodeToCP936() {};
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsUnicodeToCP936_h___ */
|
||||
|
|
|
@ -56,16 +56,6 @@ nsUnicodeToGB2312::nsUnicodeToGB2312()
|
|||
{
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToGB2312::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToGB2312();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -43,11 +43,6 @@ public:
|
|||
*/
|
||||
nsUnicodeToGB2312();
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
|
|
@ -71,7 +71,7 @@ NS_IMETHODIMP nsUnicodeToGB2312GL::ConvertNoBuff(const PRUnichar * aSrc,
|
|||
PRInt32 i=0;
|
||||
PRInt32 iSrcLength = 0;
|
||||
DByte *pDestDBCode;
|
||||
DByte *pSrcDBCode;
|
||||
DByte *pSrcDBCode;
|
||||
PRInt32 iDestLength = 0;
|
||||
PRUnichar unicode;
|
||||
PRUint8 left, right;
|
||||
|
@ -139,17 +139,6 @@ NS_IMETHODIMP nsUnicodeToGB2312GL::ConvertNoBuff(const PRUnichar * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsUnicodeToGB2312GL::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToGB2312GL();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -43,9 +43,6 @@ class nsUnicodeToGB2312GL : public nsEncoderSupport
|
|||
public:
|
||||
|
||||
nsUnicodeToGB2312GL();
|
||||
virtual ~nsUnicodeToGB2312GL(){};
|
||||
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -138,17 +138,6 @@ NS_IMETHODIMP nsUnicodeToGB2312V2::ConvertNoBuff(const PRUnichar * aSrc,
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
nsresult nsUnicodeToGB2312V2::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToGB2312V2();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -42,12 +42,6 @@ public:
|
|||
* Class constructor.
|
||||
*/
|
||||
nsUnicodeToGB2312V2();
|
||||
virtual ~nsUnicodeToGB2312V2(){};
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -153,17 +153,6 @@ NS_IMETHODIMP nsUnicodeToGBK::ConvertNoBuff(const PRUnichar * aSrc,
|
|||
|
||||
}
|
||||
|
||||
|
||||
nsresult nsUnicodeToGBK::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToGBK();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -44,13 +44,6 @@ public:
|
|||
* Class constructor.
|
||||
*/
|
||||
nsUnicodeToGBK();
|
||||
virtual ~nsUnicodeToGBK(){};
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -280,16 +280,6 @@ NS_IMETHODIMP nsUnicodeToHZ::FillInfo(PRUint32 *aInfo)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsUnicodeToHZ::CreateInstance(nsISupports ** aResult)
|
||||
{
|
||||
nsIUnicodeEncoder *p = new nsUnicodeToHZ();
|
||||
if(p) {
|
||||
*aResult = p;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Subclassing of nsTableEncoderSupport class [implementation]
|
||||
|
||||
|
|
|
@ -44,13 +44,6 @@ public:
|
|||
* Class constructor.
|
||||
*/
|
||||
nsUnicodeToHZ();
|
||||
virtual ~nsUnicodeToHZ(){};
|
||||
|
||||
/**
|
||||
* Static class constructor.
|
||||
*/
|
||||
static nsresult CreateInstance(nsISupports **aResult);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче