This commit is contained in:
Behdad Esfahbod 2010-05-10 17:04:20 -04:00
parent b3651231bf
commit 0abcc3b48c
1 changed files with 10 additions and 8 deletions

View File

@ -89,9 +89,14 @@ inline Type& StructAfter(TObject &X)
* Size checking * Size checking
*/ */
#define ASSERT_SIZE(_thing, _size) ASSERT_STATIC (sizeof (_thing) == (_size))
#define _DEFINE_SIZE_ASSERTION(_size) \
inline void _size_assertion (void) const { ASSERT_SIZE (*this, _size); }
#define DEFINE_SIZE_STATIC(size) \ #define DEFINE_SIZE_STATIC(size) \
inline void _size_assertion (void) const \ _DEFINE_SIZE_ASSERTION (size); \
{ ASSERT_STATIC (sizeof (*this) == (size)); } \
static inline unsigned int get_size (void) { return (size); } \ static inline unsigned int get_size (void) { return (size); } \
static const unsigned int static_size = (size); \ static const unsigned int static_size = (size); \
static const unsigned int min_size = (size) static const unsigned int min_size = (size)
@ -101,18 +106,15 @@ inline Type& StructAfter(TObject &X)
#define VAR0 (VAR+0) #define VAR0 (VAR+0)
#define DEFINE_SIZE_VAR0(size) \ #define DEFINE_SIZE_VAR0(size) \
inline void _size_assertion (void) const \ _DEFINE_SIZE_ASSERTION (size); \
{ ASSERT_STATIC (sizeof (*this) == (size)); } \
static const unsigned int min_size = (size) static const unsigned int min_size = (size)
#define DEFINE_SIZE_VAR(size, _var_type) \ #define DEFINE_SIZE_VAR(size, _var_type) \
inline void _size_assertion (void) const \ _DEFINE_SIZE_ASSERTION ((size) + VAR0 * sizeof (_var_type)); \
{ ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type)); } \
static const unsigned int min_size = (size) static const unsigned int min_size = (size)
#define DEFINE_SIZE_VAR2(size, _var_type1, _var_type2) \ #define DEFINE_SIZE_VAR2(size, _var_type1, _var_type2) \
inline void _size_assertion (void) const \ _DEFINE_SIZE_ASSERTION ((size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); \
{ ASSERT_STATIC (sizeof (*this) == (size) + VAR0 * sizeof (_var_type1) + VAR0 * sizeof (_var_type2)); } \
static const unsigned int min_size = (size) static const unsigned int min_size = (size)