Previous Table of Contents Next


18.3.7 Mapping for Array Types


   COM supports fixed-length arrays, just as in CORBA. As in the mapping from OMG IDL to Microsoft IDL, the arrays can be mapped bidirectionally. The type of the array elements is mapped according to the data type mapping rules. The following statements in Microsoft IDL and ODL describe a nonconformant and nonvarying array of U.

   // Microsoft IDL for Tconst long N = ...;typedef ... U;typedef U ARRAY_OF_N[N];typedef float DTYPE[0..10]; // Equivalent to [11]

   The value N can be of any integral type, and const means (as in OMG IDL) that the value of N is fixed and known at compilation time. The generalization to multidimensional arrays follows the obvious trivial mapping of syntax.

   The corresponding OMG IDL syntax is as follows.

   // OMG IDL for T const long N = ...; typedef ... T; typedef T ARRAY_OF_N[N]; typedef float DTYPE[11];

   18.3.7.1 Mapping for nonfixed arrays

   In addition to fixed length arrays, as well as conformant arrays, COM supports varying arrays, and conformant varying arrays. These are arrays whose bounds and size can be determined at run-time. Nonfixed length arrays in Microsoft IDL and ODL are mapped to sequence in OMG IDL, as shown in the following statements.

   // Microsoft IDLtypedef short BTYPE[]; // Equivalent to [*];typedef char CTYPE[*];

   The corresponding OMG IDL syntax is as follows.

   // OMG IDL typedef sequence<short> BTYPE; typedef sequence<char> CTYPE;

   18.3.7.2 Mapping for SAFEARRAY

   Microsoft ODL also defines SAFEARRAY as a variable length, variable dimension array. Both the number of dimensions and the bounds of the dimensions are determined at run-time. Only the element type is predefined. A SAFEARRAY in Microsoft ODL is mapped to a CORBA sequence, as shown in the following statements.

   // Microsoft ODL

   SAFEARRAY(element-type) * ArrayName;

   // OMG IDL

   typedef sequence<element-type> SequenceName;

   If a COM server returns a multidimensional SAFEARRAY to a CORBA client, an E_DATA_CONVERSION exception will be raised.