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

Mikael mikael.rcv at gmail.com
Tue Sep 20 14:58:33 EDT 2011


Dear Marc,

Can a present object (u8vector etc.) be switched between ___STILL /
___MOVABLE / ___PERMANENT, if so how from Scheme respectively C?

Also just to check, on vector create-time there's no way to specify GC
object type right (in make-u8vector etc.)?

Many thanks,
Mikael

2010/3/30 Marc Feeley <feeley at iro.umontreal.ca>

>
> On 2010-03-30, at 10:34 AM, Alex Queiroz wrote:
>
> >     I always use ___FETCH_U* with a C integer as the second argument,
> > i. e., I don't use the ___INT() conversion macro.
>
> Indeed the ___INT(x) macro converts the fixnum x into a C int.  It is the
> inverse of the ___FIX(n) macro which converts a C int into a fixnum.
>
> The simplest way to do what you want is:
>
> char *u8vectorptr =
> ___CAST(char*,___BODY(theu8vectorschemeobjectvariable));
>
> then
>
> u8vectorptr[i] = ...;
>
> Note that you can only do this if the u8vector will not move (it is either
> a ___STILL or ___PERM object, or you don't make any calls back to Scheme or
> the Gambit memory allocator inside your C function.
>
> Marc
>
> _______________________________________________
> 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/20110920/d2a204b5/attachment.htm>


More information about the Gambit-list mailing list