Skip to content

Commit a97b51e

Browse files
Introduce new API grapheme_line_segmenter to replace scan API
Signed-off-by: Christian Parpart <[email protected]>
1 parent 943bb41 commit a97b51e

12 files changed

+1666
-24
lines changed

src/libunicode/CMakeLists.txt

+4-5
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,18 @@ add_library(unicode ${LIBUNICODE_LIB_MODE}
114114
)
115115

116116
if(LIBUNICODE_USE_STD_SIMD)
117-
target_compile_definitions(unicode PRIVATE LIBUNICODE_USE_STD_SIMD)
117+
target_compile_definitions(unicode PUBLIC LIBUNICODE_USE_STD_SIMD)
118118
endif()
119119
if(LIBUNICODE_USE_INTRINSICS)
120-
target_compile_definitions(unicode PRIVATE USE_INTRINSICS)
120+
target_compile_definitions(unicode PUBLIC LIBUNICODE_USE_INTRINSICS)
121121
endif()
122122

123123
set(public_headers
124124
capi.h
125125
codepoint_properties.h
126126
convert.h
127127
emoji_segmenter.h
128+
grapheme_line_segmenter.h
128129
grapheme_segmenter.h
129130
intrinsics.h
130131
multistage_table_view.h
@@ -161,7 +162,6 @@ add_executable(unicode_tablegen tablegen.cpp)
161162
set_target_properties(unicode_tablegen PROPERTIES CMAKE_BUILD_TYPE Release)
162163
target_link_libraries(unicode_tablegen PRIVATE unicode::loader)
163164

164-
165165
# {{{ installation
166166
set(LIBUNICODE_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/libunicode" CACHE PATH "Installation directory for cmake files, a relative path that will be joined with ${CMAKE_INSTALL_PREFIX} or an absolute path.")
167167
set(LIBUNICODE_INSTALL_CMAKE_FILES ${MASTER_PROJECT} CACHE BOOL "Decides whether or not to install CMake config and -version files.")
@@ -220,6 +220,7 @@ if(LIBUNICODE_TESTING)
220220
capi_test.cpp
221221
convert_test.cpp
222222
emoji_segmenter_test.cpp
223+
grapheme_line_segmenter_test.cpp
223224
grapheme_segmenter_test.cpp
224225
run_segmenter_test.cpp
225226
scan_test.cpp
@@ -247,8 +248,6 @@ if(LIBUNICODE_TESTING)
247248
endif()
248249
# }}}
249250

250-
251-
252251
# {{{ unicode_test
253252
if(LIBUNICODE_BENCHMARK)
254253
if(NOT benchmark_FOUND)

src/libunicode/capi.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int u32_gc_width(u32_char_t const* codepoints, size_t size, int mode)
4949
while (segmenter.codepointsAvailable())
5050
{
5151
auto const cluster = *segmenter;
52-
int thisWidth = unicode::width(cluster.front());
52+
int thisWidth = static_cast<int>(unicode::width(cluster.front()));
5353
if (mode != GC_WIDTH_MODE_NON_MODIFIABLE)
5454
{
5555
for (size_t i = 1; i < size; ++i)
@@ -60,7 +60,7 @@ int u32_gc_width(u32_char_t const* codepoints, size_t size, int mode)
6060
{
6161
case 0xFE0E: return 1;
6262
case 0xFE0F: return 2;
63-
default: return unicode::width(codepoint);
63+
default: return static_cast<int>(unicode::width(codepoint));
6464
}
6565
}();
6666
if (width && width != thisWidth)

0 commit comments

Comments
 (0)