summaryrefslogtreecommitdiff
path: root/src/hb-ucdn.cc
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2018-04-03 14:01:34 +0900
committerYoungbok Shin <youngb.shin@samsung.com>2018-04-03 14:01:34 +0900
commit1c272a48507bb3c7905aa30d8bf0d092b474f781 (patch)
treeba3189af507d7357414e13ec3c4351cafdd2aea4 /src/hb-ucdn.cc
parente3a9d0d2fe726180a0456893d22d4aaa3ddb8931 (diff)
downloadharfbuzz-1c272a48507bb3c7905aa30d8bf0d092b474f781.tar.gz
harfbuzz-1c272a48507bb3c7905aa30d8bf0d092b474f781.tar.bz2
harfbuzz-1c272a48507bb3c7905aa30d8bf0d092b474f781.zip
Imported Upstream version 1.7.6upstream/1.7.6
Diffstat (limited to 'src/hb-ucdn.cc')
-rw-r--r--src/hb-ucdn.cc62
1 files changed, 46 insertions, 16 deletions
diff --git a/src/hb-ucdn.cc b/src/hb-ucdn.cc
index a884e3f..9515bda 100644
--- a/src/hb-ucdn.cc
+++ b/src/hb-ucdn.cc
@@ -160,17 +160,23 @@ static const hb_script_t ucdn_script_translate[] =
HB_SCRIPT_NEWA,
HB_SCRIPT_OSAGE,
HB_SCRIPT_TANGUT,
+ HB_SCRIPT_MASARAM_GONDI,
+ HB_SCRIPT_NUSHU,
+ HB_SCRIPT_SOYOMBO,
+ HB_SCRIPT_ZANABAZAR_SQUARE,
};
static hb_unicode_combining_class_t
-hb_ucdn_combining_class(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
+hb_ucdn_combining_class(hb_unicode_funcs_t *ufuncs HB_UNUSED,
+ hb_codepoint_t unicode,
void *user_data HB_UNUSED)
{
return (hb_unicode_combining_class_t) ucdn_get_combining_class(unicode);
}
static unsigned int
-hb_ucdn_eastasian_width(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
+hb_ucdn_eastasian_width(hb_unicode_funcs_t *ufuncs HB_UNUSED,
+ hb_codepoint_t unicode,
void *user_data HB_UNUSED)
{
int w = ucdn_get_east_asian_width(unicode);
@@ -178,28 +184,31 @@ hb_ucdn_eastasian_width(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
}
static hb_unicode_general_category_t
-hb_ucdn_general_category(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
+hb_ucdn_general_category(hb_unicode_funcs_t *ufuncs HB_UNUSED,
+ hb_codepoint_t unicode,
void *user_data HB_UNUSED)
{
return (hb_unicode_general_category_t)ucdn_get_general_category(unicode);
}
static hb_codepoint_t
-hb_ucdn_mirroring(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
+hb_ucdn_mirroring(hb_unicode_funcs_t *ufuncs HB_UNUSED,
+ hb_codepoint_t unicode,
void *user_data HB_UNUSED)
{
return ucdn_mirror(unicode);
}
static hb_script_t
-hb_ucdn_script(hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode,
+hb_ucdn_script(hb_unicode_funcs_t *ufuncs HB_UNUSED,
+ hb_codepoint_t unicode,
void *user_data HB_UNUSED)
{
return ucdn_script_translate[ucdn_get_script(unicode)];
}
static hb_bool_t
-hb_ucdn_compose(hb_unicode_funcs_t *ufuncs,
+hb_ucdn_compose(hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t a, hb_codepoint_t b, hb_codepoint_t *ab,
void *user_data HB_UNUSED)
{
@@ -207,7 +216,7 @@ hb_ucdn_compose(hb_unicode_funcs_t *ufuncs,
}
static hb_bool_t
-hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs,
+hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t ab, hb_codepoint_t *a, hb_codepoint_t *b,
void *user_data HB_UNUSED)
{
@@ -215,29 +224,50 @@ hb_ucdn_decompose(hb_unicode_funcs_t *ufuncs,
}
static unsigned int
-hb_ucdn_decompose_compatibility(hb_unicode_funcs_t *ufuncs,
+hb_ucdn_decompose_compatibility(hb_unicode_funcs_t *ufuncs HB_UNUSED,
hb_codepoint_t u, hb_codepoint_t *decomposed,
void *user_data HB_UNUSED)
{
return ucdn_compat_decompose(u, decomposed);
}
+static hb_unicode_funcs_t *static_ucdn_funcs = nullptr;
+
+#ifdef HB_USE_ATEXIT
+static
+void free_static_ucdn_funcs (void)
+{
+ hb_unicode_funcs_destroy (static_ucdn_funcs);
+}
+#endif
+
extern "C" HB_INTERNAL
hb_unicode_funcs_t *
hb_ucdn_get_unicode_funcs (void)
{
- static const hb_unicode_funcs_t _hb_ucdn_unicode_funcs = {
- HB_OBJECT_HEADER_STATIC,
+retry:
+ hb_unicode_funcs_t *funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get (&static_ucdn_funcs);
+
+ if (unlikely (!funcs))
+ {
+ funcs = hb_unicode_funcs_create (nullptr);
- NULL, /* parent */
- true, /* immutable */
- {
-#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_ucdn_##name,
+#define HB_UNICODE_FUNC_IMPLEMENT(name) \
+ hb_unicode_funcs_set_##name##_func (funcs, hb_ucdn_##name, nullptr, nullptr);
HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
#undef HB_UNICODE_FUNC_IMPLEMENT
+
+ hb_unicode_funcs_make_immutable (funcs);
+
+ if (!hb_atomic_ptr_cmpexch (&static_ucdn_funcs, nullptr, funcs)) {
+ hb_unicode_funcs_destroy (funcs);
+ goto retry;
}
+
+#ifdef HB_USE_ATEXIT
+ atexit (free_static_ucdn_funcs); /* First person registers atexit() callback. */
+#endif
};
- return const_cast<hb_unicode_funcs_t *> (&_hb_ucdn_unicode_funcs);
+ return hb_unicode_funcs_reference (funcs);
}
-