[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MIT-Scheme-devel] [PATCH] FFI: Fixing problem with groveller for st
From: |
Peter Feigl |
Subject: |
Re: [MIT-Scheme-devel] [PATCH] FFI: Fixing problem with groveller for structures with typedefs. |
Date: |
Wed, 12 Dec 2012 20:26:31 +0100 |
User-agent: |
Notmuch/0.11+77~gad6d0d5 (http://notmuchmail.org) Emacs/24.1.50.2 (i686-pc-linux-gnu) |
> I can't imagine just chopping "struct" off a type declaration (moving
> it from one namespace to another!) can be the solution. Can we start
> with an example?
>
> I tried generating a shim for the API you gave and had no problem.
>
> (typedef a (struct (x int)))
>
> (extern (* a) test_func (arg (* a)))
You are of course entirely correct, I omitted the typedef (and used a
named struct), which resulted (correctly) in incorrect C code. The above
code works fine!
> There IS a problem with
>
> (extern a test_func (arg a))
>
> signaled by a warning "Unexpected return type: (struct (x . int))".
> (It could call that an "unsupported return type", and warn about the
> type of ARG too.)
I've been playing around with the shim C code, is there a way I can
create an alien that contains a struct? Then it should be possible to
support structs as return and parameter types. Are aliens
garbage-collected automatically? Can I just malloc some memory for an
alien, then cons_alien it, then expect it to be garbage-collected later?
Thanks for helping me with my questions here!
Peter