]> git.decadent.org.uk Git - ion3.git/blob - libmainloop/hooks.h
[svn-upgrade] Integrating new upstream version, ion3 (20070708)
[ion3.git] / libmainloop / hooks.h
1 /*
2  * ion/mainloop/hooks.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
6  * See the included file LICENSE for details.
7  */
8
9 #ifndef ION_LIBMAINLOOP_HOOKS_H
10 #define ION_LIBMAINLOOP_HOOKS_H
11
12 #include <libtu/types.h>
13 #include <libextl/extl.h>
14
15 INTRSTRUCT(WHookItem);
16 INTRCLASS(WHook);
17
18 typedef void WHookDummy();
19 typedef bool WHookMarshall(WHookDummy *fn, void *param);
20 typedef bool WHookMarshallExtl(ExtlFn fn, void *param);
21
22 DECLSTRUCT(WHookItem){
23     WHookDummy *fn;
24     ExtlFn efn;
25     WHookItem *next, *prev;
26 };
27
28 DECLCLASS(WHook){
29     Obj obj;
30     WHookItem *items;
31 };
32
33
34 /* If hk==NULL to register, new is attempted to be created. */
35 extern WHook *mainloop_register_hook(const char *name, WHook *hk);
36 extern WHook *mainloop_unregister_hook(const char *name, WHook *hk);
37 extern WHook *mainloop_get_hook(const char *name);
38
39 extern WHook *create_hook();
40 extern bool hook_init(WHook *hk);
41 extern void hook_deinit(WHook *hk);
42
43 extern bool hook_add(WHook *hk, WHookDummy *fn);
44 extern bool hook_remove(WHook *hk, WHookDummy *fn);
45 extern WHookItem *hook_find(WHook *hk, WHookDummy *fn);
46
47 extern bool hook_add_extl(WHook *hk, ExtlFn fn);
48 extern bool hook_remove_extl(WHook *hk, ExtlFn fn);
49 extern WHookItem *hook_find_extl(WHook *hk, ExtlFn efn);
50
51 extern void hook_call(const WHook *hk, void *p,
52                       WHookMarshall *m, WHookMarshallExtl *em);
53 extern void hook_call_v(const WHook *hk);
54 extern void hook_call_o(const WHook *hk, Obj *o);
55 extern void hook_call_p(const WHook *hk, void *p, WHookMarshallExtl *em);
56
57 extern bool hook_call_alt(const WHook *hk, void *p,
58                           WHookMarshall *m, WHookMarshallExtl *em);
59 extern bool hook_call_alt_v(const WHook *hk);
60 extern bool hook_call_alt_o(const WHook *hk, Obj *o);
61 extern bool hook_call_alt_p(const WHook *hk, void *p, WHookMarshallExtl *em);
62
63
64 #endif /* ION_LIBMAINLOOP_HOOKS_H */