[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Including C struct definitions
From: |
Nicolas Pelletier |
Subject: |
Re: [Chicken-users] Including C struct definitions |
Date: |
20 Dec 2004 14:16:46 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Joel Reymont <address@hidden> writes:
> > Nicolas Pelletier wrote:
>
> >SWIG is used to provide access to C functions (a lib or custom code)
> >to a higher-level language, isn't it ? I am trying to achieve the
> >converse: calling from C into Scheme and exchanging structures in both
> >directions.
>
> Well, what SWIG does to register your structure and access methods is
> something that you could do yourself, I think. But I see where you are
> coming from. If the structure was registered "natively" with Chicken
> then
> you won't need C access wrapper methods.
Yes.
> SWIG registers a bunch of C accessor functions that take the structure/
> class pointer as an argument and get or set structure fields. Then it
> wraps the whole thing in TinyCLOS code if you ask it to.
>
> I think you could achieve what you are looking for by calling the SWIG-
> generated accessors from your Scheme code, whether you call that code
> from C or from Scheme shouldn't matter.
Thank you for pointing this. The primitive accessors/mutators for the
structures' fields can be "unhidden" (they are static C functions by
default), or I could try and use TinyCLOS, which gives
accessors/mutators already, and would allow me to implement
structure-specific behaviour easily... Hmmm, how cute !
--
Nicolas