Node:Macros guile-snarf recognizes, Next:Writing your own snarfing macros, Previous:How guile-snarf works, Up:Init Snarfing with guile-snarf
Here are the macros you can use in your source code from which
guile-snarf
can construct initialization code:
/* procedures */ SCM_DEFINE (FNAME, PRIMNAME, REQ, OPT, VAR, ARGLIST, DOCSTRING) SCM_PROC (RANAME, STR, REQ, OPT, VAR, CFN) SCM_REGISTER_PROC (RANAME, STR, REQ, OPT, VAR, CFN) SCM_GPROC (RANAME, STR, REQ, OPT, VAR, CFN, GF) /* everything else */ SCM_SYMBOL (c_name, scheme_name) SCM_GLOBAL_SYMBOL (c_name, scheme_name) SCM_KEYWORD (c_name, scheme_name) SCM_GLOBAL_KEYWORD (c_name, scheme_name) SCM_VARIABLE (c_name, scheme_name) SCM_GLOBAL_VARIABLE (c_name, scheme_name) SCM_VARIABLE_INIT (c_name, scheme_name, init_val) SCM_GLOBAL_VARIABLE_INIT (c_name, scheme_name, init_val)
REQ and OPT are numbers indicating required and optional argument
counts, respectively; VAR is a number that, if non-zero, means the
function will accept any remaining arguments as a list; DOCSTRING is a
string (use \n\
at eol for multi-line); FNAME is a C-language
identifier, CFN and GF and c_name likewise; PRIMNAME is a string
denoting the name available to Scheme code, STR and scheme_name
likewise; RANAME is the name of the static string (must match that
declared by the associated definition of cpp macro FUNC_NAME);
ARGLIST is an argument list (in parentheses); and lastly, init_val
is a expression suitable for initializing a new variable.
For procedures, you can use SCM_DEFINE
for most purposes. Use
SCM_PROC
along with SCM_REGISTER_PROC
when you don't
want to be bothered with docstrings. Use SCM_GPROC
for generic
functions (see GOOPS). All procedures are declared with
return type SCM
.
For everything else, use the appropriate macro (SCM_SYMBOL
for
symbols, and so on). Without "_GLOBAL_", the declarations are
static
.
All these macros should be used at top-level, outside function bodies.
Also, it's a good idea to define FUNC_NAME immediately after using
SCM_DEFINE
(and similar), and then the function body, and then
#undef FUNC_NAME
.
See How guile-snarf works, and also libguile source, for examples. See Subrs, for details on argument passing and how to write C functions.