
//=============================================================================
/**
 *  @file    interface.idl
 *
 *  $Id: interface.idl 94309 2011-07-08 17:19:33Z parsons $
 *
 *  This file contains examples of IDL code that has
 *  caused problems in the past for the TAO IDL
 *  compiler. This test is to make sure the problems
 *  stay fixed.
 *
 *
 *  @author Jeff Parsons <parsons@cs.wustl.edu> and TAO users.
 */
//=============================================================================


// Used to be a problem in the get() and set()
// generated code.

interface Base
{
  attribute long value;
};

interface Derived : Base
{
};

// The fact that the interface begins with 'foo' was causing
// problems. The IDL compiler thought the interface was in
// foo's scope.
module foo_mod
{
  struct date
    {
      short month;
    };
};

interface foostep
{
  foo_mod::date getDate ();
};

// Only operations or attributes should cause a clash
// in this type of situation.
interface mother
{
  struct member
    {
      long val;
    };
};

interface father
{
  struct member
    {
      short ident;
    };
};

interface child : mother, father
{
};

interface try
{
};

// Definition below in file.
interface later;

typedef boolean Bool;

interface later_user
{
  later op (in later inarg,
            inout later inoutarg,
            out later outarg);


  // Not a clash with the C++ keyword because they are case sensitive,
  // but the Arg_Traits<> specialization parameter (ACE_InputCDR::to_boolean)
  // needs the unaliased type name to work.
  void op2 (in Bool inarg2);
};

struct later_holder
{
  later member;
};

interface later {};

// Previously, we could have found v if it
// was inherited into Client, but not in
// the case below, where it is inherited into
// somewhere other than the scope where the
// lookup starts.

interface Begin
{
  typedef long Value;
};

interface Middle : Begin
{
};

interface End : Middle
{
};

interface Client
{
  attribute End::Value v;
};

// Tests arg_traits visitor for unaliased bounded (w)string
// attributes.
interface AttributeTester
{
  typedef string string_1[1];

  attribute string a_su;
  attribute string_1 a_sb;
};

// All of the 'recursion' below is legal.
module ParamMod
{
  interface ParameterTester
  {
    exception object_excep_type
    {
      ParameterTester objref;
    };

    typedef sequence<ParameterTester> object_seq_type;

    typedef ParameterTester object_array_type[5];

    struct object_struct_type
    {
      octet o1;
      ParameterTester p1;
      long l1;
    };

    union object_union_type switch (long)
    {
      case 0: string str;
      case 1: ParameterTester pt;
    };

    object_seq_type parameter_tester_op (
        in object_struct_type inarg,
        inout object_array_type inoutarg,
        out object_union_type outarg
      )
      raises (object_excep_type);
  };
};

local interface testlocal
{
};

interface A {
  union U switch(boolean)
  {
    case TRUE: A aa;
  };
};

module M
{
  interface A;
};

module M
{
  interface A;

  interface A {};
};

module i1
{
  interface if1
  {
    string getStr();
  };
};

module i2
{
  interface if2 : ::i1::if1
    {
      string getstr2();
    };

  interface if3 : ::i2::if2
    {
      string getstr3();
    };
};

/// Tests acceptance of legal redefinitions (of
/// constants, exceptions and types) in a derived
/// interface.
module redefs
{
  interface base
  {
    const long lconst = -5;

    exception ex
    {
      string info;
    };

    struct foo
    {
      short index;
    };
  };

  interface derived : base
  {
    const long lconst = 44;

    exception ex
    {
      long serial;
    };

    struct foo
    {
      string str;
    };
  };
};

// Had to relocate the spot where the typedef is marked as
// having its arg traits instantiation already generated.
// Otherwise, when the scope of the base interface is visited
// as part of this process, we had infinite recursion and a
// stack overflow.
module Rec_Arg_Traits
{
  interface base
  {
    typedef Rec_Arg_Traits::base plan_stub_type;
  };

  interface derived : Rec_Arg_Traits::base
  {
    void remove_task (in plan_stub_type listener);
  };
};
