diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-01-07 17:56:21 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-01-07 17:56:21 +0000 |
commit | 44ee2432b2271bef4c5c70ab91e55c38e1f639be (patch) | |
tree | 83f5d26b5db6cfcc52c47be1be7ad22e357fe023 | |
parent | 3b837a6e0ff1666fe4afc0c66d9b1d4df40b66f3 (diff) | |
download | ATCD-44ee2432b2271bef4c5c70ab91e55c38e1f639be.tar.gz |
Two bug fixes.
6 files changed, 203 insertions, 20 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp index f99e7fe0e62..6e4e17e4615 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/any_op_cs.cpp @@ -174,7 +174,7 @@ be_visitor_exception_any_op_cs::visit_exception (be_exception *node) << "else" << be_nl // decode failed << "{" << be_idt_nl << "delete ACE_const_cast (" << node->name () - << " *, _tao_elem);" << be_nl + << " *&, _tao_elem);" << be_nl << "_tao_elem = 0;" << be_uidt_nl << "}" << be_uidt_nl << "}" << be_uidt_nl diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp index d40e4c152f0..b10d1a57c39 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/any_op_cs.cpp @@ -179,7 +179,7 @@ be_visitor_sequence_any_op_cs::visit_sequence (be_sequence *node) << "else" << be_nl // decode failed << "{" << be_idt_nl << "delete ACE_const_cast (" << node->name () - << " *, _tao_elem);" << be_nl + << " *&, _tao_elem);" << be_nl << "_tao_elem = 0;" << be_uidt_nl << "}" << be_uidt_nl << "}" << be_uidt_nl diff --git a/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp index b2f7c4590ba..a0a21e95743 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/any_op_cs.cpp @@ -174,7 +174,7 @@ be_visitor_structure_any_op_cs::visit_structure (be_structure *node) << "else" << be_nl << "{" << be_idt_nl << "delete ACE_const_cast (" << node->name () - << " *, _tao_elem);" << be_nl + << " *&, _tao_elem);" << be_nl << "_tao_elem = 0;" << be_uidt_nl << "}" << be_uidt_nl << "}" << be_uidt_nl diff --git a/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp index 399f3e55921..46fa1abc78f 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/any_op_cs.cpp @@ -170,7 +170,7 @@ be_visitor_union_any_op_cs::visit_union (be_union *node) << "ACE_CATCHANY" << be_nl << "{" << be_idt_nl << "delete ACE_const_cast (" << node->name () - << " *, _tao_elem);" << be_nl + << " *&, _tao_elem);" << be_nl << "_tao_elem = 0;" << be_uidt_nl << "}" << be_nl << "ACE_ENDTRY;" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp index a2ff50ca202..6b29a434428 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp @@ -128,8 +128,22 @@ be_visitor_union_branch_cdr_op_ci::visit_array (be_array *node) << "_tao_union_helper (_tao_union_tmp);" << be_uidt_nl << "result = strm >> _tao_union_helper;" << be_nl << "if (result)" << be_idt_nl - << "_tao_union." << f->local_name () << "(" - << "_tao_union_tmp);" << be_uidt; + << "{" << be_idt_nl + << "_tao_union." << f->local_name () + << " (_tao_union_tmp);"; + + if (this->explicit_default ()) + { + *os << be_nl; + *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } + + *os << "}" << be_uidt; + return 0; case TAO_CodeGen::TAO_CDR_OUTPUT: @@ -215,8 +229,22 @@ be_visitor_union_branch_cdr_op_ci::visit_enum (be_enum *node) << ";" << be_nl << "result = strm >> _tao_union_tmp;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." << f->local_name () << " (" - << "_tao_union_tmp);" << be_uidt; + << "_tao_union_tmp);"; + + if (this->explicit_default ()) + { + *os << be_nl; + *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } + + *os << "}" << be_uidt; + return 0; case TAO_CodeGen::TAO_CDR_OUTPUT: @@ -294,8 +322,22 @@ be_visitor_union_branch_cdr_op_ci::visit_interface (be_interface *node) *os << node->name () << "_var _tao_union_tmp;" << be_nl << "result = strm >> _tao_union_tmp;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." - << f->local_name () << " (_tao_union_tmp.in ());" << be_uidt; + << f->local_name () << " (_tao_union_tmp.in ());"; + + if (this->explicit_default ()) + { + *os << be_nl; + *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } + + *os << "}" << be_uidt; + break; case TAO_CodeGen::TAO_CDR_OUTPUT: @@ -344,8 +386,22 @@ be_visitor_union_branch_cdr_op_ci::visit_interface_fwd (be_interface_fwd *node) *os << node->name () << "_var _tao_union_tmp;" << be_nl << "result = strm >> _tao_union_tmp;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." - << f->local_name () << " (_tao_union_tmp.in ());" << be_uidt; + << f->local_name () << " (_tao_union_tmp.in ());"; + + if (this->explicit_default ()) + { + *os << be_nl; + *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } + + *os << "}" << be_uidt; + break; case TAO_CodeGen::TAO_CDR_OUTPUT: @@ -405,8 +461,9 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no *os << "result = strm >> _tao_union_tmp.out ();" << be_nl << "if (result)" << be_idt_nl - << "_tao_union." << f->local_name () << " (_tao_union_tmp.in ());" - << be_uidt; + << "{" << be_idt_nl + << "_tao_union." << f->local_name () << " (_tao_union_tmp.in ());"; + } else if (node->pt () == AST_PredefinedType::PT_char) *os << "CORBA::Char _tao_union_tmp;" << be_nl @@ -414,38 +471,60 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no << "(_tao_union_tmp);" << be_nl << "result = strm >> _tao_union_helper;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." << f->local_name () - << "(_tao_union_tmp);" << be_uidt; + << " (_tao_union_tmp);"; + else if (node->pt () == AST_PredefinedType::PT_wchar) *os << "CORBA::WChar _tao_union_tmp;" << be_nl << "CORBA::Any::to_wchar _tao_union_helper " << "(_tao_union_tmp);" << be_nl << "result = strm >> _tao_union_helper;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." << f->local_name () - << "(_tao_union_tmp);" << be_uidt; + << " (_tao_union_tmp);"; + else if (node->pt () == AST_PredefinedType::PT_octet) *os << "CORBA::Octet _tao_union_tmp;" << be_nl << "CORBA::Any::to_octet _tao_union_helper " << "(_tao_union_tmp);" << be_nl << "result = strm >> _tao_union_helper;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." << f->local_name () - << "(_tao_union_tmp);" << be_uidt; + << " (_tao_union_tmp);"; + else if (node->pt () == AST_PredefinedType::PT_boolean) *os << "CORBA::Boolean _tao_union_tmp;" << be_nl << "CORBA::Any::to_boolean _tao_union_helper " << "(_tao_union_tmp);" << be_nl << "result = strm >> _tao_union_helper;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." << f->local_name () - << "(_tao_union_tmp);" << be_uidt; + << " (_tao_union_tmp);"; + else *os << node->name () << " _tao_union_tmp;" << be_nl << "result = strm >> _tao_union_tmp;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." << f->local_name () - << " (_tao_union_tmp);" << be_uidt; + << " (_tao_union_tmp);"; + + if (this->explicit_default ()) + { + *os << be_nl; + *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } + + *os << "}" << be_uidt; + break; case TAO_CodeGen::TAO_CDR_OUTPUT: @@ -524,8 +603,22 @@ be_visitor_union_branch_cdr_op_ci::visit_sequence (be_sequence *node) *os << " _tao_union_tmp;" << be_nl << "result = strm >> _tao_union_tmp;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." - << f->local_name () << " (_tao_union_tmp);" << be_uidt; + << f->local_name () << " (_tao_union_tmp);"; + + if (this->explicit_default ()) + { + *os << be_nl; + *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } + + *os << "}" << be_uidt; + return 0; } @@ -616,8 +709,22 @@ be_visitor_union_branch_cdr_op_ci::visit_string (be_string *node) *os << "result = strm >> _tao_union_tmp.out ();" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." - << f->local_name () << " (_tao_union_tmp);" << be_uidt; + << f->local_name () << " (_tao_union_tmp);"; + + if (this->explicit_default ()) + { + *os << be_nl; + *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } + + *os << "}" << be_uidt; + break; case TAO_CodeGen::TAO_CDR_OUTPUT: @@ -665,8 +772,22 @@ be_visitor_union_branch_cdr_op_ci::visit_structure (be_structure *node) *os << node->name () << " _tao_union_tmp;" << be_nl << "result = strm >> _tao_union_tmp;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." << f->local_name () - << " (_tao_union_tmp);" << be_uidt; + << " (_tao_union_tmp);"; + + if (this->explicit_default ()) + { + *os << be_nl; + *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } + + *os << "}" << be_uidt; + return 0; case TAO_CodeGen::TAO_CDR_OUTPUT: @@ -769,8 +890,22 @@ be_visitor_union_branch_cdr_op_ci::visit_union (be_union *node) << ";" << be_nl << "result = strm >> _tao_union_tmp;" << be_nl << "if (result)" << be_idt_nl + << "{" << be_idt_nl << "_tao_union." << f->local_name () << " (" - << "_tao_union_tmp);" << be_uidt; + << "_tao_union_tmp);"; + + if (this->explicit_default ()) + { + *os << be_nl; + *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; + } + else + { + *os << be_uidt_nl; + } + + *os << "}" << be_uidt; + return 0; case TAO_CodeGen::TAO_CDR_OUTPUT: @@ -823,3 +958,49 @@ be_visitor_union_branch_cdr_op_ci::visit_union (be_union *node) } return 0; } + +int +be_visitor_union_branch_cdr_op_ci::explicit_default (void) +{ + be_union *bu = be_union::narrow_from_decl (this->ctx_->scope ()); + int def_index = bu->default_index (); + + if (def_index != -1) + { + be_union_branch *ub = + be_union_branch::narrow_from_decl (this->ctx_->node ()); + + // instantiate a scope iterator. + UTL_ScopeActiveIterator *si = + new UTL_ScopeActiveIterator (bu, + UTL_Scope::IK_decls); + + int i = 0; // counter + be_union_branch *bub; // union branch node + AST_Decl *d; // temp node + + while (!(si->is_done ())) + { + // get the next AST decl node + d = si->item (); + + if (!d->imported ()) + bub = be_union_branch::narrow_from_decl (d); + + if (bub == ub) + { + delete si; + return (i == def_index); + } + else + { + i++; + si->next (); + } + } + + delete si; + } + + return 0; +} diff --git a/TAO/TAO_IDL/be_include/be_visitor_union_branch/cdr_op_ci.h b/TAO/TAO_IDL/be_include/be_visitor_union_branch/cdr_op_ci.h index 536fcbf9cce..1a4b582c641 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_union_branch/cdr_op_ci.h +++ b/TAO/TAO_IDL/be_include/be_visitor_union_branch/cdr_op_ci.h @@ -73,6 +73,8 @@ public: virtual int visit_union (be_union *node); // visit union type + virtual int explicit_default (void); + // extra code generation for an explicit default case }; #endif /* _BE_VISITOR_UNION_BRANCH_CDR_OP_CI_H_ */ |