summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp169
1 files changed, 36 insertions, 133 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp
index d7ce13eaedd..e34bc423157 100644
--- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_assign_cs.cpp
@@ -224,28 +224,13 @@ be_visitor_union_branch_public_assign_cs::visit_interface (be_interface *node)
os = this->ctx_->stream ();
os->indent (); // start from current indentation
-
- // So the template will work with the macro.
- *os << "typedef TAO_Object_Field_T<" << bt->name ()
- << ", " << bt->name () << "_var> OBJECT_FIELD;" << be_nl;
-
- if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
- // We are generating the copy constructor.
- *os << "ACE_NEW (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << "OBJECT_FIELD (" << bt->name ()
- << "::_duplicate (u.u_." << ub->local_name ()
- << "_->ptr ()))" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
- else
- // We are generating the assignment operator.
- *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << "OBJECT_FIELD (" << bt->name ()
- << "::_duplicate (u.u_." << ub->local_name ()
- << "_->ptr ()))," << be_nl
- << "*this" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
+ // set the discriminant to the appropriate label
+ *os << "this->u_." << ub->local_name ()
+ << "_ = new TAO_Object_Field_T<"
+ << bt->name () << ","
+ << bt->name () << "_var"
+ << "> (" << bt->name () << "::_duplicate (u.u_."
+ << ub->local_name () << "_->ptr ()));" << be_uidt_nl;
return 0;
}
@@ -277,28 +262,13 @@ be_visitor_union_branch_public_assign_cs::visit_interface_fwd (be_interface_fwd
os = this->ctx_->stream ();
os->indent (); // start from current indentation
-
- // So the template will work with the macro.
- *os << "typedef TAO_Object_Field_T<" << bt->name ()
- << ", " << bt->name () << "_var> OBJECT_FIELD;" << be_nl;
-
- if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
- // We are generating the copy constructor.
- *os << "ACE_NEW (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << "OBJECT_FIELD (" << bt->name ()
- << "::_duplicate (u.u_." << ub->local_name ()
- << "_->ptr ()))" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
- else
- // We are generating the assignment operator.
- *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << "OBJECT_FIELD (" << bt->name ()
- << "::_duplicate (u.u_." << ub->local_name ()
- << "_->ptr ()))," << be_nl
- << "*this" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
+ // set the discriminant to the appropriate label
+ *os << "this->u_." << ub->local_name ()
+ << "_ = new TAO_Object_Field_T<"
+ << bt->name () << ","
+ << bt->name () << "_var"
+ << "> (" << bt->name () << "::_duplicate (u.u_."
+ << ub->local_name () << "_->ptr ()));" << be_uidt_nl;
return 0;
}
@@ -334,29 +304,12 @@ be_visitor_union_branch_public_assign_cs::visit_predefined_type (be_predefined_t
switch (node->pt ())
{
case AST_PredefinedType::PT_pseudo:
+ *os << "this->u_." << ub->local_name () << "_ = ";
if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object"))
{
- // So the template will work with the macro.
- *os << "typedef TAO_Object_Field_T<CORBA::Object, "
- << "CORBA::Object_var> OBJECT_FIELD;" << be_nl;
-
- if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
- // We are generating the copy constructor.
- *os << "ACE_NEW (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << "OBJECT_FIELD (CORBA::Object"
- << "::_duplicate (u.u_." << ub->local_name ()
- << "_->ptr ()))" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
- else
- // We are generating the assignment operator.
- *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << "OBJECT_FIELD (CORBA::Object"
- << "::_duplicate (u.u_." << ub->local_name ()
- << "_->ptr ()))," << be_nl
- << "*this" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
+ *os << "new TAO_Object_Field_T<CORBA::Object,CORBA::Object_var> "
+ << "(CORBA::Object::_duplicate (u.u_."
+ << ub->local_name () << "_->ptr ()));" << be_uidt_nl;
}
else
{
@@ -365,19 +318,9 @@ be_visitor_union_branch_public_assign_cs::visit_predefined_type (be_predefined_t
}
break;
case AST_PredefinedType::PT_any:
- if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
- *os << "ACE_NEW (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << bt->name () << " (*u.u_."
- << ub->local_name () << "_)" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
- else
- *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << bt->name () << " (*u.u_."
- << ub->local_name () << "_)," << be_nl
- << "*this" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
+ *os << "this->u_." << ub->local_name () << "_ = new "
+ << bt->name () << " (*u.u_."
+ << ub->local_name () << "_);" << be_uidt_nl;
break;
case AST_PredefinedType::PT_void:
break;
@@ -418,26 +361,16 @@ be_visitor_union_branch_public_assign_cs::visit_sequence (be_sequence *node)
os = this->ctx_->stream ();
os->indent (); // start from current indentation
-
- if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
- *os << "ACE_NEW (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << bt->name () << " (*u.u_."
- << ub->local_name () << "_)" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
- else
- *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << bt->name () << " (*u.u_."
- << ub->local_name () << "_)," << be_nl
- << "*this" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
+ // set the discriminant to the appropriate label
+ *os << "this->u_." << ub->local_name () << "_ = new "
+ << bt->name () << " (*u.u_."
+ << ub->local_name () << "_);" << be_uidt_nl;
return 0;
}
int
-be_visitor_union_branch_public_assign_cs::visit_string (be_string *node)
+be_visitor_union_branch_public_assign_cs::visit_string (be_string *)
{
TAO_OutStream *os; // output stream
be_union_branch *ub =
@@ -456,20 +389,10 @@ be_visitor_union_branch_public_assign_cs::visit_string (be_string *node)
os = this->ctx_->stream ();
os->indent (); // start from current indentation
-
// set the discriminant to the appropriate label
- *os << "this->u_." << ub->local_name () << "_ = ";
-
- if (node->width () == sizeof (char))
- {
- *os << "CORBA::string_dup (u.u_.";
- }
- else
- {
- *os << "CORBA::wstring_dup (u.u_.";
- }
-
- *os << ub->local_name () << "_);" << be_uidt_nl;
+ *os << "this->u_." << ub->local_name () << "_ = "
+ << "CORBA::string_dup (u.u_."
+ << ub->local_name () << "_);" << be_uidt_nl;
return 0;
}
@@ -505,19 +428,9 @@ be_visitor_union_branch_public_assign_cs::visit_structure (be_structure *node)
if (bt->size_type () == be_type::VARIABLE
|| node->has_constructor ())
{
- if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
- *os << "ACE_NEW (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << bt->name () << " (*u.u_."
- << ub->local_name () << "_)" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
- else
- *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << bt->name () << " (*u.u_."
- << ub->local_name () << "_)," << be_nl
- << "*this" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
+ *os << "this->u_." << ub->local_name () << "_ = new "
+ << bt->name () << " (*u.u_."
+ << ub->local_name () << "_);" << be_uidt_nl;
}
else
{
@@ -576,20 +489,10 @@ be_visitor_union_branch_public_assign_cs::visit_union (be_union *node)
os = this->ctx_->stream ();
os->indent (); // start from current indentation
-
- if (this->ctx_->sub_state () == TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR)
- *os << "ACE_NEW (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << bt->name () << " (*u.u_."
- << ub->local_name () << "_)" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
- else
- *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl
- << "this->u_." << ub->local_name () << "_," << be_nl
- << bt->name () << " (*u.u_."
- << ub->local_name () << "_)," << be_nl
- << "*this" << be_uidt_nl
- << ");" << be_uidt << be_uidt_nl;
+ // set the discriminant to the appropriate label
+ *os << "this->u_." << ub->local_name () << "_ = new "
+ << bt->name () << " (*u.u_."
+ << ub->local_name () << "_);" << be_uidt_nl;
return 0;
}