User-Defined Data Types
In addition to the basic data types already described, IDL supports user-defined data types, which are aggregations of these basic types. These complex data types include arrays, sequences, enumerations, and constructed data types that you define yourself using structs and unions. We’ll go over each of these in detail in this section.
Complex data types are used in IDL by first giving them a type name, then using the type name wherever you would use a basic data type name, or an interface type name (e.g., declaring attributes, method arguments, etc.). There are a few ways that a name is assigned to a complex data type:
With structures, unions, and enumerations, the name is included in the declaration of the data type.
typedefcan be used to assign a name to a specific type (basic or complex).
Before we go on to see how complex data types are declared in IDL,
let’s take a look at how
typedefs are used to assign type names to these
complex data types.
typedef is used to associate a name with another
data type. The syntax of an IDL
typedef <type_spec> <identifier>
<type_spec> can be any basic IDL data
type, a user-defined data structure (structure, union, or
enumeration), an IDL interface type, or a sequence. The
<identifier> can be a simple IDL
identifier, or it can include dimension specifications for an array.
So the following are all valid
// IDL typedef short myShort; typedef long longArray; typedef PrintServer ...