diff options
author | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-10 21:01:34 +0000 |
---|---|---|
committer | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-10 21:01:34 +0000 |
commit | 6292889c9201cee4025d840568de41d0645785ae (patch) | |
tree | fa9d677b55fbd3dd2caed3b5dd0092ac1023f6b6 | |
parent | 2f90d44ea66b44509db497bd239cd3c7d8c5345c (diff) | |
download | ATCD-6292889c9201cee4025d840568de41d0645785ae.tar.gz |
ChangeLogTag: Sat Jul 10 15:30:00 1999 Michael Kircher <mk1@cs.wustl.edu>
45 files changed, 1408 insertions, 1080 deletions
diff --git a/TAO/TAO_IDL/be/be_decl.cpp b/TAO/TAO_IDL/be/be_decl.cpp index b510a4c5b3a..b658bae2df4 100644 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ b/TAO/TAO_IDL/be/be_decl.cpp @@ -40,12 +40,9 @@ be_decl::be_decl (void) cli_hdr_cdr_op_gen_ (I_FALSE), cli_stub_cdr_op_gen_ (I_FALSE), cli_inline_cdr_op_gen_ (I_FALSE), - fullname_ (0), - ami_handler_fullname_ (0), - flatname_ (0), - ami_handler_flatname_ (0), + full_name_ (0), + flat_name_ (0), repoID_ (0), - ami_handler_repoID_ (0), prefix_ (0), size_type_ (be_decl::SIZE_UNKNOWN) { @@ -68,12 +65,9 @@ be_decl::be_decl (AST_Decl::NodeType type, cli_stub_any_op_gen_ (I_FALSE), cli_hdr_cdr_op_gen_ (I_FALSE), cli_stub_cdr_op_gen_ (I_FALSE), - fullname_ (0), - ami_handler_fullname_ (0), - flatname_ (0), - ami_handler_flatname_ (0), + full_name_ (0), + flat_name_ (0), repoID_ (0), - ami_handler_repoID_ (0), prefix_ (0), size_type_ (be_decl::SIZE_UNKNOWN) { @@ -82,36 +76,21 @@ be_decl::be_decl (AST_Decl::NodeType type, //destructor be_decl::~be_decl (void) { - if (this->fullname_ != 0) + if (this->full_name_ != 0) { - delete[] this->fullname_; - this->fullname_ = 0; + delete[] this->full_name_; + this->full_name_ = 0; } - if (this->ami_handler_fullname_ != 0) + if (this->flat_name_ != 0) { - delete[] this->ami_handler_fullname_; - this->ami_handler_fullname_ = 0; - } - if (this->flatname_ != 0) - { - delete[] this->flatname_; - this->flatname_ = 0; - } - if (this->ami_handler_flatname_ != 0) - { - delete[] this->ami_handler_flatname_; - this->ami_handler_flatname_ = 0; + delete[] this->flat_name_; + this->flat_name_ = 0; } if (this->repoID_ != 0) { delete[] this->repoID_; this->repoID_ = 0; } - if (this->ami_handler_repoID_ != 0) - { - delete[] this->ami_handler_repoID_; - this->ami_handler_repoID_ = 0; - } if (this->prefix_ != 0) { delete[] this->prefix_; @@ -147,30 +126,19 @@ be_decl::size_type (be_decl::SIZE_TYPE st) } const char* -be_decl::fullname (void) -{ - if (!this->fullname_) - compute_fullname (); - - return this->fullname_; -} - -const char* -be_decl::ami_handler_fullname (void) +be_decl::full_name (void) { - if (!this->ami_handler_fullname_) - compute_ami_handler_name (this->fullname (), - this->ami_handler_fullname_); + if (!this->full_name_) + compute_full_name (); - return this->ami_handler_fullname_; + return this->full_name_; } - // compute stringified fully scoped name void -be_decl::compute_fullname (void) +be_decl::compute_full_name (void) { - if (fullname_) + if (full_name_) return; else { @@ -202,19 +170,19 @@ be_decl::compute_fullname (void) } delete i; - this->fullname_ = new char [namelen+1]; - this->fullname_[0] = '\0'; + this->full_name_ = new char [namelen+1]; + this->full_name_[0] = '\0'; first = I_TRUE; second = I_FALSE; i = new UTL_IdListActiveIterator (this->name ()); while (!(i->is_done ())) { if (!first) - ACE_OS::strcat (this->fullname_, "::"); + ACE_OS::strcat (this->full_name_, "::"); else if (second) first = second = I_FALSE; // print the identifier - ACE_OS::strcat (this->fullname_, i->item ()->get_string ()); + ACE_OS::strcat (this->full_name_, i->item ()->get_string ()); if (first) { if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) @@ -230,30 +198,81 @@ be_decl::compute_fullname (void) return; } -const char* -be_decl::flatname (void) +void +be_decl::compute_full_name (const char *prefix, + const char *suffix, + char *&name) { - if (!this->flatname_) - this->compute_flatname (); + if (prefix == 0 || suffix == 0) + return; + + ACE_CString prefix_str (prefix); + ACE_CString suffix_str (suffix); + + ACE_CString result_str; - return this->flatname_; + // Get parent. + if (this->defined_in () == 0) + { + // Global scope. + + // Prefix. + result_str = prefix_str; + + // Local name. + result_str += ACE_CString (this->local_name ()->get_string ()); + + // Suffix. + result_str += suffix_str; + } + else + { + // Get scope name. + be_decl *parent = be_scope::narrow_from_scope (this->defined_in ())->decl (); + if (parent == 0) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_decl::" + "compute_flat_name - " + "scope name is nil\n")); + } + + // Parent name. + result_str = ACE_CString (parent->full_name ()); + + // _ + if (ACE_OS::strcmp (parent->full_name (), "") != 0) + result_str += ACE_CString ("::"); + + // Prefix. + result_str += prefix_str; + + // Local name. + result_str += ACE_CString (this->local_name ()->get_string ()); + + // Suffix. + result_str += suffix_str; + } + + name = result_str.rep (); } + const char* -be_decl::ami_handler_flatname (void) +be_decl::flat_name (void) { - if (!this->ami_handler_flatname_) - this->compute_flatname ("AMI_","_Handler"); + if (!this->flat_name_) + this->compute_flat_name (); - return this->ami_handler_flatname_; + return this->flat_name_; } // compute stringified flattened fully scoped name void -be_decl::compute_flatname (void) +be_decl::compute_flat_name (void) { - if (flatname_) + if (flat_name_) return; else { @@ -286,19 +305,19 @@ be_decl::compute_flatname (void) } delete i; - this->flatname_ = new char [namelen+1]; - this->flatname_[0] = '\0'; + this->flat_name_ = new char [namelen+1]; + this->flat_name_[0] = '\0'; first = I_TRUE; second = I_FALSE; i = new UTL_IdListActiveIterator (this->name ()); while (!(i->is_done ())) { if (!first) - ACE_OS::strcat (this->flatname_, "_"); + ACE_OS::strcat (this->flat_name_, "_"); else if (second) first = second = I_FALSE; // print the identifier - ACE_OS::strcat (this->flatname_, i->item ()->get_string ()); + ACE_OS::strcat (this->flat_name_, i->item ()->get_string ()); if (first) { if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) @@ -316,11 +335,13 @@ be_decl::compute_flatname (void) -char * -be_decl::compute_flatname (const char *prefix, const char *suffix) +void +be_decl::compute_flat_name (const char *prefix, + const char *suffix, + char *&name) { if (prefix == 0 || suffix == 0) - return 0; + return; ACE_CString prefix_str (prefix); ACE_CString suffix_str (suffix); @@ -347,22 +368,21 @@ be_decl::compute_flatname (const char *prefix, const char *suffix) be_decl *parent = be_scope::narrow_from_scope (this->defined_in ())->decl (); if (parent == 0) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_decl::" - "compute_flat_name - " - "scope name is nil\n"), - 0); + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_decl::" + "compute_flat_name - " + "scope name is nil\n")); } // Parent name. - result_str = ACE_CString (parent->fullname ()); + result_str = ACE_CString (parent->full_name ()); // _ - if (ACE_OS::strcmp (parent->fullname (), "") != 0) + if (ACE_OS::strcmp (parent->full_name (), "") != 0) result_str += ACE_CString ("_"); // Prefix. - result_str += ACE_CString ("AMI_"); + result_str += prefix_str; // Local name. result_str += ACE_CString (this->local_name ()->get_string ()); @@ -371,8 +391,7 @@ be_decl::compute_flatname (const char *prefix, const char *suffix) result_str += suffix_str; } - this->ami_handler_flatname_ = result_str.rep (); - return this->ami_handler_flatname_; + name = result_str.rep (); } const char * @@ -385,16 +404,6 @@ be_decl::repoID (void) } -const char * -be_decl::ami_handler_repoID (void) -{ - if (!this->ami_handler_repoID_) - this->compute_repoID ("AMI_","_Handler"); - - return this->ami_handler_repoID_; -} - - // compute stringified repository ID void be_decl::compute_repoID (void) @@ -470,12 +479,14 @@ be_decl::compute_repoID (void) // Apply the prefix and suffix to the local name and compute the // repoID. Both the parameters should be non-null. -char * -be_decl::compute_repoID (const char *prefix, const char *suffix) +void +be_decl::compute_repoID (const char *prefix, + const char *suffix, + char *&name) { // Prefix and suffix should be valid. if (prefix == 0 || suffix == 0) - return 0; + return; // First prepare the result without IDL: and :1.0 strings. @@ -605,56 +616,7 @@ be_decl::compute_repoID (const char *prefix, const char *suffix) delete result; result = 0; - this->ami_handler_repoID_ = repoID.rep (); - - return this->ami_handler_repoID_; -} - - -int -be_decl::compute_ami_handler_name (const char *name, - char *&ami_handler_name) -{ - int name_length = ACE_OS::strlen (name); - int ami_handler_length = ACE_OS::strlen ("AMI__HANDLER"); - - ACE_NEW_RETURN (ami_handler_name, - char[name_length + ami_handler_length+1], - -1); - - // copy it in - ACE_OS::strcpy (ami_handler_name, name); - - const char *interface_name = 0; - int i = ACE_OS::strlen (name); - for (;i >= 1; i--) - { - if (name[i-1] == ':' && name[i] == ':') - { - interface_name = &name[i+1]; - break; - } - else if (i >= 3) - if (name[i-3] == 'P' && - name[i-2] == 'O' && - name[i-1] == 'A' && - name[i] == '_') - { - interface_name = &name[i+1]; - break; - } - } - - if (interface_name == 0) - interface_name = name; - - ACE_OS::strcpy(&ami_handler_name[name_length-ACE_OS::strlen(interface_name)],"AMI_"); - ACE_OS::strcpy(&ami_handler_name[name_length-ACE_OS::strlen(interface_name)+4], - interface_name); - ACE_OS::strcpy(&ami_handler_name[name_length+4], - "_Handler"); - - return 0; + name = repoID.rep (); } @@ -952,7 +914,7 @@ be_decl::is_child (be_decl *node) if (!bd) return 0; - if (!ACE_OS::strcmp (bd->fullname (), node->fullname ())) + if (!ACE_OS::strcmp (bd->full_name (), node->full_name ())) return 1; // true } return 0; // not a child diff --git a/TAO/TAO_IDL/be/be_helper.cpp b/TAO/TAO_IDL/be/be_helper.cpp index 9483cac3d19..3b9a9f7877d 100644 --- a/TAO/TAO_IDL/be/be_helper.cpp +++ b/TAO/TAO_IDL/be/be_helper.cpp @@ -185,13 +185,13 @@ TAO_OutStream::nl (void) // macro generation int -TAO_OutStream::gen_ifdef_macro (const char *flatname, const char *suffix) +TAO_OutStream::gen_ifdef_macro (const char *flat_name, const char *suffix) { static char macro [NAMEBUFSIZE]; TAO_CodeGen *cg = TAO_CODEGEN::instance (); ACE_OS::memset (macro, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (macro, "_%s_", cg->upcase (flatname)); + ACE_OS::sprintf (macro, "_%s_", cg->upcase (flat_name)); if (suffix) { //ACE_OS::sprintf (macro, "%s_%s_", macro, cg->upcase (suffix)); diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 37860f537b5..73685856081 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -15,7 +15,8 @@ // = AUTHOR // Copyright 1994-1995 by Sun Microsystems, Inc. // and -// Aniruddha Gokhale +// Aniruddha Gokhale, +// Michael Kircher // // ============================================================================ @@ -32,308 +33,107 @@ ACE_RCSID(be, be_interface, "$Id$") // default constructor be_interface::be_interface (void) - : full_skel_name_ (0), - ami_handler_full_skel_name_ (0), - skel_count_ (0), - full_coll_name_ (0), - ami_handler_full_coll_name_ (0), - local_coll_name_ (0), - ami_handler_local_coll_name_ (0), - ami_handler_local_name_ (0), - in_mult_inheritance_ (-1) + : skel_count_ (0), + in_mult_inheritance_ (-1), + strategy_ (new be_interface_default_strategy (this)) { this->size_type (be_decl::VARIABLE); // always the case } // constructor used to build the AST -be_interface::be_interface (UTL_ScopedName *n, AST_Interface **ih, long nih, +be_interface::be_interface (UTL_ScopedName *n, + AST_Interface **ih, + long nih, UTL_StrList *p) : AST_Interface (n, ih, nih, p), AST_Decl (AST_Decl::NT_interface, n, p), UTL_Scope (AST_Decl::NT_interface), - full_skel_name_ (0), - ami_handler_full_skel_name_ (0), skel_count_ (0), - full_coll_name_ (0), - ami_handler_full_coll_name_ (0), - local_coll_name_ (0), - ami_handler_local_coll_name_ (0), - ami_handler_local_name_ (0), - in_mult_inheritance_ (-1) + in_mult_inheritance_ (-1), + strategy_ (new be_interface_default_strategy (this)) { this->size_type (be_decl::VARIABLE); // always the case } be_interface::~be_interface (void) { - if (this->full_skel_name_ != 0) - { - delete[] this->full_skel_name_; - this->full_skel_name_ = 0; - } - if (this->ami_handler_full_skel_name_ != 0) - { - delete[] this->ami_handler_full_skel_name_; - this->ami_handler_full_skel_name_ = 0; - } - if (this->full_coll_name_ != 0) - { - delete[] this->full_coll_name_; - this->full_coll_name_ = 0; - } - if (this->ami_handler_full_coll_name_ != 0) - { - delete[] this->ami_handler_full_coll_name_; - this->ami_handler_full_coll_name_ = 0; - } - if (this->local_coll_name_ != 0) - { - delete[] this->local_coll_name_; - this->local_coll_name_ = 0; - } - if (this->ami_handler_local_coll_name_ != 0) - { - delete[] this->ami_handler_local_coll_name_; - this->ami_handler_local_coll_name_ = 0; - } - if (this->ami_handler_local_name_ != 0) - { - delete[] this->ami_handler_local_name_; - this->ami_handler_local_name_ = 0; - } + // We know that it cannot be 0, but.. + if (!this->strategy_) + delete this->strategy_; } -// compute stringified fully qualified collocated class name. -void -be_interface::compute_coll_name (int type) +be_interface_type_strategy * +be_interface::set_strategy (be_interface_type_strategy *new_strategy) { -// @@ not thread safe. - static int cached_type = -1; - if (type == cached_type && this->full_coll_name_ != 0) - return; - else - { - cached_type = type; - delete this->full_coll_name_; - delete this->local_coll_name_; - } - - static const char *collocated_names[] = { "_tao_thru_poa_collocated_", - "_tao_direct_collocated_" }; - const char poa[] = "POA_"; - // Reserve enough room for the "POA_" prefix, the "_tao_collocated_" - // prefix and the local name and the (optional) "::" - const char *collocated = collocated_names[type]; + be_interface_type_strategy *old = this->strategy_; - int namelen = ACE_OS::strlen (collocated) + sizeof (poa) + 1; + if (new_strategy != 0) + this->strategy_ = new_strategy; - UTL_IdListActiveIterator *i; - ACE_NEW (i, UTL_IdListActiveIterator (this->name ())); - while (!i->is_done ()) - { - // reserve 2 characters for "::". - namelen += ACE_OS::strlen (i->item ()->get_string ()) + 2; - i->next (); - } - delete i; - - ACE_NEW (this->full_coll_name_, - char[namelen+1]); - this->full_coll_name_[0] = 0; // null terminate the string... - - // Iterate again.... - ACE_NEW (i, UTL_IdListActiveIterator (this->name ())); - - // Only the first component get the "POA_" preffix. - int poa_added = 0; - while (!i->is_done ()) - { - const char* item = i->item ()->get_string (); + return old; +} - // Increase right away, so we can test for the final component - // in the loop. - i->next (); - // We add the POA_ preffix only if the first component is not - // the global scope... - if (ACE_OS::strcmp (item, "") != 0) - { - if (!i->is_done ()) - { - // We only add the POA_ preffix if there are more than - // two components in the name, in other words, if the - // class is inside some scope. - if (!poa_added) - { - ACE_OS::strcat (this->full_coll_name_, poa); - poa_added = 1; - } - ACE_OS::strcat (this->full_coll_name_, item); - ACE_OS::strcat (this->full_coll_name_, "::"); - } - else - { - ACE_OS::strcat (this->full_coll_name_, collocated); - ACE_OS::strcat (this->full_coll_name_, item); - } - } - } - delete i; - - // Compute the local name for the collocated class. - int localen = ACE_OS::strlen (collocated) + 1; - localen += ACE_OS::strlen (this->local_name ()->get_string ()); - ACE_NEW (this->local_coll_name_, char[localen]); - ACE_OS::strcpy(this->local_coll_name_, collocated); - ACE_OS::strcat(this->local_coll_name_, - this->local_name ()->get_string ()); +const char * +be_interface::local_name (void) const +{ + // return the local name + return this->strategy_->local_name (); } const char * -be_interface::full_coll_name (int type) +be_interface::full_name (void) const { - this->compute_coll_name (type); - - return this->full_coll_name_; + // return the stringified full name + return this->strategy_->full_name (); } -const char* -be_interface::local_coll_name (int type) const +const char * +be_interface::flat_name (void) const { - ACE_const_cast (be_interface*, this)->compute_coll_name (type); - - return this->local_coll_name_; + // return the flattened full scoped name. + return this->strategy_->flat_name (); } - -const char* -be_interface::ami_handler_full_coll_name (void) +const char * +be_interface::repoID (void) const { - if (this->ami_handler_full_coll_name_ == 0) - { - // @@ Michael: We need to check this one. I am just passing 1 - // for the time being. (Alex). - compute_ami_handler_name (this->full_coll_name(1), - this->ami_handler_full_coll_name_); - } - - return this->ami_handler_full_coll_name_; + // retrieve the repository ID. + return this->strategy_->repoID (); } -const char* -be_interface::ami_handler_local_coll_name (void) +const char * +be_interface::full_skel_name (void) const { - if (this->ami_handler_local_coll_name_ == 0) - { - // @@ Michael: We need to check this one. I am just passing 1 - // for the time being. (Alex). - compute_ami_handler_name (this->local_coll_name(1), - this->ami_handler_local_coll_name_); - } - - return this->ami_handler_local_coll_name_; + // retrieve the fully scoped skel class name. + return this->strategy_->full_skel_name (); } -const char* -be_interface::ami_handler_local_name (void) +const char * +be_interface::full_coll_name (int type) const { - if (this->ami_handler_local_name_ == 0) - compute_ami_handler_name (this->local_name()->get_string (), - this->ami_handler_local_name_); - - return this->ami_handler_local_name_; + // retrieve the fully qualified collocated class name + return this->strategy_->full_coll_name (type); } -// Generate collocated local and full names for the arbitrary local -// name under the scope of this interface. Usefull to generate AMI -// Handlers. -int -be_interface::compute_coll_names (const char *local_name, - char *&coll_local_name, - char *&coll_full_name) - +const char * +be_interface::local_coll_name (int type) const { - const char collocated[] = "_tao_collocated_"; - const char poa[] = "POA_"; - - // Reserve enough room for the "POA_" prefix, the "_tao_collocated_" - // prefix and the local name and the (optional) "::" - int namelen = sizeof (collocated) + sizeof (poa); - - UTL_IdListActiveIterator *i; - ACE_NEW_RETURN (i, UTL_IdListActiveIterator (this->name ()), -1); - while (!i->is_done ()) - { - // reserve 2 characters for "::". - namelen += ACE_OS::strlen (i->item ()->get_string ()) + 2; - i->next (); - } - delete i; - - ACE_NEW_RETURN (coll_full_name, - char[namelen+1], - -1); - coll_full_name[0] = 0; // null terminate the string... - - // Iterate again.... - ACE_NEW_RETURN (i, UTL_IdListActiveIterator (this->name ()), -1); - - // Only the first component get the "POA_" preffix. - int poa_added = 0; - while (!i->is_done ()) - { - const char* item = i->item ()->get_string (); - - // Increase right away, so we can test for the final component - // in the loop. - i->next (); - - // We add the POA_ preffix only if the first component is not - // the global scope... - if (ACE_OS::strcmp (item, "") != 0) - { - if (!i->is_done ()) - { - // We only add the POA_ preffix if there are more than - // two components in the name, in other words, if the - // class is inside some scope. - if (!poa_added) - { - ACE_OS::strcat (coll_full_name, poa); - poa_added = 1; - } - ACE_OS::strcat (coll_full_name, item); - ACE_OS::strcat (coll_full_name, "::"); - } - else - { - ACE_OS::strcat (coll_full_name, collocated); - ACE_OS::strcat (coll_full_name, item); - } - } - } - delete i; - - // Compute the local name for the collocated class. - int localen = sizeof (collocated); - localen += ACE_OS::strlen (local_name); - ACE_NEW_RETURN (coll_local_name, char[localen], -1); - ACE_OS::strcpy(coll_local_name, collocated); - ACE_OS::strcat(coll_local_name, - local_name); - - return 0; + // retrieve the fully qualified collocated class name. + return this->strategy_->local_coll_name (type); } -// compute stringified fully scoped skel name -void -be_interface::compute_fullskelname (void) +const char * +be_interface::relative_skel_name (const char *skel_name) { - this->compute_fullskelname (this->full_skel_name_, "POA_"); + // relative skeleton name + return this->strategy_->relative_skel_name (skel_name); } + void -be_interface::compute_fullskelname (char *&skelname, const char *prefix) +be_interface::compute_full_skel_name (const char *prefix, + char *&skelname) { if (skelname) return; @@ -368,7 +168,7 @@ be_interface::compute_fullskelname (char *&skelname, const char *prefix) } delete i; - skelname = new char [namelen+1]; + ACE_NEW (skelname, char [namelen+1]); skelname[0] = '\0'; first = I_TRUE; second = I_FALSE; @@ -397,24 +197,90 @@ be_interface::compute_fullskelname (char *&skelname, const char *prefix) return; } -// retrieve the fully scoped skeleton name const char* -be_interface::full_skel_name (void) +be_interface::relative_name (const char *localname, + const char *othername) { - if (!this->full_skel_name_) - compute_fullskelname (); + // some compilers do not like generating a fully scoped name for a + // type that was defined in the same enclosing scope in which it was + // defined. We have to emit just the partial name, relative to our + // "localname" - return this->full_skel_name_; -} + // The tricky part here is that it is not enough to check if the + // typename we are using was defined in the current scope. But we + // need to ensure that it was not defined in any of our ancestor + // scopes as well. If that is the case, then we can generate a fully + // scoped name for that type, else we use the ACE_NESTED_CLASS macro -const char* -be_interface::ami_handler_full_skel_name (void) -{ - if (this->ami_handler_full_skel_name_ == 0) - compute_ami_handler_name (this->full_skel_name(), - this->ami_handler_full_skel_name_); + // thus we need some sort of relative name to be generated + + static char macro [NAMEBUFSIZE]; + // UNUSED: be_decl *def_scope = 0; // our defining scope + char // hold the fully scoped name + def_name [NAMEBUFSIZE], + use_name [NAMEBUFSIZE]; + char // these point to the curr and next component in the scope + *def_curr = def_name, + *def_next, + *use_curr = use_name, + *use_next; - return this->ami_handler_full_skel_name_; + ACE_OS::memset (macro, '\0', NAMEBUFSIZE); + ACE_OS::memset (def_name, '\0', NAMEBUFSIZE); + ACE_OS::memset (use_name, '\0', NAMEBUFSIZE); + + // traverse every component of the def_scope and use_scope beginning at the + // root and proceeding towards the leaf trying to see if the components + // match. Continue until there is a match and keep accumulating the path + // traversed. This forms the first argument to the ACE_NESTED_CLASS + // macro. Whenever there is no match, the remaining components of the + // def_scope form the second argument + + ACE_OS::strcpy (def_name, localname); + ACE_OS::strcpy (use_name, othername); + + while (def_curr && use_curr) + { + // find the first occurrence of a :: and advance the next pointers accordingly + def_next = ACE_OS::strstr (def_curr, "::"); + use_next = ACE_OS::strstr (use_curr, "::"); + + if (def_next) + *def_next = 0; + + if (use_next) + *use_next = 0; + + if (!ACE_OS::strcmp (def_curr, use_curr)) + { + // they have same prefix, append to arg1 + def_curr = (def_next ? (def_next+2) : 0); // skip the :: + use_curr = (use_next ? (use_next+2) : 0); // skip the :: + } + else + { + // we had overwritten a ':' by a '\0' for string comparison. We + // revert back because we want the rest of the relative name to be + // used + if (def_next) + *def_next = ':'; + + if (use_next) + *use_next = ':'; + + // no match. This is the end of the first argument. Get out + // of the loop as no more comparisons are necessary + break; + } + } + + // start the 2nd argument of the macro + + // copy the remaining def_name (if any left) + if (def_curr) + ACE_OS::strcat (macro, def_curr); + + return macro; } @@ -460,13 +326,13 @@ be_interface::gen_copy_ctors_helper (be_interface* node, be_interface* base, TAO { if(first) { - *os << idl_global->impl_class_prefix () << base->flatname () << idl_global->impl_class_suffix () << " (t)" + *os << idl_global->impl_class_prefix () << base->flat_name () << idl_global->impl_class_suffix () << " (t)" << ", " << base->full_skel_name () << " (t)"; first = 0; } else { - *os << ", " << idl_global->impl_class_prefix () << base->flatname () << idl_global->impl_class_suffix () << " (t)" + *os << ", " << idl_global->impl_class_prefix () << base->flat_name () << idl_global->impl_class_suffix () << " (t)" << ", " << base->full_skel_name () << " (t)"; ; } @@ -499,12 +365,12 @@ be_interface::gen_def_ctors_helper (be_interface* node, be_interface* base, TAO_ { if(first) { - *os << idl_global->impl_class_prefix () << base->flatname () << idl_global->impl_class_suffix () << " ()"; + *os << idl_global->impl_class_prefix () << base->flat_name () << idl_global->impl_class_suffix () << " ()"; first = 0; } else { - *os << ", " << idl_global->impl_class_prefix () << base->flatname () << idl_global->impl_class_suffix () << " ()"; + *os << ", " << idl_global->impl_class_prefix () << base->flat_name () << idl_global->impl_class_suffix () << " ()"; } } @@ -531,7 +397,7 @@ be_interface::gen_var_defn (char* interface_name) // Decide which name to use. if (interface_name == 0) - interface_name = this->local_name ()->get_string (); + interface_name = (char *) this->local_name (); // Buffer with name of the var class. ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); @@ -626,8 +492,8 @@ be_interface::gen_var_impl (char *interface_local_name, // arguments. Let us then use the name in this node. if (interface_local_name == 0 || interface_full_name == 0) { - interface_local_name = local_name ()->get_string (); - interface_full_name = (char *) this->fullname (); + interface_local_name = (char *) local_name (); + interface_full_name = (char *) this->full_name (); } ACE_OS::memset (fname, '\0', NAMEBUFSIZE); @@ -815,7 +681,7 @@ be_interface::gen_out_defn (char *interface_name) // Decide which name to use. if (interface_name == 0) - interface_name = this->local_name ()->get_string (); + interface_name = (char *) this->local_name (); // Create the buffer with the name of the out class. ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); @@ -887,8 +753,8 @@ be_interface::gen_out_impl (char *interface_local_name, // arguments. Let us then use the name in this node. if (interface_local_name == 0 || interface_full_name == 0) { - interface_local_name = local_name ()->get_string (); - interface_full_name = (char *) this->fullname (); + interface_local_name = (char *) local_name (); + interface_full_name = (char *) this->full_name (); } ACE_OS::memset (fname, '\0', NAMEBUFSIZE); @@ -1017,9 +883,9 @@ be_interface::gen_out_impl (char *interface_local_name, // helper. int -be_interface::gen_operation_table (void) +be_interface::gen_operation_table () { - TAO_OutStream *ss; // output stream. + TAO_OutStream *os; // output stream. TAO_NL nl; // end line. // Retrieve the singleton instance of the CodeGen. @@ -1030,19 +896,21 @@ be_interface::gen_operation_table (void) switch (cg->lookup_strategy ()) { case TAO_CodeGen::TAO_DYNAMIC_HASH: + // Init the outstream appropriately. - ss = cg->server_skeletons (); + + os = this->strategy_->get_out_stream (); // start from current indentation level. - ss->indent (); + os->indent (); // Start the table generation. - *ss << "static const TAO_operation_db_entry " << this->flatname () << + *os << "static const TAO_operation_db_entry " << this->flat_name () << "_operations [] = {\n"; - ss->incr_indent (0); + os->incr_indent (0); // Traverse the graph. - if (this->traverse_inheritance_graph (be_interface::gen_optable_helper, ss) == -1) + if (this->traverse_inheritance_graph (be_interface::gen_optable_helper, os) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::gen_operation_table - " @@ -1050,34 +918,34 @@ be_interface::gen_operation_table (void) } // generate the skeleton for the is_a method. - ss->indent (); - *ss << "{\"_is_a\", &" << this->full_skel_name () << "::_is_a_skel},\n"; + os->indent (); + *os << "{\"_is_a\", &" << this->full_skel_name () << "::_is_a_skel},\n"; this->skel_count_++; - ss->indent (); - *ss << "{\"_non_existent\", &" << this->full_skel_name () << "::_non_existent_skel}\n"; + os->indent (); + *os << "{\"_non_existent\", &" << this->full_skel_name () << "::_non_existent_skel}\n"; this->skel_count_++; - ss->decr_indent (); - *ss << "};" << nl << nl; + os->decr_indent (); + *os << "};" << nl << nl; // XXXASG - this code should be based on using different strategies for // demux - for next release - *ss << "static const CORBA::Long _tao_" << this->flatname () + *os << "static const CORBA::Long _tao_" << this->flat_name () << "_optable_size = sizeof (ACE_Hash_Map_Entry<const char *," << " TAO_Skeleton>) * (" << (3*this->skel_count_) << ");" << be_nl; - *ss << "static char _tao_" << this->flatname () << "_optable_pool " - << "[_tao_" << this->flatname () << "_optable_size];" << be_nl; - *ss << "static ACE_Static_Allocator_Base _tao_" << this->flatname () - << "_allocator (_tao_" << this->flatname () << "_optable_pool, " - << "_tao_" << this->flatname () << "_optable_size);" << be_nl; - *ss << "static TAO_Dynamic_Hash_OpTable tao_" - << this->flatname () << "_optable " << "(" << be_idt << be_idt_nl - << this->flatname () << "_operations," << be_nl + *os << "static char _tao_" << this->flat_name () << "_optable_pool " + << "[_tao_" << this->flat_name () << "_optable_size];" << be_nl; + *os << "static ACE_Static_Allocator_Base _tao_" << this->flat_name () + << "_allocator (_tao_" << this->flat_name () << "_optable_pool, " + << "_tao_" << this->flat_name () << "_optable_size);" << be_nl; + *os << "static TAO_Dynamic_Hash_OpTable tao_" + << this->flat_name () << "_optable " << "(" << be_idt << be_idt_nl + << this->flat_name () << "_operations," << be_nl << this->skel_count_ << "," << be_nl << 2*this->skel_count_ << "," << be_nl - << "&_tao_" << this->flatname () << "_allocator" << be_uidt_nl + << "&_tao_" << this->flat_name () << "_allocator" << be_uidt_nl << ");" << be_uidt_nl; break; @@ -1096,13 +964,13 @@ be_interface::gen_operation_table (void) char *temp_file = 0; ACE_NEW_RETURN (temp_file, char [ACE_OS::strlen (idl_global->temp_dir ()) + - ACE_OS::strlen (this->flatname ()) + + ACE_OS::strlen (this->flat_name ()) + ACE_OS::strlen (".gperf") + 1], -1); ACE_OS::sprintf (temp_file, "%s%s.gperf", idl_global->temp_dir (), - this->flatname ()); + this->flat_name ()); // Save this file name with the codegen singleton. cg->gperf_input_filename (temp_file); @@ -1115,8 +983,8 @@ be_interface::gen_operation_table (void) TAO_OUTSTREAM_FACTORY::instance (); // Get a new instance for the temp file. - ss = factory->make_outstream (); - if (ss == 0) + os = factory->make_outstream (); + if (os == 0) ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ss", "::", @@ -1125,10 +993,10 @@ be_interface::gen_operation_table (void) -1); // Store the outstream with the codegen singleton. - cg->gperf_input_stream (ss); + cg->gperf_input_stream (os); // Open the temp file. - if (ss->open (temp_file, + if (os->open (temp_file, TAO_OutStream::TAO_GPERF_INPUT) == -1) ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ss", @@ -1138,24 +1006,24 @@ be_interface::gen_operation_table (void) -1); // Add the gperf input header. - this->gen_gperf_input_header (ss); + this->gen_gperf_input_header (os); // Traverse the graph. - if (this->traverse_inheritance_graph (be_interface::gen_optable_helper, ss) == -1) + if (this->traverse_inheritance_graph (be_interface::gen_optable_helper, os) == -1) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_interface::gen_operation_table - " "inheritance graph traversal failed\n"), -1); // Generate the skeleton for the is_a method. - ss->indent (); - *ss << "_is_a" << ", &" + os->indent (); + *os << "_is_a" << ", &" << this->full_skel_name () << "::_is_a_skel\n"; this->skel_count_++; - ss->indent (); - *ss << "_non_existent, &" + os->indent (); + *os << "_non_existent, &" << this->full_skel_name () << "::_non_existent_skel\n"; this->skel_count_++; @@ -1178,12 +1046,14 @@ be_interface::gen_operation_table (void) return 0; } + + // Output the header (type declaration and %%) to the gperf's input // file. void -be_interface::gen_gperf_input_header (TAO_OutStream *ss) +be_interface::gen_gperf_input_header (TAO_OutStream *os) { - *ss << "class TAO_operation_db_entry {\n" + *os << "class TAO_operation_db_entry {\n" << "public:\n" << "\tchar *opname_;" << "\n" << "\tTAO_Skeleton skel_ptr_;" << "\n" @@ -1202,7 +1072,7 @@ be_interface::gen_optable_entries (be_interface *derived) { UTL_ScopeActiveIterator *si; AST_Decl *d; - TAO_OutStream *ss; // output stream + TAO_OutStream *os; // output stream // retrieve a singleton instance of the code generator TAO_CodeGen *cg = TAO_CODEGEN::instance (); @@ -1211,7 +1081,8 @@ be_interface::gen_optable_entries (be_interface *derived) { case TAO_CodeGen::TAO_DYNAMIC_HASH: // Init the outstream. - ss = cg->server_skeletons (); + + os = this->strategy_->get_out_stream (); // The major stuff. if (this->nmembers () > 0) @@ -1230,10 +1101,10 @@ be_interface::gen_optable_entries (be_interface *derived) if (d->node_type () == AST_Decl::NT_op) { // Start from current indentation level - ss->indent (); + os->indent (); // we are an operation node - *ss << "{\"" << d->original_local_name () << "\", &" + *os << "{\"" << d->original_local_name () << "\", &" << derived->full_skel_name () << "::" << d->local_name () << "_skel},\n"; @@ -1244,11 +1115,11 @@ be_interface::gen_optable_entries (be_interface *derived) AST_Attribute *attr; // Start from current indentation level. - ss->indent (); + os->indent (); // Generate only the "get" entry if we are // readonly. - *ss << "{\"_get_" << d->original_local_name () + *os << "{\"_get_" << d->original_local_name () << "\", &" << derived->full_skel_name () << "::_get_" << d->local_name () << "_skel},\n"; @@ -1261,8 +1132,8 @@ be_interface::gen_optable_entries (be_interface *derived) if (!attr->readonly ()) { // the set method - ss->indent (); // start from current indentation level - *ss << "{\"_set_" << d->original_local_name () + os->indent (); // start from current indentation level + *os << "{\"_set_" << d->original_local_name () << "\", &" << derived->full_skel_name () << "::_set_" << d->local_name () << "_skel},\n"; derived->skel_count_++; @@ -1279,7 +1150,7 @@ be_interface::gen_optable_entries (be_interface *derived) case TAO_CodeGen::TAO_PERFECT_HASH: // We call GPERF for all these three strategies. // Init the outstream. - ss = cg->gperf_input_stream (); + os = cg->gperf_input_stream (); if (this->nmembers () > 0) { @@ -1302,11 +1173,11 @@ be_interface::gen_optable_entries (be_interface *derived) // // Start from current indentation level - ss->indent (); + os->indent (); // We are an operation node. We use the original // operation name, not the one with _cxx_ in it. - *ss << d->original_local_name () << ",\t&" + *os << d->original_local_name () << ",\t&" << derived->full_skel_name () << "::" << d->local_name () << "_skel" << "\n"; @@ -1317,10 +1188,10 @@ be_interface::gen_optable_entries (be_interface *derived) AST_Attribute *attr; // Start from current indentation level - ss->indent (); + os->indent (); // Generate only the "get" entry if we are readonly - *ss << "_get_" << d->original_local_name () << ",\t&" + *os << "_get_" << d->original_local_name () << ",\t&" << derived->full_skel_name () << "::_get_" << d->local_name () << "_skel\n"; derived->skel_count_++; @@ -1332,8 +1203,8 @@ be_interface::gen_optable_entries (be_interface *derived) if (!attr->readonly ()) { // the set method - ss->indent (); // start from current indentation level - *ss << "_set_" << d->original_local_name () << ",\t&" + os->indent (); // start from current indentation level + *os << "_set_" << d->original_local_name () << ",\t&" << derived->full_skel_name () << "::_set_" << d->local_name () << "_skel\n"; derived->skel_count_++; @@ -1356,12 +1227,14 @@ be_interface::gen_optable_entries (be_interface *derived) return 0; } + + // template method that traverses the inheritance graph in a breadth-first // style. The actual work on each element in the inheritance graph is carried // out by the function passed as argument int be_interface::traverse_inheritance_graph (be_interface::tao_code_emitter gen, - TAO_OutStream *os) + TAO_OutStream *os) { long i; // loop index ACE_Unbounded_Queue <be_interface*> queue; // Queue data structure needed for @@ -1448,7 +1321,7 @@ be_interface::traverse_inheritance_graph (be_interface::tao_code_emitter gen, be_interface **temp; // queue element (void) q_iter.next (temp); - if (!ACE_OS::strcmp (parent->fullname (), (*temp)->fullname ())) + if (!ACE_OS::strcmp (parent->full_name (), (*temp)->full_name ())) { // we exist in this queue and cannot be inserted found = 1; @@ -1466,7 +1339,7 @@ be_interface::traverse_inheritance_graph (be_interface::tao_code_emitter gen, be_interface **temp; // queue element (void) del_q_iter.next (temp); - if (!ACE_OS::strcmp (parent->fullname (), (*temp)->fullname ())) + if (!ACE_OS::strcmp (parent->full_name (), (*temp)->full_name ())) { // we exist in this del_queue and cannot be inserted found = 1; @@ -1491,6 +1364,7 @@ be_interface::traverse_inheritance_graph (be_interface::tao_code_emitter gen, return 0; } + // helpers passed to the template method int @@ -1510,6 +1384,8 @@ be_interface::gen_optable_helper (be_interface *derived, return 0; } + + // Run GPERF and get the correct lookup and other operations // depending on which strategy we are using. Returns 0 on sucess, -1 // on error. @@ -1592,9 +1468,9 @@ be_interface::gen_perfect_hash_class_definition (void) TAO_CodeGen *cg = TAO_CODEGEN::instance (); // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); + TAO_OutStream *os = this->strategy_->get_out_stream (); - *ss << "class " << "TAO_" << this->flatname () << "_Perfect_Hash_OpTable" + *os << "class " << "TAO_" << this->flat_name () << "_Perfect_Hash_OpTable" << " : public TAO_Perfect_Hash_OpTable" << be_nl << "{" @@ -1620,9 +1496,9 @@ be_interface::gen_binary_search_class_definition (void) TAO_CodeGen *cg = TAO_CODEGEN::instance (); // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); + TAO_OutStream *os = this->strategy_->get_out_stream (); - *ss << "class " << "TAO_" << this->flatname () << "_Binary_Search_OpTable" + *os << "class " << "TAO_" << this->flat_name () << "_Binary_Search_OpTable" << " : public TAO_Binary_Search_OpTable" << be_nl << "{" @@ -1644,9 +1520,9 @@ be_interface::gen_linear_search_class_definition (void) TAO_CodeGen *cg = TAO_CODEGEN::instance (); // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); + TAO_OutStream *ss = this->strategy_->get_out_stream (); - *ss << "class " << "TAO_" << this->flatname () << "_Linear_Search_OpTable" + *ss << "class " << "TAO_" << this->flat_name () << "_Linear_Search_OpTable" << " : public TAO_Linear_Search_OpTable" << be_nl << "{" @@ -1702,8 +1578,11 @@ be_interface::gen_gperf_lookup_methods (void) // again with ACE_OS::open with WRITE + APPEND option.. After this, // remember to update the file offset to the correct location. - ACE_HANDLE output = ACE_OS::open (idl_global->be_get_server_skeleton_fname (), + ACE_HANDLE output = ACE_OS::open (this->strategy_->get_out_stream_fname (), O_WRONLY | O_APPEND); + + //ACE_HANDLE output = ACE_OS::open (idl_global->be_get_server_skeleton_fname (), + // O_WRONLY | O_APPEND); if (output == ACE_INVALID_HANDLE) ACE_ERROR_RETURN ((LM_ERROR, "%p:File open failed on server skeleton file\n"), @@ -1734,7 +1613,7 @@ be_interface::gen_gperf_lookup_methods (void) " " "-N lookup", idl_global->gperf_path (), - this->flatname ()); + this->flat_name ()); break; // Binary search methods from GPERF. Everythis and the -B flag. @@ -1757,7 +1636,7 @@ be_interface::gen_gperf_lookup_methods (void) " " "-N lookup", idl_global->gperf_path (), - this->flatname ()); + this->flat_name ()); break; // Linear search methods from GPERF. Everything and the -z flag. @@ -1780,7 +1659,7 @@ be_interface::gen_gperf_lookup_methods (void) " " "-N lookup", idl_global->gperf_path (), - this->flatname ()); + this->flat_name ()); break; default: @@ -1803,7 +1682,7 @@ be_interface::gen_gperf_lookup_methods (void) -1); // Adjust the file offset to the EOF for the server skeleton file. - ACE_OS::fseek (cg->server_skeletons ()->file (), 0, SEEK_END); + ACE_OS::fseek (this->strategy_->get_out_stream()->file (), 0, SEEK_END); return 0; } @@ -1816,11 +1695,11 @@ be_interface::gen_perfect_hash_instance () TAO_CodeGen *cg = TAO_CODEGEN::instance (); // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); + TAO_OutStream *os = this->strategy_->get_out_stream (); - *ss << "static TAO_" << this->flatname () << "_Perfect_Hash_OpTable" + *os << "static TAO_" << this->flat_name () << "_Perfect_Hash_OpTable" << " " - << "tao_" << this->flatname () << "_optable" + << "tao_" << this->flat_name () << "_optable" << ";\n" << be_nl; } @@ -1832,14 +1711,15 @@ be_interface::gen_binary_search_instance () TAO_CodeGen *cg = TAO_CODEGEN::instance (); // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); + TAO_OutStream *os = this->strategy_->get_out_stream (); - *ss << "static TAO_" << this->flatname () << "_Binary_Search_OpTable" + *os << "static TAO_" << this->flat_name () << "_Binary_Search_OpTable" << " " - << "tao_" << this->flatname () << "_optable" + << "tao_" << this->flat_name () << "_optable" << ";\n" << be_nl; } + // Create an instance of this perfect hash table. void be_interface::gen_linear_search_instance () @@ -1848,14 +1728,15 @@ be_interface::gen_linear_search_instance () TAO_CodeGen *cg = TAO_CODEGEN::instance (); // Outstream. - TAO_OutStream *ss = cg->server_skeletons (); + TAO_OutStream *os = this->strategy_->get_out_stream (); - *ss << "static TAO_" << this->flatname () << "_Linear_Search_OpTable" + *os << "static TAO_" << this->flat_name () << "_Linear_Search_OpTable" << " " - << "tao_" << this->flatname () << "_optable" + << "tao_" << this->flat_name () << "_optable" << ";\n" << be_nl; } + int be_interface::is_a_helper (be_interface * /*derived*/, be_interface *bi, @@ -1869,6 +1750,8 @@ be_interface::is_a_helper (be_interface * /*derived*/, return 0; } + + int be_interface::downcast_helper (be_interface * /* derived */, be_interface *base, @@ -1881,6 +1764,7 @@ be_interface::downcast_helper (be_interface * /* derived */, return 0; } + int be_interface::gen_skel_helper (be_interface *derived, be_interface *ancestor, @@ -2114,107 +1998,451 @@ be_interface::in_mult_inheritance_helper (be_interface *derived, return 0; } -// return the relative skeleton name (needed due to NT compiler insanity) + +int +be_interface::accept (be_visitor *visitor) +{ + return visitor->visit_interface (this); +} + + + +// Interface Type Strategy Base Class + const char * -be_interface::relative_skel_name (const char *skelname) +be_interface_type_strategy::relative_skel_name (const char *skel_name) +// relative skeleton name { return be_interface::relative_name (this->full_skel_name (), - skelname); + skel_name); } -const char* -be_interface::relative_name (const char *localname, - const char *othername) + + +// compute stringified fully qualified collocated class name. +void +be_interface_type_strategy::compute_coll_names (int type, + const char *prefix, + const char *suffix) { - // some compilers do not like generating a fully scoped name for a - // type that was defined in the same enclosing scope in which it was - // defined. We have to emit just the partial name, relative to our - // "localname" +// @@ not thread safe. + static int cached_type = -1; + if (type == cached_type && this->full_coll_name_ != 0) + return; + else + { + cached_type = type; + delete this->full_coll_name_; + delete this->local_coll_name_; + } - // The tricky part here is that it is not enough to check if the - // typename we are using was defined in the current scope. But we - // need to ensure that it was not defined in any of our ancestor - // scopes as well. If that is the case, then we can generate a fully - // scoped name for that type, else we use the ACE_NESTED_CLASS macro + static const char *collocated_names[] = { "_tao_thru_poa_collocated_", + "_tao_direct_collocated_" }; + const char poa[] = "POA_"; + // Reserve enough room for the "POA_" prefix, the "_tao_collocated_" + // prefix and the local name and the (optional) "::" + const char *collocated = collocated_names[type]; - // thus we need some sort of relative name to be generated + int name_len = ACE_OS::strlen (collocated) + + sizeof (poa) + + 1; - static char macro [NAMEBUFSIZE]; - // UNUSED: be_decl *def_scope = 0; // our defining scope - char // hold the fully scoped name - def_name [NAMEBUFSIZE], - use_name [NAMEBUFSIZE]; - char // these point to the curr and next component in the scope - *def_curr = def_name, - *def_next, - *use_curr = use_name, - *use_next; + if (prefix) + name_len += ACE_OS::strlen (prefix); - ACE_OS::memset (macro, '\0', NAMEBUFSIZE); - ACE_OS::memset (def_name, '\0', NAMEBUFSIZE); - ACE_OS::memset (use_name, '\0', NAMEBUFSIZE); + if (suffix) + name_len += ACE_OS::strlen (suffix); - // traverse every component of the def_scope and use_scope beginning at the - // root and proceeding towards the leaf trying to see if the components - // match. Continue until there is a match and keep accumulating the path - // traversed. This forms the first argument to the ACE_NESTED_CLASS - // macro. Whenever there is no match, the remaining components of the - // def_scope form the second argument + { + UTL_IdListActiveIterator *i; + ACE_NEW (i, UTL_IdListActiveIterator (node_->name ())); + while (!i->is_done ()) + { + // reserve 2 characters for "::". + name_len += ACE_OS::strlen (i->item ()->get_string ()) + 2; + i->next (); + } + delete i; + } - ACE_OS::strcpy (def_name, localname); - ACE_OS::strcpy (use_name, othername); + ACE_NEW (this->full_coll_name_, + char[name_len+1]); + this->full_coll_name_[0] = 0; // null terminate the string... - while (def_curr && use_curr) - { - // find the first occurrence of a :: and advance the next pointers accordingly - def_next = ACE_OS::strstr (def_curr, "::"); - use_next = ACE_OS::strstr (use_curr, "::"); + // Iterate again.... + UTL_IdListActiveIterator *i; + ACE_NEW (i, UTL_IdListActiveIterator (node_->name ())); - if (def_next) - *def_next = 0; + // Only the first component get the "POA_" preffix. + int poa_added = 0; + while (!i->is_done ()) + { + const char* item = i->item ()->get_string (); - if (use_next) - *use_next = 0; + // Increase right away, so we can test for the final component + // in the loop. + i->next (); - if (!ACE_OS::strcmp (def_curr, use_curr)) + // We add the POA_ preffix only if the first component is not + // the global scope... + if (ACE_OS::strcmp (item, "") != 0) { - // they have same prefix, append to arg1 - def_curr = (def_next ? (def_next+2) : 0); // skip the :: - use_curr = (use_next ? (use_next+2) : 0); // skip the :: + if (!i->is_done ()) + { + // We only add the POA_ preffix if there are more than + // two components in the name, in other words, if the + // class is inside some scope. + if (!poa_added) + { + ACE_OS::strcat (this->full_coll_name_, poa); + poa_added = 1; + } + ACE_OS::strcat (this->full_coll_name_, item); + ACE_OS::strcat (this->full_coll_name_, "::"); + } + else + { + ACE_OS::strcat (this->full_coll_name_, collocated); + + if (prefix) + ACE_OS::strcat (this->full_coll_name_, prefix); + + ACE_OS::strcat (this->full_coll_name_, item); + + if (suffix) + ACE_OS::strcat (this->full_coll_name_, suffix); + } } - else - { - // we had overwritten a ':' by a '\0' for string comparison. We - // revert back because we want the rest of the relative name to be - // used - if (def_next) - *def_next = ':'; + } + delete i; - if (use_next) - *use_next = ':'; + // Compute the local name for the collocated class. + int local_len = ACE_OS::strlen (collocated) + + ACE_OS::strlen (node_->AST_Interface::local_name ()->get_string ()) + + 1; + if (prefix) + local_len += ACE_OS::strlen (prefix); - // no match. This is the end of the first argument. Get out - // of the loop as no more comparisons are necessary + if (suffix) + local_len += ACE_OS::strlen (suffix); + + ACE_NEW (this->local_coll_name_, char[local_len]); + + ACE_OS::strcpy(this->local_coll_name_, collocated); + + if (prefix) + ACE_OS::strcat (this->local_coll_name_, prefix); + + ACE_OS::strcat(this->local_coll_name_, + node_->AST_Interface::local_name ()->get_string ()); + + if (suffix) + ACE_OS::strcat (this->local_coll_name_, suffix); +} + + +void +be_interface_type_strategy::compute_names (const char *name, + const char *prefix, + const char *suffix, + char *&new_name) +{ + if (!prefix || !suffix) + return; + + int name_length = ACE_OS::strlen (name) + + ACE_OS::strlen (prefix) + + ACE_OS::strlen (suffix); + + ACE_NEW (new_name, + char[name_length + 1]); + + // copy it in + ACE_OS::strcpy (new_name, name); + + const char *interface_name = 0; + int i = ACE_OS::strlen (name); + for (;i >= 1; i--) + { + if (name[i-1] == ':' && name[i] == ':') + { + interface_name = &name[i+1]; break; } + else if (i >= 3) + if (name[i-3] == 'P' && + name[i-2] == 'O' && + name[i-1] == 'A' && + name[i] == '_') + { + interface_name = &name[i+1]; + break; + } + } + + if (interface_name == 0) + interface_name = name; + + ACE_OS::strcpy(&new_name[name_length - + ACE_OS::strlen(prefix) - + ACE_OS::strlen(interface_name) - + ACE_OS::strlen(suffix)],prefix); + + ACE_OS::strcpy(&new_name[name_length - + ACE_OS::strlen(interface_name) - + ACE_OS::strlen(suffix)],interface_name); + + ACE_OS::strcpy(&new_name[name_length - + ACE_OS::strlen(suffix)],suffix); +} + + +// AMI Hander Strategy + +const char * +be_interface_ami_handler_strategy::full_name (void) +{ + if (!this->full_name_) + this->compute_names (node_->be_decl::full_name (), + prefix_, + suffix_, + this->full_name_); + + return this->full_name_; +} + +const char * +be_interface_ami_handler_strategy::local_name (void) +{ + if (!this->local_name_) + this->compute_names (node_->AST_Interface::local_name()->get_string (), + prefix_, + suffix_, + this->local_name_); + + return this->local_name_; +} + +const char * +be_interface_ami_handler_strategy::flat_name (void) +{ + if (!this->flat_name_) + node_->compute_flat_name (prefix_, + suffix_, + this->flat_name_); + + return this->flat_name_; +} + +const char * +be_interface_ami_handler_strategy::repoID (void) +{ + if (!this->repoID_) + node_->compute_repoID (prefix_, + suffix_, + this->repoID_); + + return this->repoID_; +} + +const char * +be_interface_ami_handler_strategy::full_skel_name (void) +{ + if (this->full_skel_name_ == 0) + { + char *temp = 0; + + // the following method is inherited from the base class + node_->compute_full_skel_name ("POA_", temp); + + // we are now responsible for the memory of temp + + this->compute_names (temp, + prefix_, + suffix_, + this->full_skel_name_); + + delete temp; + } + + return this->full_skel_name_; +} + + +const char * +be_interface_ami_handler_strategy::full_coll_name (int type) +{ + if (this->full_coll_name_ == 0) + { + this->compute_coll_names (type, + prefix_, + suffix_); } - // start the 2nd argument of the macro + return this->full_coll_name_; +} - // copy the remaining def_name (if any left) - if (def_curr) - ACE_OS::strcat (macro, def_curr); +const char * +be_interface_ami_handler_strategy::local_coll_name (int type) +{ + if (this->local_coll_name_ == 0) + { + compute_coll_names (type, + prefix_, + suffix_); + } - return macro; + return this->local_coll_name_; } -int -be_interface::accept (be_visitor *visitor) +TAO_OutStream * +be_interface_ami_handler_strategy::get_out_stream () { - return visitor->visit_interface (this); + // Codegen singleton. + TAO_CodeGen *cg = TAO_CODEGEN::instance (); + + // Outstream. + return cg->client_stubs (); +} + +const char * +be_interface_ami_handler_strategy::get_out_stream_fname () +{ + return idl_global->be_get_client_stub_fname (); +} + + +// Default Strategy + + +const char * +be_interface_default_strategy::full_name (void) +{ + if (!this->full_name_) + { + int len = ACE_OS::strlen (node_->be_decl::full_name ()); + + ACE_NEW_RETURN (this->full_name_, + char[len], + 0); + + ACE_OS::strcpy (this->full_name_, + node_->be_decl::full_name ()); + } + + return this->full_name_; +} + +const char * +be_interface_default_strategy::local_name (void) +{ + if (!this->local_name_) + { + int len = ACE_OS::strlen (node_->AST_Interface::local_name()->get_string ()); + + ACE_NEW_RETURN (this->local_name_, + char[len], + 0); + + ACE_OS::strcpy (this->local_name_, + node_->AST_Interface::local_name()->get_string ()); + } + + return this->local_name_; } +const char * +be_interface_default_strategy::flat_name (void) +{ + if (!this->flat_name_) + { + int len = ACE_OS::strlen (node_->be_decl::flat_name ()); + + ACE_NEW_RETURN (this->flat_name_, + char[len], + 0); + + ACE_OS::strcpy (this->flat_name_, + node_->be_decl::flat_name ()); + } + + + return this->flat_name_; +} + +const char * +be_interface_default_strategy::repoID (void) +{ + if (!this->repoID_) + { + int len = ACE_OS::strlen (node_->be_decl::repoID ()); + + ACE_NEW_RETURN (this->repoID_, + char[len], + 0); + + ACE_OS::strcpy (this->repoID_, + node_->be_decl::repoID ()); + } + + return this->repoID_; +} +const char * +be_interface_default_strategy::full_skel_name (void) +{ + if (this->full_skel_name_ == 0) + { + // the following method is inherited from the base class + node_->compute_full_skel_name ("POA_", + this->full_skel_name_); + } + + return this->full_skel_name_; +} + + +const char * +be_interface_default_strategy::full_coll_name (int type) +{ + if (this->full_coll_name_ == 0) + { + this->compute_coll_names (type, + 0, // prefix + 0); // suffix + } + + return this->full_coll_name_; +} + +const char * +be_interface_default_strategy::local_coll_name (int type) +{ + if (this->local_coll_name_ == 0) + { + this->compute_coll_names (type, + 0, // prefix + 0); // suffix + } + + return this->local_coll_name_; +} + +TAO_OutStream * +be_interface_default_strategy::get_out_stream () +{ + // Codegen singleton. + TAO_CodeGen *cg = TAO_CODEGEN::instance (); + + // Outstream. + return cg->server_skeletons (); +} + +const char * +be_interface_default_strategy::get_out_stream_fname () +{ + return idl_global->be_get_server_skeleton_fname (); +} // Narrowing IMPL_NARROW_METHODS3 (be_interface, AST_Interface, be_scope, be_type) diff --git a/TAO/TAO_IDL/be/be_interface_fwd.cpp b/TAO/TAO_IDL/be/be_interface_fwd.cpp index 3d407fc41bd..baf21f5f1e4 100644 --- a/TAO/TAO_IDL/be/be_interface_fwd.cpp +++ b/TAO/TAO_IDL/be/be_interface_fwd.cpp @@ -137,7 +137,7 @@ be_interface_fwd::gen_var_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _var names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", this->fullname ()); + ACE_OS::sprintf (fname, "%s_var", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ()); @@ -377,7 +377,7 @@ be_interface_fwd::gen_out_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _out names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_out", this->fullname ()); + ACE_OS::sprintf (fname, "%s_out", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ()); diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp index b7232df5407..ca2b12b9053 100644 --- a/TAO/TAO_IDL/be/be_predefined_type.cpp +++ b/TAO/TAO_IDL/be/be_predefined_type.cpp @@ -151,13 +151,13 @@ be_predefined_type::be_predefined_type (AST_PredefinedType::PredefinedType t, compute_repoID (); // computes the fully scoped name - compute_fullname (); + compute_full_name (); // computes the fully scoped typecode name compute_tc_name (); // compute the flattened fully scoped name - compute_flatname (); + compute_flat_name (); } diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp index 5d88dabd8ac..94c67d91daa 100644 --- a/TAO/TAO_IDL/be/be_sequence.cpp +++ b/TAO/TAO_IDL/be/be_sequence.cpp @@ -276,11 +276,11 @@ be_sequence::instance_name () if (this->unbounded ()) ACE_OS::sprintf (namebuf, "_TAO_Unbounded_Object_Sequence_%s", - this->flatname()); + this->flat_name()); else ACE_OS::sprintf (namebuf, "_TAO_Bounded_Object_Sequence_%s_%d", - this->flatname(), + this->flat_name(), this->max_size ()->ev()->u.ulval); break; case be_sequence::MNG_STRING: // sequence of strings @@ -290,7 +290,7 @@ be_sequence::instance_name () else ACE_OS::sprintf (namebuf, "_TAO_Bounded_String_Sequence_%s", - this->flatname()); + this->flat_name()); break; default: // not a managed type if (this->unbounded ()) @@ -306,16 +306,16 @@ be_sequence::instance_name () else ACE_OS::sprintf (namebuf, "_TAO_Unbounded_Sequence_%s", - this->flatname()); - // or prim_type->flatname ()); + this->flat_name()); + // or prim_type->flat_name ()); // ACE_DEBUG ((LM_DEBUG, "testing.... %d, %d = <%s>\n", // predef, predef->pt (), namebuf)); } else ACE_OS::sprintf (namebuf, "_TAO_Bounded_Sequence_%s_%d", - this->flatname(), - //prim_type->flatname (), + this->flat_name(), + //prim_type->flat_name (), this->max_size()->ev()->u.ulval); break; } @@ -346,7 +346,7 @@ be_sequence::in_recursion (be_type *node) 0); } - if (!ACE_OS::strcmp (node->fullname (), type->fullname ())) + if (!ACE_OS::strcmp (node->full_name (), type->full_name ())) // they match return 1; else diff --git a/TAO/TAO_IDL/be/be_structure.cpp b/TAO/TAO_IDL/be/be_structure.cpp index a926adf8fcd..3dea9bb9018 100644 --- a/TAO/TAO_IDL/be/be_structure.cpp +++ b/TAO/TAO_IDL/be/be_structure.cpp @@ -169,7 +169,7 @@ be_structure::gen_var_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _var names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", this->fullname ()); + ACE_OS::sprintf (fname, "%s_var", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ()); @@ -452,7 +452,7 @@ be_structure::gen_out_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _out names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_out", this->fullname ()); + ACE_OS::sprintf (fname, "%s_out", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ()); diff --git a/TAO/TAO_IDL/be/be_type.cpp b/TAO/TAO_IDL/be/be_type.cpp index 279348d9008..19cdb46c995 100644 --- a/TAO/TAO_IDL/be/be_type.cpp +++ b/TAO/TAO_IDL/be/be_type.cpp @@ -219,8 +219,8 @@ be_type::nested_type_name (be_decl *use_scope, const char *suffix, const char *p if (def_scope && def_scope->node_type () != AST_Decl::NT_root && use_scope) // if both scopes exist and that we are not in the root scope { - ACE_OS::strcpy (def_name, def_scope->fullname ()); - ACE_OS::strcpy (use_name, use_scope->fullname ()); + ACE_OS::strcpy (def_name, def_scope->full_name ()); + ACE_OS::strcpy (use_name, use_scope->full_name ()); // find the first occurrence of a :: and advance the next pointers accordingly def_next = ACE_OS::strstr (def_curr, "::"); @@ -323,10 +323,10 @@ be_type::nested_type_name (be_decl *use_scope, const char *suffix, const char *p } // end of if the root prefixes match } - // otherwise just emit our fullname + // otherwise just emit our full_name if (prefix) ACE_OS::strcat (this->nested_type_name_, prefix); - ACE_OS::strcat (this->nested_type_name_, this->fullname ()); + ACE_OS::strcat (this->nested_type_name_, this->full_name ()); if (suffix) ACE_OS::strcat (this->nested_type_name_, suffix); diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp index 4aa4baa22fe..1c2f97fc4b7 100644 --- a/TAO/TAO_IDL/be/be_union.cpp +++ b/TAO/TAO_IDL/be/be_union.cpp @@ -228,7 +228,7 @@ be_union::gen_var_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _var names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", this->fullname ()); + ACE_OS::sprintf (fname, "%s_var", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ()); @@ -511,7 +511,7 @@ be_union::gen_out_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _out names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_out", this->fullname ()); + ACE_OS::sprintf (fname, "%s_out", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ()); diff --git a/TAO/TAO_IDL/be/be_union_branch.cpp b/TAO/TAO_IDL/be/be_union_branch.cpp index 2328d31b26d..316df27920a 100644 --- a/TAO/TAO_IDL/be/be_union_branch.cpp +++ b/TAO/TAO_IDL/be/be_union_branch.cpp @@ -95,7 +95,7 @@ be_union_branch::gen_label_value (TAO_OutStream *os, unsigned long index) // we must prefix the enum value with something... be_decl* decl = scope->decl (); - *os << decl->fullname () << "::" << e->n (); + *os << decl->full_name () << "::" << e->n (); return 0; } diff --git a/TAO/TAO_IDL/be/be_valuetype.cpp b/TAO/TAO_IDL/be/be_valuetype.cpp index 0b6c04a7472..00cdbb71161 100644 --- a/TAO/TAO_IDL/be/be_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_valuetype.cpp @@ -99,7 +99,7 @@ be_valuetype::set_abstract_valuetype () void be_valuetype::compute_fullobvskelname (void) { - this->compute_fullskelname (this->full_obv_skel_name_, "OBV_"); + this->compute_full_skel_name ("OBV_", this->full_obv_skel_name_); } @@ -124,7 +124,7 @@ be_valuetype::gen_var_defn (char *) char namebuf [NAMEBUFSIZE]; // names ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_var", this->local_name ()->get_string ()); + ACE_OS::sprintf (namebuf, "%s_var", this->local_name ()); // retrieve a singleton instance of the code generator TAO_CodeGen *cg = TAO_CODEGEN::instance (); @@ -211,10 +211,10 @@ be_valuetype::gen_var_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _var names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", this->fullname ()); + ACE_OS::sprintf (fname, "%s_var", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ()); + ACE_OS::sprintf (lname, "%s_var", local_name ()); // retrieve a singleton instance of the code generator TAO_CodeGen *cg = TAO_CODEGEN::instance (); @@ -405,7 +405,7 @@ be_valuetype::gen_out_defn (char *) char namebuf [NAMEBUFSIZE]; // to hold the _out name ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (namebuf, "%s_out", local_name ()->get_string ()); + ACE_OS::sprintf (namebuf, "%s_out", local_name ()); // retrieve a singleton instance of the code generator TAO_CodeGen *cg = TAO_CODEGEN::instance (); @@ -463,10 +463,10 @@ be_valuetype::gen_out_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _out names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_out", this->fullname ()); + ACE_OS::sprintf (fname, "%s_out", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ()); + ACE_OS::sprintf (lname, "%s_out", local_name ()); // retrieve a singleton instance of the code generator TAO_CodeGen *cg = TAO_CODEGEN::instance (); diff --git a/TAO/TAO_IDL/be/be_valuetype_fwd.cpp b/TAO/TAO_IDL/be/be_valuetype_fwd.cpp index a7a1d35ea38..44638e2ad6d 100644 --- a/TAO/TAO_IDL/be/be_valuetype_fwd.cpp +++ b/TAO/TAO_IDL/be/be_valuetype_fwd.cpp @@ -150,7 +150,7 @@ be_valuetype_fwd::gen_var_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _var names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_var", this->fullname ()); + ACE_OS::sprintf (fname, "%s_var", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); ACE_OS::sprintf (lname, "%s_var", local_name ()->get_string ()); @@ -392,7 +392,7 @@ be_valuetype_fwd::gen_out_impl (char *, char *) char lname [NAMEBUFSIZE]; // local _out names ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_out", this->fullname ()); + ACE_OS::sprintf (fname, "%s_out", this->full_name ()); ACE_OS::memset (lname, '\0', NAMEBUFSIZE); ACE_OS::sprintf (lname, "%s_out", local_name ()->get_string ()); diff --git a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp index 22e77c1924a..bf19a07a4d6 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/argument.cpp @@ -64,7 +64,7 @@ be_visitor_args::type_name (be_type *node, const char *suffix) (this->ctx_->scope (), suffix)); break; default: // fullname for all other cases - ACE_OS::sprintf (namebuf, "%s", bt->fullname ()); + ACE_OS::sprintf (namebuf, "%s", bt->full_name ()); if (suffix) ACE_OS::strcat (namebuf, suffix); } diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp index c38780bdfdb..d28b1dbee33 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_ch.cpp @@ -64,7 +64,7 @@ int be_visitor_array_ch::visit_array (be_array *node) } // generate the ifdefined macro - os->gen_ifdef_macro (node->flatname ()); + os->gen_ifdef_macro (node->flat_name ()); // If we contain an anonymous sequence, // generate code for the sequence here. diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp index b08c960285d..07d211ac5ee 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp @@ -126,8 +126,8 @@ be_visitor_array_ci::gen_var_impl (be_array *node) if (this->ctx_->tdef ()) { // typedefed node - ACE_OS::sprintf (nodename, "%s", node->fullname ()); - ACE_OS::sprintf (fname, "%s_var", node->fullname ()); + ACE_OS::sprintf (nodename, "%s", node->full_name ()); + ACE_OS::sprintf (fname, "%s_var", node->full_name ()); ACE_OS::sprintf (lname, "%s_var", node->local_name ()->get_string ()); } @@ -139,17 +139,17 @@ be_visitor_array_ci::gen_var_impl (be_array *node) if (node->is_nested ()) { be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (nodename, "%s::_%s", parent->fullname (), + ACE_OS::sprintf (nodename, "%s::_%s", parent->full_name (), node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_var", parent->fullname (), + ACE_OS::sprintf (fname, "%s::_%s_var", parent->full_name (), node->local_name ()->get_string ()); ACE_OS::sprintf (lname, "_%s_var", node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (nodename, "_%s", node->fullname ()); - ACE_OS::sprintf (fname, "_%s_var", node->fullname ()); + ACE_OS::sprintf (nodename, "_%s", node->full_name ()); + ACE_OS::sprintf (fname, "_%s_var", node->full_name ()); ACE_OS::sprintf (lname, "_%s_var", node->local_name ()->get_string ()); } @@ -319,8 +319,8 @@ be_visitor_array_ci::gen_out_impl (be_array *node) if (this->ctx_->tdef ()) { // typedefed node - ACE_OS::sprintf (nodename, "%s", node->fullname ()); - ACE_OS::sprintf (fname, "%s_out", node->fullname ()); + ACE_OS::sprintf (nodename, "%s", node->full_name ()); + ACE_OS::sprintf (fname, "%s_out", node->full_name ()); ACE_OS::sprintf (lname, "%s_out", node->local_name ()->get_string ()); } @@ -332,17 +332,17 @@ be_visitor_array_ci::gen_out_impl (be_array *node) if (node->is_nested ()) { be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (nodename, "%s::_%s", parent->fullname (), + ACE_OS::sprintf (nodename, "%s::_%s", parent->full_name (), node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_out", parent->fullname (), + ACE_OS::sprintf (fname, "%s::_%s_out", parent->full_name (), node->local_name ()->get_string ()); ACE_OS::sprintf (lname, "_%s_out", node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (nodename, "_%s", node->fullname ()); - ACE_OS::sprintf (fname, "_%s_out", node->fullname ()); + ACE_OS::sprintf (nodename, "_%s", node->full_name ()); + ACE_OS::sprintf (fname, "_%s_out", node->full_name ()); ACE_OS::sprintf (lname, "_%s_out", node->local_name ()->get_string ()); } @@ -453,8 +453,8 @@ be_visitor_array_ci::gen_forany_impl (be_array *node) if (this->ctx_->tdef ()) { // typedefed node - ACE_OS::sprintf (nodename, "%s", node->fullname ()); - ACE_OS::sprintf (fname, "%s_forany", node->fullname ()); + ACE_OS::sprintf (nodename, "%s", node->full_name ()); + ACE_OS::sprintf (fname, "%s_forany", node->full_name ()); ACE_OS::sprintf (lname, "%s_forany", node->local_name ()->get_string ()); } @@ -466,17 +466,17 @@ be_visitor_array_ci::gen_forany_impl (be_array *node) if (node->is_nested ()) { be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (nodename, "%s::_%s", parent->fullname (), + ACE_OS::sprintf (nodename, "%s::_%s", parent->full_name (), node->local_name ()->get_string ()); - ACE_OS::sprintf (fname, "%s::_%s_forany", parent->fullname (), + ACE_OS::sprintf (fname, "%s::_%s_forany", parent->full_name (), node->local_name ()->get_string ()); ACE_OS::sprintf (lname, "_%s_forany", node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (nodename, "_%s", node->fullname ()); - ACE_OS::sprintf (fname, "_%s_forany", node->fullname ()); + ACE_OS::sprintf (nodename, "_%s", node->full_name ()); + ACE_OS::sprintf (fname, "_%s_forany", node->full_name ()); ACE_OS::sprintf (lname, "_%s_forany", node->local_name ()->get_string ()); } diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp index 70dc9205344..da5090b7e16 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/array_cs.cpp @@ -72,7 +72,7 @@ int be_visitor_array_cs::visit_array (be_array *node) if (this->ctx_->tdef ()) { // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); + ACE_OS::sprintf (fname, "%s", node->full_name ()); ACE_OS::sprintf (lname, "%s", node->local_name ()->get_string ()); } @@ -84,14 +84,14 @@ int be_visitor_array_cs::visit_array (be_array *node) if (node->is_nested ()) { be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), + ACE_OS::sprintf (fname, "%s::_%s", parent->full_name (), node->local_name ()->get_string ()); ACE_OS::sprintf (lname, "_%s", node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); + ACE_OS::sprintf (fname, "_%s", node->full_name ()); ACE_OS::sprintf (lname, "_%s", node->local_name ()->get_string ()); } diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp index 3af1abc3abd..58f70f8f79d 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp @@ -59,7 +59,7 @@ be_visitor_array_cdr_op_ch::visit_array (be_array *node) { be_scope* scope = be_scope::narrow_from_scope (node->defined_in ()); be_decl* parent = scope->decl (); - *os << parent->fullname () + *os << parent->full_name () << "::_" << node->local_name () << "_forany &);" << be_nl; } @@ -73,7 +73,7 @@ be_visitor_array_cdr_op_ch::visit_array (be_array *node) { be_scope* scope = be_scope::narrow_from_scope (node->defined_in ()); be_decl* parent = scope->decl (); - *os << parent->fullname () + *os << parent->full_name () << "::_" << node->local_name () << "_forany &);" << be_nl; } diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp index 5995c25313b..c6e7bf91dce 100644 --- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp @@ -92,7 +92,7 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node) } // for anonymous arrays, the type name has a _ prepended. We compute the - // fullname with or without the underscore and use it later on. + // full_name with or without the underscore and use it later on. char fname [NAMEBUFSIZE]; // to hold the full and // save the node's local name and full name in a buffer for quick use later @@ -101,7 +101,7 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node) if (this->ctx_->tdef ()) { // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); + ACE_OS::sprintf (fname, "%s", node->full_name ()); } else { @@ -112,12 +112,12 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node) if (node->is_nested ()) { be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), + ACE_OS::sprintf (fname, "%s::_%s", parent->full_name (), node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); + ACE_OS::sprintf (fname, "_%s", node->full_name ()); } } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/ctor_assign.cpp b/TAO/TAO_IDL/be/be_visitor_exception/ctor_assign.cpp index 5c3bff6388f..78a6dcbff64 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/ctor_assign.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/ctor_assign.cpp @@ -94,7 +94,7 @@ int be_visitor_exception_ctor_assign::visit_array (be_array *node) os->indent (); - if (ACE_OS::strcmp (bd->flatname (), node->flatname ())) + if (ACE_OS::strcmp (bd->flat_name (), node->flat_name ())) { // We are typedef'd. *os << node->name (); diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp index b724b9d6e7b..3d47c0ef614 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp @@ -50,7 +50,7 @@ int be_visitor_exception_ch::visit_exception (be_exception *node) { os = this->ctx_->stream (); - os->gen_ifdef_macro (node->flatname (), "_ptr"); + os->gen_ifdef_macro (node->flat_name (), "_ptr"); os->indent (); *os << "class " << node->local_name () << ";" << be_nl; @@ -59,7 +59,7 @@ int be_visitor_exception_ch::visit_exception (be_exception *node) << node->local_name () << "_ptr;" << be_nl; os->gen_endif (); - os->gen_ifdef_macro (node->flatname ()); + os->gen_ifdef_macro (node->flat_name ()); os->indent (); *os << "class " << idl_global->export_macro () 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 6b3e59fdae6..f5647a4e9b1 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ctor.cpp @@ -126,7 +126,7 @@ int be_visitor_exception_ctor::visit_array (be_array *node) if (this->ctx_->state () != TAO_CodeGen::TAO_EXCEPTION_CTOR_CH && !tdef) - *os << this->ctx_->scope ()->fullname () << "::"; + *os << this->ctx_->scope ()->full_name () << "::"; if (!tdef) *os << "_"; diff --git a/TAO/TAO_IDL/be/be_visitor_factory.cpp b/TAO/TAO_IDL/be/be_visitor_factory.cpp index bbb90a662dd..1f66014a5f6 100644 --- a/TAO/TAO_IDL/be/be_visitor_factory.cpp +++ b/TAO/TAO_IDL/be/be_visitor_factory.cpp @@ -125,19 +125,24 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_MODULE_CH: return new be_visitor_module_ch (new_ctx); + case TAO_CodeGen::TAO_MODULE_SH: return new be_visitor_module_sh (new_ctx); + case TAO_CodeGen::TAO_MODULE_IH: return new be_visitor_module_ih (new_ctx); + case TAO_CodeGen::TAO_MODULE_CI: case TAO_CodeGen::TAO_MODULE_CS: case TAO_CodeGen::TAO_MODULE_SI: case TAO_CodeGen::TAO_MODULE_SS: case TAO_CodeGen::TAO_MODULE_IS: return new be_visitor_module (new_ctx); + case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: return new be_visitor_module_any_op (new_ctx); + case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: @@ -145,6 +150,7 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_INTERFACE_CH: return new be_visitor_interface_ch (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_CI: return new be_visitor_interface_ci (new_ctx); @@ -152,27 +158,38 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) return new be_visitor_interface_cs (new_ctx); case TAO_CodeGen::TAO_INTERFACE_SH: + case TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_CH: return new be_visitor_interface_sh (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_IH: return new be_visitor_interface_ih (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_SI: return new be_visitor_interface_si (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_SS: + case TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_CS: return new be_visitor_interface_ss (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_IS: return new be_visitor_interface_is (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_COLLOCATED_SH: + case TAO_CodeGen::TAO_AMI_HANDLER_INTERFACE_THRU_POA_COLLOCATED_CH: return new be_visitor_interface_thru_poa_collocated_sh (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_THRU_POA_COLLOCATED_SS: + case TAO_CodeGen::TAO_AMI_HANDLER_INTERFACE_THRU_POA_COLLOCATED_CS: return new be_visitor_interface_thru_poa_collocated_ss (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_DIRECT_COLLOCATED_SH: + case TAO_CodeGen::TAO_AMI_HANDLER_INTERFACE_DIRECT_COLLOCATED_CH: return new be_visitor_interface_direct_collocated_sh (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_DIRECT_COLLOCATED_SS: + case TAO_CodeGen::TAO_AMI_HANDLER_INTERFACE_DIRECT_COLLOCATED_CS: return new be_visitor_interface_direct_collocated_ss (new_ctx); - case TAO_CodeGen::TAO_COLLOCATED_AMI_HANDLER_CH: - return new be_visitor_interface_collocated_ami_handler_ch (new_ctx); - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: return new be_visitor_interface_any_op_ch (new_ctx); case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: @@ -189,7 +206,9 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) return new be_visitor_interface_cdr_op_cs (new_ctx); case TAO_CodeGen::TAO_INTERFACE_FWD_CH: + //case TAO_CodeGen::TAO_AMI_HANDLER_FWD_CH: return new be_visitor_interface_fwd_ch (new_ctx); + case TAO_CodeGen::TAO_INTERFACE_FWD_CI: return new be_visitor_interface_fwd_ci (new_ctx); case TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI: @@ -455,17 +474,22 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) // noop. return new be_visitor_decl (new_ctx); + // @@ Michael: With the strategy we can use the default one. case TAO_CodeGen::TAO_AMI_HANDLER_FWD_CH: - return new be_visitor_interface_ami_handler_fwd_ch (new_ctx); + return new be_visitor_interface_ami_handler_fwd_ch (new_ctx); case TAO_CodeGen::TAO_AMI_HANDLER_FWD_CI: return new be_visitor_interface_ami_handler_fwd_ci (new_ctx); + // @@ Michael: We use 1:1 the server servant code, but + // use different operations. +#if 0 case TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_CH: return new be_visitor_interface_ami_handler_servant_ch (new_ctx); case TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_CS: return new be_visitor_interface_ami_handler_servant_cs (new_ctx); +#endif /* 0 */ case TAO_CodeGen::TAO_AMI_HANDLER_STUB_CH: return new be_visitor_interface_ami_handler_stub_ch (new_ctx); @@ -476,6 +500,12 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RESULT_ARG: return new be_visitor_args_ami_handler_result_arg (new_ctx); + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_THRU_POA_COLLOCATED_CH: + return new be_visitor_operation_ami_handler_thru_poa_collocated_ch(new_ctx); + + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_THRU_POA_COLLOCATED_CS: + return new be_visitor_operation_ami_handler_thru_poa_collocated_cs(new_ctx); + default: // an error delete new_ctx; @@ -530,10 +560,6 @@ TAO_Interpretive_Visitor_Factory::make_visitor (be_visitor_context *ctx) return new be_visitor_operation_direct_collocated_sh (new_ctx); case TAO_CodeGen::TAO_OPERATION_DIRECT_COLLOCATED_SS: return new be_visitor_operation_direct_collocated_ss (new_ctx); - - case TAO_CodeGen::TAO_COLLOCATED_AMI_HANDLER_OPERATION_CH: - return new be_visitor_operation_ami_handler_operation_ch (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETTYPE_CH: case TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS: return new be_visitor_operation_rettype (new_ctx); @@ -582,7 +608,6 @@ TAO_Interpretive_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS: case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS: case TAO_CodeGen::TAO_AMI_OPERATION_ARG_INVOKE_CS: - // @@ Michael case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_INVOKE_CS: case TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS: case TAO_CodeGen::TAO_OPERATION_ARG_PRE_UPCALL_SS: case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: @@ -609,7 +634,6 @@ TAO_Interpretive_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_ARGUMENT_INVOKE_CS: case TAO_CodeGen::TAO_AMI_ARGUMENT_INVOKE_CS: - // @@ Michael case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_INVOKE_CS: return new be_visitor_args_docall_cs (new_ctx); case TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS: @@ -720,9 +744,6 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_OPERATION_DIRECT_COLLOCATED_SS: return new be_visitor_operation_direct_collocated_ss (new_ctx); - case TAO_CodeGen::TAO_COLLOCATED_AMI_HANDLER_OPERATION_CH: - return new be_visitor_operation_ami_handler_operation_ch (new_ctx); - case TAO_CodeGen::TAO_OPERATION_RETTYPE_CH: case TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS: return new be_visitor_operation_rettype (new_ctx); @@ -784,27 +805,23 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_OPERATION_ARG_POST_MARSHAL_SS: case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_DECL_CS: case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_UPCALL_CS: + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_COLLOCATED_ARG_UPCALL_CS: return new be_visitor_operation_argument (new_ctx); case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: case TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS: return new be_compiled_visitor_operation_argument_marshal (new_ctx); - case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_MARSHAL_CS: - case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_DEMARSHAL_CS: - return new be_compiled_visitor_operation_ami_handler_argument_marshal (new_ctx); - - case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS: - case TAO_CodeGen::TAO_AMI_OPERATION_ARG_INVOKE_CS: - // @@ Michael case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_INVOKE_CS: - return new be_compiled_visitor_operation_argument_invoke (new_ctx); - case TAO_CodeGen::TAO_OPERATION_TIE_SH: return new be_visitor_operation_tie_sh (new_ctx); case TAO_CodeGen::TAO_OPERATION_TIE_SI: return new be_visitor_operation_tie_si (new_ctx); + case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS: + case TAO_CodeGen::TAO_AMI_OPERATION_ARG_INVOKE_CS: + return new be_compiled_visitor_operation_argument_invoke (new_ctx); + case TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH: case TAO_CodeGen::TAO_ARGUMENT_ARGLIST_OTHERS: return new be_visitor_args_arglist (new_ctx); @@ -814,7 +831,6 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_ARGUMENT_INVOKE_CS: case TAO_CodeGen::TAO_AMI_ARGUMENT_INVOKE_CS: - // @@ Michael case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_INVOKE_CS: return new be_visitor_args_compiled_marshal_cs (new_ctx); case TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS: @@ -823,9 +839,6 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS: return new be_compiled_visitor_args_vardecl_ss (new_ctx); - case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS: - return new be_compiled_visitor_args_ami_handler_vardecl_cs (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_PRE_UPCALL_SS: // this is a NO-OP return new be_visitor_decl (new_ctx); @@ -834,9 +847,6 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS: return new be_visitor_args_upcall_ss (new_ctx); - case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS: - return new be_visitor_args_ami_handler_upcall_cs (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_POST_UPCALL_SS: // this is a NO-OP return new be_visitor_decl (new_ctx); @@ -845,10 +855,6 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_ARGUMENT_MARSHAL_SS: return new be_visitor_args_compiled_marshal_ss (new_ctx); - case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_DEMARSHAL_CS: - case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_MARSHAL_CS: - return new be_visitor_args_ami_handler_compiled_marshal_cs (new_ctx); - case TAO_CodeGen::TAO_ARGUMENT_POST_MARSHAL_SS: // this is a NO-OP return new be_visitor_decl (new_ctx); @@ -872,6 +878,17 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_ARGUMENT_AMI_ARGLIST_CS: return new be_visitor_args_ami_arglist (new_ctx); + case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS: + return new be_compiled_visitor_args_ami_handler_vardecl_cs (new_ctx); + + case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS: + case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_COLLOCATED_UPCALL_CS: + return new be_visitor_args_ami_handler_upcall_cs (new_ctx); + + case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_DEMARSHAL_CS: + case TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_MARSHAL_CS: + return new be_visitor_args_ami_handler_compiled_marshal_cs (new_ctx); + case TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_OPERATION_CH: case TAO_CodeGen::TAO_AMI_HANDLER_STUB_OPERATION_CH: return new be_visitor_operation_ami_handler_operation_ch (new_ctx); @@ -879,6 +896,9 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_AMI_HANDLER_STUB_OPERATION_CS: return new be_compiled_visitor_operation_ami_handler_operation_cs (new_ctx); + case TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_OPERATION_CS: + return new be_compiled_visitor_operation_ami_handler_servant_operation_cs (new_ctx); + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGLIST_CH: case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGLIST_CS: return new be_visitor_operation_ami_handler_arglist (new_ctx); @@ -893,6 +913,10 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_AMI_HANDLER_SKELETON_CS: return new be_compiled_visitor_operation_ami_handler_skeleton_cs (new_ctx); + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_MARSHAL_CS: + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_DEMARSHAL_CS: + return new be_compiled_visitor_operation_ami_handler_argument_marshal (new_ctx); + default: // cannot handle it; delegate it to the common visitor factory delete new_ctx; diff --git a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp index 78aa5dbb7e0..21272a2a32b 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp @@ -87,7 +87,7 @@ be_visitor_field_cdr_op_ci::visit_array (be_array *node) } // for anonymous arrays, the type name has a _ prepended. We compute - // the fullname with or without the underscore and use it later on. + // the full_name with or without the underscore and use it later on. char fname [NAMEBUFSIZE]; // to hold the full and // save the node's local name and full name in a buffer for quick @@ -105,18 +105,18 @@ be_visitor_field_cdr_op_ci::visit_array (be_array *node) { be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), + ACE_OS::sprintf (fname, "%s::_%s", parent->full_name (), node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); + ACE_OS::sprintf (fname, "_%s", node->full_name ()); } } else { // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); + ACE_OS::sprintf (fname, "%s", node->full_name ()); } // check what is the code generation substate. Are we generating @@ -766,7 +766,7 @@ be_visitor_cdr_op_field_decl::visit_array (be_array *node) } // for anonymous arrays, the type name has a _ prepended. We compute - // the fullname with or without the underscore and use it later on. + // the full_name with or without the underscore and use it later on. char fname [NAMEBUFSIZE]; // to hold the full and ACE_OS::memset (fname, '\0', NAMEBUFSIZE); @@ -781,18 +781,18 @@ be_visitor_cdr_op_field_decl::visit_array (be_array *node) if (node->is_nested ()) { be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), + ACE_OS::sprintf (fname, "%s::_%s", parent->full_name (), node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->fullname ()); + ACE_OS::sprintf (fname, "_%s", node->full_name ()); } } else { // typedefed node - ACE_OS::sprintf (fname, "%s", node->fullname ()); + ACE_OS::sprintf (fname, "%s", node->full_name ()); } // check what is the code generation substate. Are we generating code for diff --git a/TAO/TAO_IDL/be/be_visitor_interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface.cpp index 1ac9ed473ea..836a757e6e2 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface.cpp @@ -45,10 +45,13 @@ #include "be_visitor_interface/cdr_op_cs.cpp" #include "be_visitor_interface/ami_handler_fwd_ch.cpp" #include "be_visitor_interface/ami_handler_fwd_ci.cpp" -#include "be_visitor_interface/ami_handler_servant_ch.cpp" -#include "be_visitor_interface/ami_handler_servant_cs.cpp" #include "be_visitor_interface/ami_handler_stub_ch.cpp" #include "be_visitor_interface/ami_handler_stub_cs.cpp" + +#if 0 /* We are using normal servant code */ #include "be_visitor_interface/collocated_ami_handler_ch.cpp" +#include "be_visitor_interface/ami_handler_servant_ch.cpp" +#include "be_visitor_interface/ami_handler_servant_cs.cpp" +#endif /* 0 */ ACE_RCSID(be, be_visitor_interface, "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_cs.cpp index 62eae6c6da5..dd167168c8c 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_cs.cpp @@ -67,9 +67,9 @@ be_visitor_ ami_handler_cs::visit_interface (be_interface *node) be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); if (parent != 0 && - parent->fullname () != 0 && - ACE_OS::strlen (parent->fullname ())) - scope_len = ACE_OS::strlen (parent->fullname ()) + ACE_OS::strlen ("::"); + parent->full_name () != 0 && + ACE_OS::strlen (parent->full_name ())) + scope_len = ACE_OS::strlen (parent->full_name ()) + ACE_OS::strlen ("::"); ACE_NEW_RETURN (full_name, char [scope_len + @@ -80,11 +80,11 @@ be_visitor_ ami_handler_cs::visit_interface (be_interface *node) -1); if (parent != 0 && - parent->fullname () != 0 && - ACE_OS::strlen (parent->fullname ())) + parent->full_name () != 0 && + ACE_OS::strlen (parent->full_name ())) ACE_OS::sprintf (full_name, "%s::AMI_%s_Handler", - parent->fullname (), + parent->full_name (), node->local_name ()->get_string ()); else ACE_OS::sprintf (full_name, diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_fwd_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_fwd_ch.cpp index edd92eb656f..30ae6b541b2 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_fwd_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_fwd_ch.cpp @@ -57,32 +57,15 @@ be_visitor_interface_ami_handler_fwd_ch::visit_interface (be_interface *node) os->indent (); // Generate forward declaration class. - *os << "class " - << "AMI_" << node->local_name () << "_Handler" << ";" + *os << "class " << node->local_name () << ";" << be_nl; - // Create a string "AMI_<interface name>_Handler". We can use - // this for defining all _Var, _out,etc. - char *interface_name = 0; - ACE_NEW_RETURN (interface_name, - char [ACE_OS::strlen ("AMI_") + - ACE_OS::strlen (node->flatname ()) + - ACE_OS::strlen ("_Handler") + - // end of string - 1], - 0); - ACE_OS::sprintf (interface_name, - "AMI_%s_Handler", - node->flatname ()); - // Generate the ifdefined macro for the _ptr type. - os->gen_ifdef_macro (interface_name, "_ptr"); + os->gen_ifdef_macro (node->flat_name (), "_ptr"); // Generate the _ptr declaration - *os << "typedef " - << "AMI_" << node->local_name () << "_Handler" - << " *" - << "AMI_" << node->local_name () << "_Handler" << "_ptr;" + *os << "typedef " << node->local_name () + << " *" << node->local_name () << "_ptr;" << be_nl; // Generate the endif. @@ -91,10 +74,10 @@ be_visitor_interface_ami_handler_fwd_ch::visit_interface (be_interface *node) // Generate the var class. // Enclose under an ifdef macro - os->gen_ifdef_macro (interface_name, "_var"); + os->gen_ifdef_macro (node->local_name (), "_var"); // Generate the _var declaration. - if (node->gen_var_defn (interface_name) == -1) + if (node->gen_var_defn ((char *) node->local_name ()) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ami_handler_fwd_ch::" @@ -108,11 +91,11 @@ be_visitor_interface_ami_handler_fwd_ch::visit_interface (be_interface *node) // Generate the our class. // Enclose under an ifdef macro. - os->gen_ifdef_macro (interface_name, "_out"); + os->gen_ifdef_macro (node->local_name (), "_out"); // Generate the _out declaration - ORBOS/97-05-15 pg 16-20 // spec. - if (node->gen_out_defn (interface_name) == -1) + if (node->gen_out_defn ( (char *) node->local_name ()) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ami_handler_fwd_ch::" diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_fwd_ci.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_fwd_ci.cpp index d4f94f6198a..21402995ebb 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_fwd_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_fwd_ci.cpp @@ -57,91 +57,29 @@ be_visitor_interface_ami_handler_fwd_ci::visit_interface (be_interface *node) os = this->ctx_->stream (); // Start from the current indentation level. - os->indent (); - - // Create the full name and local name for the AMI_<Interface - // name>_Handler interface. - char *full_name = 0; - char *local_name = 0; - - // Full name. - // If there exists a scope name for this, then generate - // "Scope::AMI_<Local Name>_Handler". - - size_t scope_len = 0; - - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - - if (parent != 0 && - parent->fullname () != 0 && - ACE_OS::strlen (parent->fullname ())) - scope_len = ACE_OS::strlen (parent->fullname ()) + ACE_OS::strlen ("::"); - - ACE_NEW_RETURN (full_name, - char [scope_len + - ACE_OS::strlen ("AMI_") + - ACE_OS::strlen (node->local_name ()->get_string ()) + - ACE_OS::strlen ("_Handler") + - 1], - -1); - - if (parent != 0 && - parent->fullname () != 0 && - ACE_OS::strlen (parent->fullname ())) - ACE_OS::sprintf (full_name, - "%s::AMI_%s_Handler", - parent->fullname (), - node->local_name ()->get_string ()); - else - ACE_OS::sprintf (full_name, - "AMI_%s_Handler", - node->local_name ()->get_string ()); - - // Local name. - - ACE_NEW_RETURN (local_name, - char [ACE_OS::strlen ("AMI_") + - ACE_OS::strlen (node->local_name ()->get_string ()) + - ACE_OS::strlen ("_Handler") + - 1], - -1); - - ACE_OS::sprintf (local_name, - "AMI_%s_Handler", - node->local_name ()->get_string ()); - - // Generate the constructors and destructor. + os->indent (); // start from the current indentation level + // generate the constructors and destructor *os << "ACE_INLINE" << be_nl; - *os << full_name << "::" << local_name - << " (void) // default constructor" << be_nl; + *os << node->full_name () << "::" << node->local_name () << + " (void) // default constructor" << be_nl; *os << "{}" << be_nl << be_nl; *os << "ACE_INLINE" << be_nl; - *os << full_name << "::" << local_name - << " (TAO_Stub *objref, TAO_ServantBase *_tao_servant, " - << "CORBA::Boolean _tao_collocated) // constructor" - << be_nl - << " : CORBA_Object (objref, _tao_servant, _tao_collocated)" - << be_nl - << "{}" << be_nl << be_nl; + *os << node->full_name () << "::" << node->local_name () << + " (TAO_Stub *objref, TAO_ServantBase *_tao_servant, " + << "CORBA::Boolean _tao_collocated) // constructor" << be_nl; + *os << " : CORBA_Object (objref, _tao_servant, _tao_collocated)" << be_nl; + *os << "{}" << be_nl << be_nl; *os << "ACE_INLINE" << be_nl; - *os << full_name << "::~" << local_name - << " (void) // destructor" << be_nl - << "{}\n\n"; - - // _nil method. - *os << "ACE_INLINE " - << full_name << "_ptr" << be_nl - << full_name << "::_nil (void)" << be_nl - << "{" << be_idt_nl - << "return (" << full_name << "_ptr)0;" << be_uidt_nl - << "}" << be_nl << be_nl; - - // Generate the ifdefined macro for the _var type. - os->gen_ifdef_macro (full_name, "_var"); - if (node->gen_var_impl (full_name, local_name) == -1) + *os << node->full_name () << "::~" << node->local_name () << + " (void) // destructor" << be_nl; + *os << "{}\n\n"; + + // generate the ifdefined macro for the _var type + os->gen_ifdef_macro (node->flat_name (), "_var"); + if (node->gen_var_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ci::" @@ -150,10 +88,9 @@ be_visitor_interface_ami_handler_fwd_ci::visit_interface (be_interface *node) } os->gen_endif (); - // Generate the ifdefined macro for the _out type. - os->gen_ifdef_macro (full_name, "_out"); - if (node->gen_out_impl (full_name, - local_name) == -1) + // generate the ifdefined macro for the _out type + os->gen_ifdef_macro (node->flat_name (), "_out"); + if (node->gen_out_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ci::" @@ -162,5 +99,6 @@ be_visitor_interface_ami_handler_fwd_ci::visit_interface (be_interface *node) } os->gen_endif (); + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_servant_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_servant_ch.cpp index 899412c61fb..35b65481bc6 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_servant_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_servant_ch.cpp @@ -45,6 +45,9 @@ be_visitor_interface_ami_handler_servant_ch::~be_visitor_interface_ami_handler_s int be_visitor_interface_ami_handler_servant_ch::visit_interface (be_interface *node) { + be_interface_type_strategy *old_strategy = + node->set_strategy (new be_interface_ami_handler_strategy (node)); + // Output stream. TAO_OutStream *os; @@ -72,20 +75,20 @@ be_visitor_interface_ami_handler_servant_ch::visit_interface (be_interface *node { // we are outermost ACE_OS::sprintf (namebuf, - "POA_AMI_%s_Handler", - node->local_name ()->get_string ()); + "POA_%s", + node->local_name ()); } else { ACE_OS::sprintf (namebuf, - "AMI_%s_Handler", - node->local_name ()->get_string ()); + "%s", + node->local_name ()); } // AMI Handler object's name. ACE_OS::sprintf (ami_handler, - "AMI_%s_Handler", - node->local_name ()->get_string ()); + "%s", + node->local_name ()); *os << "class " << namebuf << ";" << be_nl; @@ -164,7 +167,7 @@ be_visitor_interface_ami_handler_servant_ch::visit_interface (be_interface *node << ");\n" << be_uidt_nl; // Print out the _this() method. - *os << ami_handler << " *_this (" << be_idt << be_idt_nl + *os << node->local_name () << " *_this (" << be_idt << be_idt_nl << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl << "TAO_default_environment ()" << be_uidt << be_uidt_nl @@ -202,20 +205,42 @@ be_visitor_interface_ami_handler_servant_ch::visit_interface (be_interface *node *os << be_uidt_nl << "};\n\n"; - // Generate the collocated class be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_COLLOCATED_AMI_HANDLER_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor *visitor = 0; + + // generate the collocated class + if (idl_global->gen_thru_poa_collocation ()) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ami_handler_servant_ch::" - "visit_interface - " - "codegen for collocated class failed\n"), - -1); + ctx.state (TAO_CodeGen::TAO_INTERFACE_THRU_POA_COLLOCATED_SH); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (node->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ami_handler_servant_ch::" + "visit_interface - " + "codegen for thru_poa_collocated class failed\n"), + -1); + } + } + + if (idl_global->gen_direct_collocation ()) + { + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_INTERFACE_DIRECT_COLLOCATED_SH); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (node->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ami_handler_servant_ch::" + "visit_interface - " + "codegen for direct_collocated class failed\n"), + -1); + } } + #if 0 // @@ Do this (Alex). // generate the TIE class. @@ -239,5 +264,7 @@ be_visitor_interface_ami_handler_servant_ch::visit_interface (be_interface *node ctx.stream (tao_cg->server_template_header ()); #endif /* 0 */ + delete node->set_strategy (old_strategy); + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_servant_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_servant_cs.cpp index 6c3be5f1597..e0e82be331a 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_servant_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_servant_cs.cpp @@ -12,6 +12,7 @@ // // = DESCRIPTION // Visitor generating code for Interfaces in the server skeletons file. +// !!!!!!!!!!!!!!! NOT USED ANY MORE !!!!!!!!!!!!!!!!!!!! // // = AUTHOR // Aniruddha Gokhale @@ -43,18 +44,18 @@ be_visitor_interface_ami_handler_servant_cs::~be_visitor_interface_ami_handler_s int be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream + be_interface_type_strategy *old_strategy = + node->set_strategy (new be_interface_ami_handler_strategy (node)); + + TAO_OutStream *os = this->ctx_->stream (); // output stream if (node->srv_skel_gen () || node->imported ()) return 0; - os = this->ctx_->stream (); - // generate the skeleton class name os->indent (); // start with whatever indentation level we are at - /* @@ Michael if (node->gen_operation_table () == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -64,25 +65,23 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node -1); } - */ // constructor *os << "// skeleton constructor" << be_nl; // find if we are at the top scope or inside some module if (!node->is_nested ()) { // we are outermost. So the POA_ prefix is prepended to our name - *os << node->ami_handler_full_skel_name () << "::POA_" << node->ami_handler_local_name () << + *os << node->full_skel_name () << "::POA_" << node->local_name () << " (void)" << be_nl; } else { // the POA_ prefix is prepended to our outermost module name - *os << node->ami_handler_full_skel_name () << "::" << node->ami_handler_local_name () << + *os << node->full_skel_name () << "::" << node->local_name () << " (void)" << be_nl; } - *os << "{" << be_idt_nl - << "this->optable_ = &tao_" << node->flatname () + << "this->optable_ = &tao_" << node->flat_name () << "_optable;" << be_uidt_nl << "}\n\n"; @@ -91,19 +90,18 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node if (!node->is_nested ()) { // we are outermost. So the POA_ prefix is prepended to our name - *os << node->ami_handler_full_skel_name () << "::POA_" - << node->ami_handler_local_name () << " (" - << "const POA_" << node->ami_handler_local_name () << "& rhs)"; + *os << node->full_skel_name () << "::POA_" + << node->local_name () << " (" + << "const POA_" << node->local_name () << "& rhs)"; } else { // the POA_ prefix is prepended to our outermost module name - *os << node->ami_handler_full_skel_name () << "::" - << node->ami_handler_local_name () << " (const " - << node->ami_handler_local_name () << "& rhs)"; + *os << node->full_skel_name () << "::" + << node->local_name () << " (const " + << node->local_name () << "& rhs)"; } - *os << be_idt_nl - << ": "; + *os << be_idt_nl << ": "; if (node->traverse_inheritance_graph (be_interface::copy_ctor_helper, os) == -1) ACE_ERROR_RETURN ((LM_ERROR, @@ -111,20 +109,18 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node " copy ctor generation failed\n"), -1); *os << " TAO_ServantBase (rhs)" << be_uidt_nl << "{}\n" << be_nl; - *os << "// skeleton destructor" << be_nl; - if (!node->is_nested ()) { // we are outermost. So the POA_ prefix is prepended to our name - *os << node->ami_handler_full_skel_name () << "::~POA_" << node->ami_handler_local_name () << - " (void)" << be_nl; + *os << node->full_skel_name () << "::~POA_" << node->local_name () + << " (void)" << be_nl; } else { // the POA_ prefix is prepended to our outermost module name - *os << node->ami_handler_full_skel_name () << "::~" << node->ami_handler_local_name () << - " (void)" << be_nl; + *os << node->full_skel_name () << "::~" << node->local_name () + << " (void)" << be_nl; } *os << "{\n"; *os << "}\n\n"; @@ -145,7 +141,7 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node // generate code for the _is_a skeleton os->indent (); - *os << "void " << node->ami_handler_full_skel_name () + *os << "void " << node->full_skel_name () << "::_is_a_skel (" << be_idt << be_idt_nl << "CORBA::ServerRequest &_tao_server_request, " << be_nl << "void * _tao_object_reference," << be_nl @@ -154,8 +150,8 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node << ")" << be_uidt_nl; *os << "{" << be_idt_nl; *os << "TAO_InputCDR &_tao_in = _tao_server_request.incoming ();" << be_nl; - *os << node->ami_handler_full_skel_name () << " *_tao_impl = (" - << node->ami_handler_full_skel_name () << " *) _tao_object_reference;" << be_nl; + *os << node->full_skel_name () << " *_tao_impl = (" + << node->full_skel_name () << " *) _tao_object_reference;" << be_nl; *os << "CORBA::Boolean _tao_retval = 0;" << be_nl; *os << "CORBA::String_var value;" << be_nl; *os << "if (!((_tao_in >> value.out ())))" << be_idt_nl; @@ -172,7 +168,7 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node // generate code for the _non_existent skeleton os->indent (); - *os << "void " << node->ami_handler_full_skel_name () + *os << "void " << node->full_skel_name () << "::_non_existent_skel (" << be_idt << be_idt_nl << "CORBA::ServerRequest &_tao_server_request, " << be_nl << "void * _tao_object_reference," << be_nl @@ -180,8 +176,8 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node << "CORBA::Environment &ACE_TRY_ENV" << be_uidt_nl << ")" << be_uidt_nl; *os << "{" << be_idt_nl; - *os << node->ami_handler_full_skel_name () << " *_tao_impl = (" - << node->ami_handler_full_skel_name () << " *) _tao_object_reference;" << be_nl; + *os << node->full_skel_name () << " *_tao_impl = (" + << node->full_skel_name () << " *) _tao_object_reference;" << be_nl; *os << "CORBA::Boolean _tao_retval = _tao_impl->_non_existent (ACE_TRY_ENV);" << be_nl; *os << "ACE_CHECK;" << be_nl << be_nl; *os << "_tao_server_request.init_reply (ACE_TRY_ENV);" << be_nl; @@ -193,7 +189,7 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node os->indent (); - *os << "CORBA::Boolean " << node->ami_handler_full_skel_name () + *os << "CORBA::Boolean " << node->full_skel_name () << "::_is_a (" << be_idt << be_idt_nl << "const char* value," << be_nl << "CORBA::Environment &ACE_TRY_ENV" << be_uidt_nl @@ -208,7 +204,6 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node "traversal of inhertance graph failed\n"), -1); } - os->indent (); *os << "(!ACE_OS::strcmp ((char *)value, " << "CORBA::_tc_Object->id (ACE_TRY_ENV))))" @@ -217,14 +212,14 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node << "return 0;" << be_uidt << be_uidt << be_uidt_nl << "}\n\n"; + // the downcast method. os->indent (); - *os << "void* " << node->ami_handler_full_skel_name () + *os << "void* " << node->full_skel_name () << "::_downcast (" << be_idt << be_idt_nl << "const char* logical_type_id" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl; - if (node->traverse_inheritance_graph (be_interface::downcast_helper, os) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -233,19 +228,17 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node "traversal of inhertance graph failed\n"), -1); } - *os << "if (ACE_OS::strcmp (logical_type_id, " << "\"IDL:omg.org/CORBA/Object:1.0\") == 0)" << be_idt_nl << "return ACE_static_cast(PortableServer::Servant, this);" << be_uidt_nl; - *os << "return 0;" << be_uidt_nl << "}\n\n"; // now the dispatch method os->indent (); - *os << "void " << node->ami_handler_full_skel_name () << + *os << "void " << node->full_skel_name () << "::_dispatch (CORBA::ServerRequest &req, " << "void *context, CORBA::Environment &ACE_TRY_ENV)" << be_nl; *os << "{\n"; @@ -265,83 +258,113 @@ be_visitor_interface_ami_handler_servant_cs::visit_interface (be_interface *node *os << "else" << be_idt_nl; *os << "skel (req, this, context, ACE_TRY_ENV);" << be_uidt << be_uidt_nl; *os << "}\n\n"; - os->indent (); - *os << "const char* " << node->ami_handler_full_skel_name () + *os << "const char* " << node->full_skel_name () << "::_interface_repository_id (void) const" << be_nl; *os << "{\n"; os->incr_indent (); *os << "return \"" << node->repoID () << "\";\n"; os->decr_indent (); - *os << "}\n\n"; - - *os << "\n"; + *os << "}\n\n\n"; // the _this () operation - *os << node->name () << "*" << be_nl - << node->ami_handler_full_skel_name () + + *os << node->full_name () << "*" << be_nl + << node->full_skel_name () << "::_this (CORBA_Environment &ACE_TRY_ENV)" << be_nl << "{" << be_idt_nl << "TAO_Stub *stub = this->_create_stub (ACE_TRY_ENV);" << be_nl - << "ACE_CHECK_RETURN (0);" << be_nl - // << "if (ACE_TRY_ENV.exception () != 0)" << be_idt_nl - // << "return 0;" << be_uidt_nl - - // @@ Michael: We need to check this value being passed. I am - // passing 1 right now. (Alex). - << "return new " << node->full_coll_name (1) - << " (this, stub);" << be_uidt_nl; - - *os << "}\n\n"; + << "ACE_CHECK_RETURN (0);" << be_nl + << "return new " ; + if (idl_global->gen_direct_collocation ()) + *os << node->full_coll_name (be_interface::DIRECT); + else if (idl_global->gen_thru_poa_collocation ()) + *os << node->full_coll_name (be_interface::THRU_POA); + *os << " (this, stub);" << be_uidt_nl + << "}\n\n"; // the _create_collocated_objref method *os << "void*" << be_nl - << node->ami_handler_full_skel_name () + << node->full_skel_name () << "::_create_collocated_objref (const char* repository_id, " << "CORBA::ULong type, TAO_Stub *stub)" << be_nl << "{" << be_idt_nl << "if (!ACE_OS::strcmp (\"" << node->repoID () << "\", repository_id))" << be_idt_nl << "return ACE_static_cast (" << be_idt << be_idt_nl - << node->name () << "_ptr," << be_nl + // @@ Michael: I changed the following line from node->name + // to "node->local_name". This might be wrong, but right + // now I think it is right .. + << node->local_name () << "_ptr," << be_nl + << "new "; - // @@ Michael: We need to check this value being passed. I am - // passing 1 right now. (Alex). - << "new " << node->full_coll_name (1) - << " (this, stub)" << be_uidt_nl + if (idl_global->gen_direct_collocation ()) + *os << node->full_coll_name (be_interface::DIRECT); + else if (idl_global->gen_thru_poa_collocation ()) + *os << node->full_coll_name (be_interface::THRU_POA); + + *os << " (this, stub)" << be_uidt_nl << ");" << be_uidt << be_uidt_nl << "return 0;" << be_uidt_nl << "}" << be_nl << be_nl; - // @@ Michael - /* + + // generate the collocated class impl - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (idl_global->gen_thru_poa_collocation ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ami_handler_servant_cs::" - "visit_interface - " - "Bad visitor for collocated class\n"), - -1); + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_INTERFACE_THRU_POA_COLLOCATED_CS); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface::" + "ami_handler_servant_cs- " + "Bad visitor for thru_poa collocated class\n"), + -1); + } + + if (node->accept (visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface::" + "ami_handler_servant_cs - " + "codegen for thru_poa collocated class failed\n"), + -1); + } + delete visitor; } - if (node->accept (visitor) == -1) + if (idl_global->gen_direct_collocation ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ami_handler_servant_cs::" - "visit_interface - " - "codegen for collocated class failed\n"), - -1); + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_INTERFACE_DIRECT_COLLOCATED_CS); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface::" + "ami_handler_servant_cs - " + "Bad visitor for direct collocated class\n"), + -1); + } + + if (node->accept (visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface::" + "ami_handler_servant_cs - " + "codegen for direct collocated class failed\n"), + -1); + } + delete visitor; } - delete visitor; *os << "\n\n"; - */ + delete node->set_strategy (old_strategy); return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_stub_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_stub_ch.cpp index c4ee9d201d3..47d01456928 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_stub_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_stub_ch.cpp @@ -53,40 +53,14 @@ be_visitor_interface_ami_handler_stub_ch::visit_interface (be_interface *node) // Ifdef guard. - // Generate AMI_...name..._Handler string. - char *ifdef_string = 0; - ACE_NEW_RETURN (ifdef_string, - char [ACE_OS::strlen ("AMI_") + - ACE_OS::strlen (node->flatname ()) + - ACE_OS::strlen ("_Handler") + - // end of string - 1], - 0); - ACE_OS::sprintf (ifdef_string, - "AMI_%s_Handler", - node->flatname ()); - - os->gen_ifdef_macro (ifdef_string); - - // Prepare the local name for the class. - char *local_name = 0; - ACE_NEW_RETURN (local_name, - char [ACE_OS::strlen ("AMI_") + - ACE_OS::strlen (node->local_name ()->get_string ()) + - ACE_OS::strlen ("_Handler") + - // end of string - 1], - 0); - ACE_OS::sprintf (local_name, - "AMI_%s_Handler", - node->local_name ()->get_string ()); + os->gen_ifdef_macro (node->flat_name ()); // Now generate the class definition. os->indent (); *os << "class " << idl_global->export_macro () << " " - << local_name; + << node->local_name (); // Node interface inherits from the Messaging::ReplyHandler // interface. @@ -101,29 +75,29 @@ be_visitor_interface_ami_handler_stub_ch::visit_interface (be_interface *node) // but we must protect against certain versions of g++ << "#if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8" << be_idt_nl - << "typedef " << local_name << "_ptr _ptr_type;" << be_nl - << "typedef " << local_name << "_var _var_type;" << be_uidt_nl + << "typedef " << node->local_name () << "_ptr _ptr_type;" << be_nl + << "typedef " << node->local_name () << "_var _var_type;" << be_uidt_nl << "#endif /* __GNUC__ */\n" << be_idt_nl // generate the static _duplicate, _narrow, and _nil operations << "// the static operations" << be_nl - << "static " << local_name << "_ptr " << "_duplicate (" - << local_name << "_ptr obj);" << be_nl - << "static " << local_name << "_ptr " + << "static " << node->local_name () << "_ptr " << "_duplicate (" + << node->local_name () << "_ptr obj);" << be_nl + << "static " << node->local_name () << "_ptr " << "_narrow (" << be_idt << be_idt_nl << "CORBA::Object_ptr obj," << be_nl << "CORBA::Environment &env = " << be_idt_nl << "TAO_default_environment ()" << be_uidt << be_uidt_nl << ");" << be_uidt_nl - << "static " << local_name << "_ptr " + << "static " << node->local_name () << "_ptr " << "_unchecked_narrow (" << be_idt << be_idt_nl << "CORBA::Object_ptr obj," << be_nl << "CORBA::Environment &env = " << be_idt_nl << "TAO_default_environment ()" << be_uidt << be_uidt_nl << ");" << be_uidt_nl - << "static " << local_name << "_ptr " << "_nil (void);\n\n"; + << "static " << node->local_name () << "_ptr " << "_nil (void);\n\n"; // Visit the scope to generate the stubs for the call back // methods. @@ -151,21 +125,21 @@ be_visitor_interface_ami_handler_stub_ch::visit_interface (be_interface *node) // generate the "protected" constructor so that users cannot instantiate // us *os << "protected:" << be_idt_nl - << local_name << " (void);" << be_nl - << local_name + << node->local_name () << " (void);" << be_nl + << node->local_name () << " (TAO_Stub *objref, " << be_idt << be_idt_nl << "TAO_ServantBase *_tao_servant = 0, " << be_nl << "CORBA::Boolean _tao_collocated = 0" << be_uidt_nl << ");" << be_uidt_nl - << "virtual ~" << local_name << " (void);" << be_uidt_nl; + << "virtual ~" << node->local_name () << " (void);" << be_uidt_nl; // private copy constructor and assignment operator. These are not // allowed, hence they are private. *os << "private:\n"; os->incr_indent (); - *os << local_name << " (const " << local_name << " &);" + *os << node->local_name () << " (const " << node->local_name () << " &);" << be_nl - << "void operator= (const " << local_name << " &);\n"; + << "void operator= (const " << node->local_name () << " &);\n"; os->decr_indent (); *os << "};\n\n"; @@ -186,13 +160,6 @@ be_visitor_interface_ami_handler_stub_ch::visit_interface (be_interface *node) "TypeCode declaration failed\n"), -1); } - - - // Delete the heap allocated vars. - delete ifdef_string; - ifdef_string = 0; - delete local_name; - local_name = 0; } return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_stub_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_stub_cs.cpp index e75034bd185..d0918b18262 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_stub_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_stub_cs.cpp @@ -43,6 +43,9 @@ be_visitor_interface_ami_handler_stub_cs::~be_visitor_interface_ami_handler_stub int be_visitor_interface_ami_handler_stub_cs::visit_interface (be_interface *node) { + be_interface_type_strategy *old_strategy = + node->set_strategy (new be_interface_ami_handler_strategy (node)); + // output stream. TAO_OutStream *os; @@ -67,29 +70,27 @@ be_visitor_interface_ami_handler_stub_cs::visit_interface (be_interface *node) be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); if (parent != 0 && - parent->fullname () != 0 && - ACE_OS::strlen (parent->fullname ())) - scope_len = ACE_OS::strlen (parent->fullname ()) + ACE_OS::strlen ("::"); + parent->full_name () != 0 && + ACE_OS::strlen (parent->full_name ())) + scope_len = ACE_OS::strlen (parent->full_name ()) + ACE_OS::strlen ("::"); ACE_NEW_RETURN (full_name, char [scope_len + - ACE_OS::strlen ("AMI_") + - ACE_OS::strlen (node->local_name ()->get_string ()) + - ACE_OS::strlen ("_Handler") + + ACE_OS::strlen (node->local_name ()) + 1], -1); if (parent != 0 && - parent->fullname () != 0 && - ACE_OS::strlen (parent->fullname ())) + parent->full_name () != 0 && + ACE_OS::strlen (parent->full_name ())) ACE_OS::sprintf (full_name, - "%s::AMI_%s_Handler", - parent->fullname (), - node->local_name ()->get_string ()); + "%s::%s", + parent->full_name (), + node->local_name ()); else ACE_OS::sprintf (full_name, - "AMI_%s_Handler", - node->local_name ()->get_string ()); + "%s", + node->local_name ()); // First generate the code for the static methods. @@ -103,7 +104,7 @@ be_visitor_interface_ami_handler_stub_cs::visit_interface (be_interface *node) << "if (CORBA::is_nil (obj))" << be_idt_nl << "return " << full_name << "::_nil ();" << be_uidt_nl << "if (!obj->_is_a (\"" - << node->compute_repoID ("AMI_", "_Handler") << "\", env))" + << node->repoID () << "\", env))" << be_idt_nl << "return " << full_name << "::_nil ();" << be_uidt_nl; @@ -114,48 +115,28 @@ be_visitor_interface_ami_handler_stub_cs::visit_interface (be_interface *node) // This may be necessary to work around a GCC compiler bug! // const char *skel_name = node->full_skel_name (); // unused at this time - // @@ Michael: We need to check this value being passed. I am - // passing 1 right now. (Alex). - const char *coll_name = node->full_coll_name (1); - assert (coll_name != 0); - + // the following full_name usage was node->name // The _unchecked_narrow method *os << full_name << "_ptr " << full_name << "::_unchecked_narrow (" << be_idt << be_idt_nl << "CORBA::Object_ptr obj," << be_nl - << "CORBA::Environment &ACE_TRY_ENV" << be_uidt_nl + << "CORBA::Environment &" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl - << "ACE_UNUSED_ARG (ACE_TRY_ENV);" << be_nl << "if (CORBA::is_nil (obj))" << be_idt_nl << "return " << full_name << "::_nil ();" << be_uidt_nl; *os << "TAO_Stub* stub = obj->_stubobj ();" << be_nl << "stub->_incr_refcnt ();" << be_nl; - *os << "void* servant = 0;" << be_nl; - *os << "if (obj->_is_collocated () " - << "&& obj->_servant() != 0)" << be_idt_nl - << "servant = obj->_servant()->_downcast (\"" - << "IDL:omg.org/CORBA/Object:1.0\");" << be_uidt_nl; - - *os << "if (servant != 0)" << be_idt_nl << "{" << be_idt_nl - // The collocated object reference factory is not working right (yet) - << full_name << "_ptr retv = ACE_reinterpret_cast (" << be_idt << be_idt_nl - << full_name << "_ptr," << be_nl - << "ACE_reinterpret_cast (" << be_idt << be_idt_nl - << "PortableServer::Servant," << be_nl - << "servant" << be_uidt_nl - << ")" << be_uidt_nl - << "->_create_collocated_objref (" << be_idt << be_idt_nl - << "\"" << node->compute_repoID ("AMI_", "_Handler") << "\"," << be_nl - << "TAO_ORB_Core::ORB_CONTROL," << be_nl - << "stub" << be_uidt_nl - << ")" << be_uidt << be_uidt_nl - << ");" << be_uidt_nl + + *os << "if (obj->_is_collocated () && _TAO_collocation_" << node->flat_name () + << "_Stub_Factory_function_pointer != 0)" << be_idt_nl + << "{" << be_idt_nl + << node->local_name () << "_ptr retv = _TAO_collocation_" + << node->flat_name () + << "_Stub_Factory_function_pointer (obj);" << be_nl << "if (retv != 0)" << be_idt_nl - << "return retv;" << be_uidt - // So we are still using the old way to create collocated objref. - << be_uidt_nl + << "return retv;" << be_uidt << be_uidt_nl << "}" << be_uidt_nl; *os << "return new " << full_name << "(stub);" << be_uidt_nl @@ -194,7 +175,7 @@ be_visitor_interface_ami_handler_stub_cs::visit_interface (be_interface *node) // Current interface. *os << "(!ACE_OS::strcmp ((char *)value, " << "\"" - << node->compute_repoID ("AMI_", "_Handler") + << node->repoID () << "\"" << ")) ||" << be_nl; @@ -223,7 +204,7 @@ be_visitor_interface_ami_handler_stub_cs::visit_interface (be_interface *node) << "::_interface_repository_id (void) const" << be_nl << "{" << be_idt_nl - << "return \"" << node->compute_repoID ("AMI_", "_Handler") << "\";" << be_uidt_nl + << "return \"" << node->repoID () << "\";" << be_uidt_nl << "}\n\n"; // By using a visitor to declare and define the TypeCode, we have the @@ -246,5 +227,7 @@ be_visitor_interface_ami_handler_stub_cs::visit_interface (be_interface *node) delete full_name; full_name = 0; + delete node->set_strategy (old_strategy); + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/any_op_ch.cpp index 4b5a6781d61..9913c49a288 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/any_op_ch.cpp @@ -53,12 +53,29 @@ be_visitor_interface_any_op_ch::visit_interface (be_interface *node) os->indent (); // Generate the stub factory function pointer declaration - *os << "extern " << node->name () << "_ptr (*_TAO_collocation_" - << node->flatname () << "_Stub_Factory_function_pointer) (" + *os << "extern " << node->full_name () << "_ptr (*_TAO_collocation_" + << node->flat_name () << "_Stub_Factory_function_pointer) (" << be_idt << be_idt_nl << "CORBA::Object_ptr obj" << be_uidt_nl << ");" << be_uidt_nl; + // @@ Michael: This might not be the right place .. + if (idl_global->ami_call_back () == I_TRUE) + { + // AMI Handler stuff + be_interface_type_strategy *old_strategy = + node->set_strategy (new be_interface_ami_handler_strategy (node)); + + // Generate the stub factory function pointer declaration + *os << "extern " << node->full_name () << "_ptr (*_TAO_collocation_" + << node->flat_name () << "_Stub_Factory_function_pointer) (" + << be_idt << be_idt_nl + << "CORBA::Object_ptr obj" << be_uidt_nl + << ");" << be_uidt_nl; + + delete node->set_strategy (old_strategy); + } + // generate the Any <<= and >>= operator declarations os->indent (); *os << "// Any operators for interface " << node->name () << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp index f3c758081c7..705f8a9c3a0 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp @@ -53,26 +53,45 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) os->indent (); // Generate the stub factory function pointer definition. - *os << node->name () << "_ptr (*"; + *os << node->full_name () << "_ptr (*"; *os << "_TAO_collocation_" - << node->flatname () << "_Stub_Factory_function_pointer) (" + << node->flat_name () << "_Stub_Factory_function_pointer) (" << be_idt << be_idt_nl << "CORBA::Object_ptr obj" << be_uidt_nl << ") = 0;" << be_uidt_nl; + // @@ Michael: This might not be the right place .. + if (idl_global->ami_call_back () == I_TRUE) + { + // AMI Handler stuff + be_interface_type_strategy *old_strategy = + node->set_strategy (new be_interface_ami_handler_strategy (node)); + + os->indent (); + // Generate the stub factory function pointer definition. + *os << node->full_name () << "_ptr (*"; + + *os << "_TAO_collocation_" + << node->flat_name () << "_Stub_Factory_function_pointer) (" + << be_idt << be_idt_nl + << "CORBA::Object_ptr obj" << be_uidt_nl + << ") = 0;" << be_uidt_nl; + + delete node->set_strategy (old_strategy); + } // generate the Any <<= and >>= operator declarations // Any <<= and >>= operators os->indent (); *os << "void operator<<= (CORBA::Any &_tao_any, " - << node->name () << "_ptr _tao_elem)" << be_nl + << node->full_name () << "_ptr _tao_elem)" << be_nl << "{" << be_idt_nl << "CORBA::Object_ptr *_tao_obj_ptr = 0;" << be_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl << "ACE_NEW (_tao_obj_ptr, CORBA::Object_ptr);" << be_nl - << "*_tao_obj_ptr = " << node->name () + << "*_tao_obj_ptr = " << node->full_name () << "::_duplicate (_tao_elem);" << be_nl << "_tao_any.replace (" << node->tc_name () << ", " << "_tao_obj_ptr, 1, ACE_TRY_ENV);" << be_nl @@ -86,12 +105,12 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) << "}\n" << be_nl; *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->name () << "_ptr &_tao_elem)" << be_nl + << node->full_name () << "_ptr &_tao_elem)" << be_nl << "{" << be_idt_nl << "CORBA::Object_ptr *tmp = 0;" << be_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl - << "_tao_elem = " << node->name () << "::_nil ();" << be_nl + << "_tao_elem = " << node->full_name () << "::_nil ();" << be_nl << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl << "if (!type->equal (" << node->tc_name () << ", ACE_TRY_ENV)) return 0; // not equal" << be_nl @@ -104,7 +123,7 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) << ", &_tao_obj_var.out (), 0, ACE_TRY_ENV)" << be_nl << " == CORBA::TypeCode::TRAVERSE_CONTINUE)" << be_nl << "{" << be_idt_nl - << "_tao_elem = " << node->name () + << "_tao_elem = " << node->full_name () << "::_narrow (_tao_obj_var.in (), ACE_TRY_ENV);" << be_nl << "ACE_TRY_CHECK;" << be_nl << "*tmp = (CORBA::Object_ptr) _tao_elem; // any owns the object" @@ -127,18 +146,18 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) *os << "#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)" << be_idt_nl << "template class TAO_Object_Field_T<" - << node->name () << "," - << node->name () << "_var>;" << be_uidt_nl + << node->full_name () << "," + << node->full_name () << "_var>;" << be_uidt_nl << "template class TAO_Object_Manager<" - << node->name () << "," - << node->name () << "_var>;" << be_uidt_nl + << node->full_name () << "," + << node->full_name () << "_var>;" << be_uidt_nl << "#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)" << be_nl << "# pragma instantiate TAO_Object_Field_T<" - << node->name () << "," - << node->name () << "_var>" << be_uidt_nl + << node->full_name () << "," + << node->full_name () << "_var>" << be_uidt_nl << "# pragma instantiate TAO_Object_Manager<" - << node->name () << "," - << node->name () << "_var>" << be_uidt_nl + << node->full_name () << "," + << node->full_name () << "_var>" << be_uidt_nl << "#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */\n\n"; // all we have to do is to visit the scope and generate code diff --git a/TAO/TAO_IDL/be/be_visitor_interface/collocated_ami_handler_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/collocated_ami_handler_ch.cpp index 9f30a1799c1..05aa4eb1f6c 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/collocated_ami_handler_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/collocated_ami_handler_ch.cpp @@ -47,44 +47,19 @@ be_visitor_interface_collocated_ami_handler_ch::visit_interface (be_interface *n { TAO_OutStream *os = this->ctx_->stream (); - // Generate AMI_...name..._Handler string. - char *ifdef_string = 0; - ACE_NEW_RETURN (ifdef_string, - char [ACE_OS::strlen ("AMI_") + - ACE_OS::strlen (node->flatname ()) + - ACE_OS::strlen ("_Handler") + - // end of string - 1], - 0); - ACE_OS::sprintf (ifdef_string, - "AMI_%s_Handler", - node->flatname ()); - - os->gen_ifdef_macro (ifdef_string, "_collocated"); - - // Prepare the local name for the class. - char *local_name = 0; - ACE_NEW_RETURN (local_name, - char [ACE_OS::strlen ("AMI_") + - ACE_OS::strlen (node->local_name ()->get_string ()) + - ACE_OS::strlen ("_Handler") + - // end of string - 1], - 0); - ACE_OS::sprintf (local_name, - "AMI_%s_Handler", - node->local_name ()->get_string ()); - - // Get the coll names. - char *coll_local_name, *coll_full_name; - node->compute_coll_names (local_name, coll_local_name, coll_full_name); + os->gen_ifdef_macro (node->flat_name (), "_collocated"); // Output the class defn. os->indent (); - *os << "class " << idl_global->export_macro () - << " " << coll_local_name; + *os << "class " << idl_global->export_macro () << " "; + + if (idl_global->gen_direct_collocation ()) + *os << node->local_coll_name (be_interface::DIRECT); + else if (idl_global->gen_thru_poa_collocation ()) + *os << node->local_coll_name (be_interface::THRU_POA); + os->incr_indent (); - *os << " : public virtual " << local_name; + *os << " : public virtual " << node->local_name (); *os << "\n"; os->decr_indent (); @@ -92,7 +67,11 @@ be_visitor_interface_collocated_ami_handler_ch::visit_interface (be_interface *n *os << "public:\n"; os->incr_indent (); - *os << coll_local_name << " (\n"; + if (idl_global->gen_direct_collocation ()) + *os << node->local_coll_name (be_interface::DIRECT) << " (\n"; + else if (idl_global->gen_thru_poa_collocation ()) + *os << node->local_coll_name (be_interface::THRU_POA) << " (\n"; + os->incr_indent (0); os->incr_indent (); @@ -105,7 +84,7 @@ be_visitor_interface_collocated_ami_handler_ch::visit_interface (be_interface *n *os << "POA_"; } - *os << local_name << "_ptr " + *os << node->local_name () << "_ptr " << " servant," << be_nl; *os << "TAO_Stub *stub\n"; @@ -131,7 +110,7 @@ be_visitor_interface_collocated_ami_handler_ch::visit_interface (be_interface *n *os << "POA_"; } - *os << local_name + *os << node->local_name () << "_ptr _get_servant (void) const;" << be_nl << be_nl; // _non_existent method. @@ -160,15 +139,11 @@ be_visitor_interface_collocated_ami_handler_ch::visit_interface (be_interface *n // POA_ prefix that goes with it. *os << "POA_"; } - *os << local_name << "_ptr servant_;\n"; + *os << node->local_name () << "_ptr servant_;\n"; os->decr_indent (); *os << "};\n\n"; os->gen_endif (); - delete ifdef_string; - delete local_name; - delete coll_local_name; - delete coll_full_name; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_sh.cpp index 277da8eece2..aa9bc2ee0c9 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_sh.cpp @@ -46,7 +46,7 @@ int be_visitor_interface_direct_collocated_sh::visit_interface (be_interface *no { TAO_OutStream *os = this->ctx_->stream (); - os->gen_ifdef_macro (node->flatname (), "_direct_collocated"); + os->gen_ifdef_macro (node->flat_name (), "_direct_collocated"); // output the class defn os->indent (); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_ss.cpp index 46e690ae815..153e94e3dd6 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/direct_collocated_ss.cpp @@ -44,10 +44,11 @@ be_visitor_interface_direct_collocated_ss::~be_visitor_interface_direct_collocat int be_visitor_interface_direct_collocated_ss::visit_interface (be_interface *node) { - TAO_OutStream *os = tao_cg->server_skeletons (); + TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); + os->indent (); *os << node->full_coll_name (be_interface::DIRECT) << "::" << node->local_coll_name (be_interface::DIRECT) << " (\n"; diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp index b9b7d3ba804..f73d03f9417 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp @@ -430,23 +430,24 @@ be_visitor_interface::visit_operation (be_operation *node) case TAO_CodeGen::TAO_INTERFACE_DIRECT_COLLOCATED_SS: ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_COLLOCATED_SS); break; - case TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_CH: ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_OPERATION_CH); break; - + case TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_CS: + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_SERVANT_OPERATION_CS); + break; case TAO_CodeGen::TAO_AMI_HANDLER_STUB_CH: ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_STUB_OPERATION_CH); break; - - case TAO_CodeGen::TAO_AMI_HANDLER_STUB_CS: + case TAO_CodeGen::TAO_AMI_HANDLER_STUB_CS: ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_STUB_OPERATION_CS); break; - - case TAO_CodeGen::TAO_COLLOCATED_AMI_HANDLER_CH: - ctx.state (TAO_CodeGen::TAO_COLLOCATED_AMI_HANDLER_OPERATION_CH); + case TAO_CodeGen::TAO_AMI_HANDLER_INTERFACE_THRU_POA_COLLOCATED_CS: + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_THRU_POA_COLLOCATED_CS); + break; + case TAO_CodeGen::TAO_AMI_HANDLER_INTERFACE_THRU_POA_COLLOCATED_CH: + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_THRU_POA_COLLOCATED_CH); break; - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp index 805b95c7bd8..c7b6dfc0e45 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp @@ -54,6 +54,9 @@ be_visitor_interface_ch::visit_interface (be_interface *node) if (idl_global->ami_call_back () == I_TRUE) { + be_interface_type_strategy *old_strategy = + node->set_strategy (new be_interface_ami_handler_strategy (node)); + // Set the context. be_visitor_context ctx (*this->ctx_); @@ -82,6 +85,8 @@ be_visitor_interface_ch::visit_interface (be_interface *node) -1); } delete visitor; + + delete node->set_strategy (old_strategy); } // Grab the stream. @@ -90,7 +95,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) // == STEP 1: generate the class name and class names we inherit == // generate the ifdefined macro for the _ptr type - os->gen_ifdef_macro (node->flatname (), "_ptr"); + os->gen_ifdef_macro (node->flat_name (), "_ptr"); // the following two are required to be under the ifdef macro to avoid @@ -106,7 +111,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) os->gen_endif (); // generate the ifdefined macro for the var type - os->gen_ifdef_macro (node->flatname (), "_var"); + os->gen_ifdef_macro (node->flat_name (), "_var"); // generate the _var declaration if (node->gen_var_defn () == -1) @@ -119,7 +124,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) os->gen_endif (); // generate the ifdef macro for the _out class - os->gen_ifdef_macro (node->flatname (), "_out"); + os->gen_ifdef_macro (node->flat_name (), "_out"); // generate the _out declaration - ORBOS/97-05-15 pg 16-20 spec if (node->gen_out_defn () == -1) @@ -133,7 +138,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) os->gen_endif (); // now the interface definition itself - os->gen_ifdef_macro (node->flatname ()); + os->gen_ifdef_macro (node->flat_name ()); // now generate the class definition *os << "class " << idl_global->export_macro () @@ -247,14 +252,12 @@ be_visitor_interface_ch::visit_interface (be_interface *node) // private copy constructor and assignment operator. These are not // allowed, hence they are private. - *os << "private:\n"; - os->incr_indent (); + *os << "private:" << be_idt_nl; *os << node->local_name () << " (const " << node->local_name () << " &);" << be_nl - << "void operator= (const " << node->local_name () << " &);\n"; - - os->decr_indent (); + << "void operator= (const " << node->local_name () << " &);" << be_uidt_nl; *os << "};\n\n"; + os->gen_endif (); // by using a visitor to declare and define the TypeCode, we have the @@ -281,6 +284,10 @@ be_visitor_interface_ch::visit_interface (be_interface *node) { // = Generate the default stub code for Handler. + be_interface_type_strategy *old_strategy = + node->set_strategy (new be_interface_ami_handler_strategy (node)); + + // Set the context. be_visitor_context ctx (*this->ctx_); @@ -340,6 +347,8 @@ be_visitor_interface_ch::visit_interface (be_interface *node) -1); } delete visitor; + + delete node->set_strategy (old_strategy); } node->cli_hdr_gen (I_TRUE); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp index c3f77bab5fc..2030f023947 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp @@ -70,7 +70,7 @@ be_visitor_interface_ci::visit_interface (be_interface *node) *os << "{}\n\n"; // generate the ifdefined macro for the _var type - os->gen_ifdef_macro (node->flatname (), "_var"); + os->gen_ifdef_macro (node->flat_name (), "_var"); if (node->gen_var_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -81,7 +81,7 @@ be_visitor_interface_ci::visit_interface (be_interface *node) os->gen_endif (); // generate the ifdefined macro for the _out type - os->gen_ifdef_macro (node->flatname (), "_out"); + os->gen_ifdef_macro (node->flat_name (), "_out"); if (node->gen_out_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -105,6 +105,9 @@ be_visitor_interface_ci::visit_interface (be_interface *node) if (idl_global->ami_call_back () == I_TRUE) { + be_interface_type_strategy *old_strategy = + node->set_strategy (new be_interface_ami_handler_strategy (node)); + // Set the context. be_visitor_context ctx (*this->ctx_); @@ -133,6 +136,8 @@ be_visitor_interface_ci::visit_interface (be_interface *node) -1); } delete visitor; + + delete node->set_strategy (old_strategy); } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp index ba5f7a2ba07..54db0d78a5d 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp @@ -55,21 +55,21 @@ be_visitor_interface_cs::visit_interface (be_interface *node) // first generate the code for the static methods // The _narrow method - *os << node->name () << "_ptr " << node->name () + *os << node->local_name () << "_ptr " << node->local_name () << "::_narrow (" << be_idt << be_idt_nl << "CORBA::Object_ptr obj," << be_nl << "CORBA::Environment &ACE_TRY_ENV" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl << "if (CORBA::is_nil (obj))" << be_idt_nl - << "return " << node->name () << "::_nil ();" << be_uidt_nl + << "return " << node->local_name () << "::_nil ();" << be_uidt_nl << "CORBA::Boolean is_a = obj->_is_a (\"" << node->repoID () << "\", ACE_TRY_ENV);" << be_nl - << "ACE_CHECK_RETURN (" << node->name () << "::_nil ());" << be_nl + << "ACE_CHECK_RETURN (" << node->local_name () << "::_nil ());" << be_nl << "if (is_a == 0)" << be_idt_nl - << "return " << node->name () << "::_nil ();" << be_uidt_nl; + << "return " << node->local_name () << "::_nil ();" << be_uidt_nl; - *os << "return " << node->name () + *os << "return " << node->local_name () << "::_unchecked_narrow (obj, ACE_TRY_ENV);" << be_uidt_nl << "}" << be_nl << be_nl; @@ -79,35 +79,35 @@ be_visitor_interface_cs::visit_interface (be_interface *node) // assert (coll_name != 0); // The _unchecked_narrow method - *os << node->name () << "_ptr " << node->name () + *os << node->local_name () << "_ptr " << node->local_name () << "::_unchecked_narrow (" << be_idt << be_idt_nl << "CORBA::Object_ptr obj," << be_nl << "CORBA::Environment &" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl << "if (CORBA::is_nil (obj))" << be_idt_nl - << "return " << node->name () << "::_nil ();" << be_uidt_nl; + << "return " << node->local_name () << "::_nil ();" << be_uidt_nl; *os << "TAO_Stub* stub = obj->_stubobj ();" << be_nl << "stub->_incr_refcnt ();" << be_nl; - *os << "if (obj->_is_collocated () && _TAO_collocation_" << node->flatname () + *os << "if (obj->_is_collocated () && _TAO_collocation_" << node->flat_name () << "_Stub_Factory_function_pointer != 0)" << be_idt_nl << "{" << be_idt_nl << node->local_name () << "_ptr retv = _TAO_collocation_" - << node->flatname () + << node->flat_name () << "_Stub_Factory_function_pointer (obj);" << be_nl << "if (retv != 0)" << be_idt_nl << "return retv;" << be_uidt << be_uidt_nl << "}" << be_uidt_nl; - *os << "return new " << node->name () << "(stub);" << be_uidt_nl + *os << "return new " << node->local_name () << "(stub);" << be_uidt_nl << "}" << be_nl << be_nl; // The _duplicate method - *os << node->name () << "_ptr " << be_nl - << node->name () << "::_duplicate (" - << node->name () << "_ptr obj)" << be_nl + *os << node->local_name () << "_ptr " << be_nl + << node->local_name () << "::_duplicate (" + << node->local_name () << "_ptr obj)" << be_nl << "{" << be_idt_nl << "if (!CORBA::is_nil (obj))" << be_idt_nl << "obj->_incr_refcnt ();" << be_uidt_nl @@ -125,7 +125,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) // generate the is_a method os->indent (); - *os << "CORBA::Boolean " << node->name () << "::_is_a (" << + *os << "CORBA::Boolean " << node->local_name () << "::_is_a (" << "const CORBA::Char *value, CORBA::Environment &ACE_TRY_ENV)" << be_nl; *os << "{\n"; os->incr_indent (); @@ -149,7 +149,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) *os << "}\n\n"; os->indent (); - *os << "const char* " << node->name () + *os << "const char* " << node->local_name () << "::_interface_repository_id (void) const" << be_nl << "{" << be_idt_nl @@ -178,6 +178,10 @@ be_visitor_interface_cs::visit_interface (be_interface *node) // Generate code for the AMI Reply Handler. if (idl_global->ami_call_back () == I_TRUE) { + + be_interface_type_strategy *old_strategy = + node->set_strategy (new be_interface_ami_handler_strategy (node)); + // = Generate the default stub code for Handler. // Set the context. @@ -238,6 +242,8 @@ be_visitor_interface_cs::visit_interface (be_interface *node) -1); } delete visitor; + + delete node->set_strategy (old_strategy); } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation.cpp index 3b4c8db91ac..04441aa4819 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation.cpp @@ -62,7 +62,10 @@ #include "be_visitor_operation/ami_handler_operation_ch.cpp" #include "be_visitor_operation/ami_handler_arglist.cpp" #include "be_visitor_operation/ami_handler_operation_cs.cpp" +#include "be_visitor_operation/ami_handler_servant_operation_cs.cpp" #include "be_visitor_operation/ami_handler_skeleton_cs.cpp" #include "be_visitor_operation/ami_handler_argument_marshal.cpp" +#include "be_visitor_operation/ami_handler_thru_poa_collocated_ch.cpp" +#include "be_visitor_operation/ami_handler_thru_poa_collocated_cs.cpp" ACE_RCSID(be, be_visitor_operation, "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_thru_poa_collocated_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_thru_poa_collocated_ch.cpp new file mode 100644 index 00000000000..dae79c4beba --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_thru_poa_collocated_ch.cpp @@ -0,0 +1,101 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_thru_poa_collocated_ch.cpp +// +// = DESCRIPTION +// Visitor generating code for thru_poa_collocated operation in the client stub +// Special code for the AMI Reply Handler +// +// = AUTHOR +// Aniruddha Gokhale +// Michael Kircher +// +// ============================================================================ + +#include "idl.h" +#include "idl_extern.h" +#include "be.h" + +#include "be_visitor_operation.h" + +ACE_RCSID(be_visitor_operation, ami_handler_thru_poa_collocated_ch, "$Id$") + + +// ************************************************************************* +// be_visitor_operation_ami_handler_thru_poa_collocated_ch -- +// This visitor generates code for the thru_poa_collocated operation signature in a +// server header file +// ************************************************************************* + +be_visitor_operation_ami_handler_thru_poa_collocated_ch::be_visitor_operation_ami_handler_thru_poa_collocated_ch +(be_visitor_context *ctx) + : be_visitor_scope (ctx) +{ +} + +be_visitor_operation_ami_handler_thru_poa_collocated_ch::~be_visitor_operation_ami_handler_thru_poa_collocated_ch (void) +{ +} + +int be_visitor_operation_ami_handler_thru_poa_collocated_ch::visit_operation (be_operation *node) +{ + TAO_OutStream *os; // output stream + be_type *bt; // type node representing the return type + + os = this->ctx_->stream (); + this->ctx_->node (node); // save the node + + os->indent (); // start with the current indentation level + + // every operation is declared virtual in the client code + *os << "virtual "; + + // STEP I: generate the return type + bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_sh::" + "visit_operation - " + "Bad return type\n"), + -1); + } + + // STEP 2: generate the operation name + *os << "void " << node->local_name (); + + // STEP 3: generate the argument list with the appropriate mapping. For these + // we grab a visitor that generates the parameter listing + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGLIST_CH); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_operation_sh::" + "visit_operation - " + "Bad visitor to return type\n"), + -1); + } + + if (node->accept (visitor) == -1) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_sh::" + "visit_operation - " + "codegen for argument list failed\n"), + -1); + } + delete visitor; + + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_rettype.cpp b/TAO/TAO_IDL/be/be_visitor_rettype.cpp index eb1cf5095d9..623a95e3e0a 100644 --- a/TAO/TAO_IDL/be/be_visitor_rettype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_rettype.cpp @@ -79,7 +79,7 @@ be_visitor_rettype_ami_handler_result_arg::visit_type (be_type *node) os->indent (); // start from current indentation level // generate the typecode information here - *os << "static const CORBA::Long _oc_" << node->flatname () << "[] =" + *os << "static const CORBA::Long _oc_" << node->flat_name () << "[] =" << be_nl; *os << "{" << be_idt << "\n"; @@ -102,7 +102,7 @@ be_visitor_rettype_ami_handler_result_arg::visit_type (be_type *node) } *os << be_uidt << "};" << be_nl; - *os << "static CORBA::TypeCode _tc_TAO_tc_" << node->flatname () + *os << "static CORBA::TypeCode _tc_TAO_tc_" << node->flat_name () << " ("; switch (node->node_type ()) { @@ -134,8 +134,8 @@ be_visitor_rettype_ami_handler_result_arg::visit_type (be_type *node) return -1; // error } - *os << ", sizeof (_oc_" << node->flatname () - << "), (char *) &_oc_" << node->flatname () + *os << ", sizeof (_oc_" << node->flat_name () + << "), (char *) &_oc_" << node->flat_name () << ", 0, sizeof (" << node->name () << "));" << be_nl; // is our enclosing scope a module? We need this check because for @@ -155,7 +155,7 @@ be_visitor_rettype_ami_handler_result_arg::visit_type (be_type *node) } *os << "TAO_NAMESPACE_DEFINE (CORBA::TypeCode_ptr, _tc_" << node->local_name () << ", &_tc_TAO_tc_" - << node->flatname () << ")" << be_nl; + << node->flat_name () << ")" << be_nl; if (this->gen_nested_namespace_end (module) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -168,7 +168,7 @@ be_visitor_rettype_ami_handler_result_arg::visit_type (be_type *node) { // outermost scope. *os << "CORBA::TypeCode_ptr " << node->tc_name () << " = &_tc_TAO_tc_" - << node->flatname () << ";\n\n"; + << node->flat_name () << ";\n\n"; } return 0; } @@ -3007,8 +3007,8 @@ queue_lookup (ACE_Unbounded_Queue <be_visitor_typecode_defn::QNode *> &queue, iter.next (addr); item = *addr; - if (!ACE_OS::strcmp (item->node->fullname (), - node->fullname ())) + if (!ACE_OS::strcmp (item->node->full_name (), + node->full_name ())) { // found return item; diff --git a/TAO/TAO_IDL/be/be_visitor_scope.cpp b/TAO/TAO_IDL/be/be_visitor_scope.cpp index d7fba5c69c3..17fb8e2c918 100644 --- a/TAO/TAO_IDL/be/be_visitor_scope.cpp +++ b/TAO/TAO_IDL/be/be_visitor_scope.cpp @@ -118,7 +118,7 @@ be_visitor_scope::visit_scope (be_scope *node) // For debugging the prefix... be_decl* decl = node->decl (); ACE_DEBUG ((LM_DEBUG, "Enter scope <%s> : [%s]\n", - decl->fullname (), decl->prefix ())); + decl->full_name (), decl->prefix ())); if (decl->pragmas () != 0) { for (UTL_StrlistActiveIterator i(decl->pragmas ()); diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_thru_poa_collocated_ch.h b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_thru_poa_collocated_ch.h new file mode 100644 index 00000000000..a7b09defbe9 --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_thru_poa_collocated_ch.h @@ -0,0 +1,53 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// thru_poa_collocated_ch.h +// +// = DESCRIPTION +// Visitor for generating code for IDL operations for the thru_poa collocated case +// inside of the servant header +// Special code for the AMI Reply Handler +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef _BE_VISITOR_OPERATION_ami_handler_thru_poa_collocated_ch_H_ +#define _BE_VISITOR_OPERATION_ami_handler_thru_poa_collocated_ch_H_ + +// ************************************************************ +// Operation visitor for server header in the thru_poa collocated class +// ************************************************************ + +class be_visitor_operation_ami_handler_thru_poa_collocated_ch : public be_visitor_scope +{ + // + // = TITLE + // be_visitor_operation_ami_handler_thru_poa_collocated_ch + // + // = DESCRIPTION + // This is a concrete visitor to generate the server header for operation + // in the thru_poa collocated class + // + // +public: + be_visitor_operation_ami_handler_thru_poa_collocated_ch (be_visitor_context *ctx); + // constructor + + ~be_visitor_operation_ami_handler_thru_poa_collocated_ch (void); + // destructor + + virtual int visit_operation (be_operation *node); + // visit operation node. + +}; + +#endif /* _BE_VISITOR_OPERATION_ami_handler_thru_poa_collocated_ch_H_ */ |