Ignore:
Timestamp:
04/25/14 16:15:30 (10 years ago)
Author:
Maciej Komosinski
Message:

Detects invalid ParamEntry? when accessing ParamEntry?-based Params in DEBUG mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/param.h

    r197 r230  
    157157
    158158        static const char* SERIALIZATION_PREFIX;
     159
     160#ifdef DEBUG
     161        virtual void sanityCheck(int i) {}
     162#endif
    159163};
    160164
     
    170174#define FIELDOFFSET(_fld_) ((long)((char*)(&((FIELDSTRUCT*)&MakeCodeGuardHappy)->_fld_)-((char*)((FIELDSTRUCT*)&MakeCodeGuardHappy))))
    171175
     176#ifdef DEBUG
     177#define PARAM_ILLEGAL_OFFSET ((long)0xdeadbeef)
     178#else
     179#define PARAM_ILLEGAL_OFFSET 0
     180#endif
     181
    172182#define FIELD(_fld_) FIELDOFFSET(_fld_),0,0
    173183#define LONGOFFSET(_o_) (_o_),0,0
    174 #define PROCEDURE(_proc_) 0,(void*)PROCOFFSET(_proc_),0
    175 #define STATICPROCEDURE(_proc_) 0,(void*)STATICPROCOFFSET(_proc_),0
    176 #define GETSET(_proc_) 0,(void*)GETOFFSET(get_ ## _proc_),(void*)SETOFFSET(set_ ## _proc_)
     184#define PROCEDURE(_proc_) PARAM_ILLEGAL_OFFSET,(void*)PROCOFFSET(_proc_),0
     185#define STATICPROCEDURE(_proc_) PARAM_ILLEGAL_OFFSET,(void*)STATICPROCOFFSET(_proc_),0
     186#define GETSET(_proc_) PARAM_ILLEGAL_OFFSET,(void*)GETOFFSET(get_ ## _proc_),(void*)SETOFFSET(set_ ## _proc_)
    177187#define GETFIELD(_proc_) FIELDOFFSET(_proc_),(void*)GETOFFSET(get_ ## _proc_),0
    178188#define SETFIELD(_proc_) FIELDOFFSET(_proc_),0,(void*)SETOFFSET(set_ ## _proc_)
    179 #define GETONLY(_proc_) 0,(void*)GETOFFSET(get_ ## _proc_),0
    180 #define SETONLY(_proc_) 0,0,(void*)SETOFFSET(set_ ## _proc_)
     189#define GETONLY(_proc_) PARAM_ILLEGAL_OFFSET,(void*)GETOFFSET(get_ ## _proc_),0
     190#define SETONLY(_proc_) PARAM_ILLEGAL_OFFSET,0,(void*)SETOFFSET(set_ ## _proc_)
    181191
    182192#define PARAMPROCARGS ExtValue* args,ExtValue* ret
     
    271281        virtual void setDefault(bool numericonly = false);
    272282        virtual void setDefault(int i, bool numericonly = false);
     283
     284#ifdef DEBUG
     285        void sanityCheck(int i);
     286#endif
    273287};
    274288
Note: See TracChangeset for help on using the changeset viewer.