/* * Copyright 2021 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "include/private/base/SkFeatures.h" // IWYU pragma: keep #include "modules/skunicode/src/SkUnicode_icupriv.h" #include #include #include #include #include #include namespace { // ubrk_clone added as draft in ICU69 and Android API 31 (first ICU NDK). // ubrk_safeClone deprecated in ICU69 and not exposed by Android. template struct SkUbrkClone { static UBreakIterator* clone(T bi, UErrorCode* status) { return ubrk_safeClone(bi, nullptr, nullptr, status); } }; template struct SkUbrkClone(), nullptr))>> { static UBreakIterator* clone(T bi, UErrorCode* status) { return ubrk_clone(bi, status); } }; // ubrk_getLocaleByType has been in ICU since version 2.8 // However, it was not included in the Android NDK template struct SkUbrkGetLocaleByType { static const char* getLocaleByType(T bi, ULocDataLocaleType type, UErrorCode* status) { *status = U_UNSUPPORTED_ERROR; return nullptr; } }; template struct SkUbrkGetLocaleByType< T, std::void_t(), std::declval(), nullptr))>> { static const char* getLocaleByType(T bi, ULocDataLocaleType type, UErrorCode* status) { return ubrk_getLocaleByType(bi, type, status); } }; } // namespace #define SKICU_FUNC(funcname) funcname, std::unique_ptr SkLoadICULib() { return std::make_unique(SkICULib{ SKICU_EMIT_FUNCS &SkUbrkClone::clone, nullptr, &SkUbrkGetLocaleByType::getLocaleByType, }); }