obj.h

changeset 62
aae5facf9fc5
parent 60
a4033700e35c
child 77
bcd82ab9ecdc
equal deleted inserted replaced
61:fc585645ad05 62:aae5facf9fc5
16 16
17 #define OBJ_IS(OBJ, TYPE) obj_is((Obj*)OBJ, &CLASSDESCR(TYPE)) 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)) 18 #define OBJ_CAST(OBJ, TYPE) (TYPE*)obj_cast((Obj*)OBJ, &CLASSDESCR(TYPE))
19 19
20 #define INTRSTRUCT(STRU) \ 20 #define INTRSTRUCT(STRU) \
21 struct STRU##_struct; typedef struct STRU##_struct STRU 21 struct STRU##_struct; typedef struct STRU##_struct STRU
22 #define DECLSTRUCT(STRU) \ 22 #define DECLSTRUCT(STRU) \
23 struct STRU##_struct 23 struct STRU##_struct
24 24
25 #define INTRCLASS(OBJ) INTRSTRUCT(OBJ); extern ClassDescr CLASSDESCR(OBJ) 25 #define INTRCLASS(OBJ) INTRSTRUCT(OBJ); extern ClassDescr CLASSDESCR(OBJ)
26 #define DECLCLASS(OBJ) DECLSTRUCT(OBJ) 26 #define DECLCLASS(OBJ) DECLSTRUCT(OBJ)
27 27
28 INTRSTRUCT(ClassDescr); 28 INTRSTRUCT(ClassDescr);
34 extern const void *obj_cast(const Obj *obj, const ClassDescr *descr); 34 extern const void *obj_cast(const Obj *obj, const ClassDescr *descr);
35 35
36 extern void destroy_obj(Obj *obj); 36 extern void destroy_obj(Obj *obj);
37 37
38 DECLCLASS(Obj){ 38 DECLCLASS(Obj){
39 ClassDescr *obj_type; 39 ClassDescr *obj_type;
40 Watch *obj_watches; 40 Watch *obj_watches;
41 int flags; 41 int flags;
42 }; 42 };
43 43
44 #define OBJ_DEST 0x0001 44 #define OBJ_DEST 0x0001
45 #define OBJ_EXTL_CACHED 0x0002 45 #define OBJ_EXTL_CACHED 0x0002
46 46
51 typedef void WatchHandler(Watch *watch, Obj *obj); 51 typedef void WatchHandler(Watch *watch, Obj *obj);
52 52
53 #define WWATCH_INIT {NULL, NULL, NULL, NULL} 53 #define WWATCH_INIT {NULL, NULL, NULL, NULL}
54 54
55 DECLSTRUCT(Watch){ 55 DECLSTRUCT(Watch){
56 Obj *obj; 56 Obj *obj;
57 Watch *next, *prev; 57 Watch *next, *prev;
58 WatchHandler *handler; 58 WatchHandler *handler;
59 }; 59 };
60 60
61 extern bool watch_setup(Watch *watch, Obj *obj, 61 extern bool watch_setup(Watch *watch, Obj *obj,
62 WatchHandler *handler); 62 WatchHandler *handler);
63 extern void watch_reset(Watch *watch); 63 extern void watch_reset(Watch *watch);
64 extern bool watch_ok(Watch *watch); 64 extern bool watch_ok(Watch *watch);
65 extern void watch_init(Watch *watch); 65 extern void watch_init(Watch *watch);
66 extern void watch_call(Obj *obj); 66 extern void watch_call(Obj *obj);
67 67

mercurial