Create an enumerated type, then add var/value pairs to it. The
constructor and the method .ints(names) take a list of variable names,
and assign them consecutive integers as values. The method
.strs(names) assigns each variable name to itself (that is variable 'v'
has value 'v'). The method .vals(a=99, b=200) allows you to assign any
value to variables. A 'list of variable names' can also be a string,
which will be .split(). The method .end() returns one more than the
maximum int value. Example: opcodes = Enum("add sub load
store").vals(illegal=255).
|
|
|
|
|
set(self,
var,
val)
Set var to the value val in the enum. |
source code
|
|
|
|
strs(self,
names)
Set each of the names to itself (as a string) in the enum. |
source code
|
|
|
|
ints(self,
names)
Set each of the names to the next highest int in the enum. |
source code
|
|
|
|
vals(self,
**entries)
Set each of var=val pairs in the enum. |
source code
|
|
|
|
end(self)
One more than the largest int value in the enum, or 0 if none. |
source code
|
|
|
|
|