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.
A
typedef
can 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.
Typedefs
A
typedef
is used to associate a name with another
data type. The syntax of an IDL typedef
is:
typedef <type_spec> <identifier>
The <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 typedef
statements:
// IDL typedef short myShort; typedef long longArray[2][2]; typedef PrintServer ...
Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.