2 @c This is part of the GNU Guile Reference Manual.
3 @c Copyright (C) 1996, 1997, 2000, 2001, 2002, 2003, 2004
4 @c Free Software Foundation, Inc.
5 @c See the file guile.texi for copying conditions.
9 @section Snarfing Macros
10 @cindex guile-snarf recognized macros
11 @cindex guile-snarf deprecated macros
13 The following macros do two different things: when compiled normally,
14 they expand in one way; when processed during snarfing, they cause the
15 @code{guile-snarf} program to pick up some initialization code,
16 @xref{Function Snarfing}.
18 The descriptions below use the term `normally' to refer to the case
19 when the code is compiled normally, and `while snarfing' when the code
20 is processed by @code{guile-snarf}.
22 @deffn {C Macro} SCM_SNARF_INIT (code)
24 Normally, @code{SCM_SNARF_INIT} expands to nothing; while snarfing, it
25 causes @var{code} to be included in the initialization action file,
26 followed by a semicolon.
28 This is the fundamental macro for snarfing initialization actions.
29 The more specialized macros below use it internally.
33 @deffn {C Macro} SCM_DEFINE (c_name, scheme_name, req, opt, var, arglist, docstring)
35 Normally, this macro expands into
38 static const char s_@var{c_name}[] = @var{scheme_name};
40 @var{c_name} @var{arglist}
43 While snarfing, it causes
46 scm_c_define_gsubr (s_@var{c_name}, @var{req}, @var{opt}, @var{var},
50 to be added to the initialization actions. Thus, you can use it to
51 declare a C function named @var{c_name} that will be made available to
52 Scheme with the name @var{scheme_name}.
54 Note that the @var{arglist} argument must have parentheses around it.
57 @deffn {C Macro} SCM_SYMBOL (c_name, scheme_name)
58 @deffnx {C Macro} SCM_GLOBAL_SYMBOL (c_name, scheme_name)
59 Normally, these macros expand into
62 static SCM @var{c_name}
71 respectively. While snarfing, they both expand into the
75 @var{c_name} = scm_permanent_object (scm_from_locale_symbol (@var{scheme_name}));
78 Thus, you can use them declare a static or global variable of type
79 @code{SCM} that will be initialized to the symbol named
83 @deffn {C Macro} SCM_KEYWORD (c_name, scheme_name)
84 @deffnx {C Macro} SCM_GLOBAL_KEYWORD (c_name, scheme_name)
85 Normally, these macros expand into
88 static SCM @var{c_name}
97 respectively. While snarfing, they both expand into the
101 @var{c_name} = scm_permanent_object (scm_c_make_keyword (@var{scheme_name}));
104 Thus, you can use them declare a static or global variable of type
105 @code{SCM} that will be initialized to the keyword named
109 @deffn {C Macro} SCM_VARIABLE (c_name, scheme_name)
110 @deffnx {C Macro} SCM_GLOBAL_VARIABLE (c_name, scheme_name)
111 These macros are equivalent to @code{SCM_VARIABLE_INIT} and
112 @code{SCM_GLOBAL_VARIABLE_INIT}, respectively, with a @var{value} of
116 @deffn {C Macro} SCM_VARIABLE_INIT (c_name, scheme_name, value)
117 @deffnx {C Macro} SCM_GLOBAL_VARIABLE_INIT (c_name, scheme_name, value)
119 Normally, these macros expand into
122 static SCM @var{c_name}
131 respectively. While snarfing, they both expand into the
135 @var{c_name} = scm_permanent_object (scm_c_define (@var{scheme_name}, @var{value}));
138 Thus, you can use them declare a static or global C variable of type
139 @code{SCM} that will be initialized to the object representing the
140 Scheme variable named @var{scheme_name} in the current module. The
141 variable will be defined when it doesn't already exist. It is always