Bug 1170072 - Part 2. Use ICU instead of GetCharProps1 and its supporting data if ICU is turned on. r=jfkthame

This commit is contained in:
Makoto Kato 2015-09-07 11:56:13 +09:00
parent 502ecb4185
commit 560bf16a85
6 changed files with 46 additions and 3 deletions

View File

@ -1345,6 +1345,7 @@ xlocale.h
unicode/locid.h
unicode/numsys.h
unicode/ucal.h
unicode/uchar.h
unicode/uclean.h
unicode/ucol.h
unicode/udat.h

View File

@ -734,7 +734,9 @@ struct nsCharProps1 {
unsigned char mCombiningClass:8;
};
/;
print DATA_TABLES "#ifndef ENABLE_INTL_API\n";
&genTables("CharProp1", $type, "nsCharProps1", 11, 5, \&sprintCharProps1, 1, 2, 1);
+print DATA_TABLES "#endif\n\n";
sub sprintCharProps2
{

View File

@ -41,6 +41,7 @@ if CONFIG['_MSC_VER']:
if CONFIG['ENABLE_INTL_API']:
CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
USE_LIBS += ['icu']
if not CONFIG['GNU_CXX']:
ALLOW_COMPILER_WARNINGS = True

View File

@ -9,10 +9,15 @@
#include "mozilla/ArrayUtils.h"
#include "nsCharTraits.h"
#if ENABLE_INTL_API
#include "unicode/uchar.h"
#endif
#define UNICODE_BMP_LIMIT 0x10000
#define UNICODE_LIMIT 0x110000
#ifndef ENABLE_INTL_API
static const nsCharProps1&
GetCharProps1(uint32_t aCh)
{
@ -34,6 +39,7 @@ GetCharProps1(uint32_t aCh)
};
return undefined;
}
#endif
const nsCharProps2&
GetCharProps2(uint32_t aCh)
@ -127,19 +133,31 @@ nsIUGenCategory::nsUGenCategory sDetailedToGeneralCategory[] = {
uint32_t
GetMirroredChar(uint32_t aCh)
{
#if ENABLE_INTL_API
return u_charMirror(aCh);
#else
return aCh + sMirrorOffsets[GetCharProps1(aCh).mMirrorOffsetIndex];
#endif
}
bool
HasMirroredChar(uint32_t aCh)
{
#if ENABLE_INTL_API
return u_isMirrored(aCh);
#else
return GetCharProps1(aCh).mMirrorOffsetIndex != 0;
#endif
}
uint8_t
GetCombiningClass(uint32_t aCh)
{
#if ENABLE_INTL_API
return u_getCombiningClass(aCh);
#else
return GetCharProps1(aCh).mCombiningClass;
#endif
}
uint32_t
@ -262,18 +280,31 @@ IsClusterExtender(uint32_t aCh, uint8_t aCategory)
}
enum HSType {
#if ENABLE_INTL_API
HST_NONE = U_HST_NOT_APPLICABLE,
HST_L = U_HST_LEADING_JAMO,
HST_V = U_HST_VOWEL_JAMO,
HST_T = U_HST_TRAILING_JAMO,
HST_LV = U_HST_LV_SYLLABLE,
HST_LVT = U_HST_LVT_SYLLABLE
#else
HST_NONE = 0x00,
HST_L = 0x01,
HST_V = 0x02,
HST_T = 0x04,
HST_LV = 0x03,
HST_LVT = 0x07
#endif
};
static HSType
GetHangulSyllableType(uint32_t aCh)
{
#if ENABLE_INTL_API
return HSType(u_getIntPropertyValue(aCh, UCHAR_HANGUL_SYLLABLE_TYPE));
#else
return HSType(GetCharProps1(aCh).mHangulType);
#endif
}
void
@ -308,14 +339,15 @@ ClusterIterator::Next()
}
break;
case HST_V:
if ((hangulState != HST_NONE) && !(hangulState & HST_T)) {
if ((hangulState != HST_NONE) && (hangulState != HST_T) &&
(hangulState != HST_LVT)) {
hangulState = hangulType;
mPos++;
continue;
}
break;
case HST_T:
if (hangulState & (HST_V | HST_T)) {
if (hangulState != HST_NONE && hangulState != HST_L) {
hangulState = hangulType;
mPos++;
continue;

View File

@ -11,7 +11,7 @@
*/
/*
* Created on Thu Sep 3 14:42:28 2015 from UCD data files with version info:
* Created on Mon Sep 7 02:52:23 2015 from UCD data files with version info:
*
# Date: 2015-06-16, 20:24:00 GMT [KW]
@ -223,6 +223,7 @@ static const int16_t sMirrorOffsets[] = {
-2108
};
#ifndef ENABLE_INTL_API
#define kCharProp1MaxPlane 1
#define kCharProp1IndexBits 11
#define kCharProp1CharBits 5
@ -391,6 +392,8 @@ static const nsCharProps1 sCharProp1Values[155][32] = {
{{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,220}, {0,0,220}, {0,0,220}, {0,0,220}, {0,0,220}, {0,0,220}, {0,0,220}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0},}
};
#endif
#define kCharProp2MaxPlane 16
#define kCharProp2IndexBits 11
#define kCharProp2CharBits 5

View File

@ -11,6 +11,10 @@ UNIFIED_SOURCES += [
'../nsUnicodeProperties.cpp',
]
if CONFIG['ENABLE_INTL_API']:
CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
USE_LIBS += ['icu']
for var in ('MOZILLA_INTERNAL_API', 'MOZILLA_XPCOMRT_API', 'MOZILLA_EXTERNAL_LINKAGE',
'NR_SOCKET_IS_VOID_PTR', 'HAVE_STRDUP'):
DEFINES[var] = True