]> git.decadent.org.uk Git - ion3.git/blob - libmainloop/hooks.h
11487de27210ce230e465f92ce84572ef6288bad
[ion3.git] / libmainloop / hooks.h
1 /*
2  * ion/mainloop/hooks.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
6  * Ion is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  */
11
12 #ifndef ION_LIBMAINLOOP_HOOKS_H
13 #define ION_LIBMAINLOOP_HOOKS_H
14
15 #include <libtu/types.h>
16 #include <libextl/extl.h>
17
18 INTRSTRUCT(WHookItem);
19 INTRCLASS(WHook);
20
21 typedef void WHookDummy();
22 typedef bool WHookMarshall(WHookDummy *fn, void *param);
23 typedef bool WHookMarshallExtl(ExtlFn fn, void *param);
24
25 DECLSTRUCT(WHookItem){
26     WHookDummy *fn;
27     ExtlFn efn;
28     WHookItem *next, *prev;
29 };
30
31 DECLCLASS(WHook){
32     Obj obj;
33     WHookItem *items;
34 };
35
36
37 /* If hk==NULL to register, new is attempted to be created. */
38 extern WHook *mainloop_register_hook(const char *name, WHook *hk);
39 extern WHook *mainloop_unregister_hook(const char *name, WHook *hk);
40 extern WHook *mainloop_get_hook(const char *name);
41
42 extern WHook *create_hook();
43 extern bool hook_init(WHook *hk);
44 extern void hook_deinit(WHook *hk);
45
46 extern bool hook_add(WHook *hk, WHookDummy *fn);
47 extern bool hook_remove(WHook *hk, WHookDummy *fn);
48 extern WHookItem *hook_find(WHook *hk, WHookDummy *fn);
49
50 extern bool hook_add_extl(WHook *hk, ExtlFn fn);
51 extern bool hook_remove_extl(WHook *hk, ExtlFn fn);
52 extern WHookItem *hook_find_extl(WHook *hk, ExtlFn efn);
53
54 extern void hook_call(const WHook *hk, void *p,
55                       WHookMarshall *m, WHookMarshallExtl *em);
56 extern void hook_call_v(const WHook *hk);
57 extern void hook_call_o(const WHook *hk, Obj *o);
58 extern void hook_call_p(const WHook *hk, void *p, WHookMarshallExtl *em);
59
60 extern bool hook_call_alt(const WHook *hk, void *p,
61                           WHookMarshall *m, WHookMarshallExtl *em);
62 extern bool hook_call_alt_v(const WHook *hk);
63 extern bool hook_call_alt_o(const WHook *hk, Obj *o);
64 extern bool hook_call_alt_p(const WHook *hk, void *p, WHookMarshallExtl *em);
65
66
67 #endif /* ION_LIBMAINLOOP_HOOKS_H */