Skip to content

Commit

Permalink
chore(core): address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mcdurdin committed Jan 19, 2024
1 parent 3878394 commit ba46d21
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 45 deletions.
2 changes: 1 addition & 1 deletion core/src/action.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace core
/* in, out */ km_core_actions *actions
);

bool actions_update_app_context(
bool actions_update_app_context_nfu(
/* in */ km_core_context const *cached_context,
/* in, out */ km_core_context *app_context
);
Expand Down
16 changes: 5 additions & 11 deletions core/src/actions_normalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@
#include "state.hpp"
#include "option.hpp"
#include "debuglog.h"

#if !defined(HAVE_ICU4C)
#error icu4c is required for this code
#endif

#define U_FALLTHROUGH
#include "unicode/utypes.h"
#include "unicode/unistr.h"
#include "unicode/normalizer2.h"
#include "core_icu.h"

// forward declarations

Expand Down Expand Up @@ -286,7 +278,9 @@ km_core_usv *unicode_string_to_usv(icu::UnicodeString& src) {


/**
* Refresh app_context to match the cached_context
* Refresh app_context to match the cached_context. Does not do normalization,
* unlike `actions_normalize`. Used in conjunction with keyboard processors that
* do not support normalization.
*
* @param cached_context the cached context, in NFU, after transform has been
* applied to it by the keyboard processor
Expand All @@ -295,7 +289,7 @@ km_core_usv *unicode_string_to_usv(icu::UnicodeString& src) {
* function
* @return true on success, false on failure
*/
bool km::core::actions_update_app_context(
bool km::core::actions_update_app_context_nfu(
/* in */ km_core_context const *cached_context,
/* in, out */ km_core_context *app_context
) {
Expand Down
13 changes: 13 additions & 0 deletions core/src/core_icu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* ICU modules used by Keyman Core
*/
#pragma once

#if !defined(HAVE_ICU4C)
#error icu4c is required for this code
#endif

#define U_FALLTHROUGH
#include "unicode/utypes.h"
#include "unicode/unistr.h"
#include "unicode/normalizer2.h"
2 changes: 1 addition & 1 deletion core/src/km_core_action_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ km_core_actions const * km_core_state_get_actions(
}
} else {
// For all other keyboard processors, we just copy the cached_context to the app_context
if(!actions_update_app_context(km_core_state_context(state), km_core_state_app_context(state))) {
if(!actions_update_app_context_nfu(km_core_state_context(state), km_core_state_app_context(state))) {
km_core_actions_dispose(result);
return nullptr;
}
Expand Down
10 changes: 1 addition & 9 deletions core/src/km_core_state_context_set_if_needed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@
#include "processor.hpp"
#include "state.hpp"
#include "debuglog.h"

#if !defined(HAVE_ICU4C)
#error icu4c is required for this code
#endif

#define U_FALLTHROUGH
#include "unicode/utypes.h"
#include "unicode/unistr.h"
#include "unicode/normalizer2.h"
#include "core_icu.h"

using namespace km::core;

Expand Down
9 changes: 1 addition & 8 deletions core/src/ldml/ldml_markers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@
#include <utility>
#include "debuglog.h"

#if !defined(HAVE_ICU4C)
#error icu4c is required for this code
#endif

#define U_FALLTHROUGH
#include "unicode/utypes.h"
#include "core_icu.h"
#include "unicode/uniset.h"
#include "unicode/usetiter.h"
#include "unicode/unistr.h"
#include "unicode/regex.h"
#include "unicode/utext.h"
#include "unicode/normalizer2.h"

namespace km {
namespace core {
Expand Down
9 changes: 1 addition & 8 deletions core/src/ldml/ldml_transforms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@
#include <utility>
#include "debuglog.h"

#if !defined(HAVE_ICU4C)
#error icu4c is required for this code
#endif

#define U_FALLTHROUGH
#include "unicode/utypes.h"
#include "core_icu.h"
#include "unicode/uniset.h"
#include "unicode/usetiter.h"
#include "unicode/unistr.h"
#include "unicode/regex.h"
#include "unicode/utext.h"
#include "unicode/normalizer2.h"

namespace km {
namespace core {
Expand Down
8 changes: 1 addition & 7 deletions core/tests/unit/ldml/ldml_test_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,9 @@
#include "ldml_test_source.hpp"
#include "ldml_test_utils.hpp"

#if defined(HAVE_ICU4C)
// TODO-LDML: Needed this for some compiler warnings
#define U_FALLTHROUGH
#include "unicode/utypes.h"
#include "core_icu.h"
#include "unicode/uniset.h"
#include "unicode/usetiter.h"
#else
#error icu4c is required for this test
#endif

#define assert_or_return(expr) if(!(expr)) { \
std::wcerr << __FILE__ << ":" << __LINE__ << ": " << \
Expand Down

0 comments on commit ba46d21

Please sign in to comment.