Previous | Table of Contents | Next |
OMG IDL Arrays and Sequences are mapped as a VARIANT containing an Automation SAFEARRAY. SAFEARRAYs are one- or multi-dimensional
arrays whose elements are of any of the basic Automation types. The following ODL syntax describes an array parameter:
SAFEARRAY (elementtype) arrayname
Safearrays have a header that describes certain characteristics of the array including bounding information, and are thus
relatively safe for marshaling. Note that the ODL declaration of Safearrays does not include bound specifiers. OLE provides
an API for allocating and manipulating Safearrays, includes a procedure for resizing the array.
For bounded Sequence, Safearray will grow dynamically up to the specified bounded size and maintain information on its current
length. Unbounded OMG IDL sequences are mapped to VARIANTS containing a Safearray with some default bound. Attempts to access
past the boundary result in a resizing of the Safearray.
Since ODL Safearray declarations contain no boundary specifiers, the bounding knowledge is contained in the Automation View.
A method of the Automation View Interface, which has the VARIANT containing the Safearray as a parameter, has the intelligence
to handle the parameter properly. When the VARIANT is submitted as in parameters, the View method uses the Safearray API to
dynamically repackage the Safearray as a CORBA array, bounded sequence, or unbounded sequence. When the VARIANT containing
the Safearray is an out parameter, the View method uses the Safearray API to dynamically repackage the CORBA array or sequence
as a Safearray. When an unbounded sequence grows beyond the current boundary of the corresponding Safearray, the View’s method
uses the Safearray API to increase the size of the array by one allocation unit. The size of an allocation unit is unspecified.
If a Safearray is mapped from a bounded sequence and a client of the View attempts to write to the Safearray past the maximum
element of the bounded sequence, the View operation considers this a run-time error and returns the HRESULT DISP_E_OVERFLOW.
Multidimensional OMG IDL arrays map to VARIANTs containing multidimensional Safearrays. The order of dimensions in the OMG
IDL array from left to right corresponds to ascending order of dimensions in the Safearray. If the number of dimensions of
an input SAFEARRAY does not match the CORBA type, the Automation view will generate the HRESULT DISP_E_TYPEMISMATCH.