Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

IDL rout parameter of a method in C++

When a sequence is specified as a rout parameter of a method of an interface, the mapping generates three arguments (assuming the name of the declarator is dcl):

T* dcl, int dclLen, int* dclLenReq 

The second argument (dclLen) specifies the total number of elements that the array dcl can hold -- that is, the number of elements worth of memory the caller has allocated). The dcl parameter must be valid unless dclLen is 0, in which case dcl may be NULL. After completion of the call, the third argument (dclLenReq) is populated with the number of elements that the callee would have required to store the entire result. The number of elements returned is the lesser of dclLen and *dclLenReq. If *dclLenReq is greater than dclLen, the result will have been truncated and only the first dclLen elements returned.

Note: All memory, namely the dcl array, is allocated by the caller. In addition, dclLenReq is considered to be a rout parameter for a primitive type, so the caller can pass NULL if it is not interested in the returned length required (see IDL methods in C++).

The following is an example of a rout sequence parameter:

typedef sequence<long> seqlong;

interface IFoo
{
  long process(rout seqlong sums);
};

is mapped as:

// __seq_int details omitted

struct IFoo
{
  virtual int process (int* sums, 
   int sumsLen,
   int* sumsLenReq) = 0;
};