// AdaBroker torture test.
// This IDL file tests a lot of parser, expander and
// code generator features.
// $Id: //depot/adabroker/main/idlac/testsuite/adabroker.torture/torture.idl#9 $

#define HAVE_BOUNDED_STRINGS

exception rootScopeException {};

module MyModule {

  struct MyStruct {
    unsigned long MyInt;
    boolean member3[4][8];
    long a, b[2], c, d, e[4];
  };
  enum Color { Red, Green, Blue, Grey };
  typedef sequence<Color> longSpectrum;

  typedef sequence<sequence<Color> > bidimSpectrum;
  typedef sequence<sequence<long,9>> bidimSparseArray;

  typedef Color Hue, Tint, Paint;
  typedef Color spectrum[7];
  typedef Color foo;

  // Constants
  const string aConstantString = "$Id: //depot/adabroker/main/idlac/testsuite/adabroker.torture/torture.idl#9 $" ;
  const long aConstantLong = 0;
  const long aComputedLong = 1 + 2 * 4 - 5;
  const double Pi = 3.14159265358;
  const long double oneSeventh = 1.0 / 7.0;
  const Color blood = Red;
  const boolean lies = FALSE;

  // Enum E2 must be moved out of the switch type
  // spec by expansion.
  union U switch (enum E2 { XX2, XY2 }) {
  case XX2:
    long hair;
  case XY2:
    long beard;
  };

  //  Check that scoped-names that denote enumerators
  //  are parsed correctly.
  union Example switch (Color) {
    case Red: case Green: long Counter;
    case Blue: boolean Flags[4][8];
    default: long Unknown;
  };

  typedef struct Complex {
    double Re;
    double Im;
  } complexNumber;

#ifdef HAVE_BOUNDED_STRINGS
  typedef string<2> saltString;

  typedef unsigned long uid_t;
  typedef unsigned long gid_t;

  struct passwd {
    string<8>	pw_name;	/* user name */
    string<13>	pw_passwd;	/* user password */
    uid_t	pw_uid;		/* user id */
    gid_t	pw_gid;		/* group id */
    wstring	pw_gecos;	/* real name */
    string	pw_dir;		/* home directory */
    string	pw_shell;	/* shell program */
  };
#endif

  union U3 switch (boolean) {
    case TRUE: long foo;
    case FALSE: string bar;
  };

  interface MyInterface;

  typedef sequence<unsigned long> longSeq;

  struct forwardUsageOccurence1 {
    MyInterface aForwardRef;
  };

  interface MyInterface {
    typedef sequence<double> list;
    string echoString (in string arg) raises (rootScopeException);
    Color echoColor (in Color arg);
    MyInterface echoRef (in MyInterface arg);
    longSeq echoLongSeq (in longSeq arg);
  };
  #pragma ID MyInterface "IDL:toto/titi/tata/tutu:1.0"
  
#if 0
  struct forwardUsageOccurence2 {
    // This should still refer to the /forward/ declaration.
    MyInterface anotherForwardRef;
  };
#endif

  exception MyException {
    unsigned long Einfo;
  };

  interface IfB : MyInterface {
    long echoLong (in long Arg);
    void bindWith (in MyInterface otherInterface);
    void testException (in long Arg)
      raises (MyModule::MyException);
    readonly attribute unsigned long inBytes, outBytes;
    attribute Color currentColorSetting;
  };
  interface smallIf {
    void smallOp (in long arg);
  };
  #pragma prefix "adabroker.net"
  interface IfC : smallIf, IfB {
    void foo ();
  };
  interface IfD : IfC, MyInterface {
    void bar ();
  };
  typedef Complex Complex2;
  typedef complexNumber complexNumber2;
#if 0
  typedef MyInterface MyReference;
  // Must resolve to a /forward/ reference.

  typedef MyReference anObjectReference;
  typedef MyReference referencePack[5];
  typedef MyInterface bunchOfObjects[2][4];
#endif

  interface Chicken;
  interface Egg;
  interface Egg {
    Chicken hatch ();
  };
  interface Chicken {
    Egg lay ();
  };

  // A test-case from the adabroker mailing list.

  module Ss_Reu_Time_Utilities {

    typedef long Time_Stamp_Type;
    typedef long Relative_Time_Stamp_Type;

    enum Time_Format_Type { H_Hour, On_Call, Absolute };

    union Uniform_Time_Type switch ( Time_Format_Type ) {
      case H_Hour:
      case On_Call:
         Relative_Time_Stamp_Type       Relative_Time_Stamp;
      case Absolute:
         Time_Stamp_Type                Time_Stamp;
    };
  };

  typedef struct coords {
    double x;
    double y;
  } point;

  union U2 switch (long) {
    case 0: wstring name;
    case 1: Complex c;
  };

  abstract interface Person {
    void greet (in string hello);
  };

  abstract interface Employee {
    long summon (in string order);
  };

  valuetype EmployeeRecord supports Person, Employee {
    private string Name;
    private string Email;
    private string SSN;
    factory init (in string name, in string SSN);
    double salary (in long age);
  };

};

typedef MyModule::complexNumber2 rootCplx;
typedef ::MyModule::Complex rootCplx1;
typedef MyModule::MyInterface rootRef;
typedef long rootLong;
