diff options
Diffstat (limited to 'pango/opentype/hb-open-types-private.hh')
-rw-r--r-- | pango/opentype/hb-open-types-private.hh | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/pango/opentype/hb-open-types-private.hh b/pango/opentype/hb-open-types-private.hh index 82b4a061..2ece79d2 100644 --- a/pango/opentype/hb-open-types-private.hh +++ b/pango/opentype/hb-open-types-private.hh @@ -38,6 +38,13 @@ #define MAX_NESTING_LEVEL 8 +/* + * Casts + */ + +#define CONST_CHARP(X) (reinterpret_cast<const char *>(X)) +#define CHARP(X) ((char *)reinterpret_cast<const char *>(X)) + /* * Sanitize @@ -58,7 +65,7 @@ struct _hb_sanitize_context_t #define SANITIZE(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG)) #define SANITIZE2(X,Y) SANITIZE (X) && SANITIZE (Y) -#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, (const char *) this)) +#define SANITIZE_THIS(X) HB_LIKELY ((X).sanitize (SANITIZE_ARG, reinterpret_cast<const char *>(this))) #define SANITIZE_THIS2(X,Y) SANITIZE_THIS (X) && SANITIZE_THIS (Y) #define SANITIZE_THIS3(X,Y,Z) SANITIZE_THIS (X) && SANITIZE_THIS (Y) && SANITIZE_THIS(Z) @@ -66,7 +73,7 @@ struct _hb_sanitize_context_t #define SANITIZE_OBJ(X) SANITIZE_MEM(&(X), sizeof (X)) #define SANITIZE_GET_SIZE() SANITIZE_MEM (this, this->get_size ()) -#define SANITIZE_MEM(B,L) HB_LIKELY (context->start <= (const char *)(B) && (const char *)(B) + (L) <= context->end) /* XXX overflow */ +#define SANITIZE_MEM(B,L) HB_LIKELY (context->start <= reinterpret_cast<const char *>(B) && reinterpret_cast<const char *>(B) + (L) <= context->end) /* XXX overflow */ #define NEUTER(Var, Val) (false) @@ -265,8 +272,8 @@ struct Tag : ULONG inline Tag (const char *c) { *(ULONG*)this = *(ULONG*)c; } inline bool operator== (const char *c) const { return *(ULONG*)this == *(ULONG*)c; } /* What the char* converters return is NOT nul-terminated. Print using "%.4s" */ - inline operator const char* (void) const { return (const char *)this; } - inline operator char* (void) { return (char *)this; } + inline operator const char* (void) const { return reinterpret_cast<const char *>(this); } + inline operator char* (void) { return reinterpret_cast<char *>(this); } }; ASSERT_SIZE (Tag, 4); #define _NULL_TAG_INIT {' ', ' ', ' ', ' '} @@ -330,14 +337,14 @@ struct GenericOffsetTo : OffsetType { unsigned int offset = *this; if (HB_UNLIKELY (!offset)) return Null(Type); - return *(const Type*)((const char *) base + offset); + return *reinterpret_cast<const Type*>(reinterpret_cast<const char *>(base) + offset); } inline bool sanitize (SANITIZE_ARG_DEF, const void *base) { if (!SANITIZE_OBJ (*this)) return false; unsigned int offset = *this; if (HB_UNLIKELY (!offset)) return true; - return SANITIZE (*(Type*)((char *) base + offset)) || NEUTER (*this, 0); + return SANITIZE (*reinterpret_cast<Type*>((char *)(reinterpret_cast<const char *>(base) + offset))) || NEUTER (*this, 0); } }; template <typename Base, typename OffsetType, typename Type> |