1 /* 2 ******************************************************************************* 3 * 4 * Copyright (C) 2004-2010, International Business Machines 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" 24 #include "uset_imp.h" 25 #include "udataswp.h" 26 27 U_CDECL_BEGIN 28 29 /* library API -------------------------------------------------------------- */ 30 31 struct UBiDiProps; 32 typedef struct UBiDiProps UBiDiProps; 33 34 U_CFUNC const UBiDiProps * 35 ubidi_getSingleton(void); 36 37 U_CFUNC void 38 ubidi_addPropertyStarts(const UBiDiProps *bdp, const USetAdder *sa, UErrorCode *pErrorCode); 39 40 /* property access functions */ 41 42 U_CFUNC int32_t 43 ubidi_getMaxValue(const UBiDiProps *bdp, UProperty which); 44 45 U_CAPI UCharDirection 46 ubidi_getClass(const UBiDiProps *bdp, UChar32 c); 47 48 U_CFUNC UBool 49 ubidi_isMirrored(const UBiDiProps *bdp, UChar32 c); 50 51 U_CFUNC UChar32 52 ubidi_getMirror(const UBiDiProps *bdp, UChar32 c); 53 54 U_CFUNC UBool 55 ubidi_isBidiControl(const UBiDiProps *bdp, UChar32 c); 56 57 U_CFUNC UBool 58 ubidi_isJoinControl(const UBiDiProps *bdp, UChar32 c); 59 60 U_CFUNC UJoiningType 61 ubidi_getJoiningType(const UBiDiProps *bdp, UChar32 c); 62 63 U_CFUNC UJoiningGroup 64 ubidi_getJoiningGroup(const UBiDiProps *bdp, UChar32 c); 65 66 /* file definitions --------------------------------------------------------- */ 67 68 #define UBIDI_DATA_NAME "ubidi" 69 #define UBIDI_DATA_TYPE "icu" 70 71 /* format "BiDi" */ 72 #define UBIDI_FMT_0 0x42 73 #define UBIDI_FMT_1 0x69 74 #define UBIDI_FMT_2 0x44 75 #define UBIDI_FMT_3 0x69 76 77 /* indexes into indexes[] */ 78 enum { 79 UBIDI_IX_INDEX_TOP, 80 UBIDI_IX_LENGTH, 81 UBIDI_IX_TRIE_SIZE, 82 UBIDI_IX_MIRROR_LENGTH, 83 84 UBIDI_IX_JG_START, 85 UBIDI_IX_JG_LIMIT, 86 87 UBIDI_MAX_VALUES_INDEX=15, 88 UBIDI_IX_TOP=16 89 }; 90 91 /* definitions for 16-bit bidi/shaping properties word ---------------------- */ 92 93 enum { 94 /* UBIDI_CLASS_SHIFT=0, */ /* bidi class: 5 bits (4..0) */ 95 UBIDI_JT_SHIFT=5, /* joining type: 3 bits (7..5) */ 96 97 /* UBIDI__SHIFT=8, reserved: 2 bits (9..8) */ 98 99 UBIDI_JOIN_CONTROL_SHIFT=10, 100 UBIDI_BIDI_CONTROL_SHIFT=11, 101 102 UBIDI_IS_MIRRORED_SHIFT=12, /* 'is mirrored' */ 103 UBIDI_MIRROR_DELTA_SHIFT=13, /* bidi mirroring delta: 3 bits (15..13) */ 104 105 UBIDI_MAX_JG_SHIFT=16 /* max JG value in indexes[UBIDI_MAX_VALUES_INDEX] bits 23..16 */ 106 }; 107 108 #define UBIDI_CLASS_MASK 0x0000001f 109 #define UBIDI_JT_MASK 0x000000e0 110 111 #define UBIDI_MAX_JG_MASK 0x00ff0000 112 113 #define UBIDI_GET_CLASS(props) ((props)&UBIDI_CLASS_MASK) 114 #define UBIDI_GET_FLAG(props, shift) (((props)>>(shift))&1) 115 116 enum { 117 UBIDI_ESC_MIRROR_DELTA=-4, 118 UBIDI_MIN_MIRROR_DELTA=-3, 119 UBIDI_MAX_MIRROR_DELTA=3 120 }; 121 122 /* definitions for 32-bit mirror table entry -------------------------------- */ 123 124 enum { 125 /* the source Unicode code point takes 21 bits (20..0) */ 126 UBIDI_MIRROR_INDEX_SHIFT=21, 127 UBIDI_MAX_MIRROR_INDEX=0x7ff 128 }; 129 130 #define UBIDI_GET_MIRROR_CODE_POINT(m) (UChar32)((m)&0x1fffff) 131 132 #define UBIDI_GET_MIRROR_INDEX(m) ((m)>>UBIDI_MIRROR_INDEX_SHIFT) 133 134 U_CDECL_END 135 136 #endif 137