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: Thomas Chust
Subject: Re: [Chicken-users] Objective-C interface (sort of...)
Date: Sat, 26 Nov 2005 20:20:55 -0000
User-agent: Opera M2/8.02 (MacPPC, build 2148)

Am 26.11.2005, 14:30 Uhr, schrieb felix winkelmann <address@hidden>:

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?
[...]

Hi,

As far as I know (because it always worked like that :), the parameter or
return value buffer can just be a pointer to a C variable of the required
type. I haven't tried this with structure types passed by value, though,
where alignment issues could arise.

cu,
Thomas




reply via email to

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