On Thu, 2001-11-15 at 10:37, Derek Atkins wrote:
> Let's say I have some C-library, foo, that I want to:
>       a) turn into a gnc-module, and
>       b) g-wrap the interfaces to allow scheme hooks..
> 
> To do this, I would create:
>       libgnc-foo.so -- the C library plus gnc-module initialization code
>                       for gnc-module "gnucash/foo".

We've been using the namign convention 'libgncmod-foo.la' for
gnc-modules, to distinguish them from normal shared libraries.  For
example, libgncmod-engine.la is a gnc-module but libgncgnome.la is not. 

>       libgw-foo.so -- the g-wrap function stub library
> 
>       gw-foo{,-spec}.scm  -- the gw-foo guile module that loads the
>                       libgw-foo shared object and exports the symbols
> 
>       foo.scm -- a guile module the gnc-module "gnucash/foo" can
>                       execute at load-time to auto-load the g-wrapped
>                       module via (use-modules (g-wrapped gw-foo)).
> 
> Then in other scheme code (e.g. extensions.scm), all I need to do is:
>       (gnc:module-load "gnucash/foo")
> and it will autoload everything above for me, and then I have access
> to all my module symbols.

That's all correct. 

> Assuming I'm correct so far, then is it reasonable to have a
> gnc-module gnucash/bar (similarly laid out as above), where bar.scm
> has (gnc:module-load "gnucash/foo")?

Yes, but it may not do exactly what you expect.  the gnc-module system
is outside the Scheme module system but has to live within its
limitations where they interact.  If you call (gnc:module-load
"gnucash/foo" 0) within the Guile define-module block for (gnucash bar),
the Scheme symbols for foo will only be visible within bar.  If you want
them to be visible to modules that module-load bar, you need to make
sure to export them within bar.scm.  

You can also do this by calling the gnc:module-load from C, inside the
gnc_module_init function for bar. That's the recommended way to do it,
because you can't guarantee that the module will be loaded from Scheme, 
and you want a C load to load dependent modules as well. 

b.g.


_______________________________________________
gnucash-devel mailing list
[EMAIL PROTECTED]
http://www.gnucash.org/cgi-bin/mailman/listinfo/gnucash-devel

Reply via email to