[pango] [HB] Flesh out Unicode funcs



commit f2fab897d32061d9a0329384cd4b0fd71748ea97
Author: Behdad Esfahbod <behdad behdad org>
Date:   Mon Aug 10 22:58:56 2009 -0400

    [HB] Flesh out Unicode funcs

 pango/opentype/hb-object-private.h  |    2 +-
 pango/opentype/hb-unicode-private.h |   12 +++----
 pango/opentype/hb-unicode.c         |   67 ++++++++++++++++++++++++++++++----
 pango/opentype/hb-unicode.h         |    3 --
 4 files changed, 65 insertions(+), 19 deletions(-)
---
diff --git a/pango/opentype/hb-object-private.h b/pango/opentype/hb-object-private.h
index 4f4c3de..2186e58 100644
--- a/pango/opentype/hb-object-private.h
+++ b/pango/opentype/hb-object-private.h
@@ -56,7 +56,7 @@ typedef struct {
 /* Helper macros */
 
 #define HB_OBJECT_IS_INERT(obj) \
-    (HB_REFERENCE_COUNT_IS_INVALID ((obj)->ref_count))
+    (HB_UNLIKELY (HB_REFERENCE_COUNT_IS_INVALID ((obj)->ref_count)))
 
 #define HB_OBJECT_DO_INIT_EXPR(obj) \
     HB_REFERENCE_COUNT_INIT (obj->ref_count, 1)
diff --git a/pango/opentype/hb-unicode-private.h b/pango/opentype/hb-unicode-private.h
index de71083..3dd528c 100644
--- a/pango/opentype/hb-unicode-private.h
+++ b/pango/opentype/hb-unicode-private.h
@@ -40,13 +40,11 @@ HB_BEGIN_DECLS
 struct _hb_unicode_funcs_t {
   hb_reference_count_t ref_count;
 
-  /*
-  hb_unicode_get_general_category_func_t general_category_func);
-  hb_unicode_get_combining_class_func_t combining_class_func);
-  hb_unicode_get_mirroring_char_func_t mirroring_char_func);
-  hb_unicode_get_script_func_t script_func);
-  hb_unicode_get_eastasian_width_func_t eastasian_width_func);
-  */
+  hb_unicode_get_general_category_func_t	get_general_category;
+  hb_unicode_get_combining_class_func_t		get_combining_class;
+  hb_unicode_get_mirroring_char_func_t		get_mirroring_char;
+  hb_unicode_get_script_func_t			get_script;
+  hb_unicode_get_eastasian_width_func_t		get_eastasian_width;
 };
 
 HB_END_DECLS
diff --git a/pango/opentype/hb-unicode.c b/pango/opentype/hb-unicode.c
index ecb4148..46b90b8 100644
--- a/pango/opentype/hb-unicode.c
+++ b/pango/opentype/hb-unicode.c
@@ -33,14 +33,13 @@
  */
 
 static hb_unicode_funcs_t _hb_unicode_funcs_nil = {
-  HB_REFERENCE_COUNT_INVALID /* ref_count */
-  /*
-  hb_unicode_get_general_category_func_t general_category_func);
-  hb_unicode_get_combining_class_func_t combining_class_func);
-  hb_unicode_get_mirroring_char_func_t mirroring_char_func);
-  hb_unicode_get_script_func_t script_func);
-  hb_unicode_get_eastasian_width_func_t eastasian_width_func);
-  */
+  HB_REFERENCE_COUNT_INVALID, /* ref_count */
+
+  NULL, /*get_general_category */
+  NULL, /*get_combining_class */
+  NULL, /*get_mirroring_char */
+  NULL, /*get_script */
+  NULL  /*get_eastasian_width */
 };
 
 hb_unicode_funcs_t *
@@ -87,3 +86,55 @@ hb_unicode_funcs_copy (hb_unicode_funcs_t *other_ufuncs)
 
   return ufuncs;
 }
+
+
+void
+hb_unicode_funcs_set_mirroring_char_func (hb_unicode_funcs_t *ufuncs,
+					  hb_unicode_get_mirroring_char_func_t mirroring_char_func)
+{
+  if (HB_OBJECT_IS_INERT (ufuncs))
+    return;
+
+  ufuncs->get_mirroring_char = mirroring_char_func;
+}
+
+void
+hb_unicode_funcs_set_general_category_func (hb_unicode_funcs_t *ufuncs,
+					    hb_unicode_get_general_category_func_t general_category_func)
+{
+  if (HB_OBJECT_IS_INERT (ufuncs))
+    return;
+
+  ufuncs->get_general_category = general_category_func;
+}
+
+void
+hb_unicode_funcs_set_script_func (hb_unicode_funcs_t *ufuncs,
+				  hb_unicode_get_script_func_t script_func)
+{
+  if (HB_OBJECT_IS_INERT (ufuncs))
+    return;
+
+  ufuncs->get_script = script_func;
+}
+
+void
+hb_unicode_funcs_set_combining_class_func (hb_unicode_funcs_t *ufuncs,
+					   hb_unicode_get_combining_class_func_t combining_class_func)
+{
+  if (HB_OBJECT_IS_INERT (ufuncs))
+    return;
+
+  ufuncs->get_combining_class = combining_class_func;
+}
+
+void
+hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
+					   hb_unicode_get_eastasian_width_func_t eastasian_width_func)
+{
+  if (HB_OBJECT_IS_INERT (ufuncs))
+    return;
+
+  ufuncs->get_eastasian_width = eastasian_width_func;
+}
+
diff --git a/pango/opentype/hb-unicode.h b/pango/opentype/hb-unicode.h
index 51b00db..5d8431c 100644
--- a/pango/opentype/hb-unicode.h
+++ b/pango/opentype/hb-unicode.h
@@ -184,7 +184,6 @@ hb_unicode_funcs_copy (hb_unicode_funcs_t *ufuncs);
 
 /* funcs */
 
-#if 0
 typedef hb_codepoint_t (*hb_unicode_get_mirroring_char_func_t) (hb_codepoint_t unicode);
 typedef hb_category_t (*hb_unicode_get_general_category_func_t) (hb_codepoint_t unicode);
 typedef hb_script_t (*hb_unicode_get_script_func_t) (hb_codepoint_t unicode);
@@ -212,8 +211,6 @@ void
 hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs,
 					   hb_unicode_get_eastasian_width_func_t eastasian_width_func);
 
-#endif
-
 
 HB_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]