4 * Copyright (c) Tuomo Valkonen 1999-2004.
6 * You may distribute and modify this library under the terms of either
7 * the Clarified Artistic License or the GNU LGPL, version 2.1 or later.
16 typedef void DynFun();
18 INTRSTRUCT(DynFunTab);
20 DECLSTRUCT(DynFunTab){
21 DynFun *func, *handler;
24 DECLSTRUCT(ClassDescr){
32 #define OBJ_TYPESTR(OBJ) ((OBJ) ? ((Obj*)OBJ)->obj_type->name : NULL)
34 #define IMPLCLASS(CLS, ANCESTOR, DFN, DYN) \
35 ClassDescr CLASSDESCR(CLS)={ \
36 #CLS, &CLASSDESCR(ANCESTOR), -1, DYN, (void (*)())DFN}
38 #define OBJ_INIT(O, TYPE) {((Obj*)(O))->obj_type=&CLASSDESCR(TYPE); \
39 ((Obj*)(O))->obj_watches=NULL; ((Obj*)(O))->flags=0;}
41 #define CREATEOBJ_IMPL(OBJ, LOWOBJ, INIT_ARGS) \
42 OBJ *p; p=ALLOC(OBJ); if(p==NULL){ warn_err(); return NULL; } \
44 if(!LOWOBJ ## _init INIT_ARGS) { free((void*)p); return NULL; } return p
46 #define SIMPLECREATEOBJ_IMPL(OBJ, LOWOBJ) \
47 OBJ *p; p=ALLOC(OBJ); if(p==NULL){ warn_err(); return NULL; } \
51 #define END_DYNFUNTAB {NULL, NULL}
53 extern DynFun *lookup_dynfun(const Obj *obj, DynFun *func,
55 extern bool has_dynfun(const Obj *obj, DynFun *func);
57 #define CALL_DYN(FUNC, OBJ, ARGS) \
59 lookup_dynfun((Obj*)OBJ, (DynFun*)FUNC, &funnotfound) ARGS;
61 #define CALL_DYN_RET(RETV, RET, FUNC, OBJ, ARGS) \
62 typedef RET ThisDynFun(); \
65 funtmp=(ThisDynFun*)lookup_dynfun((Obj*)OBJ, (DynFun*)FUNC, \
70 #define HAS_DYN(OBJ, FUNC) has_dynfun((Obj*)OBJ, (DynFun*)FUNC)
72 #endif /* LIBTU_OBJP_H */