summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be
diff options
context:
space:
mode:
authorgokhale <gokhale@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-11 22:27:10 +0000
committergokhale <gokhale@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-11 22:27:10 +0000
commit554719111f0e85c2fe1a6e91ca3f4101b3885474 (patch)
tree8251801dd45bad1351220997e2c4671c12d3da52 /TAO/TAO_IDL/be
parent1438b84e047c8c387f0a8ac21d0609d8e9bd4647 (diff)
downloadATCD-554719111f0e85c2fe1a6e91ca3f4101b3885474.tar.gz
*** empty log message ***
Diffstat (limited to 'TAO/TAO_IDL/be')
-rw-r--r--TAO/TAO_IDL/be/be_array.cpp543
-rw-r--r--TAO/TAO_IDL/be/be_interpretive.cpp12
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array.cpp537
-rw-r--r--TAO/TAO_IDL/be/be_visitor_enum.cpp4
-rw-r--r--TAO/TAO_IDL/be/be_visitor_exception.cpp6
-rw-r--r--TAO/TAO_IDL/be/be_visitor_interface.cpp19
-rw-r--r--TAO/TAO_IDL/be/be_visitor_sequence.cpp6
-rw-r--r--TAO/TAO_IDL/be/be_visitor_structure.cpp7
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typedef.cpp100
-rw-r--r--TAO/TAO_IDL/be/be_visitor_union.cpp6
10 files changed, 719 insertions, 521 deletions
diff --git a/TAO/TAO_IDL/be/be_array.cpp b/TAO/TAO_IDL/be/be_array.cpp
index b3211329eb0..967bfb0042c 100644
--- a/TAO/TAO_IDL/be/be_array.cpp
+++ b/TAO/TAO_IDL/be/be_array.cpp
@@ -216,449 +216,6 @@ be_array::gen_dimensions (TAO_OutStream *os, unsigned short slice)
return 0;
}
-#if 0 // to be eventually removed after we add support
-
-int
-be_array::gen_client_header (void)
-{
- TAO_OutStream *ch; // output stream
- TAO_NL nl; // end line
- be_type *bt; // our base type
- be_state *s; // state based code gen object
-
- if (!this->cli_hdr_gen_) // not already generated
- {
- // retrieve a singleton instance of the code generator
- TAO_CodeGen *cg = TAO_CODEGEN::instance ();
- cg->push (TAO_CodeGen::TAO_ARRAY_DEFN_CH); // set current code gen state
-
- ch = cg->client_header (); // retrieve client hdr stream
-
- if (this->create_name () == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "name creation failed\n"),
- 0);
- }
- s = cg->make_state (); // get the state-based code generation object
- if (!s)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "Bad state\n"),
- -1);
- }
-
- // retrieve the base type
- bt = be_type::narrow_from_decl (this->base_type ());
- if (!bt)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "Bad type\n"),
- -1);
- }
-
- // generate the ifdefined macro for the array type
- ch->gen_ifdef_macro (this->flatname ());
-
- ch->indent (); // start from current indentation
- // generate code for our base type if required and then print the type
- // name
- if (s->gen_code (bt, this) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "state based codegen failed\n"),
- -1);
- }
-
- // print our name
- *ch << " " << this->local_name ();
- // print our dimensions
- if (this->gen_dimensions (ch) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "dimension codegen failed\n"),
- -1);
- }
-
- *ch << ";" << nl;
-
- // if our base type is VARIABLE length, then we are variable length too
- this->size_type (bt->size_type ());
- cg->pop ();
-
- cg->push (TAO_CodeGen::TAO_ARRAY_OTHER_CH); // rest of the array defn
- s = cg->make_state ();
- if (!s)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "bad state\n"),
- -1);
- }
-
- // now generate the slice definition
- *ch << "typedef ";
- if (s->gen_code (bt, this) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "state based codegen failed\n"),
- -1);
- }
-
- *ch << " " << this->local_name () << "_slice";
- // print dimensions except first one
- if (this->gen_dimensions (ch, 1) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "slice dimensions codegen failed\n"),
- -1);
- }
- *ch << ";" << nl;
-
- // memory management functions
-
- // The T_alloc method
- // first find if we are inside a scope
- if (this->is_nested ()) // we were defined inside a scope. Hence the
- // memory management functions become static
- // members of the enclosing class
- *ch << "static ";
-
- // the return type is a pointer to slice
- *ch << this->local_name () << "_slice *"
- << this->local_name () << "_alloc (void);" << nl;
- // the T_dup method
- if (this->is_nested ())
- *ch << "static ";
- *ch << this->local_name () << "_slice *" << this->local_name () <<
- "_dup (const " << this->local_name () << "_slice *);" << nl;
- // the T_free method
- if (this->is_nested ())
- *ch << "static ";
- *ch << "void " << this->local_name () << "_free (" << this->local_name ()
- << "_slice *);\n\n";
-
- // Generate the typecode decl
- if (this->is_nested ())
- {
- // we have a scoped name
- ch->indent ();
- *ch << "static CORBA::TypeCode_ptr "
- << this->tao_name () << ";\n\n";
- }
- else
- {
- // we are in the ROOT scope
- ch->indent ();
- *ch << "extern "
- << idl_global->export_macro ()
- << " CORBA::TypeCode_ptr "
- << this->tao_name () << ";\n\n";
- }
- ch->gen_endif ();
-
- // generate the ifdefined macro
- ch->gen_ifdef_macro (this->flatname (), "_var");
- // generate the _var, _out, and _forany definition
- if (this->gen_var_defn () == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "error generating _var class\n"),
- -1);
- }
- ch->gen_endif ();
-
- // generate the ifdefined macro
- ch->gen_ifdef_macro (this->flatname (), "_out");
- if (this->gen_out_defn () == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "error generating _out class\n"),
- -1);
- }
- ch->gen_endif ();
-
- // generate the ifdefined macro
- ch->gen_ifdef_macro (this->flatname (), "_forany");
- if (this->gen_forany_defn () == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_header - "
- "error generating _forany class\n"),
- -1);
- }
- ch->gen_endif ();
-
- this->cli_hdr_gen_ = I_TRUE;
- cg->pop ();
- }
-
- return 0;
-}
-
-int
-be_array::gen_client_stubs (void)
-{
- TAO_OutStream *cs; // output stream
- TAO_NL nl; // end line
- unsigned long i;
-
- if (!this->cli_stub_gen_)
- {
- // retrieve a singleton instance of the code generator
- TAO_CodeGen *cg = TAO_CODEGEN::instance ();
- cg->push (TAO_CodeGen::TAO_SEQUENCE_BODY_CS); // set current code gen state
-
- cs = cg->client_stubs ();
-
- // generate the typecode information here
- cs->indent (); // start from current indentation level
- *cs << "static const CORBA::Long _oc_"
- << this->tao_name () << "[] =" << nl;
- *cs << "{\n";
- cs->incr_indent (0);
- if (this->gen_encapsulation () == -1)
- {
- ACE_ERROR ((LM_ERROR, "be_array:Error generating encapsulation\n\n"));
- return -1;
- }
- cs->decr_indent ();
- *cs << "};" << nl;
-
- *cs << "static CORBA::TypeCode _tc__tc_"
- << this->tao_name ()
- << " (CORBA::tk_sequence, "
- << "sizeof (_oc_" << this->tao_name ()
- << "), (char *) &_oc_"
- << this->tao_name ()
- << ", CORBA::B_FALSE);" << nl;
- *cs << "CORBA::TypeCode_ptr "
- << this->tao_name () << " = &_tc__tc_"
- << this->tao_name () << ";\n\n";
-
- cg->pop ();
- this->cli_stub_gen_ = I_TRUE;
-
- // T_dup method
- *cs << this->name () << "_slice *" << nl;
- *cs << this->name () << "_dup (const "
- << this->name () << "_slice * s)" << nl;
- *cs << "{\n";
- cs->incr_indent ();
- *cs << this->name () << "_slice *temp;" << nl;
- *cs << "// alloc an array" << nl;
- *cs << "temp = " << this->name () << "_alloc ();" << nl;
- *cs << "// copy each individual elements" << nl;
- // generate nested loops for as many dimensions as there are
- for (i = 0; i < this->n_dims (); i++)
- {
- AST_Expression *expr = this->dims ()[i]; // retrieve the ith
- // dimension value
- if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL)))
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_stubs - "
- "bad array dimension\n"),
- -1);
- }
- if (expr->ev ()->et == AST_Expression::EV_ulong)
- {
- // generate a loop for each dimension
- *cs << "for (CORBA::ULong i" << i << " = 0; i" << i << " < " <<
- expr->ev ()->u.ulval << "; i" << i << "++)\n";
- cs->incr_indent ();
- }
- else
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_stubs - "
- "bad array dimension value\n"),
- -1);
- }
- }
-
- // now generate code such that every element of the array gets assigned
- // inside the innermost level of the nested loops generated above
- *cs << "temp"; // generate the lvalue
- for (i = 0; i < this->n_dims (); i++)
- {
- *cs << "[i" << i << "]";
- }
- *cs << " = ";
- *cs << "s"; // generate the rvalue
- for (i = 0; i < this->n_dims (); i++)
- {
- *cs << "[i" << i << "]";
- }
- *cs << ";\n";
- for (i = 0; i < this->n_dims (); i++)
- {
- // decrement indentation as many times as the number of dimensions
- cs->decr_indent (0);
- }
- cs->indent ();
- *cs << "return temp;\n";
- // one more to get to the outermost level
- cs->decr_indent ();
- *cs << "}\n\n";
- }
-
- return 0;
-}
-
-// Generates the client-side inline information
-int
-be_array::gen_client_inline (void)
-{
-
- if (!this->cli_inline_gen_)
- {
- TAO_OutStream *ci; // output stream
- TAO_NL nl; // end line
- be_type *bt; // our base type
- be_state *s; // state based code gen obj
-
- // retrieve a singleton instance of the code generator
- TAO_CodeGen *cg = TAO_CODEGEN::instance ();
-
- ci = cg->client_inline ();
- cg->push (TAO_CodeGen::TAO_ARRAY_DEFN_CI);
- s = cg->make_state ();
- if (!s)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_inline - "
- "bad state\n"),
- -1);
- }
-
- // retrieve our base type
- bt = be_type::narrow_from_decl (this->base_type ());
- if (!bt)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_inline - "
- "bad base type\n"),
- -1);
- }
-
- // first define the _alloc, _dup and _free methods
- // If we are defined inside some scope, these methods become static
- // members of the enclosing scope
-
- // alloc method
- ci->indent (); // start from current indentation
- *ci << "ACE_INLINE " << this->name () << "_slice *" << nl;
- *ci << this->name () << "_alloc (void)" << nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return new ";
- if (s->gen_code (bt, this) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_inline - "
- "state based codegen failed\n"),
- -1);
- }
- if (this->gen_dimensions (ci) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_array::"
- "gen_client_inline - "
- "dimensions codegen failed\n"),
- -1);
- }
-
- *ci << ";\n";
- ci->decr_indent ();
- *ci << "}\n\n";
-
- // free method
- *ci << "ACE_INLINE void" << nl
- << this->name () << "_free (" << this->name ()
- << "_slice *s)" << nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "delete [] s;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
-
- // emit implementations of methods of the _var, _out, and _forany classes
- if (this->gen_var_impl () == -1)
- {
- ACE_ERROR ((LM_ERROR, "be_array: _var impl code gen failed\n"));
- return -1;
- }
- if (this->gen_out_impl () == -1)
- {
- ACE_ERROR ((LM_ERROR, "be_array: _out impl code gen failed\n"));
- return -1;
- }
- if (this->gen_forany_impl () == -1)
- {
- ACE_ERROR ((LM_ERROR, "be_array: _forany impl code gen failed\n"));
- return -1;
- }
-
- // generate client inline for base type
- if (bt->gen_client_inline () == -1)
- {
- ACE_ERROR ((LM_ERROR, "be_array: base type inline code gen failed\n"));
- return -1;
- }
-
- cg->pop ();
- this->cli_inline_gen_ = I_TRUE;
- }
-
- return 0;
-}
-
-int
-be_array::gen_server_header (void)
-{
- return 0;
-}
-
-int
-be_array::gen_server_skeletons (void)
-{
- return 0;
-}
-
-int
-be_array::gen_server_inline (void)
-{
- // nothing to be done
- return 0;
-}
-#endif
-
// generate the var defn
int
@@ -1184,8 +741,10 @@ be_array::gen_forany_defn (void)
*ch << this->local_name () << "_slice *_retn (void);" << nl;
// generate an additional member function that returns the underlying pointer
- *ch << this->local_name () << "_slice *ptr (void) const;\n";
+ *ch << this->local_name () << "_slice *ptr (void) const;" << nl;
+ // additional member function that returns the NOCOPY flag
+ *ch << "CORBA::Boolean nocopy (void) const;\n";
*ch << "\n";
ch->decr_indent ();
@@ -1263,10 +822,8 @@ be_array::gen_forany_impl (void)
ci->indent ();
*ci << "ACE_INLINE" << nl;
*ci << fname << "::~" << lname << " (void) // destructor" << nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << this->name () << "_free (this->ptr_);\n";
- ci->decr_indent ();
+ *ci << "{" << nl;
+ *ci << " // don't do anything" << nl;
*ci << "}\n\n";
// assignment operator
@@ -1397,23 +954,35 @@ be_array::gen_forany_impl (void)
ci->decr_indent ();
*ci << "}\n\n";
+ // the additional nocopy member function
+ ci->indent ();
+ *ci << "ACE_INLINE CORBA::Boolean" << nl;
+ *ci << fname << "::nocopy (void) const" << nl;
+ *ci << "{\n";
+ ci->incr_indent ();
+ *ci << "return this->nocopy_;\n";
+ ci->decr_indent ();
+ *ci << "}\n\n";
+
return 0;
}
int
be_array::gen_typecode (void)
{
- TAO_OutStream *cs; // output stream
- TAO_NL nl; // end line
- TAO_CodeGen *cg = TAO_CODEGEN::instance ();
+ TAO_OutStream *os; // output stream
- cs = cg->client_stubs ();
- cs->indent (); // start from whatever indentation level we were at
+ os = tao_cg->client_stubs ();
+ os->indent (); // start from whatever indentation level we were at
- *cs << "CORBA::tk_array, // typecode kind" << nl;
- *cs << this->tc_size () << ", // encapsulation length\n";
+ *os << "CORBA::tk_array, // typecode kind" << be_nl;
+ *os << this->tc_encap_len () << ", // encapsulation length" << be_idt << "\n";
// now emit the encapsulation
- return this->gen_encapsulation ();
+ if (this->gen_encapsulation () == -1)
+ {
+ }
+ // *os << (this->dims () [0]) << "," << be_nl;
+ return 0;
}
// generate encapsulation
@@ -1426,28 +995,48 @@ int
be_array::gen_encapsulation (void)
{
TAO_OutStream *os; // output stream
- TAO_NL nl; // end line
- TAO_CodeGen *cg = TAO_CODEGEN::instance ();
be_type *bt; // base type
+ unsigned long i;
- os = cg->client_stubs ();
+ os = tao_cg->client_stubs ();
os->indent (); // start from the current indentation level
- // XXXASG - byte order must be based on what m/c we are generating code -
- // TODO
- *os << "TAO_ENCAP_BYTE_ORDER, // byte order" << nl;
-
- // emit typecode of element type
+ // retrieve the base type
bt = be_type::narrow_from_decl (this->base_type ());
- if (!bt || (bt->gen_typecode () == -1))
+ if (!bt)
{
- ACE_ERROR ((LM_ERROR, "be_sequence::gen_typecode - bad base type\n"));
- return -1;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_array::gen_encapsulation - "
+ "bad base type\n"),
+ -1);
}
- // emit the length
+ for (i=0; i < (this->n_dims () - 1); i++)
+ {
+ unsigned long rem_encap_len;
+
+ *os << "TAO_ENCAP_BYTE_ORDER, // byte order" << be_nl;
+ *os << "CORBA::tk_array, // typecode kind" << be_nl;
+ rem_encap_len
+ = (this->n_dims () - (i+1))*(4+4)
+ + (this->n_dims () - (i+2))*(4+4)
+ + bt->tc_size ();
+ *os << rem_encap_len << ", // encapsulation length" << be_idt_nl;
+ }
+ *os << "TAO_ENCAP_BYTE_ORDER, // byte order\n";
+ if (bt->gen_typecode () == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_array::gen_encapsulation - "
+ "base type tyepcode gen failed\n"),
+ -1);
+ }
os->indent ();
- // *os << this->max_size () << ",\n";
+ for (i = (this->n_dims ()-1); i > 0; i--)
+ {
+ *os << this->dims ()[i] << "," << be_uidt_nl;
+ }
+ *os << this->dims ()[0] << be_uidt << ",\n";
return 0;
}
@@ -1456,19 +1045,23 @@ long
be_array::tc_size (void)
{
// 4 bytes for enumeration, 4 bytes for storing encap length val, followed by the
- // actual encapsulation length
+ // actual encapsulation
return 4 + 4 + this->tc_encap_len ();
}
long
be_array::tc_encap_len (void)
{
+ // Suppose "N" is the number of dimensions, then for a N dimensional array,
+ // we will have N encapsulations. The innermost encapsulation will hold the
+ // typecode of the real base type.
+ // Thus, we will have N byte order flags and dimensions, and N-1 tk_array
+ // enumerations, encapsulation lengths, and dimensions.
+
if (this->encap_len_ == -1) // not computed yet
{
be_type *bt; // base type
- this->encap_len_ = 4; // holds the byte order flag
- // add the encapsulation length of our base type
bt = be_type::narrow_from_decl (this->base_type ());
if (!bt)
{
@@ -1476,9 +1069,11 @@ be_array::tc_encap_len (void)
"be_array::tc_encap_len - bad base type\n"));
return 0;
}
+ this->encap_len_ =
+ this->n_dims () * (4+4) // N byte order flags and dims
+ + (this->n_dims ()-1)* (4+4); // N-1 of Enum and encap lengths
+ // to this you add the typecode size of the underlying type
this->encap_len_ += bt->tc_size ();
- this->encap_len_ += 4; // to hold the array size
-
}
return this->encap_len_;
}
diff --git a/TAO/TAO_IDL/be/be_interpretive.cpp b/TAO/TAO_IDL/be/be_interpretive.cpp
index 346c4b5e039..4cfa72d80b5 100644
--- a/TAO/TAO_IDL/be/be_interpretive.cpp
+++ b/TAO/TAO_IDL/be/be_interpretive.cpp
@@ -26,6 +26,7 @@
#include "be_interpretive.h"
#include "be_visitor_args.h"
+#include "be_visitor_array.h"
#include "be_visitor_attribute.h"
#include "be_visitor_constant.h"
#include "be_visitor_enum.h"
@@ -328,6 +329,17 @@ TAO_Interpretive_Visitor_Factory::make_visitor (be_visitor_context *ctx)
case TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS:
return new be_visitor_exception_any_op_cs (new_ctx);
+ case TAO_CodeGen::TAO_ARRAY_CH:
+ return new be_visitor_array_ch (new_ctx);
+ case TAO_CodeGen::TAO_ARRAY_CI:
+ return new be_visitor_array_ci (new_ctx);
+ case TAO_CodeGen::TAO_ARRAY_CS:
+ return new be_visitor_array_cs (new_ctx);
+ case TAO_CodeGen::TAO_ARRAY_ANY_OP_CH:
+ return new be_visitor_array_any_op_ch (new_ctx);
+ case TAO_CodeGen::TAO_ARRAY_ANY_OP_CS:
+ return new be_visitor_array_any_op_cs (new_ctx);
+
case TAO_CodeGen::TAO_OPERATION_RESULT_SS:
case TAO_CodeGen::TAO_ARGUMENT_CH:
case TAO_CodeGen::TAO_ARGUMENT_CS:
diff --git a/TAO/TAO_IDL/be/be_visitor_array.cpp b/TAO/TAO_IDL/be/be_visitor_array.cpp
new file mode 100644
index 00000000000..0f92cd40b52
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_array.cpp
@@ -0,0 +1,537 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// be_visitor_array.cpp
+//
+// = DESCRIPTION
+// Visitors for generation of code for Array
+//
+// = AUTHOR
+// Aniruddha Gokhale
+//
+// ============================================================================
+
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
+
+#include "be_visitor_array.h"
+
+// ************************************************************************
+// visitor for array declaration in client header
+// ************************************************************************
+
+be_visitor_array_ch::be_visitor_array_ch (be_visitor_context *ctx)
+ : be_visitor_decl (ctx)
+{
+}
+
+be_visitor_array_ch::~be_visitor_array_ch (void)
+{
+}
+
+int be_visitor_array_ch::visit_array (be_array *node)
+{
+ TAO_OutStream *os = this->ctx_->stream (); // get output stream
+ be_type *bt; // base type
+ be_decl *scope = this->ctx_->scope (); // scope in which it is used
+
+ // nothing to do if we are imported or code is already generated
+ if (node->imported () || (node->cli_hdr_gen ()))
+ return 0;
+
+ this->ctx_->node (node); // save the array node
+
+ // retrieve the type
+ bt = be_type::narrow_from_decl (node->base_type ());
+ if (!bt)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ch::"
+ "visit_array - "
+ "Bad base type\n"),
+ -1);
+ }
+
+ // generate the ifdefined macro
+ os->gen_ifdef_macro (node->flatname ());
+
+ os->indent ();
+ if (this->ctx_->tdef ())
+ {
+ // this is a typedef to an array node
+ *os << "typedef " << bt->nested_type_name (scope) << " "
+ << node->local_name ();
+ if (node->gen_dimensions (os) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ch::"
+ "visit_array - "
+ "gen dimensions failed\n"),
+ -1);
+ }
+ *os << ";" << be_nl;
+ *os << "typedef " << bt->nested_type_name (scope) << " "
+ << node->local_name () << "_slice";
+ if (node->gen_dimensions (os, 1) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ch::"
+ "visit_array - "
+ "gen slice dimensions failed\n"),
+ -1);
+ }
+ *os << ";" << be_nl;
+ }
+ else
+ {
+ }
+ // typedef the _var, _out, and _forany types
+ if (node->gen_var_defn () == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ch::"
+ "visit_argument - "
+ "var_defn failed\n"),
+ -1);
+ }
+ if (node->gen_out_defn () == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ch::"
+ "visit_argument - "
+ "out_defn failed\n"),
+ -1);
+ }
+ if (node->gen_forany_defn () == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ch::"
+ "visit_argument - "
+ "forany_defn failed\n"),
+ -1);
+ }
+ // the _alloc, _dup, copy, and free methods. If the node is nested, the
+ // methods become static
+ *os << "static " << node->nested_type_name (scope, "_slice") << " *"
+ << node->nested_type_name (scope, "_alloc") << " (void);" << be_nl;
+ *os << "static " << node->nested_type_name (scope, "_slice") << " *"
+ << node->nested_type_name (scope, "_dup") << " (const "
+ << node->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl;
+ *os << "static void " << node->nested_type_name (scope, "_copy") << " ("
+ << node->nested_type_name (scope, "_slice") << " *_tao_to, const "
+ << node->nested_type_name (scope, "_slice") << " *_tao_from);" << be_nl;
+ *os << "static void " << node->nested_type_name (scope, "_free") << " ("
+ << node->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl;
+
+ // is this a typedefined array? if so, then let the typedef deal with
+ // generation of the typecode
+ if (!this->ctx_->tdef ())
+ {
+ // by using a visitor to declare and define the TypeCode, we have the
+ // added advantage to conditionally not generate any code. This will be
+ // based on the command line options. This is still TO-DO
+ be_visitor_context ctx = *this->ctx_;
+ ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL);
+ be_visitor *visitor = tao_cg->make_visitor (&ctx);
+ if (!visitor || (node->accept (visitor) == -1))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_ch::"
+ "visit_array - "
+ "TypeCode declaration failed\n"
+ ), -1);
+ }
+ delete visitor;
+ }
+
+ // generate the endif macro
+ os->gen_endif ();
+
+ node->cli_hdr_gen (1);
+ return 0;
+}
+
+// ************************************************************************
+// visitor for array declaration in client inline
+// ************************************************************************
+
+be_visitor_array_ci::be_visitor_array_ci (be_visitor_context *ctx)
+ : be_visitor_decl (ctx)
+{
+}
+
+be_visitor_array_ci::~be_visitor_array_ci (void)
+{
+}
+
+int be_visitor_array_ci::visit_array (be_array *node)
+{
+ TAO_OutStream *os = this->ctx_->stream (); // get output stream
+ be_type *bt; // base type
+ be_decl *scope = this->ctx_->scope (); // scope in which it is used
+
+ // nothing to do if we are imported or code is already generated
+ if (node->imported () || (node->cli_inline_gen ()))
+ return 0;
+
+ this->ctx_->node (node); // save the array node
+
+ // retrieve the type
+ bt = be_type::narrow_from_decl (node->base_type ());
+ if (!bt)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ci::"
+ "visit_array - "
+ "Bad base type\n"),
+ -1);
+ }
+
+ // alloc method
+ os->indent (); // start from current indentation
+ *os << "ACE_INLINE " << node->name () << "_slice *" << be_nl;
+ *os << node->name () << "_alloc (void)" << be_nl;
+ *os << "{" << be_idt_nl;
+ *os << "return new " << bt->name ();
+ if (node->gen_dimensions (os) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_array::"
+ "gen_client_inline - "
+ "dimensions codegen failed\n"),
+ -1);
+ }
+
+ *os << ";" << be_uidt_nl;
+ *os << "}\n\n";
+
+ // free method
+ os->indent ();
+ *os << "ACE_INLINE void" << be_nl
+ << node->name () << "_free (" << node->name ()
+ << "_slice *_tao_slice)" << be_nl;
+ *os << "{" << be_idt_nl;
+ *os << "delete [] _tao_slice;" << be_uidt_nl;
+ *os << "}\n\n";
+
+ // generate code for the _var, _out, and _forany types
+ if (node->gen_var_impl () == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ci::"
+ "visit_array - "
+ "var_defn failed\n"),
+ -1);
+ }
+ if (node->gen_out_impl () == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ci::"
+ "visit_array - "
+ "out_defn failed\n"),
+ -1);
+ }
+ if (node->gen_forany_impl () == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ci::"
+ "visit_array - "
+ "forany_defn failed\n"),
+ -1);
+ }
+
+ // is this a typedefined array? if so, then let the typedef deal with
+ // generation of the typecode
+ if (!this->ctx_->tdef ())
+ {
+ // by using a visitor to declare and define the TypeCode, we have the
+ // added advantage to conditionally not generate any code. This will be
+ // based on the command line options. This is still TO-DO
+ be_visitor_context ctx = *this->ctx_;
+ ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN);
+ be_visitor *visitor = tao_cg->make_visitor (&ctx);
+ if (!visitor || (node->accept (visitor) == -1))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_cs::"
+ "visit_array - "
+ "TypeCode definition failed\n"
+ ), -1);
+ }
+ delete visitor;
+ }
+
+ node->cli_inline_gen (1);
+ return 0;
+}
+
+// ************************************************************************
+// visitor for array declaration in client stubs
+// ************************************************************************
+
+be_visitor_array_cs::be_visitor_array_cs (be_visitor_context *ctx)
+ : be_visitor_decl (ctx)
+{
+}
+
+be_visitor_array_cs::~be_visitor_array_cs (void)
+{
+}
+
+int be_visitor_array_cs::visit_array (be_array *node)
+{
+ TAO_OutStream *os = this->ctx_->stream (); // get output stream
+ be_type *bt; // base type
+ be_decl *scope = this->ctx_->scope (); // scope in which it is used
+ unsigned long i;
+
+ // nothing to do if we are imported or code is already generated
+ if (node->imported () || (node->cli_stub_gen ()))
+ return 0;
+
+ this->ctx_->node (node); // save the array node
+
+ // retrieve the type
+ bt = be_type::narrow_from_decl (node->base_type ());
+ if (!bt)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_ci::"
+ "visit_array - "
+ "Bad base type\n"),
+ -1);
+ }
+
+ // dup method
+ os->indent ();
+ *os << node->name () << "_slice *" << be_nl
+ << node->name () << "_dup (const " << node->name ()
+ << "_slice *_tao_src_array)" << be_nl;
+ *os << "{" << be_idt_nl;
+ *os << node->name () << "_slice *_tao_dup_array = " << node->name ()
+ << "_alloc ();" << be_nl;
+ *os << "if (!_tao_dup_array) return (" << node->name ()
+ << "_slice *)0;" << be_nl;
+ *os << node->name () << "_copy (_tao_dup_array, _tao_src_array);" << be_nl;
+ *os << "return _tao_dup_array;" << be_uidt_nl;
+ *os << "}\n\n";
+
+ // copy method
+ *os << "void " << be_nl;
+ *os << node->name () << "_copy (" << node->name () << "_slice * _tao_to, "
+ << "const " << node->name () << "_slice *_tao_from)" << be_nl;
+ *os << "{" << be_idt_nl;
+ *os << "// copy each individual elements" << be_nl;
+
+ // generate nested loops for as many dimensions as there are
+ for (i = 0; i < node->n_dims (); i++)
+ {
+ // retrieve the ith dimension value
+ AST_Expression *expr = node->dims ()[i];
+ // dimension value
+ if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL)))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_cs::"
+ "visit_array - "
+ "bad array dimension\n"),
+ -1);
+ }
+ if (expr->ev ()->et == AST_Expression::EV_ulong)
+ {
+ // generate a loop for each dimension
+ *os << "for (CORBA::ULong i" << i << " = 0; i" << i << " < "
+ << expr->ev ()->u.ulval << "; i" << i << "++)" << be_idt_nl;
+ }
+ else
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_cs::"
+ "visit_array - "
+ "bad array dimension value\n"),
+ -1);
+ }
+ }
+
+ // now generate code such that every element of the array gets assigned
+ // inside the innermost level of the nested loops generated above
+ be_array *primitive_type = 0;
+ if (bt->node_type () == AST_Decl::NT_typedef)
+ {
+ // base type of the array node is a typedef. We need to make sure that
+ // this typedef is not to another array type. If it is, then we cannot
+ // assign an array to another. We will have to invoke the underlying
+ // array type's copy method for every array dimension.
+ be_typedef *tdef = be_typedef::narrow_from_decl (bt);
+ // check if the base type of the typedef node is an Array node
+ primitive_type = be_array::narrow_from_decl (tdef->base_type ());
+ }
+ if (primitive_type)
+ {
+ // the base type is not a typedef to a possibly another array type. In
+ // such a case, assign each element.
+
+ *os << "// call the underlying _copy" << be_nl;
+ *os << bt->name () << "_copy (_tao_to";
+ for (i = 0; i < node->n_dims (); i++)
+ {
+ *os << "[i" << i << "]";
+ }
+ *os << ", ";
+ *os << "_tao_from"; // generate the rvalue
+ for (i = 0; i < node->n_dims (); i++)
+ {
+ *os << "[i" << i << "]";
+ }
+ *os << ");";
+ }
+ else
+ {
+ // the base type is not a typedef to a possibly another array type. In
+ // such a case, assign each element.
+
+ *os << "_tao_to"; // generate the lvalue
+ for (i = 0; i < node->n_dims (); i++)
+ {
+ *os << "[i" << i << "]";
+ }
+ *os << " = ";
+ *os << "_tao_from"; // generate the rvalue
+ for (i = 0; i < node->n_dims (); i++)
+ {
+ *os << "[i" << i << "]";
+ }
+ *os << ";";
+ }
+ for (i = 0; i < node->n_dims (); i++)
+ {
+ // decrement indentation as many times as the number of dimensions
+ *os << be_uidt;
+ }
+ *os << be_uidt_nl << "}\n\n";
+
+ node->cli_stub_gen (1);
+
+ return 0;
+}
+
+// ***************************************************************************
+// Array visitor for generating Any operator declarations in the client header
+// ***************************************************************************
+
+be_visitor_array_any_op_ch::be_visitor_array_any_op_ch
+(be_visitor_context *ctx)
+ : be_visitor_decl (ctx)
+{
+}
+
+be_visitor_array_any_op_ch::~be_visitor_array_any_op_ch (void)
+{
+}
+
+int
+be_visitor_array_any_op_ch::visit_array (be_array *node)
+{
+ if (node->cli_hdr_any_op_gen () || node->imported ())
+ return 0;
+
+ TAO_OutStream *os = tao_cg->client_header ();
+
+ // generate the Any <<= and >>= operator declarations
+ os->indent ();
+ *os << "void " << idl_global->export_macro ()
+ << " operator<<= (CORBA::Any &, const " << node->name ()
+ << "_forany &);" << be_nl;
+ *os << "CORBA::Boolean " << idl_global->export_macro ()
+ << " operator>>= (const CORBA::Any &, "
+ << node->name () << "_forany &);\n";
+
+ node->cli_hdr_any_op_gen (1);
+ return 0;
+}
+
+// ***************************************************************************
+// Array visitor for generating Any operator declarations in the client
+// stubs file
+// ***************************************************************************
+
+be_visitor_array_any_op_cs::be_visitor_array_any_op_cs
+(be_visitor_context *ctx)
+ : be_visitor_decl (ctx)
+{
+}
+
+be_visitor_array_any_op_cs::~be_visitor_array_any_op_cs (void)
+{
+}
+
+int
+be_visitor_array_any_op_cs::visit_array (be_array *node)
+{
+ if (node->cli_stub_any_op_gen () || node->imported ())
+ return 0;
+
+ TAO_OutStream *os = tao_cg->client_stubs ();
+
+ // generate the Any <<= and >>= operator declarations
+ // Any <<= and >>= operators
+ os->indent ();
+ *os << "void operator<<= (CORBA::Any &_tao_any, const "
+ << node->name () << "_forany &_tao_elem)" << be_nl
+ << "{" << be_idt_nl
+ << "CORBA::Environment _tao_env;" << be_nl
+ << "if (_tao_elem.nocopy ()) // no copy" << be_idt_nl
+ << "_tao_any.replace (" << node->tc_name () << ", "
+ << "_tao_elem.ptr (), 1, _tao_env); // consume it" << be_uidt_nl
+ << "else // copy" << be_idt_nl
+ << "_tao_any.replace (" << node->tc_name () << ", " << node->name ()
+ << "_dup (_tao_elem.ptr ()), 1, _tao_env);" << be_uidt_nl
+ << be_uidt_nl << "}" << be_nl;
+
+ *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, "
+ << node->name () << "_forany &_tao_elem)" << be_nl
+ << "{" << be_idt_nl
+ << "CORBA::Environment _tao_env;" << be_nl
+ << "if (!_tao_any.type ()->equal (" << node->tc_name ()
+ << ", _tao_env)) return 0; // not equal" << be_nl
+ << "if (_tao_any.any_owns_data ())" << be_nl
+ << "{" << be_idt_nl
+ << node->name () << "_slice *&_tao_elem_ptr = _tao_elem.out ();" << be_nl
+ << "_tao_elem_ptr = " << node->name () << "_alloc ();" << be_nl
+ << "if (!_tao_elem_ptr) return 0;" << be_nl
+ << "TAO_InputCDR stream ((ACE_Message_Block *)_tao_any.value ());"
+ << be_nl
+ << "if (stream.decode (" << node->tc_name ()
+ << ", _tao_elem_ptr, 0, _tao_env)" << be_nl
+ << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl
+ << "{" << be_idt_nl
+ << "((CORBA::Any *)&_tao_any)->replace (_tao_any.type (), "
+ << "_tao_elem_ptr, 1, _tao_env);"
+ << be_nl
+ << " return 1;" << be_uidt_nl
+ << "}" << be_nl
+ << "else" << be_nl // decode failed
+ << "{" << be_idt_nl
+ << node->name () << "_free (_tao_elem_ptr);" << be_nl
+ << "return 0;" << be_uidt_nl
+ << "}" << be_uidt_nl
+ << "}" << be_nl
+ << "else" << be_nl // else Any does not own the data
+ << "{" << be_idt_nl
+ << "_tao_elem = (" << node->name () << "_slice *)_tao_any.value ();"
+ << be_nl
+ << "return 1;" << be_uidt_nl
+ << "}" << be_uidt_nl
+ << "}\n\n";
+
+ node->cli_stub_any_op_gen (1);
+ return 0;
+}
diff --git a/TAO/TAO_IDL/be/be_visitor_enum.cpp b/TAO/TAO_IDL/be/be_visitor_enum.cpp
index a9ea5665410..162475bfc2c 100644
--- a/TAO/TAO_IDL/be/be_visitor_enum.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_enum.cpp
@@ -216,8 +216,8 @@ be_visitor_enum_any_op_cs::visit_enum (be_enum *node)
<< node->name () << " _tao_elem)" << be_nl
<< "{" << be_idt_nl
<< "CORBA::Environment _tao_env;" << be_nl
- << "_tao_any.replace (" << node->tc_name () << ", &"
- << "_tao_elem, 1, _tao_env);" << be_uidt_nl
+ << "_tao_any.replace (" << node->tc_name () << ", new "
+ << node->name () << "(_tao_elem), 1, _tao_env);" << be_uidt_nl
<< "}" << be_nl;
*os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, "
diff --git a/TAO/TAO_IDL/be/be_visitor_exception.cpp b/TAO/TAO_IDL/be/be_visitor_exception.cpp
index dc9bd2458cd..338cf3cc375 100644
--- a/TAO/TAO_IDL/be/be_visitor_exception.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_exception.cpp
@@ -1090,8 +1090,8 @@ be_visitor_exception_any_op_cs::visit_exception (be_exception *node)
<< node->name () << " &_tao_elem) // copying" << be_nl
<< "{" << be_idt_nl
<< "CORBA::Environment _tao_env;" << be_nl
- << "_tao_any.replace (" << node->tc_name () << ", &"
- << "_tao_elem, 1, _tao_env);" << be_uidt_nl
+ << "_tao_any.replace (" << node->tc_name () << ", new "
+ << node->name () << "(_tao_elem), 1, _tao_env);" << be_uidt_nl
<< "}" << be_nl;
*os << "void operator<<= (CORBA::Any &_tao_any, "
@@ -1099,7 +1099,7 @@ be_visitor_exception_any_op_cs::visit_exception (be_exception *node)
<< "{" << be_idt_nl
<< "CORBA::Environment _tao_env;" << be_nl
<< "_tao_any.replace (" << node->tc_name () << ", "
- << "_tao_elem, 0, _tao_env);" << be_uidt_nl
+ << "_tao_elem, 1, _tao_env); // consume it" << be_uidt_nl
<< "}" << be_nl;
*os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, "
diff --git a/TAO/TAO_IDL/be/be_visitor_interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface.cpp
index a70e554e0d2..c1bc39dee31 100644
--- a/TAO/TAO_IDL/be/be_visitor_interface.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_interface.cpp
@@ -1966,7 +1966,7 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node)
<< "{" << be_idt_nl
<< "CORBA::Environment _tao_env;" << be_nl
<< "_tao_any.replace (" << node->tc_name () << ", "
- << "_tao_elem, 0, _tao_env);" << be_uidt_nl
+ << "_tao_elem, 1, _tao_env); // consume it" << be_uidt_nl
<< "}" << be_nl;
*os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, "
@@ -2111,7 +2111,7 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node)
*os << be_uidt << "private:" << be_idt_nl
<< "T *ptr_;" << be_nl
- << "PortableServer::POA_ptr poa_;" << be_nl
+ << "PortableServer::POA_var poa_;" << be_nl
<< "CORBA::Boolean rel_;" << be_nl << be_nl
<< "// copy and assignment are not allowed" << be_nl
<< tiename << " (const " << tiename << " &);" << be_nl
@@ -2255,11 +2255,18 @@ be_visitor_interface_tie_si::visit_interface (be_interface *node)
<< "PortableServer::POA_ptr" << be_nl
<< fulltiename << "<T>::_default_POA (CORBA::Environment &env)" << be_nl
<< "{" << be_idt_nl
- << "if (!CORBA::is_nil (this->poa_))" << be_idt_nl
- << "return this->poa_;" << be_uidt_nl
+ << "if (!CORBA::is_nil (this->poa_.in ()))" << be_idt_nl
+ << "return PortableServer::POA::_duplicate (this->poa_.in ());"
+ << be_uidt_nl
+ << "else" << be_nl
+ << "{" << be_idt_nl
+ << "TAO_POA *poa = TAO_ORB_Core_instance ()->root_poa ();" << be_nl
+ << "PortableServer::POA_var result = poa->_this (env);" << be_nl
+ << "if (env.exception () != 0)" << be_idt_nl
+ << "return PortableServer::POA::_nil ();" << be_uidt_nl
<< "else" << be_idt_nl
- << "return TAO_ORB_Core_instance ()->root_poa ();"
- << be_uidt << be_uidt_nl
+ << "return result._retn ();" << be_uidt << be_uidt_nl
+ << "}" << be_uidt
<< "}\n\n";
// generate code for the operations in the scope
diff --git a/TAO/TAO_IDL/be/be_visitor_sequence.cpp b/TAO/TAO_IDL/be/be_visitor_sequence.cpp
index dd13ee27f05..466d3959f85 100644
--- a/TAO/TAO_IDL/be/be_visitor_sequence.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_sequence.cpp
@@ -112,9 +112,6 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node)
be_type *bt; // type node
TAO_OutStream *os = this->ctx_->stream ();
- if (node->cli_hdr_gen () || node->imported ())
- return 0;
-
// first create a name for ourselves
if (node->create_name (this->ctx_->tdef ()) == -1)
{
@@ -124,6 +121,9 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node)
"failed creating name\n"), -1);
}
+ if (node->cli_hdr_gen () || node->imported ())
+ return 0;
+
// generate the ifdefined macro for the sequence type
os->gen_ifdef_macro (node->flatname ());
diff --git a/TAO/TAO_IDL/be/be_visitor_structure.cpp b/TAO/TAO_IDL/be/be_visitor_structure.cpp
index a988f291b24..3e5261a34c6 100644
--- a/TAO/TAO_IDL/be/be_visitor_structure.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_structure.cpp
@@ -389,8 +389,9 @@ be_visitor_structure_any_op_cs::visit_structure (be_structure *node)
<< node->name () << " &_tao_elem) // copying" << be_nl
<< "{" << be_idt_nl
<< "CORBA::Environment _tao_env;" << be_nl
- << "_tao_any.replace (" << node->tc_name () << ", &"
- << "_tao_elem, 1, _tao_env);" << be_uidt_nl
+ << "_tao_any.replace (" << node->tc_name () << ", new "
+ << node->name () << "(_tao_elem), 1, _tao_env);"
+ << " // copy the value" << be_uidt_nl
<< "}" << be_nl;
*os << "void operator<<= (CORBA::Any &_tao_any, "
@@ -398,7 +399,7 @@ be_visitor_structure_any_op_cs::visit_structure (be_structure *node)
<< "{" << be_idt_nl
<< "CORBA::Environment _tao_env;" << be_nl
<< "_tao_any.replace (" << node->tc_name () << ", "
- << "_tao_elem, 0, _tao_env);" << be_uidt_nl
+ << "_tao_elem, 1, _tao_env); // consume it" << be_uidt_nl
<< "}" << be_nl;
*os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, "
diff --git a/TAO/TAO_IDL/be/be_visitor_typedef.cpp b/TAO/TAO_IDL/be/be_visitor_typedef.cpp
index ef0b9ce4478..2c3921daa59 100644
--- a/TAO/TAO_IDL/be/be_visitor_typedef.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_typedef.cpp
@@ -591,14 +591,14 @@ be_visitor_typedef_ch::visit_array (be_array *node)
be_decl *scope = this->ctx_->scope (); // scope in which it is used
be_type *bt;
- if (this->ctx_->alias ()) // typedef of a typedef
+ // is the base type an alias to an array node or an actual array node
+ if (this->ctx_->alias ())
bt = this->ctx_->alias ();
else
bt = node;
- if (!bt->imported () &&
- bt->node_type () == AST_Decl::NT_array) // direct typedef of a base node
- // type
+ // is our base type an array node. If so, generate code for that array node
+ if (bt->node_type () == AST_Decl::NT_array)
{
// let the base class visitor handle this case
if (this->be_visitor_typedef::visit_array (node) == -1)
@@ -610,30 +610,36 @@ be_visitor_typedef_ch::visit_array (be_array *node)
), -1);
}
}
+ else
+ {
+ // base type is simply an alias to an array node. Simply output the
+ // required typedefs
- // now generate the typedefs
- os->indent ();
- // typedef the type and the _slice type
- *os << "typedef " << bt->nested_type_name (scope)
- << " " << tdef->nested_type_name (scope) << ";" << be_nl;
- *os << "typedef " << bt->nested_type_name (scope, "_slice")
- << " " << tdef->nested_type_name (scope, "_slice") << ";" << be_nl;
- // typedef the _var, _out, and _forany types
- *os << "typedef " << bt->nested_type_name (scope, "_var")
- << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl;
- *os << "typedef " << bt->nested_type_name (scope, "_out")
- << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl;
- *os << "typedef " << bt->nested_type_name (scope, "_forany")
- << " " << tdef->nested_type_name (scope, "_forany") << ";" << be_nl;
- // the _alloc, _dup, and free methods
- *os << tdef->nested_type_name (scope, "_slice") << " *"
- << tdef->nested_type_name (scope, "_alloc") << " (void);" << be_nl;
- *os << tdef->nested_type_name (scope, "_slice") << " *"
- << tdef->nested_type_name (scope, "_dup") << " ("
- << tdef->nested_type_name (scope, "_slice") << " *slice);" << be_nl;
- *os << tdef->nested_type_name (scope, "_slice") << " *"
- << tdef->nested_type_name (scope, "_free") << " ("
- << tdef->nested_type_name (scope, "_slice") << " *slice);" << be_nl;
+ os->indent ();
+ // typedef the type and the _slice type
+ *os << "typedef " << bt->nested_type_name (scope)
+ << " " << tdef->nested_type_name (scope) << ";" << be_nl;
+ *os << "typedef " << bt->nested_type_name (scope, "_slice")
+ << " " << tdef->nested_type_name (scope, "_slice") << ";" << be_nl;
+ // typedef the _var, _out, and _forany types
+ *os << "typedef " << bt->nested_type_name (scope, "_var")
+ << " " << tdef->nested_type_name (scope, "_var") << ";" << be_nl;
+ *os << "typedef " << bt->nested_type_name (scope, "_out")
+ << " " << tdef->nested_type_name (scope, "_out") << ";" << be_nl;
+ *os << "typedef " << bt->nested_type_name (scope, "_forany")
+ << " " << tdef->nested_type_name (scope, "_forany") << ";" << be_nl;
+ // the _alloc, _dup, copy, and free methods
+ *os << "static " << tdef->nested_type_name (scope, "_slice") << " *"
+ << tdef->nested_type_name (scope, "_alloc") << " (void);" << be_nl;
+ *os << "static " << tdef->nested_type_name (scope, "_slice") << " *"
+ << tdef->nested_type_name (scope, "_dup") << " (const "
+ << tdef->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl;
+ *os << "static void " << tdef->nested_type_name (scope, "_copy") << " ("
+ << tdef->nested_type_name (scope, "_slice") << " *_tao_to, const "
+ << tdef->nested_type_name (scope, "_slice") << " *_tao_from);" << be_nl;
+ *os << "static void " << tdef->nested_type_name (scope, "_free") << " ("
+ << tdef->nested_type_name (scope, "_slice") << " *_tao_slice);" << be_nl;
+ }
return 0;
}
@@ -1012,6 +1018,46 @@ be_visitor_typedef_ci::visit_array (be_array *node)
), -1);
}
}
+ else
+ {
+ // generate the inline code for alloc, dup, copy, and free methods
+
+ // alloc method
+ os->indent ();
+ *os << "ACE_INLINE " << tdef->name () << "_slice *" << be_nl;
+ *os << tdef->name () << "_alloc (void)" << be_nl;
+ *os << "{" << be_idt_nl;
+ *os << "return " << bt->name () << "_alloc ();" << be_uidt_nl;
+ *os << "}\n\n";
+
+ // dup method
+ os->indent ();
+ *os << "ACE_INLINE " << tdef->name () << "_slice *" << be_nl;
+ *os << tdef->name () << "_dup (const " << tdef->name ()
+ << "_slice *_tao_src)" << be_nl;
+ *os << "{" << be_idt_nl;
+ *os << "return " << bt->name () << "_dup (_tao_src);" << be_uidt_nl;
+ *os << "}\n\n";
+
+ // copy method
+ os->indent ();
+ *os << "ACE_INLINE void" << be_nl;
+ *os << tdef->name () << "_copy (" << tdef->name ()
+ << "_slice *_tao_dest, const " << tdef->name ()
+ << "_slice *_tao_src)" << be_nl;
+ *os << "{" << be_idt_nl;
+ *os << bt->name () << "_copy (_tao_dest, _tao_src);" << be_uidt_nl;
+ *os << "}\n\n";
+
+ // free method
+ os->indent ();
+ *os << "ACE_INLINE void" << be_nl;
+ *os << tdef->name () << "_free (" << tdef->name ()
+ << "_slice *_tao_src)" << be_nl;
+ *os << "{" << be_idt_nl;
+ *os << bt->name () << "_free (_tao_src);" << be_uidt_nl;
+ *os << "}\n\n";
+ }
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_union.cpp b/TAO/TAO_IDL/be/be_visitor_union.cpp
index 9e7b6e43e08..09ea167c66b 100644
--- a/TAO/TAO_IDL/be/be_visitor_union.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_union.cpp
@@ -948,8 +948,8 @@ be_visitor_union_any_op_cs::visit_union (be_union *node)
<< node->name () << " &_tao_elem) // copying" << be_nl
<< "{" << be_idt_nl
<< "CORBA::Environment _tao_env;" << be_nl
- << "_tao_any.replace (" << node->tc_name () << ", &"
- << "_tao_elem, 1, _tao_env);" << be_uidt_nl
+ << "_tao_any.replace (" << node->tc_name () << ", new "
+ << node->name () << "(_tao_elem), 1, _tao_env);" << be_uidt_nl
<< "}" << be_nl;
*os << "void operator<<= (CORBA::Any &_tao_any, "
@@ -957,7 +957,7 @@ be_visitor_union_any_op_cs::visit_union (be_union *node)
<< "{" << be_idt_nl
<< "CORBA::Environment _tao_env;" << be_nl
<< "_tao_any.replace (" << node->tc_name () << ", "
- << "_tao_elem, 0, _tao_env);" << be_uidt_nl
+ << "_tao_elem, 1, _tao_env); // consume it" << be_uidt_nl
<< "}" << be_nl;
*os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, "