More normalization kick
[framework/uifw/harfbuzz.git] / src / hb-unicode.cc
index 8ca178e..aba2cd3 100644 (file)
@@ -39,19 +39,67 @@ HB_BEGIN_DECLS
  * hb_unicode_funcs_t
  */
 
-#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name, default_value)            \
-                                                                               \
-                                                                               \
-static return_type                                                             \
-hb_unicode_get_##name##_nil (hb_unicode_funcs_t *ufuncs    HB_UNUSED,          \
-                            hb_codepoint_t      unicode   HB_UNUSED,           \
-                            void               *user_data HB_UNUSED)           \
-{                                                                              \
-  return default_value;                                                                \
+static unsigned int
+hb_unicode_combining_class_nil (hb_unicode_funcs_t *ufuncs    HB_UNUSED,
+                               hb_codepoint_t      unicode   HB_UNUSED,
+                               void               *user_data HB_UNUSED)
+{
+  return 0;
 }
 
-  HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
-#undef HB_UNICODE_FUNC_IMPLEMENT
+static unsigned int
+hb_unicode_eastasian_width_nil (hb_unicode_funcs_t *ufuncs    HB_UNUSED,
+                               hb_codepoint_t      unicode   HB_UNUSED,
+                               void               *user_data HB_UNUSED)
+{
+  return 1;
+}
+
+static hb_unicode_general_category_t
+hb_unicode_general_category_nil (hb_unicode_funcs_t *ufuncs    HB_UNUSED,
+                                hb_codepoint_t      unicode   HB_UNUSED,
+                                void               *user_data HB_UNUSED)
+{
+  return HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER;
+}
+
+static hb_codepoint_t
+hb_unicode_mirroring_nil (hb_unicode_funcs_t *ufuncs    HB_UNUSED,
+                         hb_codepoint_t      unicode   HB_UNUSED,
+                         void               *user_data HB_UNUSED)
+{
+  return unicode;
+}
+
+static hb_script_t
+hb_unicode_script_nil (hb_unicode_funcs_t *ufuncs    HB_UNUSED,
+                      hb_codepoint_t      unicode   HB_UNUSED,
+                      void               *user_data HB_UNUSED)
+{
+  return HB_SCRIPT_UNKNOWN;
+}
+
+static hb_bool_t
+hb_unicode_compose_nil (hb_unicode_funcs_t *ufuncs    HB_UNUSED,
+                       hb_codepoint_t      a         HB_UNUSED,
+                       hb_codepoint_t      b         HB_UNUSED,
+                       hb_codepoint_t     *ab        HB_UNUSED,
+                       void               *user_data HB_UNUSED)
+{
+  /* TODO handle Hangul jamo here? */
+  return FALSE;
+}
+
+static hb_bool_t
+hb_unicode_decompose_nil (hb_unicode_funcs_t *ufuncs    HB_UNUSED,
+                         hb_codepoint_t      ab        HB_UNUSED,
+                         hb_codepoint_t     *a         HB_UNUSED,
+                         hb_codepoint_t     *b         HB_UNUSED,
+                         void               *user_data HB_UNUSED)
+{
+  /* TODO handle Hangul jamo here? */
+  return FALSE;
+}
 
 
 hb_unicode_funcs_t _hb_unicode_funcs_nil = {
@@ -60,7 +108,7 @@ hb_unicode_funcs_t _hb_unicode_funcs_nil = {
   NULL, /* parent */
   TRUE, /* immutable */
   {
-#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name, default_value) hb_unicode_get_##name##_nil,
+#define HB_UNICODE_FUNC_IMPLEMENT(name) hb_unicode_##name##_nil,
     HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
 #undef HB_UNICODE_FUNC_IMPLEMENT
   }
@@ -87,7 +135,7 @@ hb_unicode_funcs_create (hb_unicode_funcs_t *parent)
   hb_unicode_funcs_make_immutable (parent);
   ufuncs->parent = hb_unicode_funcs_reference (parent);
 
-  ufuncs->get = parent->get;
+  ufuncs->func = parent->func;
 
   /* We can safely copy user_data from parent since we hold a reference
    * onto it and it's immutable.  We should not copy the destroy notifiers
@@ -114,7 +162,7 @@ hb_unicode_funcs_destroy (hb_unicode_funcs_t *ufuncs)
 {
   if (!hb_object_destroy (ufuncs)) return;
 
-#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name, default_value) \
+#define HB_UNICODE_FUNC_IMPLEMENT(name) \
   if (ufuncs->destroy.name) ufuncs->destroy.name (ufuncs->user_data.name);
     HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
 #undef HB_UNICODE_FUNC_IMPLEMENT
@@ -163,11 +211,11 @@ hb_unicode_funcs_get_parent (hb_unicode_funcs_t *ufuncs)
 }
 
 
-#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name, default_value)            \
+#define HB_UNICODE_FUNC_IMPLEMENT(name)                                                \
                                                                                \
 void                                                                           \
 hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t            *ufuncs,     \
-                                   hb_unicode_get_##name##_func_t  func,       \
+                                   hb_unicode_##name##_func_t      func,       \
                                    void                           *user_data,  \
                                    hb_destroy_func_t               destroy)    \
 {                                                                              \
@@ -178,25 +226,49 @@ hb_unicode_funcs_set_##name##_func (hb_unicode_funcs_t               *ufuncs,     \
     ufuncs->destroy.name (ufuncs->user_data.name);                             \
                                                                                \
   if (func) {                                                                  \
-    ufuncs->get.name = func;                                                   \
+    ufuncs->func.name = func;                                                  \
     ufuncs->user_data.name = user_data;                                                \
     ufuncs->destroy.name = destroy;                                            \
   } else {                                                                     \
-    ufuncs->get.name = ufuncs->parent->get.name;                               \
+    ufuncs->func.name = ufuncs->parent->func.name;                             \
     ufuncs->user_data.name = ufuncs->parent->user_data.name;                   \
     ufuncs->destroy.name = NULL;                                               \
   }                                                                            \
-}                                                                              \
+}
+
+    HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
+#undef HB_UNICODE_FUNC_IMPLEMENT
+
+
+#define HB_UNICODE_FUNC_IMPLEMENT(return_type, name)                           \
                                                                                \
 return_type                                                                    \
-hb_unicode_get_##name (hb_unicode_funcs_t *ufuncs,                             \
-                      hb_codepoint_t      unicode)                             \
+hb_unicode_##name (hb_unicode_funcs_t *ufuncs,                                 \
+                  hb_codepoint_t      unicode)                                 \
 {                                                                              \
-  return ufuncs->get.name (ufuncs, unicode, ufuncs->user_data.name);           \
+  return ufuncs->func.name (ufuncs, unicode, ufuncs->user_data.name);          \
 }
-
-    HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS
+    HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
 #undef HB_UNICODE_FUNC_IMPLEMENT
 
+hb_bool_t
+hb_unicode_compose (hb_unicode_funcs_t *ufuncs,
+                   hb_codepoint_t      a,
+                   hb_codepoint_t      b,
+                   hb_codepoint_t     *ab)
+{
+  *ab = 0;
+  return ufuncs->func.compose (ufuncs, a, b, ab, ufuncs->user_data.compose);
+}
+
+hb_bool_t
+hb_unicode_decompose (hb_unicode_funcs_t *ufuncs,
+                     hb_codepoint_t      ab,
+                     hb_codepoint_t     *a,
+                     hb_codepoint_t     *b)
+{
+  *a = ab; *b = 0;
+  return ufuncs->func.decompose (ufuncs, ab, a, b, ufuncs->user_data.decompose);
+}
 
 HB_END_DECLS