[Top][All Lists]

[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: Fri, 25 Nov 2005 14:19:57 -0000
User-agent: Opera M2/8.02 (MacPPC, build 2148)

Am 25.11.2005, 06:49 Uhr, schrieb felix winkelmann <address@hidden>:

Well, objc_msgSendv is undocumented, and we have to
construct calls somehow, anyway. I don't know how easy it is to
build NSInvocation instances by hand, but it all looks like a hack as
well (just as with libffi), especially regarding your comments about
non-working ObjC dispatching code, etc.

My installation of the ADC Reference Library includes documentation of
objc_msgSendv along with all the other runtime methods. And in contrary
to the class and method creation functions, this documentation is even
correct ;)

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
  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])
  [inv invoke];
  void *rbuf = alloca([sig methodReturnLength]);
  [inv getReturnValue:rbuf];
  convertReturnValueToScheme([sig methodReturnType], rbuf);
  [inv release];
  [sig release];

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

I would simply disallow class-changes at runtime.

... and then you have to fix method signatures upon registration with
the runtime.

But I better spend my time with things I understand. I'm pretty new
to OS X and have to learn a good deal more.

Your code doesn't look like you didn't know what you were doing --
I really appreciate the quality of your work :)


reply via email to

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