NBExternalType subclass: #NBExternalEnumerationType	instanceVariableNames: 'enumerationClass'	classVariableNames: ''	poolDictionaries: ''	category: 'NBReifiedEnum'!!NBExternalEnumerationType methodsFor: 'accessing' stamp: 'cipt 11/25/2012 18:16'!enumerationClass	^ enumerationClass! !!NBExternalEnumerationType methodsFor: 'accessing' stamp: 'cipt 11/25/2012 18:16'!enumerationClass: anObject	enumerationClass := anObject! !!NBExternalEnumerationType methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:40'!coerceReturnValue: gen	"value is in EAX, get a ST Integer and place it in the value ivar"	| asm proxy  valueOop oop done |		proxy := gen proxy.	asm := gen asm.	valueOop := gen reserveTemp.	oop := gen reserveTemp.	proxy signed32BitIntegerFor: (gen returnValueRegister).	asm mov: asm EAX to: valueOop.	proxy pushRemappableOop: valueOop.		gen emitFetchClass: enumerationClass.		proxy instantiateClass: asm EAX indexableSize: 0.	"EAX <- our instance "	asm mov: asm EAX to: oop.	proxy popRemappableOop.	asm mov: asm EAX to: valueOop.		proxy storePointer: self valueIvarIndex ofObject: oop  withValue: valueOop.	asm mov: oop to: asm EAX.  "return the oop"	gen releaseTemps: 2.! !!NBExternalEnumerationType methodsFor: 'as yet unclassified' stamp: 'cipt 11/25/2012 18:23'!printOn: aStream	aStream nextPutAll: 'External enum(' , enumerationClass name , ')'! !!NBExternalEnumerationType methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:17'!pushAsValue: gen	"push value"	|asm proxy oop|	proxy := gen proxy.	asm := gen asm.	oop := gen reserveTemp.	loader emitLoad: gen to: oop.		"Special case: do not emit type checking if argument is receiver"	(loader isReceiver and: [  gen requestor  includesBehavior: enumerationClass ])	ifFalse: [		self verifyClassOf: oop is: enumerationClass generator: gen.	].	proxy fetchPointer: (self valueIvarIndex) ofObject: oop. "value ivar"	proxy integerValueOf: asm EAX. "handle value"	asm push: asm EAX.		gen releaseTemps: 1.! !!NBExternalEnumerationType methodsFor: 'as yet unclassified' stamp: 'cipt 11/25/2012 18:23'!valueIvarIndex	" return a zero-based index "	^ ( enumerationClass instVarIndexFor: #value ifAbsent: [ self error: ' should not happen ' ] ) - 1! !!NBExternalEnumerationType methodsFor: 'as yet unclassified' stamp: 'cipt 11/25/2012 18:17'!valueSize	^4! !"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!NBExternalEnumerationType class	instanceVariableNames: ''!!NBExternalEnumerationType class methodsFor: 'as yet unclassified' stamp: 'cipt 11/25/2012 22:07'!enumerationClass: aClass	^self new enumerationClass: aClass! !TestCase subclass: #NBSimpleEnumTests	instanceVariableNames: ''	classVariableNames: ''	poolDictionaries: ''	category: 'NBReifiedEnum'!!NBSimpleEnumTests methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:34'!primEnumToInt: aMyEnumInst	<primitive: #primitiveNativeCall module: #NativeBoostPlugin>	^ NBFFICallout 		cdecl: #(NBInt32 (MyEnumeration aMyEnumInst)) 		emitCall: [ :gen :proxy :asm | 			asm pop: asm EAX 		]! !!NBSimpleEnumTests methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:39'!primIntToEnum: anInteger	<primitive: #primitiveNativeCall module: #NativeBoostPlugin>	^ NBFFICallout 		cdecl: #(MyEnumeration (NBInt32 anInteger)) 		emitCall: [ :gen :proxy :asm | 			asm pop: asm EAX. 		]! !!NBSimpleEnumTests methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:30'!testEnumIdents	self assert: MyEnumeration AAA value = 1.	self assert: MyEnumeration DDD value = 2400.! !!NBSimpleEnumTests methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:50'!testEnumIncludes	self assert: (MyEnumeration includes: #DDD).	self deny: (MyEnumeration includes: #EEE).! !!NBSimpleEnumTests methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:36'!testEnumToInt	self assert: (self primEnumToInt: MyEnumeration AAA) = 1.	self assert: (self primEnumToInt: MyEnumeration BBB) = 2.	self assert: (self primEnumToInt: MyEnumeration CCC) = 3.	self assert: (self primEnumToInt: MyEnumeration DDD) = 2400.! !!NBSimpleEnumTests methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:39'!testIntToEnum	self assert: (self primIntToEnum: 1) value = 1 .	self assert: (self primIntToEnum: 2) value = 2.	self assert: (self primIntToEnum: 3) value = 3.	self assert: (self primIntToEnum: 2400) value = 2400.! !!NBSimpleEnumTests methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:46'!testIntToEnumNotIncluded	self assert: (self primIntToEnum: 7) value = 7.	self assert: (self primIntToEnum: 3) value = 3.		self assert: (self primIntToEnum: 7) item isNil.	self assert: (self primIntToEnum: 256) item isNil.! !!NBSimpleEnumTests methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:27'!testNewError	self should: [ MyEnumeration new ] raise: ShouldNotImplement! !!NBSimpleEnumTests methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:37'!testNotEnumMember	self should: [ MyEnumeration TTT ] raise: MessageNotUnderstood ! !Object subclass: #NBExternalEnumeration	instanceVariableNames: 'value'	classVariableNames: ''	poolDictionaries: ''	category: 'NBReifiedEnum'!!NBExternalEnumeration methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:45'!item	^ self class enumDecl keyAtValue: value ifAbsent: [ nil ]! !!NBExternalEnumeration methodsFor: 'as yet unclassified' stamp: 'cipt 11/25/2012 22:08'!printOn: aStream	super printOn: aStream.	aStream		nextPut: $(;		nextPutAll: (self class enumDecl keyAtValue: value ifAbsent: [ nil printString ]);		nextPut: $)! !!NBExternalEnumeration methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:30'!value	^ value! !!NBExternalEnumeration methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:47'!value: aValue	value := aValue! !"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!NBExternalEnumeration class	instanceVariableNames: ''!!NBExternalEnumeration class methodsFor: 'as yet unclassified' stamp: 'cipt 11/25/2012 22:06'!asNBExternalType: aTypeName	^ NBExternalEnumerationType enumerationClass: self! !!NBExternalEnumeration class methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:51'!doesNotUnderstand: aMessage	^ self enumDecl		at: aMessage selector		ifPresent: [ :value | self basicNew value: value ]		ifAbsent: [ super doesNotUnderstand: aMessage ]! !!NBExternalEnumeration class methodsFor: 'as yet unclassified' stamp: 'cipt 11/25/2012 22:07'!enumDecl	^ super subclassResponsibility! !!NBExternalEnumeration class methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:49'!includes: aSymbol	^self enumDecl includesKey: aSymbol ! !!NBExternalEnumeration class methodsFor: 'as yet unclassified' stamp: 'cipt 11/26/2012 20:25'!new	^self shouldNotImplement ! !NBExternalEnumeration subclass: #MyEnumeration	instanceVariableNames: ''	classVariableNames: ''	poolDictionaries: ''	category: 'NBReifiedEnum'!"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!MyEnumeration class	instanceVariableNames: ''!!MyEnumeration class methodsFor: 'as yet unclassified' stamp: 'cipt 11/25/2012 22:07'!enumDecl	^ {(#AAA -> 1).	(#BBB -> 2).	(#CCC -> 3).	(#DDD -> 2400)} asDictionary ! !