Resources | Resources |



Sample IDL

The following sample IDL file illustrates the use of common IDL constructs:

#include "AEEIQI.idl"     // Needed for 'IQI'
#include "AEEStdDef.idl"          // Needed for 'AEEResult' and 'AEEIID' types

// Every CS ``interface`` needs a unique IID constant.  Constants should be
// generated using the class ID generator on the BREW Developer Extranet
// (
const AEEIID AEEIID_ICalculator = 0x0104dc0d;

interface ICalculator : IQI
  // This structure is specific to this interface, so we scope it within the
  // interface to avoid pollution of the global namespace.
  struct Complex
     float real; // Real part
     float imag; // Imaginary part

  // Symbolic constants for the "Number" discriminator.  Unlike in C, values
  // cannot be specified for the enumerators in IDL, but the order is
  // guaranteed to be preserved (for example, TYPE_INTEGER will be less than
  // TYPE_FLOAT, which will be less than TYPE_DOUBLE).
  enum NumberType

  // A universal "Number" type, which can be an integer, single-precision
  // float, or double-precision float.  Unions in IDL must be discriminated.
  union Number switch (NumberType)
     case TYPE_INTEGER: long i;
     case TYPE_FLOAT:   float f;
     case TYPE_DOUBLE:  double d;

  // A Vector, consisting of 0 or more Numbers.
  typedef sequence Vector;

  // Compute a*b, where a and b are both complex
  AEEResult ComplexMultiply(in Complex a, in Complex b, rout Complex result);

  // Add a and b.
  AEEResult Add(in Number a, in Number b, rout Number result);

  // Compute the sum of all elements in a vector
  AEEResult Sum(in Vector vec, rout Number result);

  // Parse and evaluate the expression (represented as a string)
  AEEResult Evaluate(in string expr, rout float result);