next up previous contents
Next: Objects Up: Fundamental Types Previous: Opaque   Contents


Enumerations

An enumeration is typically used in programming languages to specify a limited range of states and deal 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.

users_guide/basics/code/enum_example.sidl

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.

  1. Error if two states are explicitly assigned the same value
  2. Assign all explicit values to their named state.
  3. Assign smallest unused non-negative value to first unassigned state in enumeration.
  4. Repeat 3 until all states have assigned (unique) values.

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.


next up previous contents
Next: Objects Up: Fundamental Types Previous: Opaque   Contents


babel-0.8.0
users_guide Last Modified 2003-01-14

http://www.llnl.gov/CASC/components
components@llnl.gov