4 * Guile-interface help inspired by SCWM.
7 * Copyright (C) 1997-1999, Maciej Stachowiak and Greg J. Badros
11 #ifndef SCWM_GUILE_H__
12 #define SCWM_GUILE_H__
14 #include "arg_unused.h"
27 #define SCWM_MAKE_HOOK(args) scm_permanent_object(scm_make_hook(scm_long2num(args)))
29 SCM
scwm_handle_error (void *handler_data
, SCM tag
, SCM throw_args
);
30 SCM
scwm_safe_apply_message_only (SCM proc
, SCM args
);
32 /* Individual callbacks. */
34 SCM
scwm_safe_apply (SCM proc
, SCM args
);
35 SCM
scwm_safe_call0 (SCM thunk
);
36 SCM
scwm_safe_call1 (SCM proc
, SCM arg
);
37 SCM
scwm_safe_call2 (SCM proc
, SCM arg1
, SCM arg2
);
38 SCM
scwm_safe_call3 (SCM proc
, SCM arg1
, SCM arg2
, SCM arg3
);
39 SCM
scwm_safe_call4 (SCM proc
, SCM arg1
, SCM arg2
, SCM arg3
, SCM arg4
);
40 SCM
scwm_safe_call5 (SCM proc
, SCM arg1
, SCM arg2
, SCM arg3
, SCM arg4
, SCM arg5
);
42 SCM
safe_load (SCM fname
);
43 SCM
scwm_safe_load (char *filename
);
44 SCM
scwm_safe_eval_str (char *string
);
48 SCM
call0_hooks (SCM hook
);
49 SCM
call1_hooks (SCM hook_type
, SCM arg
);
50 SCM
call2_hooks (SCM hook_type
, SCM arg1
, SCM arg2
);
51 SCM
call3_hooks (SCM hook_type
, SCM arg1
, SCM arg2
, SCM arg3
);
52 SCM
call4_hooks (SCM hook_type
, SCM arg1
, SCM arg2
, SCM arg3
, SCM arg4
);
53 SCM
call5_hooks (SCM hook_type
, SCM arg1
, SCM arg2
, SCM arg3
, SCM arg4
, SCM arg5
);
54 SCM
call6_hooks (SCM hook_type
, SCM arg1
, SCM arg2
, SCM arg3
, SCM arg4
, SCM arg5
, SCM arg6
);
55 SCM
call7_hooks (SCM hook_type
, SCM arg1
, SCM arg2
, SCM arg3
, SCM arg4
, SCM arg5
, SCM arg6
, SCM arg7
);
57 SCM
scwm_run_hook(SCM hook
, SCM args
);
58 SCM
scwm_run_hook_message_only(SCM hook
, SCM args
);
60 SCM
scm_empty_hook_p(SCM hook
);
63 /* new-style SMOBs -- this gives smobs names, too */
64 #define MAKE_SMOBFUNS(T) /* nothing */
65 #define REGISTER_SCWMSMOBFUNS(T) \
67 scm_tc16_scwm_ ## T = scm_make_smob_type_mfpe( #T, 0, &(mark_ ##T), &(free_ ## T), &(print_ ## T), NULL); \
71 #ifndef SCWM_EXTRACT_COMMENTS
72 /* do not define this macro if we are extracting comments since
73 the macro name is used as a lexical cue to the extractor */
75 /* SCWM_VAR_INIT, SCWM_VAR still require a variable declaration */
77 #define SCWM_VAR_INIT(cvar, name, val) \
78 do { pscm_ ## cvar = SCM_CDRLOC( \
79 scm_sysintern(name, val) ); } while (0)
81 #define SCWM_VAR(cvar, name) \
82 do { pscm_ ## cvar = SCM_CDRLOC( \
83 scm_sysintern0(name) ); } while (0)
86 /* GJB:FIXME:: Note that cvar is ignored for now */
87 #define SCWM_VAR_READ_ONLY(cvar, name,val) \
88 do { scm_sysintern(name,val); \
92 #endif /* !SCWM_EXTRACT_COMMENTS */
95 /* Check if the scm variable is undefined or #f -- these cases
96 correspond to places where we want to use a default value
97 either because the args were omitted, or #f was used to skip
98 the argument to get to an argument that the client wanted to
100 Intentionally not named SCM_UNSET, since that would imply
101 it's part of guile */
102 #define UNSET_SCM(x) (((x) == SCM_UNDEFINED) || ((x) == SCM_BOOL_F))
104 #define GC_MARK_SCM_IF_SET(scm) do { if (scm && !UNSET_SCM((scm))) \
105 { scm_gc_mark((scm)); } } while (0)
107 /* a NEWSMOB variation that hides the tc16 part */
108 /*#define SGT_NEWCELL_SMOB(ANSWER,ID,PSMOB) \
110 SCM_NEWCELL((ANSWER)); \
111 SCM_SETCAR((ANSWER),(scm_tc16_scwm_ ## ID)); \
112 SCM_SETCDR((ANSWER),(SCM) (PSMOB)); \
116 #define SGT_NEWCELL_SMOB(ANSWER,ID,PSMOB) \
118 SCM_NEWSMOB(ANSWER, (scm_tc16_scwm_ ## ID), (SCM) (PSMOB)); \
121 #define DEREF_IF_SYMBOL(x) do { if (gh_symbol_p((x))) { \
122 (x) = scm_symbol_binding(SCM_BOOL_F,(x)); \
125 #define DYNAMIC_PROCEDURE_P(x) (gh_procedure_p((x)) || \
126 (gh_symbol_p((x)) && \
127 gh_procedure_p(scm_symbol_binding(SCM_BOOL_F,(x)))))
129 #define PROCEDURE_OR_SYMBOL_P(x) (gh_procedure_p((x)) || gh_symbol_p((x)))
134 #define scwm_ptr2scm(p) gh_long2scm((long)(p))
136 #define SCM_BOOL_FromBool(x) ((x)? SCM_BOOL_T: SCM_BOOL_F)
140 #define PackedBool(x) unsigned short x:1
142 #endif /* SCWM_GUILE_H__ */
144 /* Global variables */
146 /* Local Variables: */
148 /* c-basic-offset: 2 */