From dde4e2b2c3e145d3983a1ac681fa10d21a53fe41 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Wed, 14 Aug 2024 10:07:08 +0200 Subject: [PATCH] refactor: move kmx_u16 to common and rename to km_u16 --- .../src/kmx_u16.cpp => common/cpp/km_u16.cpp | 2 +- .../src/kmx_u16.h => common/include/km_u16.h | 0 developer/src/kmcmplib/src/CasedKeys.cpp | 5 +++-- developer/src/kmcmplib/src/CheckForDuplicates.cpp | 2 +- developer/src/kmcmplib/src/Compiler.cpp | 2 +- developer/src/kmcmplib/src/meson.build | 2 +- developer/src/kmcmplib/src/pch.h | 2 +- .../src/kmcmplib/tests/gtest-compiler-test.cpp | 2 +- ...test-kmx_u16-test.cpp => gtest-km_u16-test.cpp} | 14 +++++++------- developer/src/kmcmplib/tests/meson.build | 4 ++-- developer/src/kmcmplib/tests/util_filesystem.h | 2 +- 11 files changed, 19 insertions(+), 18 deletions(-) rename developer/src/kmcmplib/src/kmx_u16.cpp => common/cpp/km_u16.cpp (99%) rename developer/src/kmcmplib/src/kmx_u16.h => common/include/km_u16.h (100%) rename developer/src/kmcmplib/tests/{gtest-kmx_u16-test.cpp => gtest-km_u16-test.cpp} (94%) diff --git a/developer/src/kmcmplib/src/kmx_u16.cpp b/common/cpp/km_u16.cpp similarity index 99% rename from developer/src/kmcmplib/src/kmx_u16.cpp rename to common/cpp/km_u16.cpp index 884ddc663e..84a6c4a75e 100644 --- a/developer/src/kmcmplib/src/kmx_u16.cpp +++ b/common/cpp/km_u16.cpp @@ -6,7 +6,7 @@ #include #include "utfcodec.hpp" -#include "kmx_u16.h" +#include "km_u16.h" /** string <- wstring * @brief Obtain a std::string from a std::wstring diff --git a/developer/src/kmcmplib/src/kmx_u16.h b/common/include/km_u16.h similarity index 100% rename from developer/src/kmcmplib/src/kmx_u16.h rename to common/include/km_u16.h diff --git a/developer/src/kmcmplib/src/CasedKeys.cpp b/developer/src/kmcmplib/src/CasedKeys.cpp index 0a0508f11a..0883c401ce 100644 --- a/developer/src/kmcmplib/src/CasedKeys.cpp +++ b/developer/src/kmcmplib/src/CasedKeys.cpp @@ -1,13 +1,14 @@ #include "pch.h" +#include "km_u16.h" +#include "../../../../common/windows/cpp/include/vkeys.h" + #include "compfile.h" #include "kmn_compiler_errors.h" -#include "../../../../common/windows/cpp/include/vkeys.h" #include "kmcmplib.h" #include "CharToKeyConversion.h" -#include "kmx_u16.h" #include "xstring.h" namespace kmcmp { diff --git a/developer/src/kmcmplib/src/CheckForDuplicates.cpp b/developer/src/kmcmplib/src/CheckForDuplicates.cpp index 9e5d63b9ef..e0fa0094bc 100644 --- a/developer/src/kmcmplib/src/CheckForDuplicates.cpp +++ b/developer/src/kmcmplib/src/CheckForDuplicates.cpp @@ -1,11 +1,11 @@ #include "pch.h" +#include #include "compfile.h" #include #include "kmcmplib.h" #include -#include "kmx_u16.h" #include #include "CheckForDuplicates.h" diff --git a/developer/src/kmcmplib/src/Compiler.cpp b/developer/src/kmcmplib/src/Compiler.cpp index 03f3982366..3893a72855 100644 --- a/developer/src/kmcmplib/src/Compiler.cpp +++ b/developer/src/kmcmplib/src/Compiler.cpp @@ -102,7 +102,7 @@ #include "UnreachableRules.h" #include "CheckForDuplicates.h" -#include "kmx_u16.h" +#include "km_u16.h" /* These macros are adapted from winnt.h and legacy use only */ #define MAKELANGID(p, s) ((((uint16_t)(s)) << 10) | (uint16_t)(p)) diff --git a/developer/src/kmcmplib/src/meson.build b/developer/src/kmcmplib/src/meson.build index 260df09b83..51acf70409 100644 --- a/developer/src/kmcmplib/src/meson.build +++ b/developer/src/kmcmplib/src/meson.build @@ -78,13 +78,13 @@ lib = library('kmcmplib', 'cp1252.cpp', 'DeprecationChecks.cpp', 'Edition.cpp', - 'kmx_u16.cpp', 'NamedCodeConstants.cpp', 'UnreachableRules.cpp', 'uset-api.cpp', 'versioning.cpp', 'virtualcharkeys.cpp', 'xstring.cpp', + '../../../../common/cpp/km_u16.cpp', '../../../../common/cpp/utfcodec.cpp', '../../../../common/windows/cpp/src/ConvertUTF.c', '../../../../common/windows/cpp/src/crc32.cpp', diff --git a/developer/src/kmcmplib/src/pch.h b/developer/src/kmcmplib/src/pch.h index 358e28998a..80bb639fb8 100644 --- a/developer/src/kmcmplib/src/pch.h +++ b/developer/src/kmcmplib/src/pch.h @@ -4,7 +4,7 @@ #define USE_CHAR16_T #include -#include "kmx_u16.h" +#include #include #include "../../../../common/windows/cpp/include/crc32.h" diff --git a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp index 22b38dccc6..1c20597645 100644 --- a/developer/src/kmcmplib/tests/gtest-compiler-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-compiler-test.cpp @@ -1,7 +1,7 @@ #include +#include #include "../include/kmcompx.h" #include "../include/kmcmplibapi.h" -#include "../src/kmx_u16.h" #include "../src/compfile.h" #include "../src/CompilerErrors.h" #include "../../common/include/kmn_compiler_errors.h" diff --git a/developer/src/kmcmplib/tests/gtest-kmx_u16-test.cpp b/developer/src/kmcmplib/tests/gtest-km_u16-test.cpp similarity index 94% rename from developer/src/kmcmplib/tests/gtest-kmx_u16-test.cpp rename to developer/src/kmcmplib/tests/gtest-km_u16-test.cpp index aa1dca1de0..b67957bd31 100644 --- a/developer/src/kmcmplib/tests/gtest-kmx_u16-test.cpp +++ b/developer/src/kmcmplib/tests/gtest-km_u16-test.cpp @@ -1,9 +1,9 @@ #include -#include "../src/kmx_u16.h" +#include +#include #include "../src/compfile.h" -#include "../../../../common/include/km_types.h" -TEST(kmx_u16_Test, u16chr) { +TEST(km_u16_Test, u16chr) { KMX_WCHAR str[LINESIZE]; u16cpy(str, u"abc"); @@ -14,7 +14,7 @@ TEST(kmx_u16_Test, u16chr) { EXPECT_EQ(3, u16chr(str, '\0') - str); // locate null terminator } -TEST(kmx_u16_Test, u16chr_compare_to_strchr) { +TEST(km_u16_Test, u16chr_compare_to_strchr) { // Compare behaviour of strchr: char str[LINESIZE]; @@ -26,7 +26,7 @@ TEST(kmx_u16_Test, u16chr_compare_to_strchr) { EXPECT_EQ(3, strchr(str, '\0') - str); // locate null terminator } -TEST(kmx_u16_Test, u16tok_char_delim) { +TEST(km_u16_Test, u16tok_char_delim) { // For char delimiter: KMX_WCHAR * u16tok(KMX_WCHAR *p, const KMX_WCHAR ch, KMX_WCHAR **ctx) ; KMX_WCHAR str[LINESIZE]; @@ -67,7 +67,7 @@ TEST(kmx_u16_Test, u16tok_char_delim) { EXPECT_TRUE(!u16cmp(u"def", ctx)); } -TEST(kmx_u16_Test, u16tok_str_delim) { +TEST(km_u16_Test, u16tok_str_delim) { // For string delimiter: KMX_WCHAR * u16tok(KMX_WCHAR* p, const KMX_WCHAR* ch, KMX_WCHAR** ctx) ; KMX_WCHAR str[LINESIZE]; @@ -126,7 +126,7 @@ TEST(kmx_u16_Test, u16tok_str_delim) { EXPECT_EQ(nullptr, ctx); } -TEST(kmx_u16_Test, u16tok_str_compare_to_strtok) { +TEST(km_u16_Test, u16tok_str_compare_to_strtok) { // Compare behaviour of strtok: char str[LINESIZE]; diff --git a/developer/src/kmcmplib/tests/meson.build b/developer/src/kmcmplib/tests/meson.build index a5b6476c88..65915d1e9d 100644 --- a/developer/src/kmcmplib/tests/meson.build +++ b/developer/src/kmcmplib/tests/meson.build @@ -168,7 +168,7 @@ gtestcompilertest = executable('gtest-compiler-test', 'gtest-compiler-test.cpp', test('gtest-compiler-test', gtestcompilertest) -gtestkmx_u16test = executable('gtest-kmx_u16-test', 'gtest-kmx_u16-test.cpp', +gtest_km_u16_test = executable('gtest-km_u16-test', 'gtest-km_u16-test.cpp', cpp_args: defns + flags, include_directories: inc, name_suffix: name_suffix, @@ -177,4 +177,4 @@ gtestkmx_u16test = executable('gtest-kmx_u16-test', 'gtest-kmx_u16-test.cpp', dependencies: [ icuuc_dep, gtest_dep, gmock_dep ], ) -test('gtest-kmx_u16-test', gtestkmx_u16test) +test('gtest-km_u16-test', gtest_km_u16_test) diff --git a/developer/src/kmcmplib/tests/util_filesystem.h b/developer/src/kmcmplib/tests/util_filesystem.h index 0e183b1a6f..c35967b05e 100644 --- a/developer/src/kmcmplib/tests/util_filesystem.h +++ b/developer/src/kmcmplib/tests/util_filesystem.h @@ -1,7 +1,7 @@ #pragma once #include -#include "../src/kmx_u16.h" +#include // Opens files on windows and non-windows platforms. Datatypes for Filename and mode must be the same. // returns FILE* if file could be opened; FILE needs to be closed in calling function