[gambit-list] How to pass a u8vector to the FFI

Mikael mikael.trash at gmail.com
Tue Mar 30 08:39:54 EDT 2010


You do this, by declaring the passed u8vector as a scheme-object in the
c-lambda definition.

The memory pointer to the u8vector's contents in the C code is resolved by

     void *u8vectorptr =
___CAST(void*,&___FETCH_U8(___BODY(theu8vectorschemeobjectvariable),___INT(0)));

Remember that the pointer is only to be kept until the next return to
Scheme.

Mikael

2010/3/30 Álvaro Castro-Castilla <alvaro.castro.castilla at gmail.com>

> Hi!
>
> Is there a way to pass a u8-vector to a FFI interface somehow?
> The way I expect this to work is through a (pointer unsigned-char), but it
> obviously doesn't work, claiming a proper C pointer. I would like to be able
> to build this arrays from Scheme code. Is there a way?
>
> Currently I have to call a FFI function to set char by char, calling the
> c-lambda function too many times.
>
> One thing that could work is something that converts u8-vectors to unsigned
> char* arrays, does that exist in Gambit?
>
>
> Thanks,
>
> Álvaro
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20100330/f0c56b7d/attachment.htm>


More information about the Gambit-list mailing list