In the following presentation, we use the SIDL double type; however, everything in this section applies to all types except where noted. The basic types are in the SIDL namespace. Table 5.2 shows the prefix for SIDL base types and the actual value type held by the array...
SIDL TYPE | ARRAY FUNCTION PREFIX | VALUE TYPE |
---|---|---|
bool | sidl_bool | sidl_bool |
char | sidl_char | char |
dcomplex | sidl_dcomplex | struct sidl_dcomplex |
double | sidl_double | double |
fcomplex | sidl_fcomplex | struct sidl_fcomplex |
float | sidl_float | float |
int | sidl_int | int32_t |
long | sidl_long | int64_t |
opaque | sidl_opaque | void * |
string | sidl_string | char * |
For arrays of interfaces or classes, the name of the array function prefix is derived from the fully qualified type name. For example, for the type sidl.BaseClass, the array functions all begin with sidl_BaseClass. For sidl.BaseInterface, they all begin with sidl_BaseInterface.
When you add an object or interface to an array, the reference count of the element being overwritten is decremented, and the reference count of the element being added is incremented. When you get an object or interface from an array, the caller owns the returned reference.
For arrays of strings when you add a string to any array, the array will store a copy of the string. When you retrieve a string from an array, you will receive a copy of the string. You should sidl_String_free the returned string when you are done with it.
When you create an array of interfaces, classes, or strings, all elements of the array are initialized to NULL. Other arrays are not initialized. When an array of interfaces, classes, or strings is destroyed, it releases any held references in the case of objects or interfaces. In the case of strings, it frees any non-NULL pointers.
The name of the data structure that holds the array if double is struct sidl_double__array. For some types, the data structure is an opaque type, and for others, it is defined in a public C header file.
The functions are listed succinctly in Table 5.3 as well as in detail over the next few pages.