summaryrefslogtreecommitdiff
path: root/TAO
diff options
context:
space:
mode:
Diffstat (limited to 'TAO')
-rw-r--r--TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp48
-rw-r--r--TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp517
-rw-r--r--TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp18
-rw-r--r--TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp18
-rw-r--r--TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp5
5 files changed, 343 insertions, 263 deletions
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 b91688e46d1..169a9167b3e 100644
--- a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp
@@ -57,8 +57,8 @@ be_visitor_field_ch::visit_field (be_field *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_field - "
- "Bad field type\n"
- ), -1);
+ "Bad field type\n"),
+ -1);
}
this->ctx_->node (node);
@@ -68,8 +68,8 @@ be_visitor_field_ch::visit_field (be_field *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_field - "
- "codegen for field type failed\n"
- ), -1);
+ "codegen for field type failed\n"),
+ -1);
}
// Now output the field name.
@@ -117,8 +117,8 @@ be_visitor_field_ch::visit_array (be_array *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_array - "
- "Bad visitor\n"
- ), -1);
+ "Bad visitor\n"),
+ -1);
}
if (node->accept (visitor) == -1)
@@ -126,8 +126,8 @@ be_visitor_field_ch::visit_array (be_array *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_array - "
- "codegen failed\n"
- ), -1);
+ "codegen failed\n"),
+ -1);
}
delete visitor;
@@ -188,8 +188,8 @@ be_visitor_field_ch::visit_enum (be_enum *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_enum - "
- "Bad visitor\n"
- ), -1);
+ "Bad visitor\n"),
+ -1);
}
if (node->accept (visitor) == -1)
@@ -197,8 +197,8 @@ be_visitor_field_ch::visit_enum (be_enum *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_enum - "
- "codegen failed\n"
- ), -1);
+ "codegen failed\n"),
+ -1);
}
delete visitor;
@@ -436,8 +436,7 @@ be_visitor_field_ch::visit_sequence (be_sequence *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_sequence - "
- "Bad visitor\n"
- ),
+ "Bad visitor\n"),
-1);
}
@@ -446,8 +445,7 @@ be_visitor_field_ch::visit_sequence (be_sequence *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_sequence - "
- "codegen failed\n"
- ),
+ "codegen failed\n"),
-1);
}
@@ -544,8 +542,8 @@ be_visitor_field_ch::visit_structure (be_structure *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_struct - "
- "Bad visitor\n"
- ), -1);
+ "Bad visitor\n"),
+ -1);
}
if (node->accept (visitor) == -1)
@@ -553,8 +551,8 @@ be_visitor_field_ch::visit_structure (be_structure *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_struct - "
- "codegen failed\n"
- ), -1);
+ "codegen failed\n"),
+ -1);
}
delete visitor;
@@ -588,8 +586,8 @@ be_visitor_field_ch::visit_typedef (be_typedef *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_typedef - "
- "Bad primitive type\n"
- ), -1);
+ "Bad primitive type\n"),
+ -1);
}
// Reset the alias.
@@ -631,8 +629,7 @@ be_visitor_field_ch::visit_union (be_union *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_union - "
- "Bad visitor\n"
- ),
+ "Bad visitor\n"),
-1);
}
@@ -641,8 +638,7 @@ be_visitor_field_ch::visit_union (be_union *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_union - "
- "codegen failed\n"
- ),
+ "codegen failed\n"),
-1);
}
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp
index 40bab9605e1..3e2ae5c2e01 100644
--- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp
@@ -20,14 +20,14 @@
//
// ============================================================================
-#include "idl.h"
-#include "idl_extern.h"
-#include "be.h"
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
ACE_RCSID(be_visitor_valuetype, field_ch, "$Id$")
-// constructor
+// Constructor.
be_visitor_valuetype_field_ch::be_visitor_valuetype_field_ch
(be_visitor_context *ctx)
: be_visitor_decl (ctx)
@@ -35,12 +35,12 @@ be_visitor_valuetype_field_ch::be_visitor_valuetype_field_ch
setenclosings ("",";");
}
-// destructor
+// Destructor.
be_visitor_valuetype_field_ch::~be_visitor_valuetype_field_ch (void)
{
}
-// visit the field node
+// Visit the field node.
int
be_visitor_valuetype_field_ch::visit_field (be_field *node)
{
@@ -51,8 +51,8 @@ be_visitor_valuetype_field_ch::visit_field (be_field *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_union_branch - "
- "Bad type\n"
- ), -1);
+ "Bad type\n"),
+ -1);
}
this->ctx_->node (node); // save the node
@@ -62,78 +62,83 @@ be_visitor_valuetype_field_ch::visit_field (be_field *node)
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_union_branch - "
- "codegen failed\n"
- ), -1);
+ "codegen failed\n"),
+ -1);
}
return 0;
}
-// =visit operations on all possible data types (valuetype state member)
+// =Visit operations on all possible data types (valuetype state member).
// visit array type
int
be_visitor_valuetype_field_ch::visit_array (be_array *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- be_decl *bu = this->ctx_->scope (); // get the enclosing union node
+ be_decl *ub = this->ctx_->node ();
+ be_decl *bu = this->ctx_->scope ();
be_type *bt;
- // check if we are visiting this via a visit to a typedef node
+ // Check if we are visiting this 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_array - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -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
{
- // this is the case of an anonymous array inside a union
+ // This is the case of an anonymous array inside a union.
- // instantiate a visitor context with a copy of our context. This info
- // will be modified based on what type of node we are visiting
+ // 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_);
- ctx.node (node); // set the node to be the node being visited. The scope
- // is still the same
+ ctx.node (node);
- // first generate the array declaration
+ // First generate the array declaration.
ctx.state (TAO_CodeGen::TAO_ARRAY_CH);
be_visitor *visitor = tao_cg->make_visitor (&ctx);
+
if (!visitor)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_array - "
- "Bad visitor\n"
- ), -1);
+ "Bad visitor\n"),
+ -1);
}
+
if (node->accept (visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_array - "
- "codegen failed\n"
- ), -1);
+ "codegen failed\n"),
+ -1);
}
+
delete visitor;
- // now use this array as a "type" for the subsequent declarator
- // the set method
+ // Now use this array as a "type" for the subsequent declarator
+ // the set method.
*os << pre_op () << "void " << ub->local_name () << " ("
<< "_" << bt->local_name () << ")"
<< post_op () << " // set" << be_nl;
- // the get method
+ // The get method.
*os << pre_op () << "const _" << bt->local_name ()
<< "_slice * " << ub->local_name ()
<< " (void) const" << post_op () << be_nl;
@@ -143,16 +148,16 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node)
}
else
{
- // now use this array as a "type" for the subsequent declarator
- // the set method
+ // Now use this array as a "type" for the subsequent declarator.
+ // The set method.
*os << pre_op () << "void " << ub->local_name () << " ("
<< bt->name () << ")" << post_op () << " // set"
<< be_nl;
- // the get method
+ // The get method.
*os << pre_op()
<< bt->name () << "_slice *" << ub->local_name ()
<< " (void)" << post_op () << be_nl;
- // the get (read/write) method
+ // The get (read/write) method.
*os << pre_op () << "const "
<< bt->name () << "_slice *" << ub->local_name ()
<< " (void) const" << post_op () << "\n\n";
@@ -161,342 +166,380 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node)
return 0;
}
-// visit enum type
+// Visit enum type.
int
be_visitor_valuetype_field_ch::visit_enum (be_enum *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- be_decl *bu = this->ctx_->scope (); // get the enclosing union node
+ 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 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_enum - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -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
{
- // instantiate a visitor context with a copy of our context. This info
- // will be modified based on what type of node we are visiting
+ // 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_);
- ctx.node (node); // set the node to be the node being visited. The scope
- // is still the same
+ ctx.node (node);
- // first generate the enum declaration
+ // First generate the enum declaration.
ctx.state (TAO_CodeGen::TAO_ENUM_CH);
be_visitor *visitor = tao_cg->make_visitor (&ctx);
+
if (!visitor)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_enum - "
- "Bad visitor\n"
- ), -1);
+ "Bad visitor\n"),
+ -1);
}
+
if (node->accept (visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_enum - "
- "codegen failed\n"
- ), -1);
+ "codegen failed\n"),
+ -1);
}
+
delete visitor;
}
- // now use this enum as a "type" for the subsequent declarator
- // the set method
+ // Now use this enum as a "type" for the subsequent declarator
+ // the set method.
*os << pre_op () << "void " << ub->local_name () << " ("
<< bt->name () << ")" << post_op () << " // set"
<< be_nl;
- // the get method
+ // The get method.
*os << pre_op () << bt->name () << " " << ub->local_name ()
- << " (void) const" << post_op () << " // get method\n\n";
+ << " (void) const" << post_op () << " // get method"
+ << be_nl << be_nl;
return 0;
}
-// visit interface type
+// Visit interface type.
int
be_visitor_valuetype_field_ch::visit_interface (be_interface *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- 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 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_interface - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- // set method
+ // Set method.
*os << pre_op() << "void " << ub->local_name () << " ("
<< bt->name () << "_ptr"
<< ")" << post_op() << " // set" << be_nl;
- // get method
+ // Get method.
*os << pre_op()
<< bt->name () << "_ptr " << ub->local_name ()
- << " (void) const" << post_op() << " // get method\n\n";
+ << " (void) const" << post_op() << " // get method"
+ << be_nl << be_nl;
+
return 0;
}
-// visit interface forward type
+// Visit interface forward type.
int
be_visitor_valuetype_field_ch::visit_interface_fwd (be_interface_fwd *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- 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 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_interface_fwd - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- // set method
+ // Set method.
*os << pre_op () << "void " << ub->local_name () << " ("
<< bt->name () << "_ptr"
<< ")" << post_op () << " // set" << be_nl;
- // get method
+ // Get method.
*os << pre_op ()
<< bt->name () << "_ptr " << ub->local_name ()
- << " (void) const" << post_op () << " // get method\n\n";
+ << " (void) const" << post_op () << " // get method"
+ << be_nl << be_nl;
+
return 0;
}
-// visit valuetype type
+// Visit valuetype type.
int
be_visitor_valuetype_field_ch::visit_valuetype (be_valuetype *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- 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 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_valuetype - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- // set method
+ // Set method.
*os << pre_op () << "void " << ub->local_name () << " ("
<< bt->name () << " *"
<< ")" << post_op () << " // set" << be_nl;
- // get method
+ // Get method.
*os << pre_op ()
<< bt->name () << " *" << ub->local_name ()
- << " (void) const" << post_op () << " // get method\n\n";
+ << " (void) const" << post_op () << " // get method"
+ << be_nl << be_nl;
+
return 0;
}
-// visit valuetype forward type
+// Visit valuetype forward type.
int
be_visitor_valuetype_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- 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 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_valuetype_fwd - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- // set method
+ // Set method.
*os << pre_op () << "void " << ub->local_name () << " ("
<< bt->name () << " *"
<< ")" << post_op () << " // set" << be_nl;
- // get method
+ // Get method.
*os << pre_op ()
<< bt->name () << " *" << ub->local_name ()
- << " (void) const" << post_op () << " // get method\n\n";
+ << " (void) const" << post_op () << " // get method"
+ << be_nl << be_nl;
+
return 0;
}
-// visit predefined type
+// Visit predefined type.
int
be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- 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 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_predefined_type - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
switch (node->pt ())
{
case AST_PredefinedType::PT_pseudo:
- // set method
+ // set method.
*os << pre_op () << "void " << ub->local_name () << " ("
<< bt->name () << "_ptr)"
<< post_op () << " // set" << be_nl;
- // get method
+ // Get method.
*os << pre_op ()
<< bt->name () << "_ptr " << ub->local_name ()
- << " (void) const" << post_op () << " // get method\n\n";
+ << " (void) const" << post_op () << " // get method"
+ << be_nl << be_nl;
break;
case AST_PredefinedType::PT_any:
- // set method
+ // Set method.
*os << pre_op () << "void " << ub->local_name () << " ("
<< bt->name () << ")"
<< post_op () << " // set" << be_nl;
- // get method (read-only)
+ // Get method (read-only).
*os << pre_op () << "const " << bt->name () << " "
<< ub->local_name () << " (void) const"
- << post_op () << " // get method\n\n";
- // get method (read/write)
+ << post_op () << " // get method"
+ << be_nl << be_nl;
+ // Get method (read/write).
*os << pre_op () << bt->name () << " "
<< ub->local_name () << " (void)"
- << post_op () << " // get method\n\n";
+ << post_op () << " // get method"
+ << be_nl << be_nl;
break;
case AST_PredefinedType::PT_void:
break;
default:
- // set method
+ // Set method.
*os << pre_op () << "void " << ub->local_name () << " ("
<< bt->name () << ")"
<< post_op () << " // set" << be_nl;
- // get method
+ // Get method.
*os << pre_op () << bt->name () << " " << ub->local_name ()
- << " (void) const" << post_op () << " // get method\n\n";
+ << " (void) const" << post_op () << " // get method"
+ << be_nl << be_nl;
}
return 0;
}
-// visit sequence type
+// Visit sequence type.
int
be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- 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 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_sequence - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -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 here.
+ if (bt->node_type () != AST_Decl::NT_typedef
+ && bt->is_child (bu))
{
- // instantiate a visitor context with a copy of our context. This info
- // will be modified based on what type of node we are visiting
+ // 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_);
- ctx.node (node); // set the node to be the node being visited. The scope
- // is still the same
+ ctx.node (node);
- // first generate the sequence declaration
+ // First generate the sequence declaration.
ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH);
be_visitor *visitor = tao_cg->make_visitor (&ctx);
+
if (!visitor)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_sequence - "
- "Bad visitor\n"
- ), -1);
+ "Bad visitor\n"),
+ -1);
}
+
if (node->accept (visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_sequence - "
- "codegen failed\n"
- ), -1);
+ "codegen failed\n"),
+ -1);
}
delete visitor;
@@ -515,42 +558,42 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node)
}
- // set method
+ // Set method.
*os << pre_op () << "void " << ub->local_name () << " (const "
<< bt->name () << " &)"
<< post_op () << " // set" << be_nl;
- // read-only
+ // Read-only.
*os << pre_op () << "const " << bt->name () << " &"
<< ub->local_name () << " (void) const"
<< post_op () << " // get method (read only)" << be_nl;
- // read/write
+ // Read/write.
*os << pre_op () << bt->name () << " &" << ub->local_name ()
<< " (void)"
- << post_op () << " // get method (read/write only)\n\n";
+ << post_op () << " // get method (read/write only)"
+ << be_nl << be_nl;
return 0;
}
-// visit string type
+// Visit string type.
int
be_visitor_valuetype_field_ch::visit_string (be_string *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_string - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -1);
}
- os = this->ctx_->stream ();
+ TAO_OutStream *os = this->ctx_->stream ();
- // three methods to set the string value
+ // Three methods to set the string value.
if (node->width () == (long) sizeof (char))
{
*os << pre_op ()
@@ -562,9 +605,10 @@ be_visitor_valuetype_field_ch::visit_string (be_string *node)
*os << pre_op ()
<< "void " << ub->local_name () << " (const CORBA::String_var&)"
<< post_op () << " // set" << be_nl;
- //get method
+ // Get method.
*os << pre_op () << "const char *" << ub->local_name ()
- << " (void) const" << post_op () << " // get method\n\n";
+ << " (void) const" << post_op () << " // get method"
+ << be_nl << be_nl;
}
else
{
@@ -577,180 +621,193 @@ be_visitor_valuetype_field_ch::visit_string (be_string *node)
*os << pre_op ()
<< "void " << ub->local_name () << " (const CORBA::WString_var&)"
<< post_op () << " // set" << be_nl;
- //get method
+ // Get method.
*os << pre_op() << "const CORBA::WChar *" << ub->local_name ()
- << " (void) const" << post_op() << " // get method\n\n";
+ << " (void) const" << post_op() << " // get method"
+ << be_nl << be_nl;
}
return 0;
}
-// visit structure type
+// Visit structure type.
int
be_visitor_valuetype_field_ch::visit_structure (be_structure *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- 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 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_structure - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -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 here.
+ if (bt->node_type () != AST_Decl::NT_typedef
+ && bt->is_child (bu))
{
- // instantiate a visitor context with a copy of our context. This info
- // will be modified based on what type of node we are visiting
+ // 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_);
- ctx.node (node); // set the node to be the node being visited. The scope
- // is still the same
+ ctx.node (node);
- // first generate the sequence declaration
+ // First generate the sequence declaration.
ctx.state (TAO_CodeGen::TAO_STRUCT_CH);
be_visitor *visitor = tao_cg->make_visitor (&ctx);
+
if (!visitor)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_structure - "
- "Bad visitor\n"
- ), -1);
+ "Bad visitor\n"),
+ -1);
}
+
if (node->accept (visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_structure - "
- "codegen failed\n"
- ), -1);
+ "codegen failed\n"),
+ -1);
}
+
delete visitor;
}
- // set method
+ // Set method.
*os << pre_op () << "void " << ub->local_name () << " (const "
<< bt->name () << " &)"
<< post_op () << " // set" << be_nl;
- // read-only
+ // Read-only.
*os << pre_op () << "const " << bt->name () << " &";
*os << ub->local_name () << " (void) const"
<< post_op () << " // get method (read only)" << be_nl
- // read/write
+ // Read/write.
<< pre_op () << bt->name () << " &" << ub->local_name ()
- << " (void)" << post_op () << " // get method (read/write only)\n\n";
+ << " (void)" << post_op () << " // get method (read/write only)"
+ << be_nl << be_nl;
return 0;
}
-// visit typedefed type
+// Visit typedefed type.
int
be_visitor_valuetype_field_ch::visit_typedef (be_typedef *node)
{
- TAO_OutStream *os; // output stream
+ TAO_OutStream *os = this->ctx_->stream ();
+ this->ctx_->alias (node);
- os = this->ctx_->stream ();
- this->ctx_->alias (node); // save the node for use in code generation and
- // indicate that the union_branch of the union_branch node
- // is a typedefed quantity
-
- // make a decision based on the primitive base type
+ // Make a decision based on the primitive base type.
be_type *bt = node->primitive_base_type ();
+
if (!bt || (bt->accept (this) == -1))
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_spec_ch::"
"visit_typedef - "
- "Bad primitive type\n"
- ), -1);
+ "Bad primitive type\n"),
+ -1);
}
+
this->ctx_->alias (0);
return 0;
}
-// visit union type
+// Visit union type.
int
be_visitor_valuetype_field_ch::visit_union (be_union *node)
{
- TAO_OutStream *os; // output stream
- be_decl *ub = this->ctx_->node (); // get state member
- 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 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)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_union - "
- "bad context information\n"
- ), -1);
+ "bad context information\n"),
+ -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 here.
+ if (bt->node_type () != AST_Decl::NT_typedef
+ && bt->is_child (bu))
{
- // instantiate a visitor context with a copy of our context. This info
- // will be modified based on what type of node we are visiting
+ // 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_);
- ctx.node (node); // set the node to be the node being visited. The scope
- // is still the same
+ ctx.node (node);
- // first generate the sequence declaration
+ // First generate the sequence declaration.
ctx.state (TAO_CodeGen::TAO_STRUCT_CH);
be_visitor *visitor = tao_cg->make_visitor (&ctx);
+
if (!visitor)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_union - "
- "Bad visitor\n"
- ), -1);
+ "Bad visitor\n"),
+ -1);
}
+
if (node->accept (visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_ch::"
"visit_union - "
- "codegen failed\n"
- ), -1);
+ "codegen failed\n"),
+ -1);
}
+
delete visitor;
}
- // set method
+ // Set method.
*os << pre_op () << "void " << ub->local_name () << " (const "
<< bt->name () << " &)"
<< post_op () << " // set" << be_nl;
- // read-only
+ // Read-only.
*os << pre_op () << "const " << bt->name () << " &"
<< ub->local_name () << " (void) const"
<< post_op () << " // get method (read only)"
<< be_nl;
- // read/write
+ // Read/write.
*os << pre_op () << bt->name () << " &" << ub->local_name ()
- << " (void)" << post_op () << " // get method (read/write only)\n\n";
+ << " (void)" << post_op () << " // get method (read/write only)"
+ << be_nl << be_nl;
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp
index 75491a3450c..00932f05f65 100644
--- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp
@@ -62,6 +62,7 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node)
UTL_Scope::IK_decls),
-1);
this->elem_number_ = 0;
+
// continue until each element is visited
for (;!si->is_done ();si->next())
{
@@ -118,6 +119,7 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node)
for (;!si->is_done ();si->next())
{
AST_Decl *d = si->item ();
+
if (!d)
{
delete si;
@@ -126,15 +128,22 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node)
"bad node in this scope\n"), -1);
}
+
AST_Field *field = AST_Field::narrow_from_decl (d);
+
if (!field ||
(field && field->visibility() != AST_Field::vis_PRIVATE))
{
continue; // only private fields in this run
}
+
++ n_processed;
+
if (n_processed == 1)
- this->begin_private ();
+ {
+ this->begin_private ();
+ }
+
be_decl *bd = be_decl::narrow_from_decl (d);
// set the scope node as "node" in which the code is being
// generated so that elements in the node's scope can use it
@@ -151,12 +160,15 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node)
delete si;
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_scope::visit_scope - "
- "codegen for scope failed\n"), -1);
+ "codegen for scope failed\n"),
+ -1);
}
} // end of for loop
+
delete si;
} // end of if
+
return 0;
}
@@ -776,7 +788,7 @@ be_visitor_valuetype::gen_field_pd (be_field *node)
// now output the field name.
*os << " " << vt->field_pd_prefix ()
<< node->local_name ()
- << vt->field_pd_postfix() << ";\n";
+ << vt->field_pd_postfix() << ";" << be_nl;
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp
index 264ff7af24c..8906470b2be 100644
--- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp
@@ -144,7 +144,16 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node)
if (n_inherits_valuetypes > 1)
{
- *os << "," << be_nl;
+ *os << ",";
+
+ if (i == 1)
+ {
+ *os << be_idt_nl;
+ }
+ else
+ {
+ *os << be_nl;
+ }
}
be_decl *scope = 0;
@@ -163,6 +172,11 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node)
if (n_inherits_valuetypes > 0)
{
+ if (n_inherits_valuetypes > 1)
+ {
+ *os << be_uidt;
+ }
+
*os << be_uidt_nl;
}
}
@@ -429,5 +443,5 @@ void
be_visitor_valuetype_ch::begin_private (void)
{
TAO_OutStream *os = this->ctx_->stream ();
- *os << "protected:" << be_idt_nl;
+ *os << be_uidt_nl << "protected:" << be_idt_nl;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp
index 6daf1e66e85..3b6d6e69636 100644
--- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp
@@ -88,7 +88,9 @@ be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node)
// STEP 2: Generate the body ==
- *os << "{" << be_idt_nl;
+ *os << "{" << be_nl;
+
+ this->begin_public ();
// Generate code for the OBV_ class definition.
if (this->visit_valuetype_scope (node) == -1)
@@ -175,7 +177,6 @@ void
be_visitor_valuetype_obv_ch::begin_public (void)
{
TAO_OutStream *os = this->ctx_->stream ();
- *os << be_uidt_nl;
*os << "public:" << be_idt_nl;
}