Module system.utils.Enum
Classes
Enumeration | |
EnumerationBitmask: |
Functions
bitmask (tbl) | Creates a bitmask enumeration from the specified table. |
data (data) | |
entry (value) | |
immutable (tbl) | |
literal (value) | |
negativeSequence (tbl) | Creates a negative sequential enumeration. |
positiveSequence (tbl) | Creates a positive sequential enumeration. |
protocol (tbl) | Creates a protocol enumeration. |
sequence (tbl) | Creates a sequential enumeration. |
string (tbl) | Creates a string enumeration from the specified table. |
Classes
- Enumeration
-
- extend fun(key:string,value:integer|nil):integer
- data
table
- names
table
- keyList string[]
- valueList integer[]
- indices
table
- builtInMin integer
- builtInMax integer
- prettyNames
table
- EnumerationBitmask:
-
Enumeration
- mask fun(v1:integer, v2:integer, ...):integer
- unmask fun(v1:integer, v2:integer):integer
- check fun(v1:integer, v2:integer):boolean
- checkAll fun(v1:integer, v2:integer):boolean
- inspect fun(v:integer):string
Functions
- bitmask (tbl)
-
Creates a bitmask enumeration from the specified table. Entries should be numbered consecutively, starting from
0 for a "NONE" value, or from 1 for the first bit value. Values are automatically converted to powers of 2.
Up to 32 non-zero entries are supported.
Parameters:
- tbl E
Returns:
-
E|EnumerationBitmask
- data (data)
-
Parameters:
- data
Returns:
-
number
- entry (value)
-
Parameters:
- value V
Returns:
-
V
- immutable (tbl)
-
Parameters:
- tbl E
Returns:
-
E
- literal (value)
-
Parameters:
- value V
Returns:
-
V
- negativeSequence (tbl)
-
Creates a negative sequential enumeration. Entries can be assigned negative integer values only.
Parameters:
- tbl E
Returns:
-
E|Enumeration
- positiveSequence (tbl)
-
Creates a positive sequential enumeration. Entries can be assigned positive integer values only.
Parameters:
- tbl E
Returns:
-
E|Enumeration
- protocol (tbl)
-
Creates a protocol enumeration. Built-in entries are assigned numeric values, while extended entries use the string
key as their value.
Parameters:
- tbl E
Returns:
-
E|Enumeration
- sequence (tbl)
-
Creates a sequential enumeration. Entries can be assigned arbitrary integer values.
Parameters:
- tbl E
Returns:
-
E|Enumeration
- string (tbl)
-
Creates a string enumeration from the specified table. The string keys are simply used as values directly.
Parameters:
- tbl E
Returns:
-
E|Enumeration