From 25326c2359b0a3e25222b94acd142bc36eff78a4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 4 Aug 2012 16:43:18 -0700 Subject: [PATCH] Rewrite ARRAY_LENGTH as a template function Such it wouldn't apply to pointers accidentally. --- src/hb-ot-shape-complex-arabic-table.hh | 4 ++-- src/hb-private.hh | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-shape-complex-arabic-table.hh b/src/hb-ot-shape-complex-arabic-table.hh index df8508676..c66111b69 100644 --- a/src/hb-ot-shape-complex-arabic-table.hh +++ b/src/hb-ot-shape-complex-arabic-table.hh @@ -914,9 +914,9 @@ static const uint16_t shaping_table[][4] = #define SHAPING_TABLE_LAST 0x06D3 -static const struct { +static const struct ligature_set_t { uint16_t first; - struct { + struct ligature_pairs_t { uint16_t second; uint16_t ligature; } ligatures[4]; diff --git a/src/hb-private.hh b/src/hb-private.hh index 2f8502545..0f1e5cedf 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -66,14 +66,17 @@ #undef MIN -template static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; } +template +static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; } #undef MAX -template static inline Type MAX (const Type &a, const Type &b) { return a > b ? a : b; } +template +static inline Type MAX (const Type &a, const Type &b) { return a > b ? a : b; } #undef ARRAY_LENGTH -#define ARRAY_LENGTH(__array) ((signed int) (sizeof (__array) / sizeof (__array[0]))) +template +static inline unsigned int ARRAY_LENGTH (const Type (&a)[n]) { return n; } #define HB_STMT_START do #define HB_STMT_END while (0)