destruct.h

00001 #ifndef CTL_DESTRUCT_H
00002 #define CTL_DESTRUCT_H
00003 
00016 struct Destruction
00017 {
00018     struct Destruction* next;   
00019     void* destroy;              
00020     void (*destroyit)(void*);   
00021 };
00022 
00027 #define Destruction_auto(destructhead)  struct Destruction* destructhead = NULL
00028 
00033 #define Destruction_init(destructhead)  (destructhead) = NULL
00034 
00041 #define Destruction_add(destructhead,destructor,objptr) \
00042 {\
00043     static struct Destruction ppScr(dnode);\
00044     ppScr(dnode).destroy = (objptr);\
00045     ppScr(dnode).destroyit = ppCastPtr(void (*)(void*))(destructor);\
00046     ppScr(dnode).next = destructhead;\
00047     destructhead = &ppScr(dnode);\
00048     assertcodeptr(destructor);\
00049     assertobjptr(objptr);\
00050 }
00051 
00058 #define Destruction_addctl(destructhead,type,instance)  Destruction_add(destructhead,ppConcat(type,_destroy),instance)
00059 
00065 #define Destruction_destroy(destructhead) \
00066     while( NULL != destructhead )\
00067     {\
00068         assertobjptr(destructhead);\
00069         assertcodeptr(destructhead->destroyit);\
00070         destructhead->destroyit(destructhead->destroy);\
00071         destructhead = destructhead->next;\
00072     }
00073 
00074 
00075 #endif /* CTL_DESTRUCT_H */

Generated on Fri Jan 2 15:28:34 2009 for Squat by  doxygen 1.5.6