From 01c01618e98283611628cd54d5ba4bf122f24cd9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 21 Apr 2010 22:49:56 -0400 Subject: [PATCH] Further simplify IntType struct defs --- src/hb-open-type-private.hh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 2a9fe00..2c675f5 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -354,18 +354,20 @@ template class BEInt { public: - inline void put (Type i) { hb_be_uint16_put (v,i); } - inline Type get () const { return hb_be_uint16_get (v); } - inline bool cmp (const BEInt o) const { return hb_be_uint16_cmp (v, o.v); } + 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 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]; }; template class BEInt { public: - inline void put (Type i) { hb_be_uint32_put (v,i); } - inline Type get () const { return hb_be_uint32_get (v); } - inline bool cmp (const BEInt o) const { return hb_be_uint32_cmp (v, o.v); } + 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 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]; }; @@ -373,9 +375,10 @@ template struct IntType { static inline unsigned int get_size () { return sizeof (Type); } - inline void set (Type i) { v.put (i); } - inline operator Type(void) const { return v.get (); } - inline bool operator == (const IntType &o) const { return v.cmp (o.v); } + inline void set (Type i) { v = 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 bool sanitize (SANITIZE_ARG_DEF) { TRACE_SANITIZE (); return SANITIZE_SELF (); -- 2.7.4