From 729b993f6e1568798015168bd25542f181b8b011 Mon Sep 17 00:00:00 2001 From: msmit Date: Fri, 2 Dec 2011 15:00:16 +0000 Subject: Fri Dec 2 14:59:28 UTC 2011 Marcel Smit * TAO_IDL/be/be_codegen.cpp: * TAO_IDL/be/be_global.cpp: * TAO_IDL/be_include/be_codegen.h: * TAO_IDL/be_include/be_global.h: Include base file into inherited template header file. * TAO_IDL/be/be_visitor_component/component_svth.cpp: * TAO_IDL/be/be_visitor_component/component_svts.cpp: * TAO_IDL/be/be_visitor_component/facet_svth.cpp: * TAO_IDL/be/be_visitor_component/facet_svts.cpp: * TAO_IDL/be_include/be_visitor_component/component_svts.h: Contexts are now template classes which derive from their template base classes. --- TAO/ChangeLog.BRANCH | 16 ++++++++ TAO/TAO_IDL/be/be_codegen.cpp | 43 ++++++++++++++++++---- TAO/TAO_IDL/be/be_global.cpp | 24 ++++++++++++ .../be/be_visitor_component/context_svth.cpp | 36 +++++++++++++++++- .../be/be_visitor_component/context_svts.cpp | 36 +++++++++++++++++- TAO/TAO_IDL/be/be_visitor_component/facet_svth.cpp | 4 ++ TAO/TAO_IDL/be/be_visitor_component/facet_svts.cpp | 4 ++ TAO/TAO_IDL/be_include/be_codegen.h | 2 + TAO/TAO_IDL/be_include/be_global.h | 4 ++ .../be_visitor_component/component_svts.h | 1 - 10 files changed, 158 insertions(+), 12 deletions(-) diff --git a/TAO/ChangeLog.BRANCH b/TAO/ChangeLog.BRANCH index 9e066d943e6..7e744a8516f 100644 --- a/TAO/ChangeLog.BRANCH +++ b/TAO/ChangeLog.BRANCH @@ -1,3 +1,19 @@ +Fri Dec 2 14:59:28 UTC 2011 Marcel Smit + + * TAO_IDL/be/be_codegen.cpp: + * TAO_IDL/be/be_global.cpp: + * TAO_IDL/be_include/be_codegen.h: + * TAO_IDL/be_include/be_global.h: + Include base file into inherited template header file. + + * TAO_IDL/be/be_visitor_component/component_svth.cpp: + * TAO_IDL/be/be_visitor_component/component_svts.cpp: + * TAO_IDL/be/be_visitor_component/facet_svth.cpp: + * TAO_IDL/be/be_visitor_component/facet_svts.cpp: + * TAO_IDL/be_include/be_visitor_component/component_svts.h: + Contexts are now template classes which derive from their template + base classes. + Fri Dec 2 08:00:16 UTC 2011 Marcel Smit * TAO_IDL/be/be_codegen.cpp: diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp index a9c790f1ab5..e59c29fa346 100644 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ b/TAO/TAO_IDL/be/be_codegen.cpp @@ -1184,6 +1184,7 @@ TAO_CodeGen::start_ciao_svnt_template_header (const char *fname) << be_global->skel_export_include () << "\"\n"; } + // For base components/connectors. // Some compilers don't optimize the #ifndef header include // protection, but do optimize based on #pragma once. @@ -1193,6 +1194,29 @@ TAO_CodeGen::start_ciao_svnt_template_header (const char *fname) this->gen_svnt_hdr_includes (this->ciao_svnt_template_header_); + size_t const nfiles = idl_global->n_included_idl_files (); + + if (nfiles > 0) + { + os << be_nl; + } + for (size_t j = 0; j < nfiles; ++j) + { + char* idl_name = idl_global->included_idl_files ()[j]; + + if (this->is_system_file (idl_name)) + { + continue; + } + UTL_String str (idl_name); + + this->gen_standard_include ( + this->ciao_svnt_template_header_, + BE_GlobalData::be_get_svnt_template_hdr (&str, true)); + + str.destroy (); + } + return 0; } @@ -1941,7 +1965,7 @@ TAO_CodeGen::end_ciao_svnt_source (void) int TAO_CodeGen::end_ciao_svnt_template_header (void) { - *this->ciao_svnt_template_header_ << be_nl + *this->ciao_svnt_template_header_ << be_nl_2 << "#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)" << be_nl << "#include \"" << be_global->be_get_ciao_tmpl_svnt_src_fname (true) @@ -3493,6 +3517,16 @@ TAO_CodeGen::gen_exec_idl_includes (void) } } +bool +TAO_CodeGen::is_system_file (const char * idl_name) const +{ + return + ACE_OS::strcmp (idl_name, "Components.idl") == 0 + || ACE_OS::strcmp ( + idl_name, + "connectors/ami4ccm/ami4ccm/ami4ccm.idl") == 0; +} + void TAO_CodeGen::gen_conn_hdr_includes (void) { @@ -3575,13 +3609,8 @@ TAO_CodeGen::gen_conn_hdr_includes (void) char * const idl_name = idl_global->included_idl_files ()[j]; - bool const system_file = - ACE_OS::strcmp (idl_name, "Components.idl") == 0 - || ACE_OS::strcmp ( - idl_name, - "connectors/ami4ccm/ami4ccm/ami4ccm.idl") == 0; - if (system_file) + if (this->is_system_file (idl_name)) { continue; } diff --git a/TAO/TAO_IDL/be/be_global.cpp b/TAO/TAO_IDL/be/be_global.cpp index 7fbf68871e3..c2c5669e84f 100644 --- a/TAO/TAO_IDL/be/be_global.cpp +++ b/TAO/TAO_IDL/be/be_global.cpp @@ -340,6 +340,30 @@ BE_GlobalData::be_get_server_hdr (UTL_String *idl_file_name, true); } +const char * +BE_GlobalData::be_get_svnt_template_hdr (UTL_String *idl_file_name, + bool base_name_only) +{ + // User-defined file extensions don't apply to .pidl files. + ACE_CString fn (idl_file_name->get_string ()); + ACE_CString fn_ext = fn.substr (fn.length () - 5); + bool orb_file = (fn_ext == ".pidl" || fn_ext == ".PIDL"); + + if (!orb_file && !be_global->gen_custom_ending () + && FE_Utils::validate_orb_include (idl_file_name)) + { + orb_file = true; + } + + return be_change_idl_file_extension (idl_file_name, + orb_file + ? "S.h" + : be_global->ciao_svnt_header_template_ending (), + base_name_only, + false, + true); +} + const char * BE_GlobalData::be_get_implementation_hdr (UTL_String *idl_file_name, bool base_name_only) diff --git a/TAO/TAO_IDL/be/be_visitor_component/context_svth.cpp b/TAO/TAO_IDL/be/be_visitor_component/context_svth.cpp index dcdea99519c..8ea4e15f4b2 100644 --- a/TAO/TAO_IDL/be/be_visitor_component/context_svth.cpp +++ b/TAO/TAO_IDL/be/be_visitor_component/context_svth.cpp @@ -49,8 +49,25 @@ be_visitor_context_svth::visit_component (be_component *node) os_ << "template " << be_nl; os_ << "class " << export_macro_.c_str () << " " << lname - << "_Context_T" << be_idt_nl - << ": public virtual BASE"; + << "_Context_T" << be_idt_nl; + // Spec: no multiple inheritance allowed for components. + AST_Component * base = node->base_component (); + if (base) + { + AST_Decl *base_scope = ScopeAsDecl (base->defined_in ()); + ACE_CString sbase_name_str (scope->full_name ()); + const char *sbase_name = sbase_name_str.c_str (); + const char *lbase_name = + base->original_local_name ()->get_string (); + + os_ << ": public " << global << "CIAO_" << base->flat_name () + << "_Impl::" << lbase_name << "_Context_T"; + } + else + { + os_ << ": public virtual BASE"; + } + os_ << be_uidt_nl << "{" << be_nl @@ -135,6 +152,11 @@ be_visitor_context_svth::visit_connector (be_connector *node) int be_visitor_context_svth::visit_uses (be_uses *node) { + if (node->imported ()) + { + return 0; + } + ACE_CString prefix (this->ctx_->port_prefix ()); prefix += node->local_name ()->get_string (); const char *port_name = prefix.c_str (); @@ -207,6 +229,11 @@ be_visitor_context_svth::visit_uses (be_uses *node) int be_visitor_context_svth::visit_publishes (be_publishes *node) { + if (node->imported ()) + { + return 0; + } + const char *obj_name = node->publishes_type ()->full_name (); const char *port_name = node->local_name ()->get_string (); @@ -246,6 +273,11 @@ be_visitor_context_svth::visit_publishes (be_publishes *node) int be_visitor_context_svth::visit_emits (be_emits *node) { + if (node->imported ()) + { + return 0; + } + const char *obj_name = node->emits_type ()->full_name (); const char *port_name = node->local_name ()->get_string (); diff --git a/TAO/TAO_IDL/be/be_visitor_component/context_svts.cpp b/TAO/TAO_IDL/be/be_visitor_component/context_svts.cpp index b5926728fcb..f724511bebc 100644 --- a/TAO/TAO_IDL/be/be_visitor_component/context_svts.cpp +++ b/TAO/TAO_IDL/be/be_visitor_component/context_svts.cpp @@ -47,8 +47,25 @@ be_visitor_context_svts::visit_component (be_component *node) << "PortableServer::Servant sv," << be_uidt_nl << "const char *id)" << be_uidt_nl << ": ::CIAO::Context_Impl_Base_T (h, c, id)," - << be_idt_nl - << "BASE (h, c, sv, id)"; + << be_idt_nl; + // Spec: no multiple inheritance allowed for components. + AST_Component * base = node->base_component (); + if (base) + { + AST_Decl *base_scope = ScopeAsDecl (base->defined_in ()); + ACE_CString sbase_name_str (scope->full_name ()); + const char *sbase_name = sbase_name_str.c_str (); + const char *lbase_name = + base->original_local_name ()->get_string (); + + os_ << global << "CIAO_" << base->flat_name () + << "_Impl::" << lbase_name << "_Context_T"; + } + else + { + os_ << "BASE"; + } + os_ << " (h, c, sv, id)"; os_ << be_uidt_nl << "{" << be_nl @@ -83,6 +100,11 @@ be_visitor_context_svts::visit_connector (be_connector *node) int be_visitor_context_svts::visit_uses (be_uses *node) { + if (node->imported ()) + { + return 0; + } + ACE_CString prefix (this->ctx_->port_prefix ()); prefix += node->local_name ()->get_string (); const char *port_name = prefix.c_str (); @@ -105,6 +127,11 @@ be_visitor_context_svts::visit_uses (be_uses *node) int be_visitor_context_svts::visit_publishes (be_publishes *node) { + if (node->imported ()) + { + return 0; + } + AST_Type *obj = node->publishes_type (); const char *port_name = node->local_name ()->get_string (); @@ -241,6 +268,11 @@ be_visitor_context_svts::visit_publishes (be_publishes *node) int be_visitor_context_svts::visit_emits (be_emits *node) { + if (node->imported ()) + { + return 0; + } + AST_Type *obj = node->emits_type (); const char *port_name = node->local_name ()->get_string (); diff --git a/TAO/TAO_IDL/be/be_visitor_component/facet_svth.cpp b/TAO/TAO_IDL/be/be_visitor_component/facet_svth.cpp index 17389a93e50..57d56d86d86 100644 --- a/TAO/TAO_IDL/be/be_visitor_component/facet_svth.cpp +++ b/TAO/TAO_IDL/be/be_visitor_component/facet_svth.cpp @@ -25,6 +25,10 @@ be_visitor_facet_svth::~be_visitor_facet_svth (void) int be_visitor_facet_svth::visit_provides (be_provides *node) { + if (node->imported ()) + { + return 0; + } if (node->gen_facet_svnt_tmpl_decl (os_) == -1) { ACE_ERROR_RETURN ((LM_ERROR, diff --git a/TAO/TAO_IDL/be/be_visitor_component/facet_svts.cpp b/TAO/TAO_IDL/be/be_visitor_component/facet_svts.cpp index 613d2cf9e7d..5af88b1cfa2 100644 --- a/TAO/TAO_IDL/be/be_visitor_component/facet_svts.cpp +++ b/TAO/TAO_IDL/be/be_visitor_component/facet_svts.cpp @@ -25,6 +25,10 @@ be_visitor_facet_svts::~be_visitor_facet_svts (void) int be_visitor_facet_svts::visit_provides (be_provides *node) { + if (node->imported ()) + { + return 0; + } if (node->gen_facet_svnt_tmpl_defn (os_) == -1) { ACE_ERROR_RETURN ((LM_ERROR, diff --git a/TAO/TAO_IDL/be_include/be_codegen.h b/TAO/TAO_IDL/be_include/be_codegen.h index 03f7442c765..4f2f742583c 100644 --- a/TAO/TAO_IDL/be_include/be_codegen.h +++ b/TAO/TAO_IDL/be_include/be_codegen.h @@ -428,6 +428,8 @@ private: void gen_conn_src_includes (void); void gen_ami_conn_idl_includes (void); + bool is_system_file (const char * idl_name) const; + void gen_export_file (const char *filename, const char *macro, const char *msg, diff --git a/TAO/TAO_IDL/be_include/be_global.h b/TAO/TAO_IDL/be_include/be_global.h index e65c4d30646..ed063f8dd3a 100644 --- a/TAO/TAO_IDL/be_include/be_global.h +++ b/TAO/TAO_IDL/be_include/be_global.h @@ -164,6 +164,10 @@ public: UTL_String *idl_file_name, bool base_name_only = false); + static const char *be_get_svnt_template_hdr ( + UTL_String *idl_file_name, + bool base_name_only = false); + static const char *be_get_implementation_hdr ( UTL_String *idl_file_name, bool base_name_only = false); diff --git a/TAO/TAO_IDL/be_include/be_visitor_component/component_svts.h b/TAO/TAO_IDL/be_include/be_visitor_component/component_svts.h index 45d073a821a..957aa44d0a5 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_component/component_svts.h +++ b/TAO/TAO_IDL/be_include/be_visitor_component/component_svts.h @@ -33,7 +33,6 @@ public: virtual int visit_component (be_component *node); virtual int visit_connector (be_connector *node); -// virtual int visit_provides (be_provides *node); private: TAO_OutStream &os_; -- cgit v1.2.1