Objective-C bridge (Re: [VM][OS X] FFI plugin 1.1.0b1)

Marcel Weiher marcel at metaobject.com
Fri Mar 8 12:09:51 UTC 2002

On Thursday, March 7, 2002, at 11:30 PM, Alain Fischer wrote:

>> What do you need?
> For exemple I wasn't able to send a massage to a NSString from squeak. 
> The NSString are translated in Squeak String
> before they are returned to the VM.

Yes.  This has bothered me here and again when doing little tests, but 
so far not with anything real.  Any good ideas?

Another thing I am looking at is direct array access for the message 
arguments, as well as tapping into (+ possibly extending) the FFI 
infrastructure, though I would like to avoid relying on the FFI plugin.

> Another example is that when I send className to a Cocoa class it's the 
> Squeak message that respond. But this could
> be fixed by making ObjcProxy inherit from ProtoObject insteed of Object 
> and changing ...

Even easier is to implement

	^bridge forward:(Message selector:#className) to:id.

> I am experimenting here to be able to use Cocoa object as easy as 
> possible.

Hope to hear more of your progress!

> One thing that still missing is the ability to call squeak method from 
> Objective-C, for example think of implementing
> "printOn: aStream" in Objective-C with sending message to aStream.

Yup.  This isn't easy, especially not in a call-out, since Squeak isn't 
re-entrant.  I am currently working on some other 'baby-steps' towards 
that capability, which is a slightly more generalized event mechanism.  
That way we would have call-out + call-in, but without a bi-directional 

The only way I see of accomplishing that without changing the VM is to 
use threading:  dispatch the Objective-C message in a separate thread 
and then return to Squeak, but block the (Squeak) thread making the 
call-out on a semaphore.  When the Objective-C message returns, signal 
the semaphore, unblocking the thread which then gets the return values.

> Now I have to play with Squeak and Objective-C to experiment what is 
> the easiest way to mix the two world.
> My dream: a Cocoa app with Aqua look implemented with Squeak,

Yes, with beautiful GUI done in IB and using powerful Objective-C 
frameworks for heavy lifting.

> now that Squeak is becoming modular,
> We can hope something resonably small.




Marcel Weiher				Metaobject Software Technologies
marcel at metaobject.com		www.metaobject.com
Metaprogramming for the Graphic Arts.   HOM, IDEAs, MetaAd etc.

More information about the Squeak-dev mailing list