diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-27 13:38:34 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-27 13:38:34 +0000 |
commit | 43d789ccae244164c041e070f08e6e71feb6a0f1 (patch) | |
tree | 32942442a886e9009d4a71d77d3184217da44c7d | |
parent | 895bf88bb51eb6dd776a00e4a7ea0fa52b9f95b7 (diff) | |
download | ATCD-43d789ccae244164c041e070f08e6e71feb6a0f1.tar.gz |
Pathes sent in for nested_type_name() and other code related to
ACE_NESTED_CLASS.
-rw-r--r-- | TAO/TAO_IDL/be/be_type.cpp | 43 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp | 15 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp | 6 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp | 18 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp | 2 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp | 14 |
6 files changed, 58 insertions, 40 deletions
diff --git a/TAO/TAO_IDL/be/be_type.cpp b/TAO/TAO_IDL/be/be_type.cpp index 080bc5356a9..a5a7a5a0dca 100644 --- a/TAO/TAO_IDL/be/be_type.cpp +++ b/TAO/TAO_IDL/be/be_type.cpp @@ -164,10 +164,15 @@ be_type::tc_name (const char *prefix, const char *suffix) return this->tc_name_; } -// XXXASG - This code works. However, whether we should generate the +// This code works. However, whether we should generate the // ACE_NESTED_CLASS macro or not should be based on an option to the -// compiler. In this version, we choose to generate a relative path. - +// compiler. The previous version generated a relative path. +// This version always generates ACE_NESTED_CLASS, (leave ace/ACE.h and friends +// do the porting) +// +// caution: returns the same buffer pointer even if the contents may change +// in the next call. (return std::string anyone?) +// // return the type name using the ACE_NESTED_CLASS macro const char * be_type::nested_type_name (be_decl *use_scope, const char *suffix, const char *prefix) @@ -226,6 +231,20 @@ be_type::nested_type_name (be_decl *use_scope, const char *suffix, const char *p def_next = ACE_OS::strstr (def_curr, "::"); use_next = ACE_OS::strstr (use_curr, "::"); + // If the scopes are identical, don't supply them. + if(!ACE_OS::strcmp (def_name, use_name)) + { + if (prefix) + ACE_OS::strcat (this->nested_type_name_, prefix); + + ACE_OS::strcat (this->nested_type_name_, + this->local_name ()->get_string ()); + if (suffix) + ACE_OS::strcat (this->nested_type_name_, suffix); + + return this->nested_type_name_; + } + if (def_next) len_to_match = ACE_OS::strlen (def_curr) - ACE_OS::strlen (def_next); @@ -251,9 +270,10 @@ be_type::nested_type_name (be_decl *use_scope, const char *suffix, const char *p // initial prefix matches i.e., they have a common root // start by initializing the macro - //@@ ACE_OS::sprintf (this->nested_type_name_, "ACE_NESTED_CLASS ("); - //@@ ACE_OS::strcat (this->nested_type_name_, def_curr, - //len_to_match); // initialize the first argument + ACE_OS::sprintf (this->nested_type_name_, "ACE_NESTED_CLASS ("); + ACE_OS::strncat (this->nested_type_name_, + def_curr, + len_to_match); // initialize the first argument // shift the curr scopes to the next level def_curr = (def_next ? (def_next + 2) : 0); // skip the :: @@ -288,9 +308,10 @@ be_type::nested_type_name (be_decl *use_scope, const char *suffix, const char *p if (!ACE_OS::strncmp (def_curr, use_curr, len_to_match)) { // they have same prefix, append to arg1 - //@@ ACE_OS::strcat (this->nested_type_name_, "::"); - //@@ ACE_OS::strncat (this->nested_type_name_, def_curr, - //len_to_match); + ACE_OS::strcat (this->nested_type_name_, "::"); + ACE_OS::strncat (this->nested_type_name_, + def_curr, + len_to_match); def_curr = (def_next ? (def_next + 2) : 0); // skip the :: use_curr = (use_next ? (use_next + 2) : 0); // skip the :: } @@ -303,7 +324,7 @@ be_type::nested_type_name (be_decl *use_scope, const char *suffix, const char *p } // start the 2nd argument of the macro - //@@ ACE_OS::strcat (this->nested_type_name_, ", "); + ACE_OS::strcat (this->nested_type_name_, ", "); // copy the remaining def_name (if any left) if (def_curr) @@ -318,7 +339,7 @@ be_type::nested_type_name (be_decl *use_scope, const char *suffix, const char *p ACE_OS::strcat (this->nested_type_name_, this->local_name ()->get_string ()); if (suffix) ACE_OS::strcat (this->nested_type_name_, suffix); - //@@ ACE_OS::strcat (this->nested_type_name_, ")"); + ACE_OS::strcat (this->nested_type_name_, ")"); return this->nested_type_name_; } // end of if the root prefixes match } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp index 25cec1980b3..747dd9d0e7f 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp @@ -166,10 +166,9 @@ int be_visitor_exception_ctor::visit_interface (be_interface *node) bt = node; if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + *os << "const " << bt->nested_type_name (this->ctx_->scope (), "_ptr "); else - *os << "const " << bt->name (); - *os << "_ptr "; + *os << "const " << bt->name () << "_ptr "; return 0; } @@ -185,10 +184,9 @@ int be_visitor_exception_ctor::visit_interface_fwd (be_interface_fwd *node) bt = node; if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + *os << "const " << bt->nested_type_name (this->ctx_->scope (), "_ptr "); else - *os << "const " << bt->name (); - *os << "_ptr "; + *os << "const " << bt->name () << "_ptr "; return 0; } @@ -216,10 +214,9 @@ int be_visitor_exception_ctor::visit_predefined_type (be_predefined_type *node) else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object { if (this->ctx_->state () == TAO_CodeGen::TAO_EXCEPTION_CTOR_CH) - *os << "const " << bt->nested_type_name (this->ctx_->scope ()); + *os << "const " << bt->nested_type_name (this->ctx_->scope (), "_ptr "); else - *os << "const " << bt->name (); - *os << "_ptr "; + *os << "const " << bt->name () << "_ptr "; } // end else if else // simple predefined types { 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 08ae4e574d0..70cc19ba281 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp @@ -259,8 +259,7 @@ be_visitor_field_ch::visit_valuetype (be_valuetype *node) // if not a typedef and we are defined in the use scope, we must be defined os->indent (); - *os << bt->nested_type_name (this->ctx_->scope (), "") - << "_var"; + *os << bt->nested_type_name (this->ctx_->scope (), "_var"); return 0; } @@ -280,8 +279,7 @@ be_visitor_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) // if not a typedef and we are defined in the use scope, we must be defined os->indent (); - *os << bt->nested_type_name (this->ctx_->scope (), "") - << "_var"; + *os << bt->nested_type_name (this->ctx_->scope (), "_var"); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp index ace226ecbb2..8f3e8f832cd 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/elemtype.cpp @@ -90,7 +90,7 @@ be_visitor_sequence_elemtype::visit_predefined_type (be_predefined_type *node) if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) { *os << bt->nested_type_name (this->ctx_->scope ()) << "," - << bt->nested_type_name (this->ctx_->scope ()) << "_var> "; + << bt->nested_type_name (this->ctx_->scope (), "_var") << "> "; } else { @@ -127,14 +127,16 @@ be_visitor_sequence_elemtype::visit_interface (be_interface *node) if (this->ctx_->state () == TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH) { - *os << "TAO_Object_Manager<" - << bt->nested_type_name (this->ctx_->scope ()) << "," - << bt->nested_type_name (this->ctx_->scope ()) << "_var> "; + *os << "TAO_Object_Manager<"; + *os << bt->nested_type_name (this->ctx_->scope ()) << ", "; + *os << bt->nested_type_name (this->ctx_->scope (), "_var") << "> "; } else - *os << "TAO_Object_Manager<" - << bt->name () << "," - << bt->name () << "_var> "; + { + *os << "TAO_Object_Manager<"; + *os << bt->name () << ", "; + *os << bt->name () << "_var> "; + } return 0; } @@ -154,7 +156,7 @@ be_visitor_sequence_elemtype::visit_interface_fwd (be_interface_fwd *node) { *os << "TAO_Object_Manager<" << bt->nested_type_name (this->ctx_->scope ()) << "," - << bt->nested_type_name (this->ctx_->scope ()) << "_var> "; + << bt->nested_type_name (this->ctx_->scope (), "_var") << "> "; } else *os << "TAO_Object_Manager<" diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp index 7f7e3886fc2..3506cbefa75 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp @@ -390,7 +390,7 @@ be_visitor_union_branch_public_ci::visit_interface_fwd (be_interface_fwd *node) << "_ = new TAO_Object_Field_T<" << bt->nested_type_name (bu, "") << ","; // Must use another statement, nested_type_name has side effects... - *os << bt->nested_type_name (bu, "") << "_var" + *os << bt->nested_type_name (bu, "_var") << "> (" << bt->name () << "::_duplicate (val));" << be_uidt_nl; } 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 d11108e183a..057e7d411fb 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp @@ -637,10 +637,10 @@ be_visitor_valuetype_field_ch::visit_structure (be_structure *node) // set method *os << pre_op() << "void " << ub->local_name () << " (const " << bt->nested_type_name (bu) << " &)" - << post_op() << " // set" << be_nl + << post_op() << " // set" << be_nl; // read-only - << pre_op() << "const " << bt->nested_type_name (bu) << " &" - << ub->local_name () << " (void) const" + *os << pre_op() << "const " << bt->nested_type_name (bu) << " &"; + *os << ub->local_name () << " (void) const" << post_op() << " // get method (read only)" << be_nl // read/write << pre_op() << bt->nested_type_name (bu) << " &" << ub->local_name () @@ -735,14 +735,14 @@ be_visitor_valuetype_field_ch::visit_union (be_union *node) // set method *os << pre_op() << "void " << ub->local_name () << " (const " << bt->nested_type_name (bu) << " &)" - << post_op() << " // set" << be_nl + << post_op() << " // set" << be_nl; // read-only - << pre_op() << "const " << bt->nested_type_name (bu) << " &" + *os << pre_op() << "const " << bt->nested_type_name (bu) << " &" << ub->local_name () << " (void) const" << post_op() << " // get method (read only)" - << be_nl + << be_nl; // read/write - << pre_op() << bt->nested_type_name (bu) << " &" << ub->local_name () + *os << pre_op() << bt->nested_type_name (bu) << " &" << ub->local_name () << " (void)" << post_op() << " // get method (read/write only)\n\n"; return 0; |