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: felix winkelmann
Subject: Re: [Chicken-users] Objective-C interface (sort of...)
Date: Sat, 26 Nov 2005 15:30:07 +0100

On 11/25/05, Thomas Chust <address@hidden> wrote:
>
> Building NSInvocation instances is even easier than doing everything by
> hand -- for example the parsing of ObjC parameter type encoding strings
> is much less work, because the NSMethodSignature objects at least split
> them
> correctly for you. You just have to create the object, set the parameters,
> execute the call and retrieve the return value -- like in this pseudocode
> snippet:
>    SEL sel = sel_registerName("someSelector");
>    NSMethodSignature *sig = [someObject methodSignatureForSelector:sel];
>    NSInvocation *inv = [NSInvocation invocationWithMethodSignature:sig];
>    [inv setTarget:someObject];
>    [inv setSelector:sel];
>    for (int i = 2; i < [sig numberOfArguments]; i++)
>      [inv setArgument:convertArgumentFromScheme(i-2, [sig
> getArgumentTypeAtIndex:i])
>               atIndex:i];
>    [inv invoke];
>    void *rbuf = alloca([sig methodReturnLength]);
>    [inv getReturnValue:rbuf];
>    convertReturnValueToScheme([sig methodReturnType], rbuf);
>    [inv release];
>    [sig release];

Yes, this looks fine. Can one assume the buffer for arguments/return values
uses a "natural" representation?

>
> But I don't want to urge you not to use the library of your choice if you
> find
> it more convenient.

I don't want to force libffi on everybody - it worked for me and simplifies
certain things tremendously. That it's so horribly maintained is definitely
an argument against using it.


cheers,
felix




reply via email to

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