Squeak and Objective-C (Re: I was wondering ...)

Benjamin Pollack foxtrot at travelin.com
Wed Jun 23 15:48:10 UTC 1999


I might be misunderstanding the issue here, but I'm wondering: is there
anything wrong with using the NSNumber class?  Conversion with that would
be especially easy with [NSNumber numberWith[type]: aNumber], or even using
the object-converter prefixes to a method that took an NSNumber.  This
would avoid the complicated modifications to gcc that you would be talking
about.  Further, because you then have an NSNumber object, it should be
possible in that case to easily keep all Smalltalk parameters as an id,
i.e., permitting multiple types.  Would this work?

Marcel Weiher wrote:

> > 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