1 /*
2 * Copyright 2021 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "modules/skunicode/src/SkUnicode_icu.h"
9
10 #define SKICU_FUNC(funcname) funcname,
11
12 // ubrk_clone added as draft in ICU69 and Android API 31 (first ICU NDK).
13 // ubrk_safeClone deprecated in ICU69 and not exposed by Android.
14 template<typename...> using void_t = void;
15 template<typename T, typename = void>
16 struct SkUbrkClone {
cloneSkUbrkClone17 static UBreakIterator* clone(T bi, UErrorCode* status) {
18 return ubrk_safeClone(bi, nullptr, nullptr, status);
19 }
20 };
21 template<typename T>
22 struct SkUbrkClone<T, void_t<decltype(ubrk_clone(std::declval<T>(), nullptr))>> {
cloneSkUbrkClone23 static UBreakIterator* clone(T bi, UErrorCode* status) {
24 return ubrk_clone(bi, status);
25 }
26 };
27
SkLoadICULib()28 std::unique_ptr<SkICULib> SkLoadICULib() {
29
30 return std::make_unique<SkICULib>(SkICULib{
31 SKICU_EMIT_FUNCS
32
33 &SkUbrkClone<const UBreakIterator*>::clone,
34 nullptr,
35 });
36 }
37