<!--
 === Copyright (c) 1999 The University of Utah and
 === the Computer Systems Laboratory at the University of Utah (CSL).
 === All rights reserved.
 ===
 === Permission to use, copy, modify and distribute this software is hereby
 === granted provided that (1) source code retains these copyright, permission,
 === and disclaimer notices, and (2) redistributions including binaries
 === reproduce the notices in supporting documentation.
 ===
 === THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
 === IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
 === ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS
 === SOFTWARE.
 ===
 === CSL requests users of this software to return to csl-dist@cs.utah.edu any
 === improvements that they make and grant CSL redistribution rights.
 -->

<!-- These are some basic things that other things can reference -->

<idl type="base">

  <pres type="var">
  
    <func kind="T_var()" inline=true>
      : ptr_(0)
    {}
    </func>
    
    <func kind="T_var(T_ptr)" inline=true>
     : ptr_(<(parameter[0])>)
    {}
    </func>
    
    <func kind="T_var(const T_var &)" inline=true>
    {
      if( <(parameter[0])>.ptr_ )
        this->ptr_ = new <(definition)>(*<(parameter[0])>.ptr_);
      else
        this->ptr_ = 0;
    }
    </func>
    
    <func kind="~T_var()" inline=true>
    {
      delete this->ptr_;
    }
    </func>
    
    <func kind="T_var &operator=(T_ptr)" inline=true>
    {
      delete this->ptr_;
      this->ptr_ = <(parameter[0])>;
      return *this;
    }
    </func>
    
    <func kind="T_var &operator=(T_var &)" inline=true>
    {
      if( this != &amp;<(parameter[0])> )
      {
        delete this->ptr_;
	this->ptr_ = new <(definition)>(*<(parameter[0])>.ptr_);
      }
      return *this;
    }
    </func>
    
    <func kind="T_ptr operator->()" inline=true>
    {
      return this->ptr_;
    }
    </func>
    
    <func kind="const T_ptr operator->() const" inline=true>
    {
      return this->ptr_;
    }
    </func>
    
    <func kind="operator const T_ptr &() const" inline=true>
    {
      return *this->ptr_;
    }
    </func>
    
    <func kind="operator T_ptr &()" inline=true>
    {
      return *this->ptr_;
    }
    </func>
    
    <func kind="operator T_ptr &() const" inline=true>
    {
      return *this->ptr_;
    }
    </func>
    
    <func kind="in()" inline=true>
    {
      return *this->ptr_;
    }
    </func>
    
    <func kind="inout()" inline=true>
    {
      return *this->ptr_;
    }
    </func>
    
    <func kind="out()" inline=true>
    {
      return this->ptr_;
    }
    </func>
    
    <func kind="_retn()" inline=true>
    {
      retrurn *this->ptr_;
    }
    </func>
    
    <func kind="ptr()" inline=true>
    {
      return this->ptr_;
    }
    </func>
    
  </pres>
  
  <pres type="main">
  
    <func kind="operator<<=(copy)">
    {
      <(definition)> *_any_val;
      ACE_NEW(_any_val, <(definition)> (<(parameter[1])>));
      if( !_any_val ) return;
      ACE_TRY_NEW_ENV
      {
        <(parameter[0])>.replace(<(tc_ref)>, _any_val, 1, ACE_TRY_ENV);
	ACE_TRY_CHECK;
      }
      ACE_CATCHANY
      {
        delete _any_val;
      }
      ACE_ENDTRY;
    }
    </func>
    
    <func kind="operator<<=(no-copy)">
    {
      ACE_TRY_NEW_ENV
      {
        <(parameter[0])>.replace(<(tc_ref)>, <(parameter[1])>, 1, ACE_TRY_ENV);
	ACE_TRY_CHECK;
      }
      ACE_CATCHANY {}
      ACE_ENDTRY;
    }
    </func>
    
    <func kind="bool operator>>=(any &, ptr &)">
    {
      ACE_TRY_NEW_ENV
      {
        CORBA::TypeCode_var type = <(parameter[0])>.type();
	if(!type->equal(<(tc_ref)>, ACE_TRY_ENV)) return 0;
	ACE_TRY_CHECK;
	if(<(parameter[0])>.any_owns_data())
	{
	  <(parameter[1])> = (<(definition)> *)<(parameter[0])>.value();
	  return 1;
	}
	else
	{
	  ACE_NEW_RETURN(<(parameter[1])>, <(definition)>, 0);
	  TAO_InputCDR stream (<(parameter[0])>._tao_get_cdr());
	  if(stream.decode(<(tc_ref)>, <(parameter[1])>, 0, ACE_TRY_ENV)
	    == CORBA::TypeCode::TRAVERSE_CONTINUE)
	  {
	    ((CORBA::Any *)&amp;<(parameter[0])>)->replace(<(tc_ref)>, <(parameter[1])>, 1, ACE_TRY_ENV);
	    ACE_TRY_CHECK;
	    return 1;
	  }
	  else
	  {
	    delete <(parameter[1])>;
	  }
	}
      }
      ACE_CATCHANY
      {
        delete <(parameter[1])>;
	return 0;
      }
      ACE_ENDTRY;
      return 0;
    }
    </func>
    
  </pres>
  
</idl>

<idl type="string">

  <pres type="main">
  
    <macro name="do_copy" rparams={ptype:tag_list ptr:bool arg:string}>
    <(ptype.main.'string_dup()'.name)>(<(arg)>)
    </macro>
    
    <macro name="do_free" rparams={ptype:tag_list arg:string}>
    <(ptype.main.'string_free()'.name)>(<(arg)>)
    </macro>
    
    <macro name="do_access"
           rparams={ptype:tag_list alloc_flag:string slot:string}>
    return &amp;<(slot)>;
    </macro>
    
  </pres>
  
</idl>

<idl type="Any">

  <pres type="main">
  
    <macro name="do_copy" rparams={ptype:tag_list ptr:bool arg:string}>
    new <(ptype.definition)>(<if ptr>*</if><(arg)>)
    </macro>
    
    <macro name="do_free" rparams={ptype:tag_list arg:string}>
    delete (<(arg)>)
    </macro>
    
    <macro name="do_access"
           rparams={ptype:tag_list alloc_flag:string slot:string}>
    <pre>
    if( <(alloc_flag)> )
      <(slot)> = new CORBA::Any;
    return <(slot)>;</pre>
    </macro>
  
  </pres>
  
</idl>

<idl type="TypeCode">

  <pres type="main">
  
    <macro name="do_copy" rparams={ptype:tag_list ptr:bool arg:string}>
    CORBA::TypeCode::_duplicate(<(arg)>)
    </macro>
    
    <macro name="do_free" rparams={ptype:tag_list arg:string}>
    CORBA::release(<(arg)>)
    </macro>
    
    <macro name="do_access"
           rparams={ptype:tag_list alloc_flag:string slot:string}>
    return &amp;<(slot)>;
    </macro>
    
  </pres>
  
</idl>

<!-- End of file. -->

