chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] hygienic egg PORT-A-MANIA!


From: felix winkelmann
Subject: Re: [Chicken-users] hygienic egg PORT-A-MANIA!
Date: Tue, 26 Aug 2008 11:07:33 +0200

On Tue, Aug 26, 2008 at 7:00 AM, Ivan Raikov <address@hidden> wrote:
>
>> Just give me an exact specification and I'll add it (if possible).
>
> Well, in SWIG you can specify an exception handler like this:
>
> %exception
> {
>     const char *err;
>     clear_exception();
>     $action
>     if ((err = check_exception()))
>     {
>          SWIG_exception(SWIG_IOError, error_string);
>     }
> }
>
>
> And this code is inserted in every wrapper for a C function, while
> replacing $action with the C function invocation. I would like to have
> such a feature in easyffi.

Ok, I'll try to do so.

>
>>
>>> I also remember
>>> that I did something with SWIG typemaps that allowed in/out arguments,
>>> and I am not sure how to reproduce those semantics with the native
>>> Chicken FFI, other than writing a Scheme wrapper for each C procedure
>>> that has in/out arguments.
>>
>> Easyffi makes this actually quite easy.
>
>  Ok, how to do that automatically? Let's make things simple: how can
> easyffi take a C procedure with one or more out arguments, and create
> a Scheme wrapper that returns a list containing the values of the out
> arguments.
>

like this:

(foreign-parse/declare #<<END
int foo(___out int *x, ___out int *y);
END
)

(define-values (r1 x y) (foo))

Out (or in/out) parameters are returned after the default return value (if any).


cheers,
felix




reply via email to

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