michael@0: /* michael@0: ******************************************************************************* michael@0: * michael@0: * Copyright (C) 2004-2013, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: * michael@0: ******************************************************************************* michael@0: * file name: ubidi_props.h michael@0: * encoding: US-ASCII michael@0: * tab size: 8 (not used) michael@0: * indentation:4 michael@0: * michael@0: * created on: 2004dec30 michael@0: * created by: Markus W. Scherer michael@0: * michael@0: * Low-level Unicode bidi/shaping properties access. michael@0: */ michael@0: michael@0: #ifndef __UBIDI_PROPS_H__ michael@0: #define __UBIDI_PROPS_H__ michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include "unicode/uset.h" michael@0: #include "putilimp.h" michael@0: #include "uset_imp.h" michael@0: #include "udataswp.h" michael@0: michael@0: U_CDECL_BEGIN michael@0: michael@0: /* library API -------------------------------------------------------------- */ michael@0: michael@0: struct UBiDiProps; michael@0: typedef struct UBiDiProps UBiDiProps; michael@0: michael@0: U_CFUNC const UBiDiProps * michael@0: ubidi_getSingleton(void); michael@0: michael@0: U_CFUNC void michael@0: ubidi_addPropertyStarts(const UBiDiProps *bdp, const USetAdder *sa, UErrorCode *pErrorCode); michael@0: michael@0: /* property access functions */ michael@0: michael@0: U_CFUNC int32_t michael@0: ubidi_getMaxValue(const UBiDiProps *bdp, UProperty which); michael@0: michael@0: U_CAPI UCharDirection michael@0: ubidi_getClass(const UBiDiProps *bdp, UChar32 c); michael@0: michael@0: U_CFUNC UBool michael@0: ubidi_isMirrored(const UBiDiProps *bdp, UChar32 c); michael@0: michael@0: U_CFUNC UChar32 michael@0: ubidi_getMirror(const UBiDiProps *bdp, UChar32 c); michael@0: michael@0: U_CFUNC UBool michael@0: ubidi_isBidiControl(const UBiDiProps *bdp, UChar32 c); michael@0: michael@0: U_CFUNC UBool michael@0: ubidi_isJoinControl(const UBiDiProps *bdp, UChar32 c); michael@0: michael@0: U_CFUNC UJoiningType michael@0: ubidi_getJoiningType(const UBiDiProps *bdp, UChar32 c); michael@0: michael@0: U_CFUNC UJoiningGroup michael@0: ubidi_getJoiningGroup(const UBiDiProps *bdp, UChar32 c); michael@0: michael@0: U_CFUNC UBidiPairedBracketType michael@0: ubidi_getPairedBracketType(const UBiDiProps *bdp, UChar32 c); michael@0: michael@0: U_CFUNC UChar32 michael@0: ubidi_getPairedBracket(const UBiDiProps *bdp, UChar32 c); michael@0: michael@0: /* file definitions --------------------------------------------------------- */ michael@0: michael@0: #define UBIDI_DATA_NAME "ubidi" michael@0: #define UBIDI_DATA_TYPE "icu" michael@0: michael@0: /* format "BiDi" */ michael@0: #define UBIDI_FMT_0 0x42 michael@0: #define UBIDI_FMT_1 0x69 michael@0: #define UBIDI_FMT_2 0x44 michael@0: #define UBIDI_FMT_3 0x69 michael@0: michael@0: /* indexes into indexes[] */ michael@0: enum { michael@0: UBIDI_IX_INDEX_TOP, michael@0: UBIDI_IX_LENGTH, michael@0: UBIDI_IX_TRIE_SIZE, michael@0: UBIDI_IX_MIRROR_LENGTH, michael@0: michael@0: UBIDI_IX_JG_START, michael@0: UBIDI_IX_JG_LIMIT, michael@0: michael@0: UBIDI_MAX_VALUES_INDEX=15, michael@0: UBIDI_IX_TOP=16 michael@0: }; michael@0: michael@0: /* definitions for 16-bit bidi/shaping properties word ---------------------- */ michael@0: michael@0: enum { michael@0: /* UBIDI_CLASS_SHIFT=0, */ /* bidi class: 5 bits (4..0) */ michael@0: UBIDI_JT_SHIFT=5, /* joining type: 3 bits (7..5) */ michael@0: michael@0: UBIDI_BPT_SHIFT=8, /* Bidi_Paired_Bracket_Type(bpt): 2 bits (9..8) */ michael@0: michael@0: UBIDI_JOIN_CONTROL_SHIFT=10, michael@0: UBIDI_BIDI_CONTROL_SHIFT=11, michael@0: michael@0: UBIDI_IS_MIRRORED_SHIFT=12, /* 'is mirrored' */ michael@0: UBIDI_MIRROR_DELTA_SHIFT=13, /* bidi mirroring delta: 3 bits (15..13) */ michael@0: michael@0: UBIDI_MAX_JG_SHIFT=16 /* max JG value in indexes[UBIDI_MAX_VALUES_INDEX] bits 23..16 */ michael@0: }; michael@0: michael@0: #define UBIDI_CLASS_MASK 0x0000001f michael@0: #define UBIDI_JT_MASK 0x000000e0 michael@0: #define UBIDI_BPT_MASK 0x00000300 michael@0: michael@0: #define UBIDI_MAX_JG_MASK 0x00ff0000 michael@0: michael@0: #define UBIDI_GET_CLASS(props) ((props)&UBIDI_CLASS_MASK) michael@0: #define UBIDI_GET_FLAG(props, shift) (((props)>>(shift))&1) michael@0: michael@0: #if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC michael@0: # define UBIDI_GET_MIRROR_DELTA(props) ((int16_t)(props)>>UBIDI_MIRROR_DELTA_SHIFT) michael@0: #else michael@0: # define UBIDI_GET_MIRROR_DELTA(props) (int16_t)(((props)&0x8000) ? (((props)>>UBIDI_MIRROR_DELTA_SHIFT)|0xe000) : ((props)>>UBIDI_MIRROR_DELTA_SHIFT)) michael@0: #endif michael@0: michael@0: enum { michael@0: UBIDI_ESC_MIRROR_DELTA=-4, michael@0: UBIDI_MIN_MIRROR_DELTA=-3, michael@0: UBIDI_MAX_MIRROR_DELTA=3 michael@0: }; michael@0: michael@0: /* definitions for 32-bit mirror table entry -------------------------------- */ michael@0: michael@0: enum { michael@0: /* the source Unicode code point takes 21 bits (20..0) */ michael@0: UBIDI_MIRROR_INDEX_SHIFT=21, michael@0: UBIDI_MAX_MIRROR_INDEX=0x7ff michael@0: }; michael@0: michael@0: #define UBIDI_GET_MIRROR_CODE_POINT(m) (UChar32)((m)&0x1fffff) michael@0: michael@0: #define UBIDI_GET_MIRROR_INDEX(m) ((m)>>UBIDI_MIRROR_INDEX_SHIFT) michael@0: michael@0: U_CDECL_END michael@0: michael@0: #endif