summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-05-15 15:48:36 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-05-15 15:48:36 +0000
commit84ccf8be7df9f6d89fd11b688b67d0d1654a7afc (patch)
treead8a1b9d077b93a3e95d5b6e0e5a1aff5a97d0ca /TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp
parent47bbff92ad876f011724bd0ca37af05a7e9f4dc1 (diff)
downloadATCD-84ccf8be7df9f6d89fd11b688b67d0d1654a7afc.tar.gz
ChangeLogTag: Tue May 15 10:43:23 2001 Jeff Parsons <parsons@cs.wustl.edu>
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp281
1 files changed, 160 insertions, 121 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp
index 7bcc99e9fb8..6702c1703b0 100644
--- a/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_union_branch/private_ch.cpp
@@ -32,58 +32,66 @@ ACE_RCSID(be_visitor_union_branch, private_ch, "$Id$")
// visitor for union_branch in the client header generating the private information
// **********************************************
-// constructor
+// Constructor.
be_visitor_union_branch_private_ch::be_visitor_union_branch_private_ch (be_visitor_context *ctx)
: be_visitor_decl (ctx)
{
}
-// destructor
+// Destructor.
be_visitor_union_branch_private_ch::~be_visitor_union_branch_private_ch (void)
{
}
-// visit the union_branch node
+// Visit the union_branch node.
int
be_visitor_union_branch_private_ch::visit_union_branch (be_union_branch *node)
{
be_type *bt = be_type::narrow_from_decl (node->field_type ());
+
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_union_branch - "
"Bad union_branch type\n"
- ), -1);
+ ),
+ -1);
}
- this->ctx_->node (node); // save the node
+ this->ctx_->node (node);
+
if (bt->accept (this) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_union_branch - "
"codegen for union_branch type failed\n"
- ), -1);
+ ),
+ -1);
}
+
return 0;
}
-// =visit operations on all possible data types that a union_branch can be
+// Visit operations on all possible data types that a union_branch can be.
int
be_visitor_union_branch_private_ch::visit_array (be_array *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get union branch
- be_decl *bu = this->ctx_->scope (); // get the enclosing union backend
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
be_type *bt;
- // check if we are visiting this node via a visit to a typedef node
+ // Check if we are visiting this node via a visit to a typedef node
if (this->ctx_->alias ())
- bt = this->ctx_->alias ();
+ {
+ bt = this->ctx_->alias ();
+ }
else
- bt = node;
+ {
+ bt = node;
+ }
if (!ub || !bu)
{
@@ -91,24 +99,24 @@ be_visitor_union_branch_private_ch::visit_array (be_array *node)
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_array - "
"bad context information\n"
- ), -1);
+ ),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- if (bt->node_type () != AST_Decl::NT_typedef // not a typedef
- && bt->is_child (bu)) // bt is defined inside the union
+ // Not a typedef and bt is defined inside the union.
+ if (bt->node_type () != AST_Decl::NT_typedef
+ && bt->is_child (bu))
{
- // case of anonymous array in union
- os->indent ();
+ // Case of anonymous array in union
*os << "_" << bt->local_name () << "_slice *" << ub->local_name ()
- << "_;\n";
+ << "_;" << be_nl;
}
else
{
- os->indent ();
*os << bt->nested_type_name (bu, "_slice") << " *" << ub->local_name ()
- << "_;\n";
+ << "_;" << be_nl;
}
return 0;
@@ -117,16 +125,19 @@ be_visitor_union_branch_private_ch::visit_array (be_array *node)
int
be_visitor_union_branch_private_ch::visit_enum (be_enum *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get union branch
- be_decl *bu = this->ctx_->scope (); // get the enclosing union backend
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
be_type *bt;
- // check if we are visiting this node via a visit to a typedef node
+ // Check if we are visiting this node via a visit to a typedef node
if (this->ctx_->alias ())
- bt = this->ctx_->alias ();
+ {
+ bt = this->ctx_->alias ();
+ }
else
- bt = node;
+ {
+ bt = node;
+ }
if (!ub || !bu)
{
@@ -134,29 +145,34 @@ be_visitor_union_branch_private_ch::visit_enum (be_enum *node)
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_enum - "
"bad context information\n"
- ), -1);
+ ),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ *os << bt->nested_type_name (bu) << " " << ub->local_name ()
+ << "_;" << be_nl;
- os->indent (); // start from current indentation
- *os << bt->nested_type_name (bu) << " " << ub->local_name () << "_;\n";
return 0;
}
int
be_visitor_union_branch_private_ch::visit_interface (be_interface *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get union branch
- be_decl *bu = this->ctx_->scope (); // get the enclosing union backend
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
be_type *bt;
- // check if we are visiting this node via a visit to a typedef node
+ // Check if we are visiting this node via a visit to a typedef node
if (this->ctx_->alias ())
- bt = this->ctx_->alias ();
+ {
+ bt = this->ctx_->alias ();
+ }
else
- bt = node;
+ {
+ bt = node;
+ }
if (!ub || !bu)
{
@@ -164,30 +180,34 @@ be_visitor_union_branch_private_ch::visit_interface (be_interface *node)
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_interface - "
"bad context information\n"
- ), -1);
+ ),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- os->indent (); // start from current indentation
*os << bt->nested_type_name (bu, "_var")
- << " *" << ub->local_name () << "_;\n";
+ << " *" << ub->local_name () << "_;" << be_nl;
+
return 0;
}
int
be_visitor_union_branch_private_ch::visit_interface_fwd (be_interface_fwd *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get union branch
- be_decl *bu = this->ctx_->scope (); // get the enclosing union backend
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
be_type *bt;
- // check if we are visiting this node via a visit to a typedef node
+ // Check if we are visiting this node via a visit to a typedef node
if (this->ctx_->alias ())
- bt = this->ctx_->alias ();
+ {
+ bt = this->ctx_->alias ();
+ }
else
- bt = node;
+ {
+ bt = node;
+ }
if (!ub || !bu)
{
@@ -195,30 +215,36 @@ be_visitor_union_branch_private_ch::visit_interface_fwd (be_interface_fwd *node)
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_interface_fwd - "
"bad context information\n"
- ), -1);
+ ),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- os->indent (); // start from current indentation
*os << bt->nested_type_name (bu, "_var")
- << " *" << ub->local_name () << "_;\n";
+ << " *" << ub->local_name () << "_;" << be_nl;
+
return 0;
}
int
-be_visitor_union_branch_private_ch::visit_predefined_type (be_predefined_type *node)
+be_visitor_union_branch_private_ch::visit_predefined_type (
+ be_predefined_type *node
+ )
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get union branch
- be_decl *bu = this->ctx_->scope (); // get the enclosing union backend
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
be_type *bt;
- // check if we are visiting this node via a visit to a typedef node
+ // Check if we are visiting this node via a visit to a typedef node
if (this->ctx_->alias ())
- bt = this->ctx_->alias ();
+ {
+ bt = this->ctx_->alias ();
+ }
else
- bt = node;
+ {
+ bt = node;
+ }
if (!ub || !bu)
{
@@ -226,55 +252,57 @@ be_visitor_union_branch_private_ch::visit_predefined_type (be_predefined_type *n
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_predefined_type - "
"bad context information\n"
- ), -1);
+ ),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
if (node->pt () == AST_PredefinedType::PT_pseudo)
{
- // Cannot have an object inside of a union
- os->indent (); // start from current indentation
- // check if we are dealing with a CORBA::Object
+ // Cannot have an object inside of a union.
+ // Check if we are dealing with a CORBA::Object
if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object"))
{
*os << bt->name () << "_var"
- << " *" << ub->local_name () << "_;\n";
+ << " *" << ub->local_name () << "_;" << be_nl;
}
else
*os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name ()
- << "_;\n";
+ << "_;" << be_nl;
}
else if (node->pt () == AST_PredefinedType::PT_any)
{
// Cannot have an object inside of a union. In addition, an Any is a
- // variable data type
- os->indent (); // start from current indentation
- *os << bt->nested_type_name (bu) << " *" << ub->local_name () <<
- "_;\n";
+ // variable data type.
+ *os << bt->nested_type_name (bu) << " *" << ub->local_name ()
+ << "_;" << be_nl;
}
else
{
- os->indent (); // start from current indentation
- *os << bt->nested_type_name (bu) << " " << ub->local_name () <<
- "_;\n";
+ *os << bt->nested_type_name (bu) << " " << ub->local_name ()
+ << "_;" << be_nl;
}
+
return 0;
}
int
be_visitor_union_branch_private_ch::visit_sequence (be_sequence *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get union branch
- be_decl *bu = this->ctx_->scope (); // get the enclosing union backend
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
be_type *bt;
- // check if we are visiting this node via a visit to a typedef node
+ // Check if we are visiting this node via a visit to a typedef node
if (this->ctx_->alias ())
- bt = this->ctx_->alias ();
+ {
+ bt = this->ctx_->alias ();
+ }
else
- bt = node;
+ {
+ bt = node;
+ }
if (!ub || !bu)
{
@@ -282,24 +310,25 @@ be_visitor_union_branch_private_ch::visit_sequence (be_sequence *node)
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_sequence - "
"bad context information\n"
- ), -1);
+ ),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- os->indent ();
// C++ doesn't allow object instances inside unions, so we need a
- // pointer
- *os << bt->nested_type_name (bu) << " *" << ub->local_name () << "_;\n";
+ // pointer.
+ *os << bt->nested_type_name (bu) << " *" << ub->local_name ()
+ << "_;" << be_nl;
+
return 0;
}
int
be_visitor_union_branch_private_ch::visit_string (be_string *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get union branch
- be_decl *bu = this->ctx_->scope (); // get the enclosing union backend
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
if (!ub || !bu)
{
@@ -307,20 +336,19 @@ be_visitor_union_branch_private_ch::visit_string (be_string *node)
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_string - "
"bad context information\n"
- ), -1);
+ ),
+ -1);
}
- os = this->ctx_->stream ();
-
- os->indent ();
+ TAO_OutStream *os = this->ctx_->stream ();
if (node->width () == (long) sizeof (char))
{
- *os << "char *" << ub->local_name () << "_;\n";
+ *os << "char *" << ub->local_name () << "_;" << be_nl;
}
else
{
- *os << "CORBA::WChar *" << ub->local_name () << "_;\n";
+ *os << "CORBA::WChar *" << ub->local_name () << "_;" << be_nl;
}
return 0;
@@ -329,16 +357,19 @@ be_visitor_union_branch_private_ch::visit_string (be_string *node)
int
be_visitor_union_branch_private_ch::visit_structure (be_structure *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get union branch
- be_decl *bu = this->ctx_->scope (); // get the enclosing union backend
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
be_type *bt;
- // check if we are visiting this node via a visit to a typedef node
+ // Check if we are visiting this node via a visit to a typedef node
if (this->ctx_->alias ())
- bt = this->ctx_->alias ();
+ {
+ bt = this->ctx_->alias ();
+ }
else
- bt = node;
+ {
+ bt = node;
+ }
if (!ub || !bu)
{
@@ -346,22 +377,23 @@ be_visitor_union_branch_private_ch::visit_structure (be_structure *node)
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_structure - "
"bad context information\n"
- ), -1);
+ ),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- os->indent ();
-
- // if we are variable sized, we need a pointer type
+ // If we are variable sized, we need a pointer type.
if (node->size_type () == be_decl::VARIABLE
|| node->has_constructor ())
{
- *os << bt->nested_type_name (bu) << " *" << ub->local_name () << "_;\n";
+ *os << bt->nested_type_name (bu) << " *" << ub->local_name ()
+ << "_;" << be_nl;
}
else
{
- *os << bt->nested_type_name (bu) << " " << ub->local_name () << "_;\n";
+ *os << bt->nested_type_name (bu) << " " << ub->local_name ()
+ << "_;" << be_nl;
}
return 0;
@@ -370,18 +402,19 @@ be_visitor_union_branch_private_ch::visit_structure (be_structure *node)
int
be_visitor_union_branch_private_ch::visit_typedef (be_typedef *node)
{
- this->ctx_->alias (node); // save the typedef node for use in code generation
- // as we visit the base type
+ this->ctx_->alias (node);
- // the node to be visited in the base primitve type that gets typedefed
+ // The node to be visited in the base primitve type that gets typedefed.
be_type *bt = node->primitive_base_type ();
+
if (!bt || (bt->accept (this) == -1))
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_typedef - "
"Bad primitive type\n"
- ), -1);
+ ),
+ -1);
}
this->ctx_->alias (0);
@@ -391,16 +424,19 @@ be_visitor_union_branch_private_ch::visit_typedef (be_typedef *node)
int
be_visitor_union_branch_private_ch::visit_union (be_union *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get union branch
- be_decl *bu = this->ctx_->scope (); // get the enclosing union backend
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
be_type *bt;
- // check if we are visiting this node via a visit to a typedef node
+ // Check if we are visiting this node via a visit to a typedef node
if (this->ctx_->alias ())
- bt = this->ctx_->alias ();
+ {
+ bt = this->ctx_->alias ();
+ }
else
- bt = node;
+ {
+ bt = node;
+ }
if (!ub || !bu)
{
@@ -408,13 +444,16 @@ be_visitor_union_branch_private_ch::visit_union (be_union *node)
"(%N:%l) be_visitor_union_branch_private_ch::"
"visit_union - "
"bad context information\n"
- ), -1);
+ ),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // C++ doesn't allow object instances inside unions, so we need a
+ // pointer.
+ *os << bt->nested_type_name (bu) << " *" << ub->local_name ()
+ << "_;" << be_nl;
- os->indent ();
- // C++ doesn't allow instances of classes
- *os << bt->nested_type_name (bu) << " *" << ub->local_name () << "_;\n";
return 0;
}