guile-devel
[Top][All Lists]
Advanced

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

Re: goops C interface


From: Dale P. Smith
Subject: Re: goops C interface
Date: Sat, 21 Oct 2000 00:39:02 -0400

Eric Moore wrote:
> 
> >>>>> "Dale" == Dale P Smith <address@hidden> writes:
> 
> Dale> First, a question: How do you wrap a C struct containing char
> Dale> *'s?  Would this work?
> 
> [snip]
> 
> Looks right to me, I'll try it and see if it works :)

Well, there isn't a gh_scm2str, and if you use gh_scm2newstr there will
be leaks.

> 
> [snip]
> 
> Dale> There already are tools out there, g-wrap and swig come to mind,
> Dale> that might be a good starting point for this tool.
> 
> Dale> What do you think?
> 
> I think it's a good idea, but somewhat separate from the process of
> providing an API.  Some form of API is needed by the glue-generator to
> generate the glue in, and right now, I'd like to limit what I'm doing
> to the API.  I suppose I could however take a look at what swig and
> g-wrap do and make ure whatever functions they need are in the API :)

I haven't looked at them that closely, but it appears they are more for
for wrapping function calls than for wrapping data structures.  I think
is very important to be able to access an already existing structure. 
I'm thinking of things like a mod_guile (which I'm playing around with)
where Apache calls your function with a pointer to a structure.  Some
members you can play with, some are read-only.  Some are pointers to
other structures (as in a linked list) for administrative purposes.

Basic types are easy, the storage for them is already there as part of
the structure, but what about pointers to things?  Who is responsible
for memory management?  The goops C api probably needs a way to specify
who is going to free the old junk when freshly malloced memory is
pointed to. Something like an ownership flag?  If the memory is
application (not guile) owned, there are probably routines to free and
allocate that memory.  There probably needs to be a way to specify them
too.

Is it enough to create a new class for each "application-owned" slot and
use the SCM_ROSLOT_PTR and SCM_SLOT_PTR macros?  Hmmm...  Um, I'll just
shut up now..  ;^)

-Dale

-- 
Dale P. Smith
Altus Technologies Corp.
address@hidden
400-746-9000 x309



reply via email to

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