Previous | Table of Contents | Next |
Automation SafeArrays should be mapped to CORBA unbounded sequences.
A method of the CORBA View Interface, which has a SafeArray as a parameter, will have the knowledge to handle the parameter
properly.
When SafeArrays are “in? parameters, the View method uses the Safearray API to dynamically repackage the SafeArray as a CORBA
sequence. When arrays are “out? parameters, the View method uses the Safearray API to dynamically repackage the CORBA sequence
as a SafeArray.
19.9.13.1 Multidimensional SafeArrays
SafeArrays are allowed to have more than one dimension. However, the bounding information for each dimension, and indeed the
number of dimensions, is not available in the static typelibrary information or ODL definition. It is only available at run-time.
For this reason, SafeArrays, which have more than one dimension, are mapped to an identical linear format and then to a sequence
in the normal way.
This linearization of the multidimensional SafeArray should be carried out as follows:
• The number of elements in the linear sequence is the product of the dimensions.
• The position of each element is deterministic; for a SafeArray with dimensions d0, d1, d2, the location of an element [p0][p1][p2] is defined as:
pos[p0][p1][p2] = p0*d1*d2 + p1*d2 + p2
Consider the following example: SafeArray with dimensions 5, 8, 9.
This maps to a linear sequence with a run-time bound of 5 * 8 * 9 = 360. This gives us valid offsets 0-359. In this example,
the real offset to the element at location [4][5][1] is 4*8*9 + 5*9 + 1 = 334.