which reifies the enum declarations in C and offers a nice interface (especially in terms of debug/inspect).
NBExternalEnumeration subclass: #NBTestEnumeration
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'NativeBoost-Tests'
NBTestEnumeration�class>>enumDecl
^ {(#AAA -> 1).
(#BBB -> 2).
(#CCC -> 3).
(#DDD -> 2400)} asDictionary�
DO NOT FORGET to call the #initialize method on your class. The rest is automatically done ;)
You can use your new enum in two ways:
- add it to a client class poolDictionaries list (see��#NBExternalEnumTests for an example), and then just write CCC in your code -- CCC here is an item of your enum
- or you can send the name of an item to your class --- NBTestEnumeration DDD
The NBExternalEnumeration implements��(instance and class)�some more API methods like:
- #itemAt: retrieves the item having a specific value �---�NBTestEnumeration itemAt: 2
- #includes: checks the existence of a specific item in the enum --- NBTestEnumeration includes: #AAA
Having this already gives us a nice interface to working with enums. Now I plan to improve a little bit on performance and usage scenarios:
- the possibility to accept smalltalk integers as valid input/output for functions(or callbacks) that use enums as arguments/return.�
- support the different representation types for the enum values (int/uint)
So that will be for now. Feel free to try it out and send me any comments and/or improvement ideas, It will be my pleasure to improve it.�
Cheers,
--
Dr. Ciprian TEODOROV
Ing�nieur�D�veloppement�CAO
t�l : 06 08 54 73 48mail :�ciprian.teodorov@gmail.com
www.teodorov.ro