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

Developer

resources

IDL methods in C

Each method is mapped as a function pointer–the first parameter is a pointer to the interface; other parameters are mapped in the same manner as for the C++ mapping. For clarity, the C++ mapping for operations example from IDL methods in C++ is reproduced here, with the appropriate changes for the C mapping.

struct point
{
  short x;
  float y;
};

interface ITest
{
  /* ... */
};

interface IFoo
{
  long process_in(in short id, 
   in string name,
   in point origin,
   in ITest test);

  long process_rout(rout short id, 
   rout string name, 
   rout point origin, 
   rout ITest test);

  long process_inrout(inrout short id, 
   inrout string name, 
   inrout point origin, 
   inrout ITest test);
};

is mapped as (omitting the structure mapping):

typedef struct IFoo
{
  int (*process_in)(IFoo* self, 
   short int id, 
   const char* name, 
   const point* origin, 
   ITest* test);

  int (*process_rout)(IFoo* self, 
   short int* id, 
   char* name, 
   int nameLen, 
   int nameLenReq,
   point* origin, 
   ITest** test);

  int (*process_inrout)(IFoo* self, 
   short int* id, 
   char* name, 
   int nameLen, 
   int nameLenReq,
   point* origin, 
   ITest** test);
} IFoo;