Question on Embedding Squeak

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Question on Embedding Squeak

Brian Brown-2
 
Hello folks,

Is it possible to embed squeak in a host C application with it's own  
thread (if needed)?

Is so, how could I get started?  ;-)


- Brian

Reply | Threaded
Open this post in threaded view
|

Re: Question on Embedding Squeak

Michael van der Gulik-2
 


On 2/23/08, Brian Brown <[hidden email]> wrote:

Hello folks,

Is it possible to embed squeak in a host C application with it's own
thread (if needed)?

Is so, how could I get started?  ;-)



Hi Brian.

The Squeak interpreter is essentially a while loop with a switch statement in it for each of the 255 bytecodes. Memory is allocated on the heap but in a platform dependent manner. There might be issues with resource contention between Squeak and your application, but it should be perfectly possible to integrate Squeak in another application.

The VM is automatically converted from Smalltalk to C using VMMaker. The generated code is mostly readable.

Start at http://www.squeakvm.org/, and search http://wiki.squeak.org/ (i.e. Google for "squeak vm build instructions site:wiki.squeak.org") for instructions for building the VM. You can customise the platform-specific code for opening files, allocating memory, loading the image  etc if they cause problems. You'll probably also want to disable Squeak's video output, which shouldn't be difficult.

Igor has recently done some interesting work in essentially running Squeak as an embedded application in itself. Read his postings about the Hydra VM on the main squeak-dev mailing list for more info.

Gulik.


--
http://people.squeakfoundation.org/person/mikevdg
http://gulik.pbwiki.com/
Reply | Threaded
Open this post in threaded view
|

Re: Question on Embedding Squeak

timrowledge
 
Gulik's reply reminds me that you might find the code that allows the  
VM to be a browser plugin instructive. Part of your interest will  
likely be that there is so little needing changing.

I'll leave it to John McI to explain the details since he's probably  
done most of the code fudging involved.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Never write software that patronizes the user.


Reply | Threaded
Open this post in threaded view
|

Re: Question on Embedding Squeak

johnmci
 
Well certainly the hydra VM work he should look at.

The browser plugin code at
http://www.squeakvm.org/cgi-bin/viewcvs.cgi/trunk/platforms/Mac%20OS/vm/npsqueak/npsqueak.c?rev=1662&view=auto

could be examined too, it was written mostly by Bert Freudenberg with  
changes by myself to let you start a netscape plugin os-x safari/
firefox which setups a shared
memory area (non-trival because instructions how to do this are vague)  
and two pipes to let the plugin code stuff interact with a headless VM  
via execv(plugin->vmName, plugin->argv);

The pipes are used to pass control information between the plugin stub  
and the headless VM
The shared memory area is the quartz window canvas, other operating  
such as windows and X11 let you deal with remote surface display in an  
easier manner.

There is a bunch of nasty semaphore logic to deal with preventing the  
VM from burying the browser with update requests, plus code to figure  
out if the browser has gone away.

Thus the headless VM is feed UI events and serves back UI images to  
the browser.

On Feb 22, 2008, at 6:55 PM, tim Rowledge wrote:

> Gulik's reply reminds me that you might find the code that allows  
> the VM to be a browser plugin instructive. Part of your interest  
> will likely be that there is so little needing changing.
>
> I'll leave it to John McI to explain the details since he's probably  
> done most of the code fudging involved.
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> Never write software that patronizes the user.
>
>

--
=
=
=
========================================================================
John M. McIntosh <[hidden email]>
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
=
=
=
========================================================================