ubidi_props.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. *
  6. * Copyright (C) 2004-2014, International Business Machines
  7. * Corporation and others. All Rights Reserved.
  8. *
  9. *******************************************************************************
  10. * file name: ubidi_props.h
  11. * encoding: UTF-8
  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. #ifndef __UBIDI_PROPS_H__
  21. #define __UBIDI_PROPS_H__
  22. #include "unicode/utypes.h"
  23. #include "unicode/uset.h"
  24. #include "putilimp.h"
  25. #include "uset_imp.h"
  26. #include "udataswp.h"
  27. U_CDECL_BEGIN
  28. /* library API -------------------------------------------------------------- */
  29. U_CFUNC void
  30. ubidi_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode);
  31. /* property access functions */
  32. U_CFUNC int32_t
  33. ubidi_getMaxValue(UProperty which);
  34. U_CAPI UCharDirection
  35. ubidi_getClass(UChar32 c);
  36. U_CFUNC UBool
  37. ubidi_isMirrored(UChar32 c);
  38. U_CFUNC UChar32
  39. ubidi_getMirror(UChar32 c);
  40. U_CFUNC UBool
  41. ubidi_isBidiControl(UChar32 c);
  42. U_CFUNC UBool
  43. ubidi_isJoinControl(UChar32 c);
  44. U_CFUNC UJoiningType
  45. ubidi_getJoiningType(UChar32 c);
  46. U_CFUNC UJoiningGroup
  47. ubidi_getJoiningGroup(UChar32 c);
  48. U_CFUNC UBidiPairedBracketType
  49. ubidi_getPairedBracketType(UChar32 c);
  50. U_CFUNC UChar32
  51. ubidi_getPairedBracket(UChar32 c);
  52. /* file definitions --------------------------------------------------------- */
  53. #define UBIDI_DATA_NAME "ubidi"
  54. #define UBIDI_DATA_TYPE "icu"
  55. /* format "BiDi" */
  56. #define UBIDI_FMT_0 0x42
  57. #define UBIDI_FMT_1 0x69
  58. #define UBIDI_FMT_2 0x44
  59. #define UBIDI_FMT_3 0x69
  60. /* indexes into indexes[] */
  61. enum {
  62. UBIDI_IX_INDEX_TOP,
  63. UBIDI_IX_LENGTH,
  64. UBIDI_IX_TRIE_SIZE,
  65. UBIDI_IX_MIRROR_LENGTH,
  66. UBIDI_IX_JG_START,
  67. UBIDI_IX_JG_LIMIT,
  68. UBIDI_IX_JG_START2, /* new in format version 2.2, ICU 54 */
  69. UBIDI_IX_JG_LIMIT2,
  70. UBIDI_MAX_VALUES_INDEX=15,
  71. UBIDI_IX_TOP=16
  72. };
  73. /* definitions for 16-bit bidi/shaping properties word ---------------------- */
  74. enum {
  75. /* UBIDI_CLASS_SHIFT=0, */ /* bidi class: 5 bits (4..0) */
  76. UBIDI_JT_SHIFT=5, /* joining type: 3 bits (7..5) */
  77. UBIDI_BPT_SHIFT=8, /* Bidi_Paired_Bracket_Type(bpt): 2 bits (9..8) */
  78. UBIDI_JOIN_CONTROL_SHIFT=10,
  79. UBIDI_BIDI_CONTROL_SHIFT=11,
  80. UBIDI_IS_MIRRORED_SHIFT=12, /* 'is mirrored' */
  81. UBIDI_MIRROR_DELTA_SHIFT=13, /* bidi mirroring delta: 3 bits (15..13) */
  82. UBIDI_MAX_JG_SHIFT=16 /* max JG value in indexes[UBIDI_MAX_VALUES_INDEX] bits 23..16 */
  83. };
  84. #define UBIDI_CLASS_MASK 0x0000001f
  85. #define UBIDI_JT_MASK 0x000000e0
  86. #define UBIDI_BPT_MASK 0x00000300
  87. #define UBIDI_MAX_JG_MASK 0x00ff0000
  88. #define UBIDI_GET_CLASS(props) ((props)&UBIDI_CLASS_MASK)
  89. #define UBIDI_GET_FLAG(props, shift) (((props)>>(shift))&1)
  90. #if U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC
  91. # define UBIDI_GET_MIRROR_DELTA(props) ((int16_t)(props)>>UBIDI_MIRROR_DELTA_SHIFT)
  92. #else
  93. # define UBIDI_GET_MIRROR_DELTA(props) (int16_t)(((props)&0x8000) ? (((props)>>UBIDI_MIRROR_DELTA_SHIFT)|0xe000) : ((props)>>UBIDI_MIRROR_DELTA_SHIFT))
  94. #endif
  95. enum {
  96. UBIDI_ESC_MIRROR_DELTA=-4,
  97. UBIDI_MIN_MIRROR_DELTA=-3,
  98. UBIDI_MAX_MIRROR_DELTA=3
  99. };
  100. /* definitions for 32-bit mirror table entry -------------------------------- */
  101. enum {
  102. /* the source Unicode code point takes 21 bits (20..0) */
  103. UBIDI_MIRROR_INDEX_SHIFT=21,
  104. UBIDI_MAX_MIRROR_INDEX=0x7ff
  105. };
  106. #define UBIDI_GET_MIRROR_CODE_POINT(m) (UChar32)((m)&0x1fffff)
  107. #define UBIDI_GET_MIRROR_INDEX(m) ((m)>>UBIDI_MIRROR_INDEX_SHIFT)
  108. U_CDECL_END
  109. #endif