summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-07-22 22:28:28 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2002-07-22 22:28:28 +0000
commit57368ce48d7378aa333b9df705ba89c1df2bf0e4 (patch)
tree95b54052f4394257c7f46607247c5129bf47649b
parentdaeea59f4d5813c0a957968bae431250c186d7f2 (diff)
downloadATCD-57368ce48d7378aa333b9df705ba89c1df2bf0e4.tar.gz
ChangeLogTag: Mon Jul 22 17:20:41 2002 Jeff Parsons <parsons@cs.wustl.edu>
-rw-r--r--TAO/ChangeLog25
-rw-r--r--TAO/TAO_IDL/be/be_structure.cpp279
-rw-r--r--TAO/TAO_IDL/be/be_union.cpp280
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array.cpp3
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp49
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp42
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp54
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp51
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp237
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp42
-rw-r--r--TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp12
-rw-r--r--TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp8
-rw-r--r--TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp6
-rw-r--r--TAO/tests/IDL_Test/enum_in_struct.idl41
-rw-r--r--TAO/tests/IDL_Test/union.idl33
15 files changed, 700 insertions, 462 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 51b928068b3..258f3a468d0 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,28 @@
+Mon Jul 22 17:20:41 2002 Jeff Parsons <parsons@cs.wustl.edu>
+
+ * TAO_IDL/be/be_structure.cpp:
+ * TAO_IDL/be/be_union.cpp:
+ * TAO_IDL/be/be_visitor_array.cpp:
+ * TAO_IDL/be/be_visitor_array/array_ch.cpp:
+ * TAO_IDL/be/be_visitor_array/array_ci.cpp:
+ * TAO_IDL/be/be_visitor_array/array_cs.cpp:
+ * TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp:
+ * TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp:
+ * TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp:
+ * TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp:
+ * TAO_IDL/be/be_visitor_exception/exception_ctor.cpp:
+ * TAO_IDL/be/be_visitor_field/field_ch.cpp:
+
+ Fixes for certain kinds of declarations within structs,
+ exceptions and unions - enum in exception and anonymous array of
+ enum/struct/union inside exception/struct/union. These fixes
+ close out [BUGID:569] and [BUGID:1079].
+
+ * tests/IDL_Test/enum_in_struct.idl:
+ * tests/IDL_Test/union.idl:
+
+ Added examples to the test to cover the above fixes.
+
Mon Jul 22 20:16:04 UTC 2002 Craig Rodrigues <crodrigu@bbn.com>
* orbsvcs/orbsvcs/Makefile.PortableGroup: Add
diff --git a/TAO/TAO_IDL/be/be_structure.cpp b/TAO/TAO_IDL/be/be_structure.cpp
index f4a41acbf30..ec64b202fb6 100644
--- a/TAO/TAO_IDL/be/be_structure.cpp
+++ b/TAO/TAO_IDL/be/be_structure.cpp
@@ -187,13 +187,11 @@ be_structure::gen_var_impl (char *,
ci = tao_cg->client_inline ();
- // Start with whatever was our current indent level.
- ci->indent ();
-
*ci << "// *************************************************************"
<< be_nl;
*ci << "// Inline operations for class " << fname << be_nl;
- *ci << "// *************************************************************\n\n";
+ *ci << "// *************************************************************"
+ << be_nl << be_nl;
// Default constructor.
*ci << "ACE_INLINE" << be_nl;
@@ -207,22 +205,19 @@ be_structure::gen_var_impl (char *,
*ci << fname << "::" << lname << " (" << this->local_name ()
<< " *p)" << be_nl;
*ci << " : ptr_ (p)" << be_nl;
- *ci << "{}\n\n";
+ *ci << "{}" << be_nl << be_nl;
// Copy constructor.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (const ::" << fname
<< " &p) // copy constructor" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "if (p.ptr_)" << be_nl;
*ci << " ACE_NEW (this->ptr_, " << "::" << this->name ()
<< " (*p.ptr_));" << be_nl;
*ci << "else" << be_nl;
- *ci << " this->ptr_ = 0;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << " this->ptr_ = 0;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Fixed-size types only.
if (this->size_type () == AST_Type::FIXED)
@@ -231,55 +226,49 @@ be_structure::gen_var_impl (char *,
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (const "
<< "::" << this->name () << " &p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "ACE_NEW (this->ptr_, " << "::" << this->name ()
- << " (p));\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ << " (p));" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
}
// Destructor.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::~" << lname << " (void) // destructor" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "delete this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "delete this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Assignment operator from a pointer.
- ci->indent ();
*ci << "ACE_INLINE " << fname << " &" << be_nl;
*ci << fname << "::operator= (" << this->local_name ()
- << " *p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ << " *_tao_struct_var)" << be_nl;
+ *ci << "{" << be_idt_nl;
*ci << "delete this->ptr_;" << be_nl;
- *ci << "this->ptr_ = p;" << be_nl;
- *ci << "return *this;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "this->ptr_ = _tao_struct_var;" << be_nl;
+ *ci << "return *this;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Assignment operator from _var.
- ci->indent ();
*ci << "ACE_INLINE ::" << fname << " &" << be_nl
<< fname << "::operator= (const ::" << fname
- << " &p)" << be_nl
+ << " &_tao_struct_var)" << be_nl
<< "{" << be_idt_nl
- << "if (this != &p)" << be_idt_nl
+ << "if (this != &_tao_struct_var)" << be_idt_nl
<< "{" << be_idt_nl
- << "if (p.ptr_ == 0)" << be_idt_nl
+ << "if (_tao_struct_var.ptr_ == 0)" << be_idt_nl
<< "{" << be_idt_nl
<< "delete this->ptr_;" << be_nl
<< "this->ptr_ = 0;" << be_uidt_nl
<< "}" << be_uidt_nl
<< "else" << be_idt_nl
<< "{" << be_idt_nl
- << this->local_name () << " *deep_copy =" << be_idt_nl
- << "new " << this->local_name () << " (*p.ptr_);"
- << be_uidt_nl << be_nl
+ << this->local_name () << " *deep_copy = 0;" << be_nl
+ << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
+ << "deep_copy," << be_nl
+ << this->local_name () << " (*_tao_struct_var.ptr_)," << be_nl
+ << "*this" << be_uidt_nl
+ << ");" << be_uidt_nl << be_nl
<< "if (deep_copy != 0)" << be_idt_nl
<< "{" << be_idt_nl
<< this->local_name () << " *tmp = deep_copy;" << be_nl
@@ -290,173 +279,132 @@ be_structure::gen_var_impl (char *,
<< "}" << be_uidt << be_uidt_nl
<< "}" << be_uidt_nl << be_nl
<< "return *this;" << be_uidt_nl
- << "}\n\n";
+ << "}" << be_nl << be_nl;
// Fixed-size types only.
if (this->size_type () == AST_Type::FIXED)
{
- ci->indent ();
*ci << "// fixed-size types only" << be_nl;
*ci << "ACE_INLINE " << fname << " &" << be_nl;
*ci << fname << "::operator= (const " << "::" << this->name ()
<< " &p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "if (this->ptr_ != &p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "delete this->ptr_;" << be_nl;
- *ci << "ACE_NEW_RETURN (this->ptr_, ::"
- << this->name () << " (p), *this);\n";
- ci->decr_indent ();
- *ci << "}" << be_nl;
- *ci << "return *this;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
+ << "this->ptr_," << be_nl
+ << "::" << this->name () << " (p)," << be_nl
+ << "*this" << be_uidt_nl
+ << ");" << be_uidt << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
+ *ci << "return *this;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
}
// Two arrow operators.
- ci->indent ();
*ci << "ACE_INLINE const " << "::" << this->name () << " *" << be_nl;
*ci << fname << "::operator-> (void) const" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE " << "::" << this->name () << " *" << be_nl;
*ci << fname << "::operator-> (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Other extra methods - 3 cast operator ().
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::operator const " << "::" << this->name ()
<< " &() const // cast" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::operator " << "::" << this->name ()
<< " &() // cast " << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::operator " << "::" << this->name ()
<< " &() const // cast " << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Variable-size types only.
if (this->size_type () == AST_Type::VARIABLE)
{
- ci->indent ();
*ci << "// variable-size types only" << be_nl;
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::operator " << "::" << this->name ()
<< " *&() // cast " << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
}
// in, inout, out, and _retn
- ci->indent ();
*ci << "ACE_INLINE const " << "::" << this->name () << " &" << be_nl;
*ci << fname << "::in (void) const" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE " << "::" << this->name () << " &" << be_nl;
*ci << fname << "::inout (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// The out is handled differently based on our size type.
- ci->indent ();
if (this->size_type () == AST_Type::VARIABLE)
{
*ci << "// mapping for variable size " << be_nl;
*ci << "ACE_INLINE " << "::" << this->name () << " *&" << be_nl;
*ci << fname << "::out (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "delete this->ptr_;" << be_nl;
*ci << "this->ptr_ = 0;" << be_nl;
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE " << "::" << this->name () << " *" << be_nl;
*ci << fname << "::_retn (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "::" << this->name () << " *tmp = this->ptr_;" << be_nl;
*ci << "this->ptr_ = 0;" << be_nl;
- *ci << "return tmp;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
-
+ *ci << "return tmp;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
}
else
{
*ci << "// mapping for fixed size " << be_nl;
*ci << "ACE_INLINE " << "::" << this->name () << " &" << be_nl;
*ci << fname << "::out (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE " << "::" << this->name () << be_nl;
*ci << fname << "::_retn (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
}
// The additional ptr () member function.
- ci->indent ();
*ci << "ACE_INLINE " << "::" << this->name () << " *" << be_nl;
*ci << fname << "::ptr (void) const" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
return 0;
}
@@ -556,13 +504,11 @@ be_structure::gen_out_impl (char *,
// Generate the var implementation in the inline file.
- // Start with whatever was our current indent level.
- ci->indent ();
-
*ci << "// *************************************************************"
<< be_nl;
*ci << "// Inline operations for class " << fname << be_nl;
- *ci << "// *************************************************************\n\n";
+ *ci << "// *************************************************************"
+ << be_nl << be_nl;
// Constructor from a pointer.
ci->indent ();
@@ -570,88 +516,67 @@ be_structure::gen_out_impl (char *,
*ci << fname << "::" << lname << " (" << "::"
<< this->name () << " *&p)" << be_nl;
*ci << " : ptr_ (p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "this->ptr_ = 0;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "this->ptr_ = 0;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Constructor from _var &.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (" << this->local_name ()
<< "_var &p) // constructor from _var" << be_nl;
*ci << " : ptr_ (p.out ())" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "delete this->ptr_;" << be_nl;
- *ci << "this->ptr_ = 0;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "this->ptr_ = 0;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Copy constructor.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (const ::" << fname
<< " &p) // copy constructor" << be_nl;
*ci << " : ptr_ (ACE_const_cast (" << lname << "&, p).ptr_)" << be_nl;
- *ci << "{}\n\n";
+ *ci << "{}" << be_nl << be_nl;
// assignment operator from _out &.
- ci->indent ();
*ci << "ACE_INLINE " << fname << " &" << be_nl;
*ci << fname << "::operator= (const ::" << fname <<
" &p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "this->ptr_ = ACE_const_cast (" << lname << "&, p).ptr_;" << be_nl;
- *ci << "return *this;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "return *this;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Assignment from _var is not allowed by a private declaration.
// Assignment operator from pointer.
- ci->indent ();
*ci << "ACE_INLINE " << fname << " &" << be_nl;
- *ci << fname << "::operator= (" << this->local_name () << " *p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "this->ptr_ = p;" << be_nl;
- *ci << "return *this;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << fname << "::operator= (" << this->local_name () << " *_tao_struct_out)" << be_nl;
+ *ci << "{" << be_idt_nl;
+ *ci << "this->ptr_ = _tao_struct_out;" << be_nl;
+ *ci << "return *this;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Other extra methods - cast operator ().
- ci->indent ();
*ci << "ACE_INLINE " << be_nl;
*ci << fname << "::operator " << "::" << this->name ()
<< " *&() // cast" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// ptr function
- ci->indent ();
*ci << "ACE_INLINE " << "::" << this->name () << " *&" << be_nl;
*ci << fname << "::ptr (void) // ptr" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// operator ->
- ci->indent ();
*ci << "ACE_INLINE " << "::" << this->name () << " *" << be_nl;
*ci << fname << "::operator-> (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp
index 4477c463d60..49c723372f9 100644
--- a/TAO/TAO_IDL/be/be_union.cpp
+++ b/TAO/TAO_IDL/be/be_union.cpp
@@ -203,43 +203,37 @@ be_union::gen_var_impl (char *,
ci = tao_cg->client_inline ();
- // Start with whatever was our current indent level.
- ci->indent ();
-
*ci << "// *************************************************************"
<< be_nl;
*ci << "// Inline operations for class " << fname << be_nl;
- *ci << "// *************************************************************\n\n";
+ *ci << "// *************************************************************"
+ << be_nl << be_nl;
// Default constructor.
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname <<
" (void) // default constructor" << be_nl;
*ci << " " << ": ptr_ (0)" << be_nl;
- *ci << "{}\n\n";
+ *ci << "{}" << be_nl << be_nl;
// Constructor from a pointer.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (" << this->local_name ()
<< " *p)" << be_nl;
*ci << " : ptr_ (p)" << be_nl;
- *ci << "{}\n\n";
+ *ci << "{}" << be_nl << be_nl;
// Copy constructor.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (const ::" << fname
<< " &p) // copy constructor" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "if (p.ptr_)" << be_nl;
*ci << " ACE_NEW (this->ptr_, ::" << this->name ()
<< " (*p.ptr_));" << be_nl;
*ci << "else" << be_nl;
- *ci << " this->ptr_ = 0;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << " this->ptr_ = 0;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Fixed-size types only.
if (this->size_type () == AST_Type::FIXED)
@@ -248,55 +242,49 @@ be_union::gen_var_impl (char *,
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (const ::"
<< this->name () << " &p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "ACE_NEW (this->ptr_, ::" << this->name ()
- << " (p));\n";
- ci->decr_indent ();
+ << " (p));" << be_uidt_nl;
*ci << "}\n\n";
}
// Destructor.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::~" << lname << " (void) // destructor" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "delete this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "delete this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Assignment operator from a pointer.
- ci->indent ();
*ci << "ACE_INLINE ::" << fname << " &" << be_nl;
*ci << fname << "::operator= (" << this->local_name ()
- << " *p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ << " *_tao_union_var)" << be_nl;
+ *ci << "{" << be_idt_nl;
*ci << "delete this->ptr_;" << be_nl;
- *ci << "this->ptr_ = p;" << be_nl;
- *ci << "return *this;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "this->ptr_ = _tao_union_var;" << be_nl;
+ *ci << "return *this;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Assignment operator from _var.
- ci->indent ();
*ci << "ACE_INLINE ::" << fname << " &" << be_nl
<< fname << "::operator= (const ::" << fname
- << " &p)" << be_nl
+ << " &_tao_union_var)" << be_nl
<< "{" << be_idt_nl
- << "if (this != &p)" << be_idt_nl
+ << "if (this != &_tao_union_var)" << be_idt_nl
<< "{" << be_idt_nl
- << "if (p.ptr_ == 0)" << be_idt_nl
+ << "if (_tao_union_var.ptr_ == 0)" << be_idt_nl
<< "{" << be_idt_nl
<< "delete this->ptr_;" << be_nl
<< "this->ptr_ = 0;" << be_uidt_nl
<< "}" << be_uidt_nl
<< "else" << be_idt_nl
<< "{" << be_idt_nl
- << this->local_name () << " *deep_copy =" << be_idt_nl
- << "new " << this->local_name () << " (*p.ptr_);"
- << be_uidt_nl << be_nl
+ << this->local_name () << " *deep_copy = 0;" << be_nl
+ << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
+ << "deep_copy," << be_nl
+ << this->local_name () << " (*_tao_union_var.ptr_)," << be_nl
+ << "*this" << be_uidt_nl
+ << ");" << be_uidt_nl << be_nl
<< "if (deep_copy != 0)" << be_idt_nl
<< "{" << be_idt_nl
<< this->local_name () << " *tmp = deep_copy;" << be_nl
@@ -307,140 +295,109 @@ be_union::gen_var_impl (char *,
<< "}" << be_uidt << be_uidt_nl
<< "}" << be_uidt_nl << be_nl
<< "return *this;" << be_uidt_nl
- << "}\n\n";
+ << "}" << be_nl << be_nl;
// Fixed-size types only.
if (this->size_type () == AST_Type::FIXED)
{
- ci->indent ();
*ci << "// fixed-size types only" << be_nl;
*ci << "ACE_INLINE ::" << fname << " &" << be_nl;
*ci << fname << "::operator= (const ::" << this->name ()
- << " &p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "if (this->ptr_ != &p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ << " &_tao_union_var)" << be_nl;
+ *ci << "{" << be_idt_nl;
+ *ci << "if (this->ptr_ != &_tao_union_var)" << be_nl;
+ *ci << "{" << be_idt_nl;
*ci << "delete this->ptr_;" << be_nl;
- *ci << "ACE_NEW_RETURN (this->ptr_, ::"
- << this->name () << " (p), *this);\n";
- ci->decr_indent ();
+ *ci << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
+ << "this->ptr_," << be_nl
+ << "::" << this->name () << " (_tao_union_var)," << be_nl
+ << "*this" << be_uidt_nl
+ << ");" << be_uidt << be_uidt_nl;
*ci << "}" << be_nl;
- *ci << "return *this;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "return *this;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
}
// Two arrow operators.
- ci->indent ();
*ci << "ACE_INLINE const ::" << this->name () << " *" << be_nl;
*ci << fname << "::operator-> (void) const" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE ::" << this->name () << " *" << be_nl;
*ci << fname << "::operator-> (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Other extra methods - 3 cast operator ().
- ci->indent ();
*ci << "ACE_INLINE " << be_nl;
*ci << fname << "::operator const ::" << this->name ()
<< " &() const // cast" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE " << be_nl;
*ci << fname << "::operator ::" << this->name ()
<< " &() // cast " << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE " << be_nl;
*ci << fname << "::operator ::" << this->name ()
<< " &() const// cast " << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Variable-size types only.
if (this->size_type () == AST_Type::VARIABLE)
{
- ci->indent ();
*ci << "// variable-size types only" << be_nl;
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::operator ::" << this->name ()
<< " *&() // cast " << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
}
// in, inout, out, _retn, and ptr.
- ci->indent ();
*ci << "ACE_INLINE const ::" << this->name () << " &" << be_nl;
*ci << fname << "::in (void) const" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE ::" << this->name () << " &" << be_nl;
*ci << fname << "::inout (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// The out and _retn are handled differently based on our size type.
- ci->indent ();
if (this->size_type () == AST_Type::VARIABLE)
{
*ci << "// mapping for variable size " << be_nl;
*ci << "ACE_INLINE ::" << this->name () << " *&" << be_nl;
*ci << fname << "::out (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "delete this->ptr_;" << be_nl;
*ci << "this->ptr_ = 0;" << be_nl;
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
+ *ci << "return this->ptr_;" << be_uidt_nl;
*ci << "}\n\n";
ci->indent ();
*ci << "ACE_INLINE ::" << this->name () << " *" << be_nl;
*ci << fname << "::_retn (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "::" << this->name () << " *tmp = this->ptr_;" << be_nl;
*ci << "this->ptr_ = 0;" << be_nl;
- *ci << "return tmp;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "return tmp;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
}
else
@@ -448,31 +405,23 @@ be_union::gen_var_impl (char *,
*ci << "// mapping for fixed size " << be_nl;
*ci << "ACE_INLINE ::" << this->name () << " &" << be_nl;
*ci << fname << "::out (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
- ci->indent ();
*ci << "ACE_INLINE ::" << this->name () << be_nl;
*ci << fname << "::_retn (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return *this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return *this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
}
// The additional ptr () member function.
- ci->indent ();
*ci << "ACE_INLINE ::" << this->name () << " *" << be_nl;
*ci << fname << "::ptr (void) const" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
return 0;
}
@@ -576,102 +525,79 @@ be_union::gen_out_impl (char *,
// Generate the var implementation in the inline file.
- // Start with whatever was our current indent level.
- ci->indent ();
-
*ci << "// *************************************************************"
<< be_nl;
*ci << "// Inline operations for class " << fname << be_nl;
- *ci << "// *************************************************************\n\n";
+ *ci << "// *************************************************************"
+ << be_nl << be_nl;
// Constructor from a pointer.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (" << this->local_name ()
<< " *&p)" << be_nl;
*ci << " : ptr_ (p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "this->ptr_ = 0;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "this->ptr_ = 0;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Constructor from _var &.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (" << this->local_name ()
<< "_var &p) // constructor from _var" << be_nl;
*ci << " : ptr_ (p.out ())" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "delete this->ptr_;" << be_nl;
- *ci << "this->ptr_ = 0;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "this->ptr_ = 0;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Copy constructor.
- ci->indent ();
*ci << "ACE_INLINE" << be_nl;
*ci << fname << "::" << lname << " (const ::" << fname
<< " &p) // copy constructor" << be_nl;
*ci << " : ptr_ (ACE_const_cast (" << lname << "&, p).ptr_)" << be_nl;
- *ci << "{}\n\n";
+ *ci << "{}" << be_nl << be_nl;
// Assignment operator from _out &.
- ci->indent ();
*ci << "ACE_INLINE ::" << fname << " &" << be_nl;
*ci << fname << "::operator= (const ::" << fname
<< " &p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
+ *ci << "{" << be_idt_nl;
*ci << "this->ptr_ = ACE_const_cast (" << lname << "&, p).ptr_;" << be_nl;
- *ci << "return *this;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "return *this;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Assignment from _var is not allowed by a private declaration.
// Assignment operator from pointer.
- ci->indent ();
*ci << "ACE_INLINE ::" << fname << " &" << be_nl;
- *ci << fname << "::operator= (" << this->local_name () << " *p)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "this->ptr_ = p;" << be_nl;
- *ci << "return *this;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << fname << "::operator= (" << this->local_name ()
+ << " *_tao_union_out)" << be_nl;
+ *ci << "{" << be_idt_nl;
+ *ci << "this->ptr_ = _tao_union_out;" << be_nl;
+ *ci << "return *this;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// Other extra methods - cast operator ().
- ci->indent ();
*ci << "ACE_INLINE " << be_nl;
*ci << fname << "::operator ::" << this->name ()
<< " *&() // cast" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// ptr function.
- ci->indent ();
*ci << "ACE_INLINE ::" << this->name () << " *&" << be_nl;
*ci << fname << "::ptr (void) // ptr" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
// operator ->
- ci->indent ();
*ci << "ACE_INLINE ::" << this->name () << " *" << be_nl;
*ci << fname << "::operator-> (void)" << be_nl;
- *ci << "{\n";
- ci->incr_indent ();
- *ci << "return this->ptr_;\n";
- ci->decr_indent ();
- *ci << "}\n\n";
+ *ci << "{" << be_idt_nl;
+ *ci << "return this->ptr_;" << be_uidt_nl;
+ *ci << "}" << be_nl << be_nl;
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_array.cpp b/TAO/TAO_IDL/be/be_visitor_array.cpp
index 5b425c96a6e..fab845d54b1 100644
--- a/TAO/TAO_IDL/be/be_visitor_array.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array.cpp
@@ -37,6 +37,9 @@
#include "be_visitor_array.h"
#include "be_visitor_context.h"
+#include "be_visitor_enum.h"
+#include "be_visitor_structure.h"
+#include "be_visitor_union.h"
#include "be_visitor_array/array.cpp"
#include "be_visitor_array/array_ch.cpp"
diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp
index 1825b00443e..d3b499e53b2 100644
--- a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp
@@ -50,6 +50,7 @@ int be_visitor_array_ch::visit_array (be_array *node)
// Retrieve the type.
be_type *bt = be_type::narrow_from_decl (node->base_type ());
+ AST_Decl::NodeType nt = bt->node_type ();
if (!bt)
{
@@ -69,7 +70,7 @@ int be_visitor_array_ch::visit_array (be_array *node)
// If we contain an anonymous sequence,
// generate code for the sequence here.
- if (bt->node_type () == AST_Decl::NT_sequence)
+ if (nt == AST_Decl::NT_sequence)
{
if (this->gen_anonymous_base_type (bt,
TAO_CodeGen::TAO_SEQUENCE_CH)
@@ -83,6 +84,52 @@ int be_visitor_array_ch::visit_array (be_array *node)
}
}
+ // If the array is an anonymous member and if its element type
+ // is a declaration (not a reference), we must generate code for
+ // the declaration.
+ if (this->ctx_->alias () == 0 // Not a typedef.
+ && bt->is_child (this->ctx_->scope ()))
+ {
+ int status = 0;
+ be_visitor_context ctx (*this->ctx_);
+
+ switch (nt)
+ {
+ case AST_Decl::NT_enum:
+ {
+ ctx.state (TAO_CodeGen::TAO_ENUM_CH);
+ be_visitor_enum_ch ec_visitor (&ctx);
+ status = bt->accept (&ec_visitor);
+ break;
+ }
+ case AST_Decl::NT_struct:
+ {
+ ctx.state (TAO_CodeGen::TAO_STRUCT_CH);
+ be_visitor_structure_ch sc_visitor (&ctx);
+ status = bt->accept (&sc_visitor);
+ break;
+ }
+ case AST_Decl::NT_union:
+ {
+ ctx.state (TAO_CodeGen::TAO_UNION_CH);
+ be_visitor_union_ch uc_visitor (&ctx);
+ status = bt->accept (&uc_visitor);
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_ch::"
+ "visit_array - "
+ "array base type codegen failed\n"),
+ -1);
+ }
+ }
+
*os << "typedef ";
if (bt->accept (this) == -1)
diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp
index d5dc7a1647c..3fb26adb236 100644
--- a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp
@@ -48,6 +48,7 @@ int be_visitor_array_ci::visit_array (be_array *node)
// If we contain an anonymous sequence, generate code for it here.
be_type *bt = be_type::narrow_from_decl (node->base_type ());
+ AST_Decl::NodeType nt = bt->node_type ();
if (!bt)
{
@@ -58,7 +59,7 @@ int be_visitor_array_ci::visit_array (be_array *node)
-1);
}
- if (bt->node_type () == AST_Decl::NT_sequence)
+ if (nt == AST_Decl::NT_sequence)
{
if (this->gen_anonymous_base_type (bt,
TAO_CodeGen::TAO_SEQUENCE_CI)
@@ -72,6 +73,45 @@ int be_visitor_array_ci::visit_array (be_array *node)
}
}
+ // If the array is an anonymous member and if its element type
+ // is a declaration (not a reference), we must generate code for
+ // the declaration.
+ if (this->ctx_->alias () == 0 // Not a typedef.
+ && bt->is_child (this->ctx_->scope ()))
+ {
+ int status = 0;
+ be_visitor_context ctx (*this->ctx_);
+
+ switch (nt)
+ {
+ case AST_Decl::NT_struct:
+ {
+ ctx.state (TAO_CodeGen::TAO_STRUCT_CI);
+ be_visitor_structure_ci sc_visitor (&ctx);
+ status = bt->accept (&sc_visitor);
+ break;
+ }
+ case AST_Decl::NT_union:
+ {
+ ctx.state (TAO_CodeGen::TAO_UNION_CI);
+ be_visitor_union_ci uc_visitor (&ctx);
+ status = bt->accept (&uc_visitor);
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_ch::"
+ "visit_array - "
+ "array base type codegen failed\n"),
+ -1);
+ }
+ }
+
// No _var or _out class for an anonymous (non-typedef'd) array.
if (this->ctx_->tdef () != 0)
{
diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp
index 8040f161617..eccd4840dc7 100644
--- a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp
@@ -305,11 +305,13 @@ int be_visitor_array_cs::visit_array (be_array *node)
*os << be_uidt_nl << "}" << be_uidt;
}
- *os << be_uidt_nl << "}\n\n";
+ *os << be_uidt_nl << "}" << be_nl << be_nl;
+
+ AST_Decl::NodeType nt = bt->node_type ();
// If we contain an anonymous sequence,
- // generate code for the seuqence here.
- if (bt->node_type () == AST_Decl::NT_sequence)
+ // generate code for the sequence here.
+ if (nt == AST_Decl::NT_sequence)
{
if (this->gen_anonymous_base_type (bt,
TAO_CodeGen::TAO_SEQUENCE_CS)
@@ -323,6 +325,52 @@ int be_visitor_array_cs::visit_array (be_array *node)
}
}
+ // If the array is an anonymous member and if its element type
+ // is a declaration (not a reference), we must generate code for
+ // the declaration.
+ if (this->ctx_->alias () == 0 // Not a typedef.
+ && bt->is_child (this->ctx_->scope ()))
+ {
+ int status = 0;
+ be_visitor_context ctx (*this->ctx_);
+
+ switch (nt)
+ {
+ case AST_Decl::NT_enum:
+ {
+ ctx.state (TAO_CodeGen::TAO_ENUM_CS);
+ be_visitor_enum_cs ec_visitor (&ctx);
+ status = bt->accept (&ec_visitor);
+ break;
+ }
+ case AST_Decl::NT_struct:
+ {
+ ctx.state (TAO_CodeGen::TAO_STRUCT_CS);
+ be_visitor_structure_cs sc_visitor (&ctx);
+ status = bt->accept (&sc_visitor);
+ break;
+ }
+ case AST_Decl::NT_union:
+ {
+ ctx.state (TAO_CodeGen::TAO_UNION_CS);
+ be_visitor_union_cs uc_visitor (&ctx);
+ status = bt->accept (&uc_visitor);
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_ch::"
+ "visit_array - "
+ "array base type codegen failed\n"),
+ -1);
+ }
+ }
+
node->cli_stub_gen (1);
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp
index 551ff95a687..a613a1dbaf3 100644
--- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp
@@ -50,17 +50,16 @@ be_visitor_array_cdr_op_ch::visit_array (be_array *node)
TAO_OutStream *os = this->ctx_->stream ();
- AST_Type *bt = node->base_type ();
+ be_type *bt = be_type::narrow_from_decl (node->base_type ());
AST_Decl::NodeType nt = bt->node_type ();
// If the node is an array of anonymous sequence, we need to
// generate the sequence's cdr operator declaration here.
if (nt == AST_Decl::NT_sequence && bt->anonymous ())
{
- be_sequence *bs = be_sequence::narrow_from_decl (bt);
be_visitor_sequence_cdr_op_ch visitor (this->ctx_);
- if (bs->accept (&visitor) == -1)
+ if (bt->accept (&visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_array_cdr_op_ch::"
@@ -70,6 +69,52 @@ be_visitor_array_cdr_op_ch::visit_array (be_array *node)
}
}
+ // If the array is an anonymous member and if its element type
+ // is a declaration (not a reference), we must generate code for
+ // the declaration.
+ if (this->ctx_->alias () == 0 // Not a typedef.
+ && bt->is_child (this->ctx_->scope ()))
+ {
+ int status = 0;
+ be_visitor_context ctx (*this->ctx_);
+
+ switch (nt)
+ {
+ case AST_Decl::NT_enum:
+ {
+ ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH);
+ be_visitor_enum_cdr_op_ch ec_visitor (&ctx);
+ status = bt->accept (&ec_visitor);
+ break;
+ }
+ case AST_Decl::NT_struct:
+ {
+ ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH);
+ be_visitor_structure_cdr_op_ch sc_visitor (&ctx);
+ status = bt->accept (&sc_visitor);
+ break;
+ }
+ case AST_Decl::NT_union:
+ {
+ ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH);
+ be_visitor_union_cdr_op_ch uc_visitor (&ctx);
+ status = bt->accept (&uc_visitor);
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_ch::"
+ "visit_array - "
+ "array base type codegen failed\n"),
+ -1);
+ }
+ }
+
// Generate the CDR << and >> operator declarations.
*os << be_global->stub_export_macro () << " CORBA::Boolean"
<< " operator<< (TAO_OutputCDR &, const ";
diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp
index 1d781d2d4b5..dfcbc34cb6d 100644
--- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp
@@ -55,132 +55,175 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node)
// array, i.e., this is a case of array of array.
return this->visit_node (node);
}
- else
+
+ if (node->cli_inline_cdr_op_gen () || node->imported ())
{
- if (node->cli_inline_cdr_op_gen () || node->imported ())
- {
- return 0;
- }
+ return 0;
+ }
+
+ be_type *bt = be_type::narrow_from_decl (node->base_type ());
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ if (!bt)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_cdr_op_ci::"
+ "visit_array - "
+ "Bad base type\n"),
+ -1);
+ }
+
+ // If we contain an anonymous sequence,
+ // generate code for the sequence here.
+
+ AST_Decl::NodeType nt = bt->node_type ();
- be_type *bt = be_type::narrow_from_decl (node->base_type ());
- TAO_OutStream *os = this->ctx_->stream ();
+ // If the node is an array of anonymous sequence, we need to
+ // generate the sequence's cdr operator declaration here.
+ if (nt == AST_Decl::NT_sequence && bt->anonymous ())
+ {
+ be_visitor_sequence_cdr_op_ci visitor (this->ctx_);
- if (!bt)
+ if (bt->accept (&visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_visitor_array_cdr_op_ci::"
+ "be_visitor_array_cdr_op_ci::"
"visit_array - "
- "Bad base type\n"),
+ "accept on anonymous base type failed\n"),
-1);
}
+ }
- // If we contain an anonymous sequence,
- // generate code for the sequence here.
-
- AST_Decl::NodeType nt = bt->node_type ();
-
- // If the node is an array of anonymous sequence, we need to
- // generate the sequence's cdr operator declaration here.
- if (nt == AST_Decl::NT_sequence && bt->anonymous ())
+ // If the array is an anonymous member and if its element type
+ // is a declaration (not a reference), we must generate code for
+ // the declaration.
+ if (this->ctx_->alias () == 0 // Not a typedef.
+ && bt->is_child (this->ctx_->scope ()))
+ {
+ int status = 0;
+ be_visitor_context ctx (*this->ctx_);
+
+ switch (nt)
+ {
+ case AST_Decl::NT_enum:
+ {
+ ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI);
+ be_visitor_enum_cdr_op_ci ec_visitor (&ctx);
+ status = bt->accept (&ec_visitor);
+ break;
+ }
+ case AST_Decl::NT_struct:
+ {
+ ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI);
+ be_visitor_structure_cdr_op_ci sc_visitor (&ctx);
+ status = bt->accept (&sc_visitor);
+ break;
+ }
+ case AST_Decl::NT_union:
+ {
+ ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI);
+ be_visitor_union_cdr_op_ci uc_visitor (&ctx);
+ status = bt->accept (&uc_visitor);
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (status == -1)
{
- be_visitor_sequence_cdr_op_ci visitor (this->ctx_);
-
- if (bt->accept (&visitor) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_array_cdr_op_ci::"
- "visit_array - "
- "accept on anonymous base type failed\n"),
- -1);
- }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_ch::"
+ "visit_array - "
+ "array base type codegen failed\n"),
+ -1);
}
+ }
- // For anonymous arrays, the type name has a _ prepended. We compute the
- // full_name with or without the underscore and use it later on.
- char fname [NAMEBUFSIZE]; // to hold the full and
+ // For anonymous arrays, the type name has a _ prepended. We compute the
+ // full_name with or without the underscore and use it later on.
+ char fname [NAMEBUFSIZE]; // to hold the full and
- // Save the node's local name and full name in a buffer for quick use later
- // on.
- ACE_OS::memset (fname,
- '\0',
- NAMEBUFSIZE);
+ // Save the node's local name and full name in a buffer for quick use later
+ // on.
+ ACE_OS::memset (fname,
+ '\0',
+ NAMEBUFSIZE);
- if (this->ctx_->tdef ())
+ if (this->ctx_->tdef ())
+ {
+ ACE_OS::sprintf (fname, "%s", node->full_name ());
+ }
+ else
+ {
+ // For anonymous arrays ...
+ // We have to generate a name for us that has an underscope prepended
+ // to our local name. This needs to be inserted after the parents's
+ // name.
+
+ if (node->is_nested ())
{
- ACE_OS::sprintf (fname, "%s", node->full_name ());
+ be_decl *parent =
+ be_scope::narrow_from_scope (node->defined_in ())->decl ();
+ ACE_OS::sprintf (fname,
+ "%s::_%s",
+ parent->full_name (),
+ node->local_name ()->get_string ());
}
else
{
- // For anonymous arrays ...
- // We have to generate a name for us that has an underscope prepended
- // to our local name. This needs to be inserted after the parents's
- // name.
-
- if (node->is_nested ())
- {
- be_decl *parent =
- be_scope::narrow_from_scope (node->defined_in ())->decl ();
- ACE_OS::sprintf (fname,
- "%s::_%s",
- parent->full_name (),
- node->local_name ()->get_string ());
- }
- else
- {
- ACE_OS::sprintf (fname,
- "_%s",
- node->full_name ());
- }
+ ACE_OS::sprintf (fname,
+ "_%s",
+ node->full_name ());
}
+ }
- // Generate the CDR << and >> operator defns.
-
- // Save the array node for further use.
- this->ctx_->node (node);
+ // Generate the CDR << and >> operator defns.
- // Set the sub state as generating code for the output operator.
- this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT);
- *os << "ACE_INLINE CORBA::Boolean operator<< (" << be_idt << be_idt_nl
- << "TAO_OutputCDR &strm," << be_nl
- << "const " << fname << "_forany &_tao_array" << be_uidt_nl
- << ")" << be_uidt_nl
- << "{" << be_idt_nl;
+ // Save the array node for further use.
+ this->ctx_->node (node);
- if (bt->accept (this) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_array_cdr_op_ci::"
- "visit_array - "
- "Base type codegen failed\n"),
- -1);
- }
+ // Set the sub state as generating code for the output operator.
+ this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT);
+ *os << "ACE_INLINE CORBA::Boolean operator<< (" << be_idt << be_idt_nl
+ << "TAO_OutputCDR &strm," << be_nl
+ << "const " << fname << "_forany &_tao_array" << be_uidt_nl
+ << ")" << be_uidt_nl
+ << "{" << be_idt_nl;
- *os << "}\n\n";
+ if (bt->accept (this) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_cdr_op_ci::"
+ "visit_array - "
+ "Base type codegen failed\n"),
+ -1);
+ }
- // Set the sub state as generating code for the input operator.
- os->indent ();
+ *os << "}\n\n";
- this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_INPUT);
- *os << "ACE_INLINE CORBA::Boolean operator>> (" << be_idt << be_idt_nl
- << "TAO_InputCDR &strm," << be_nl
- << fname << "_forany &_tao_array" << be_uidt_nl
- << ")" << be_uidt_nl
- << "{" << be_idt_nl;
+ // Set the sub state as generating code for the input operator.
+ os->indent ();
- if (bt->accept (this) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_array_cdr_op_ci::"
- "visit_array - "
- "Base type codegen failed\n"),
- -1);
- }
+ this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_INPUT);
+ *os << "ACE_INLINE CORBA::Boolean operator>> (" << be_idt << be_idt_nl
+ << "TAO_InputCDR &strm," << be_nl
+ << fname << "_forany &_tao_array" << be_uidt_nl
+ << ")" << be_uidt_nl
+ << "{" << be_idt_nl;
- *os << "}\n\n";
-
- node->cli_inline_cdr_op_gen (1);
+ if (bt->accept (this) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_array_cdr_op_ci::"
+ "visit_array - "
+ "Base type codegen failed\n"),
+ -1);
}
+ *os << "}" << be_nl << be_nl;
+
+ node->cli_inline_cdr_op_gen (1);
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp
index 750f5f9bcfd..2ba08492dcd 100644
--- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp
@@ -49,6 +49,7 @@ be_visitor_array_cdr_op_cs::visit_array (be_array *node)
// Retrieve the base type.
be_type *bt = be_type::narrow_from_decl (node->base_type ());
+ AST_Decl::NodeType nt = bt->node_type ();
if (!bt)
{
@@ -62,7 +63,7 @@ be_visitor_array_cdr_op_cs::visit_array (be_array *node)
// If we contain an anonymous sequence,
// generate code for the sequence here.
- if (bt->node_type () == AST_Decl::NT_sequence)
+ if (nt == AST_Decl::NT_sequence)
{
if (this->gen_anonymous_base_type (bt,
TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS)
@@ -76,5 +77,44 @@ be_visitor_array_cdr_op_cs::visit_array (be_array *node)
}
}
+ // If the array is an anonymous member and if its element type
+ // is a declaration (not a reference), we must generate code for
+ // the declaration.
+ if (this->ctx_->alias () == 0 // Not a typedef.
+ && bt->is_child (this->ctx_->scope ()))
+ {
+ int status = 0;
+ be_visitor_context ctx (*this->ctx_);
+
+ switch (nt)
+ {
+ case AST_Decl::NT_struct:
+ {
+ ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS);
+ be_visitor_structure_cdr_op_cs sc_visitor (&ctx);
+ status = bt->accept (&sc_visitor);
+ break;
+ }
+ case AST_Decl::NT_union:
+ {
+ ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS);
+ be_visitor_union_cdr_op_cs uc_visitor (&ctx);
+ status = bt->accept (&uc_visitor);
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_ch::"
+ "visit_array - "
+ "array base type codegen failed\n"),
+ -1);
+ }
+ }
+
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp
index 0d7b253b307..28fe2a3b1bb 100644
--- a/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_exception/cdr_op_ci.cpp
@@ -56,7 +56,7 @@ be_visitor_exception_cdr_op_ci::visit_exception (be_exception *node)
// it in our parent.
// Set the substate as generating code for the types defined in our scope.
- this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_SCOPE);
+ this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_SCOPE);
if (this->visit_scope (node) == -1)
{
@@ -68,7 +68,7 @@ be_visitor_exception_cdr_op_ci::visit_exception (be_exception *node)
}
// Set the sub state as generating code for the output operator.
- this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_OUTPUT);
+ this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT);
*os << "ACE_INLINE" << be_nl
<< "CORBA::Boolean operator<< (" << be_idt << be_idt_nl
@@ -203,6 +203,14 @@ be_visitor_exception_cdr_op_ci::visit_exception (be_exception *node)
int
be_visitor_exception_cdr_op_ci::post_process (be_decl *bd)
{
+ // This checks for members of an enum 'non-scope' declared inside
+ // the exception. If an enum val is actually a member, it will
+ // have node type NT_field.
+ if (bd->node_type () == AST_Decl::NT_enum_val)
+ {
+ return 0;
+ }
+
TAO_OutStream *os = this->ctx_->stream ();
if (!this->last_node (bd))
diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp
index cf497604458..dac93c08e41 100644
--- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp
@@ -39,6 +39,14 @@ be_visitor_exception_ctor::~be_visitor_exception_ctor (void)
int
be_visitor_exception_ctor::post_process (be_decl *bd)
{
+ // This checks for members of an enum 'non-scope' declared inside
+ // the exception. If an enum val is actually a member, it will
+ // have node type NT_field.
+ if (bd->node_type () == AST_Decl::NT_enum_val)
+ {
+ return 0;
+ }
+
TAO_OutStream *os = this->ctx_->stream (); // get output stream
if (!this->last_node (bd))
diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp
index 31c468d4e9f..aaafd9aaf73 100644
--- a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp
@@ -94,6 +94,12 @@ be_visitor_field_ch::visit_array (be_array *node)
{
// This is the case for anonymous arrays.
+ AST_Type *elem = node->base_type ();
+
+ if (elem->is_child (this->ctx_->scope ()))
+ {
+ }
+
// Instantiate a visitor context with a copy of our context. This info
// will be modified based on what type of node we are visiting
be_visitor_context ctx (*this->ctx_);
diff --git a/TAO/tests/IDL_Test/enum_in_struct.idl b/TAO/tests/IDL_Test/enum_in_struct.idl
index 07e309fe5b7..a8c98468f30 100644
--- a/TAO/tests/IDL_Test/enum_in_struct.idl
+++ b/TAO/tests/IDL_Test/enum_in_struct.idl
@@ -41,3 +41,44 @@ struct HoldsEnum
UnNamed unnamed_enum;
};
+// Test for anonymous arrays of member declarations
+
+struct decl_heavy_struct
+{
+ enum en
+ {
+ a,
+ b,
+ c
+ } m_en[10];
+
+ struct st
+ {
+ long a;
+ char b;
+ } m_st[10];
+
+ union un switch (long)
+ {
+ case 1: long a;
+ case 2: char b;
+ } m_un[10];
+};
+
+// Similar case for exception included here - no sense
+// in making a separte file for exceptions, which are
+// almost the same as structs.
+
+exception ErrorException
+{
+ enum ReasonCode
+ {
+ RESOURCE,
+ COMMUNICATION,
+ ASSERTION,
+ STATE,
+ ALREADY,
+ OTHER
+ } reason;
+};
+
diff --git a/TAO/tests/IDL_Test/union.idl b/TAO/tests/IDL_Test/union.idl
index f2e88ae05c6..30064ac3360 100644
--- a/TAO/tests/IDL_Test/union.idl
+++ b/TAO/tests/IDL_Test/union.idl
@@ -236,3 +236,36 @@ union TestUnion switch (short)
case 2: TestTwoEnum twoEnum;
};
+// Test for various kinds of declarations inside a union,
+// similar to the example in enum_in_struct.idl.
+
+union decl_heavy_union switch (short)
+{
+ case 1:
+ enum which
+ {
+ ZERO,
+ ONE,
+ TWO
+ } m_which;
+ case 2:
+ enum en
+ {
+ a,
+ b,
+ c
+ } m_en_arr[10];
+ case 3:
+ struct st
+ {
+ long a;
+ char b;
+ } m_st_arr[10];
+ case 4:
+ union un switch (long)
+ {
+ case 1: long a;
+ case 2: char b;
+ } m_un_arr[10];
+};
+