Skip to content

Commit

Permalink
Merge branch 'feat/core/9707-tertiary-reorder-epic-ldml' into fix/dev…
Browse files Browse the repository at this point in the history
…eloper/9438-vis-kbd-crash-epic-ldml
  • Loading branch information
srl295 authored Nov 16, 2023
2 parents 361c7d8 + 350eb83 commit 054ec28
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 28 deletions.
36 changes: 18 additions & 18 deletions core/src/ldml/ldml_transforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ element::is_uset() const {
return (flags & LDML_ELEM_FLAGS_TYPE) == LDML_ELEM_FLAGS_TYPE_USET;
}

signed char
reorder_weight
element::get_order() const {
unsigned char uorder = ((flags & LDML_ELEM_FLAGS_ORDER_MASK) >> LDML_ELEM_FLAGS_ORDER_BITSHIFT);
return (signed char)uorder;
return (reorder_weight)uorder; // unsigned to signed
}

signed char
reorder_weight
element::get_tertiary() const {
unsigned char uorder = ((flags & LDML_ELEM_FLAGS_TERTIARY_MASK) >> LDML_ELEM_FLAGS_TERTIARY_BITSHIFT);
return (signed char)uorder;
return (reorder_weight)uorder; // unsigned to signed
}

bool
Expand Down Expand Up @@ -93,19 +93,19 @@ element::dump() const {

int
reorder_sort_key::compare(const reorder_sort_key &other) const {
int primaryResult = (int)primary - (int)other.primary;
int secondaryResult = (int)secondary - (int)other.secondary;
int tertiaryResult = (int)tertiary - (int)other.tertiary;
int quaternaryResult = (int)quaternary - (int)other.quaternary;
auto primaryResult = primary - other.primary;
auto secondaryResult = secondary - other.secondary;
auto tertiaryResult = tertiary - other.tertiary;
auto quaternaryResult = quaternary - other.quaternary;

if (primaryResult) {
return primaryResult;
return (int)primaryResult;
} else if (secondaryResult) {
return secondaryResult;
return (int)secondaryResult;
} else if (tertiaryResult) {
return tertiaryResult;
return (int)tertiaryResult;
} else if (quaternaryResult) {
return quaternaryResult;
return (int)quaternaryResult;
} else {
// We don't expect to get here. quaternaryResult is the string index, which
// should be unequal.
Expand All @@ -131,8 +131,8 @@ reorder_sort_key::from(const std::u32string &str) {
// construct a 'baseline' sort key, that is, in the absence of
// any match rules.
std::deque<reorder_sort_key> keylist;
auto s = str.begin(); // str iterator
size_t c = 0; // str index
auto s = str.begin(); // str iterator
reorder_weight c = 0; // str index
for (auto e = str.begin(); e < str.end(); e++, s++, c++) {
// primary weight: 0
// seconary weight: c (the string index)
Expand Down Expand Up @@ -215,9 +215,9 @@ std::deque<reorder_sort_key> &
element_list::update_sort_key(size_t offset, std::deque<reorder_sort_key> &key) const {
/** string index */
size_t c = 0;
bool have_last_base = false;
signed char last_base_primary = -1;
signed char last_base_secondary = -1;
bool have_last_base = false;
reorder_weight last_base_primary = -1;
reorder_weight last_base_secondary = -1;
for (auto e = begin(); e < end(); e++, c++) {
/** position in the key */
auto n = offset + c;
Expand Down Expand Up @@ -418,7 +418,7 @@ reorder_group::apply(std::u32string &str) const {
// recombine into a string by pulling out the 'ch' value
// that's in each sortkey element.
std::u32string newSuffix;
size_t q = sort_keys.begin()->quaternary; // start with the first quaternary
signed char q = sort_keys.begin()->quaternary; // start with the first quaternary
for (auto e = sort_keys.begin(); e < sort_keys.end(); e++, q++) {
if (q != e->quaternary) {
// something rearranged in this subrange, because the quaternary values are out of order.
Expand Down
17 changes: 11 additions & 6 deletions core/src/ldml/ldml_transforms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ inline bool uassert_success(const char *file, int line, const char *function, UE

using km::core::kmx::SimpleUSet;

/** a reorder weight, such as primary, secondary, etc. */
typedef signed char reorder_weight;



/**
* Type of a group
*/
Expand All @@ -71,9 +76,9 @@ class element {
/** @returns true if tertiary base bit set */
bool is_tertiary_base() const;
/** @returns the primary order */
signed char get_order() const;
reorder_weight get_order() const;
/** @returns the tertiary order */
signed char get_tertiary() const;
reorder_weight get_tertiary() const;
/** @returns raw elem flags */
KMX_DWORD get_flags() const;
/** @returns true if matches this character*/
Expand Down Expand Up @@ -157,10 +162,10 @@ class transform_group : public std::deque<transform_entry> {
/** a single char, categorized according to reorder rules*/
struct reorder_sort_key {
km_core_usv ch; // the single char value
signed char primary; // primary order value
size_t secondary; // index position
signed char tertiary; // tertiary value, defaults to 0
size_t quaternary; // index again
reorder_weight primary; // primary order value
reorder_weight secondary; // index position
reorder_weight tertiary; // tertiary value, defaults to 0
reorder_weight quaternary; // index again
bool is_tertiary_base; // remember that this key was a tertiary base

/** @returns -1, 0, 1 depending on ordering */
Expand Down
2 changes: 1 addition & 1 deletion core/tests/unit/ldml/test_transforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ test_reorder_standalone() {
l.update_sort_key(0, keylist);
std::cout << __FILE__ << ":" << __LINE__ << " updated sortkey" << std::endl;
assert_equal(keylist.size(), 2);
size_t secondary = 0;
reorder_weight secondary = 0;
for (auto i = keylist.begin(); i < keylist.end(); i++) {
i->dump();
assert_equal(i->secondary, secondary);
Expand Down
6 changes: 3 additions & 3 deletions resources/build/trigger-builds.inc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ function triggerGitHubActionsBuild() {
GIT_BASE_REF="$(git rev-parse "${GIT_BUILD_SHA}^")"
GIT_EVENT_TYPE="${GITHUB_ACTION}: release@${VERSION_WITH_TAG}"
elif [[ $GIT_BRANCH != stable-* ]] && [[ $GIT_BRANCH =~ [0-9]+ ]]; then
GIT_BUILD_SHA="$(git rev-parse "refs/pull/${GIT_BRANCH}/head")"
GIT_EVENT_TYPE="${GITHUB_ACTION}: PR #${GIT_BRANCH}"
JSON=$(curl -s "${GITHUB_SERVER}/pulls/${GIT_BRANCH}")
GIT_BUILD_SHA="$(echo "$JSON" | $JQ -r '.head.sha')"
GIT_EVENT_TYPE="${GITHUB_ACTION}: PR #${GIT_BRANCH}"
GIT_USER="$(echo "$JSON" | $JQ -r '.user.login')"
GIT_BASE_BRANCH="$(echo "$JSON" | $JQ -r '.base.ref')"
GIT_BASE_REF="$(git rev-parse "${GIT_BASE_BRANCH}")"
GIT_BASE_REF="$(echo "$JSON" | $JQ -r '.base.sha')"
GIT_BRANCH="PR-${GIT_BRANCH}"
else
GIT_BUILD_SHA="$(git rev-parse "refs/heads/${GIT_BRANCH}")"
Expand Down

0 comments on commit 054ec28

Please sign in to comment.