Re: [Chicken-users] foreign: Why is passing structs as arguments and return-types not supported?

2012-03-04 Thread Kristian Lein-Mathisen
Hi guys, I'd like to give a short status-update on the issue. Based on the feedback on this thread and #chicken, the original plan was to patch up chicken-core to support struct-by-val argument- and return-type passing. This turned out to be very complex indeed. It's unclear of how to represent

[Chicken-users] foreign: Why is passing structs as arguments and return-types not supported?

2012-02-29 Thread Kristian Lein-Mathisen
Hi guys! Reading the chicken docs on foreign, you'll find: Structs cannot be directly passed as arguments to foreign functions, nor can they be result values. ( http://api.call-cc.org/doc/foreign/types#def:struct) Pointers to structs are supported, but not structs-by-value. I am wondering if

Re: [Chicken-users] foreign: Why is passing structs as arguments and return-types not supported?

2012-02-29 Thread Thomas Chust
On Wed, 2012-02-29 at 14:07 +0100, Kristian Lein-Mathisen wrote: [...] Reading the chicken docs on foreign, you'll find: Structs cannot be directly passed as arguments to foreign functions, nor can they be result values.

Re: [Chicken-users] foreign: Why is passing structs as arguments and return-types not supported?

2012-02-29 Thread Alaric Snell-Pym
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/29/2012 01:29 PM, Thomas Chust wrote: Last but not least, passing structures as pointers makes memory management for them explicit and that is a good thing in this case because there is simply no way the FFI could automatically figure out

Re: [Chicken-users] foreign: Why is passing structs as arguments and return-types not supported?

2012-02-29 Thread Kristian Lein-Mathisen
Thanks to both of you for some valuable insight! I didn't realize de-referencing on the c-side would be that simple, nor that structs-by-value would actually be pointers anyway. However, my problem is still not entirely solved. I am trying to interface to the physics engines Box2D and Chipmunk,

Re: [Chicken-users] foreign: Why is passing structs as arguments and return-types not supported?

2012-02-29 Thread Alaric Snell-Pym
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/29/2012 03:18 PM, Kristian Lein-Mathisen wrote: Since struct-by-value is so central in both of these libraries, manually writing wrapper-code would take too long. I am unsure of where to go from here, but I suppose my options are: - Modify

Re: [Chicken-users] foreign: Why is passing structs as arguments and return-types not supported?

2012-02-29 Thread Moritz Heidkamp
Kristian Lein-Mathisen kristianl...@gmail.com writes: Any thoughts on how to pursue this? Another option would be to create a module which re-exports all `foreign' syntax wrapped with support for structs-by-value. Then just import your wrapper module instead of `foreign' in the code generated