guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bytestructures, FFI


From: Taylan Ulrich Bayırlı/Kammer
Subject: Re: Bytestructures, FFI
Date: Wed, 01 Jun 2016 00:07:52 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Amirouche Boubekki <address@hidden> writes:

> On 2016-05-31 21:29, address@hidden wrote:
>> scheme@(guile-user)> (define testfunc
>>                        (bs:pointer->proc
>>                         foo_t  ;return value type
>>                         (dynamic-func "testfunc" (dynamic-link
>> "libtest"))
>>                         (list foo_t)))  ;list of argument types
>
> Why don't you use dynamic-link* signature like described in [1]:
>
>   ((dynamic-link* [library-name]) return-type function-name . arguments)
>
> [1] http://www.hyperdev.fr/notes/gnu-guile-ffi.html

Hmm, if one wishes, one can wrap bs:pointer->proc in a similar fashion;
I'll leave that up to the users of the library. :-)

>> scheme@(guile-user)> (define foo2 (testfunc foo))
>
> isn't foo2 `equal?' to foo?

I'm not sure how you mean exactly.  Firstly, foo and foo2 are separate
record instances, so they wouldn't be equal? even if they contained the
same values in the same fields (using equal? on record objects falls
back to using eqv?), but they also contain different values in their
fields, since foo2 is the one returned by 'testfunc'.  (Also remember
that structs are passed by-value in C, so testfunc receives a *copy* of
foo as its argument when it's called, which it then modifies and
returns.)

Hope that helps!
Taylan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]