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.
15 #define CLASSDESCR(TYPE) TYPE##_classdescr
17 #define OBJ_IS(OBJ, TYPE) obj_is((Obj*)OBJ, &CLASSDESCR(TYPE))
18 #define OBJ_CAST(OBJ, TYPE) (TYPE*)obj_cast((Obj*)OBJ, &CLASSDESCR(TYPE))
20 #define INTRSTRUCT(STRU) \
21 struct STRU##_struct; typedef struct STRU##_struct STRU
22 #define DECLSTRUCT(STRU) \
25 #define INTRCLASS(OBJ) INTRSTRUCT(OBJ); extern ClassDescr CLASSDESCR(OBJ)
26 #define DECLCLASS(OBJ) DECLSTRUCT(OBJ)
28 INTRSTRUCT(ClassDescr
);
32 extern bool obj_is(const Obj
*obj
, const ClassDescr
*descr
);
33 extern bool obj_is_str(const Obj
*obj
, const char *str
);
34 extern const void *obj_cast(const Obj
*obj
, const ClassDescr
*descr
);
36 extern void destroy_obj(Obj
*obj
);
44 #define OBJ_DEST 0x0001
45 #define OBJ_EXTL_CACHED 0x0002
46 #define OBJ_EXTL_OWNED 0x0004
48 #define OBJ_IS_BEING_DESTROYED(OBJ) (((Obj*)(OBJ))->flags&OBJ_DEST)
52 typedef void WatchHandler(Watch
*watch
, Obj
*obj
);
54 #define WATCH_INIT {NULL, NULL, NULL, NULL}
59 WatchHandler
*handler
;
62 extern bool watch_setup(Watch
*watch
, Obj
*obj
,
63 WatchHandler
*handler
);
64 extern void watch_reset(Watch
*watch
);
65 extern bool watch_ok(Watch
*watch
);
66 extern void watch_init(Watch
*watch
);
67 extern void watch_call(Obj
*obj
);
69 #endif /* LIBTU_OBJ_H */