diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-03-25 07:53:56 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2005-03-25 07:53:56 +0000 |
commit | a6f6b72179bd8562577bc3dfec26bc7b997ded90 (patch) | |
tree | c6bcc9bc0ef153c933c295caea4c9993580a9cda | |
parent | db6aeb207578f95af526314690aa529cbb2e0e5f (diff) | |
download | ATCD-a6f6b72179bd8562577bc3dfec26bc7b997ded90.tar.gz |
*** empty log message ***
4 files changed, 457 insertions, 436 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp index 163a46b15ac..f2ae5961b22 100644 --- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp @@ -371,9 +371,9 @@ be_visitor_typecode_defn::visit_type (be_type *node) // case AST_Decl::NT_typedef: // *os << "CORBA::tk_alias"; // break; - case AST_Decl::NT_union: - *os << "CORBA::tk_union"; - break; +// case AST_Decl::NT_union: +// *os << "CORBA::tk_union"; +// break; default: return -1; // error } @@ -1923,336 +1923,336 @@ be_visitor_typecode_defn::gen_encapsulation (be_array *node) // return 0; // } -int -be_visitor_typecode_defn::gen_typecode (be_union *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream +// int +// be_visitor_typecode_defn::gen_typecode (be_union *node) +// { +// TAO_OutStream *os = this->ctx_->stream (); // output stream - os->indent (); // start from whatever indentation level we were at +// os->indent (); // start from whatever indentation level we were at - // check if we are repeated - const be_visitor_typecode_defn::QNode *qnode = - this->queue_lookup (this->tc_queue_, node); +// // check if we are repeated +// const be_visitor_typecode_defn::QNode *qnode = +// this->queue_lookup (this->tc_queue_, node); - ACE_Unbounded_Queue<AST_Type *> list; +// ACE_Unbounded_Queue<AST_Type *> list; - if (qnode && (be_global->opt_tc () || node->in_recursion (list))) - { - // we are repeated, so we must generate an indirection here - *os << "0xffffffff, // indirection" << be_nl; - this->tc_offset_ += sizeof (ACE_CDR::ULong); - // the offset must point to the tc_kind value of the first occurrence of - // this type - os->print ("0x%x, // negative offset (%d)\n", - (qnode->offset - this->tc_offset_), - (qnode->offset - this->tc_offset_)); - this->tc_offset_ += sizeof (ACE_CDR::ULong); - } - else - { - // Insert node into tc_queue_ in case the node is involved in - // some form of recursion. - if (this->queue_insert (this->tc_queue_, node, this->tc_offset_) == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::" - "visit_type - " - "queue insert failed\n"), - -1); - } +// if (qnode && (be_global->opt_tc () || node->in_recursion (list))) +// { +// // we are repeated, so we must generate an indirection here +// *os << "0xffffffff, // indirection" << be_nl; +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// // the offset must point to the tc_kind value of the first occurrence of +// // this type +// os->print ("0x%x, // negative offset (%d)\n", +// (qnode->offset - this->tc_offset_), +// (qnode->offset - this->tc_offset_)); +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// } +// else +// { +// // Insert node into tc_queue_ in case the node is involved in +// // some form of recursion. +// if (this->queue_insert (this->tc_queue_, node, this->tc_offset_) == 0) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// "(%N:%l) be_visitor_typecode_defn::" +// "visit_type - " +// "queue insert failed\n"), +// -1); +// } - *os << "CORBA::tk_union, // typecode kind" << be_nl; - // size of the enum - this->tc_offset_ += sizeof (ACE_CDR::ULong); +// *os << "CORBA::tk_union, // typecode kind" << be_nl; +// // size of the enum +// this->tc_offset_ += sizeof (ACE_CDR::ULong); - { - Scoped_Compute_Queue_Guard guard (this); - - // emit the encapsulation length - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); - - if (node->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) - be_visitor_typecode_defn") - ACE_TEXT ("gen_typecode (union) - ") - ACE_TEXT ("Failed to get encap length\n")), - -1); - } - } +// { +// Scoped_Compute_Queue_Guard guard (this); - *os << this->computed_encap_len_ << ", // encapsulation length" - << be_idt << "\n"; - // size of the encap length - this->tc_offset_ += sizeof (ACE_CDR::ULong); +// // emit the encapsulation length +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); - // now emit the encapsulation - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAPSULATION); +// if (node->accept (this) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// ACE_TEXT ("(%N:%l) - be_visitor_typecode_defn") +// ACE_TEXT ("gen_typecode (union) - ") +// ACE_TEXT ("Failed to get encap length\n")), +// -1); +// } +// } - if (node->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") - ACE_TEXT ("::gen_typecode (union) - ") - ACE_TEXT ("failed to generate encapsulation\n")), - -1); - } +// *os << this->computed_encap_len_ << ", // encapsulation length" +// << be_idt << "\n"; +// // size of the encap length +// this->tc_offset_ += sizeof (ACE_CDR::ULong); - *os << be_uidt << "\n"; - } - return 0; -} +// // now emit the encapsulation +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAPSULATION); -int -be_visitor_typecode_defn::gen_encapsulation (be_union *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_type *discrim; +// if (node->accept (this) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") +// ACE_TEXT ("::gen_typecode (union) - ") +// ACE_TEXT ("failed to generate encapsulation\n")), +// -1); +// } - os->indent (); // start from whatever indentation level we were at +// *os << be_uidt << "\n"; +// } +// return 0; +// } - *os << "TAO_ENCAP_BYTE_ORDER, // byte order" << be_nl; - // size of the encapsulation byte order flag. Although it is 1 byte, the - // aligned size is 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); +// int +// be_visitor_typecode_defn::gen_encapsulation (be_union *node) +// { +// TAO_OutStream *os = this->ctx_->stream (); // output stream +// be_type *discrim; - // generate repoID - this->gen_repoID (node); +// os->indent (); // start from whatever indentation level we were at - // generate name - this->gen_name (node); +// *os << "TAO_ENCAP_BYTE_ORDER, // byte order" << be_nl; +// // size of the encapsulation byte order flag. Although it is 1 byte, the +// // aligned size is 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); - // generate typecode for discriminant - discrim = be_type::narrow_from_decl (node->disc_type ()); - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE_NESTED); +// // generate repoID +// this->gen_repoID (node); - if (discrim->accept (this) == -1) - { - ACE_ERROR ((LM_ERROR, "be_union: cannot generate typecode for discriminant\n")); - return -1; - } +// // generate name +// this->gen_name (node); - // generate the default used flag - *os << node->default_index () << ", // default used index" << be_nl; - // size of the default index used - this->tc_offset_ += sizeof (ACE_CDR::ULong); +// // generate typecode for discriminant +// discrim = be_type::narrow_from_decl (node->disc_type ()); +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE_NESTED); - // generate the member count - *os << node->nfields () << ", // member count" << be_nl; - // size of the member count - this->tc_offset_ += sizeof (ACE_CDR::ULong); +// if (discrim->accept (this) == -1) +// { +// ACE_ERROR ((LM_ERROR, "be_union: cannot generate typecode for discriminant\n")); +// return -1; +// } - // hand over to the scope to generate the typecode for elements - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE); +// // generate the default used flag +// *os << node->default_index () << ", // default used index" << be_nl; +// // size of the default index used +// this->tc_offset_ += sizeof (ACE_CDR::ULong); - // Set the scope node as "node" in which the code is being - // generated so that elements in the node's scope can use it - // for code generation. - this->ctx_->scope (node); +// // generate the member count +// *os << node->nfields () << ", // member count" << be_nl; +// // size of the member count +// this->tc_offset_ += sizeof (ACE_CDR::ULong); - if (node->accept (this) == -1) - { - ACE_ERROR ((LM_ERROR, "be_union: cannot generate code for members\n")); - return -1; - } +// // hand over to the scope to generate the typecode for elements +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE); - return 0; -} +// // Set the scope node as "node" in which the code is being +// // generated so that elements in the node's scope can use it +// // for code generation. +// this->ctx_->scope (node); -int -be_visitor_typecode_defn::gen_encapsulation (be_union_branch *node) -{ - TAO_OutStream *os = this->ctx_->stream (); // output stream - be_type *bt; // our type node +// if (node->accept (this) == -1) +// { +// ACE_ERROR ((LM_ERROR, "be_union: cannot generate code for members\n")); +// return -1; +// } - be_union *ub = this->ctx_->be_scope_as_union (); +// return 0; +// } - ACE_UINT32 buf[1]; - ACE_OS::memset (buf, 0, sizeof (buf)); +// int +// be_visitor_typecode_defn::gen_encapsulation (be_union_branch *node) +// { +// TAO_OutStream *os = this->ctx_->stream (); // output stream +// be_type *bt; // our type node - os->indent (); +// be_union *ub = this->ctx_->be_scope_as_union (); - // Emit the case label value. We use only the first value in the - // label list even if there are multiple case labels for this node. - // The TypeCode class does not have any way of dealing with - // any count but member count. We make sure in the generation of - // the union's _discriminant(0 function (called by (de)marshaling - // code) that the same value is returned that is generated here. - if (node->label (0)->label_kind () == AST_UnionLabel::UL_label) - { - AST_Expression *expression = node->label (0)->label_val (); - AST_Expression::AST_ExprValue *ev = expression->ev (); +// ACE_UINT32 buf[1]; +// ACE_OS::memset (buf, 0, sizeof (buf)); - switch (ub->udisc_type ()) - { - case AST_Expression::EV_char: - os->print ("ACE_IDL_NCTOHL (0x%02.2x)", - (unsigned char)ev->u.cval); - // size of char aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_bool: - os->print ("ACE_IDL_NCTOHL (0x%02.2x)", - (unsigned char)ev->u.bval); - // size of bool aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_wchar: - case AST_Expression::EV_short: - os->print ("ACE_IDL_NSTOHL (0x%04.4x)", - (unsigned short)ev->u.sval); - // size of short/wchar aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_ushort: - os->print ("ACE_IDL_NSTOHL (0x%04.4x)", - (unsigned short)ev->u.usval); - // size of unsigned short aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_long: - os->print ("0x%08.8x", (unsigned long)ev->u.lval); - // size of long aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_ulong: - os->print ("0x%08.8x", ev->u.ulval); - // size of unsigned long aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_enum: - // enum - os->print ("0x%08.8x", (unsigned long)ev->u.eval); - // size of any aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_ulonglong: - case AST_Expression::EV_longlong: - // unimplemented yet - - default: - ACE_ERROR_RETURN ((LM_DEBUG, - "be_union_branch: (%N:%l) Label value " - "type (%d) is invalid\n", ev->et), -1); - ACE_NOTREACHED (break;) - } +// os->indent (); - *os << ", // union case label (evaluated value)" << be_nl; - } - else - { - // default case - be_union::DefaultValue dv; +// // Emit the case label value. We use only the first value in the +// // label list even if there are multiple case labels for this node. +// // The TypeCode class does not have any way of dealing with +// // any count but member count. We make sure in the generation of +// // the union's _discriminant(0 function (called by (de)marshaling +// // code) that the same value is returned that is generated here. +// if (node->label (0)->label_kind () == AST_UnionLabel::UL_label) +// { +// AST_Expression *expression = node->label (0)->label_val (); +// AST_Expression::AST_ExprValue *ev = expression->ev (); - if (ub->default_value (dv) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typecode::" - "gen_encapsulation (union_branch) - " - "computing default value failed\n"), - -1); - } +// switch (ub->udisc_type ()) +// { +// case AST_Expression::EV_char: +// os->print ("ACE_IDL_NCTOHL (0x%02.2x)", +// (unsigned char)ev->u.cval); +// // size of char aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; - switch (ub->udisc_type ()) - { - case AST_Expression::EV_char: - os->print ("ACE_IDL_NCTOHL (0x%02.2x)", - (unsigned char)dv.u.char_val); - // size of bool/char aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_bool: - os->print ("ACE_IDL_NCTOHL (0x%02.2x)", - (unsigned char)dv.u.bool_val); - // size of bool/char aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_wchar: - os->print ("ACE_IDL_NSTOHL (0x%04.4x)", - (unsigned short)dv.u.wchar_val); - // size of short/wchar aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_short: - os->print ("ACE_IDL_NSTOHL (0x%04.4x)", - (unsigned short)dv.u.short_val); - // size of short/wchar aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_ushort: - os->print ("ACE_IDL_NSTOHL (0x%04.4x)", - (unsigned short)dv.u.ushort_val); - // size of short/wchar aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_long: - os->print ("0x%08.8x", (unsigned long)dv.u.long_val); - // size of short/wchar aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_ulong: - os->print ("0x%08.8x", (unsigned long)dv.u.ulong_val); - // size of short/wchar aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_enum: - // enum - os->print ("0x%08.8x", (unsigned long)dv.u.enum_val); - // size of short/wchar aligned to 4 bytes - this->tc_offset_ += sizeof (ACE_CDR::ULong); - break; - - case AST_Expression::EV_ulonglong: - case AST_Expression::EV_longlong: - // unimplemented yet - - default: - ACE_ERROR_RETURN ((LM_DEBUG, - "be_union_branch: (%N:%l) Label value " - "type (%d) is invalid\n", - ub->udisc_type ()), - -1); - ACE_NOTREACHED (break;) - } +// case AST_Expression::EV_bool: +// os->print ("ACE_IDL_NCTOHL (0x%02.2x)", +// (unsigned char)ev->u.bval); +// // size of bool aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; - *os << ", // union default label (evaluated value)" << be_nl; - } +// case AST_Expression::EV_wchar: +// case AST_Expression::EV_short: +// os->print ("ACE_IDL_NSTOHL (0x%04.4x)", +// (unsigned short)ev->u.sval); +// // size of short/wchar aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; - // emit name - this->gen_name (node); +// case AST_Expression::EV_ushort: +// os->print ("ACE_IDL_NSTOHL (0x%04.4x)", +// (unsigned short)ev->u.usval); +// // size of unsigned short aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; - // hand over code generation to our type node - bt = be_type::narrow_from_decl (node->field_type ()); - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE_NESTED); +// case AST_Expression::EV_long: +// os->print ("0x%08.8x", (unsigned long)ev->u.lval); +// // size of long aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; - if (!bt || bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") - ACE_TEXT ("::gen_encapsulation (union_branch) - ") - ACE_TEXT ("failed to generate typecode\n") - ), - -1); - } +// case AST_Expression::EV_ulong: +// os->print ("0x%08.8x", ev->u.ulval); +// // size of unsigned long aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; - // revert the state - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE); - return 0; -} +// case AST_Expression::EV_enum: +// // enum +// os->print ("0x%08.8x", (unsigned long)ev->u.eval); +// // size of any aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; + +// case AST_Expression::EV_ulonglong: +// case AST_Expression::EV_longlong: +// // unimplemented yet + +// default: +// ACE_ERROR_RETURN ((LM_DEBUG, +// "be_union_branch: (%N:%l) Label value " +// "type (%d) is invalid\n", ev->et), -1); +// ACE_NOTREACHED (break;) +// } + +// *os << ", // union case label (evaluated value)" << be_nl; +// } +// else +// { +// // default case +// be_union::DefaultValue dv; + +// if (ub->default_value (dv) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// "(%N:%l) be_visitor_typecode::" +// "gen_encapsulation (union_branch) - " +// "computing default value failed\n"), +// -1); +// } + +// switch (ub->udisc_type ()) +// { +// case AST_Expression::EV_char: +// os->print ("ACE_IDL_NCTOHL (0x%02.2x)", +// (unsigned char)dv.u.char_val); +// // size of bool/char aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; + +// case AST_Expression::EV_bool: +// os->print ("ACE_IDL_NCTOHL (0x%02.2x)", +// (unsigned char)dv.u.bool_val); +// // size of bool/char aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; + +// case AST_Expression::EV_wchar: +// os->print ("ACE_IDL_NSTOHL (0x%04.4x)", +// (unsigned short)dv.u.wchar_val); +// // size of short/wchar aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; + +// case AST_Expression::EV_short: +// os->print ("ACE_IDL_NSTOHL (0x%04.4x)", +// (unsigned short)dv.u.short_val); +// // size of short/wchar aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; + +// case AST_Expression::EV_ushort: +// os->print ("ACE_IDL_NSTOHL (0x%04.4x)", +// (unsigned short)dv.u.ushort_val); +// // size of short/wchar aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; + +// case AST_Expression::EV_long: +// os->print ("0x%08.8x", (unsigned long)dv.u.long_val); +// // size of short/wchar aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; + +// case AST_Expression::EV_ulong: +// os->print ("0x%08.8x", (unsigned long)dv.u.ulong_val); +// // size of short/wchar aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; + +// case AST_Expression::EV_enum: +// // enum +// os->print ("0x%08.8x", (unsigned long)dv.u.enum_val); +// // size of short/wchar aligned to 4 bytes +// this->tc_offset_ += sizeof (ACE_CDR::ULong); +// break; + +// case AST_Expression::EV_ulonglong: +// case AST_Expression::EV_longlong: +// // unimplemented yet + +// default: +// ACE_ERROR_RETURN ((LM_DEBUG, +// "be_union_branch: (%N:%l) Label value " +// "type (%d) is invalid\n", +// ub->udisc_type ()), +// -1); +// ACE_NOTREACHED (break;) +// } + +// *os << ", // union default label (evaluated value)" << be_nl; +// } + +// // emit name +// this->gen_name (node); + +// // hand over code generation to our type node +// bt = be_type::narrow_from_decl (node->field_type ()); +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE_NESTED); + +// if (!bt || bt->accept (this) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") +// ACE_TEXT ("::gen_encapsulation (union_branch) - ") +// ACE_TEXT ("failed to generate typecode\n") +// ), +// -1); +// } + +// // revert the state +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE); +// return 0; +// } // int // be_visitor_typecode_defn::gen_typecode (be_valuetype *node) @@ -3149,158 +3149,158 @@ be_visitor_typecode_defn::compute_encap_length (be_array *node) // } -ACE_CDR::Long -be_visitor_typecode_defn::compute_tc_size (be_union *node) -{ - // while computing the encapsulation length we must keep in mind the typecode - // that has gotten generated until this point. Hence, we must first check the - // "tc_queue" to ensure if are already there somewhere in a previous - // encapsulation in which case we must count only the bytes for the - // indirection. If we are not already generated, we must then check if we - // have already been counted in the current computation or not by checking - // for our presence in the compute queue. In both cases, we only include the - // 8 bytes in the computation - ACE_Unbounded_Queue<AST_Type *> list; - - if ((be_global->opt_tc () || node->in_recursion (list)) - && (this->queue_lookup (this->tc_queue_, node) - || this->queue_lookup (this->compute_queue_, node))) - { - this->computed_tc_size_ = 4 + 4; - } - else - { - // Insert node into tc_queue_ in case the node is involved in - // some form of recursion. - if (this->queue_insert (this->compute_queue_, - node, - this->tc_offset_) - == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::" - "compute_tc_size (union) - " - "queue insert failed\n"), - -1); - } +// ACE_CDR::Long +// be_visitor_typecode_defn::compute_tc_size (be_union *node) +// { +// // while computing the encapsulation length we must keep in mind the typecode +// // that has gotten generated until this point. Hence, we must first check the +// // "tc_queue" to ensure if are already there somewhere in a previous +// // encapsulation in which case we must count only the bytes for the +// // indirection. If we are not already generated, we must then check if we +// // have already been counted in the current computation or not by checking +// // for our presence in the compute queue. In both cases, we only include the +// // 8 bytes in the computation +// ACE_Unbounded_Queue<AST_Type *> list; - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); +// if ((be_global->opt_tc () || node->in_recursion (list)) +// && (this->queue_lookup (this->tc_queue_, node) +// || this->queue_lookup (this->compute_queue_, node))) +// { +// this->computed_tc_size_ = 4 + 4; +// } +// else +// { +// // Insert node into tc_queue_ in case the node is involved in +// // some form of recursion. +// if (this->queue_insert (this->compute_queue_, +// node, +// this->tc_offset_) +// == 0) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// "(%N:%l) be_visitor_typecode_defn::" +// "compute_tc_size (union) - " +// "queue insert failed\n"), +// -1); +// } - if (node->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") - ACE_TEXT ("::compute_tc_size (union) - ") - ACE_TEXT ("cannot compute encap len\n")), - -1); - } +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); - this->computed_tc_size_ = 4 + 4 + this->computed_encap_len_; - } +// if (node->accept (this) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") +// ACE_TEXT ("::compute_tc_size (union) - ") +// ACE_TEXT ("cannot compute encap len\n")), +// -1); +// } - return this->computed_tc_size_; -} +// this->computed_tc_size_ = 4 + 4 + this->computed_encap_len_; +// } +// return this->computed_tc_size_; +// } -ACE_CDR::Long -be_visitor_typecode_defn::compute_encap_length (be_union *node) -{ - be_type *discrim; - ACE_CDR::Long encap_len = 4; // holds the byte order flag +// ACE_CDR::Long +// be_visitor_typecode_defn::compute_encap_length (be_union *node) +// { +// be_type *discrim; - encap_len += this->repoID_encap_len (node); // for repoID +// ACE_CDR::Long encap_len = 4; // holds the byte order flag - // do the same thing for the local name - encap_len += this->name_encap_len (node); // for name +// encap_len += this->repoID_encap_len (node); // for repoID - // add encapsulation size of discriminant typecode - discrim = be_type::narrow_from_decl (node->disc_type ()); - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TC_SIZE); +// // do the same thing for the local name +// encap_len += this->name_encap_len (node); // for name - if (!discrim || discrim->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") - ACE_TEXT ("::compute_encap_len (union) - ") - ACE_TEXT ("cannot compute tc size\n")), - -1); - } +// // add encapsulation size of discriminant typecode +// discrim = be_type::narrow_from_decl (node->disc_type ()); +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TC_SIZE); - encap_len += this->computed_tc_size_; +// if (!discrim || discrim->accept (this) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") +// ACE_TEXT ("::compute_encap_len (union) - ") +// ACE_TEXT ("cannot compute tc size\n")), +// -1); +// } - encap_len += 4; // to hold the "default used" flag - encap_len += 4; // to hold the member count +// encap_len += this->computed_tc_size_; - // save the current value of scope len and start with a fresh one for our - // scope length computation - if (this->push (this->computed_scope_encap_len_) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") - ACE_TEXT ("::compute_encap_len (union) - ") - ACE_TEXT ("push failed\n")), - -1); - } - this->computed_scope_encap_len_ = 0; +// encap_len += 4; // to hold the "default used" flag +// encap_len += 4; // to hold the member count - // compute encap length for members - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE_LEN); +// // save the current value of scope len and start with a fresh one for our +// // scope length computation +// if (this->push (this->computed_scope_encap_len_) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") +// ACE_TEXT ("::compute_encap_len (union) - ") +// ACE_TEXT ("push failed\n")), +// -1); +// } +// this->computed_scope_encap_len_ = 0; - if (node->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") - ACE_TEXT ("::compute_encap_len (union) - ") - ACE_TEXT ("cannot compute scope tc size\n")), - -1); - } +// // compute encap length for members +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE_LEN); - this->computed_encap_len_ = encap_len + this->computed_scope_encap_len_; +// if (node->accept (this) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") +// ACE_TEXT ("::compute_encap_len (union) - ") +// ACE_TEXT ("cannot compute scope tc size\n")), +// -1); +// } - // pop off the previous value of computed_scope_len_ - if (this->pop (this->computed_scope_encap_len_) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") - ACE_TEXT ("::compute_encap_len (union) - ") - ACE_TEXT ("pop failed\n")), - -1); - } +// this->computed_encap_len_ = encap_len + this->computed_scope_encap_len_; - return this->computed_encap_len_; -} +// // pop off the previous value of computed_scope_len_ +// if (this->pop (this->computed_scope_encap_len_) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") +// ACE_TEXT ("::compute_encap_len (union) - ") +// ACE_TEXT ("pop failed\n")), +// -1); +// } + +// return this->computed_encap_len_; +// } -ACE_CDR::Long -be_visitor_typecode_defn::compute_encap_length (be_union_branch *node) -{ - be_type *bt; +// ACE_CDR::Long +// be_visitor_typecode_defn::compute_encap_length (be_union_branch *node) +// { +// be_type *bt; - ACE_CDR::Long encap_len = 0; +// ACE_CDR::Long encap_len = 0; - encap_len += 4; // case label; - encap_len += this->name_encap_len (node); // for name +// encap_len += 4; // case label; +// encap_len += this->name_encap_len (node); // for name - bt = be_type::narrow_from_decl (node->field_type ()); - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TC_SIZE); +// bt = be_type::narrow_from_decl (node->field_type ()); +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TC_SIZE); - if (!bt || bt->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") - ACE_TEXT ("::compute_encap_len (union branch) - ") - ACE_TEXT ("cannot compute tc size\n")), - -1); - } +// if (!bt || bt->accept (this) == -1) +// { +// ACE_ERROR_RETURN ((LM_ERROR, +// ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") +// ACE_TEXT ("::compute_encap_len (union branch) - ") +// ACE_TEXT ("cannot compute tc size\n")), +// -1); +// } - encap_len += this->computed_tc_size_; +// encap_len += this->computed_tc_size_; - this->computed_encap_len_ = encap_len; +// this->computed_encap_len_ = encap_len; - this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE_LEN); - return this->computed_encap_len_; -} +// this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE_LEN); +// return this->computed_encap_len_; +// } // ACE_CDR::Long // be_visitor_typecode_defn::compute_tc_size (be_valuetype *node) diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp index 2a0aed9082c..09b47ce52e6 100644 --- a/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp @@ -54,7 +54,8 @@ TAO::be_visitor_union_typecode::visit_union (be_union * node) << "[] =" << be_idt_nl << "{" << be_idt_nl; - if (this->visit_cases (node) != 0) + be_union_branch * default_case = 0; + if (this->visit_cases (node, default_case) != 0) return -1; os << be_uidt_nl @@ -63,7 +64,8 @@ TAO::be_visitor_union_typecode::visit_union (be_union * node) // Generate the TypeCode instantiation. os << "static TAO::TypeCode::Union<char const *," << be_nl - << " " << case_array_type.c_str () << " const *," << be_nl + << " " << case_array_type.c_str () + << " const *," << be_nl << " TAO::Null_RefCount_Policy> const" << be_idt_nl << "_tao_tc_" << node->flat_name () << " (" << be_idt_nl @@ -72,18 +74,31 @@ TAO::be_visitor_union_typecode::visit_union (be_union * node) << discriminant_type->tc_name () << "," << be_nl << "_tao_cases_" << node->flat_name () << "," << be_nl << node->nfields () << "," - << node->default_index () << "," << be_nl -// << default_member_name, -// << default_member_type - << ");" << be_uidt_nl - << be_uidt_nl; + << node->default_index () << "," << be_nl; + + if (default_case) + { + be_type * const type = + be_type::narrow_from_decl (default_case->field_type ()); + + os << "\"" << default_case->original_local_name () << "\", " + << "&" << type->tc_name (); + } + else + { + os << "0, 0"; // No default_case. + } + + os << ");" << be_uidt_nl + << be_uidt_nl; return this->gen_typecode_ptr (be_type::narrow_from_decl (node)); } int -TAO::be_visitor_union_typecode::visit_cases (be_union * node) +TAO::be_visitor_union_typecode::visit_cases (be_union * node, + be_union_branch *& default_case) { AST_Field ** member_ptr = 0; @@ -91,6 +106,8 @@ TAO::be_visitor_union_typecode::visit_cases (be_union * node) TAO_OutStream & os = *this->ctx_->stream (); + default_case = 0; + for (size_t i = 0; i < count; ++i) { node->field (member_ptr, i); @@ -126,6 +143,10 @@ TAO::be_visitor_union_typecode::visit_cases (be_union * node) os << be_nl; } + else + { + default_case = branch; + } } return 0; diff --git a/TAO/TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h b/TAO/TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h index aaeb0332d61..fc8f3e521db 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h +++ b/TAO/TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h @@ -140,7 +140,7 @@ public: // int gen_typecode (be_typedef *node); - int gen_typecode (be_union *node); +// int gen_typecode (be_union *node); // int gen_typecode (be_valuetype *node); @@ -170,9 +170,9 @@ public: // int gen_encapsulation (be_typedef *node); - int gen_encapsulation (be_union *node); +// int gen_encapsulation (be_union *node); - int gen_encapsulation (be_union_branch *node); +// int gen_encapsulation (be_union_branch *node); // int gen_encapsulation (be_valuetype *node); @@ -198,7 +198,7 @@ public: // ACE_CDR::Long compute_tc_size (be_typedef *node); - ACE_CDR::Long compute_tc_size (be_union *node); +// ACE_CDR::Long compute_tc_size (be_union *node); // ACE_CDR::Long compute_tc_size (be_valuetype *node); @@ -228,9 +228,9 @@ public: // ACE_CDR::Long compute_encap_length (be_typedef *node); - ACE_CDR::Long compute_encap_length (be_union *node); +// ACE_CDR::Long compute_encap_length (be_union *node); - ACE_CDR::Long compute_encap_length (be_union_branch *node); +// ACE_CDR::Long compute_encap_length (be_union_branch *node); // ACE_CDR::Long compute_encap_length (be_valuetype *node); diff --git a/TAO/TAO_IDL/be_include/be_visitor_typecode/union_typecode.h b/TAO/TAO_IDL/be_include/be_visitor_typecode/union_typecode.h index c2127af498e..d6318da9dc4 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_typecode/union_typecode.h +++ b/TAO/TAO_IDL/be_include/be_visitor_typecode/union_typecode.h @@ -47,8 +47,8 @@ namespace TAO private: - /// Generate union field related TypeCode code. - int visit_cases (be_union * node); + /// Generate union branch related TypeCode code. + int visit_cases (be_union * node, be_union_branch *& default_case); }; |