[plt-scheme] cffi.ss

From: Ed Cavazos (proteus at theworld.com)
Date: Mon Jun 23 19:04:16 EDT 2003

On Monday 23 June 2003 11:48 am, Matthew Flatt wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> At 23 Jun 2003 02:26:02 -0500, Ed Cavazos wrote:
> > 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?
> You could do it just changing "cffi.ss", I think.
> Matthew

Just a few days ago I was asking basic questions about how syntax-case works. 
Boy, did I walk into a warzone when I visited "cffi.ss". I feel violated. ;-)

Ahem. Anywho, I got it to work. The file is a total mess right now but if 
you're interested absorbing this I may be able to clean it up. The hacked up 
version is at:


I say I "may" be able to clean it up because I'm not even sure it's "correct" 
or if the hacks I put in make sense. But they made enough sense to call Xlib 
and launch some windows...

Again, I wanted the ability to return values of arbitrary C types to Scheme 
and pass them back in as arguments. Obviously, to be returned to Scheme, the 
value must be wrapped up in a Scheme_Object. I'm scheme_mallocing sizeof the 
indicated type and assigning the original C value to the new space. Then I'm 
boxing up the pointer to the space in a c-ptr object and returning it. The 
downside is that from the Scheme side of things, the printed representation 
says it's a pointer (#<c-pointer:foo>) when really it should just be 
(#<c-val:foo>). But that's minor.


Posted on the users mailing list.