From ebcccbe0efe7bf4aa07da8d21224fcac1106dc85 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Mon, 3 Jul 2023 18:20:59 -0500 Subject: [PATCH] =?UTF-8?q?feat(core):=20rearrange=20elem=20flags=20?= =?UTF-8?q?=F0=9F=99=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - per review comments, make the elem flags clearer For: #7377 --- core/include/ldml/keyboardprocessor_ldml.h | 10 +++--- core/include/ldml/keyboardprocessor_ldml.ts | 31 +++++++++---------- core/src/ldml/C7043_ldml.md | 6 ++-- .../src/kmc-ldml/test/fixtures/basic.txt | 4 +-- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/core/include/ldml/keyboardprocessor_ldml.h b/core/include/ldml/keyboardprocessor_ldml.h index 9654f972d9..a92731bfa3 100644 --- a/core/include/ldml/keyboardprocessor_ldml.h +++ b/core/include/ldml/keyboardprocessor_ldml.h @@ -22,14 +22,14 @@ #define LDML_CLDR_VERSION_TECHPREVIEW "techpreview" #define LDML_ELEM_FLAGS_ORDER_BITSHIFT 0x10 #define LDML_ELEM_FLAGS_ORDER_MASK 0xFF0000 -#define LDML_ELEM_FLAGS_PREBASE 0x2 -#define LDML_ELEM_FLAGS_TERTIARY_BASE 0x1 +#define LDML_ELEM_FLAGS_PREBASE 0x8 +#define LDML_ELEM_FLAGS_TERTIARY_BASE 0x4 #define LDML_ELEM_FLAGS_TERTIARY_BITSHIFT 0x18 #define LDML_ELEM_FLAGS_TERTIARY_MASK 0xFF000000 -#define LDML_ELEM_FLAGS_TYPE 0xC +#define LDML_ELEM_FLAGS_TYPE 0x3 #define LDML_ELEM_FLAGS_TYPE_CHAR 0x0 -#define LDML_ELEM_FLAGS_TYPE_STR 0x4 -#define LDML_ELEM_FLAGS_TYPE_USET 0x8 +#define LDML_ELEM_FLAGS_TYPE_STR 0x1 +#define LDML_ELEM_FLAGS_TYPE_USET 0x2 #define LDML_FINL_FLAGS_ERROR 0x1 #define LDML_KEYS_FLICK_FLAGS_EXTEND 0x1 #define LDML_KEYS_KEY_FLAGS_EXTEND 0x1 diff --git a/core/include/ldml/keyboardprocessor_ldml.ts b/core/include/ldml/keyboardprocessor_ldml.ts index c23739797b..4d59700895 100644 --- a/core/include/ldml/keyboardprocessor_ldml.ts +++ b/core/include/ldml/keyboardprocessor_ldml.ts @@ -139,6 +139,19 @@ class Constants { */ readonly length_elem_item_element = 8; + /** + * bitwise or value for type in elem[elemstr][element].flags. + * If bits are 00b, then 'element' is a UTF-32LE codepoint. + * If bits are 01b, then 'element' is a string index. + * If bits are 10b (2), then 'element' is a uset index. + * + * `type = flags & elem_flags_type` + */ + readonly elem_flags_type = 0x00000003; + readonly elem_flags_type_char = 0x00000000; + readonly elem_flags_type_str = 0x00000001; + readonly elem_flags_type_uset = 0x00000002; + /** * bitwise or value for tertiary_base in elem[elemstr][element].flags. * If bit is 1, then tertiary_base is true. @@ -148,7 +161,7 @@ class Constants { * * `tertiary_base = flags & elem_flags_tertiary_base` */ - readonly elem_flags_tertiary_base = 0x00000001; + readonly elem_flags_tertiary_base = 0x00000004; /** * bitwise or value for tertiary_base in elem[elemstr][element].flags. @@ -159,21 +172,7 @@ class Constants { * * `prebase = flags & elem_flags_prebase` */ - readonly elem_flags_prebase = 0x00000002; - - /** - * bitwise or value for type in elem[elemstr][element].flags. - * If bits are 00b, then 'element' is a UTF-32LE codepoint. - * If bits are 01b, then 'element' is a string index. - * If bits are 10b (2), then 'element' is a uset index. - * - * `type = flags & elem_flags_type` - */ - readonly elem_flags_type = 0x0000000C; - readonly elem_flags_type_char = 0x0 << 2; - readonly elem_flags_type_str = 0x1 << 2; - readonly elem_flags_type_uset = 0x2 << 2; - + readonly elem_flags_prebase = 0x00000008; /** * bitwise mask for order in elem[elemstr][element].flags. diff --git a/core/src/ldml/C7043_ldml.md b/core/src/ldml/C7043_ldml.md index b5ed8fc571..bb226d9ba5 100644 --- a/core/src/ldml/C7043_ldml.md +++ b/core/src/ldml/C7043_ldml.md @@ -93,9 +93,9 @@ Each element string is made up of elements with the following item structure: | Bit position | Meaning | Description | |--------------|---------------|-------------------------------------------| - | 0 | tertiary_base | 1: tertiary_base is true | - | 1 | prebase | 1: prebase is true | - | 2-3 | type | `element` is 0: UTF-32LE, 1: str, 2: uset | + | 0-1 | type | `element` is 0: UTF-32LE, 1: str, 2: uset | + | 2 | tertiary_base | 1: tertiary_base is true | + | 3 | prebase | 1: prebase is true | | 4-15 | reserved | reserved | | 16-23 | order | signed int: -128 to +127 | | 24-31 | tertiary | signed int: -128 to +127 | diff --git a/developer/src/kmc-ldml/test/fixtures/basic.txt b/developer/src/kmc-ldml/test/fixtures/basic.txt index 6672fc4c9b..d5d8a93f14 100644 --- a/developer/src/kmc-ldml/test/fixtures/basic.txt +++ b/developer/src/kmc-ldml/test/fixtures/basic.txt @@ -227,8 +227,8 @@ block(elemOrdrFrom) # from="\u{1A60}[\u1A75-\u1A79]\u{1A45}" order="10 55 10" 60 1a 00 00 # KMX_DWORD element; '᩠' // str: output string or UTF-32LE codepoint 00 00 0A 00 # KMX_DWORD flags; // flag and order values - cp - 00 00 00 00 # TODO-LDML: uset #0 # KMX_DWORD element; [uset] // str: output string or UTF-32LE codepoint - 08 00 37 00 # KMX_DWORD flags; // flag and order values - unicodeset + 00 00 00 00 # TODO-LDML: uset #0 # KMX_DWORD element; [uset] // str: output string or UTF-32LE codepoint + 02 00 37 00 # KMX_DWORD flags; // flag and order values - unicodeset 45 1A 00 00 # KMX_DWORD element; 'ᩅ' // str: output string or UTF-32LE codepoint 00 00 0A 00 # KMX_DWORD flags; // flag and order values - unicodeset