Previous Table of Contents Next


15.3.2 OMG IDL Constructed Types


   Constructed types are built from OMG IDL’s data types using facilities defined by the OMG IDL language.

   15.3.2.1 Alignment

   Constructed types have no alignment restrictions beyond those of their primitive components. The alignment of those primitive types is not intended to support use of marshaling buffers as equivalent to the implementation of constructed data types within any particular language environment. GIOP assumes that agents will usually construct structured data types by copying primitive data between the marshaled buffer and the appropriate in-memory data structure layout for the language mapping implementation involved.

   15.3.2.2 Struct

   The components of a structure are encoded in the order of their declaration in the structure. Each component is encoded as defined for its data type.

   15.3.2.3 Union

   Unions are encoded as the discriminant tag of the type specified in the union declaration, followed by the representation of any selected member, encoded as its type indicates.

   15.3.2.4 Array

   Arrays are encoded as the array elements in sequence. As the array length is fixed, no length values are encoded. Each element is encoded as defined for the type of the array. In multidimensional arrays, the elements are ordered so the index of the first dimension varies most slowly, and the index of the last dimension varies most quickly.

   15.3.2.5 Sequence

   Sequences are encoded as an unsigned long value, followed by the elements of the sequence. The initial unsigned long contains the number of elements in the sequence. The elements of the sequence are encoded as specified for their type.

   15.3.2.6 Enum

   Enum values are encoded as unsigned longs. The numeric values associated with enum identifiers are determined by the order in which the identifiers appear in the enum declaration. The first enum identifier has the numeric value zero (0). Successive enum identifiers take ascending numeric values, in order of declaration from left to right.

   15.3.2.7 Strings and Wide Strings

   A string is encoded as an unsigned long indicating the length of the string in octets, followed by the string value in single- or multi-byte form represented as a sequence of octets. The string contents include a single terminating null character. The string length includes the null character, so an empty string has a length of 1.

   For GIOP version 1.1, 1.2, and 1.3 - when encoding a string, always encode the length as the total number of bytes used by the encoding string, regardless of whether the encoding is byte-oriented or not.

   For GIOP version 1.1, a wide string is encoded as an unsigned long indicating the length of the string in octets or unsigned integers (determined by the transfer syntax for wchar) followed by the individual wide characters. The string contents include a single terminating null character. The string length includes the null character. The terminating null character for a wstring is also a wide character.

   For GIOP version 1.2 and 1.3, when encoding a wstring, always encode the length as the total number of octets used by the encoded value, regardless of whether the encoding is byte-oriented or not. For GIOP version 1.2 and 1.3 a wstring is not terminated by a null character. In particular, in GIOP version 1.2 and 1.3 a length of 0 is legal for wstring.

   Note – For GIOP versions prior to 1.2 and 1.3, interoperability for wstring is limited to the use of two-octet fixed-length encoding.

   Wstring values in encapsulations are assumed to be encoded using GIOP version 1.2 and 1.3 CDR.

   15.3.2.8 Fixed-Point Decimal Type

   The IDL fixed type has no alignment restrictions, and is represented as shown in Table 15-4 on page 15-14. Each octet contains (up to) two decimal digits. If the fixed type has an odd number of decimal digits, then the representation begins with the first (most significant) digit — d0 in the figure. Otherwise, this first half-octet is all zero, and the first digit is in the second half-octet — d1 in the figure. The sign configuration, in the last half-octet of the representation, is 0xD for negative numbers and 0xC for positive and zero values.

   The number of digits present must equal the number of significant digits specified in the IDL definition for the fixed type being marshalled, with the exception of the inclusion of a leading 0x0 half octet when there are an even number of significant digits.

   Decimal digits are encoded as hexadecimal values in each half-octet as follows:

   Decimal Digit Half-Octet Value

0 0x0
1 0x1
2 0x2
... ...
9 0x9

   Figure 15-3 Decimal Digit Encoding for Fixed Type

   Big and Little-Endian octet

   fixed

   MSD 0 1 2 == =

d0 d1
d2 d3
d4 d5


   Figure 15-4 IDL Fixed Type Representation