Skip to content

Commit

Permalink
Merge pull request #9794 from keymanapp/chore/linux/9733_RenameDefines
Browse files Browse the repository at this point in the history
chore(linux): Rename KBP to CORE 〽️
  • Loading branch information
ermshiperete authored Oct 20, 2023
2 parents 054e1a2 + 2f073f7 commit b177df2
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions common/include/kmx_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ typedef KMX_WORD __attribute__((aligned(1))) KMX_WORD_unaligned;
#define KMX_WORD_unaligned KMX_WORD
#endif

#ifdef KMN_KBP
#ifdef KM_CORE_LIBRARY
// TODO: move this to a common namespace keyman::common::kmx_file or similar in the future
namespace km {
namespace kbp {
Expand Down Expand Up @@ -402,7 +402,7 @@ static_assert(sizeof(COMP_KEY) == KEYBOARDFILEKEY_SIZE, "COMP_KEY must be KEYBOA
static_assert(sizeof(COMP_GROUP) == KEYBOARDFILEGROUP_SIZE, "COMP_GROUP must be KEYBOARDFILEGROUP_SIZE bytes");
static_assert(sizeof(COMP_KEYBOARD) == KEYBOARDFILEHEADER_SIZE, "COMP_KEYBOARD must be KEYBOARDFILEHEADER_SIZE bytes");

#ifdef KMN_KBP
#ifdef KM_CORE_LIBRARY
} // namespace kmx
} // namespace kbp
} // namespace km
Expand Down
16 changes: 8 additions & 8 deletions core/include/keyman/keyman_core_api_bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

#if defined _WIN32 || defined __CYGWIN__
typedef wchar_t const * km_core_path_name;
#define _KM_KBP_PATH_SEPARATOR (L'\\')
#define _KM_KBP_EXT_SEPARATOR (L'.')
#define _KM_CORE_PATH_SEPARATOR (L'\\')
#define _KM_CORE_EXT_SEPARATOR (L'.')
#if defined __GNUC__ // These three will be redefined for Windows
#undef _kmn_export_flag
#undef _kmn_import_flag
Expand All @@ -44,23 +44,23 @@
#define _kmn_static_flag
#else
typedef char const * km_core_path_name;
#define _KM_KBP_PATH_SEPARATOR ('/')
#define _KM_KBP_EXT_SEPARATOR ('.')
#define _KM_CORE_PATH_SEPARATOR ('/')
#define _KM_CORE_EXT_SEPARATOR ('.')
#endif

#if defined KMN_KBP_STATIC
#if defined KM_CORE_LIBRARY_STATIC
#define KMN_API _kmn_tag_fn(_kmn_static_flag)
#define KMN_DEPRECATED_API _kmn_tag_fn(_kmn_deprecated_flag _kmn_and _kmn_static_flag)
#elif defined KMN_KBP_EXPORTING
#elif defined KM_CORE_LIBRARY_EXPORTING
#define KMN_API _kmn_tag_fn(_kmn_export_flag)
#define KMN_DEPRECATED_API _kmn_tag_fn(_kmn_deprecated_flag _kmn_and _kmn_export_flag)
#else
#define KMN_API _kmn_tag_fn(_kmn_import_flag)
#define KMN_DEPRECATED_API _kmn_tag_fn(_kmn_deprecated_flag _kmn_and _kmn_import_flag)
#endif

#ifndef KMN_KBP
#define KMN_KBP
#ifndef KM_CORE_LIBRARY
#define KM_CORE_LIBRARY
#endif
#ifndef USE_CHAR16_T
#define USE_CHAR16_T
Expand Down
6 changes: 3 additions & 3 deletions core/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ py = import('python')
python = py.find_installation()

# TODO: Shared includes may use namespaces, etc which need future tidyup.
# For now, we use KMN_KBP to inject the km::kbp::kmx namespace
defns += ['-DKMN_KBP']
# For now, we use KM_CORE_LIBRARY to inject the km::kbp::kmx namespace
defns += ['-DKM_CORE_LIBRARY']

