4 * Copyright (c) Tuomo Valkonen 1999-2001.
5 * See the included file LICENSE for details.
8 #ifndef INCLUDED_WOBJP_H
9 #define INCLUDED_WOBJP_H
13 DECLSTRUCT(WObjDescr
){
19 #define IMPLOBJ(OBJ, ANCESTOR, FUNTAB) \
20 WObjDescr OBJDESCR(OBJ)={#OBJ, &OBJDESCR(ANCESTOR), (void*)FUNTAB};
22 #define WOBJ_INIT(O, TYPE) ((WObj*)(O))->obj_type=&OBJDESCR(TYPE)
24 #define CREATESTRUCT_IMPL_(OBJ, LOWOBJ, INIT, ARGS) \
25 OBJ *p; p=ALLOC(OBJ); if(p==NULL){ warn_err(); return NULL; } \
27 if(!init_##LOWOBJ ARGS){ free((void*)p); return NULL; } return p
29 #define CREATESTRUCT_IMPL(OBJ, LOWOBJ, ARGS) \
30 CREATESTRUCT_IMPL_(OBJ, LOWOBJ, /* */, ARGS)
32 #define SIMPLECREATESTRUCT_IMPL(OBJ, LOWOBJ, ARGS) \
33 CREATESTRUCT_IMPL_(OBJ, LOWOBJ, /* */, (p))
35 #define CREATEOBJ_IMPL(OBJ, LOWOBJ, ARGS) \
36 CREATESTRUCT_IMPL_(OBJ, LOWOBJ, WOBJ_INIT(p, OBJ), ARGS)
38 #define SIMPLECREATEOBJ_IMPL(OBJ, LOWOBJ, ARGS) \
39 CREATESTRUCT_IMPL_(OBJ, LOWOBJ, WOBJ_INIT(p, OBJ), (p))
41 #define FUNTAB(OBJ, TYPE) ((TYPE*)(((WObj*)OBJ)->obj_type->funtab))
42 #define CALL_FUNTAB(OBJ, TYPE, FN) if(FUNTAB(OBJ, TYPE)->FN!=NULL) FUNTAB(OBJ, TYPE)->FN
44 #endif /* INCLUDED_WOBJP_H */