ICU-4287 move bidi/shaping properties to ubidi.icu
X-SVN-Rev: 17056
This commit is contained in:
parent
739b6a5220
commit
ca773f99db
@ -806,43 +806,7 @@ u_getNumericValue(UChar32 c) {
|
||||
}
|
||||
}
|
||||
|
||||
/* Gets the character's linguistic directionality.*/
|
||||
U_CAPI UCharDirection U_EXPORT2
|
||||
u_charDirection(UChar32 c) {
|
||||
uint32_t props;
|
||||
GET_PROPS(c, props);
|
||||
return (UCharDirection)GET_BIDI_CLASS(props);
|
||||
}
|
||||
|
||||
U_CAPI UBool U_EXPORT2
|
||||
u_isMirrored(UChar32 c) {
|
||||
uint32_t props;
|
||||
GET_PROPS(c, props);
|
||||
return (UBool)(props&(1UL<<UPROPS_MIRROR_SHIFT) ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
U_CAPI UChar32 U_EXPORT2
|
||||
u_charMirror(UChar32 c) {
|
||||
uint32_t props;
|
||||
GET_PROPS(c, props);
|
||||
if((props&(1UL<<UPROPS_MIRROR_SHIFT))==0) {
|
||||
/* not mirrored - the value is not a mirror offset */
|
||||
return c;
|
||||
} else if(!PROPS_VALUE_IS_EXCEPTION(props)) {
|
||||
return c+GET_SIGNED_VALUE(props);
|
||||
} else {
|
||||
const uint32_t *pe=GET_EXCEPTIONS(props);
|
||||
uint32_t firstExceptionValue=*pe;
|
||||
if(HAVE_EXCEPTION_VALUE(firstExceptionValue, EXC_MIRROR_MAPPING)) {
|
||||
int i=EXC_MIRROR_MAPPING;
|
||||
++pe;
|
||||
ADD_EXCEPTION_OFFSET(firstExceptionValue, i, pe);
|
||||
return (UChar32)*pe;
|
||||
} else {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* ICU 3.4: bidi/shaping properties moved to ubidi_props.c */
|
||||
|
||||
/* ICU 2.1: u_getCombiningClass() moved to unorm.cpp */
|
||||
|
||||
|
@ -30,7 +30,7 @@ U_CFUNC UBool ucln_common_lib_cleanup(void);
|
||||
|
||||
/*
|
||||
Please keep the order of enums declared in same order
|
||||
as the functions are suppose to be called. */
|
||||
as the cleanup functions are suppose to be called. */
|
||||
typedef enum ECleanupCommonType {
|
||||
UCLN_COMMON_START = -1,
|
||||
UCLN_COMMON_USPREP,
|
||||
@ -43,6 +43,7 @@ typedef enum ECleanupCommonType {
|
||||
UCLN_COMMON_USET,
|
||||
UCLN_COMMON_UNAMES,
|
||||
UCLN_COMMON_PNAME,
|
||||
UCLN_COMMON_UBIDI,
|
||||
UCLN_COMMON_UCASE,
|
||||
UCLN_COMMON_UCHAR,
|
||||
UCLN_COMMON_UCNV,
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "propname.h"
|
||||
#include "unormimp.h"
|
||||
#include "ucase.h"
|
||||
#include "ubidi_props.h"
|
||||
#include "uinvchar.h"
|
||||
#include "charstr.h"
|
||||
#include "cstring.h"
|
||||
@ -1346,6 +1347,9 @@ const UnicodeSet* UnicodeSet::getInclusions(int32_t src, UErrorCode &status) {
|
||||
case UPROPS_SRC_CASE:
|
||||
ucase_addPropertyStarts(ucase_getSingleton(&status), &sa, &status);
|
||||
break;
|
||||
case UPROPS_SRC_BIDI:
|
||||
ubidi_addPropertyStarts(ubidi_getSingleton(&status), &sa, &status);
|
||||
break;
|
||||
default:
|
||||
status = U_INTERNAL_PROGRAM_ERROR;
|
||||
break;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "unicode/uscript.h"
|
||||
#include "cstring.h"
|
||||
#include "unormimp.h"
|
||||
#include "ubidi_props.h"
|
||||
#include "uprops.h"
|
||||
|
||||
#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
|
||||
@ -46,8 +47,8 @@ static const struct {
|
||||
*/
|
||||
{ 1, U_MASK(UPROPS_ALPHABETIC) },
|
||||
{ 1, U_MASK(UPROPS_ASCII_HEX_DIGIT) },
|
||||
{ 1, U_MASK(UPROPS_BIDI_CONTROL) },
|
||||
{ -1, U_MASK(UPROPS_MIRROR_SHIFT) },
|
||||
{ UPROPS_SRC_BIDI, 0 }, /* UCHAR_BIDI_CONTROL */
|
||||
{ UPROPS_SRC_BIDI, 0 }, /* UCHAR_BIDI_MIRRORED */
|
||||
{ 1, U_MASK(UPROPS_DASH) },
|
||||
{ 1, U_MASK(UPROPS_DEFAULT_IGNORABLE_CODE_POINT) },
|
||||
{ 1, U_MASK(UPROPS_DEPRECATED) },
|
||||
@ -64,7 +65,7 @@ static const struct {
|
||||
{ 1, U_MASK(UPROPS_IDEOGRAPHIC) },
|
||||
{ 1, U_MASK(UPROPS_IDS_BINARY_OPERATOR) },
|
||||
{ 1, U_MASK(UPROPS_IDS_TRINARY_OPERATOR) },
|
||||
{ 1, U_MASK(UPROPS_JOIN_CONTROL) },
|
||||
{ UPROPS_SRC_BIDI, 0 }, /* UCHAR_JOIN_CONTROL */
|
||||
{ 1, U_MASK(UPROPS_LOGICAL_ORDER_EXCEPTION) },
|
||||
{ UPROPS_SRC_CASE, 0 }, /* UCHAR_LOWERCASE */
|
||||
{ 1, U_MASK(UPROPS_MATH) },
|
||||
@ -136,6 +137,23 @@ u_hasBinaryProperty(UChar32 c, UProperty which) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
} else if(column==UPROPS_SRC_BIDI) {
|
||||
/* bidi/shaping properties */
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
UBiDiProps *bdp=ubidi_getSingleton(&errorCode);
|
||||
if(U_FAILURE(errorCode)) {
|
||||
return FALSE;
|
||||
}
|
||||
switch(which) {
|
||||
case UCHAR_BIDI_MIRRORED:
|
||||
return ubidi_isMirrored(bdp, c);
|
||||
case UCHAR_BIDI_CONTROL:
|
||||
return ubidi_isBidiControl(bdp, c);
|
||||
case UCHAR_JOIN_CONTROL:
|
||||
return ubidi_isJoinControl(bdp, c);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -171,9 +189,25 @@ u_getIntPropertyValue(UChar32 c, UProperty which) {
|
||||
case UCHAR_GENERAL_CATEGORY:
|
||||
return (int32_t)u_charType(c);
|
||||
case UCHAR_JOINING_GROUP:
|
||||
return (int32_t)(u_getUnicodeProperties(c, 2)&UPROPS_JG_MASK)>>UPROPS_JG_SHIFT;
|
||||
{
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
UBiDiProps *bdp=ubidi_getSingleton(&errorCode);
|
||||
if(bdp!=NULL) {
|
||||
return ubidi_getJoiningGroup(bdp, c);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
case UCHAR_JOINING_TYPE:
|
||||
return (int32_t)(u_getUnicodeProperties(c, 2)&UPROPS_JT_MASK)>>UPROPS_JT_SHIFT;
|
||||
{
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
UBiDiProps *bdp=ubidi_getSingleton(&errorCode);
|
||||
if(bdp!=NULL) {
|
||||
return ubidi_getJoiningType(bdp, c);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
case UCHAR_LINE_BREAK:
|
||||
return (int32_t)(u_getUnicodeProperties(c, 0)&UPROPS_LB_MASK)>>UPROPS_LB_SHIFT;
|
||||
case UCHAR_NUMERIC_TYPE:
|
||||
@ -222,7 +256,12 @@ u_getIntPropertyMaxValue(UProperty which) {
|
||||
} else if(which<UCHAR_INT_LIMIT) {
|
||||
switch(which) {
|
||||
case UCHAR_BIDI_CLASS:
|
||||
return (int32_t)U_CHAR_DIRECTION_COUNT-1;
|
||||
case UCHAR_JOINING_GROUP:
|
||||
case UCHAR_JOINING_TYPE:
|
||||
{
|
||||
UErrorCode errorCode=U_ZERO_ERROR;
|
||||
return ubidi_getMaxValue(ubidi_getSingleton(&errorCode), which);
|
||||
}
|
||||
case UCHAR_BLOCK:
|
||||
max=(uprv_getMaxValues(0)&UPROPS_BLOCK_MASK)>>UPROPS_BLOCK_SHIFT;
|
||||
return max!=0 ? max : (int32_t)UBLOCK_COUNT-1;
|
||||
@ -238,12 +277,6 @@ u_getIntPropertyMaxValue(UProperty which) {
|
||||
return max!=0 ? max : (int32_t)U_EA_COUNT-1;
|
||||
case UCHAR_GENERAL_CATEGORY:
|
||||
return (int32_t)U_CHAR_CATEGORY_COUNT-1;
|
||||
case UCHAR_JOINING_GROUP:
|
||||
max=(uprv_getMaxValues(2)&UPROPS_JG_MASK)>>UPROPS_JG_SHIFT;
|
||||
return max!=0 ? max : (int32_t)U_JG_COUNT-1;
|
||||
case UCHAR_JOINING_TYPE:
|
||||
max=(uprv_getMaxValues(2)&UPROPS_JT_MASK)>>UPROPS_JT_SHIFT;
|
||||
return max!=0 ? max : (int32_t)U_JT_COUNT-1;
|
||||
case UCHAR_LINE_BREAK:
|
||||
max=(uprv_getMaxValues(0)&UPROPS_LB_MASK)>>UPROPS_LB_SHIFT;
|
||||
return max!=0 ? max : (int32_t)U_LB_COUNT-1;
|
||||
@ -286,6 +319,7 @@ uprops_getSource(UProperty which) {
|
||||
switch(which) {
|
||||
case UCHAR_HANGUL_SYLLABLE_TYPE:
|
||||
return UPROPS_SRC_HST;
|
||||
|
||||
case UCHAR_CANONICAL_COMBINING_CLASS:
|
||||
case UCHAR_NFD_QUICK_CHECK:
|
||||
case UCHAR_NFKD_QUICK_CHECK:
|
||||
@ -294,6 +328,12 @@ uprops_getSource(UProperty which) {
|
||||
case UCHAR_LEAD_CANONICAL_COMBINING_CLASS:
|
||||
case UCHAR_TRAIL_CANONICAL_COMBINING_CLASS:
|
||||
return UPROPS_SRC_NORM;
|
||||
|
||||
case UCHAR_BIDI_CLASS:
|
||||
case UCHAR_JOINING_GROUP:
|
||||
case UCHAR_JOINING_TYPE:
|
||||
return UPROPS_SRC_BIDI;
|
||||
|
||||
default:
|
||||
return UPROPS_SRC_CHAR;
|
||||
}
|
||||
@ -409,7 +449,9 @@ uprv_getInclusions(const USetAdder *sa, UErrorCode *pErrorCode) {
|
||||
unorm_addPropertyStarts(sa, pErrorCode);
|
||||
#endif
|
||||
uchar_addPropertyStarts(sa, pErrorCode);
|
||||
uhst_addPropertyStarts(sa, pErrorCode);
|
||||
ucase_addPropertyStarts(ucase_getSingleton(pErrorCode), sa, pErrorCode);
|
||||
ubidi_addPropertyStarts(ubidi_getSingleton(pErrorCode), sa, pErrorCode);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -340,7 +340,7 @@ enum UPropertySource {
|
||||
UPROPS_SRC_NORM,
|
||||
/** From ucase.c/ucase.icu */
|
||||
UPROPS_SRC_CASE,
|
||||
/** From ubidi.c/ubidi.icu */
|
||||
/** From ubidi_props.c/ubidi.icu */
|
||||
UPROPS_SRC_BIDI,
|
||||
/** One more than the highes UPropertySource (UPROPS_SRC_) constant. */
|
||||
UPROPS_SRC_COUNT
|
||||
|
Loading…
Reference in New Issue
Block a user