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