An enumeration is typically used in programming languages to specify a limited range of states to enable dealing with them by names instead of hard-coded values. For language interoperability purposes -- especially to support this concept on languages with no native support -- we've had to create specific rules for the integer values associated with enumerated types.
package enumSample version 1.0 { // undefined integer values enum color { red, orange, yellow, green, blue, violet }; // completely defined integer values enum car { /** * A sports car. */ porsche = 911, /** * A family car. */ ford = 150, /** * A luxury car. */ mercedes = 550 }; // partially defined integer value enum number { notZero, // This non-doc comment will not be retained. notOne, zero=0, one=1, negOne=-1, notNeg }; }
Above is a sample of enumerations taken directly from our regression tests. It defines a package enumSample that contains three enumerations. C/C++ developers will find the syntax very familiar. When defining an enumeration, the actual integer values assigned can be undefined, completely defined, or partially defined.
SIDL defines the following rules for adding integer values to enumerated states that don't have a value explicitly defined.
To verify the application of these rules, the enumSample.number enumeration will have the following values assigned to its states: NotZero=2, NotOne=3, zero=0; one=1, negOne=-1, notNeg=4.