X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fhb-open-type-private.hh;h=ea1d371ae5aee9f4df228bdcef8b47dffe721ecc;hb=8f08c3275040870a645ef034a38d30c05c619f21;hp=99255776e95b4ceda7de825930c6834abe2ce348;hpb=fd56ae49637b978ea3b36fab5b48f1a3cc99e90e;p=framework%2Fuifw%2Fharfbuzz.git diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 9925577..ea1d371 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -31,6 +31,8 @@ #include "hb-blob.h" +HB_BEGIN_DECLS +HB_END_DECLS /* @@ -124,7 +126,7 @@ static const void *_NullPool[64 / sizeof (void *)]; /* Generic nul-content Null objects. */ template -static inline const Type& Null () { +static inline const Type& Null (void) { ASSERT_STATIC (Type::min_size <= sizeof (_NullPool)); return *CastP (_NullPool); } @@ -133,7 +135,7 @@ static inline const Type& Null () { #define DEFINE_NULL_DATA(Type, data) \ static const char _Null##Type[Type::min_size + 1] = data; /* +1 is for nul-termination in data */ \ template <> \ -inline const Type& Null () { \ +inline const Type& Null (void) { \ return *CastP (_Null##Type); \ } /* The following line really exists such that we end in a place needing semicolon */ \ ASSERT_STATIC (Type::min_size + 1 <= sizeof (_Null##Type)) @@ -191,8 +193,9 @@ struct hb_sanitize_context_t this->debug_depth = 0; if (HB_DEBUG_SANITIZE) - fprintf (stderr, "sanitize %p init [%p..%p] (%u bytes)\n", - this->blob, this->start, this->end, this->end - this->start); + fprintf (stderr, "sanitize %p init [%p..%p] (%lu bytes)\n", + this->blob, this->start, this->end, + (unsigned long) (this->end - this->start)); } inline void finish (void) @@ -228,7 +231,7 @@ struct hb_sanitize_context_t inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const { const char *p = (const char *) base; - bool overflows = len >= ((unsigned int) -1) / record_size; + bool overflows = record_size > 0 && len >= ((unsigned int) -1) / record_size; if (HB_DEBUG_SANITIZE && (int) this->debug_depth < (int) HB_DEBUG_SANITIZE) fprintf (stderr, "SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s\n", \ @@ -369,8 +372,8 @@ template class BEInt { public: - inline class BEInt& operator = (Type i) { hb_be_uint16_put (v,i); return *this; } - inline operator Type () const { return hb_be_uint16_get (v); } + inline void set (Type i) { hb_be_uint16_put (v,i); } + inline operator Type (void) const { return hb_be_uint16_get (v); } inline bool operator == (const BEInt& o) const { return hb_be_uint16_cmp (v, o.v); } inline bool operator != (const BEInt& o) const { return !(*this == o); } private: uint8_t v[2]; @@ -379,8 +382,8 @@ template class BEInt { public: - inline class BEInt& operator = (Type i) { hb_be_uint32_put (v,i); return *this; } - inline operator Type () const { return hb_be_uint32_get (v); } + inline void set (Type i) { hb_be_uint32_put (v,i); } + inline operator Type (void) const { return hb_be_uint32_get (v); } inline bool operator == (const BEInt& o) const { return hb_be_uint32_cmp (v, o.v); } inline bool operator != (const BEInt& o) const { return !(*this == o); } private: uint8_t v[4]; @@ -390,11 +393,11 @@ class BEInt template struct IntType { - inline void set (Type i) { v = i; } + inline void set (Type i) { v.set (i); } inline operator Type(void) const { return v; } inline bool operator == (const IntType &o) const { return v == o.v; } inline bool operator != (const IntType &o) const { return v != o.v; } - inline int cmp (Type b) const { Type a = v; return b < a ? -1 : b == a ? 0 : +1; } + inline int cmp (Type a) const { Type b = v; return a < b ? -1 : a == b ? 0 : +1; } inline bool sanitize (hb_sanitize_context_t *c) { TRACE_SANITIZE (); return likely (c->check_struct (this)); @@ -568,7 +571,7 @@ struct GenericArrayOf if (unlikely (i >= len)) return Null(Type); return array[i]; } - inline unsigned int get_size () const + inline unsigned int get_size (void) const { return len.static_size + len * Type::static_size; } inline bool sanitize (hb_sanitize_context_t *c) { @@ -674,7 +677,7 @@ struct HeadlessArrayOf if (unlikely (i >= len || !i)) return Null(Type); return array[i-1]; } - inline unsigned int get_size () const + inline unsigned int get_size (void) const { return len.static_size + (len ? len - 1 : 0) * Type::static_size; } inline bool sanitize_shallow (hb_sanitize_context_t *c) { @@ -715,16 +718,15 @@ struct SortedArrayOf : ArrayOf { template inline int search (const SearchType &x) const { class Cmp { - public: static int cmp (const void *p1, const void *p2) { - const SearchType *a = (const SearchType *) p1; - const Type *b = (const Type *) p2; - return b->cmp (*a); - } + public: static int cmp (const SearchType *a, const Type *b) { return b->cmp (*a); } }; - const Type *p = (const Type *) bsearch (&x, this->array, this->len, sizeof (this->array[0]), Cmp::cmp); + const Type *p = (const Type *) bsearch (&x, this->array, this->len, sizeof (this->array[0]), (hb_compare_func_t) Cmp::cmp); return p ? p - this->array : -1; } }; +HB_BEGIN_DECLS +HB_END_DECLS + #endif /* HB_OPEN_TYPE_PRIVATE_HH */