Quick Start 

Well here it is.  I started to try and explain how the interface works in README.rtf but I am having trouble with it.  But you  shouldn't need to know much of that to be able to write code.  Since the executable, mst, and smalltalk image, mst.im, are included all you need to do to try out my smalltalk browser is type (this only applies to intel)

	mst -qV STBrowser.st 

from a terminal window in the directory <where ever you unpacked it>/Smalltalk1.2A3.
The main window is a class browser, the button between the browser and text really don't doing anything usefull yet, they were supposed to be create a subclass, edit a class, and file out a class.  To browse the class and instance methods of a class you double click on the class you which to browse in the browser.  Again the button here don't really work but you can fool around and try stuff out, just be sure not to take a snapshot of the kernel and screwing with stuff.

If you want to rebuild the whole thing from scratch you need to do a 'make' in
the main directory.  Once you have mst build you need to type

	mst -qV

which will build the new image.  Once the smalltalk prompt appears type

	OCInterface createInterface!

This start creating the interface between smalltalk and objective-c and on my Pentium 90 can take as long as 4 minutes.  Note that I have had this fail occasionally with floating point errors and other strange things so email if you persevere is something strange happens and try it again.  This is also the point at which my stuff fails on Motorolla hardware.   

If you want to try and build it on hardware other than intel you need to do a 'make distclean' and then reconfigure the system by running './configure'.  Than follow the same steps as for building on intel.  

If anything, the files to play with our OCObject.st and cfuncs.c in the main directory.  This is where my code is for querying the objective-c runtime system lies.

A simple (and poor) explanation of how things works

All documented objective-c objects found in NeXT_s and Media_s are duplicated starting with OCObject as the root object in the smalltalk system.  These class respond to all methods that they normally would in objective-c and some that may have been undocumented.  However, methods that pass around the NXColor struct will not work (I am working on fixing this).  Also methods that expect pointer to structures will only work if you create an objective-c object to hold that structure and then use that object in the smalltalk system.  (see STRect, STSize, and STPoint in ./Smalltalk1.2A3/OCInterfaceSupport/  for examples of this usage).

The ability to for objective-c objects to forward methods class to there smalltalk brothers is currently only done by subclasses of the objective-c object STObject in  ./Smalltalk1.2A3/OCInterfaceSupport/ .  

STObject uses two mechanisms to forward certain method calls to its smalltalk brothers and sisters.  First there is a class method called 
	+ (BOOL)forwardToSmalltlak:(SEL)aSelector
which is called for each selector in each class by smalltalk code to see if, on the smalltalk side, we want to forward the method to objective-c.  If we don't smalltalk creates a empty method in the name of the selector which is called whenever the objective-c object gets this method.  

The second thing is that STObject has a handle to its smalltalk brother via the ivar stObject.  This is a pointer to the objects representation in the smalltalk interpreter.  It is set via the setOOP: method of STObject, which by the way is one of the selectors in STObject that is not forwarded to smalltalk.

This is usefull for stuff  any delegate methods since we have no control, from smalltalk, over these messages.  See the objective-c code for the STDelegate subclasses as well as the smalltalk code in STBrowser.st for ClassBrowserDelegate.  It is also used to setup smalltalk based objects to be targets of objective-c control subclasses actions.  You will notice that STObject has a bunch of doubleAction: and singleAction: methods.  These are designed to be the actions called when a control is activated.  If you can think of a better way to do this please email me, since this feels like a terrible hack.

Below are a few hints and warning

	o 	Never do this 
			browser setDelegate: aDelegate.
		what you meant was
			browser setDelegate: aDelegate id.
		The id method tells aDelegate to pass its id value to browser otherwise
		you telling an objective-c object to ask a smalltalk object for browser
		data.
		
	o	When creating subclasses of STObject in smalltalk make sure to call super's
		init method or objective-c methods will never be forwarded to the smalltalk
		object.
		
	o	Email with any question you have since this explanation is looking worse
		and worse as I read over it. Sorry.

And now the code