[core][android] Remove unaccent from platform interfaces
The unaccent is used only within collator, thus, there is no need to have separate platform interface for it.
This commit is contained in:
@@ -195,7 +195,6 @@ target_sources(
|
||||
${MBGL_ROOT}/platform/android/src/text/local_glyph_rasterizer_jni.hpp
|
||||
${MBGL_ROOT}/platform/android/src/thread.cpp
|
||||
${MBGL_ROOT}/platform/android/src/timer.cpp
|
||||
${MBGL_ROOT}/platform/android/src/unaccent.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/gfx/headless_backend.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/gfx/headless_frontend.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/gl/headless_backend.cpp
|
||||
|
||||
@@ -31,7 +31,6 @@ target_sources(
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/text/bidi.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/text/collator.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/text/local_glyph_rasterizer.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/text/unaccent.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/util/async_task.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/util/compression.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/util/format_number.cpp
|
||||
|
||||
@@ -26,7 +26,6 @@ target_sources(
|
||||
${MBGL_ROOT}/platform/default/include/mbgl/gfx/headless_backend.hpp
|
||||
${MBGL_ROOT}/platform/default/include/mbgl/gfx/headless_frontend.hpp
|
||||
${MBGL_ROOT}/platform/default/include/mbgl/gl/headless_backend.hpp
|
||||
${MBGL_ROOT}/platform/default/include/mbgl/text/unaccent.hpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/gfx/headless_backend.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/gfx/headless_frontend.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/gl/headless_backend.cpp
|
||||
@@ -43,7 +42,6 @@ target_sources(
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/storage/online_file_source.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/storage/sqlite3.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/text/collator.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/text/unaccent.cpp
|
||||
${MBGL_ROOT}/platform/default/src/mbgl/util/compression.cpp
|
||||
${MBGL_ROOT}/platform/qt/src/async_task.cpp
|
||||
${MBGL_ROOT}/platform/qt/src/async_task_impl.hpp
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
"platform/android/src/gl_functions.cpp",
|
||||
"platform/android/src/thread.cpp",
|
||||
"platform/android/src/timer.cpp",
|
||||
"platform/android/src/unaccent.cpp",
|
||||
"platform/default/src/mbgl/gfx/headless_backend.cpp",
|
||||
"platform/default/src/mbgl/gfx/headless_frontend.cpp",
|
||||
"platform/default/src/mbgl/gl/headless_backend.cpp",
|
||||
@@ -103,8 +102,7 @@
|
||||
"mbgl/gfx/headless_backend.hpp": "platform/default/include/mbgl/gfx/headless_backend.hpp",
|
||||
"mbgl/gfx/headless_frontend.hpp": "platform/default/include/mbgl/gfx/headless_frontend.hpp",
|
||||
"mbgl/gl/headless_backend.hpp": "platform/default/include/mbgl/gl/headless_backend.hpp",
|
||||
"mbgl/map/map_snapshotter.hpp": "platform/default/include/mbgl/map/map_snapshotter.hpp",
|
||||
"mbgl/text/unaccent.hpp": "platform/default/include/mbgl/text/unaccent.hpp"
|
||||
"mbgl/map/map_snapshotter.hpp": "platform/default/include/mbgl/map/map_snapshotter.hpp"
|
||||
},
|
||||
"private_headers": {
|
||||
"android_renderer_backend.hpp": "platform/android/src/android_renderer_backend.hpp",
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include <mbgl/text/language_tag.hpp>
|
||||
#include <mbgl/util/platform.hpp>
|
||||
|
||||
#include <mbgl/text/unaccent.hpp>
|
||||
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
#include "../attach_env.hpp"
|
||||
@@ -144,12 +142,10 @@ public:
|
||||
// Because of the difference in locale-awareness, this means turning on case-sensitivity
|
||||
// can _potentially_ change compare results for strings that don't actually have any case
|
||||
// differences.
|
||||
jni::Local<jni::String> jlhs = jni::Make<jni::String>(*env, useUnaccent ?
|
||||
platform::unaccent(lhs) :
|
||||
lhs);
|
||||
jni::Local<jni::String> jrhs = jni::Make<jni::String>(*env, useUnaccent ?
|
||||
platform::unaccent(rhs) :
|
||||
rhs);
|
||||
jni::Local<jni::String> jlhs = useUnaccent ? android::StringUtils::unaccent(*env, jni::Make<jni::String>(*env, lhs))
|
||||
: jni::Make<jni::String>(*env, lhs);
|
||||
jni::Local<jni::String> jrhs = useUnaccent ? android::StringUtils::unaccent(*env, jni::Make<jni::String>(*env, rhs))
|
||||
: jni::Make<jni::String>(*env, rhs);
|
||||
|
||||
jni::jint result = android::Collator::compare(*env, collator, jlhs, jrhs);
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#include <mbgl/text/unaccent.hpp>
|
||||
#include <string>
|
||||
#include "attach_env.hpp"
|
||||
#include "text/collator_jni.hpp"
|
||||
#include <jni/jni.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace platform {
|
||||
|
||||
std::string unaccent(const std::string& str) {
|
||||
android::UniqueEnv env = android::AttachEnv();
|
||||
jni::Local<jni::String> input = jni::Make<jni::String>(*env, str);
|
||||
jni::Local<jni::String> unaccented = android::StringUtils::unaccent(*env, input);
|
||||
return jni::Make<std::string>(*env, unaccented);
|
||||
}
|
||||
|
||||
} // namespace platform
|
||||
} // namespace mbgl
|
||||
@@ -1,7 +1,10 @@
|
||||
#include <mbgl/style/expression/collator.hpp>
|
||||
#include <mbgl/util/platform.hpp>
|
||||
#include <libnu/strcoll.h>
|
||||
#include <mbgl/text/unaccent.hpp>
|
||||
#include <libnu/unaccent.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
/*
|
||||
The default implementation of Collator ignores locale.
|
||||
@@ -16,6 +19,40 @@
|
||||
but would require bundling locale data.
|
||||
*/
|
||||
|
||||
namespace {
|
||||
std::string unaccent(const std::string& str)
|
||||
{
|
||||
std::stringstream output;
|
||||
char const *itr = str.c_str(), *nitr;
|
||||
char const *end = itr + str.length();
|
||||
char lo[5] = { 0 };
|
||||
|
||||
for (; itr < end; itr = nitr)
|
||||
{
|
||||
uint32_t code_point = 0;
|
||||
char const* buf = nullptr;
|
||||
|
||||
nitr = _nu_tounaccent(itr, end, nu_utf8_read, &code_point, &buf, nullptr);
|
||||
if (buf != nullptr)
|
||||
{
|
||||
do
|
||||
{
|
||||
buf = NU_CASEMAP_DECODING_FUNCTION(buf, &code_point);
|
||||
if (code_point == 0) break;
|
||||
output.write(lo, nu_utf8_write(code_point, lo) - lo);
|
||||
}
|
||||
while (code_point != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
output.write(itr, nitr - itr);
|
||||
}
|
||||
}
|
||||
|
||||
return output.str();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace mbgl {
|
||||
namespace style {
|
||||
namespace expression {
|
||||
@@ -40,10 +77,10 @@ public:
|
||||
return nu_strcasecoll(lhs.c_str(), rhs.c_str(),
|
||||
nu_utf8_read, nu_utf8_read);
|
||||
} else if (caseSensitive && !diacriticSensitive) {
|
||||
return nu_strcoll(platform::unaccent(lhs).c_str(), platform::unaccent(rhs).c_str(),
|
||||
return nu_strcoll(unaccent(lhs).c_str(), unaccent(rhs).c_str(),
|
||||
nu_utf8_read, nu_utf8_read);
|
||||
} else {
|
||||
return nu_strcasecoll(platform::unaccent(lhs).c_str(), platform::unaccent(rhs).c_str(),
|
||||
return nu_strcasecoll(unaccent(lhs).c_str(), unaccent(rhs).c_str(),
|
||||
nu_utf8_read, nu_utf8_read);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
#include <mbgl/util/platform.hpp>
|
||||
#include <libnu/unaccent.h>
|
||||
#include <mbgl/text/unaccent.hpp>
|
||||
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
|
||||
namespace mbgl { namespace platform {
|
||||
|
||||
std::string unaccent(const std::string& str)
|
||||
{
|
||||
std::stringstream output;
|
||||
char const *itr = str.c_str(), *nitr;
|
||||
char const *end = itr + str.length();
|
||||
char lo[5] = { 0 };
|
||||
|
||||
for (; itr < end; itr = nitr)
|
||||
{
|
||||
uint32_t code_point = 0;
|
||||
char const* buf = nullptr;
|
||||
|
||||
nitr = _nu_tounaccent(itr, end, nu_utf8_read, &code_point, &buf, nullptr);
|
||||
if (buf != nullptr)
|
||||
{
|
||||
do
|
||||
{
|
||||
buf = NU_CASEMAP_DECODING_FUNCTION(buf, &code_point);
|
||||
if (code_point == 0) break;
|
||||
output.write(lo, nu_utf8_write(code_point, lo) - lo);
|
||||
}
|
||||
while (code_point != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
output.write(itr, nitr - itr);
|
||||
}
|
||||
}
|
||||
|
||||
return output.str();
|
||||
}
|
||||
|
||||
} // namespace platform
|
||||
} // namespace mbgl
|
||||
@@ -54,8 +54,6 @@ macro(mbgl_platform_core)
|
||||
PRIVATE platform/default/src/mbgl/layermanager/layer_manager.cpp
|
||||
PRIVATE platform/default/src/mbgl/text/local_glyph_rasterizer.cpp
|
||||
PRIVATE platform/default/src/mbgl/util/thread_local.cpp
|
||||
PRIVATE platform/default/src/mbgl/text/unaccent.cpp
|
||||
PRIVATE platform/default/include/mbgl/text/unaccent.hpp
|
||||
PRIVATE platform/default/src/mbgl/util/utf.cpp
|
||||
PRIVATE platform/default/src/mbgl/util/format_number.cpp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user