struct X_Y_Z__object; struct X_Y_Z__array; typedef struct X_Y_Z__object* X_Y_Z;
This code fragment also shows that struct X_Y_Z__array is used for a multi-dimensional array of X.Y.Z objects. Here are some additional concrete examples of the object and interface reference types derived by the C mapping:
/** * Symbol "sidl.BaseClass" (version 0.5.1) * * Every class implicitly inherits from <code>BaseClass</code>. This * class implements the methods in <code>BaseInterface</code>. */ struct sidl_BaseClass__object; struct sidl_BaseClass__array; typedef struct sidl_BaseClass__object* sidl_BaseClass; /** * Symbol "sidl.BaseInterface" (version 0.5.1) * * Every interface in <code>SIDL</code> implicitly inherits * from <code>BaseInterface</code>, and it is implemented * by <code>BaseClass</code> below. */ struct sidl_BaseInterface__object; struct sidl_BaseInterface__array; typedef struct sidl_BaseInterface__object* sidl_BaseInterface;
Here is an example of the C client-side binding for an r-array. This example is for the solve example from Section 5.4. Here, I assume that the package name is num, and the class name is Linsol. The data for each array is passed as a double pointer, and the index parameters are normal in ints.
/** C client-side API for solve method */ void num_Linsol_solve(/*in*/ num_Linsol self, /*in*/ double* A, /*inout*/ double* x, /*in*/ double* b, /*in*/ int32_t m, /*in*/ int32_t n);
The one catch for C programmers is that A is in column-major order -- not the typical row-major ordering used in C. To access the element in row i and column j, you can use the RarrayElem2(A,i,j,m). RarrayElem2 is a convenience macro for C and C++ programmers to access r-arrays in column-major order. To access memory by stride one make i your inner loop.
Passing NULL for A, x, or b is not allowed. You must always pass a valid pointer.