[plt-scheme] cffi.ss

From: Ed Cavazos (proteus at theworld.com)
Date: Wed Jun 25 03:55:22 EDT 2003

On Wednesday 25 June 2003 01:19 am, David Van Horn wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Ed Cavazos wrote:
> > I noticed in the Gambit-C manual that an allowed type specifier in
> > c-lambda is one of: "c-type-id". So, just a string naming a C
> > type. For example, given these 2 C function prototypes:
> >
> > person make_person(char *name);
> > int    move_person(person p);
> >
> > I guess the c-lambda code would be:
> >
> > (c-lambda (char-string) "person" "make_person")
> > (c-lambda ("person")    int      "move_person")
> >
> > It doesn't look like the current cffi.ss supports this. Would adding
> > this be as simple as modifying cffi.ss or would support have to be
> > added to mzc itself?
> >
> > Ed
>
> I believe in Gambit this should be:
>
> (c-define-type person "person")
> (c-lambda (char-string) person "make_person")
> (c-lambda (person)      int    "move_person")
>
> -d

Yes, you're right. I was smoking crack. I just read in the Gambit-C manual 
that what I specified above is prohibited. You have to first use 
c-define-type, then c-lambda can accept this type as an arg or return item. 
Here's the exact paragraph that mentions this:

"Note that not all of these types can be used in all contexts. In particular 
the arguments and result of functions defined with c-lambda and c-define can 
not be (struct "name") or (union "name") or "c-type-id". On the other hand, 
pointers to these types are acceptable."

So the right thing to do is implement c-define-type and teach c-lambda to 
recognize these newly defined types. It's not clear to me how the code 
generated by c-lambda and c-declare is communicated back to mzc. Something to 
do with the mzc-cffi syntax-property. So I guess that implementing the 
c-define-type macro would involve modifying mzc.(?)

Ed


Posted on the users mailing list.