]>
Commit | Line | Data |
---|---|---|
73c04bcf A |
1 | /* |
2 | ******************************************************************************* | |
3 | * | |
b331163b | 4 | * Copyright (C) 2004-2014, International Business Machines |
73c04bcf A |
5 | * Corporation and others. All Rights Reserved. |
6 | * | |
7 | ******************************************************************************* | |
8 | * file name: ubidi_props.h | |
9 | * encoding: US-ASCII | |
10 | * tab size: 8 (not used) | |
11 | * indentation:4 | |
12 | * | |
13 | * created on: 2004dec30 | |
14 | * created by: Markus W. Scherer | |
15 | * | |
16 | * Low-level Unicode bidi/shaping properties access. | |
17 | */ | |
18 | ||
19 | #ifndef __UBIDI_PROPS_H__ | |
20 | #define __UBIDI_PROPS_H__ | |
21 | ||
22 | #include "unicode/utypes.h" | |
23 | #include "unicode/uset.h" | |
57a6839d | 24 | #include "putilimp.h" |
73c04bcf A |
25 | #include "uset_imp.h" |
26 | #include "udataswp.h" | |
27 | ||
28 | U_CDECL_BEGIN | |
29 | ||
30 | /* library API -------------------------------------------------------------- */ | |
31 | ||
32 | struct UBiDiProps; | |
33 | typedef struct UBiDiProps UBiDiProps; | |
34 | ||
46f4442e | 35 | U_CFUNC const UBiDiProps * |
729e4ab9 | 36 | ubidi_getSingleton(void); |
73c04bcf | 37 | |
46f4442e | 38 | U_CFUNC void |
73c04bcf A |
39 | ubidi_addPropertyStarts(const UBiDiProps *bdp, const USetAdder *sa, UErrorCode *pErrorCode); |
40 | ||
41 | /* property access functions */ | |
42 | ||
43 | U_CFUNC int32_t | |
44 | ubidi_getMaxValue(const UBiDiProps *bdp, UProperty which); | |
45 | ||
46f4442e | 46 | U_CAPI UCharDirection |
73c04bcf A |
47 | ubidi_getClass(const UBiDiProps *bdp, UChar32 c); |
48 | ||
46f4442e | 49 | U_CFUNC UBool |
73c04bcf A |
50 | ubidi_isMirrored(const UBiDiProps *bdp, UChar32 c); |
51 | ||
46f4442e | 52 | U_CFUNC UChar32 |
73c04bcf A |
53 | ubidi_getMirror(const UBiDiProps *bdp, UChar32 c); |
54 | ||
46f4442e | 55 | U_CFUNC UBool |
73c04bcf A |
56 | ubidi_isBidiControl(const UBiDiProps *bdp, UChar32 c); |
57 | ||
46f4442e | 58 | U_CFUNC UBool |
73c04bcf A |
59 | ubidi_isJoinControl(const UBiDiProps *bdp, UChar32 c); |
60 | ||
46f4442e | 61 | U_CFUNC UJoiningType |
73c04bcf A |
62 | ubidi_getJoiningType(const UBiDiProps *bdp, UChar32 c); |
63 | ||
46f4442e | 64 | U_CFUNC UJoiningGroup |
73c04bcf A |
65 | ubidi_getJoiningGroup(const UBiDiProps *bdp, UChar32 c); |
66 | ||
57a6839d A |
67 | U_CFUNC UBidiPairedBracketType |
68 | ubidi_getPairedBracketType(const UBiDiProps *bdp, UChar32 c); | |
69 | ||
70 | U_CFUNC UChar32 | |
71 | ubidi_getPairedBracket(const UBiDiProps *bdp, UChar32 c); | |
72 | ||
73c04bcf A |
73 | /* file definitions --------------------------------------------------------- */ |
74 | ||
75 | #define UBIDI_DATA_NAME "ubidi" | |
76 | #define UBIDI_DATA_TYPE "icu" | |
77 | ||
78 | /* format "BiDi" */ | |
79 | #define UBIDI_FMT_0 0x42 | |
80 | #define UBIDI_FMT_1 0x69 | |
81 | #define UBIDI_FMT_2 0x44 | |
82 | #define UBIDI_FMT_3 0x69 | |
83 | ||
84 | /* indexes into indexes[] */ | |
85 | enum { | |
86 | UBIDI_IX_INDEX_TOP, | |
87 | UBIDI_IX_LENGTH, | |
88 | UBIDI_IX_TRIE_SIZE, | |
89 | UBIDI_IX_MIRROR_LENGTH, | |
90 | ||
91 | UBIDI_IX_JG_START, | |
92 | UBIDI_IX_JG_LIMIT, | |
b331163b A |
93 | UBIDI_IX_JG_START2, /* new in format version 2.2, ICU 54 */ |
94 | UBIDI_IX_JG_LIMIT2, | |
73c04bcf A |
95 | |
96 | UBIDI_MAX_VALUES_INDEX=15, | |
97 | UBIDI_IX_TOP=16 | |
98 | }; | |
99 | ||
100 | /* definitions for 16-bit bidi/shaping properties word ---------------------- */ | |
101 | ||
102 | enum { | |
103 | /* UBIDI_CLASS_SHIFT=0, */ /* bidi class: 5 bits (4..0) */ | |
104 | UBIDI_JT_SHIFT=5, /* joining type: 3 bits (7..5) */ | |
105 | ||
57a6839d | 106 | UBIDI_BPT_SHIFT=8, /* Bidi_Paired_Bracket_Type(bpt): 2 bits (9..8) */ |
73c04bcf A |
107 | |
108 | UBIDI_JOIN_CONTROL_SHIFT=10, | |
109 | UBIDI_BIDI_CONTROL_SHIFT=11, | |
110 | ||
111 | UBIDI_IS_MIRRORED_SHIFT=12, /* 'is mirrored' */ | |
112 | UBIDI_MIRROR_DELTA_SHIFT=13, /* bidi mirroring delta: 3 bits (15..13) */ | |
113 | ||
114 | UBIDI_MAX_JG_SHIFT=16 /* max JG value in indexes[UBIDI_MAX_VALUES_INDEX] bits 23..16 */ | |
115 | }; | |
116 | ||
117 | #define UBIDI_CLASS_MASK 0x0000001f | |
118 | #define UBIDI_JT_MASK 0x000000e0 | |
57a6839d | 119 | #define UBIDI_BPT_MASK 0x00000300 |
73c04bcf A |
120 | |
121 | #define UBIDI_MAX_JG_MASK 0x00ff0000 | |
122 | ||
123 | #define UBIDI_GET_CLASS(props) ((props)&UBIDI_CLASS_MASK) | |
124 | #define UBIDI_GET_FLAG(props, shift) (((props)>>(shift))&1) | |
125 | ||
57a6839d A |
126 | #if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC |
127 | # define UBIDI_GET_MIRROR_DELTA(props) ((int16_t)(props)>>UBIDI_MIRROR_DELTA_SHIFT) | |
128 | #else | |
129 | # define UBIDI_GET_MIRROR_DELTA(props) (int16_t)(((props)&0x8000) ? (((props)>>UBIDI_MIRROR_DELTA_SHIFT)|0xe000) : ((props)>>UBIDI_MIRROR_DELTA_SHIFT)) | |
130 | #endif | |
131 | ||
73c04bcf A |
132 | enum { |
133 | UBIDI_ESC_MIRROR_DELTA=-4, | |
134 | UBIDI_MIN_MIRROR_DELTA=-3, | |
135 | UBIDI_MAX_MIRROR_DELTA=3 | |
136 | }; | |
137 | ||
138 | /* definitions for 32-bit mirror table entry -------------------------------- */ | |
139 | ||
140 | enum { | |
141 | /* the source Unicode code point takes 21 bits (20..0) */ | |
142 | UBIDI_MIRROR_INDEX_SHIFT=21, | |
143 | UBIDI_MAX_MIRROR_INDEX=0x7ff | |
144 | }; | |
145 | ||
146 | #define UBIDI_GET_MIRROR_CODE_POINT(m) (UChar32)((m)&0x1fffff) | |
147 | ||
148 | #define UBIDI_GET_MIRROR_INDEX(m) ((m)>>UBIDI_MIRROR_INDEX_SHIFT) | |
149 | ||
150 | U_CDECL_END | |
151 | ||
152 | #endif |