diff options
Diffstat (limited to 'TAO/TAO_IDL/be/be_interface.cpp')
-rw-r--r-- | TAO/TAO_IDL/be/be_interface.cpp | 730 |
1 files changed, 277 insertions, 453 deletions
diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index b0028396a15..799dd96221d 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -94,6 +94,7 @@ be_interface::be_interface (UTL_ScopedName *n, skel_count_ (0), in_mult_inheritance_ (-1), original_interface_ (0), + is_amh_rh_ (false), is_ami_rh_ (false), is_ami4ccm_rh_ (false), full_skel_name_ (0), @@ -929,6 +930,19 @@ int be_interface::gen_operation_table (const char *flat_name, const char *skeleton_class_name) { + // TODO: + // find another way to determine whether this is an AMH class + // Create 'is_amh' methods, just like AMI. Problem is finding where + // to invoke these methods since an AMH class is generated twice: + // once for AMH and once the 'normal' way. + + bool amh = false; + ACE_CString tmp (skeleton_class_name); + if (tmp.strstr ("AMH_") != ACE_String_Base_Const::npos) + { + amh = true; + } + // Check out the op_lookup_strategy. switch (be_global->lookup_strategy ()) { @@ -970,39 +984,96 @@ be_interface::gen_operation_table (const char *flat_name, } // Generate the skeleton for the is_a method. - *os << "{\"_is_a\", &" << skeleton_class_name - << "::_is_a_skel, 0}," << be_nl; + if (amh) + { + *os << "{\"_is_a\", &TAO_AMH_Skeletons::_is_a_amh_skel, 0}," << be_nl; + } + else if (be_global->gen_thru_poa_collocation ()) + { + *os << "{\"_is_a\", &TAO_ServantBase::_is_a_thru_poa_skel, 0}," << be_nl; + } + else + { + *os << "{\"_is_a\", &TAO_ServantBase::_is_a_skel, 0}," << be_nl; + } ++this->skel_count_; if (!be_global->gen_minimum_corba ()) { - *os << "{\"_non_existent\", &" << skeleton_class_name - << "::_non_existent_skel, 0}," << be_nl; + if (amh) + { + *os << "{\"_non_existent\", &TAO_AMH_Skeletons" + << "::_non_existent_amh_skel, 0}," << be_nl; + } + else if (be_global->gen_thru_poa_collocation ()) + { + *os << "{\"_non_existent\", &TAO_ServantBase" + << "::_non_existent_thru_poa_skel, 0}," << be_nl; + } + else + { + *os << "{\"_non_existent\", &TAO_ServantBase" + << "::_non_existent_skel, 0}," << be_nl; + } ++this->skel_count_; } if (!be_global->gen_corba_e () && !be_global->gen_minimum_corba ()) { - *os << "{\"_component\", &" << skeleton_class_name - << "::_component_skel, 0}," << be_nl; + if (amh) + { + *os << "{\"_component\", &TAO_AMH_Skeletons" + << "::_component_amh_skel, 0}," << be_nl; + } + else if (be_global->gen_thru_poa_collocation ()) + { + *os << "{\"_component\", &TAO_ServantBase" + << "::_component_thru_poa_skel, 0}," << be_nl; + } + else + { + *os << "{\"_component\", &TAO_ServantBase" + << "::_component_skel, 0}," << be_nl; + } ++this->skel_count_; } if (!be_global->gen_corba_e () && !be_global->gen_minimum_corba ()) { - *os << "{\"_interface\", &" << skeleton_class_name - << "::_interface_skel, 0}," << be_nl; + if (amh) + { + *os << "{\"_interface\", &TAO_AMH_Skeletons" + << "::_interface_amh_skel, 0}," << be_nl; + } + else + { + *os << "{\"_interface\", &TAO_ServantBase" + << "::_interface_skel, 0}," << be_nl; + } ++this->skel_count_; } if (!be_global->gen_minimum_corba ()) { - *os << "{\"_repository_id\", &" << skeleton_class_name - << "::_repository_id_skel, 0}" << be_uidt_nl; + if (amh) + { + *os << "{\"_repository_id\", &TAO_AMH_Skeletons" + << "::_repository_id_amh_skel, 0}" << be_uidt_nl; + } + else if (be_global->gen_thru_poa_collocation ()) + { + *os << "{\"_repository_id\", &TAO_ServantBase" + << "::_repository_id_thru_poa_skel, 0}" << be_uidt_nl; + } + else + { + *os << "{\"_repository_id\", &TAO_ServantBase" + << "::_repository_id_skel, 0}" << be_uidt_nl; + } ++this->skel_count_; } @@ -1137,43 +1208,98 @@ be_interface::gen_operation_table (const char *flat_name, -1); } - *os << "_is_a,&" - << skeleton_class_name - << "::_is_a_skel, 0" << be_nl; + if (amh) + { + *os << "_is_a,&TAO_AMH_Skeletons" + << "::_is_a_amh_skel, 0" << be_nl; + } + else if (be_global->gen_thru_poa_collocation ()) + { + *os << "_is_a,&TAO_ServantBase" + << "::_is_a_thru_poa_skel, 0" << be_nl; + } + else + { + *os << "_is_a,&TAO_ServantBase" + << "::_is_a_skel, 0" << be_nl; + } ++this->skel_count_; if (!be_global->gen_minimum_corba ()) { - *os << "_non_existent,&" - << skeleton_class_name - << "::_non_existent_skel, 0" << be_nl; + if (amh) + { + *os << "_non_existent,&TAO_AMH_Skeletons" + << "::_non_existent_amh_skel, 0" << be_nl; + } + else if (be_global->gen_thru_poa_collocation ()) + { + *os << "_non_existent,&TAO_ServantBase" + << "::_non_existent_thru_poa_skel, 0" << be_nl; + } + else + { + *os << "_non_existent,&TAO_ServantBase" + << "::_non_existent_skel, 0" << be_nl; + } ++this->skel_count_; } if (!be_global->gen_corba_e () && !be_global->gen_minimum_corba ()) { - *os << "_component,&" - << skeleton_class_name - << "::_component_skel, 0" << be_nl; + if (amh) + { + *os << "_component,&TAO_AMH_Skeletons" + << "::_component_amh_skel, 0" << be_nl; + } + else if (be_global->gen_thru_poa_collocation ()) + { + *os << "_component,&TAO_ServantBase" + << "::_component_thru_poa_skel, 0" << be_nl; + } + else + { + *os << "_component,&TAO_ServantBase" + << "::_component_skel, 0" << be_nl; + } ++this->skel_count_; } if (!be_global->gen_corba_e () && !be_global->gen_minimum_corba ()) { - *os << "_interface,&" - << skeleton_class_name - << "::_interface_skel, 0" << be_nl; + if (amh) + { + *os << "_interface,&TAO_AMH_Skeletons" + << "::_interface_amh_skel, 0" << be_nl; + } + else + { + *os << "_interface,&TAO_ServantBase" + << "::_interface_skel, 0" << be_nl; + } ++this->skel_count_; } if (!be_global->gen_minimum_corba ()) { - *os << "_repository_id,&" - << skeleton_class_name - << "::_repository_id_skel, 0" << be_nl; + if (amh) + { + *os << "_repository_id,&TAO_AMH_Skeletons" + << "::_repository_id_amh_skel, 0" << be_nl; + } + else if (be_global->gen_thru_poa_collocation ()) + { + *os << "_repository_id,&TAO_ServantBase" + << "::_repository_id_thru_poa_skel, 0" << be_nl; + } + else + { + *os << "_repository_id,&TAO_ServantBase" + << "::_repository_id_skel, 0" << be_nl; + } ++this->skel_count_; } @@ -1281,7 +1407,7 @@ be_interface::gen_optable_entries (be_interface *derived_interface, if (be_global->gen_direct_collocation ()) { *os << " &" - << derived_interface->full_direct_proxy_impl_name () + << this->full_direct_proxy_impl_name () << "::" << d->local_name (); } else @@ -1310,7 +1436,7 @@ be_interface::gen_optable_entries (be_interface *derived_interface, if (be_global->gen_direct_collocation ()) { *os << " &" - << derived_interface->full_direct_proxy_impl_name () + << this->full_direct_proxy_impl_name () << "::_get_" << d->local_name (); } else @@ -1332,7 +1458,7 @@ be_interface::gen_optable_entries (be_interface *derived_interface, if (be_global->gen_direct_collocation ()) { *os << " &" - << derived_interface->full_direct_proxy_impl_name () + << this->full_direct_proxy_impl_name () << "::_set_" << d->local_name (); } else @@ -1378,15 +1504,64 @@ be_interface::gen_optable_entries (be_interface *derived_interface, // We are an operation node. We use the original // operation name, not the one with _cxx_ in it. - *os << d->original_local_name () << ",&" - << full_skeleton_name << "::" - << d->local_name () << "_skel,"; - + // We need to the name of the base class!! But since + // we don't know whether this is an AMH class, we + // need to check this, using the full_skeleton_name + // TODO: find a more elegant solution for this + ACE_CString tmp (full_skeleton_name); + if (tmp.strstr ("AMH_") != ACE_String_Base_Const::npos) + { + ACE_CString name (d->full_name ()); + ACE_String_Base_Const::size_type const last = name.rfind(':') - 1; + name = name.substring (0, last); + if (name.rfind (':') != ACE_String_Base_Const::npos) + { + ACE_CString nspace = name.substring (0, name.rfind (':') - 1); + name = name.substring (name.rfind (':') + 1); + *os << d->original_local_name () << ",&POA_" + << nspace.c_str () << "::AMH_" + << name.c_str () << "::" + << d->original_local_name () + << "_skel,"; + } + else + { + *os << d->original_local_name () << ",&POA_AMH_" + << name.c_str () << "::" + << d->original_local_name () + << "_skel,"; + } + } + else + { + if (!d->is_abstract ()) + { + *os << d->original_local_name () << ",&POA_" + << d->full_name () << "_skel,"; + } + else + { + *os << d->original_local_name () << ",&" + << full_skeleton_name << "::" + << d->original_local_name () + << "_skel,"; + } + } if (be_global->gen_direct_collocation ()) { - *os << " &" - << derived_interface->full_direct_proxy_impl_name (); - *os << "::" << d->local_name (); + if (!d->is_abstract ()) + { + *os << " &" + << this->full_direct_proxy_impl_name () + << "::" << d->local_name (); + } + else + { + *os << " &" + << derived_interface->full_direct_proxy_impl_name () + << "::" << d->local_name (); + } + } else { @@ -1408,19 +1583,47 @@ be_interface::gen_optable_entries (be_interface *derived_interface, } // Generate only the "get" entry if we are readonly. - *os << "_get_" << d->original_local_name () << ",&" - << full_skeleton_name << "::_get_" - << d->local_name () << "_skel,"; + // we need to split the full name in order to push _set_ + // or _get_ in between the namespace and attribute name. - if (be_global->gen_direct_collocation ()) + //determine the correct namespace + ACE_CString nspace (d->full_name ()); + ACE_String_Base_Const::size_type const pos = nspace.rfind(':'); + nspace = nspace.substring(0, pos + 1); + + if (!d->is_abstract ()) { - *os << " &" - << derived_interface->full_direct_proxy_impl_name () - << "::_get_" << d->local_name (); + *os << "_get_" << d->original_local_name () << ",&POA_" + << nspace.c_str () << "_get_" + << d->original_local_name () << "_skel,"; + + if (be_global->gen_direct_collocation ()) + { + *os << " &" + << this->full_direct_proxy_impl_name () + << "::_get_" << d->local_name (); + } + else + { + *os << " 0"; + } } else { - *os << " 0"; + *os << "_get_" << d->original_local_name () << ",&" + << full_skeleton_name << "::_get_" + << d->original_local_name () << "_skel,"; + + if (be_global->gen_direct_collocation ()) + { + *os << " &" + << derived_interface->full_direct_proxy_impl_name () + << "::_get_" << d->local_name (); + } + else + { + *os << " 0"; + } } *os << "\n"; @@ -1429,20 +1632,41 @@ be_interface::gen_optable_entries (be_interface *derived_interface, if (!attr->readonly ()) { - // The set method - *os << "_set_" << d->original_local_name () << ",&" - << full_skeleton_name << "::_set_" - << d->local_name () << "_skel,"; - - if (be_global->gen_direct_collocation ()) + if (!d->is_abstract ()) { - *os << " &" - << derived_interface->full_direct_proxy_impl_name () - << "::_set_" << d->local_name (); + // The set method + *os << "_set_" << d->original_local_name () << ",&POA_" + << nspace.c_str () << "_set_" + << d->original_local_name () << "_skel,"; + + if (be_global->gen_direct_collocation ()) + { + *os << " &" + << this->full_direct_proxy_impl_name () + << "::_set_" << d->local_name (); + } + else + { + *os << " 0"; + } } else { - *os << " 0"; + // The set method in case abstract + *os << "_set_" << d->original_local_name () << ",&" + << full_skeleton_name << "::_set_" + << d->original_local_name () << "_skel,"; + + if (be_global->gen_direct_collocation ()) + { + *os << " &" + << derived_interface->full_direct_proxy_impl_name () + << "::_set_" << d->local_name (); + } + else + { + *os << " 0"; + } } *os << "\n"; @@ -1464,37 +1688,6 @@ be_interface::gen_optable_entries (be_interface *derived_interface, } void -be_interface::gen_collocated_skel_body (be_interface *derived, - be_interface *ancestor, - AST_Decl *d, - const char *prefix, - bool /* direct */, - UTL_ExceptList *, - TAO_OutStream *os) -{ - *os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl - << "// " << __FILE__ << ":" << __LINE__; - - // Generate the static method corresponding to this method. - *os << be_nl_2 - << "ACE_INLINE void" << be_nl - << derived->full_direct_proxy_impl_name () - << "::" << prefix << d->local_name () << " (" - << be_idt_nl - << "TAO_Abstract_ServantBase *servant," << be_nl - << "TAO::Argument ** args)" << be_uidt_nl; - - *os << "{" << be_idt_nl - << ancestor->full_direct_proxy_impl_name () - << "::" << prefix << d->local_name () << " (" - << be_idt_nl - << "servant," << be_nl - << "args);" << be_uidt - << be_uidt_nl - << "}"<< be_nl; -} - -void be_interface::gen_ostream_operator (TAO_OutStream *os, bool /* use_underscore */) { @@ -2130,375 +2323,6 @@ be_interface::is_a_helper (be_interface * /*derived*/, } int -be_interface::gen_skel_helper (be_interface *derived, - be_interface *ancestor, - TAO_OutStream *os) -{ - // If derived and ancestor are same, skip it. - if (derived == ancestor) - { - return 0; - } - - // If an operation or an attribute is abstract (declared in an - // abstract interface), we will either generate the full - // definition (if there are no concrete interfaces between the - // abstract ancestor and us) or, if there is a concrete ancestor - // in between, we will catch its definition elsewhere in this - // traversal. - if (ancestor->is_abstract ()) - { - return 0; - } - - // Else generate code that does the cast to the appropriate type. - - if (ancestor->nmembers () > 0) - { - // If there are elements in ancestor scope i.e., any operations and - // attributes defined by "ancestor", become methods on the derived - // class which call the corresponding method of the base class by - // doing the proper casting. - for (UTL_ScopeActiveIterator si (ancestor, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - // Get the next AST decl node - AST_Decl *d = si.item (); - AST_Decl::NodeType nt = d->node_type (); - - if (nt == AST_Decl::NT_op) - { - be_operation *op = - be_operation::narrow_from_decl (d); - - /// These are not generated on the server side. - if (op->is_sendc_ami ()) - { - continue; - } - - *os << be_nl_2 - << "// TAO_IDL - Generated from" << be_nl - << "// " << __FILE__ << ":" << __LINE__ - << be_nl_2; - - if (os->stream_type () == TAO_OutStream::TAO_SVR_HDR) - { - // Generate the static method corresponding to this method. - *os << "static void" << be_nl - << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest & server_request," << be_nl - << "void * servant_upcall," << be_nl - << "void * servant);" << be_uidt - << be_uidt; - } - else - { // Generate code in the inline file. - // Generate the static method corresponding to this method. - *os << "ACE_INLINE" << be_nl - << "void" << be_nl - << derived->full_skel_name () << "::" - << d->local_name () - << "_skel (" << be_idt_nl - << "TAO_ServerRequest & server_request," << be_nl - << "void * servant_upcall," << be_nl - << "void * servant)" - << be_uidt_nl - << "{" << be_idt_nl; - - *os << ancestor->full_skel_name () - << " * const impl =" << be_idt_nl - << "static_cast<" - << derived->full_skel_name () - << " *> (servant);" << be_uidt_nl; - - *os << ancestor->full_skel_name () - << "::" << d->local_name () - << "_skel (" << be_idt_nl - << "server_request," << be_nl - << "servant_upcall," << be_nl - << "impl);" << be_uidt - << be_uidt_nl - << "}"; - } - } - else if (nt == AST_Decl::NT_attr) - { - AST_Attribute *attr = AST_Attribute::narrow_from_decl (d); - - if (attr == 0) - { - return -1; - } - - *os << be_nl_2; - - if (os->stream_type () == TAO_OutStream::TAO_SVR_HDR) - { - // Generate the static method corresponding to this method. - *os << "static void" << be_nl - << "_get_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest & server_request," << be_nl - << "void * servant_upcall," << be_nl - << "void * servant);" << be_uidt - << be_uidt; - } - else - { // Generate code in the inline file. - // Generate the static method corresponding to this method. - *os << "ACE_INLINE" << be_nl - << "void" << be_nl - << derived->full_skel_name () << "::_get_" - << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest & server_request," << be_nl - << "void * servant_upcall," << be_nl - << "void * servant)" << be_uidt - << be_uidt_nl - << "{" << be_idt_nl; - - *os << ancestor->full_skel_name () - << " * const impl = static_cast<" - << derived->full_skel_name () - << " *> (servant);" << be_nl; - - *os << ancestor->full_skel_name () - << "::_get_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "server_request," << be_nl - << "servant_upcall," << be_nl - << "impl);" << be_uidt - << be_uidt << be_uidt_nl - << "}"; - } - - if (!attr->readonly ()) - { - *os << be_nl_2; - - if (os->stream_type () == TAO_OutStream::TAO_SVR_HDR) - { - // Generate the static method corresponding to - // this method. - *os << "static void" << be_nl - << "_set_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest & server_request," << be_nl - << "void * servant_upcall," << be_nl - << "void * servant);" << be_uidt - << be_uidt; - } - else - { // Generate code in the inline file. - // Generate the static method corresponding to - // this method. - *os << "ACE_INLINE" << be_nl - << "void" << be_nl - << derived->full_skel_name () - << "::_set_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest & server_request," << be_nl - << "void * servant_upcall," << be_nl - << "void * servant)" << be_uidt - << be_uidt_nl - << "{" << be_idt_nl; - - *os << ancestor->full_skel_name () - << " * const impl = static_cast<" - << derived->full_skel_name () - << " *> (servant);" << be_nl; - - *os << ancestor->full_skel_name () - << "::_set_" << d->local_name () - << "_skel (" << be_idt << be_idt_nl - << "server_request," << be_nl - << "servant_upcall," << be_nl - << "impl);" << be_uidt - << be_uidt << be_uidt_nl - << "}"; - } - } - } - } // End of FOR. - } - - return 0; -} - -int -be_interface::gen_colloc_op_decl_helper (be_interface *derived, - be_interface *ancestor, - TAO_OutStream *os) -{ - // If derived and ancestor are same, skip it. - if (derived == ancestor) - { - return 0; - } - - // If an operation or an attribute is abstract (declared in an - // abstract interface), we will either generate the full - // definition (if there are no concrete interfaces between the - // abstract ancestor and us) or, if there is a concrete ancestor - // in between, we will catch its definition elsewhere in this - // traversal. - if (ancestor->is_abstract () || ancestor->nmembers () == 0) - { - return 0; - } - - for (UTL_ScopeActiveIterator si (ancestor, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - // Get the next AST decl node - AST_Decl *d = si.item (); - - if (d->node_type () == AST_Decl::NT_op) - { - *os << be_nl_2 << "// TAO_IDL - Generated from" << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl_2; - - // Generate the static method corresponding to this method. - *os << "static void" << be_nl - << d->local_name () << " (" << be_idt_nl - << "TAO_Abstract_ServantBase *servant, " - << "TAO::Argument **args);" << be_uidt_nl; - } - else if (d->node_type () == AST_Decl::NT_attr) - { - AST_Attribute *attr = AST_Attribute::narrow_from_decl (d); - - if (attr == 0) - { - return -1; - } - - // Generate the static method corresponding to this method. - *os << "static void" << be_nl - << "_get_" << d->local_name () << " (" << be_idt_nl - << "TAO_Abstract_ServantBase *servant, " - << "TAO::Argument **args);" << be_uidt_nl; - - if (!attr->readonly ()) - { - *os << be_nl_2; - - // Generate the static method corresponding to - // this method. - *os << "static void" << be_nl - << "_set_" << d->local_name () << " (" - << be_idt_nl - << "TAO_Abstract_ServantBase *servant, " - << "TAO::Argument **args);" << be_uidt_nl; - } - } - } - - return 0; -} - -int -be_interface::gen_colloc_op_defn_helper (be_interface *derived, - be_interface *ancestor, - TAO_OutStream *os) -{ - // If derived and ancestor are same, skip it. - if (derived == ancestor) - { - return 0; - } - - // If an operation or an attribute is abstract (declared in an - // abstract interface), we will either generate the full - // definition (if there are no concrete interfaces between the - // abstract ancestor and us) or, if there is a concrete ancestor - // in between, we will catch its definition elsewhere in this - // traversal. - if (ancestor->is_abstract () || ancestor->nmembers () == 0) - { - return 0; - } - - AST_Decl *d = 0; - be_operation *op = 0; - - for (UTL_ScopeActiveIterator si (ancestor, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - // Get the next AST decl node - d = si.item (); - AST_Decl::NodeType nt = d->node_type (); - - if (nt == AST_Decl::NT_op) - { - op = be_operation::narrow_from_decl (d); - - /// Skip these on the skeleton side. - if (op->is_sendc_ami ()) - { - continue; - } - - if (be_global->gen_direct_collocation ()) - { - be_interface::gen_collocated_skel_body (derived, - ancestor, - d, - "", - true, - op->exceptions (), - os); - } - } - else if (nt == AST_Decl::NT_attr) - { - AST_Attribute *attr = AST_Attribute::narrow_from_decl (d); - - if (attr == 0) - { - return -1; - } - - if (be_global->gen_direct_collocation ()) - { - be_interface::gen_collocated_skel_body ( - derived, - ancestor, - d, - "_get_", - true, - attr->get_get_exceptions (), - os - ); - } - - if (!attr->readonly ()) - { - if (be_global->gen_direct_collocation ()) - { - be_interface::gen_collocated_skel_body ( - derived, - ancestor, - d, - "_set_", - true, - attr->get_set_exceptions (), - os - ); - } - } - } - } - - return 0; -} - -int be_interface::copy_ctor_helper (be_interface *derived, be_interface *base, TAO_OutStream *os) |