Commit | Line | Data |
---|---|---|
abd95148 MD |
1 | /* classes: h_files */ |
2 | ||
56e55ac7 DH |
3 | #ifndef SCM_HOOKS_H |
4 | #define SCM_HOOKS_H | |
dee01b01 | 5 | |
102dbb6f | 6 | /* Copyright (C) 1995,1996,1999,2000,2001, 2006, 2008 Free Software Foundation, Inc. |
dee01b01 | 7 | * |
73be1d9e MV |
8 | * This library is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU Lesser General Public | |
10 | * License as published by the Free Software Foundation; either | |
11 | * version 2.1 of the License, or (at your option) any later version. | |
dee01b01 | 12 | * |
73be1d9e | 13 | * This library is distributed in the hope that it will be useful, |
abd95148 | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
73be1d9e MV |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | * Lesser General Public License for more details. | |
dee01b01 | 17 | * |
73be1d9e MV |
18 | * You should have received a copy of the GNU Lesser General Public |
19 | * License along with this library; if not, write to the Free Software | |
92205699 | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
73be1d9e | 21 | */ |
abd95148 | 22 | |
abd95148 MD |
23 | \f |
24 | ||
25 | #include "libguile/__scm.h" | |
26 | ||
27 | /* | |
28 | * C level hooks | |
29 | */ | |
30 | ||
31 | /* | |
32 | * The interface is designed for and- and or-type hooks which | |
33 | * both may want to indicate success/failure and return a result. | |
34 | */ | |
35 | ||
387d418c | 36 | typedef enum scm_t_c_hook_type { |
abd95148 MD |
37 | SCM_C_HOOK_NORMAL, |
38 | SCM_C_HOOK_OR, | |
39 | SCM_C_HOOK_AND | |
387d418c | 40 | } scm_t_c_hook_type; |
abd95148 | 41 | |
92c2555f | 42 | typedef void *(*scm_t_c_hook_function) (void *hook_data, |
5c004b6d | 43 | void *fn_data, |
abd95148 MD |
44 | void *data); |
45 | ||
92c2555f MV |
46 | typedef struct scm_t_c_hook_entry { |
47 | struct scm_t_c_hook_entry *next; | |
48 | scm_t_c_hook_function func; | |
abd95148 | 49 | void *data; |
92c2555f | 50 | } scm_t_c_hook_entry; |
abd95148 | 51 | |
92c2555f MV |
52 | typedef struct scm_t_c_hook { |
53 | scm_t_c_hook_entry *first; | |
387d418c | 54 | scm_t_c_hook_type type; |
abd95148 | 55 | void *data; |
92c2555f | 56 | } scm_t_c_hook; |
abd95148 | 57 | |
33b001fd MV |
58 | SCM_API void scm_c_hook_init (scm_t_c_hook *hook, |
59 | void *hook_data, | |
387d418c | 60 | scm_t_c_hook_type type); |
33b001fd MV |
61 | SCM_API void scm_c_hook_add (scm_t_c_hook *hook, |
62 | scm_t_c_hook_function func, | |
5c004b6d | 63 | void *fn_data, |
33b001fd MV |
64 | int appendp); |
65 | SCM_API void scm_c_hook_remove (scm_t_c_hook *hook, | |
66 | scm_t_c_hook_function func, | |
5c004b6d | 67 | void *fn_data); |
33b001fd | 68 | SCM_API void *scm_c_hook_run (scm_t_c_hook *hook, void *data); |
abd95148 MD |
69 | |
70 | /* | |
71 | * Scheme level hooks | |
72 | */ | |
73 | ||
33b001fd | 74 | SCM_API scm_t_bits scm_tc16_hook; |
abd95148 | 75 | |
f5710d53 MV |
76 | #define SCM_HOOKP(x) SCM_SMOB_PREDICATE (scm_tc16_hook, x) |
77 | #define SCM_HOOK_ARITY(hook) SCM_SMOB_FLAGS (hook) | |
78 | #define SCM_HOOK_PROCEDURES(hook) SCM_SMOB_OBJECT (hook) | |
79 | #define SCM_SET_HOOK_PROCEDURES(hook, procs) SCM_SET_SMOB_OBJECT ((hook), (procs)) | |
abd95148 | 80 | |
33b001fd MV |
81 | SCM_API SCM scm_make_hook (SCM n_args); |
82 | SCM_API SCM scm_hook_p (SCM x); | |
83 | SCM_API SCM scm_hook_empty_p (SCM hook); | |
84 | SCM_API SCM scm_add_hook_x (SCM hook, SCM thunk, SCM appendp); | |
85 | SCM_API SCM scm_remove_hook_x (SCM hook, SCM thunk); | |
86 | SCM_API SCM scm_reset_hook_x (SCM hook); | |
87 | SCM_API SCM scm_run_hook (SCM hook, SCM args); | |
88 | SCM_API void scm_c_run_hook (SCM hook, SCM args); | |
89 | SCM_API SCM scm_hook_to_list (SCM hook); | |
102dbb6f | 90 | SCM_INTERNAL void scm_init_hooks (void); |
abd95148 | 91 | |
56e55ac7 | 92 | #endif /* SCM_HOOKS_H */ |
abd95148 MD |
93 | |
94 | /* | |
95 | Local Variables: | |
96 | c-file-style: "gnu" | |
97 | End: | |
98 | */ |