[Indic] Add Final Reordering rules into comments
[framework/uifw/harfbuzz.git] / src / hb-ot-shape-complex-private.hh
index bf79890..1aca595 100644 (file)
 HB_BEGIN_DECLS
 
 
-/* buffer var allocations, used by all shapers */
+/* buffer var allocations, used during the entire shaping process */
 #define general_category() var1.u8[0] /* unicode general_category (hb_unicode_general_category_t) */
 #define combining_class() var1.u8[1] /* unicode combining_class (uint8_t) */
 
+/* buffer var allocations, used by complex shapers */
+#define complex_var_persistent_u8_0()  var2.u8[0]
+#define complex_var_persistent_u8_1()  var2.u8[1]
+#define complex_var_persistent_u16()   var2.u16[0]
+#define complex_var_temporary_u8_0()   var2.u8[2]
+#define complex_var_temporary_u8_1()   var2.u8[3]
+#define complex_var_temporary_u16()    var2.u16[1]
+
+
+#define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \
+  HB_COMPLEX_SHAPER_IMPLEMENT (default) /* should be first */ \
+  HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \
+  HB_COMPLEX_SHAPER_IMPLEMENT (indic) \
+  /* ^--- Add new shapers here */
 
 enum hb_ot_complex_shaper_t {
-  hb_ot_complex_shaper_none,
-  hb_ot_complex_shaper_arabic,
-  hb_ot_complex_shaper_indic
+#define HB_COMPLEX_SHAPER_IMPLEMENT(name) hb_ot_complex_shaper_##name,
+  HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
+#undef HB_COMPLEX_SHAPER_IMPLEMENT
 };
 
 static inline hb_ot_complex_shaper_t
@@ -50,6 +64,9 @@ hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
 {
   switch ((int) props->script)
   {
+    default:
+      return hb_ot_complex_shaper_default;
+
     case HB_SCRIPT_ARABIC:
     case HB_SCRIPT_MANDAIC:
     case HB_SCRIPT_MONGOLIAN:
@@ -103,8 +120,7 @@ hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
     case HB_SCRIPT_TIBETAN:
       return hb_ot_complex_shaper_indic;
 
-    default:
-      return hb_ot_complex_shaper_none;
+    /* ^--- Add new shapers here */
   }
 }
 
@@ -119,8 +135,10 @@ hb_ot_shape_complex_categorize (const hb_segment_properties_t *props)
  */
 
 typedef void hb_ot_shape_complex_collect_features_func_t (hb_ot_map_builder_t *map, const hb_segment_properties_t  *props);
-HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_arabic;
-HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_indic;
+#define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
+  HB_INTERNAL hb_ot_shape_complex_collect_features_func_t _hb_ot_shape_complex_collect_features_##name;
+  HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
+#undef HB_COMPLEX_SHAPER_IMPLEMENT
 
 static inline void
 hb_ot_shape_complex_collect_features (hb_ot_complex_shaper_t shaper,
@@ -128,9 +146,38 @@ hb_ot_shape_complex_collect_features (hb_ot_complex_shaper_t shaper,
                                      const hb_segment_properties_t  *props)
 {
   switch (shaper) {
-    case hb_ot_complex_shaper_arabic:  _hb_ot_shape_complex_collect_features_arabic    (map, props);   return;
-    case hb_ot_complex_shaper_indic:   _hb_ot_shape_complex_collect_features_indic     (map, props);   return;
-    case hb_ot_complex_shaper_none:    default:                                                        return;
+    default:
+#define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
+    case hb_ot_complex_shaper_##name:  _hb_ot_shape_complex_collect_features_##name (map, props); return;
+    HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
+#undef HB_COMPLEX_SHAPER_IMPLEMENT
+  }
+}
+
+
+/*
+ * prefer_decomposed()
+ *
+ * Called during shape_execute().
+ *
+ * Shapers should return TRUE if it prefers decomposed (NFD) input rather than precomposed (NFC).
+ */
+
+typedef bool hb_ot_shape_complex_prefer_decomposed_func_t (void);
+#define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
+  HB_INTERNAL hb_ot_shape_complex_prefer_decomposed_func_t _hb_ot_shape_complex_prefer_decomposed_##name;
+  HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
+#undef HB_COMPLEX_SHAPER_IMPLEMENT
+
+static inline bool
+hb_ot_shape_complex_prefer_decomposed (hb_ot_complex_shaper_t shaper)
+{
+  switch (shaper) {
+    default:
+#define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
+    case hb_ot_complex_shaper_##name:  return _hb_ot_shape_complex_prefer_decomposed_##name ();
+    HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
+#undef HB_COMPLEX_SHAPER_IMPLEMENT
   }
 }
 
@@ -143,8 +190,10 @@ hb_ot_shape_complex_collect_features (hb_ot_complex_shaper_t shaper,
  */
 
 typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer_t *buffer);
-HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_arabic;
-HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_indic;
+#define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
+  HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_##name;
+  HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
+#undef HB_COMPLEX_SHAPER_IMPLEMENT
 
 static inline void
 hb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper,
@@ -152,9 +201,11 @@ hb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper,
                                 hb_buffer_t *buffer)
 {
   switch (shaper) {
-    case hb_ot_complex_shaper_arabic:  _hb_ot_shape_complex_setup_masks_arabic (map, buffer);  return;
-    case hb_ot_complex_shaper_indic:   _hb_ot_shape_complex_setup_masks_indic  (map, buffer);  return;
-    case hb_ot_complex_shaper_none:    default:                                                return;
+    default:
+#define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
+    case hb_ot_complex_shaper_##name:  _hb_ot_shape_complex_setup_masks_##name (map, buffer); return;
+    HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
+#undef HB_COMPLEX_SHAPER_IMPLEMENT
   }
 }