Squeak and Objective-C (Re: I was wondering ...)
Marcel Weiher
marcel at system.de
Wed Jun 23 08:53:32 UTC 1999
> From: Christian Brunschen <cb at df.lth.se>
> One thing that crossed my mind is, how difficult would it be to make
> Squeak objects callable from Objective-C ?
The reverse ( Squeak -> Objective-C ) is actually not that
difficult, I am currently encoding the Squeak args as a Foundation
property-list and decoding that on the Objective-C side, using
Objective-C runtime info to handle basic-types. I've implemented a
slightly better version (binary/object property lists) for my native
drawing experiments but haven't had time to integrate these efforts.
Call-ins into Squeak are currently not really supported, though I am
hoping this will change sometime soon (and willing to help!).
As to type info the easy option (for call-ins anyhow) would be to
forbid primitive types as parameters, requiring INT2SMALLINT( anInt )
macros for passing integer parameters. Otherwise you would have to
generate typed method signatures for each Squeak method you wish to
call. An inbetween option would be for optional typed method
signatures that could then allow native types in calls.
Another option I'd like to pursue would be adding SmallIntegers to
Objective-C. For basic support, you'd have to patch objc_msgSend()
and related to deal with "low-bit set -> this is a SmallInteger" and
take it from there. For the really fancy, you could modify gcc to
actually handle SmallIntegers natively, so code like the following
works:
SmallInteger a,b,c;
int d;
a=3; // compiled as 'a = (3 << 1) &1'
b=4; // compiled as 'b = (4 << 1) & 1'
c=a+b; // compiled as 'c = (((a>>1) + (b>>1)) << 1) & 1;
d=c; // compiled as 'd=c>>1'
Any gcc hackers on this list?
Marcel
More information about the Squeak-dev
mailing list
|