[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ffi docs
Re: ffi docs
Tue, 27 Jul 2010 10:24:10 +0200
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Neil Jerram <address@hidden> writes:
>> Void pointers may be accessed as bytevectors.
>> -- Scheme Procedure: foreign->bytevector foreign [uvec_type [offset
>> -- C Function: scm_foreign_to_bytevector foreign uvec_type offset len
>> Return a bytevector aliasing the memory pointed to by FOREIGN.
>> FOREIGN must be a void pointer, a foreign whose type is VOID. By
>> default, the resulting bytevector will alias all of the memory
>> pointed to by FOREIGN, from beginning to end, treated as a `vu8'
> It feels like we're missing a unification trick here.
> Thought #1: if we have, e.g., an int8 pointer ip, why not just use
> (foreign-ref ip n) to interpret the pointer as pointing to an array, and
> get its nth element?
> Thought #2: but if we do that we'll be duplicating the bytevector API.
> So instead, shouldn't the fundamental operation be (foreign->bytevector
> NAME TYPE LIBRARY [LEN]), and get/set then done using the bytevector
Andy and I discussed it at GHM, which led to this simplification of the API:
There are a few more changes coming: renaming some of the procedures
from ‘foreign’ to ‘pointer’, and adding more convenience procedures
(C string manipulation notably).
|[Prev in Thread]
||[Next in Thread]|
- Re: ffi docs,
Ludovic Courtès <=