Remove ArrayAfter, use StructAfter in place

This commit is contained in:
Behdad Esfahbod 2010-04-21 22:30:36 -04:00
parent e961c86c57
commit 2e2f43edf2
1 changed files with 6 additions and 15 deletions

View File

@ -48,6 +48,8 @@ template <typename Type> inline char * DeConstCharP (const Type X) { return (cha
#define CAST(T,X,Ofs) (*(reinterpret_cast<T *>(CharP(&(X)) + Ofs)))
/* StructAfter<T>(X) returns the struct T& that is placed after X.
* Works with X of variable size also. */
template<typename Type, typename TObject>
inline const Type& StructAfter(const TObject &X)
{
@ -59,17 +61,6 @@ inline Type& StructAfter(TObject &X)
return * reinterpret_cast<Type*> (CharP (&X) + X.get_size());
}
template<typename Type, typename TObject>
inline const Type* ArrayAfter(const TObject &X)
{
return reinterpret_cast<const Type*> (ConstCharP (&X) + X.get_size());
}
template<typename Type, typename TObject>
inline Type* ArrayAfter(TObject &X)
{
return reinterpret_cast<Type*> (CharP (&X) + X.get_size());
}
/*
* Class features
@ -522,8 +513,8 @@ struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
template <typename LenType, typename Type>
struct GenericArrayOf
{
const Type *const_array(void) const { return ArrayAfter<Type> (len); }
Type *array(void) { return ArrayAfter<Type> (len); }
const Type *const_array(void) const { return &StructAfter<Type> (len); }
Type *array(void) { return &StructAfter<Type> (len); }
const Type *const_sub_array (unsigned int start_offset, unsigned int *pcount /* IN/OUT */) const
{
@ -640,8 +631,8 @@ struct OffsetListOf : OffsetArrayOf<Type>
template <typename Type>
struct HeadlessArrayOf
{
const Type *const_array(void) const { return ArrayAfter<Type> (len); }
Type *array(void) { return ArrayAfter<Type> (len); }
const Type *const_array(void) const { return &StructAfter<Type> (len); }
Type *array(void) { return &StructAfter<Type> (len); }
inline const Type& operator [] (unsigned int i) const
{