Squeak
  links to this page:    
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
SqueakAsCppClass
Last updated at 3:35 pm UTC on 14 January 2006
From the Squeak Mailing Lists, October 28, 1997:

Another thing that must be done on the Squeak->Newton port that might get you closer to the guts of Squeak than the other items I mentioned before: mouse event issue, getting image on Newton, sound & networking primitives.

There can be no global variables (other than unchanging data) in a C++ Newton program. So, I have made the VM a C++ class, and hold onto one instance of it. Right now I convert the C VM to a C++ class by hand, and put all global & static variables into it. I looked at the C code generator and subclassed it and messed with it a bit quite a while ago (to make a record based VM, though I abandoned that approach), and it should be possible to make it generate C++ code fairly easily.

While I have the VM in C++ now, it would be nice to automatically take advantage of new VM code without having to redo any work by hand. It takes me an hour or two to do it, mostly by search and replace, and then compiling looking for errors.

No matter what you do, there will likely still be a bit of hand editing at the end. The objective is to minimize this, not neccesarily entirely replace it. Like at the end, one still likely must move globals from support routines into the VM class definition.

Basically:

Have the C++ code generator put a class definition for a SqueakVM class around the global variable list and function declaration list. Then have it append SqueakVM:: before every function definition, and after the type of course.

Seven other things you could do with the C++ code generator if you're ambitious; I only did the first four in my by hand version:

PaulFernhout