summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-10-16 19:55:20 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-10-16 19:55:20 +0000
commitd37612581c07e20d95dd4dcbb1cddbb521b83604 (patch)
treec410496521f16b60137ec52db0aed810c7d9ba51
parente0f79e4a8207e1dd5d19ed488dcfd4e9788d865f (diff)
downloadATCD-d37612581c07e20d95dd4dcbb1cddbb521b83604.tar.gz
ChangeLogTag: Fri Oct 16 19:54:38 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--modules/TAO/ChangeLog30
-rw-r--r--modules/TAO/TAO_IDL/be/be_provides.cpp2
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component.cpp3
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/component_exh.cpp2
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/component_svh.cpp838
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/context_svh.cpp322
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/facet_svh.cpp86
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/servant_svh.cpp459
-rw-r--r--modules/TAO/TAO_IDL/be_include/be_visitor_component.h3
-rw-r--r--modules/TAO/TAO_IDL/be_include/be_visitor_component/component_svh.h40
-rw-r--r--modules/TAO/TAO_IDL/be_include/be_visitor_component/context_svh.h60
-rw-r--r--modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_svh.h53
-rw-r--r--modules/TAO/TAO_IDL/be_include/be_visitor_component/servant_svh.h65
13 files changed, 1105 insertions, 858 deletions
diff --git a/modules/TAO/ChangeLog b/modules/TAO/ChangeLog
index 7472d82afb2..07147e0cc08 100644
--- a/modules/TAO/ChangeLog
+++ b/modules/TAO/ChangeLog
@@ -1,3 +1,33 @@
+Fri Oct 16 19:54:38 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * TAO_IDL/be/be_visitor_component/servant_svh.cpp:
+ * TAO_IDL/be/be_visitor_component/facet_svh.cpp:
+ * TAO_IDL/be/be_visitor_component/context_svh.cpp:
+ * TAO_IDL/be_include/be_visitor_component/servant_svh.h:
+ * TAO_IDL/be_include/be_visitor_component/facet_svh.h:
+ * TAO_IDL/be_include/be_visitor_component/context_svh.h:
+
+ New files, new visitors that contain code moved from
+ private methods in class be_visitor_component_svh.
+
+ * TAO_IDL/be/be_provides.cpp:
+
+ Fixed bug in code generation.
+
+ * TAO_IDL/be/be_visitor_component.cpp:
+ * TAO_IDL/be_include/be_visitor_component.h:
+
+ Added new visitor files.
+
+ * TAO_IDL/be/be_visitor_component/component_exh.cpp:
+
+ Removed debugging output.
+
+ * TAO_IDL/be/be_visitor_component/component_svh.cpp:
+ * TAO_IDL/be_include/be_visitor_component/component_svh.h:
+
+ Moved code out to new visitor above.
+
Tue Oct 13 15:54:44 UTC 2009 Vladimir Zykov <vz@prismtech.com>
* tests/Bug_3748_Regression/client.cpp:
diff --git a/modules/TAO/TAO_IDL/be/be_provides.cpp b/modules/TAO/TAO_IDL/be/be_provides.cpp
index 0124c9ddc1c..f0929bef0cd 100644
--- a/modules/TAO/TAO_IDL/be/be_provides.cpp
+++ b/modules/TAO/TAO_IDL/be/be_provides.cpp
@@ -285,7 +285,7 @@ be_facet_op_attr_defn_helper::emit (be_interface * /* derived_interface */,
ctx.stream (os);
ctx.state (TAO_CodeGen::TAO_ROOT_SVS);
- for (UTL_ScopeActiveIterator i (op_scope_, UTL_Scope::IK_decls);
+ for (UTL_ScopeActiveIterator i (base_interface, UTL_Scope::IK_decls);
!i.is_done ();
i.next ())
{
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component.cpp
index f4954f7c293..9f6ffff2896 100644
--- a/modules/TAO/TAO_IDL/be/be_visitor_component.cpp
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component.cpp
@@ -69,6 +69,9 @@
#include "be_visitor_component/component_ih.cpp"
#include "be_visitor_component/component_is.cpp"
#include "be_visitor_component/component_svh.cpp"
+#include "be_visitor_component/facet_svh.cpp"
+#include "be_visitor_component/context_svh.cpp"
+#include "be_visitor_component/servant_svh.cpp"
#include "be_visitor_component/component_svs.cpp"
#include "be_visitor_component/component_ex_idl.cpp"
#include "be_visitor_component/component_exh.cpp"
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/component_exh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/component_exh.cpp
index 1928ce8136e..810594d8654 100644
--- a/modules/TAO/TAO_IDL/be/be_visitor_component/component_exh.cpp
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/component_exh.cpp
@@ -369,8 +369,6 @@ be_visitor_component_exh::gen_consumes_r (AST_Component *node)
AST_Consumes *c =
AST_Consumes::narrow_from_decl (d);
- ACE_DEBUG ((LM_DEBUG, "%s\n", c->full_name ()));
-
be_type *impl =
be_type::narrow_from_decl (c->consumes_type ());
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/component_svh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/component_svh.cpp
index 97257994785..741cb10c475 100644
--- a/modules/TAO/TAO_IDL/be/be_visitor_component/component_svh.cpp
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/component_svh.cpp
@@ -18,20 +18,14 @@
//
// ============================================================================
-ACE_RCSID (be_visitor_component,
- component_svh,
- "$Id$")
-
// ******************************************************
// Component visitor for server header
// ******************************************************
be_visitor_component_svh::be_visitor_component_svh (be_visitor_context *ctx)
: be_visitor_component (ctx),
- node_ (0),
os_ (*ctx->stream ()),
- export_macro_ (be_global->svnt_export_macro ()),
- in_ancestor_ (false)
+ export_macro_ (be_global->svnt_export_macro ())
{
/// All existing CIAO examples set the servant export values in the CIDL
/// compiler to equal the IDL compiler's skel export values. Below is a
@@ -50,852 +44,64 @@ be_visitor_component_svh::~be_visitor_component_svh (void)
int
be_visitor_component_svh::visit_component (be_component *node)
{
- node_ = node;
-
- if (this->gen_facets () == -1)
+ // Generate the facet servant class declaration.
+ be_visitor_facet_svh facet_visitor (this->ctx_);
+
+ if (facet_visitor.visit_component (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_component_svh::")
ACE_TEXT ("visit_component - ")
- ACE_TEXT ("gen_facets() failed\n")),
+ ACE_TEXT ("facet visitor failed\n")),
-1);
}
/// CIDL-generated namespace used 'CIDL_' + composition name.
/// Now we use 'CIAO_' + component's flat name.
os_ << be_nl << be_nl
- << "namespace CIAO_" << node_->flat_name ()
+ << "namespace CIAO_" << node->flat_name ()
<< "_Impl" << be_nl
<< "{" << be_idt;
- this->gen_context_class ();
+ // Generate the context class declaration.
+ be_visitor_context_svh context_visitor (this->ctx_);
- if (this->gen_servant_class () == -1)
+ if (context_visitor.visit_component (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_component_svh::")
ACE_TEXT ("visit_component - ")
- ACE_TEXT ("gen_servant_class() failed\n")),
+ ACE_TEXT ("context visitor failed\n")),
-1);
}
+
+ // Generate the servant class declaration.
+ be_visitor_servant_svh servant_visitor (this->ctx_);
- this->gen_entrypoint ();
-
- os_ << be_uidt_nl
- << "}";
-
- return 0;
-}
-
-int
-be_visitor_component_svh::visit_operation (be_operation *node)
-{
- be_visitor_operation_ch v (this->ctx_);
- return v.visit_operation (node);
-}
-
-int
-be_visitor_component_svh::visit_attribute (be_attribute *node)
-{
- be_visitor_attribute v (this->ctx_);
- return v.visit_attribute (node);
-}
-
-int
-be_visitor_component_svh::visit_extended_port (
- be_extended_port *)
-{
- return 0;
-}
-
-int
-be_visitor_component_svh::visit_mirror_port (
- be_mirror_port *)
-{
- return 0;
-}
-
-int
-be_visitor_component_svh::gen_facets (void)
-{
- for (UTL_ScopeActiveIterator si (node_, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
- AST_Decl::NodeType nt = d->node_type ();
-
- switch (nt)
- {
- case AST_Decl::NT_provides:
- {
- be_provides *p =
- be_provides::narrow_from_decl (d);
-
- if (p->gen_facet_svnt_decl (os_) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("be_visitor_component_svh")
- ACE_TEXT ("::gen_facets - ")
- ACE_TEXT ("gen_facet_svnt_decl() ")
- ACE_TEXT ("failed\n")),
- -1);
- }
-
- break;
- }
- case AST_Decl::NT_ext_port:
- {
- be_extended_port *ep =
- be_extended_port::narrow_from_decl (d);
-
- be_visitor_extended_port_facet_svh visitor (this->ctx_);
-
- if (visitor.visit_extended_port (ep) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_component_svh::gen_facets - "
- "visit_extended_port() failed\n"),
- -1);
- }
-
- break;
- }
- case AST_Decl::NT_mirror_port:
- {
- be_mirror_port *mp =
- be_mirror_port::narrow_from_decl (d);
-
- if (this->visit_mirror_port (mp) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_component_svh::gen_facets - "
- "visit_mirror_port() failed\n"),
- -1);
- }
-
- break;
- }
- default:
- continue;
- }
- }
-
- return 0;
-}
-
-void
-be_visitor_component_svh::gen_context_class (void)
-{
- AST_Decl *scope = ScopeAsDecl (node_->defined_in ());
- ACE_CString sname_str (scope->full_name ());
- const char *sname = sname_str.c_str ();
-
- // No '_cxx_' prefix.
- const char *lname =
- node_->original_local_name ()->get_string ();
-
- const char *global = (sname_str == "" ? "" : "::");
- bool swapping = be_global->gen_component_swapping ();
-
- os_ << be_nl
- << "class " << lname << "_Servant;"
- << be_nl << be_nl;
-
- os_ << "class " << export_macro_.c_str () << " " << lname
- << "_Context" << be_idt_nl
- << ": public virtual ::CIAO::"
- << (swapping ? "Upgradeable_" : "")
- << "Context_Impl<" << be_idt << be_idt_nl
- << global << sname << "::CCM_" << lname
- << "_Context," << be_nl
- << lname << "_Servant," << be_nl
- << "::" << node_->name () << ">" << be_uidt << be_uidt << be_uidt_nl
- << "{" << be_nl
- << "public:" << be_idt_nl;
-
- os_ << "// Allow the servant to access our state." << be_nl
- << "friend class " << lname << "_Servant;"
- << be_nl << be_nl;
-
- os_ << "// Some useful typedefs." << be_nl<< be_nl
- << "typedef" << be_nl
- << "::CIAO::Context_Impl<" << be_idt << be_idt_nl
- << global << sname << "::CCM_"
- << lname << "_Context," << be_nl
- << lname << "_Servant," << be_nl
- << "::" << node_->name () << ">" << be_uidt_nl
- << "base_type;" << be_uidt_nl << be_nl;
-
- os_ << "typedef base_type::context_type context_type;" << be_nl
- << "typedef base_type::servant_type servant_type;" << be_nl
- << "typedef base_type::component_type component_type;"
- << be_nl << be_nl;
-
- os_ << lname << "_Context (" << be_idt_nl
- << "::Components::CCMHome_ptr h," << be_nl
- << "::CIAO::Container_ptr c," << be_nl
- << lname << "_Servant *sv);" << be_uidt_nl << be_nl;
-
- os_ << "virtual ~" << lname << "_Context (void);";
-
- os_ << be_nl << be_nl
- << "// CIAO-specific." << be_nl
- << "static " << lname << "_Context *" << be_nl
- << "_narrow ( ::Components::SessionContext_ptr p);";
-
- this->gen_context_r (node_);
-
- if (swapping)
- {
- os_ << be_nl << be_nl
- << "/// Operation defined in " << sname << "::CCM_"
- << lname << "_Context" << be_nl
- << "/// that enable component swapping in the container."
- << be_nl
- << "virtual ::Components::ConsumerDescriptions *" << be_nl
- << "get_registered_consumers (const char * publisher_name);";
- }
-
- os_ << be_uidt_nl
- << "};";
-}
-
-void
-be_visitor_component_svh::gen_context_r (AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- AST_Decl *scope = ScopeAsDecl (node->defined_in ());
- ACE_CString sname_str (scope->full_name ());
- const char *sname = sname_str.c_str ();
-
- // No '_cxx_' prefix.
- const char *lname =
- node->original_local_name ()->get_string ();
-
- const char *global = (sname_str == "" ? "" : "::");
-
- os_ << be_nl << be_nl
- << "// Operations for " << lname
- << " receptacles and event sources,"
- << be_nl
- << "// defined in " << global << sname
- << "::CCM_" << lname << "_Context.";
-
- this->gen_ports (node, AST_Decl::NT_uses, false);
- this->gen_ports (node, AST_Decl::NT_publishes, false);
- this->gen_ports (node, AST_Decl::NT_emits, false);
-
- AST_Component *ancestor = node->base_component ();
- in_ancestor_ |= (ancestor != 0);
-
- this->gen_context_r (ancestor);
-}
-
-int
-be_visitor_component_svh::gen_servant_class (void)
-{
- AST_Decl *scope = ScopeAsDecl (node_->defined_in ());
- ACE_CString sname_str (scope->full_name ());
- const char *sname = sname_str.c_str ();
-
- // No '_cxx_' prefix.
- const char *lname =
- node_->original_local_name ()->get_string ();
-
- const char *global = (sname_str == "" ? "" : "::");
-
- os_ << be_nl << be_nl
- << "class " << export_macro_.c_str () << " " << lname
- << "_Servant" << be_idt_nl
- << ": public virtual" << be_idt << be_idt_nl
- << "::CIAO::Servant_Impl<" << be_idt_nl
- << "::" << node_->full_skel_name () << "," << be_nl
- << global << sname << "::CCM_" << lname << "," << be_nl
- << lname << "_Context>"
- << be_uidt << be_uidt << be_uidt << be_uidt_nl
- << "{" << be_nl
- << "public:" << be_idt_nl;
-
- os_ << "typedef " << global << sname << "::CCM_" << lname
- << " _exec_type;" << be_nl;
-
- os_ << be_nl
- << lname << "_Servant (" << be_idt_nl
- << global << sname << "::CCM_"
- << lname << "_ptr executor," << be_nl
- << "::Components::CCMHome_ptr h," << be_nl
- << "const char * ins_name," << be_nl
- << "::CIAO::Home_Servant_Impl_Base *hs," << be_nl
- << "::CIAO::Container_ptr c);" << be_uidt_nl;
-
- os_ << be_nl
- << "virtual ~" << lname << "_Servant"
- << " (void);" << be_nl;
-
- os_ << be_nl
- << "virtual void" << be_nl
- << "set_attributes (const "
- << "::Components::ConfigValues & descr);"
- << be_nl;
-
- os_ << be_nl
- << "// Supported operations and attributes.";
-
- int status =
- node_->traverse_inheritance_graph (
- be_interface::facet_op_attr_decl_helper,
- &os_,
- false,
- false);
-
- if (status == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_component_svh::"
- "gen_servant_class - "
- "inheritance graph traversal failed\n"),
- -1);
- }
-
- /// Reset flag for servant class.
- in_ancestor_ = false;
-
- status = this->gen_servant_r (node_);
-
- if (status == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_component_svh::"
- "gen_servant_class - "
- "gen_servant_r() failed\n"),
- -1);
- }
-
- this->gen_non_type_specific ();
-
- os_ << be_uidt_nl
- << "};";
-
- return 0;
-}
-
-int
-be_visitor_component_svh::gen_servant_r (AST_Component *node)
-{
- if (node == 0)
- {
- return 0;
- }
-
- os_ << be_nl << be_nl
- << "// " << (in_ancestor_ ? "Inherited p" : "P")
- << "orts code.";
-
- this->gen_ports (node, AST_Decl::NT_provides, true);
- this->gen_ports (node, AST_Decl::NT_uses, true);
- this->gen_ports (node, AST_Decl::NT_publishes, true);
- this->gen_ports (node, AST_Decl::NT_emits, true);
- this->gen_ports (node, AST_Decl::NT_consumes, true);
-
- os_ << be_nl << be_nl
- << "// " << (in_ancestor_ ? "Inherited c" : "C")
- << "omponent attributes.";
-
- int status = this->gen_component_attrs (node);
-
- if (status == -1)
+ if (servant_visitor.visit_component (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_component_svh::")
- ACE_TEXT ("gen_servant_r - ")
- ACE_TEXT ("gen_component_attrs() failed\n")),
+ ACE_TEXT ("visit_component - ")
+ ACE_TEXT ("servant visitor failed\n")),
-1);
}
- AST_Component *ancestor = node->base_component ();
- in_ancestor_ |= (ancestor != 0);
-
- return gen_servant_r (ancestor);
-}
-
-int
-be_visitor_component_svh::gen_component_attrs (AST_Component *node)
-{
- /// Traverse the scope and ignore everything but attributes.
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
- be_attribute *attr = be_attribute::narrow_from_decl (d);
-
- if (attr == 0)
- {
- continue;
- }
-
- if (attr->accept (this) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("be_visitor_component_svh::")
- ACE_TEXT ("gen_component_attrs - ")
- ACE_TEXT ("be_attribute::accept() failed\n")),
- -1);
- }
- }
-
- return 0;
-}
-
-void
-be_visitor_component_svh::gen_ports (AST_Component *node,
- AST_Decl::NodeType nt,
- bool in_servant)
-{
- os_ << be_nl << be_nl;
-
- switch (nt)
- {
- case AST_Decl::NT_provides:
- os_ << "// Facets.";
- break;
- case AST_Decl::NT_uses:
- os_ << "// Receptacles.";
- break;
- case AST_Decl::NT_publishes:
- os_ << "// Event publishers.";
- break;
- case AST_Decl::NT_consumes:
- os_ << "// Event consumers.";
- break;
- case AST_Decl::NT_emits:
- os_ << "// Event emitters.";
- break;
- default:
- break;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != nt)
- {
- continue;
- }
-
- switch (nt)
- {
- case AST_Decl::NT_provides:
- this->gen_provides (AST_Provides::narrow_from_decl (d));
- break;
- case AST_Decl::NT_uses:
- this->gen_uses (AST_Uses::narrow_from_decl (d),
- in_servant);
- break;
- case AST_Decl::NT_publishes:
- this->gen_publishes (AST_Publishes::narrow_from_decl (d),
- in_servant);
- break;
- case AST_Decl::NT_emits:
- this->gen_emits (AST_Emits::narrow_from_decl (d),
- in_servant);
- break;
- case AST_Decl::NT_consumes:
- this->gen_consumes (AST_Consumes::narrow_from_decl (d));
- break;
- default:
- break;
- }
- }
-}
-
-void
-be_visitor_component_svh::gen_provides (AST_Provides *p)
-{
- const char *obj_name = p->provides_type ()->full_name ();
- const char *port_name = p->local_name ()->get_string ();
-
- os_ << be_uidt_nl << be_nl
- << "public:" << be_idt_nl
- << "virtual ::" << obj_name << "_ptr" << be_nl
- << "provide_" << port_name << " (void);"
- << be_uidt_nl << be_nl;
-
- os_ << "private:" << be_idt_nl
- << "::CORBA::Object_ptr" << be_nl
- << "provide_" << port_name << "_i (void);"
- << be_uidt_nl << be_nl;
-
- os_ << "private:" << be_idt_nl
- << "::" << obj_name << "_var" << be_nl
- << "provide_" << port_name << "_;";
-}
-
-void
-be_visitor_component_svh::gen_uses (
- AST_Uses *u,
- bool in_servant)
-{
- const char *obj_name = u->uses_type ()->full_name ();
- const char *port_name = u->local_name ()->get_string ();
- bool is_multiple = u->is_multiple ();
-
- os_ << be_uidt_nl << be_nl
- << "public:" << be_idt_nl
- << "virtual ";
-
- if (is_multiple)
- {
- os_ << "::" << node_->full_name () << "::"
- << port_name << "Connections *" << be_nl
- << "get_connections_" << port_name << " (void);";
- }
- else
- {
- os_ << "::" << obj_name << "_ptr" << be_nl
- << "get_connection_" << port_name << " (void);";
- }
-
- os_ << be_nl;
-
- if (!in_servant)
- {
- os_ << be_uidt_nl
- << "protected:" << be_idt;
- }
-
- os_ << be_nl
- << "virtual "
- << (is_multiple ? "::Components::Cookie *" : "void")
- << be_nl
- << "connect_" << port_name << " (" << be_idt_nl
- << "::" << obj_name << "_ptr);"
- << be_uidt_nl << be_nl;
-
- os_ << "virtual ::" << obj_name << "_ptr" << be_nl
- << "disconnect_" << port_name << " (";
-
- if (is_multiple)
- {
- os_ << be_idt_nl
- << "::Components::Cookie * ck);" << be_uidt;
- }
- else
- {
- os_ << "void);";
- }
-
- if (!in_servant)
- {
- os_ << be_uidt_nl << be_nl
- << "protected:" << be_idt_nl;
-
- if (is_multiple)
- {
- os_ << "// Multiplex " << port_name << " connection." << be_nl
- << "typedef ACE_Array_Map<ptrdiff_t," << be_nl
- << " ::"
- << obj_name << "_var>" << be_idt_nl
- << tao_cg->upcase (port_name)
- << "_TABLE;" << be_uidt_nl
- << tao_cg->upcase (port_name) << "_TABLE "
- << "ciao_uses_" << port_name << "_;" << be_nl
- << "TAO_SYNCH_MUTEX " << port_name << "_lock_;";
- }
- else
- {
- os_ << "// Simplex " << port_name << " connection." << be_nl
- << "::" << obj_name << "_var" << be_nl
- << "ciao_uses_" << port_name << "_;";
- }
- }
-}
-
-void
-be_visitor_component_svh::gen_publishes (AST_Publishes *p,
- bool in_servant)
-{
- const char *obj_name = p->publishes_type ()->full_name ();
- const char *port_name = p->local_name ()->get_string ();
-
- os_ << be_uidt_nl << be_nl
- << "public:" << be_idt_nl;
-
- if (!in_servant)
- {
- os_ << "virtual void" << be_nl
- << "push_" << port_name << " (" << be_idt_nl
- << "::" << obj_name << " * ev);" << be_uidt_nl;
-
- os_ << be_uidt_nl
- << "protected:" << be_idt_nl;
- }
-
- os_ << "virtual ::Components::Cookie *" << be_nl
- << "subscribe_" << port_name << " (" << be_idt_nl
- << "::" << obj_name << "Consumer_ptr c);" << be_uidt_nl;
-
- os_ << be_nl
- << "// CIAO-specific." << be_nl
- << "::Components::Cookie *" << be_nl
- << "subscribe_" << port_name << "_generic (" << be_idt_nl
- << "::Components::EventConsumerBase_ptr c);" << be_uidt_nl;
-
- os_ << be_nl
- << "virtual ::" << obj_name << "Consumer_ptr" << be_nl
- << "unsubscribe_" << port_name << " (" << be_idt_nl
- << "::Components::Cookie * ck);" << be_uidt;
-
- if (!in_servant)
- {
- os_ << be_uidt_nl << be_nl
- << "protected:" << be_idt_nl;
-
- os_ << "typedef ACE_Array_Map<ptrdiff_t," << be_nl
- << " ::" << obj_name
- << "Consumer_var>" << be_idt_nl
- << tao_cg->upcase (port_name) << "_TABLE;" << be_uidt_nl
- << tao_cg->upcase (port_name) << "_TABLE ciao_publishes_"
- << port_name << "_;" << be_nl
- << "TAO_SYNCH_MUTEX " << port_name << "_lock_;"
- << be_nl << be_nl;
-
- os_ << "typedef ACE_Array_Map<ptrdiff_t," << be_nl
- << " ::Components::EventConsumerBase_var>"
- << be_idt_nl
- << tao_cg->upcase (port_name)
- << "_GENERIC_TABLE;" << be_uidt_nl
- << tao_cg->upcase (port_name)
- << "_GENERIC_TABLE ciao_publishes_"
- << port_name << "_generic_;";
- }
-}
-
-void
-be_visitor_component_svh::gen_consumes (AST_Consumes *c)
-{
- const char *obj_name = c->consumes_type ()->full_name ();
- const char *port_name = c->local_name ()->get_string ();
-
- ACE_CString holder (obj_name);
- ACE_CString::size_type pos = holder.rfind (':');
- const char *ev_lname = 0;
-
- if (pos == ACE_CString::npos)
- {
- ev_lname = obj_name;
- }
- else
- {
- holder = holder.substr (pos + 1);
- ev_lname = holder.c_str ();
- }
-
- os_ << be_uidt_nl << be_nl
- << "public:" << be_idt_nl;
-
- os_ << "// Servant class for the " << port_name
- << " consumer." << be_nl
- << "class " << export_macro_.c_str () << " " << ev_lname
- << "Consumer_" << port_name << "_Servant" << be_idt_nl
- << ": public virtual ::POA_" << obj_name << "Consumer"
- << be_uidt_nl
- << "{" << be_nl
- << "public:" << be_idt_nl;
-
- ACE_CString sname_str (
- ScopeAsDecl (node_->defined_in ())->full_name ());
- const char *sname = sname_str.c_str ();
- const char *lname = node_->local_name ();
- const char *global = (sname_str == "" ? "" : "::");
-
- os_ << ev_lname << "Consumer_" << port_name
- << "_Servant (" << be_idt_nl
- << global << sname << "::CCM_" << lname
- << "_ptr executor," << be_nl
- << global << sname << "::CCM_" << lname
- << "_Context_ptr c);" << be_uidt_nl << be_nl;
-
- os_ << "virtual ~" << ev_lname << "Consumer_" << port_name
- << "_Servant (void);";
-
- os_ << be_nl << be_nl
- << "virtual void" << be_nl
- << "push_" << ev_lname << " (" << be_idt_nl
- << "::" << obj_name << " * evt);" << be_uidt;
-
- os_ << be_nl << be_nl
- << "// Inherited from ::Components::EventConsumerBase." << be_nl
- << "virtual void" << be_nl
- << "push_event ( ::Components::EventBase * ev);";
-
- os_ << be_nl << be_nl
- << "// CIAO-specific in ::Components::EventConsumerBase." << be_nl
- << "virtual void" << be_nl
- << "ciao_push_event ( ::Components::EventBase * ev," << be_nl
- << " const char * source_id," << be_nl
- << " ::CORBA::TypeCode_ptr tc);";
-
- os_ << be_nl << be_nl
- << "// CIAO-specific in ::Components::EventConsumerBase." << be_nl
- << "virtual ::CORBA::Boolean" << be_nl
- << "ciao_is_substitutable (const char * event_repo_id);";
-
- os_ << be_nl << be_nl
- << "// Get component implementation." << be_nl
- << "virtual ::CORBA::Object_ptr" << be_nl
- << "_get_component (void);";
-
- os_ << be_uidt_nl << be_nl
- << "protected:" << be_idt_nl;
-
- os_ << global << sname << "::CCM_" << lname << "_var" << be_nl
- << "executor_;";
-
- os_ << be_nl << be_nl
- << global << sname << "::CCM_"
- << lname << "_Context_var" << be_nl
- << "ctx_;";
+ this->gen_entrypoint (node);
os_ << be_uidt_nl
- << "};";
-
- os_ << be_nl << be_nl
- << "virtual ::" << obj_name << "Consumer_ptr" << be_nl
- << "get_consumer_" << port_name << " (void);";
-
- os_ << be_uidt_nl << be_nl
- << "private:" << be_idt_nl;
-
- os_ << "::Components::EventConsumerBase_ptr" << be_nl
- << "get_consumer_" << port_name << "_i (void);";
-
- os_ << be_uidt_nl << be_nl
- << "private:" << be_idt_nl;
-
- os_ << "::" << obj_name << "Consumer_var" << be_nl
- << "consumes_" << port_name << "_;";
-}
-
-void
-be_visitor_component_svh::gen_emits (AST_Emits *e,
- bool in_servant)
-{
- const char *obj_name = e->emits_type ()->full_name ();
- const char *port_name = e->local_name ()->get_string ();
-
- if (in_servant)
- {
- os_ << be_nl << be_nl;
- }
- else
- {
- os_ << be_uidt_nl << be_nl
- << "public:" << be_idt_nl;
-
- os_ << "virtual void" << be_nl
- << "push_" << port_name << " (" << be_idt_nl
- << "::" << obj_name << " * ev);" << be_uidt;
-
- os_ << be_uidt_nl << be_nl
- << "protected:" << be_idt_nl;
- }
-
- os_ << "virtual void" << be_nl
- << "connect_" << port_name << " (" << be_idt_nl
- << "::" << obj_name << "Consumer_ptr c);" << be_uidt;
-
- os_ << be_nl << be_nl
- << "virtual ::" << obj_name << "Consumer_ptr" << be_nl
- << "disconnect_" << port_name << " (void);";
-
- if (!in_servant)
- {
- os_ << be_uidt_nl << be_nl
- << "protected:" << be_idt_nl
- << "::" << obj_name << "Consumer_var" << be_nl
- << "ciao_emits_" << port_name << "_consumer_;";
- }
-}
-
-void
-be_visitor_component_svh::gen_non_type_specific (void)
-{
- os_ << be_nl << be_nl
- << "// Base class overrides.";
-
- os_ << be_uidt_nl << be_nl
- << "public:" << be_idt_nl
- << "virtual ::Components::Cookie *" << be_nl
- << "connect (const char * name," << be_nl
- << " ::CORBA::Object_ptr connection);";
-
- os_ << be_nl << be_nl
- << "virtual ::CORBA::Object_ptr" << be_nl
- << "disconnect (const char * name," << be_nl
- << " ::Components::Cookie * ck);";
-
- os_ << be_nl << be_nl
- << "virtual ::Components::ReceptacleDescriptions *" << be_nl
- << "get_all_receptacles (void);";
-
- os_ << be_nl << be_nl
- << "virtual ::Components::Cookie *" << be_nl
- << "subscribe (const char * publisher_name," << be_nl
- << " ::Components::EventConsumerBase_ptr subscriber);";
-
- os_ << be_nl << be_nl
- << "virtual ::Components::EventConsumerBase_ptr" << be_nl
- << "unsubscribe (const char * publisher_name," << be_nl
- << " ::Components::Cookie * ck);";
-
- os_ << be_nl << be_nl
- << "virtual void" << be_nl
- << "connect_consumer (const char * emitter_name," << be_nl
- << " ::Components::EventConsumerBase_ptr consumer);";
-
- os_ << be_nl << be_nl
- << "virtual ::Components::EventConsumerBase_ptr" << be_nl
- << "disconnect_consumer (const char * source_name);";
-
- os_ << be_nl << be_nl
- << "virtual ::Components::PublisherDescriptions *" << be_nl
- << "get_all_publishers (void);";
-
- os_ << be_nl << be_nl
- << "virtual ::Components::EmitterDescriptions *" << be_nl
- << "get_all_emitters (void);";
-
- os_ << be_nl << be_nl
- << "// CIAO-specific." << be_nl
- << "::CORBA::Object_ptr" << be_nl
- << "get_facet_executor (const char * name);";
-
- os_ << be_uidt_nl << be_nl
- << "private:" << be_idt_nl
- << "void" << be_nl
- << "populate_port_tables (void);";
+ << "}";
- os_ << be_uidt_nl << be_nl
- << "private:" << be_idt_nl
- << "const char * ins_name_;";
+ return 0;
}
void
-be_visitor_component_svh::gen_entrypoint (void)
+be_visitor_component_svh::gen_entrypoint (be_component *node)
{
os_ << be_nl << be_nl
<< "extern \"C\" " << export_macro_.c_str ()
<< " ::PortableServer::Servant" << be_nl
- << "create_" << node_->flat_name ()
+ << "create_" << node->flat_name ()
<< "_Servant (" << be_idt_nl
<< "::Components::EnterpriseComponent_ptr p," << be_nl
<< "::CIAO::Container_ptr c," << be_nl
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/context_svh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/context_svh.cpp
new file mode 100644
index 00000000000..688165f3566
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/context_svh.cpp
@@ -0,0 +1,322 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// context_svh.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for a context class in the
+// servant header.
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+be_visitor_context_svh::be_visitor_context_svh (be_visitor_context *ctx)
+ : be_visitor_scope (ctx),
+ node_ (0),
+ os_ (*ctx->stream ()),
+ export_macro_ (be_global->svnt_export_macro ()),
+ swapping_ (be_global->gen_component_swapping ())
+{
+ /// All existing CIAO examples set the servant export values in the CIDL
+ /// compiler to equal the IDL compiler's skel export values. Below is a
+ /// partial effort to decouple them, should be completely decoupled
+ /// sometime. See comment in codegen.cpp, line 1173.
+ if (export_macro_ == "")
+ {
+ export_macro_ = be_global->skel_export_macro ();
+ }
+}
+
+be_visitor_context_svh::~be_visitor_context_svh (void)
+{
+}
+
+int
+be_visitor_context_svh::visit_component (be_component *node)
+{
+ node_ = node;
+
+ AST_Decl *scope = ScopeAsDecl (node->defined_in ());
+ ACE_CString sname_str (scope->full_name ());
+ const char *sname = sname_str.c_str ();
+
+ // No '_cxx_' prefix.
+ const char *lname =
+ node->original_local_name ()->get_string ();
+
+ const char *global = (sname_str == "" ? "" : "::");
+
+ os_ << be_nl
+ << "class " << lname << "_Servant;"
+ << be_nl << be_nl;
+
+ os_ << "class " << export_macro_.c_str () << " " << lname
+ << "_Context" << be_idt_nl
+ << ": public virtual ::CIAO::"
+ << (swapping_ ? "Upgradeable_" : "")
+ << "Context_Impl<" << be_idt << be_idt_nl
+ << global << sname << "::CCM_" << lname
+ << "_Context," << be_nl
+ << lname << "_Servant," << be_nl
+ << "::" << node->name () << ">" << be_uidt << be_uidt << be_uidt_nl
+ << "{" << be_nl
+ << "public:" << be_idt_nl;
+
+ os_ << "// Allow the servant to access our state." << be_nl
+ << "friend class " << lname << "_Servant;"
+ << be_nl << be_nl;
+
+ os_ << "// Some useful typedefs." << be_nl<< be_nl
+ << "typedef" << be_nl
+ << "::CIAO::Context_Impl<" << be_idt << be_idt_nl
+ << global << sname << "::CCM_"
+ << lname << "_Context," << be_nl
+ << lname << "_Servant," << be_nl
+ << "::" << node->name () << ">" << be_uidt_nl
+ << "base_type;" << be_uidt_nl << be_nl;
+
+ os_ << "typedef base_type::context_type context_type;" << be_nl
+ << "typedef base_type::servant_type servant_type;" << be_nl
+ << "typedef base_type::component_type component_type;"
+ << be_nl << be_nl;
+
+ os_ << lname << "_Context (" << be_idt_nl
+ << "::Components::CCMHome_ptr h," << be_nl
+ << "::CIAO::Container_ptr c," << be_nl
+ << lname << "_Servant *sv);" << be_uidt_nl << be_nl;
+
+ os_ << "virtual ~" << lname << "_Context (void);";
+
+ os_ << be_nl << be_nl
+ << "// CIAO-specific." << be_nl
+ << "static " << lname << "_Context *" << be_nl
+ << "_narrow ( ::Components::SessionContext_ptr p);";
+
+ os_ << be_nl << be_nl
+ << "// Operations for " << lname
+ << " receptacles and event sources,"
+ << be_nl
+ << "// defined in " << global << sname
+ << "::CCM_" << lname << "_Context.";
+
+ this->gen_context_r (node);
+
+ if (swapping_)
+ {
+ os_ << be_nl << be_nl
+ << "/// Operation defined in " << sname << "::CCM_"
+ << lname << "_Context" << be_nl
+ << "/// that enable component swapping in the container."
+ << be_nl
+ << "virtual ::Components::ConsumerDescriptions *" << be_nl
+ << "get_registered_consumers (const char * publisher_name);";
+ }
+
+ os_ << be_uidt_nl
+ << "};";
+
+ return 0;
+}
+
+int
+be_visitor_context_svh::visit_uses (be_uses *node)
+{
+ const char *obj_name = node->uses_type ()->full_name ();
+ const char *port_name = node->local_name ()->get_string ();
+ bool is_multiple = node->is_multiple ();
+
+ os_ << be_uidt_nl << be_nl
+ << "public:" << be_idt_nl
+ << "virtual ";
+
+ if (is_multiple)
+ {
+ os_ << "::" << node_->full_name () << "::"
+ << port_name << "Connections *" << be_nl
+ << "get_connections_" << port_name << " (void);";
+ }
+ else
+ {
+ os_ << "::" << obj_name << "_ptr" << be_nl
+ << "get_connection_" << port_name << " (void);";
+ }
+
+ os_ << be_nl << be_uidt_nl
+ << "protected:" << be_idt_nl
+ << "virtual "
+ << (is_multiple ? "::Components::Cookie *" : "void")
+ << be_nl
+ << "connect_" << port_name << " (" << be_idt_nl
+ << "::" << obj_name << "_ptr);"
+ << be_uidt_nl << be_nl;
+
+ os_ << "virtual ::" << obj_name << "_ptr" << be_nl
+ << "disconnect_" << port_name << " (";
+
+ if (is_multiple)
+ {
+ os_ << be_idt_nl
+ << "::Components::Cookie * ck);" << be_uidt;
+ }
+ else
+ {
+ os_ << "void);";
+ }
+
+ os_ << be_uidt_nl << be_nl
+ << "protected:" << be_idt_nl;
+
+ if (is_multiple)
+ {
+ os_ << "// Multiplex " << port_name << " connection." << be_nl
+ << "typedef ACE_Array_Map<ptrdiff_t," << be_nl
+ << " ::"
+ << obj_name << "_var>" << be_idt_nl
+ << tao_cg->upcase (port_name)
+ << "_TABLE;" << be_uidt_nl
+ << tao_cg->upcase (port_name) << "_TABLE "
+ << "ciao_uses_" << port_name << "_;" << be_nl
+ << "TAO_SYNCH_MUTEX " << port_name << "_lock_;";
+ }
+ else
+ {
+ os_ << "// Simplex " << port_name << " connection." << be_nl
+ << "::" << obj_name << "_var" << be_nl
+ << "ciao_uses_" << port_name << "_;";
+ }
+
+ return 0;
+}
+
+int
+be_visitor_context_svh::visit_publishes (be_publishes *node)
+{
+ const char *obj_name = node->publishes_type ()->full_name ();
+ const char *port_name = node->local_name ()->get_string ();
+
+ os_ << be_uidt_nl << be_nl
+ << "public:" << be_idt_nl
+ << "virtual void" << be_nl
+ << "push_" << port_name << " (" << be_idt_nl
+ << "::" << obj_name << " * ev);" << be_uidt_nl;
+
+ os_ << be_uidt_nl
+ << "protected:" << be_idt_nl;
+
+ os_ << "virtual ::Components::Cookie *" << be_nl
+ << "subscribe_" << port_name << " (" << be_idt_nl
+ << "::" << obj_name << "Consumer_ptr c);" << be_uidt_nl;
+
+ os_ << be_nl
+ << "// CIAO-specific." << be_nl
+ << "::Components::Cookie *" << be_nl
+ << "subscribe_" << port_name << "_generic (" << be_idt_nl
+ << "::Components::EventConsumerBase_ptr c);" << be_uidt_nl;
+
+ os_ << be_nl
+ << "virtual ::" << obj_name << "Consumer_ptr" << be_nl
+ << "unsubscribe_" << port_name << " (" << be_idt_nl
+ << "::Components::Cookie * ck);" << be_uidt;
+
+ os_ << be_uidt_nl << be_nl
+ << "protected:" << be_idt_nl;
+
+ os_ << "typedef ACE_Array_Map<ptrdiff_t," << be_nl
+ << " ::" << obj_name
+ << "Consumer_var>" << be_idt_nl
+ << tao_cg->upcase (port_name) << "_TABLE;" << be_uidt_nl
+ << tao_cg->upcase (port_name) << "_TABLE ciao_publishes_"
+ << port_name << "_;" << be_nl
+ << "TAO_SYNCH_MUTEX " << port_name << "_lock_;"
+ << be_nl << be_nl;
+
+ os_ << "typedef ACE_Array_Map<ptrdiff_t," << be_nl
+ << " ::Components::EventConsumerBase_var>"
+ << be_idt_nl
+ << tao_cg->upcase (port_name)
+ << "_GENERIC_TABLE;" << be_uidt_nl
+ << tao_cg->upcase (port_name)
+ << "_GENERIC_TABLE ciao_publishes_"
+ << port_name << "_generic_;";
+
+ return 0;
+}
+
+int
+be_visitor_context_svh::visit_emits (be_emits *node)
+{
+ const char *obj_name = node->emits_type ()->full_name ();
+ const char *port_name = node->local_name ()->get_string ();
+
+ os_ << be_uidt_nl << be_nl
+ << "public:" << be_idt_nl;
+
+ os_ << "virtual void" << be_nl
+ << "push_" << port_name << " (" << be_idt_nl
+ << "::" << obj_name << " * ev);" << be_uidt;
+
+ os_ << be_uidt_nl << be_nl
+ << "protected:" << be_idt_nl;
+
+ os_ << "virtual void" << be_nl
+ << "connect_" << port_name << " (" << be_idt_nl
+ << "::" << obj_name << "Consumer_ptr c);" << be_uidt;
+
+ os_ << be_nl << be_nl
+ << "virtual ::" << obj_name << "Consumer_ptr" << be_nl
+ << "disconnect_" << port_name << " (void);";
+
+ os_ << be_uidt_nl << be_nl
+ << "protected:" << be_idt_nl
+ << "::" << obj_name << "Consumer_var" << be_nl
+ << "ciao_emits_" << port_name << "_consumer_;";
+
+ return 0;
+}
+
+int
+be_visitor_context_svh::visit_extended_port (be_extended_port *)
+{
+ return 0;
+}
+
+int
+be_visitor_context_svh::visit_mirror_port (be_mirror_port *)
+{
+ // TODO
+ return 0;
+}
+
+int
+be_visitor_context_svh::gen_context_r (be_component *node)
+{
+ if (node == 0)
+ {
+ return 0;
+ }
+
+ if (this->visit_scope (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_context_svh")
+ ACE_TEXT ("::gen_context_r - ")
+ ACE_TEXT ("visit_scope() ")
+ ACE_TEXT ("failed\n")),
+ -1);
+ }
+
+ be_component *ancestor =
+ be_component::narrow_from_decl (node->base_component ());
+
+ return this->gen_context_r (ancestor);
+}
+
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/facet_svh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_svh.cpp
new file mode 100644
index 00000000000..e13f9402e70
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_svh.cpp
@@ -0,0 +1,86 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// facet_svh.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for a facet servant class in the
+// servant header.
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+be_visitor_facet_svh::be_visitor_facet_svh (be_visitor_context *ctx)
+ : be_visitor_scope (ctx),
+ os_ (*ctx->stream ()),
+ export_macro_ (be_global->svnt_export_macro ())
+{
+ /// All existing CIAO examples set the servant export values in the CIDL
+ /// compiler to equal the IDL compiler's skel export values. Below is a
+ /// partial effort to decouple them, should be completely decoupled
+ /// sometime. See comment in codegen.cpp, line 1173.
+ if (export_macro_ == "")
+ {
+ export_macro_ = be_global->skel_export_macro ();
+ }
+}
+
+be_visitor_facet_svh::~be_visitor_facet_svh (void)
+{
+}
+
+int
+be_visitor_facet_svh::visit_component (be_component *node)
+{
+ if (this->visit_scope (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_facet_svh::")
+ ACE_TEXT ("visit_component() - ")
+ ACE_TEXT ("visit_scope() failed\n")),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+be_visitor_facet_svh::visit_provides (be_provides *node)
+{
+ if (node->gen_facet_svnt_decl (os_) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_facet_svh")
+ ACE_TEXT ("::visit_provides - ")
+ ACE_TEXT ("gen_facet_svnt_decl() ")
+ ACE_TEXT ("failed\n")),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+be_visitor_facet_svh::visit_extended_port (be_extended_port *node)
+{
+ be_visitor_extended_port_facet_svh visitor (this->ctx_);
+
+ return visitor.visit_extended_port (node);
+}
+
+int
+be_visitor_facet_svh::visit_mirror_port (be_mirror_port *)
+{
+ // TODO
+ return 0;
+}
+
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svh.cpp
new file mode 100644
index 00000000000..77ab8476882
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svh.cpp
@@ -0,0 +1,459 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// servant_svh.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for a servant class in the
+// servant header.
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+be_visitor_servant_svh::be_visitor_servant_svh (be_visitor_context *ctx)
+ : be_visitor_scope (ctx),
+ node_ (0),
+ os_ (*ctx->stream ()),
+ export_macro_ (be_global->svnt_export_macro ())
+{
+ /// All existing CIAO examples set the servant export values in the CIDL
+ /// compiler to equal the IDL compiler's skel export values. Below is a
+ /// partial effort to decouple them, should be completely decoupled
+ /// sometime. See comment in codegen.cpp, line 1173.
+ if (export_macro_ == "")
+ {
+ export_macro_ = be_global->skel_export_macro ();
+ }
+}
+
+be_visitor_servant_svh::~be_visitor_servant_svh (void)
+{
+}
+
+int
+be_visitor_servant_svh::visit_component (be_component *node)
+{
+ node_ = node;
+
+ AST_Decl *scope = ScopeAsDecl (node_->defined_in ());
+ ACE_CString sname_str (scope->full_name ());
+ const char *sname = sname_str.c_str ();
+
+ // No '_cxx_' prefix.
+ const char *lname =
+ node_->original_local_name ()->get_string ();
+
+ const char *global = (sname_str == "" ? "" : "::");
+
+ os_ << be_nl << be_nl
+ << "class " << export_macro_.c_str () << " " << lname
+ << "_Servant" << be_idt_nl
+ << ": public virtual" << be_idt << be_idt_nl
+ << "::CIAO::Servant_Impl<" << be_idt_nl
+ << "::" << node_->full_skel_name () << "," << be_nl
+ << global << sname << "::CCM_" << lname << "," << be_nl
+ << lname << "_Context>"
+ << be_uidt << be_uidt << be_uidt << be_uidt_nl
+ << "{" << be_nl
+ << "public:" << be_idt_nl;
+
+ os_ << "typedef " << global << sname << "::CCM_" << lname
+ << " _exec_type;" << be_nl;
+
+ os_ << be_nl
+ << lname << "_Servant (" << be_idt_nl
+ << global << sname << "::CCM_"
+ << lname << "_ptr executor," << be_nl
+ << "::Components::CCMHome_ptr h," << be_nl
+ << "const char * ins_name," << be_nl
+ << "::CIAO::Home_Servant_Impl_Base *hs," << be_nl
+ << "::CIAO::Container_ptr c);" << be_uidt_nl;
+
+ os_ << be_nl
+ << "virtual ~" << lname << "_Servant"
+ << " (void);" << be_nl;
+
+ os_ << be_nl
+ << "virtual void" << be_nl
+ << "set_attributes (const "
+ << "::Components::ConfigValues & descr);"
+ << be_nl;
+
+ os_ << be_nl
+ << "// Supported operations and attributes.";
+
+ int status =
+ node_->traverse_inheritance_graph (
+ be_interface::facet_op_attr_decl_helper,
+ &os_,
+ false,
+ false);
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_servant_svh::"
+ "visit_component - "
+ "inheritance graph traversal failed\n"),
+ -1);
+ }
+
+ status = this->gen_servant_r (node_);
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_servant_svh::"
+ "visit_component - "
+ "gen_servant_r() failed\n"),
+ -1);
+ }
+
+ this->gen_non_type_specific ();
+
+ os_ << be_uidt_nl
+ << "};";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svh::visit_attribute (be_attribute *node)
+{
+ be_visitor_attribute v (this->ctx_);
+ return v.visit_attribute (node);
+}
+
+int
+be_visitor_servant_svh::visit_provides (be_provides *node)
+{
+ const char *obj_name = node->provides_type ()->full_name ();
+ const char *port_name = node->local_name ()->get_string ();
+
+ os_ << be_uidt_nl << be_nl
+ << "public:" << be_idt_nl
+ << "virtual ::" << obj_name << "_ptr" << be_nl
+ << "provide_" << port_name << " (void);"
+ << be_uidt_nl << be_nl;
+
+ os_ << "private:" << be_idt_nl
+ << "::CORBA::Object_ptr" << be_nl
+ << "provide_" << port_name << "_i (void);"
+ << be_uidt_nl << be_nl;
+
+ os_ << "private:" << be_idt_nl
+ << "::" << obj_name << "_var" << be_nl
+ << "provide_" << port_name << "_;";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svh::visit_uses (be_uses *node)
+{
+ const char *obj_name = node->uses_type ()->full_name ();
+ const char *port_name = node->local_name ()->get_string ();
+ bool is_multiple = node->is_multiple ();
+
+ os_ << be_uidt_nl << be_nl
+ << "public:" << be_idt_nl
+ << "virtual ";
+
+ if (is_multiple)
+ {
+ os_ << "::" << node_->full_name () << "::"
+ << port_name << "Connections *" << be_nl
+ << "get_connections_" << port_name << " (void);";
+ }
+ else
+ {
+ os_ << "::" << obj_name << "_ptr" << be_nl
+ << "get_connection_" << port_name << " (void);";
+ }
+
+ os_ << be_nl << be_nl
+ << "virtual "
+ << (is_multiple ? "::Components::Cookie *" : "void")
+ << be_nl
+ << "connect_" << port_name << " (" << be_idt_nl
+ << "::" << obj_name << "_ptr);"
+ << be_uidt_nl << be_nl;
+
+ os_ << "virtual ::" << obj_name << "_ptr" << be_nl
+ << "disconnect_" << port_name << " (";
+
+ if (is_multiple)
+ {
+ os_ << be_idt_nl
+ << "::Components::Cookie * ck);" << be_uidt;
+ }
+ else
+ {
+ os_ << "void);";
+ }
+
+ return 0;
+}
+
+int
+be_visitor_servant_svh::visit_publishes (be_publishes *node)
+{
+ const char *obj_name = node->publishes_type ()->full_name ();
+ const char *port_name = node->local_name ()->get_string ();
+
+ os_ << be_uidt_nl << be_nl
+ << "public:" << be_idt_nl;
+
+ os_ << "virtual ::Components::Cookie *" << be_nl
+ << "subscribe_" << port_name << " (" << be_idt_nl
+ << "::" << obj_name << "Consumer_ptr c);" << be_uidt_nl;
+
+ os_ << be_nl
+ << "// CIAO-specific." << be_nl
+ << "::Components::Cookie *" << be_nl
+ << "subscribe_" << port_name << "_generic (" << be_idt_nl
+ << "::Components::EventConsumerBase_ptr c);" << be_uidt_nl;
+
+ os_ << be_nl
+ << "virtual ::" << obj_name << "Consumer_ptr" << be_nl
+ << "unsubscribe_" << port_name << " (" << be_idt_nl
+ << "::Components::Cookie * ck);" << be_uidt;
+
+ return 0;
+}
+
+int
+be_visitor_servant_svh::visit_emits (be_emits *node)
+{
+ const char *obj_name = node->emits_type ()->full_name ();
+ const char *port_name = node->local_name ()->get_string ();
+
+ os_ << be_nl << be_nl
+ << "virtual void" << be_nl
+ << "connect_" << port_name << " (" << be_idt_nl
+ << "::" << obj_name << "Consumer_ptr c);" << be_uidt;
+
+ os_ << be_nl << be_nl
+ << "virtual ::" << obj_name << "Consumer_ptr" << be_nl
+ << "disconnect_" << port_name << " (void);";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svh::visit_consumes (be_consumes *node)
+{
+ const char *obj_name = node->consumes_type ()->full_name ();
+ const char *port_name = node->local_name ()->get_string ();
+
+ ACE_CString holder (obj_name);
+ ACE_CString::size_type pos = holder.rfind (':');
+ const char *ev_lname = 0;
+
+ if (pos == ACE_CString::npos)
+ {
+ ev_lname = obj_name;
+ }
+ else
+ {
+ holder = holder.substr (pos + 1);
+ ev_lname = holder.c_str ();
+ }
+
+ os_ << be_uidt_nl << be_nl
+ << "public:" << be_idt_nl;
+
+ os_ << "// Servant class for the " << port_name
+ << " consumer." << be_nl
+ << "class " << export_macro_.c_str () << " " << ev_lname
+ << "Consumer_" << port_name << "_Servant" << be_idt_nl
+ << ": public virtual ::POA_" << obj_name << "Consumer"
+ << be_uidt_nl
+ << "{" << be_nl
+ << "public:" << be_idt_nl;
+
+ ACE_CString sname_str (
+ ScopeAsDecl (node_->defined_in ())->full_name ());
+ const char *sname = sname_str.c_str ();
+ const char *lname = node_->local_name ();
+ const char *global = (sname_str == "" ? "" : "::");
+
+ os_ << ev_lname << "Consumer_" << port_name
+ << "_Servant (" << be_idt_nl
+ << global << sname << "::CCM_" << lname
+ << "_ptr executor," << be_nl
+ << global << sname << "::CCM_" << lname
+ << "_Context_ptr c);" << be_uidt_nl << be_nl;
+
+ os_ << "virtual ~" << ev_lname << "Consumer_" << port_name
+ << "_Servant (void);";
+
+ os_ << be_nl << be_nl
+ << "virtual void" << be_nl
+ << "push_" << ev_lname << " (" << be_idt_nl
+ << "::" << obj_name << " * evt);" << be_uidt;
+
+ os_ << be_nl << be_nl
+ << "// Inherited from ::Components::EventConsumerBase." << be_nl
+ << "virtual void" << be_nl
+ << "push_event ( ::Components::EventBase * ev);";
+
+ os_ << be_nl << be_nl
+ << "// CIAO-specific in ::Components::EventConsumerBase." << be_nl
+ << "virtual void" << be_nl
+ << "ciao_push_event ( ::Components::EventBase * ev," << be_nl
+ << " const char * source_id," << be_nl
+ << " ::CORBA::TypeCode_ptr tc);";
+
+ os_ << be_nl << be_nl
+ << "// CIAO-specific in ::Components::EventConsumerBase." << be_nl
+ << "virtual ::CORBA::Boolean" << be_nl
+ << "ciao_is_substitutable (const char * event_repo_id);";
+
+ os_ << be_nl << be_nl
+ << "// Get component implementation." << be_nl
+ << "virtual ::CORBA::Object_ptr" << be_nl
+ << "_get_component (void);";
+
+ os_ << be_uidt_nl << be_nl
+ << "protected:" << be_idt_nl;
+
+ os_ << global << sname << "::CCM_" << lname << "_var" << be_nl
+ << "executor_;";
+
+ os_ << be_nl << be_nl
+ << global << sname << "::CCM_"
+ << lname << "_Context_var" << be_nl
+ << "ctx_;";
+
+ os_ << be_uidt_nl
+ << "};";
+
+ os_ << be_nl << be_nl
+ << "virtual ::" << obj_name << "Consumer_ptr" << be_nl
+ << "get_consumer_" << port_name << " (void);";
+
+ os_ << be_uidt_nl << be_nl
+ << "private:" << be_idt_nl;
+
+ os_ << "::Components::EventConsumerBase_ptr" << be_nl
+ << "get_consumer_" << port_name << "_i (void);";
+
+ os_ << be_uidt_nl << be_nl
+ << "private:" << be_idt_nl;
+
+ os_ << "::" << obj_name << "Consumer_var" << be_nl
+ << "consumes_" << port_name << "_;";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svh::visit_extended_port (be_extended_port *)
+{
+ return 0;
+}
+
+int
+be_visitor_servant_svh::visit_mirror_port (be_mirror_port *)
+{
+ // TODO
+ return 0;
+}
+
+int
+be_visitor_servant_svh::gen_servant_r (be_component *node)
+{
+ if (node == 0)
+ {
+ return 0;
+ }
+
+ if (this->visit_scope (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_servant_svh")
+ ACE_TEXT ("::gen_servant_r - ")
+ ACE_TEXT ("visit_scope() ")
+ ACE_TEXT ("failed\n")),
+ -1);
+ }
+
+ be_component *ancestor =
+ be_component::narrow_from_decl (node->base_component ());
+
+ return this->gen_servant_r (ancestor);
+}
+
+void
+be_visitor_servant_svh::gen_non_type_specific (void)
+{
+ os_ << be_nl << be_nl
+ << "// Base class overrides.";
+
+ os_ << be_uidt_nl << be_nl
+ << "public:" << be_idt_nl
+ << "virtual ::Components::Cookie *" << be_nl
+ << "connect (const char * name," << be_nl
+ << " ::CORBA::Object_ptr connection);";
+
+ os_ << be_nl << be_nl
+ << "virtual ::CORBA::Object_ptr" << be_nl
+ << "disconnect (const char * name," << be_nl
+ << " ::Components::Cookie * ck);";
+
+ os_ << be_nl << be_nl
+ << "virtual ::Components::ReceptacleDescriptions *" << be_nl
+ << "get_all_receptacles (void);";
+
+ os_ << be_nl << be_nl
+ << "virtual ::Components::Cookie *" << be_nl
+ << "subscribe (const char * publisher_name," << be_nl
+ << " ::Components::EventConsumerBase_ptr subscriber);";
+
+ os_ << be_nl << be_nl
+ << "virtual ::Components::EventConsumerBase_ptr" << be_nl
+ << "unsubscribe (const char * publisher_name," << be_nl
+ << " ::Components::Cookie * ck);";
+
+ os_ << be_nl << be_nl
+ << "virtual void" << be_nl
+ << "connect_consumer (const char * emitter_name," << be_nl
+ << " ::Components::EventConsumerBase_ptr consumer);";
+
+ os_ << be_nl << be_nl
+ << "virtual ::Components::EventConsumerBase_ptr" << be_nl
+ << "disconnect_consumer (const char * source_name);";
+
+ os_ << be_nl << be_nl
+ << "virtual ::Components::PublisherDescriptions *" << be_nl
+ << "get_all_publishers (void);";
+
+ os_ << be_nl << be_nl
+ << "virtual ::Components::EmitterDescriptions *" << be_nl
+ << "get_all_emitters (void);";
+
+ os_ << be_nl << be_nl
+ << "// CIAO-specific." << be_nl
+ << "::CORBA::Object_ptr" << be_nl
+ << "get_facet_executor (const char * name);";
+
+ os_ << be_uidt_nl << be_nl
+ << "private:" << be_idt_nl
+ << "void" << be_nl
+ << "populate_port_tables (void);";
+
+ os_ << be_uidt_nl << be_nl
+ << "private:" << be_idt_nl
+ << "const char * ins_name_;";
+}
+
diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component.h
index c51ae8c98cc..99772ed0e5e 100644
--- a/modules/TAO/TAO_IDL/be_include/be_visitor_component.h
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component.h
@@ -34,6 +34,9 @@
#include "be_visitor_component/component_ih.h"
#include "be_visitor_component/component_is.h"
#include "be_visitor_component/component_svh.h"
+#include "be_visitor_component/facet_svh.h"
+#include "be_visitor_component/context_svh.h"
+#include "be_visitor_component/servant_svh.h"
#include "be_visitor_component/component_svs.h"
#include "be_visitor_component/component_ex_idl.h"
#include "be_visitor_component/component_exh.h"
diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_svh.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_svh.h
index 28d95dadfe6..935bcc0179c 100644
--- a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_svh.h
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_svh.h
@@ -38,51 +38,13 @@ public:
~be_visitor_component_svh (void);
virtual int visit_component (be_component *node);
- virtual int visit_operation (be_operation *node);
- virtual int visit_attribute (be_attribute *node);
- virtual int visit_extended_port (be_extended_port *node);
- virtual int visit_mirror_port (be_mirror_port *node);
private:
- int gen_facets (void);
-
- void gen_context_class (void);
-
- void gen_context_r (AST_Component *node);
-
- int gen_servant_class (void);
-
- int gen_servant_r (AST_Component *node);
-
- int gen_component_attrs (AST_Component *node);
-
- void gen_ports (AST_Component *node,
- AST_Decl::NodeType nt,
- bool in_servant);
-
- void gen_provides (AST_Provides *p);
-
- void gen_uses (AST_Uses *u,
- bool in_servant);
-
- void gen_publishes (AST_Publishes *p,
- bool in_servant);
-
- void gen_consumes (AST_Consumes *c);
-
- void gen_emits (AST_Emits *e,
- bool in_servant);
-
- /// Base class overrides and CIAO-specific code.
- void gen_non_type_specific (void);
-
- void gen_entrypoint (void);
+ void gen_entrypoint (be_component *node);
private:
- be_component *node_;
TAO_OutStream &os_;
ACE_CString export_macro_;
- bool in_ancestor_;
};
#endif /* _BE_COMPONENT_COMPONENT_SVH_H_ */
diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/context_svh.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/context_svh.h
new file mode 100644
index 00000000000..c82c5cd6410
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/context_svh.h
@@ -0,0 +1,60 @@
+//
+// $Id$
+//
+/* -*- c++ -*- */
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// context_svh.h
+//
+// = DESCRIPTION
+// Concrete visitor for the Component node.
+// This provides for code generation for the Context
+// class declaration
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+#ifndef _BE_COMPONENT_CONTEXT_SVH_H_
+#define _BE_COMPONENT_CONTEXT_SVH_H_
+
+class be_visitor_context_svh : public be_visitor_scope
+{
+ //
+ // = TITLE
+ // be_visitor_context_svh
+ //
+ // = DESCRIPTION
+ // This is a concrete visitor to generate the context class decl
+ // for a component.
+ //
+ //
+public:
+ be_visitor_context_svh (be_visitor_context *ctx);
+
+ ~be_visitor_context_svh (void);
+
+ virtual int visit_component (be_component *node);
+ virtual int visit_uses (be_uses *node);
+ virtual int visit_publishes (be_publishes *node);
+ virtual int visit_emits (be_emits *node);
+ virtual int visit_extended_port (be_extended_port *node);
+ virtual int visit_mirror_port (be_mirror_port *node);
+
+private:
+ int gen_context_r (be_component *node);
+
+private:
+ be_component *node_;
+ TAO_OutStream &os_;
+ ACE_CString export_macro_;
+ bool swapping_;
+};
+
+#endif /* _BE_COMPONENT_CONTEXT_SVH_H_ */
+
diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_svh.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_svh.h
new file mode 100644
index 00000000000..b7769b9510f
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_svh.h
@@ -0,0 +1,53 @@
+//
+// $Id$
+//
+/* -*- c++ -*- */
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// facet_svh.h
+//
+// = DESCRIPTION
+// Concrete visitor for the Component node.
+// This provides for code generation for the facet servant
+// class declaration
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+#ifndef _BE_COMPONENT_FACET_SVH_H_
+#define _BE_COMPONENT_FACET_SVH_H_
+
+class be_visitor_facet_svh : public be_visitor_scope
+{
+ //
+ // = TITLE
+ // be_visitor_facet_svh
+ //
+ // = DESCRIPTION
+ // This is a concrete visitor to generate the facet servant decl
+ // for a component.
+ //
+ //
+public:
+ be_visitor_facet_svh (be_visitor_context *ctx);
+
+ ~be_visitor_facet_svh (void);
+
+ virtual int visit_component (be_component *node);
+ virtual int visit_provides (be_provides *node);
+ virtual int visit_extended_port (be_extended_port *node);
+ virtual int visit_mirror_port (be_mirror_port *node);
+
+private:
+ TAO_OutStream &os_;
+ ACE_CString export_macro_;
+};
+
+#endif /* _BE_COMPONENT_FACET_SVH_H_ */
+
diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/servant_svh.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/servant_svh.h
new file mode 100644
index 00000000000..17df7ef6721
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/servant_svh.h
@@ -0,0 +1,65 @@
+//
+// $Id$
+//
+/* -*- c++ -*- */
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// servant_svh.h
+//
+// = DESCRIPTION
+// Concrete visitor for the Component node.
+// This provides for code generation for the Servant
+// class declaration
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+#ifndef _BE_COMPONENT_SERVANT_SVH_H_
+#define _BE_COMPONENT_SERVANT_SVH_H_
+
+class be_visitor_servant_svh : public be_visitor_scope
+{
+ //
+ // = TITLE
+ // be_visitor_servant_svh
+ //
+ // = DESCRIPTION
+ // This is a concrete visitor to generate the servant class decl
+ // for a component.
+ //
+ //
+public:
+ be_visitor_servant_svh (be_visitor_context *ctx);
+
+ ~be_visitor_servant_svh (void);
+
+ virtual int visit_component (be_component *node);
+ virtual int visit_attribute (be_attribute *node);
+ virtual int visit_provides (be_provides *node);
+ virtual int visit_uses (be_uses *node);
+ virtual int visit_publishes (be_publishes *node);
+ virtual int visit_emits (be_emits *node);
+ virtual int visit_consumes (be_consumes *node);
+ virtual int visit_extended_port (be_extended_port *node);
+ virtual int visit_mirror_port (be_mirror_port *node);
+
+private:
+ int gen_servant_r (be_component *node);
+
+ /// Base class overrides and CIAO-specific code.
+ void gen_non_type_specific (void);
+
+private:
+ be_component *node_;
+ TAO_OutStream &os_;
+ ACE_CString export_macro_;
+};
+
+#endif /* _BE_COMPONENT_SERVANT_SVH_H_ */
+