On 11/25/05, Thomas Chust <[EMAIL PROTECTED]> 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


_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to