[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ffi docs
From: |
Ludovic Courtès |
Subject: |
Re: ffi docs |
Date: |
Tue, 27 Jul 2010 10:24:10 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Hi!
Neil Jerram <address@hidden> writes:
>> Void pointers may be accessed as bytevectors.
>>
>> -- Scheme Procedure: foreign->bytevector foreign [uvec_type [offset
>> [len]]]
>> -- 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'
>> array.
>
> 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
> API?
Andy and I discussed it at GHM, which led to this simplification of the API:
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=d4149a510e4a87915b625255f4de3301510d810c
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).
Thanks,
Ludo’.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: ffi docs,
Ludovic Courtès <=