Overview
This issue addresses compiler compatibility and runtime path resolution improvements across inflection:
-
Explicit <unicode/utf16.h> includes:
Several C++ source files use ICU UTF-16 code point macros (U16_PREV, U16_GET, U16_LENGTH, U16_NEXT) without explicitly including <unicode/utf16.h>. On strict compiler toolchains that do not transitively include ICU sub-headers, compilation fails.
-
C++17/20 Class Template Argument Deduction (CTAD) Guides:
Template classes (Finally, CompressedArray, MarisaTrie) and test code (DialogThreadSafetyTest.cpp) rely on template argument deduction. On toolchains compiling with strict C++17/20 warning options (such as -Wctad-maybe-unsupported), compiler warnings or errors are triggered. Adding explicit deduction guides for these classes and specifying explicit template arguments (std::atomic<bool>, std::barrier<>) ensures clean compilation.
-
ResourceLocator.cpp Relative Path Resolution:
In ResourceLocator::getRootForLocale(), when the INFLECTION_ROOT environment variable is unset/empty, string concatenation INFLECTION_ROOT_DIRECTORY() + u"/" + U16(INFLECTION_DATA_ROOT_DIR) + u"/inflection" evaluates with an unintended leading slash (u"/..."). This converts relative INFLECTION_DATA_ROOT_DIR paths into absolute filesystem root paths. Updating getRootForLocale to check if INFLECTION_ROOT_DIRECTORY() is empty preserves intended relative directory pathing.
Proposed Changes
Overview
This issue addresses compiler compatibility and runtime path resolution improvements across
inflection:Explicit
<unicode/utf16.h>includes:Several C++ source files use ICU UTF-16 code point macros (
U16_PREV,U16_GET,U16_LENGTH,U16_NEXT) without explicitly including<unicode/utf16.h>. On strict compiler toolchains that do not transitively include ICU sub-headers, compilation fails.C++17/20 Class Template Argument Deduction (CTAD) Guides:
Template classes (
Finally,CompressedArray,MarisaTrie) and test code (DialogThreadSafetyTest.cpp) rely on template argument deduction. On toolchains compiling with strict C++17/20 warning options (such as-Wctad-maybe-unsupported), compiler warnings or errors are triggered. Adding explicit deduction guides for these classes and specifying explicit template arguments (std::atomic<bool>,std::barrier<>) ensures clean compilation.ResourceLocator.cppRelative Path Resolution:In
ResourceLocator::getRootForLocale(), when theINFLECTION_ROOTenvironment variable is unset/empty, string concatenationINFLECTION_ROOT_DIRECTORY() + u"/" + U16(INFLECTION_DATA_ROOT_DIR) + u"/inflection"evaluates with an unintended leading slash (u"/..."). This converts relativeINFLECTION_DATA_ROOT_DIRpaths into absolute filesystem root paths. UpdatinggetRootForLocaleto check ifINFLECTION_ROOT_DIRECTORY()is empty preserves intended relative directory pathing.Proposed Changes
Header Includes: Add
#include <unicode/utf16.h>to:src/inflection/tokenizer/ControlCleaver.cppsrc/inflection/grammar/synthesis/HeGrammarSynthesizer_WithConditionalHyphen.cppsrc/inflection/grammar/synthesis/KoGrammarSynthesizer_ParticleResolver.cppsrc/inflection/grammar/synthesis/TrGrammarSynthesizer_TrDisplayFunction.cppsrc/inflection/lang/StringFilterUtil.cppsrc/inflection/tokenizer/TokenUtil.cppsrc/inflection/util/StringViewUtils.cppsrc/inflection/util/UnicodeSetUtils.cppCTAD Guides & Test Updates:
src/inflection/util/Finally.hpp: Add deduction guidetemplate <typename Function> Finally(Function) -> Finally<Function>;src/inflection/dictionary/metadata/CompressedArray.hpp: Add deduction guidetemplate <typename T> CompressedArray(const std::vector<T>&) -> CompressedArray<T>;src/inflection/dictionary/metadata/MarisaTrie.hpp: Add deduction guidetemplate <typename T> MarisaTrie(const std::map<std::u16string_view, T>&) -> MarisaTrie<T>;test/src/inflection/dialog/DialogThreadSafetyTest.cpp: Specify explicit template parameters forstd::atomic<bool>andstd::barrier<>.Path Resolution:
src/inflection/util/ResourceLocator.cpp: Check ifINFLECTION_ROOT_DIRECTORY()is empty before prependingu"/".