[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

more things lost....



I don't know whether 'Smalltalk at: #XAxis put: XOrientation create' would ever
have translated correctly, though I doubt it. Anyhow, you should now
use a class variable as follows:

Gnat subclass: Gnu
	instanceVariableNames: ''
	classVariableNames: 'XAxis {XOrientation}'
	poolDictionaries: ''
	category: 'Zoo'

Gnat class methodsFor: 'smalltalk initialization'	
"the protocol should have keywords smalltalk & init"

linkTimeNonInherited
	XAxis _ NULL

initTimeNonInherited
	self REQUIRES: XOrientation.
	XAxis _ XOrientation create

This makes XAxis a static variable in C++. If other classes need to
access it, you should write functions (class messages) to do it.
	--ravi

P.S. If you just need something that is a compile time constant use:

linkTimeNonInherited
	Heaper constant: #ONE type: '{IntegerVar}' value: 1

which translates to

const IntegerVar ONE = 1;

P.P.S. From what I can see of this example, it looks like you should
instead be using a pseudo constructor that caches a single instance:

XOrientation ...
	classVariableNames: 'TheXOrientation {XOrientation}'
	...

XOrientation class methodsFor: 'smalltalk initialization'

linkTimeNonInherited
	TheXOrientation _ NULL

initTimeNonInheried
	TheXOrientation _ XOrientation create

XOrientation methodsFor: 'pseudo constructors'

make
	^TheXOrientation

Then you use XOrientation make where you would have used the variable
XAxis. Inlining makes this just as efficient.