unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* c interface to modules
@ 2005-06-16 19:40 Ondrej Zajicek
  2005-06-17 22:44 ` Rob Browning
  2005-06-17 23:38 ` Jonathan Wilson
  0 siblings, 2 replies; 3+ messages in thread
From: Ondrej Zajicek @ 2005-06-16 19:40 UTC (permalink / raw)


Hello
I would like to export two sets (low-level and high-level interface)
of C functions to Scheme. I think it is a good idea to have each
interface in different module. What is a good way to define C
function in specific module? Should i just replace scm_c_define_gsubr
with combination of scm_c_make_gsubr and scm_c_module_define?

-- 
Elen sila lumenn' omentielvo

Ondrej 'SanTiago' Zajicek (email: santiago@mail.cz, jabber: santiago@njs.netlab.cz)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c interface to modules
  2005-06-16 19:40 c interface to modules Ondrej Zajicek
@ 2005-06-17 22:44 ` Rob Browning
  2005-06-17 23:38 ` Jonathan Wilson
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Browning @ 2005-06-17 22:44 UTC (permalink / raw)
  Cc: guile-user

Ondrej Zajicek <santiago@mail.cz> writes:

> I would like to export two sets (low-level and high-level interface)
> of C functions to Scheme. I think it is a good idea to have each
> interface in different module. What is a good way to define C
> function in specific module? Should i just replace
> scm_c_define_gsubr with combination of scm_c_make_gsubr and
> scm_c_module_define?

If you write each of your modules as a .scm file which loads a C
library and calls an init function (see 1.6's srfi-13.scm, for
example), then you can just have two init functions in your C library,
one for the low-level functions, and one for the high-level functions,
i.e.

  ;; high-level.scm
  (define-module (high-level))
  (load-extension "libguile-foo-v-1" "scm_init_foo_high_level")
  (export bar)
  ...


  ;; high-level.scm
  (define-module (low-level))
  (load-extension "libguile-foo-v-1" "scm_init_foo_low_level")
  (export baz)
  ...

-- 
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c interface to modules
  2005-06-16 19:40 c interface to modules Ondrej Zajicek
  2005-06-17 22:44 ` Rob Browning
@ 2005-06-17 23:38 ` Jonathan Wilson
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Wilson @ 2005-06-17 23:38 UTC (permalink / raw)


Whoops! I always forget and just hit reply, then the message doesn't go 
to the list.

Ondrej Zajicek wrote:

>Hello
>I would like to export two sets (low-level and high-level interface)
>of C functions to Scheme. I think it is a good idea to have each
>interface in different module. What is a good way to define C
>function in specific module? Should i just replace scm_c_define_gsubr
>with combination of scm_c_make_gsubr and scm_c_module_define?
>
>  
>
Hi Ondrej!
I would use SWIG if I were you.  Very simple, fast, and easy.  Does all
the drudge work of creating wrapper functions and all for you.
http://www.swig.org/  I have not used it for anything large scale, but
the smaller scale stuff I have done to test it out worked like a charm!
It will create a xxx_wrap.c file for every xxx.c or xxx.h file you feed
it, then you compile these wrapper files and link them into a shared
library along with the original code (and whatever libraries it needs to
link with).  Then you can either just use (load-extension "xxx.so"
"SWIG_init") directly, or write a module in Scheme that loads the shared
lib whenever the module is loaded.

Best of luck!
Jon




_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-06-17 23:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-16 19:40 c interface to modules Ondrej Zajicek
2005-06-17 22:44 ` Rob Browning
2005-06-17 23:38 ` Jonathan Wilson

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).