This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: a module spanning a .c and a .scm file


Shawn <sabetts@vcn.bc.ca> writes:

> I have figured out how to create a module in scheme with
> (define-module ...) and I can create a module in c with
> scm_register_module_xxx. Is there a way I could have a module span .c
> and .scm files? That is, I have some functions for a module defined in
> a .scm file and others defined in .c file, how could I load them all
> with one
> 
> (use-modules (i-dig the-modules))
> 
> I tried just dynamically linking the c functions and calling an
> scm_init_the_module function from within the .scm file, which sorta worked
> except that I couldn't access any of the scm functions from the c
> library. I'm guessing they weren't added the same way a (define-public
> ...) procedure is added.

Here is how GOOPS achieves to have mixed C and Scheme in the module
(oop goops):

1. Create a dynamically loadable library called libgoopscore which
   registers the module (oop goops goopscore) using
   scm_register_module_xxx, and place a link to the .la file on the
   load path.

2. Create a Scheme module goops.scm starting with

   (define-module (oop goops)
     :use-module (oop goops goopscore)
     ...)

3. Switch to the (oop goops) module in the init function for the
   goopscore module.  (Please refer to guile-oops/goops.c.)

(This problem will get a final solution with the new module system.)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]