summaryrefslogtreecommitdiff
path: root/TAO_IDL/be/be_visitor_arg_traits.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO_IDL/be/be_visitor_arg_traits.cpp')
-rw-r--r--TAO_IDL/be/be_visitor_arg_traits.cpp597
1 files changed, 347 insertions, 250 deletions
diff --git a/TAO_IDL/be/be_visitor_arg_traits.cpp b/TAO_IDL/be/be_visitor_arg_traits.cpp
index a15234e5d61..3f5dd300306 100644
--- a/TAO_IDL/be/be_visitor_arg_traits.cpp
+++ b/TAO_IDL/be/be_visitor_arg_traits.cpp
@@ -109,7 +109,7 @@ be_visitor_arg_traits::visit_root (be_root *node)
int
be_visitor_arg_traits::visit_module (be_module *node)
{
- if (this->visit_scope (node) == -1)
+ if (this->visit_scope (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_arg_traits::"
@@ -123,51 +123,61 @@ be_visitor_arg_traits::visit_module (be_module *node)
int
be_visitor_arg_traits::visit_interface (be_interface *node)
{
- if (this->generated (node))
+ if (node->imported ())
{
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
return 0;
}
- if (node->seen_in_operation ())
+ // A local interface can never be an argument.
+ if (node->is_local () || this->generated (node))
{
- TAO_OutStream *os = this->ctx_->stream ();
+ return 0;
+ }
- *os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
- << "// " << __FILE__ << ":" << __LINE__;
+ this->generated (node, true);
- std::string guard_suffix =
- std::string (this->S_) + std::string ("arg_traits");
+ TAO_OutStream *os = this->ctx_->stream ();
- // This should be generated even for imported nodes. The ifdef
- // guard prevents multiple declarations.
- os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
+ *os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
+ << "// " << __FILE__ << ":" << __LINE__;
- *os << be_nl_2
- << "template<>" << be_nl
- << "class "
- << " " << this->S_ << "Arg_Traits<"
- << node->name () << ">" << be_idt_nl
- << ": public" << be_idt << be_idt_nl
- << "Object_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
- << node->name () << "_ptr," << be_nl
- << node->name () << "_var," << be_nl
- << node->name () << "_out";
-
- if (ACE_OS::strlen (this->S_) == 0)
- {
- *os << "," << be_nl
- << "TAO::Objref_Traits<" << node->name () << ">";
- }
+ std::string guard_suffix =
+ std::string (this->S_) + std::string ("arg_traits");
- *os << "," << be_nl << this->insert_policy()
- << be_uidt_nl
- << ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
- << "{" << be_nl
- << "};";
+ // The guard should be generated to prevent multiple declarations,
+ // since a forward declaration may appear more than once.
+ os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
- os->gen_endif ();
+ *os << be_nl_2
+ << "template<>" << be_nl
+ << "class "
+ << " " << this->S_ << "Arg_Traits< ::"
+ << node->name () << ">" << be_idt_nl
+ << ": public" << be_idt << be_idt_nl
+ << "Object_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
+ << "::" << node->name () << "_ptr," << be_nl
+ << "::" << node->name () << "_var," << be_nl
+ << "::" << node->name () << "_out";
+
+ if (ACE_OS::strlen (this->S_) == 0)
+ {
+ *os << "," << be_nl
+ << "TAO::Objref_Traits<" << node->name () << ">";
}
+ *os << "," << be_nl << this->insert_policy ()
+ << be_uidt_nl
+ << ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
+ << "{" << be_nl
+ << "};";
+
+ os->gen_endif ();
+
if (this->visit_scope (node) != 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
@@ -176,13 +186,22 @@ be_visitor_arg_traits::visit_interface (be_interface *node)
-1);
}
- this->generated (node, true);
return 0;
}
int
be_visitor_arg_traits::visit_interface_fwd (be_interface_fwd *node)
{
+ if (node->imported ())
+ {
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
+ return 0;
+ }
+
// If a full definition with the same name in the same scope
// has been seen, then it will have gone through visit_interface()
// already.
@@ -211,53 +230,51 @@ be_visitor_arg_traits::visit_interface_fwd (be_interface_fwd *node)
int
be_visitor_arg_traits::visit_valuebox (be_valuebox *node)
{
- if (this->generated (node))
+ if (node->imported ())
{
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
return 0;
}
- if (node->seen_in_operation ())
+ if (this->generated (node))
{
- TAO_OutStream & os = *this->ctx_->stream ();
-
- os << be_nl_2
- << "// TAO_IDL - Generated from" << be_nl
- << "// " << __FILE__ << ":" << __LINE__;
-
- std::string guard_suffix =
- std::string (this->S_) + std::string ("arg_traits");
-
- // This should be generated even for imported nodes. The ifdef
- // guard prevents multiple declarations.
- os.gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
+ return 0;
+ }
- os << be_nl_2
- << "template<>" << be_nl
- << "class "
- << this->S_ << "Arg_Traits<"
- << node->name () << ">" << be_idt_nl
- << ": public" << be_idt << be_idt_nl
- << "Object_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
- << node->name () << " *," << be_nl
- << node->name () << "_var," << be_nl
- << node->name () << "_out";
+ TAO_OutStream & os = *this->ctx_->stream ();
- // The SArgument classes don't need the traits parameter (yet?)
- if (ACE_OS::strlen (this->S_) == 0)
- {
- os << "," << be_nl
- << "TAO::Value_Traits<" << node->name () << ">";
- }
+ os << be_nl_2
+ << "// TAO_IDL - Generated from" << be_nl
+ << "// " << __FILE__ << ":" << __LINE__;
- os << "," << be_nl << this->insert_policy()
- << be_uidt_nl
- << ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
- << "{" << be_nl
- << "};";
+ os << be_nl_2
+ << "template<>" << be_nl
+ << "class "
+ << this->S_ << "Arg_Traits< ::"
+ << node->name () << ">" << be_idt_nl
+ << ": public" << be_idt << be_idt_nl
+ << "Object_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
+ << "::" << node->name () << " *," << be_nl
+ << "::" << node->name () << "_var," << be_nl
+ << "::" << node->name () << "_out";
- os.gen_endif ();
+ // The SArgument classes don't need the traits parameter (yet?)
+ if (ACE_OS::strlen (this->S_) == 0)
+ {
+ os << "," << be_nl
+ << "TAO::Value_Traits<" << node->name () << ">";
}
+ os << "," << be_nl << this->insert_policy()
+ << be_uidt_nl
+ << ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
+ << "{" << be_nl
+ << "};";
+
this->generated (node, true);
return 0;
}
@@ -265,53 +282,64 @@ be_visitor_arg_traits::visit_valuebox (be_valuebox *node)
int
be_visitor_arg_traits::visit_valuetype (be_valuetype *node)
{
- if (this->generated (node))
+ if (node->imported ())
{
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
return 0;
}
- if (node->seen_in_operation ())
+ if (this->generated (node))
{
- TAO_OutStream & os = *this->ctx_->stream ();
+ return 0;
+ }
- os << be_nl_2
- << "// TAO_IDL - Generated from" << be_nl
- << "// " << __FILE__ << ":" << __LINE__;
+ /// Put this here to prevent infinite recursion with recursive
+ /// valuetypes.
+ this->generated (node, true);
- std::string guard_suffix =
- std::string (this->S_) + std::string ("arg_traits");
+ TAO_OutStream & os = *this->ctx_->stream ();
- // This should be generated even for imported nodes. The ifdef
- // guard prevents multiple declarations.
- os.gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
+ os << be_nl_2
+ << "// TAO_IDL - Generated from" << be_nl
+ << "// " << __FILE__ << ":" << __LINE__;
- os << be_nl_2
- << "template<>" << be_nl
- << "class "
- << this->S_ << "Arg_Traits<"
- << node->name () << ">" << be_idt_nl
- << ": public" << be_idt << be_idt_nl
- << "Object_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
- << node->name () << " *," << be_nl
- << node->name () << "_var," << be_nl
- << node->name () << "_out";
+ std::string guard_suffix =
+ std::string (this->S_) + std::string ("arg_traits");
- // The SArgument classes don't need the traits parameter (yet?)
- if (ACE_OS::strlen (this->S_) == 0)
- {
- os << "," << be_nl
- << "TAO::Value_Traits<" << node->name () << ">";
- }
+ // The guard should be generated to prevent multiple declarations,
+ // since a forward declaration may appear more than once.
+ os.gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
- os << "," << be_nl << this->insert_policy()
- << be_uidt_nl
- << ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
- << "{" << be_nl
- << "};";
+ os << be_nl_2
+ << "template<>" << be_nl
+ << "class "
+ << this->S_ << "Arg_Traits< ::"
+ << node->name () << ">" << be_idt_nl
+ << ": public" << be_idt << be_idt_nl
+ << "Object_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
+ << "::" << node->name () << " *," << be_nl
+ << "::" << node->name () << "_var," << be_nl
+ << "::" << node->name () << "_out";
- os.gen_endif ();
+ // The SArgument classes don't need the traits parameter (yet?)
+ if (ACE_OS::strlen (this->S_) == 0)
+ {
+ os << "," << be_nl
+ << "TAO::Value_Traits<" << node->name () << ">";
}
+ os << "," << be_nl << this->insert_policy()
+ << be_uidt_nl
+ << ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
+ << "{" << be_nl
+ << "};";
+
+ os.gen_endif ();
+
if (this->visit_scope (node) != 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
@@ -320,13 +348,22 @@ be_visitor_arg_traits::visit_valuetype (be_valuetype *node)
-1);
}
- this->generated (node, true);
return 0;
}
int
be_visitor_arg_traits::visit_valuetype_fwd (be_valuetype_fwd *node)
{
+ if (node->imported ())
+ {
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
+ return 0;
+ }
+
if (this->generated (node))
{
return 0;
@@ -393,18 +430,21 @@ be_visitor_arg_traits::visit_operation (be_operation *node)
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
+ std::string guard_suffix =
+ std::string (this->S_) + std::string ("arg_traits");
+
+ // The guard should be generated to prevent multiple declarations,
+ // since a bounded (w)string of the same length may be used or typedef'd
+ // more than once.
+
+ os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
+
bool wide = (str->width () != 1);
*os << be_nl_2;
- bool const skel =
- (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_SS);
-
- // Avoid generating a duplicate structure in the skeleton
- // when generating Arg_Traits<> for ThruPOA and direct
- // collocation code.
- if (!skel
- || (skel && ACE_OS::strlen (this->S_) != 0))
+ // Avoid generating a duplicate structure in the skeleton.
+ if (ACE_OS::strlen (this->S_) == 0)
{
*os << "struct " << node->flat_name () << " {};"
<< be_nl_2;
@@ -424,6 +464,8 @@ be_visitor_arg_traits::visit_operation (be_operation *node)
<< be_uidt << be_uidt << be_uidt_nl
<< "{" << be_nl
<< "};";
+
+ os->gen_endif ();
}
}
@@ -432,8 +474,8 @@ be_visitor_arg_traits::visit_operation (be_operation *node)
if (this->visit_scope (node) != 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_visitor_arg_traits::"
- "visit_operation - visit scope failed\n"),
+ ACE_TEXT ("be_visitor_arg_traits::")
+ ACE_TEXT ("visit_operation - visit scope failed\n")),
-1);
}
@@ -468,6 +510,15 @@ be_visitor_arg_traits::visit_attribute (be_attribute *node)
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
+ std::string guard_suffix =
+ std::string (this->S_) + std::string ("arg_traits");
+
+ // The guard should be generated to prevent multiple declarations,
+ // since a bounded (w)string of the same length may be used or typedef'd
+ // more than once.
+
+ os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
+
bool wide = (st->width () != 1);
// It is legal IDL to declare a bounded (w)string as an operation
@@ -479,13 +530,8 @@ be_visitor_arg_traits::visit_attribute (be_attribute *node)
*os << be_nl;
- bool const skel =
- (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_SS);
-
- // Avoid generating a duplicate structure in the skeleton when
- // generating Arg_Traits<> for ThruPOA and direct collocation code.
- if (!skel
- || (skel && ACE_OS::strlen (this->S_) != 0))
+ // Avoid generating a duplicate structure in the skeleton.
+ if (ACE_OS::strlen (this->S_) == 0)
{
*os << "struct " << node->flat_name () << " {};"
<< be_nl_2;
@@ -506,6 +552,8 @@ be_visitor_arg_traits::visit_attribute (be_attribute *node)
<< "{" << be_nl
<< "};";
+ os->gen_endif ();
+
this->generated (node, true);
return 0;
}
@@ -542,6 +590,15 @@ be_visitor_arg_traits::visit_argument (be_argument *node)
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
+ std::string guard_suffix =
+ std::string (this->S_) + std::string ("arg_traits");
+
+ // The guard should be generated to prevent multiple declarations,
+ // since a bounded (w)string of the same length may be used or typedef'd
+ // more than once.
+
+ os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
+
bool wide = (st->width () != 1);
// It is legal IDL to declare a bounded (w)string as an operation
@@ -552,9 +609,6 @@ be_visitor_arg_traits::visit_argument (be_argument *node)
// parameter for Arg_Traits<>.
*os << be_nl_2;
- bool const skel =
- (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_SS);
-
AST_Decl *op = ScopeAsDecl (node->defined_in ());
AST_Decl *intf = ScopeAsDecl (op->defined_in ());
ACE_CString arg_flat_name (intf->flat_name ());
@@ -563,10 +617,8 @@ be_visitor_arg_traits::visit_argument (be_argument *node)
arg_flat_name += '_';
arg_flat_name += node->local_name ()->get_string ();
- // Avoid generating a duplicate structure in the skeleton when
- // generating Arg_Traits<> for ThruPOA and direct collocation code.
- if (!skel
- || (skel && ACE_OS::strlen (this->S_) != 0))
+ // Avoid generating a duplicate structure in the skeleton.
+ if (ACE_OS::strlen (this->S_) == 0)
{
*os << "struct " << arg_flat_name.c_str () << " {};"
<< be_nl_2;
@@ -588,6 +640,8 @@ be_visitor_arg_traits::visit_argument (be_argument *node)
<< "{" << be_nl
<< "};";
+ os->gen_endif ();
+
this->generated (node, true);
return 0;
}
@@ -595,54 +649,81 @@ be_visitor_arg_traits::visit_argument (be_argument *node)
int
be_visitor_arg_traits::visit_sequence (be_sequence *node)
{
- if (this->generated (node) || !node->seen_in_operation ())
+ if (node->imported ())
+ {
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
+ return 0;
+ }
+
+ if (this->generated (node))
{
return 0;
}
+ this->generated (node, true);
+
TAO_OutStream *os = this->ctx_->stream ();
be_typedef *alias = this->ctx_->alias ();
+ /// No arg traits for anonymous sequences.
+ if (alias == 0)
+ {
+ return 0;
+ }
+
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
+ AST_Type *bt = node->base_type ()->unaliased_type ();
+
std::string guard_suffix =
- std::string (this->S_) + std::string ("arg_traits");
+ std::string ("Seq_") + std::string (this->S_) + std::string ("arg_traits");
- // This should be generated even for imported nodes. The ifdef
- // guard prevents multiple declarations.
- os->gen_ifdef_macro (alias->flat_name (),
- guard_suffix.c_str (),
- false);
+ // The guard should be generated to prevent multiple declarations,
+ // since a sequence of a given element type may be typedef'd
+ // more than once.
+
+ os->gen_ifdef_macro (bt->flat_name (), guard_suffix.c_str (), false);
bool use_vec = (node->unbounded () && be_global->alt_mapping ());
UTL_ScopedName *sn = alias->name ();
*os << be_nl_2
<< "template<>" << be_nl
- << "class " << this->S_ << "Arg_Traits<" << sn << ">"
+ << "class " << this->S_ << "Arg_Traits< ::" << sn << ">"
<< be_idt_nl
<< ": public" << be_idt << be_idt_nl
<< (use_vec ? "Vector_" : "Var_Size_")
<< this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
- << sn << "," << be_nl
- << this->insert_policy() << be_uidt_nl
+ << "::" << sn << "," << be_nl
+ << this->insert_policy () << be_uidt_nl
<< ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
<< "{" << be_nl
<< "};";
-
os->gen_endif ();
-
- this->generated (node, true);
+
return 0;
}
int
be_visitor_arg_traits::visit_string (be_string *node)
{
- if ((this->generated (node) && !this->ctx_->alias())
- || !node->seen_in_operation ())
+ if (node->imported ())
+ {
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
+ return 0;
+ }
+
+ if (this->generated (node) && !this->ctx_->alias())
{
return 0;
}
@@ -665,12 +746,13 @@ be_visitor_arg_traits::visit_string (be_string *node)
std::string guard_suffix =
std::string (this->S_) + std::string ("arg_traits");
- // This should be generated even for imported nodes. The ifdef
- // guard prevents multiple declarations.
+ // The guard should be generated to prevent multiple declarations,
+ // since a bounded (w)string of the same length may be used or typedef'd
+ // more than once.
if (alias == 0)
{
- os->gen_ifdef_macro (node->flat_name(), guard_suffix.c_str (), false);
+ os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
}
else
{
@@ -703,13 +785,9 @@ be_visitor_arg_traits::visit_string (be_string *node)
delete [] bound_string;
}
- bool const skel =
- (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_SS);
-
- // Avoid generating a duplicate structure in the skeleton when
- // generating Arg_Traits<> for ThruPOA and direct collocation code.
- if (!skel
- || (skel && ACE_OS::strlen (this->S_) != 0))
+ // Avoid generating a duplicate structure in the skeleton since
+ // it has already been generated in *C.h.
+ if (ACE_OS::strlen (this->S_) == 0)
{
// A workaround 'dummy' type, since bounded (w)strings are all
// generated as typedefs of (w)char *.
@@ -751,7 +829,7 @@ be_visitor_arg_traits::visit_string (be_string *node)
<< this->insert_policy()
<< be_uidt << be_uidt_nl
<< ">"
- << be_uidt << be_uidt << be_uidt << be_uidt_nl
+ << be_uidt << be_uidt << be_uidt_nl
<< "{" << be_nl
<< "};";
@@ -764,33 +842,39 @@ be_visitor_arg_traits::visit_string (be_string *node)
int
be_visitor_arg_traits::visit_array (be_array *node)
{
- if (this->generated (node) || !node->seen_in_operation ())
+ if (node->imported ())
{
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
return 0;
}
- TAO_OutStream *os = this->ctx_->stream ();
+ // Add the alias check here because anonymous arrays can't be
+ // operation arguments.
+ if (this->generated (node) || this->ctx_->alias () == 0)
+ {
+ return 0;
+ }
- // This should be generated even for imported nodes. The ifdef guard prevents
- // multiple declarations.
- ACE_CString suffix (this->S_);
- suffix += "arg_traits";
- os->gen_ifdef_macro (node->flat_name (), suffix.c_str (), false);
+ TAO_OutStream *os = this->ctx_->stream ();
*os << be_nl_2
<< "template<>" << be_nl
<< "class "
- << this->S_ << "Arg_Traits<"
+ << this->S_ << "Arg_Traits< ::"
<< node->name () << "_tag>" << be_idt_nl
<< ": public" << be_idt << be_idt_nl;
*os << (node->size_type () == AST_Type::FIXED ? "Fixed" : "Var")
<< "_Array_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
- << node->name ()
+ << "::" << node->name ()
<< (node->size_type () == AST_Type::VARIABLE ? "_out" : "_var")
<< "," << be_nl;
- *os << node->name () << "_forany";
+ *os << "::" << node->name () << "_forany";
*os << "," << be_nl << this->insert_policy();
@@ -799,8 +883,6 @@ be_visitor_arg_traits::visit_array (be_array *node)
<< "{" << be_nl
<< "};";
- os->gen_endif ();
-
this->generated (node, true);
return 0;
}
@@ -808,7 +890,17 @@ be_visitor_arg_traits::visit_array (be_array *node)
int
be_visitor_arg_traits::visit_enum (be_enum *node)
{
- if (this->generated (node) || !node->seen_in_operation ())
+ if (node->imported ())
+ {
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
+ return 0;
+ }
+
+ if (this->generated (node))
{
return 0;
}
@@ -818,29 +910,20 @@ be_visitor_arg_traits::visit_enum (be_enum *node)
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
- std::string guard_suffix =
- std::string (this->S_) + std::string ("arg_traits");
-
- // This should be generated even for imported nodes. The ifdef
- // guard prevents multiple declarations.
- os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
-
*os << be_nl_2
<< "template<>" << be_nl
<< "class "
- << this->S_ << "Arg_Traits<"
+ << this->S_ << "Arg_Traits< ::"
<< node->name () << ">" << be_idt_nl
<< ": public" << be_idt << be_idt_nl;
*os << "Basic_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
- << node->name () << "," << be_nl
+ << "::" << node->name () << "," << be_nl
<< this->insert_policy() << be_uidt_nl
<< ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
<< "{" << be_nl
<< "};";
- os->gen_endif ();
-
this->generated (node, true);
return 0;
}
@@ -848,7 +931,17 @@ be_visitor_arg_traits::visit_enum (be_enum *node)
int
be_visitor_arg_traits::visit_structure (be_structure *node)
{
- if (this->generated (node) || !node->seen_in_operation ())
+ if (node->imported ())
+ {
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
+ return 0;
+ }
+
+ if (this->generated (node))
{
return 0;
}
@@ -860,30 +953,22 @@ be_visitor_arg_traits::visit_structure (be_structure *node)
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
- std::string guard_suffix =
- std::string (this->S_) + std::string ("arg_traits");
-
- // This should be generated even for imported nodes. The ifdef
- // guard prevents multiple declarations.
- os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
-
*os << be_nl_2
<< "template<>" << be_nl
<< "class "
- << this->S_ << "Arg_Traits<"
+ << this->S_ << "Arg_Traits< ::"
<< node->name () << ">" << be_idt_nl
<< ": public" << be_idt << be_idt_nl;
*os << (node->size_type () == AST_Type::FIXED ? "Fixed" : "Var")
<< "_Size_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl;
- *os << node->name () << "," << be_nl << this->insert_policy() << be_uidt_nl
+ *os << "::" << node->name () << "," << be_nl\
+ << this->insert_policy () << be_uidt_nl
<< ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
<< "{" << be_nl
<< "};";
- os->gen_endif ();
-
/* Set this before visiting the scope so things like
interface foo
@@ -950,13 +1035,24 @@ be_visitor_arg_traits::visit_field (be_field *node)
this->generated (node, true);
this->generated (bt, true);
+
return 0;
}
int
be_visitor_arg_traits::visit_union (be_union *node)
{
- if (this->generated (node) || !node->seen_in_operation ())
+ if (node->imported ())
+ {
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
+ return 0;
+ }
+
+ if (this->generated (node))
{
return 0;
}
@@ -968,31 +1064,23 @@ be_visitor_arg_traits::visit_union (be_union *node)
*os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
- std::string guard_suffix =
- std::string (this->S_) + std::string ("arg_traits");
-
- // This should be generated even for imported nodes. The ifdef
- // guard prevents multiple declarations.
- os->gen_ifdef_macro (node->flat_name (), guard_suffix.c_str (), false);
-
*os << be_nl_2
<< "template<>" << be_nl
<< "class "
- << this->S_ << "Arg_Traits<"
+ << this->S_ << "Arg_Traits< ::"
<< node->name () << ">" << be_idt_nl
<< ": public" << be_idt << be_idt_nl;
*os << (node->size_type () == AST_Type::FIXED ? "Fixed" : "Var")
<< "_Size_" << this->S_ << "Arg_Traits_T<" << be_idt << be_idt_nl
- << node->name () << "," << be_nl << this->insert_policy();
+ << "::" << node->name () << "," << be_nl
+ << this->insert_policy ();
*os << be_uidt_nl
<< ">" << be_uidt << be_uidt << be_uidt << be_uidt_nl
<< "{" << be_nl
<< "};";
- os->gen_endif ();
-
/* Set this before visiting the scope so things like
interface foo
@@ -1054,33 +1142,36 @@ be_visitor_arg_traits::visit_union_branch (be_union_branch *node)
int
be_visitor_arg_traits::visit_typedef (be_typedef *node)
{
- if (this->generated (node) || !node->seen_in_operation ())
+ if (node->imported ())
{
+ // Arg traits will presumably already be generated, but
+ // perhaps from another compilation unit. We mark it
+ // generated because if we get here from a typedef in
+ // the main file, we should skip it.
+ this->generated (node, true);
return 0;
}
+ if (this->generated (node))
+ {
+ return 0;
+ }
+
+ // Had to move up the spot where the typedef is marked as
+ // having its arg traits instantiation already generated.
+ // Consider the case where the base type is an interface,
+ // the typedef occurs inside the interface, and the typdef
+ // is used as an arg in an operation of a derived interface.
+ // When the scope of the base interface is visited
+ // as part of the arg traits visitation, we had infinite
+ // recursion and a stack overflow.
+ this->generated (node, true);
+
this->ctx_->alias (node);
// Make a decision based on the primitive base type.
be_type *bt = node->primitive_base_type ();
- // We can't set seen_in_operation_ for the base type
- // in the be_typedef operation, since valuetype OBV
- // constructor code may reset it to FALSE, and the base
- // type may be used unaliased in another arg somewhere.
- // So we just set it to TRUE here, since we know it
- // has to be TRUE at this point. We also set the
- // 'generated' flag to false if the original value
- // of 'seen_in_operation' was false, since the base
- // type could have been processed already, as a member
- // for example, before the typedef was seen, which
- // would short-circuit things.
- if (!bt->seen_in_operation ())
- {
- bt->seen_in_operation (true);
- this->generated (bt, false);
- }
-
if (!bt || (bt->accept (this) == -1))
{
ACE_ERROR_RETURN ((LM_ERROR,
@@ -1091,10 +1182,33 @@ be_visitor_arg_traits::visit_typedef (be_typedef *node)
}
this->ctx_->alias (0);
- this->generated (node, true);
return 0;
}
+int
+be_visitor_arg_traits::visit_component (be_component *node)
+{
+ return this->visit_interface (node);
+}
+
+int
+be_visitor_arg_traits::visit_component_fwd (be_component_fwd *node)
+{
+ return this->visit_interface_fwd (node);
+}
+
+int
+be_visitor_arg_traits::visit_connector (be_connector *node)
+{
+ return this->visit_component (node);
+}
+
+int
+be_visitor_arg_traits::visit_home (be_home *node)
+{
+ return this->visit_interface (node);
+}
+
bool
be_visitor_arg_traits::generated (be_decl *node) const
{
@@ -1102,9 +1216,9 @@ be_visitor_arg_traits::generated (be_decl *node) const
{
switch (this->ctx_->state ())
{
- case TAO_CodeGen::TAO_ROOT_CS:
+ case TAO_CodeGen::TAO_ROOT_CH:
return node->cli_arg_traits_gen ();
- case TAO_CodeGen::TAO_ROOT_SS:
+ case TAO_CodeGen::TAO_ROOT_SH:
return node->srv_arg_traits_gen ();
default:
return 0;
@@ -1122,10 +1236,10 @@ be_visitor_arg_traits::generated (be_decl *node,
{
switch (this->ctx_->state ())
{
- case TAO_CodeGen::TAO_ROOT_CS:
+ case TAO_CodeGen::TAO_ROOT_CH:
node->cli_arg_traits_gen (val);
return;
- case TAO_CodeGen::TAO_ROOT_SS:
+ case TAO_CodeGen::TAO_ROOT_SH:
node->srv_arg_traits_gen (val);
return;
default:
@@ -1136,36 +1250,19 @@ be_visitor_arg_traits::generated (be_decl *node,
node->srv_sarg_traits_gen (val);
}
-int
-be_visitor_arg_traits::visit_component (be_component *node)
-{
- return this->visit_interface (node);
-}
-
-int
-be_visitor_arg_traits::visit_component_fwd (be_component_fwd *node)
-{
- return this->visit_interface_fwd (node);
-}
-
-int
-be_visitor_arg_traits::visit_connector (be_connector *node)
-{
- return this->visit_component (node);
-}
-
-int
-be_visitor_arg_traits::visit_home (be_home *node)
-{
- return this->visit_interface (node);
-}
-
const char *
be_visitor_arg_traits::insert_policy (void)
{
if (be_global->any_support ())
{
- return "TAO::Any_Insert_Policy_Stream";
+ if (be_global->gen_anytypecode_adapter ())
+ {
+ return "TAO::Any_Insert_Policy_AnyTypeCode_Adapter";
+ }
+ else
+ {
+ return "TAO::Any_Insert_Policy_Stream";
+ }
}
else
{