guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cmod-play 1 available + modsup.h additions


From: Thien-Thi Nguyen
Subject: cmod-play 1 available + modsup.h additions
Date: Thu, 13 Nov 2003 22:55:53 +0100

folks,

libtool modules cannot depend on other libtool modules (according to the
documentation on libltdl), so we can't co-opt that strategy if we want
to design compiled modules that depend on other modules.  sure, we can
throw up our hands and relegate everything to the system linker/loader,
but why pass up a thorny question for others to play with?  i mean, to
do system programming you need to grab control of the system, and to do
module system programming you need to grab control of the module system.

so, this message actually presents two pieces of source code: (1) a
pointer to the documented exploratory process:

  http://www.glug.org/people/ttn/software/cmod-play/

and (2) a request for comments on the tentative conclusions of the above
exploration, as expressed by the additional <guile/modsup.h> interface
elements excerpted below.  if All Goes Well, they will appear in guile
1.4.1.97.

in other news, i will be using this new support immediately for
guile-sdl compiled modules (the motivation for all this, you see), so to
spare everyone the agony guile-sdl will not be released until 1.4.1.97
is out.  (however, everything works swimmingly from cvs, if you are
feeling adventurous. :-)

thi

_____________________________________________________________
/*:Return the @var{obj} given, but marked as "permanent".
   This means that it can never be garbage collected.
*/
#define GHSTONED(obj) \
  scm_permanent_object (obj)

/*:Declare and later arrange for @var{cvar} (type SCM) to hold a resolved
   module object for @var{fullname}, a C string such as "(ice-9 q)".  The
   string is saved in a C variable named by prefixing "s_" to @var{cvar}.
   You must use @var{cvar} as the second arg to @code{MUSEMODULEVAR}.
*/
#define MUSEMODULE(cvar,fullname) \
SCM_SNARF_HERE (static char * s_ ## cvar = fullname; static SCM cvar) \
SCM_SNARF_INIT (cvar = GHSTONED (gh_resolve_module (s_ ## cvar));)

/*:Declare and later arrange for @var{cvar} (type SCM) to have the
   same value as the imported module @var{m_cvar} variable @var{s_name}.
   @var{m_cvar} is the SCM object declared with @code{MUSEMODULE}, and
   @var{s_name} is a string such as "q-empty?".  If the imported value
   is a procedure, you can use @code{gh_apply} or @code{gh_call0} through
   @code{gh_call3} on it.
*/
#define MUSEMODULEVAR(cvar,m_cvar,s_name) \
SCM_SNARF_HERE (static SCM cvar) \
SCM_SNARF_INIT (cvar = GHSTONED (gh_module_lookup (m_cvar, s_name));)

/*:Declare and define a procedure @var{cvar} that takes 0 (zero) args,
   which returns the result of calling @code{gh_call0} on @var{proc_cvar}.
   @var{proc_cvar} is the SCM object declared with @code{MUSEMODULEVAR}.
*/
#define MUSEMODULEPROC0(cvar,proc_cvar) \
  static SCM cvar (void) \
  { return gh_call0 (proc_cvar); }

/*:Declare and define a procedure @var{cvar} that takes 1 (one) SCM arg,
   which returns the result of calling @code{gh_call1} on @var{proc_cvar}
   and this arg.  @var{proc_var} is the SCM object declared with
   @{MUSEMODULEVAR}.
*/
#define MUSEMODULEPROC1(cvar,proc_cvar) \
  static SCM cvar (SCM a1) \
  { return gh_call1 (proc_cvar, a1); }

/*:Declare and define a procedure @var{cvar} that takes 2 (two) SCM args,
   which returns the result of calling @code{gh_call2} on @var{proc_cvar}
   and the args.  @var{proc_var} is the SCM object declared with
   @{MUSEMODULEVAR}.
*/
#define MUSEMODULEPROC2(cvar,proc_cvar) \
  static SCM cvar (SCM a1, SCM a2) \
  { return gh_call2 (proc_cvar, a1, a2); }

/*:Declare and define a procedure @var{cvar} that takes 3 (three) SCM args,
   which returns the result of calling @code{gh_call3} on @var{proc_cvar}
   and the args.  @var{proc_var} is the SCM object declared with
   @{MUSEMODULEVAR}.
*/
#define MUSEMODULEPROC3(cvar,proc_cvar) \
  static SCM cvar (SCM a1, SCM a2, SCM a3) \
  { return gh_call3 (proc_cvar, a1, a2, a3); }

[modsup.h excerpt ends here]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]