| 1 |
// This file is part of ICU4X. For terms of use, please see the file |
| 2 |
// called LICENSE at the top level of the ICU4X source tree |
| 3 |
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). |
| 4 |
|
| 5 |
pub const FAST_TYPE_SHIFT: i32 = 6; |
| 6 |
|
| 7 |
/// Number of entries in a data block for code points below the fast limit. 64=0x40 |
| 8 |
pub const FAST_TYPE_DATA_BLOCK_LENGTH: u32 = 1 << FAST_TYPE_SHIFT; |
| 9 |
|
| 10 |
/// Mask for getting the lower bits for the in-fast-data-block offset. |
| 11 |
pub const FAST_TYPE_DATA_MASK: u32 = FAST_TYPE_DATA_BLOCK_LENGTH - 1; |
| 12 |
|
| 13 |
/// Fast indexing limit for "fast"-type trie |
| 14 |
pub const FAST_TYPE_FAST_INDEXING_MAX: u32 = 0xffff; |
| 15 |
|
| 16 |
/// Fast indexing limit for "small"-type trie |
| 17 |
pub const SMALL_TYPE_FAST_INDEXING_MAX: u32 = 0xfff; |
| 18 |
|
| 19 |
/// Offset from dataLength (to be subtracted) for fetching the |
| 20 |
/// value returned for out-of-range code points and ill-formed UTF-8/16. |
| 21 |
pub const ERROR_VALUE_NEG_DATA_OFFSET: u32 = 1; |
| 22 |
|
| 23 |
/// Offset from dataLength (to be subtracted) for fetching the |
| 24 |
/// value returned for code points highStart..U+10FFFF. |
| 25 |
pub const HIGH_VALUE_NEG_DATA_OFFSET: u32 = 2; |
| 26 |
|
| 27 |
/// The length of the BMP index table. 1024=0x400 |
| 28 |
pub const BMP_INDEX_LENGTH: u32 = 0x10000 >> FAST_TYPE_SHIFT; |
| 29 |
|
| 30 |
pub const SMALL_LIMIT: u32 = 0x1000; |
| 31 |
|
| 32 |
pub const SMALL_INDEX_LENGTH: u32 = SMALL_LIMIT >> FAST_TYPE_SHIFT; |
| 33 |
|
| 34 |
/// Shift size for getting the index-3 table offset. |
| 35 |
pub const SHIFT_3: u32 = 4; |
| 36 |
|
| 37 |
/// Shift size for getting the index-2 table offset. |
| 38 |
pub const SHIFT_2: u32 = 5 + SHIFT_3; |
| 39 |
|
| 40 |
/// Shift size for getting the index-1 table offset. |
| 41 |
pub const SHIFT_1: u32 = 5 + SHIFT_2; |
| 42 |
|
| 43 |
/// Difference between two shift sizes, |
| 44 |
/// for getting an index-2 offset from an index-3 offset. 5=9-4 |
| 45 |
pub const SHIFT_2_3: u32 = SHIFT_2 - SHIFT_3; |
| 46 |
|
| 47 |
/// Difference between two shift sizes, |
| 48 |
/// for getting an index-1 offset from an index-2 offset. 5=14-9 |
| 49 |
pub const SHIFT_1_2: u32 = SHIFT_1 - SHIFT_2; |
| 50 |
|
| 51 |
/// Number of index-1 entries for the BMP. (4) |
| 52 |
/// This part of the index-1 table is omitted from the serialized form. |
| 53 |
pub const OMITTED_BMP_INDEX_1_LENGTH: u32 = 0x10000 >> SHIFT_1; |
| 54 |
|
| 55 |
/// Number of entries in an index-2 block. 32=0x20 |
| 56 |
pub const INDEX_2_BLOCK_LENGTH: u32 = 1 << SHIFT_1_2; |
| 57 |
|
| 58 |
/// Mask for getting the lower bits for the in-index-2-block offset. |
| 59 |
pub const INDEX_2_MASK: u32 = INDEX_2_BLOCK_LENGTH - 1; |
| 60 |
|
| 61 |
/// Number of code points per index-2 table entry. 512=0x200 |
| 62 |
pub const CP_PER_INDEX_2_ENTRY: u32 = 1 << SHIFT_2; |
| 63 |
|
| 64 |
/// Number of entries in an index-3 block. 32=0x20 |
| 65 |
pub const INDEX_3_BLOCK_LENGTH: u32 = 1 << SHIFT_2_3; |
| 66 |
|
| 67 |
/// Mask for getting the lower bits for the in-index-3-block offset. |
| 68 |
pub const INDEX_3_MASK: u32 = INDEX_3_BLOCK_LENGTH - 1; |
| 69 |
|
| 70 |
/// Number of entries in a small data block. 16=0x10 |
| 71 |
pub const SMALL_DATA_BLOCK_LENGTH: u32 = 1 << SHIFT_3; |
| 72 |
|
| 73 |
/// Mask for getting the lower bits for the in-small-data-block offset. |
| 74 |
pub const SMALL_DATA_MASK: u32 = SMALL_DATA_BLOCK_LENGTH - 1; |
| 75 |
|
| 76 |
pub const CODE_POINT_MAX: u32 = 0x10ffff; |