123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- c This is part of the GNU Guile Reference Manual.
- c Free Software Foundation, Inc.
- node Function Snarfing
- code{scm_c_define_gsubr} or related functions. If you have
- many functions to publish, it can sometimes be annoying to keep the
- list of calls to
- code{guile-snarf} program to manage this problem.
- Using this tool, you can keep all the information needed to define the
- function alongside the function definition itself;
- code{scm_c_define_gsubr} which you can
- code{scm_c_define_gsubr}. For a
- full list of what can be done,
- cindex guile-snarf invocation
- code{guile-snarf} program is invoked like this:
- var{outfile}] [
- end smallexample
- This command will extract initialization actions to
- var{outfile} has been specified or when
- code{-}, standard output will be used. The C preprocessor is called
- with
- var{outfile} is deleted and the
- program exits with non-zero status.
- During snarfing, the pre-processor macro
- smallexample
- #ifndef SCM_MAGIC_SNARFER
- #include "foo.x"
- #endif
- code{clear-image},
- implemented by the C function
- example
- {
-
- {
- #include "image-type.x"
- end group
- code{SCM_DEFINE} declaration says that the C function
- code{clear-image}, which takes one required argument (of type
- code{image_smob}), no optional arguments, and no
- rest argument. The string
- dfn{docstring}.
- code{s_clear_image} is set to the C string, "clear-image". You might
- want to use this symbol when generating error messages.
- Assuming the text above lives in a file named
- example
- guile-snarf -o image-type.x image-type.c
- file{image-type.c} for
- file{image-type.x} the output:
- end example
- When compiled normally,
- code{clear_image}.
- Note that the output file name matches the
- code{scm_c_define_gsubr} yourself, but you
- can place the information near the function definition itself, so it is
- less likely to become incorrect or out-of-date.
- If you have many files that
- example
- snarfcppopts = $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
- .SUFFIXES: .x
- .c.x:
- guile-snarf -o $ $< $(snarfcppopts)
- code{guile-snarf} to produce each needed
- file{.c} file.
- The program
- code{guile-snarf} to define preprocessor
- symbols, add header file directories, and so on.
|