diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index b585e1873..15198b176 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -37,11 +37,6 @@ namespace OT { -/* - * Void! - */ -typedef struct {} void_t; - /* * Casts diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh index 55ea9ca5c..608ed5ae8 100644 --- a/src/hb-ot-layout-gsubgpos-private.hh +++ b/src/hb-ot-layout-gsubgpos-private.hh @@ -50,7 +50,7 @@ struct hb_closure_context_t typedef return_t (*recurse_func_t) (hb_closure_context_t *c, unsigned int lookup_index); template inline return_t process (const T &obj) { obj.closure (this); return void_t (); } - static const return_t default_return_value (void) { return return_t (); } + static return_t default_return_value (void) { return return_t (); } bool stop_sublookup_iteration (const return_t r) const { return false; } return_t recurse (unsigned int lookup_index) { @@ -82,7 +82,6 @@ struct hb_closure_context_t -/* TODO Add TRACE_RETURN annotation to gsub. */ #ifndef HB_DEBUG_WOULD_APPLY #define HB_DEBUG_WOULD_APPLY (HB_DEBUG+0) #endif @@ -119,7 +118,6 @@ struct hb_would_apply_context_t -/* TODO Add TRACE_RETURN annotation to gsub. */ #ifndef HB_DEBUG_COLLECT_GLYPHS #define HB_DEBUG_COLLECT_GLYPHS (HB_DEBUG+0) #endif @@ -133,7 +131,7 @@ struct hb_collect_glyphs_context_t typedef void_t return_t; template inline return_t process (const T &obj) { obj.collect_glyphs (this); return void_t (); } - static const return_t default_return_value (void) { return return_t (); } + static return_t default_return_value (void) { return return_t (); } bool stop_iteration (const return_t r) const { return false; } return_t recurse (unsigned int lookup_index) { @@ -170,7 +168,7 @@ struct hb_get_coverage_context_t typedef const Coverage &return_t; template inline return_t process (const T &obj) { return obj.get_coverage (); } - static return_t default_return_value (void) { return Null(Coverage); } + static const return_t default_return_value (void) { return Null(Coverage); } bool stop_sublookup_iteration (const return_t r) const { return true; /* Unused */ } return_t recurse (unsigned int lookup_index) { return default_return_value (); } @@ -194,7 +192,7 @@ struct hb_apply_context_t typedef return_t (*recurse_func_t) (hb_apply_context_t *c, unsigned int lookup_index); template inline return_t process (const T &obj) { return obj.apply (this); } - static const return_t default_return_value (void) { return false; } + static return_t default_return_value (void) { return false; } bool stop_sublookup_iteration (const return_t r) const { return r; } return_t recurse (unsigned int lookup_index) { diff --git a/src/hb-private.hh b/src/hb-private.hh index 5c5359190..16c356217 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -62,6 +62,10 @@ #endif +/* Void! */ +typedef struct {} void_t; + + /* Basics */ @@ -656,6 +660,24 @@ _hb_debug_msg<0> (const char *what HB_UNUSED, #define DEBUG_MSG_FUNC(WHAT, OBJ, ...) _hb_debug_msg (#WHAT, (OBJ), HB_FUNC, false, 0, 0, __VA_ARGS__) +/* + * Printer + */ + +template +struct hb_printer_t {}; + +template <> +struct hb_printer_t { + const char *print (bool v) { return v ? "true" : "false"; } +}; + +template <> +struct hb_printer_t { + const char *print (void_t v) { return ""; } +}; + + /* * Trace */ @@ -687,14 +709,15 @@ struct hb_auto_trace_t { if (plevel) --*plevel; } - inline bool ret (bool v, unsigned int line = 0) + template + inline T ret (T v, unsigned int line = 0) { if (unlikely (returned)) { fprintf (stderr, "OUCH, double calls to TRACE_RETURN. This is a bug, please report.\n"); return v; } - _hb_debug_msg (what, obj, NULL, true, plevel ? *plevel : 1, -1, "return %s (line %d)", v ? "true" : "false", line); + _hb_debug_msg (what, obj, NULL, true, plevel ? *plevel : 1, -1, "return %s (line %d)", hb_printer_t().print (v), line); if (plevel) --*plevel; plevel = NULL; returned = true;