Include path: ExampleVariables.

Class name: ExampleVariablesTest {

Function [ run

	ExampleVariables initializeModule.

	ExampleVariables setIvar: 42.
	ExampleVariables setSvar: -31000.
	ExampleVariables setLvar: 65537.
	ExampleVariables setUivar: 123456.
	ExampleVariables setUsvar: 61000.
	ExampleVariables setUlvar: 654321.
	ExampleVariables setUcvar: 251.
	ExampleVariables setCvar: $S.
	ExampleVariables setFvar: 3.14159.
	ExampleVariables setDvar: 2.1828.
	ExampleVariables setBvar: true.
	ExampleVariables setStrvar: 'Hello World'.
	ExampleVariables setCstrvar: 'Goodbye'.
	ExampleVariables setIptrvar: (ExampleVariables new_int: 37) .
	ExampleVariables setPtptr: (ExampleVariables new_Point: 37y: 42).
	ExampleVariables setName: 'Bill'.

	"Now print out the values of the variables"

	Transcript nextPutAll: 'Variables (values printed from Smalltalk)'; cr.

	Transcript nextPutAll: 'ivar      ='; nextPutAll: ExampleVariables getIvar printString; cr.
	Transcript nextPutAll: 'svar      ='; nextPutAll: ExampleVariables getSvar printString; cr.
	Transcript nextPutAll: 'lvar      ='; nextPutAll: ExampleVariables getLvar printString; cr.
	Transcript nextPutAll: 'uivar     ='; nextPutAll: ExampleVariables getUivar printString; cr.
	Transcript nextPutAll: 'usvar     ='; nextPutAll: ExampleVariables getUsvar printString; cr.
	Transcript nextPutAll: 'ulvar     ='; nextPutAll: ExampleVariables getUlvar printString; cr.
	Transcript nextPutAll: 'scvar     ='; nextPutAll: ExampleVariables getScvar printString; cr.
	Transcript nextPutAll: 'ucvar     ='; nextPutAll: ExampleVariables getUcvar printString; cr.
	Transcript nextPutAll: 'fvar      ='; nextPutAll: ExampleVariables getFvar printString; cr.
	Transcript nextPutAll: 'dvar      ='; nextPutAll: ExampleVariables getDvar printString; cr.
	Transcript nextPutAll: 'cvar      ='; nextPutAll: ExampleVariables getCvar printString; cr.
	Transcript nextPutAll: 'bvar      ='; nextPutAll: ExampleVariables getBvar printString; cr.
	Transcript nextPutAll: 'strvar    ='; nextPutAll: ExampleVariables getStrvar printString; cr.
	Transcript nextPutAll: 'cstrvar   ='; nextPutAll: ExampleVariables getCstrvar printString; cr.
	Transcript nextPutAll: 'iptrvar   ='; nextPutAll: ExampleVariables getIptrvar getCPtr printString; cr.
	Transcript nextPutAll: 'name      ='; nextPutAll: ExampleVariables getName printString; cr.

	Transcript nextPutAll: 'ptptr     ='; nextPutAll: ExampleVariables getPtptr getCPtr printString;
		 nextPutAll: (ExampleVariables point_print: ExampleVariables getPtptr); cr.

	Transcript nextPutAll: 'pt        ='; nextPutAll: ExampleVariables getPt getCPtr printString;
		 nextPutAll: (ExampleVariables point_print: ExampleVariables getPt); cr.

	Transcript nextPutAll: 'Variables (values printed from C)'; cr.
	Transcript nextPutAll: ExampleVariables print_vars.
	Transcript flush.
]

Function [ testInterfaceSpeed

	| millisToRun callsPerSecond |

	ExampleVariables initializeModule.

	millisToRun := Time millisecondsToRun:[
		1 to: 400000 do:[ :i |
			ExampleVariables setIvar: 42.
			ExampleVariables getIvar.
		].
	].
	callsPerSecond :=  ((1000 / millisToRun) * 800000.0) asInteger.
	Transcript nextPutAll: 'This interface made approximately ', callsPerSecond printString, ' external swig calls per second.'.
	Transcript flush.
]

}

