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

Developer

resources

IDL sequence in C

IDL sequences are mapped, as in C++, to a pointer of the type of the sequence, followed by the length of the sequence in elements (int), and the required number of elements to store the sequence when used as a result (int *). The sequence lengths are always in terms of the number of elements in the sequence, not the number of bytes required to store the sequence.

As in C++, for each sequence type sequence, a corresponding structure __seq_T is generated with three members:

T* data;
int dataLen;
int dataLenReq;

The name of this structure may be prepended with the names of any enclosing modules or interfaces (see Broken Link). Because this structure is not intended for use directly by client code, the __seq_T name is only the structure tag, and is not typedef-ed to a type name.

For example:

typedef sequence<long> seqlong; 

is mapped as:

struct __seq_int
{
  int* data;
  int dataLen;
  int dataLenReq;
};

typedef struct __seq_int seqlong;

This structure is used when constructing sequences of sequence types, and when sequence types are used as part of unions.

The C mapping for sequences in different contexts is the same as in C++ (see Broken Link). For clarity, excerpts of examples from that section are reproduced here.

typedef sequence<long> seqlong;

interface IFoo
{
  long process_in(in seqlong sums);
  long process_rout(rout seqlong sums);
  long process_inrout(inrout seqlong sums);
};

struct Atm
{
  seqlong sums;
};

is mapped as:

struct __seq_int
{
  int* data;
  int dataLen;
  int dataLenReq;
};

typedef struct __seq_int seqlong;

typedef struct IFoo
{
  int (*process_in)(IFoo* self,
   const int* sums, int sumsLen);

  int (*process_rout)(IFoo* self,
   int* sums, int sumsLen, int* sumLenReq);

  int (*process_inrout)(IFoo* self,
   int* sums, int sumsLen, int* sumLenReq);
} IFoo;

typedef struct Atm
{
  int* sums;
  int sumsLen;
  int sumsLenReq;
} Atm;