# #define DEBUG when we are on a debug build
if get_option('buildtype') == 'debug'
Expand All @@ -36,4 +36,4 @@ endif
subdir('doc')
subdir('include')
subdir('src')
subdir('tests')
subdir('tests')
4 changes: 2 additions & 2 deletions core/src/kmx/kmx_file_validator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <kmx_file.h>

#ifdef KMN_KBP
#ifdef KM_CORE_LIBRARY
// TODO: move this to a common namespace keyman::common::kmx_file or similar in the future
namespace km {
namespace kbp {
Expand All @@ -27,7 +27,7 @@ class KMX_FileValidator : public COMP_KEYBOARD {
};


#ifdef KMN_KBP
#ifdef KM_CORE_LIBRARY
} // namespace kmx
} // namespace kbp
} // namespace km
Expand Down
4 changes: 2 additions & 2 deletions core/src/kmx/kmx_processevent.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

#pragma once

#ifndef KMN_KBP
#define KMN_KBP
#ifndef KM_CORE_LIBRARY
#define KM_CORE_LIBRARY
#endif
#ifndef USE_CHAR16_T
#define USE_CHAR16_T
Expand Down
4 changes: 2 additions & 2 deletions core/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
version_res = []

# TODO: shouldn't this be defined only for dylib and not static lib?
defns += ['-DKMN_KBP_EXPORTING']
defns += ['-DKM_CORE_LIBRARY_EXPORTING']

if cpp_compiler.get_id() == 'msvc'
defns += ['-DUNICODE']
Expand All @@ -18,7 +18,7 @@ endif

if cpp_compiler.get_id() == 'emscripten'
# TODO: why do we need this defn here?
defns += ['-DKMN_KBP']
defns += ['-DKM_CORE_LIBRARY']
endif

# ICU4C is used for repertoire tests and core implementation
Expand Down
8 changes: 4 additions & 4 deletions core/src/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ namespace kbp
using char_type = std::remove_const_t<
std::remove_pointer_t<km_core_path_name>>;
using string_type = std::basic_string<char_type>;
static constexpr char_type const parent_separator = _KM_KBP_PATH_SEPARATOR,
suffix_separator = _KM_KBP_EXT_SEPARATOR;
static constexpr char_type const parent_separator = _KM_CORE_PATH_SEPARATOR,
suffix_separator = _KM_CORE_EXT_SEPARATOR;
private:
string_type _path;

