* ${prefix}/include/guile/modsup.h
@ 2003-10-24 14:12 Thien-Thi Nguyen
0 siblings, 0 replies; only message in thread
From: Thien-Thi Nguyen @ 2003-10-24 14:12 UTC (permalink / raw)
Cc: guile-user
folks,
please find below modsup.h, which provides the C macros `MDEFLOCEXP', to
support writing compiled modules with a "minimal public interface"; and
`MDEFLINKFUNC', to support stylized buildtime cataloging and/or runtime
module-name->filename discovery/loading free of a scheme wrapper.
place this file in subdir libguile/ and modify the Makefile.am to read:
# These are headers visible as <guile/mumble.h>
pkginclude_HEADERS = gh.h modsup.h
to get it installed in the right place. alternatively, if you don't
build guile yourself, you can bundle it with your projects.
the particular comment syntax "/*:" ... "^J*/" is for the benefit of
"guile-tools h2doc". you can munge it if you don't use h2doc, or if you
enhance h2doc to handle the modified comment syntax, or if you have an
irrepressible urge to just break things.
thi
____________________________________
/* modsup.h */
/* Copyright (C) 2003 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* The exception is that, if you link the GUILE library with other files
* to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the GUILE library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the
* Free Software Foundation under the name GUILE. If you copy
* code from other Free Software Foundation releases into a copy of
* GUILE, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice. */
\f
/* Usage:
#include "guile/modsup.h"
This provides the macros `MDEFLOCEXP' and `MDEFLINKFUNC'. Together they
support init and doc snarfing of Scheme-visible C functions, as well as
`scm_register_module_xxx'-style dynamic linking and init.
This file should be included in implementation (.c) files only, since it
pollutes the namespace by pulling in various libguile headers. */
#include "libguile/__scm.h"
#include "libguile/snarf.h"
#include "libguile/dynl.h"
/*:Declare, define and document a C function callable from Scheme.
The C function is declared `static' and is "exported" later by the the
module initialization routine. @var{fname} is the name of the C function
(must be a valid C identifier). @var{primname}, a string, is the name
visible from Scheme code. @var{req}, @var{opt} and @var{var} are each
integers quantifying the number of required, optional and rest args are in
the @var{arglist}. Note that @var{var} can be only 0 or 1. @var{arglist}
is the C-style argument list for the function. The type for every element
must be @code{SCM}. @code{docstring} is one or more strings that describe
the function. Each string except the last must end in @code{\n}.
*/
#define MDEFLOCEXP(fname, primname, req, opt, var, arglist, docstring) \
SCM_SNARF_HERE(static SCM fname arglist;) \
SCM_DEFINE (fname, primname, req, opt, var, arglist, docstring)
/*:Define the C function to be called at link time.
This function registers the @var{module_name} (a string) and arranges for
@var{module_init_func} to be called at the right time to actually do the
module-specific initializations. @var{fname_frag} is the C translation of
@var{module_name} with unrepresentable characters replaced by underscore.
It should have the same length as @var{module_name}.
*/
#define MDEFLINKFUNC(module_name, fname_frag, module_init_func) \
void \
scm_init_ ## fname_frag ## _module (void) \
{ \
scm_register_module_xxx (module_name, module_init_func); \
}
/* modsup.h ends here */
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-10-24 14:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-24 14:12 ${prefix}/include/guile/modsup.h Thien-Thi Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).