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