chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Objective-C interface (sort of...)


From: Zbigniew
Subject: Re: [Chicken-users] Objective-C interface (sort of...)
Date: Sat, 26 Nov 2005 14:06:09 -0600

Yes, they use the natural representation, so if you know from the
methodReturnType call that a return type is _C_DBL, you can cast the
return value directly to a double.  E.g. C_flonum(&a, *(double
*)rbuf);   And _C_CLASS is a Class (struct objc_class *) and _C_ID is
an id (struct objc_object *).   And so on.

As an aside, and this is probably not news to you, the BOOL type is
just an alias for signed char.  However, signed char is exceedingly
rare as a return or argument type, it is almost 100% BOOL.  I found it
beneficial to implicitly convert a return of (char)0 into #f --- other
values still return the character itself --- and to convert an signed
char argument of #f or #t into (char)0 or (char)1 --- though character
values are still accepted.  This makes Scheme predicates behave
nicely.  And the rare real signed char returns and args still work,
with the caveat that a #f return would mean #\x0.

On 11/26/05, felix winkelmann <address@hidden> wrote:
>
> Yes, this looks fine. Can one assume the buffer for arguments/return values
> uses a "natural" representation?

On 11/25/05, Thomas Chust <address@hidden> wrote:
> >      [inv setArgument:convertArgumentFromScheme(i-2, [sig
> > getArgumentTypeAtIndex:i])
> >               atIndex:i];
> >    [inv invoke];
> >    void *rbuf = alloca([sig methodReturnLength]);
> >    [inv getReturnValue:rbuf];
> >    convertReturnValueToScheme([sig methodReturnType], rbuf);




reply via email to

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