void normalise() {
#if '/' != _KM_KBP_PATH_SEPARATOR
std::replace(_path.begin(), _path.end(), char_type('/'), _KM_KBP_PATH_SEPARATOR);
#if '/' != _KM_CORE_PATH_SEPARATOR
std::replace(_path.begin(), _path.end(), char_type('/'), _KM_CORE_PATH_SEPARATOR);
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/processor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace kbp
* updateing the state as required.
*
* @param state An opaque pointer to a state object
* @return km_core_status `KM_CORE_STATUS_OK`: On success. Else KB_KBP_ error code
* @return km_core_status `KM_CORE_STATUS_OK`: On success. Else KB_CORE_ error code
*/
virtual km_core_status
process_queued_actions(
Expand Down
2 changes: 1 addition & 1 deletion core/src/version.rc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
VALUE "InternalName", "Keyman Core"
VALUE "LegalCopyright", "© SIL International"
VALUE "LegalTrademarks", ""
VALUE "OriginalFilename", "KMNKBP0-0.DLL"
VALUE "OriginalFilename", "KMNCORE0-0.DLL"
VALUE "ProductName", "Keyman Core"
VALUE "ProductVersion", KM_CORE_VERSION_STRING
VALUE "Comments", ""
Expand Down
2 changes: 1 addition & 1 deletion core/tests/unit/kmnkbd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ else
warns = []
endif

local_defns = ['-DKMN_KBP_STATIC']
local_defns = ['-DKM_CORE_LIBRARY_STATIC']
tests = [
['context-api', 'context_api.cpp'],
['keyboard-api', 'keyboard_api.cpp'],
Expand Down
4 changes: 2 additions & 2 deletions core/tests/unit/kmnkbd/test_kmx_xstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Keyman Core - KMX Extended String unit tests
*/

#ifndef KMN_KBP
#define KMN_KBP
#ifndef KM_CORE_LIBRARY
#define KM_CORE_LIBRARY
#endif
#ifndef USE_CHAR16_T
#define USE_CHAR16_T
Expand Down
8 changes: 4 additions & 4 deletions core/tools/ldml-const-builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ THIS_SCRIPT="$(readlink -f "${BASH_SOURCE[0]}")"
# This script runs from its own folder
cd "$(dirname "$THIS_SCRIPT")"

KBP_LDML_H_FILE="../../include/ldml/keyboardprocessor_ldml.h"
CORE_LDML_H_FILE="../../include/ldml/keyboardprocessor_ldml.h"

################################ Main script ################################

Expand All @@ -30,7 +30,7 @@ builder_parse "$@"

if builder_start_action clean; then
rm -rf ../../include/ldml/build/
# Not removing ${KBP_LDML_H_FILE} as it is checked in
# Not removing ${CORE_LDML_H_FILE} as it is checked in
builder_finish_action success clean
fi

Expand All @@ -42,8 +42,8 @@ if builder_start_action build; then
fi

if builder_start_action run; then
node --enable-source-maps ../../include/ldml/ldml-const-builder/ldml-const-builder.js > ${KBP_LDML_H_FILE}
echo "Updated ${KBP_LDML_H_FILE}"
node --enable-source-maps ../../include/ldml/ldml-const-builder/ldml-const-builder.js > ${CORE_LDML_H_FILE}
echo "Updated ${CORE_LDML_H_FILE}"

builder_finish_action success run
fi
Expand Down
8 changes: 4 additions & 4 deletions windows/src/engine/keyman32/keyboardoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
BOOL IntLoadKeyboardOptionsRegistrytoCore(LPCSTR key, LPINTKEYBOARDINFO kp, km_core_state* const state);
void IntSaveKeyboardOptionCoretoRegistry(LPCSTR REGKey, LPINTKEYBOARDINFO kp, LPCWSTR key, LPWSTR value);

static km_core_cp* CloneKMKBPCP(const km_core_cp* cp) {
static km_core_cp* CloneKMCORECP(const km_core_cp* cp) {
LPCWSTR buf = reinterpret_cast<LPCWSTR>(cp);
km_core_cp* clone = new km_core_cp[wcslen(buf) + 1];
wcscpy_s(reinterpret_cast<LPWSTR>(clone), wcslen(buf) + 1, buf);
return clone;
}

static km_core_cp* CloneKMKBPCPFromWSTR(LPWSTR buf) {
static km_core_cp* CloneKMCORECPFromWSTR(LPWSTR buf) {
km_core_cp* clone = new km_core_cp[wcslen(buf) + 1];
wcscpy_s(reinterpret_cast<LPWSTR>(clone), wcslen(buf) + 1, buf);
return clone;
Expand Down Expand Up @@ -90,9 +90,9 @@ BOOL IntLoadKeyboardOptionsRegistrytoCore(LPCSTR key, LPINTKEYBOARDINFO kp, km_c
LPCWSTR coreKey = reinterpret_cast<LPCWSTR>(kpc->key);
WCHAR val[256];
if (hasData && r.ReadString(coreKey, val, sizeof(val) / sizeof(val[0])) && val[0]) {
keyboardOpts[n].value = CloneKMKBPCPFromWSTR(val);
keyboardOpts[n].value = CloneKMCORECPFromWSTR(val);
} else {
keyboardOpts[n].value = CloneKMKBPCP(kpc->value);
keyboardOpts[n].value = CloneKMCORECP(kpc->value);
}
n++;
}
Expand Down
4 changes: 2 additions & 2 deletions windows/src/engine/keyman32/keymanengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#endif

// For keyman_core_api_bits.h
#ifndef KMN_KBP_STATIC
#define KMN_KBP_STATIC
#ifndef KM_CORE_LIBRARY_STATIC
#define KM_CORE_LIBRARY_STATIC
#endif
// For keyman_core_api_bits.h
#ifndef _WIN32
Expand Down

0 comments on commit b177df2

Please sign in to comment.