summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-10-19 23:26:40 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2009-10-19 23:26:40 +0000
commit293edc4103d53f8858a981324f9c5e1f3debc81d (patch)
treef8a803b58c14d2e884a226673cc9ff9d1e85de99
parentd37612581c07e20d95dd4dcbb1cddbb521b83604 (diff)
downloadATCD-293edc4103d53f8858a981324f9c5e1f3debc81d.tar.gz
ChangeLogTag: Mon Oct 19 23:26:07 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--modules/TAO/ChangeLog22
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_attribute/component_init.cpp5
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component.cpp7
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/component_svs.cpp2752
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/context_svh.cpp10
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/context_svs.cpp816
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/facet_svh.cpp2
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/facet_svs.cpp77
-rw-r--r--modules/TAO/TAO_IDL/be/be_visitor_component/servant_svs.cpp1727
-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_svs.h124
-rw-r--r--modules/TAO/TAO_IDL/be_include/be_visitor_component/context_svs.h69
-rw-r--r--modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_svs.h52
-rw-r--r--modules/TAO/TAO_IDL/be_include/be_visitor_component/servant_svs.h126
14 files changed, 2932 insertions, 2860 deletions
diff --git a/modules/TAO/ChangeLog b/modules/TAO/ChangeLog
index 07147e0cc08..358bc577494 100644
--- a/modules/TAO/ChangeLog
+++ b/modules/TAO/ChangeLog
@@ -1,3 +1,25 @@
+Mon Oct 19 23:26:07 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * TAO_IDL/be/be_visitor_component/servant_svs.cpp:
+ * TAO_IDL/be/be_visitor_component/facet_svs.cpp:
+ * TAO_IDL/be/be_visitor_component/context_svs.cpp:
+ * TAO_IDL/be_include/be_visitor_component/facet_svs.h:
+ * TAO_IDL/be_include/be_visitor_component/servant_svs.h:
+ * TAO_IDL/be_include/be_visitor_component/context_svs.h:
+
+ New files containing new visitors with code factored out
+ of class be_visitor_component_svs
+
+ * TAO_IDL/be/be_visitor_component.cpp:
+ * TAO_IDL/be/be_visitor_component/facet_svh.cpp:
+ * TAO_IDL/be/be_visitor_component/context_svh.cpp:
+ * TAO_IDL/be/be_visitor_component/component_svs.cpp:
+ * TAO_IDL/be/be_visitor_attribute/component_init.cpp:
+ * TAO_IDL/be_include/be_visitor_component/component_svs.h:
+ * TAO_IDL/be_include/be_visitor_component.h:
+
+ Changes stemming from the new visitors above.
+
Fri Oct 16 19:54:38 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
* TAO_IDL/be/be_visitor_component/servant_svh.cpp:
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_attribute/component_init.cpp b/modules/TAO/TAO_IDL/be/be_visitor_attribute/component_init.cpp
index 39a1e4cd024..33c54a91151 100644
--- a/modules/TAO/TAO_IDL/be/be_visitor_attribute/component_init.cpp
+++ b/modules/TAO/TAO_IDL/be/be_visitor_attribute/component_init.cpp
@@ -35,6 +35,11 @@ int
be_visitor_attribute_component_init::visit_attribute (
be_attribute *node)
{
+ if (node->readonly ())
+ {
+ return 0;
+ }
+
attr_ = node;
be_type *ft = be_type::narrow_from_decl (node->field_type ());
return ft->accept (this);
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component.cpp
index 9f6ffff2896..31e867a6fd8 100644
--- a/modules/TAO/TAO_IDL/be/be_visitor_component.cpp
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component.cpp
@@ -73,6 +73,9 @@
#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/facet_svs.cpp"
+#include "be_visitor_component/context_svs.cpp"
+#include "be_visitor_component/servant_svs.cpp"
#include "be_visitor_component/component_ex_idl.cpp"
#include "be_visitor_component/component_exh.cpp"
#include "be_visitor_component/component_exs.cpp"
@@ -81,7 +84,3 @@
#include "be_visitor_component/cdr_op_ch.cpp"
#include "be_visitor_component/cdr_op_cs.cpp"
-ACE_RCSID (be,
- be_visitor_component,
- "$Id$")
-
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/component_svs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/component_svs.cpp
index da2158211fb..3294483c1df 100644
--- a/modules/TAO/TAO_IDL/be/be_visitor_component/component_svs.cpp
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/component_svs.cpp
@@ -18,27 +18,14 @@
//
// ============================================================================
-ACE_RCSID (be_visitor_component,
- component_svs,
- "$Id$")
-
// ******************************************************
// Component visitor for servant source
// ******************************************************
-bool be_visitor_component_svs::in_facets_ = false;
-
be_visitor_component_svs::be_visitor_component_svs (be_visitor_context *ctx)
: be_visitor_component (ctx),
- node_ (0),
os_ (*ctx->stream ()),
- export_macro_ (be_global->svnt_export_macro ()),
- swapping_ (be_global->gen_component_swapping ()),
- n_provides_ (0UL),
- n_uses_ (0UL),
- n_publishes_ (0UL),
- n_emits_ (0UL),
- n_consumes_ (0UL)
+ 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
@@ -57,394 +44,47 @@ be_visitor_component_svs::~be_visitor_component_svs (void)
int
be_visitor_component_svs::visit_component (be_component *node)
{
- node_ = node;
-
- n_provides_ = 0UL;
- n_uses_ = 0UL;
- n_publishes_ = 0UL;
- n_emits_ = 0UL;
- n_consumes_ = 0UL;
+ be_visitor_facet_svs facet_visitor (this->ctx_);
- this->compute_slots (node_);
-
- if (this->gen_facets () == -1)
+ if (facet_visitor.visit_component (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_component_svs::")
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;
+
+ be_visitor_context_svs context_visitor (this->ctx_);
- this->gen_context_class ();
-
- if (this->gen_servant_class () == -1)
+ if (context_visitor.visit_component (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_component_svs::")
ACE_TEXT ("visit_component - ")
- ACE_TEXT ("gen_servant_class() failed\n")),
+ ACE_TEXT ("context visitor failed\n")),
-1);
}
+
+ be_visitor_servant_svs servant_visitor (this->ctx_);
- this->gen_entrypoint ();
-
- os_ << be_uidt_nl
- << "}";
-
- return 0;
-}
-
-int
-be_visitor_component_svs::visit_operation (be_operation *node)
-{
- be_visitor_operation_svs v (this->ctx_);
- v.for_facets (be_visitor_component_svs::in_facets_);
- v.scope (this->op_scope_);
-
- return v.visit_operation (node);
-}
-
-int
-be_visitor_component_svs::visit_attribute (be_attribute *node)
-{
- be_visitor_attribute v (this->ctx_);
-
- v.for_facets (be_visitor_component_svs::in_facets_);
- v.op_scope (this->op_scope_);
-
- return v.visit_attribute (node);
-}
-
-int
-be_visitor_component_svs::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_defn (os_) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("be_visitor_component_svs")
- ACE_TEXT ("::gen_facets - ")
- ACE_TEXT ("gen_facet_svnt_defn() ")
- 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_svs visitor (this->ctx_);
-
- if (visitor.visit_extended_port (ep) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_component_svs::gen_facets - "
- "visit_extended_port() failed\n"),
- -1);
- }
-
- break;
- }
- case AST_Decl::NT_mirror_port:
- default:
- continue;
- }
- }
-
- return 0;
-}
-
-int
-be_visitor_component_svs::gen_facet_ops_attrs (be_interface *node)
-{
- os_ << be_nl << be_nl
- << "// All facet operations and attributes.";
-
- /// The overload of traverse_inheritance_graph() used here
- /// doesn't automatically prime the queues.
- node->get_insert_queue ().reset ();
- node->get_del_queue ().reset ();
- node->get_insert_queue ().enqueue_tail (node);
-
- Component_Op_Attr_Generator op_attr_gen (this);
-
- int status =
- node->traverse_inheritance_graph (op_attr_gen,
- &os_,
- false,
- false);
-
- if (status == -1)
+ if (servant_visitor.visit_component (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("be_visitor_component_svs::")
- ACE_TEXT ("gen_facet_ops_attrs - ")
- ACE_TEXT ("traverse_inheritance_graph() ")
- ACE_TEXT ("failed\n")),
- -1);
- }
-
- return 0;
-}
-
-void
-be_visitor_component_svs::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 ();
- const char *lname = node_->local_name ();
- const char *global = (sname_str == "" ? "" : "::");
-
- os_ << be_nl
- << lname <<"_Context::" << lname << "_Context ("
- << be_idt << be_idt_nl
- << "::Components::CCMHome_ptr h," << be_nl
- << "::CIAO::Container_ptr c," << be_nl
- << lname << "_Servant * sv)" << be_uidt_nl
- << ": ::CIAO::Context_Impl_Base (h, c)," << be_idt_nl
- << "::CIAO::Context_Impl<" << be_idt_nl
- << global << sname << "::CCM_"
- << lname << "_Context," << be_nl
- << lname << "_Servant," << be_nl
- << "::" << node_->full_name () << "> (h, c, sv)";
-
- if (swapping_)
- {
- os_ << "," << be_uidt_nl
- << "::CIAO::Upgradeable_Context_Impl<" << be_idt_nl
- << global << sname << "::CCM_" << lname
- << "_Context," << be_nl
- << lname << "_Servant," << be_nl
- << "::" << node_->full_name ()
- << "> (h, c, sv)";
- }
-
- os_ << be_uidt << be_uidt << be_uidt_nl
- << "{" << be_nl
- << "}";
-
- os_ << be_nl << be_nl
- << lname << "_Context::~"
- << lname << "_Context (void)" << be_nl
- << "{" << be_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "/// CIAO-specific." << be_nl
- << lname << "_Context *" << be_nl
- << lname
- << "_Context::_narrow ( ::Components::SessionContext_ptr p)"
- << be_nl
- << "{" << be_idt_nl
- << "return dynamic_cast<" << lname
- << "_Context *> (p);" << be_uidt_nl
- << "}";
-
- this->gen_uses_context_r (node_);
- this->gen_publishes_context_r (node_);
- this->gen_emits_context_r (node_);
-
- if (swapping_)
- {
- os_ << be_nl << be_nl
- << "/// Operations defined in " << sname
- << "::CCM_" << lname << "_Context" << be_nl
- << "/// that enable component swapping in the container"
- << be_nl << be_nl
- << "::Components::ConsumerDescriptions *" << be_nl
- << lname << "_Context::get_registered_consumers ("
- << be_idt_nl
- << "const char * publisher_name)" << be_uidt_nl
- << "{" << be_idt_nl
- << "if (publisher_name == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "::Components::ConsumerDescriptions * tmp = 0;"
- << be_nl
- << "::Components::ConsumerDescriptions_var retval;"
- << be_nl
- << "::CORBA::ULong _ciao_index = 0UL;" << be_nl
- << "::CORBA::ULong _ciao_size = 0UL;" << be_nl
- << "ACE_UNUSED_ARG (tmp);" << be_nl
- << "ACE_UNUSED_ARG (retval);" << be_nl
- << "ACE_UNUSED_ARG (_ciao_index);" << be_nl
- << "ACE_UNUSED_ARG (_ciao_size);";
-
- this->gen_swapping_get_consumers_r (node_);
-
- os_ << be_nl << be_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}";
- }
-}
-
-int
-be_visitor_component_svs::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 ();
- const char *lname = node_->local_name ();
- const char *global = (sname_str == "" ? "" : "::");
-
- os_ << be_nl << be_nl
- << lname << "_Servant::"
- << lname << "_Servant (" << be_idt << be_idt_nl
- << global << sname << "::CCM_" << lname
- << "_ptr exe," << 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
- << ": ::CIAO::Servant_Impl_Base (h, hs, c),"
- << be_idt_nl
- << "::CIAO::Servant_Impl<" << be_idt_nl
- << "::" << node_->full_skel_name ()
- << "," << be_nl
- << global << sname << "::CCM_"
- << lname << "," << be_nl
- << lname << "_Context> (exe, h, hs, c)," << be_uidt_nl
- << "ins_name_ (ins_name)" << be_uidt << be_uidt_nl
- << "{" << be_idt_nl
- << "ACE_NEW (this->context_," << be_nl
- << " " << lname << "_Context (h, c, this));"
- << be_nl << be_nl
- << "/// Set the instance id of the component on the context."
- << be_nl
- << "this->context_->_ciao_instance_id (this->ins_name_);";
-
- if (be_global->gen_ciao_valuefactory_reg ())
- {
- this->gen_all_factory_registration ();
- }
-
- os_ << be_nl << be_nl
- << "try" << be_idt_nl
- << "{" << be_idt_nl
- << "::Components::SessionComponent_var scom =" << be_idt_nl
- << "::Components::SessionComponent::_narrow (exe);"
- << be_uidt_nl << be_nl
- << "if (! ::CORBA::is_nil (scom.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "scom->set_session_context (this->context_);" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "this->populate_port_tables ();" << be_uidt_nl
- << "}" << be_uidt_nl
- << "catch (const ::CORBA::Exception &)" << be_idt_nl
- << "{" << be_nl
- << "}" << be_uidt << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << lname << "_Servant::~"
- << lname << "_Servant (void)" << be_nl
- << "{" << be_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "void" << be_nl
- << lname << "_Servant::set_attributes (" << be_idt_nl
- << "const ::Components::ConfigValues & descr)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl << be_nl;
- }
-
- os_ << "for ( ::CORBA::ULong i = 0; i < descr.length (); ++i)"
- << be_idt_nl
- << "{" << be_idt_nl
- << "const char * descr_name = descr[i]->name ();" << be_nl
- << "::CORBA::Any & descr_value = descr[i]->value ();";
-
- this->gen_attr_set_r (node_);
-
- os_ << be_nl << be_nl
- << "ACE_UNUSED_ARG (descr_name);" << be_nl
- << "ACE_UNUSED_ARG (descr_value);" << be_uidt_nl
- << "}" << be_uidt << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "/// Supported operations and all attributes.";
-
- this->op_scope_ = node_;
-
- /// The overload of traverse_inheritance_graph() used here
- /// doesn't automatically prime the queues.
- node_->get_insert_queue ().reset ();
- node_->get_del_queue ().reset ();
- node_->get_insert_queue ().enqueue_tail (node_);
-
- Component_Op_Attr_Generator op_attr_gen (this);
-
- int status =
- node_->traverse_inheritance_graph (op_attr_gen,
- &os_,
- false,
- false);
-
- if (status == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_component_svs::"
- "gen_servant_class - "
- "inheritance graph traversal failed\n"),
+ ACE_TEXT ("visit_component - ")
+ ACE_TEXT ("servant visitor failed\n")),
-1);
}
-
- this->gen_component_attrs_r (node_);
-
- os_ << be_nl << be_nl
- << "/// All port operations.";
-
- this->gen_provides_top ();
- this->gen_publishes_servant_top ();
- this->gen_consumes_r (node_);
- this->gen_uses_servant_top ();
- this->gen_emits_servant_top ();
-
- os_ << be_nl << be_nl
- << "/// Private method to trigger population of the port"
- << be_nl
- << "/// tables (facets and event consumers)." << be_nl
- << "void" << be_nl
- << node_->local_name ()
- << "_Servant::populate_port_tables (void)" << be_nl
- << "{" << be_idt_nl
- << "::CORBA::Object_var obj_var;" << be_nl
- << "::Components::EventConsumerBase_var ecb_var;"
- << be_nl;
-
- this->gen_populate_r (node_);
+
+ this->gen_entrypoint (node);
os_ << be_uidt_nl
<< "}";
@@ -452,2186 +92,19 @@ be_visitor_component_svs::gen_servant_class (void)
return 0;
}
-int
-be_visitor_component_svs::gen_component_attrs_r (AST_Component *node)
-{
- if (node == 0)
- {
- return 0;
- }
-
- int status = this->gen_component_attrs (node);
-
- if (status == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- ACE_TEXT ("be_visitor_component_svs::")
- ACE_TEXT ("gen_servant_r - ")
- ACE_TEXT ("gen_component_attrs() failed\n")),
- -1);
- }
-
- AST_Component *ancestor = node->base_component ();
- return gen_component_attrs_r (ancestor);
-}
-
-int
-be_visitor_component_svs::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_svs::")
- ACE_TEXT ("gen_component_attrs - ")
- ACE_TEXT ("be_attribute::accept() failed\n")),
- -1);
- }
- }
-
- return 0;
-}
-
-void
-be_visitor_component_svs::gen_provides_top (void)
-{
- os_ << be_nl << be_nl
- << "/// CIAO-specific." << be_nl
- << "::CORBA::Object_ptr" << be_nl
- << node_->local_name ()
- << "_Servant::get_facet_executor (" << be_idt_nl
- << "const char * name)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl << be_nl;
- }
-
- os_ << "if (name == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
- << "}" << be_uidt;
-
- AST_Component *node = node_;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_provides)
- {
- continue;
- }
-
- this->gen_facet_executor_block (
- d->local_name ()->get_string ());
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "return ::CORBA::Object::_nil ();" << be_uidt_nl
- << "}";
-
- this->gen_provides_r (node_);
-}
-
-void
-be_visitor_component_svs::gen_facet_executor_block (
- const char *port_name)
-{
- os_ << be_nl << be_nl
- << "if (ACE_OS::strcmp (name, \"" << port_name
- << "\") == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "return this->executor_->get_" << port_name
- << " ();" << be_uidt_nl
- << "}" << be_uidt;
-}
-
-void
-be_visitor_component_svs::gen_provides_r (AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_provides)
- {
- continue;
- }
-
- AST_Provides *p =
- AST_Provides::narrow_from_decl (d);
-
- this->gen_provides (p);
- }
-
- node = node->base_component ();
- this->gen_provides_r (node);
-}
-
-void
-be_visitor_component_svs::gen_provides (AST_Provides *p)
-{
- AST_Type *obj = p->provides_type ();
- const char *obj_name = obj->full_name ();
- const char *port_name = p->local_name ()->get_string ();
- AST_Decl *scope = ScopeAsDecl (obj->defined_in ());
- ACE_CString sname_str (scope->full_name ());
- const char *sname = sname_str.c_str ();
-
- // Avoid '_cxx_' prefix.
- const char *lname =
- obj->original_local_name ()->get_string ();
-
- const char *global = (sname_str == "" ? "" : "::");
- const char *prefix_connector = (sname_str == "" ? "" : "_");
-
- os_ << be_nl << be_nl
- << "::" << obj_name << "_ptr" << be_nl
- << node_->local_name () << "_Servant::provide_"
- << port_name << " (void)" << be_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl << be_nl;
- }
-
- os_ << "if ( ::CORBA::is_nil (this->provide_"
- << port_name << "_.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "::CORBA::Object_var obj =" << be_idt_nl
- << "this->provide_" << port_name << "_i ();"
- << be_uidt_nl << be_nl
- << "::" << obj_name << "_var fo =" << be_idt_nl
- << "::" << obj_name << "::_narrow (obj.in ());"
- << be_uidt_nl << be_nl
- << "this->provide_" << port_name << "_ = fo;" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "return" << be_idt_nl
- << "::" << obj_name << "::_duplicate (this->provide_"
- << port_name << "_.in ());" << be_uidt << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::CORBA::Object_ptr" << be_nl
- << node_->local_name () << "_Servant::provide_"
- << port_name << "_i (void)" << be_nl
- << "{" << be_idt_nl
- << "::CORBA::Object_ptr ret =" << be_idt_nl
- << "this->lookup_facet (\"" << port_name << "\");"
- << be_uidt_nl << be_nl
- << "if (! ::CORBA::is_nil (ret))" << be_idt_nl
- << "{" << be_idt_nl
- << "return ret;" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "typedef" << be_idt_nl
- << "::CIAO::Port_Activator_T<" << be_idt_nl
- << "::CIAO_FACET" << prefix_connector
- << scope->flat_name () << "::" << lname
- << "_Servant," << be_nl
- << global << sname << "::CCM_" << lname << "," << be_nl
- << "::Components::CCMContext," << be_nl
- << node_->local_name () << "_Servant>" << be_uidt_nl
- << "MACRO_MADNESS_TYPEDEF;" << be_uidt_nl << be_nl
- << "MACRO_MADNESS_TYPEDEF * tmp = 0;" << be_nl
- << "ACE_CString obj_id (this->ins_name_);" << be_nl
- << "obj_id += \"_" << port_name << "\";" << be_nl << be_nl
- << "ACE_NEW_THROW_EX (" << be_idt_nl
- << "tmp," << be_nl
- << "MACRO_MADNESS_TYPEDEF (" << be_idt_nl
- << "obj_id.c_str ()," << be_nl
- << "\"" << port_name << "\"," << be_nl
- << "::CIAO::Port_Activator_Types::FACET," << be_nl
- << "0," << be_nl
- << "this->context_," << be_nl
- << "this)," << be_uidt_nl
- << "::CORBA::NO_MEMORY ());" << be_uidt_nl << be_nl
- << "::CIAO::Port_Activator_var pa = tmp;" << be_nl << be_nl
- << "::CIAO::Servant_Activator_var sa =" << be_idt_nl
- << "this->container_->ports_servant_activator ();"
- << be_uidt_nl << be_nl
- << "if (! sa->register_port_activator (pa._retn ()))"
- << be_idt_nl
- << "{" << be_idt_nl
- << "return ::" << obj_name << "::_nil ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "::CORBA::Object_var obj =" << be_idt_nl
- << "this->container_->generate_reference (" << be_idt_nl
- << "obj_id.c_str ()," << be_nl
- << "\"" << obj->repoID () << "\"," << be_nl
- << "::CIAO::Container_Types::FACET_CONSUMER_t);"
- << be_uidt_nl << be_uidt_nl
- << "this->add_facet (\"" << port_name << "\", obj.in ());"
- << be_nl << be_nl
- << "return obj._retn ();" << be_uidt_nl
- << "}";
-}
-
-void
-be_visitor_component_svs::gen_uses_context_r (AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_uses)
- {
- continue;
- }
-
- AST_Uses *u =
- AST_Uses::narrow_from_decl (d);
-
- this->gen_uses_context (u);
- }
-
- node = node->base_component ();
- this->gen_uses_context_r (node);
-}
-
-void
-be_visitor_component_svs::gen_uses_context (
- AST_Uses *u)
-{
- AST_Type *obj = u->uses_type ();
- const char *port_name = u->local_name ()->get_string ();
- bool is_multiple = u->is_multiple ();
-
- if (is_multiple)
- {
- this->gen_uses_context_multiplex (obj, port_name);
- }
- else
- {
- this->gen_uses_context_simplex (obj, port_name);
- }
-}
-
-void
-be_visitor_component_svs::gen_uses_context_simplex (
- AST_Type *obj,
- const char *port_name)
-{
- const char *fname = obj->full_name ();
-
- os_ << be_nl << be_nl
- << "::" << fname << "_ptr" << be_nl
- << node_->local_name () << "_Context::get_connection_"
- << port_name << " (void)" << be_nl
- << "{" << be_idt_nl
- << "return ::" << fname << "::_duplicate (" << be_idt_nl
- << "this->ciao_uses_" << port_name << "_.in ());"
- << be_uidt << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "void" << be_nl
- << node_->local_name () << "_Context::connect_"
- << port_name << " (" << be_idt_nl
- << "::" << fname << "_ptr c)" << be_uidt_nl
- << "{" << be_idt_nl
- << "if (! ::CORBA::is_nil (this->ciao_uses_"
- << port_name << "_.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::AlreadyConnected ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "if ( ::CORBA::is_nil (c))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "this->ciao_uses_" << port_name << "_ =" << be_idt_nl
- << "::" << fname << "::_duplicate (c);"
- << be_uidt << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::" << fname << "_ptr" << be_nl
- << node_->local_name () << "_Context::disconnect_"
- << port_name << " (void)" << be_nl
- << "{" << be_idt_nl
- << "if ( ::CORBA::is_nil (this->ciao_uses_"
- << port_name << "_.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::NoConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "return this->ciao_uses_" << port_name
- << "_._retn ();" << be_uidt_nl
- << "}";
-}
-
-void
-be_visitor_component_svs::gen_uses_context_multiplex (
- AST_Type *obj,
- const char *port_name)
-{
- const char *fname = obj->full_name ();
- bool static_config = be_global->gen_ciao_static_config ();
-
- os_ << be_nl << be_nl
- << "::" << node_->full_name () << "::" << port_name
- << "Connections *" << be_nl
- << node_->local_name () << "_Context::get_connections_"
- << port_name << " (void)" << be_nl
- << "{" << be_idt_nl;
-
- if (! static_config)
- {
- os_ << "ACE_READ_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->" << port_name
- << "_lock_," << be_nl
- << " 0);" << be_nl << be_nl;
- }
-
- os_ << "::" << node_->full_name () << "::" << port_name
- << "Connections * tmp_retv = 0;" << be_nl
- << "ACE_NEW_THROW_EX (tmp_retv," << be_nl
- << " ::" << node_->full_name ()
- << "::" << port_name << "Connections (" << be_nl
- << " this->ciao_uses_"
- << port_name << "_.size ())," << be_nl
- << " ::CORBA::NO_MEMORY ());"
- << be_nl << be_nl
- << "::" << node_->full_name () << "::" << port_name
- << "Connections_var retv = tmp_retv;" << be_nl
- << "retv->length (this->ciao_uses_" << port_name
- << "_.size ());" << be_nl
- << "::CORBA::ULong i = 0UL;" << be_nl << be_nl
- << "for (" << tao_cg->upcase (port_name)
- << "_TABLE::const_iterator iter =" << be_nl
- << " this->ciao_uses_" << port_name << "_.begin ();"
- << be_nl
- << " iter != this->ciao_uses_"
- << port_name << "_.end ();" << be_nl
- << " ++iter, ++i)" << be_idt_nl
- << "{" << be_idt_nl
- << "retv[i].objref = iter->second;" << be_nl << be_nl
- << "ACE_NEW_THROW_EX (retv[i].ck.inout ()," << be_nl
- << " ::CIAO::Cookie_Impl (iter->first),"
- << be_nl
- << " ::CORBA::NO_MEMORY ());" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "return retv._retn (); " << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::Cookie *" << be_nl
- << node_->local_name () << "_Context::connect_"
- << port_name << " (" << be_idt_nl
- << "::" << fname << "_ptr c)" << be_uidt_nl
- << "{" << be_idt_nl
- << "if ( ::CORBA::is_nil (c))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "std::pair<" << tao_cg->upcase (port_name)
- << "_TABLE::iterator, bool> result;" << be_nl
- << tao_cg->upcase (port_name)
- << "_TABLE::value_type entry;" << be_nl
- << "entry.first = reinterpret_cast<ptrdiff_t> (c);" << be_nl
- << "entry.second = ::" << fname
- << "::_duplicate (c);";
-
- if (! static_config)
- {
- os_ << be_nl << be_nl
- << "{" << be_idt_nl
- << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->" << port_name
- << "_lock_," << be_nl
- << " 0);";
- }
-
- os_ << be_nl << be_nl
- << "result = this->ciao_uses_" << port_name
- << "_.insert (entry);";
-
- if (! static_config)
- {
- os_ << be_uidt_nl
- << "}";
- }
-
- os_ << be_nl << be_nl
- << "if (! result.second)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();"
- << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "::Components::Cookie * ck = 0;" << be_nl
- << "ACE_NEW_THROW_EX (ck," << be_nl
- << " ::CIAO::Cookie_Impl (entry.first),"
- << be_nl
- << " ::CORBA::NO_MEMORY ());"
- << be_nl << be_nl
- << "return ck;" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::" << fname << "_ptr" << be_nl
- << node_->local_name () << "_Context::disconnect_"
- << port_name << " (" << be_idt_nl
- << "::Components::Cookie * ck)" << be_uidt_nl
- << "{" << be_idt_nl
- << "::" << fname << "_var retv;" << be_nl
- << "ptrdiff_t key = 0UL;" << be_nl
- << tao_cg->upcase (port_name)
- << "_TABLE::size_type n = 0UL;" << be_nl << be_nl
- << "if (ck == 0 || ! ::CIAO::Cookie_Impl::extract (ck, key))"
- << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt;
-
- if (! static_config)
- {
- os_ << be_nl << be_nl
- << "{" << be_idt_nl
- << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->" << port_name
- << "_lock_," << be_nl
- << " ::" << fname
- << "::_nil ());";
- }
-
- os_ << be_nl << be_nl
- << tao_cg->upcase (port_name)
- << "_TABLE::iterator iter =" << be_idt_nl
- << "this->ciao_uses_" << port_name
- << "_.find (key);" << be_uidt_nl << be_nl
- << "if (iter == this->ciao_uses_" << port_name
- << "_.end ())" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "retv = iter->second;" << be_nl
- << "n = this->ciao_uses_" << port_name
- << "_.erase (key);";
-
- if (! static_config)
- {
- os_ << be_uidt_nl
- << "}";
- }
-
- os_ << be_nl << be_nl
- << "if (n != 1UL)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "return retv._retn ();" << be_uidt_nl
- << "}";
-}
-
-void
-be_visitor_component_svs::gen_uses_servant_top (void)
-{
- os_ << be_nl << be_nl
- << "::Components::Cookie *" << be_nl
- << node_->local_name () << "_Servant::connect (" << be_idt_nl
- << "const char * name," << be_nl
- << "::CORBA::Object_ptr connection)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl << be_nl;
- }
-
- os_ << "/// If the component has no receptacles, "
- << "arg will be unused." << be_nl
- << "ACE_UNUSED_ARG (connection);" << be_nl << be_nl
- << "if (name == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}" << be_uidt;
-
- AST_Component *node = node_;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_uses)
- {
- continue;
- }
-
- AST_Uses *u =
- AST_Uses::narrow_from_decl (d);
-
- this->gen_connect_block (u);
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::CORBA::Object_ptr" << be_nl
- << node_->local_name () << "_Servant::disconnect ("
- << be_idt_nl
- << "const char * name," << be_nl
- << "::Components::Cookie * ck)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl << be_nl;
- }
-
- os_ << "ACE_UNUSED_ARG (ck);" << be_nl << be_nl
- << "if (name == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
- << "}" << be_uidt;
-
- node = node_;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_uses)
- {
- continue;
- }
-
- AST_Uses *u =
- AST_Uses::narrow_from_decl (d);
-
- this->gen_disconnect_block (u);
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::ReceptacleDescriptions *" << be_nl
- << node_->local_name ()
- << "_Servant::get_all_receptacles (void)" << be_nl
- << "{" << be_idt_nl
- << "::Components::ReceptacleDescriptions * retval = 0;"
- << be_nl
- << "ACE_NEW_RETURN (retval," << be_nl
- << " ::Components::ReceptacleDescriptions,"
- << be_nl
- << " 0);" << be_nl
- << "::Components::ReceptacleDescriptions_var "
- << "safe_retval = retval;" << be_nl
- << "safe_retval->length (" << n_uses_
- << "UL);";
-
- node = node_;
- ACE_CDR::ULong slot = 0UL;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_uses)
- {
- continue;
- }
-
- AST_Uses *u =
- AST_Uses::narrow_from_decl (d);
-
- this->gen_receptacle_description (u, slot++);
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "return safe_retval._retn ();" << be_uidt_nl
- << "}";
-
- this->gen_uses_servant_r (node_);
-}
-
-void
-be_visitor_component_svs::gen_connect_block (AST_Uses *u)
-{
- 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_nl << be_nl
- << "if (ACE_OS::strcmp (name, \"" << port_name
- << "\") == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "::" << obj_name << "_var _ciao_conn =" << be_idt_nl
- << "::" << obj_name << "::_narrow (connection);"
- << be_uidt_nl << be_nl
- << "if ( ::CORBA::is_nil (_ciao_conn.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl;
-
- if (! is_multiple)
- {
- os_ << "ACE_CString receptacle_name (\"" << port_name
- << "\");" << be_nl
- << "receptacle_name += \'_\';" << be_nl
- << "receptacle_name += "
- << "this->context_->_ciao_instance_id ();" << be_nl
- << "::CORBA::PolicyList_var policy_list =" << be_idt_nl
- << "this->container_->get_receptacle_policy "
- << "(receptacle_name.c_str ());" << be_uidt_nl << be_nl
- << "if (policy_list->length () != 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "::CORBA::Object_var over_ridden_object ="
- << be_idt_nl
- << "_ciao_conn->_set_policy_overrides (policy_list.in (),"
- << be_nl
- << " CORBA::SET_OVERRIDE);"
- << be_uidt_nl
- << "_ciao_conn =" << be_idt_nl
- << "::" << obj_name << "::_narrow (over_ridden_object.in ());"
- << be_uidt << be_uidt_nl
- << "}" << be_uidt_nl << be_nl;
- }
-
- os_ << "/// " << (is_multiple ? "Multiplex" : "Simplex")
- << " connect." << be_nl
- << (is_multiple ? "return " : "") << "this->connect_"
- << port_name << " (_ciao_conn.in ());";
-
- if (! is_multiple)
- {
- os_ << be_nl << be_nl
- << "return 0;";
- }
-
- os_ << be_uidt_nl
- << "}" << be_uidt;
-}
-
-void
-be_visitor_component_svs::gen_disconnect_block (AST_Uses *u)
-{
- const char *port_name = u->local_name ()->get_string ();
- bool is_multiple = u->is_multiple ();
-
- os_ << be_nl << be_nl
- << "if (ACE_OS::strcmp (name, \"" << port_name
- << "\") == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "/// " << (is_multiple ? "Multiplex" : "Simplex")
- << " disconnect." << be_nl;
-
- if (is_multiple)
- {
- os_ << "if (ck == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::CookieRequired ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl;
- }
-
- os_ << "return this->disconnect_" << port_name
- << " (" << (is_multiple ? "ck" : "") << ");" << be_uidt_nl
- << "}" << be_uidt;
-}
-
-void
-be_visitor_component_svs::gen_uses_servant_r (
- AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_uses)
- {
- continue;
- }
-
- AST_Uses *u =
- AST_Uses::narrow_from_decl (d);
-
- this->gen_uses_servant (u);
- }
-
- node = node->base_component ();
- this->gen_uses_servant_r (node);
-}
-
-void
-be_visitor_component_svs::gen_uses_servant (AST_Uses *u)
-{
- 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_nl << be_nl
- << (is_multiple ? "::Components::Cookie *" : "void")
- << be_nl
- << node_->local_name () << "_Servant::connect_"
- << port_name << " (" << be_idt_nl
- << "::" << obj_name << "_ptr c)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (is_multiple)
- {
- os_ << "::Components::Cookie * cookie =" << be_idt_nl;
- }
-
- os_ << "this->context_->connect_" << port_name
- << " (c);" << be_nl;
-
- if (is_multiple)
- {
- os_ << be_uidt_nl;
- }
-
- os_ << "this->add_receptacle (\"" << port_name
- << "\", c, " << (is_multiple ? "cookie" : "0")
- << ");";
-
- if (is_multiple)
- {
- os_ << be_nl << be_nl
- << "return cookie;";
- }
-
- os_ << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::" << obj_name << "_ptr" << be_nl
- << node_->local_name () << "_Servant::disconnect_"
- << port_name << " (";
-
- if (is_multiple)
- {
- os_ << be_idt_nl
- << "::Components::Cookie * ck" << be_uidt;
- }
- else
- {
- os_ << "void";
- }
-
- os_ << ")" << be_nl
- << "{" << be_idt_nl
- << "return this->context_->disconnect_"
- << port_name << " (" << (is_multiple ? "ck" : "")
- << ");" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::";
-
- if (is_multiple)
- {
- os_ << node_->full_name () << "::" << port_name
- << "Connections *";
- }
- else
- {
- os_ << obj_name << "_ptr";
- }
-
- os_ << be_nl
- << node_->local_name () << "_Servant::get_connection"
- << (is_multiple ? "s" : "") << "_"
- << port_name << " (void)" << be_nl
- << "{" << be_idt_nl
- << "return this->context_->get_connection"
- << (is_multiple ? "s" : "") << "_"
- << port_name << " ();" << be_uidt_nl
- << "}";
-}
-
-void
-be_visitor_component_svs::gen_receptacle_description (
- AST_Uses *u,
- ACE_CDR::ULong slot)
-{
- AST_Type *obj = u->uses_type ();
- const char *port_name = u->local_name ()->get_string ();
- bool is_multiple = u->is_multiple ();
-
- os_ << be_nl << be_nl;
-
- bool gen_guard =
- is_multiple && ! be_global->gen_ciao_static_config ();
-
- if (gen_guard)
- {
- os_ << "{" << be_idt_nl
- << "ACE_READ_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->context_->"
- << port_name << "_lock_," << be_nl
- << " 0);" << be_nl << be_nl;
- }
-
- os_ << "::CIAO::Servant::describe_"
- << (is_multiple ? "multiplex" : "simplex")
- << "_receptacle<" << be_idt_nl
- << "::" << obj->full_name () << "_var> (" << be_idt_nl
- << "\"" << port_name << "\"," << be_nl
- << "\"" << obj->repoID () << "\"," << be_nl
- << "this->context_->ciao_uses_"
- << port_name << "_," << be_nl
- << "safe_retval," << be_nl
- << slot << "UL);" << be_uidt << be_uidt;
-
- if (gen_guard)
- {
- os_ << be_uidt_nl
- << "}";
- }
-}
-
-void
-be_visitor_component_svs::gen_publishes_context_r (
- AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_publishes)
- {
- continue;
- }
-
- AST_Publishes *p =
- AST_Publishes::narrow_from_decl (d);
-
- this->gen_publishes_context (p);
- }
-
- node = node->base_component ();
- this->gen_publishes_context_r (node);
-}
-
-void
-be_visitor_component_svs::gen_publishes_context (
- AST_Publishes *p)
-{
- AST_Type *obj = p->publishes_type ();
- const char *port_name = p->local_name ()->get_string ();
- const char *fname = obj->full_name ();
- const char *lname = obj->local_name ()->get_string ();
- ACE_CString sname_str (
- ScopeAsDecl (obj->defined_in ())->full_name ());
- const char *sname = sname_str.c_str ();
- const char *global = (sname_str == "" ? "" : "::");
- bool static_config =
- be_global->gen_ciao_static_config ();
-
- os_ << be_nl << be_nl
- << "void" << be_nl
- << node_->local_name () << "_Context::push_"
- << port_name << " (" << be_idt_nl
- << "::" << fname << " * ev)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (! static_config)
- {
- os_ << "ACE_READ_GUARD (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->" << port_name
- << "_lock_);" << be_nl << be_nl;
- }
-
- os_ << "for (" << tao_cg->upcase (port_name)
- << "_TABLE::const_iterator iter =" << be_nl
- << " this->ciao_publishes_" << port_name
- << "_.begin ();" << be_nl
- << " iter != this->ciao_publishes_" << port_name
- << "_.end ();" << be_nl
- << " ++iter)" << be_idt_nl
- << "{" << be_idt_nl
- << "iter->second->push_" << lname << " (ev);"
- << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "ACE_CString source_id (this->_ciao_instance_id ());"
- << be_nl
- << "source_id += \"_" << port_name << "\";"
- << be_nl << be_nl
- << "for (" << tao_cg->upcase (port_name)
- << "_GENERIC_TABLE::const_iterator giter =" << be_nl
- << " this->ciao_publishes_" << port_name
- << "_generic_.begin ();" << be_nl
- << " giter != this->ciao_publishes_"
- << port_name << "_generic_.end ();" << be_nl
- << " ++giter)" << be_idt_nl
- << "{" << be_idt_nl
- << "giter->second->ciao_push_event (ev," << be_nl
- << " source_id.c_str (),"
- << be_nl
- << " " << global
- << sname << "::_tc_" << lname << ");" << be_uidt_nl
- << "}" << be_uidt << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::Cookie *" << be_nl
- << node_->local_name () << "_Context::subscribe_"
- << port_name << " (" << be_idt_nl
- << "::" << fname << "Consumer_ptr c)" << be_uidt_nl
- << "{" << be_idt_nl
- << "if ( ::CORBA::is_nil (c))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "std::pair<" << tao_cg->upcase (port_name)
- << "_TABLE::iterator, bool> result;" << be_nl
- << tao_cg->upcase (port_name)
- << "_TABLE::value_type entry;" << be_nl
- << "entry.first = reinterpret_cast<ptrdiff_t> (c);"
- << be_nl
- << "entry.second = ::" << fname
- << "Consumer::_duplicate (c);" << be_nl << be_nl;
-
- if (! static_config)
- {
- os_ << "{" << be_idt_nl
- << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->" << port_name
- << "_lock_," << be_nl
- << " 0);" << be_nl << be_nl;
- }
-
- os_ << "result = this->ciao_publishes_" << port_name
- << "_.insert (entry);";
-
- if (! static_config)
- {
- os_ << be_uidt_nl
- << "}";
- }
-
- os_ << be_nl << be_nl
- << "if (! result.second)" << be_idt_nl
- << "{" << be_idt_nl
- << "ACE_ERROR_RETURN ((LM_ERROR," << be_nl
- << " ACE_TEXT (\"subscribe on %s failed\\n\"),"
- << be_nl
- << " ACE_TEXT (\"" << port_name
- << "\"))," << be_nl
- << " 0);" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "::Components::Cookie * retv = 0;" << be_nl
- << "ACE_NEW_THROW_EX (retv," << be_nl
- << " ::CIAO::Cookie_Impl (entry.first),"
- << be_nl
- << " ::CORBA::NO_MEMORY ());"
- << be_nl << be_nl
- << "return retv;" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::Cookie *" << be_nl
- << node_->local_name () << "_Context::subscribe_"
- << port_name << "_generic (" << be_idt_nl
- << "::Components::EventConsumerBase_ptr c)" << be_uidt_nl
- << "{" << be_idt_nl
- << "if ( ::CORBA::is_nil (c))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "std::pair<" << tao_cg->upcase (port_name)
- << "_GENERIC_TABLE::iterator, bool> result;" << be_nl
- << tao_cg->upcase (port_name)
- << "_GENERIC_TABLE::value_type entry;" << be_nl
- << "entry.first = reinterpret_cast<ptrdiff_t> (c);"
- << be_nl
- << "entry.second =" << be_idt_nl
- << "::Components::EventConsumerBase::_duplicate (c);"
- << be_uidt_nl << be_nl;
-
- if (! static_config)
- {
- os_ << "{" << be_idt_nl
- << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->" << port_name
- << "_lock_," << be_nl
- << " 0);" << be_nl << be_nl;
- }
-
- os_ << "result =" << be_idt_nl
- << "this->ciao_publishes_" << port_name
- << "_generic_.insert (entry);" << be_uidt;
-
- if (! static_config)
- {
- os_ << be_uidt_nl
- << "}";
- }
-
- os_ << be_nl << be_nl
- << "if (! result.second)" << be_idt_nl
- << "{" << be_idt_nl
- << "ACE_ERROR_RETURN ((LM_ERROR," << be_nl
- << " ACE_TEXT (\"generic subscribe \")"
- << be_nl
- << " ACE_TEXT (\"on %s failed\\n\"),"
- << be_nl
- << " ACE_TEXT (\"" << port_name
- << "\"))," << be_nl
- << " 0);" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "::Components::Cookie * retv = 0;" << be_nl
- << "ACE_NEW_THROW_EX (retv," << be_nl
- << " ::CIAO::Cookie_Impl (entry.first),"
- << be_nl
- << " ::CORBA::NO_MEMORY ());"
- << be_nl << be_nl
- << "return retv;" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::" << fname << "Consumer_ptr" << be_nl
- << node_->local_name () << "_Context::unsubscribe_"
- << port_name << " (" << be_idt_nl
- << "::Components::Cookie * ck)" << be_uidt_nl
- << "{" << be_idt_nl
- << "ptrdiff_t key = 0UL;" << be_nl
- << tao_cg->upcase (port_name)
- << "_TABLE::size_type n = 0UL;" << be_nl << be_nl
- << "if (ck == 0 || ! ::CIAO::Cookie_Impl::extract (ck, key))"
- << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl;
-
- if (! static_config)
- {
- os_ << "{" << be_idt_nl
- << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->" << port_name
- << "_lock_," << be_nl
- << " ::" << fname
- << "Consumer::_nil ());" << be_nl << be_nl;
- }
-
- os_ << tao_cg->upcase (port_name) << "_TABLE::iterator iter ="
- << be_idt_nl
- << "this->ciao_publishes_" << port_name << "_.find (key);"
- << be_uidt_nl << be_nl
- << "if (iter != this->ciao_publishes_" << port_name
- << "_.end ())" << be_idt_nl
- << "{" << be_idt_nl
- << "::" << fname
- << "Consumer_var retv = iter->second;" << be_nl
- << "n = this->ciao_publishes_" << port_name
- << "_.erase (key);" << be_nl << be_nl
- << "if (n == 1UL)" << be_idt_nl
- << "{" << be_idt_nl
- << "return retv._retn ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << tao_cg->upcase (port_name)
- << "_GENERIC_TABLE::iterator giter =" << be_idt_nl
- << "this->ciao_publishes_" << port_name
- << "_generic_.find (key);" << be_uidt_nl << be_nl
- << "if (giter == this->ciao_publishes_" << port_name
- << "_generic_.end ())" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "n = this->ciao_publishes_" << port_name
- << "_generic_.erase (key);";
-
- if (! static_config)
- {
- os_ << be_uidt_nl
- << "}";
- }
-
- os_ << be_nl << be_nl
- << "if (n != 1UL)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "return ::" << fname << "Consumer::_nil ();"
- << be_uidt_nl
- << "}";
-}
-
-void
-be_visitor_component_svs::gen_publishes_servant_top (void)
-{
- os_ << be_nl << be_nl
- << "::Components::Cookie *" << be_nl
- << node_->local_name () << "_Servant::subscribe ("
- << be_idt_nl
- << "const char * publisher_name," << be_nl
- << "::Components::EventConsumerBase_ptr subscribe)"
- << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl << be_nl;
- }
-
- os_ << "ACE_UNUSED_ARG (subscribe);" << be_nl << be_nl
- << "if (publisher_name == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}" << be_uidt;
-
- AST_Component *node = node_;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_publishes)
- {
- continue;
- }
-
- AST_Publishes *p =
- AST_Publishes::narrow_from_decl (d);
-
- this->gen_subscribe_block (p);
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::EventConsumerBase_ptr" << be_nl
- << node_->local_name () << "_Servant::unsubscribe ("
- << be_idt_nl
- << "const char * publisher_name," << be_nl
- << "::Components::Cookie * ck)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl << be_nl;
- }
-
- os_ << "ACE_UNUSED_ARG (ck);" << be_nl << be_nl
- << "if (publisher_name == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}" << be_uidt;
-
- node = node_;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_publishes)
- {
- continue;
- }
-
- AST_Publishes *p =
- AST_Publishes::narrow_from_decl (d);
-
- this->gen_unsubscribe_block (p);
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::PublisherDescriptions *" << be_nl
- << node_->local_name ()
- << "_Servant::get_all_publishers (void)" << be_nl
- << "{" << be_idt_nl
- << "::Components::PublisherDescriptions *retval = 0;"
- << be_nl
- << "ACE_NEW_RETURN (retval," << be_nl
- << " ::Components::PublisherDescriptions,"
- << be_nl
- << " 0);" << be_nl << be_nl
- << "::Components::PublisherDescriptions_var "
- << "safe_retval = retval;" << be_nl
- << "safe_retval->length (" << n_publishes_
- << "UL);";
-
- node = node_;
- ACE_CDR::ULong slot = 0UL;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_publishes)
- {
- continue;
- }
-
- AST_Publishes *p =
- AST_Publishes::narrow_from_decl (d);
-
- this->gen_event_source_description (p, slot++);
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "return safe_retval._retn ();" << be_uidt_nl
- << "}";
-
- this->gen_publishes_servant_r (node_);
-}
-
-void
-be_visitor_component_svs::gen_subscribe_block (
- AST_Publishes *p)
-{
- const char *obj_name = p->publishes_type ()->full_name ();
- const char *port_name = p->local_name ()->get_string ();
-
- os_ << be_nl << be_nl
- << "if (ACE_OS::strcmp (publisher_name, \""
- << port_name << "\") == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "::" << obj_name << "Consumer_var sub =" << be_idt_nl
- << "::" << obj_name << "Consumer::_narrow (subscribe);"
- << be_uidt_nl << be_nl
- << "if ( ::CORBA::is_nil (sub.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "::CORBA::Boolean const substitutable =" << be_idt_nl
- << "subscribe->ciao_is_substitutable (" << be_idt_nl
- << "::" << obj_name
- << "::_tao_obv_static_repository_id ());"
- << be_uidt << be_uidt_nl << be_nl
- << "if (substitutable)" << be_idt_nl
- << "{" << be_idt_nl
- << "return this->subscribe_" << port_name
- << "_generic (subscribe);" << be_uidt_nl
- << "}" << be_uidt_nl
- << "else" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt << be_uidt_nl
- << "}" << be_uidt_nl
- << "else" << be_idt_nl
- << "{" << be_idt_nl
- << "return this->subscribe_" << port_name
- << " (sub.in ());" << be_uidt_nl
- << "}" << be_uidt << be_uidt_nl
- << "}" << be_uidt;
-}
-
-void
-be_visitor_component_svs::gen_unsubscribe_block (
- AST_Publishes *p)
-{
- const char *port_name = p->local_name ()->get_string ();
-
- os_ << be_nl << be_nl
- << "if (ACE_OS::strcmp (publisher_name, \""
- << port_name << "\") == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "return this->unsubscribe_" << port_name
- << " (ck);" << be_uidt_nl
- << "}" << be_uidt;
-}
-
-void
-be_visitor_component_svs::gen_event_source_description (
- AST_Publishes *p,
- ACE_CDR::ULong slot)
-{
- AST_Type *obj = p->publishes_type ();
- const char *port_name = p->local_name ()->get_string ();
-
- os_ << be_nl << be_nl;
-
- if (! be_global->gen_ciao_static_config ())
- {
- os_ << "{" << be_idt_nl
- << "ACE_READ_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->context_->"
- << port_name << "_lock_," << be_nl
- << " 0);" << be_nl << be_nl;
- }
-
- os_ << "::CIAO::Servant::describe_pub_event_source<"
- << be_idt_nl
- << "::" << obj->full_name () << "Consumer_var> ("
- << be_idt_nl
- << "\"" << port_name << "\"," << be_nl
- << "\"" << obj->repoID () << "\"," << be_nl
- << "this->context_->ciao_publishes_"
- << port_name << "_," << be_nl
- << "safe_retval," << be_nl
- << slot << "UL);" << be_uidt << be_uidt;
-
- if (! be_global->gen_ciao_static_config ())
- {
- os_ << be_uidt_nl
- << "}";
- }
-}
-
-void
-be_visitor_component_svs::gen_publishes_servant_r (AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_publishes)
- {
- continue;
- }
-
- AST_Publishes *p =
- AST_Publishes::narrow_from_decl (d);
-
- this->gen_publishes_servant (p);
- }
-
- node = node->base_component ();
- this->gen_publishes_servant_r (node);
-}
-
-void
-be_visitor_component_svs::gen_publishes_servant (
- AST_Publishes *p)
-{
- const char *obj_name = p->publishes_type ()->full_name ();
- const char *port_name = p->local_name ()->get_string ();
-
- os_ << be_nl << be_nl
- << "::Components::Cookie *" << be_nl
- << node_->local_name () << "_Servant::subscribe_"
- << port_name << " (" << be_idt_nl
- << "::" << obj_name << "Consumer_ptr c)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl;
- }
-
- os_ << "return this->context_->subscribe_" << port_name
- << " (c);" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::Cookie *" << be_nl
- << node_->local_name () << "_Servant::subscribe_"
- << port_name << "_generic (" << be_idt_nl
- << "::Components::EventConsumerBase_ptr c)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl;
- }
-
- os_ << "return this->context_->subscribe_" << port_name
- << "_generic (c);" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::" << obj_name << "Consumer_ptr" << be_nl
- << node_->local_name () << "_Servant::unsubscribe_"
- << port_name << " (" << be_idt_nl
- << "::Components::Cookie * ck)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl;
- }
-
- os_ << "return this->context_->unsubscribe_" << port_name
- << " (ck);" << be_uidt_nl
- << "}";
-}
-
void
-be_visitor_component_svs::gen_consumes_r (AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_consumes)
- {
- continue;
- }
-
- AST_Consumes *c =
- AST_Consumes::narrow_from_decl (d);
-
- this->gen_consumes (c);
- }
-
- node = node->base_component ();
- this->gen_consumes_r (node);
-}
-
-void
-be_visitor_component_svs::gen_consumes (AST_Consumes *c)
-{
- AST_Type *obj = c->consumes_type ();
- const char *port_name = c->local_name ()->get_string ();
-
- const char *comp_lname = node_->local_name ();
- ACE_CString comp_sname_str (
- ScopeAsDecl (node_->defined_in ())->full_name ());
- const char *comp_sname = comp_sname_str.c_str ();
- const char *global = (comp_sname_str == "" ? "" : "::");
-
- const char *lname = obj->local_name ()->get_string ();
- const char *fname = obj->full_name ();
-
- os_ << be_nl << be_nl
- << comp_lname << "_Servant::" << lname << "Consumer_"
- << port_name << "_Servant::" << lname << "Consumer_"
- << port_name << "_Servant (" << be_idt << be_idt_nl
- << global << comp_sname << "::CCM_" << comp_lname
- << "_ptr executor," << be_nl
- << global << comp_sname << "::CCM_" << comp_lname
- << "_Context_ptr c)" << be_uidt_nl
- << ": executor_ ( " << global << comp_sname << "::CCM_"
- << comp_lname << "::_duplicate (executor))," << be_idt_nl
- << "ctx_ ( " << global << comp_sname
- << "::CCM_" << comp_lname
- << "_Context::_duplicate (c))" << be_uidt << be_uidt_nl
- << "{" << be_nl
- << "}";
-
- os_ << be_nl << be_nl
- << comp_lname << "_Servant::" << lname << "Consumer_"
- << port_name << "_Servant::~" << lname << "Consumer_"
- << port_name << "_Servant (void)" << be_nl
- << "{" << be_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::CORBA::Object_ptr" << be_nl
- << comp_lname << "_Servant::" << lname << "Consumer_"
- << port_name << "_Servant::_get_component (void)" << be_nl
- << "{" << be_idt_nl
- << "return this->ctx_->get_CCM_object ();" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "void" << be_nl
- << comp_lname << "_Servant::" << lname << "Consumer_"
- << port_name << "_Servant::push_" << lname
- << " (" << be_idt_nl
- << "::" << fname << " * evt)" << be_uidt_nl
- << "{" << be_idt_nl
- << "this->executor_->push_" << port_name
- << " (evt);" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "/// Inherited from ::Components::EventConsumerBase."
- << be_nl
- << "void" << be_nl
- << comp_lname << "_Servant::" << lname << "Consumer_"
- << port_name << "_Servant::push_event (" << be_idt_nl
- << "::Components::EventBase * ev)" << be_uidt_nl
- << "{" << be_idt_nl
- << "::" << fname << " * ev_type =" << be_idt_nl
- << "::" << fname << "::_downcast (ev);"
- << be_uidt_nl << be_nl
- << "if (ev_type != 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "this->push_" << lname << " (ev_type);" << be_nl
- << "return;" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "throw ::Components::BadEventType ();" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "/// CIAO-specific."
- << be_nl
- << "void" << be_nl
- << comp_lname << "_Servant::" << lname << "Consumer_"
- << port_name << "_Servant::ciao_push_event (" << be_idt_nl
- << "::Components::EventBase * ev," << be_nl
- << "const char * /* source_id */," << be_nl
- << "::CORBA::TypeCode_ptr /* tc */)" << be_uidt_nl
- << "{" << be_idt_nl
- << "this->push_event (ev);" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "/// CIAO-specific."
- << be_nl
- << "::CORBA::Boolean" << be_nl
- << comp_lname << "_Servant::" << lname << "Consumer_"
- << port_name << "_Servant::ciao_is_substitutable ("
- << be_idt_nl
- << "const char * event_repo_id)" << be_uidt_nl
- << "{" << be_idt_nl
- << "if (event_repo_id == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "CORBA::ORB_ptr orb = TAO_ORB_Core_instance ()->orb ();"
- << be_nl << be_nl
- << "CORBA::ValueFactory f =" << be_idt_nl
- << "orb->lookup_value_factory (event_repo_id);"
- << be_uidt_nl << be_nl
- << "if (f == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "return false;" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "CORBA::ValueBase_var v = f->create_for_unmarshal ();"
- << be_nl
- << "f->_remove_ref ();" << be_nl << be_nl
- << "if (v.in () == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "return false;" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "return dynamic_cast< ::" << fname
- << " *> (v.in ()) != 0;" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::" << fname << "Consumer_ptr" << be_nl
- << node_->local_name () << "_Servant::get_consumer_"
- << port_name << " (void)" << be_nl
- << "{" << be_idt_nl
- << "if (! ::CORBA::is_nil (this->consumes_" << port_name
- << "_.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "return ::" << fname
- << "Consumer::_duplicate (this->consumes_"
- << port_name << "_.in ());" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "::Components::EventConsumerBase_var obj =" << be_idt_nl
- << "this->get_consumer_" << port_name << "_i ();"
- << be_uidt_nl << be_nl
- << "::" << fname << "Consumer_var eco =" << be_idt_nl
- << "::" << fname << "Consumer::_narrow (obj.in ());"
- << be_uidt_nl << be_nl
- << "this->consumes_" << port_name << "_ = eco;" << be_nl
- << "return" << be_idt_nl
- << "::" << fname << "Consumer::_duplicate (" << be_idt_nl
- << "this->consumes_" << port_name << "_.in ());"
- << be_uidt << be_uidt << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::EventConsumerBase_ptr" << be_nl
- << node_->local_name () << "_Servant::get_consumer_"
- << port_name << "_i (void)" << be_nl
- << "{" << be_idt_nl
- << "::Components::EventConsumerBase_ptr ret =" << be_idt_nl
- << "this->lookup_consumer (\"" << port_name << "\");"
- << be_uidt_nl << be_nl
- << "if (! ::CORBA::is_nil (ret))" << be_idt_nl
- << "{" << be_idt_nl
- << "return ret;" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "typedef" << be_idt_nl
- << "::CIAO::Port_Activator_T<" << be_idt_nl
- << node_->local_name () << "_Servant::" << lname
- << "Consumer_" << port_name << "_Servant," << be_nl
- << global << comp_sname << "::CCM_" << comp_lname
- << "," << be_nl
- << global << comp_sname << "::CCM_" << comp_lname
- << "_Context," << be_nl
- << node_->local_name () << "_Servant>" << be_uidt_nl
- << "MACRO_MADNESS_TYPEDEF;" << be_uidt_nl << be_nl
- << "MACRO_MADNESS_TYPEDEF * tmp = 0;" << be_nl
- << "ACE_CString obj_id (this->ins_name_);" << be_nl
- << "obj_id += \"_" << port_name << "\";" << be_nl << be_nl
- << "ACE_NEW_THROW_EX (" << be_idt_nl
- << "tmp," << be_nl
- << "MACRO_MADNESS_TYPEDEF (" << be_idt_nl
- << "obj_id.c_str ()," << be_nl
- << "\"" << port_name << "\"," << be_nl
- << "::CIAO::Port_Activator_Types::SINK," << be_nl
- << "this->executor_.in ()," << be_nl
- << "this->context_," << be_nl
- << "this)," << be_uidt_nl
- << "::CORBA::NO_MEMORY ());" << be_uidt_nl << be_nl
- << "::CIAO::Port_Activator_var pa = tmp;" << be_nl << be_nl
- << "::CIAO::Servant_Activator_var sa =" << be_idt_nl
- << "this->container_->ports_servant_activator ();"
- << be_uidt_nl << be_nl
- << "if (! sa->register_port_activator (tmp))"
- << be_idt_nl
- << "{" << be_idt_nl
- << "return ::" << fname << "Consumer::_nil ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "::CORBA::Object_var obj =" << be_idt_nl
- << "this->container_->generate_reference (" << be_idt_nl
- << "obj_id.c_str ()," << be_nl
- << "\"";
-
- ACE_CString work (obj->repoID ());
- ACE_CString result (work.substr (0, work.rfind (':')));
- result += "Consumer:1.0";
-
- os_ << result.c_str ();
-
- os_ << "\"," << be_nl
- << "::CIAO::Container_Types::FACET_CONSUMER_t);"
- << be_uidt_nl << be_uidt_nl
- << "::Components::EventConsumerBase_var ecb =" << be_idt_nl
- << "::Components::EventConsumerBase::_narrow (obj.in ());"
- << be_uidt_nl << be_nl
- << "this->add_consumer (\"" << port_name << "\", ecb.in ());"
- << be_nl << be_nl
- << "return ecb._retn ();" << be_uidt_nl
- << "}";
-}
-
-void
-be_visitor_component_svs::gen_emits_context_r (AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_emits)
- {
- continue;
- }
-
- AST_Emits *e =
- AST_Emits::narrow_from_decl (d);
-
- this->gen_emits_context (e);
- }
-
- node = node->base_component ();
- this->gen_emits_context_r (node);
-}
-
-void
-be_visitor_component_svs::gen_emits_context (
- AST_Emits *e)
-{
- AST_Type *obj = e->emits_type ();
- const char *port_name = e->local_name ()->get_string ();
-
- const char *fname = obj->full_name ();
- const char *lname = obj->local_name ()->get_string ();
-
- os_ << be_nl << be_nl
- << "void" << be_nl
- << node_->local_name () << "_Context::push_" << port_name
- << " (" << be_idt_nl
- << "::" << fname << " * ev)" << be_uidt_nl
- << "{" << be_idt_nl
- << "if (! ::CORBA::is_nil (this->ciao_emits_"
- << port_name << "_consumer_.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "this->ciao_emits_" << port_name << "_consumer_->push_"
- << lname << " (ev);" << be_uidt_nl
- << "}" << be_uidt << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "void" << be_nl
- << node_->local_name () << "_Context::connect_" << port_name
- << " (" << be_idt_nl
- << "::" << fname << "Consumer_ptr c)" << be_uidt_nl
- << "{" << be_idt_nl
- << "if ( ::CORBA::is_nil (c))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "if (! ::CORBA::is_nil (this->ciao_emits_"
- << port_name << "_consumer_.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::AlreadyConnected ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "this->ciao_emits_" << port_name
- << "_consumer_ =" << be_idt_nl
- << "::" << fname << "Consumer::_duplicate (c);"
- << be_uidt << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::" << fname << "Consumer_ptr" << be_nl
- << node_->local_name () << "_Context::disconnect_"
- << port_name << " (void)" << be_nl
- << "{" << be_idt_nl
- << "if ( ::CORBA::is_nil (this->ciao_emits_"
- << port_name << "_consumer_.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::NoConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "return this->ciao_emits_" << port_name
- << "_consumer_._retn ();" << be_uidt_nl
- << "}";
-}
-
-void
-be_visitor_component_svs::gen_emits_servant_top (void)
-{
- os_ << be_nl << be_nl
- << "void" << be_nl
- << node_->local_name () << "_Servant::connect_consumer ("
- << be_idt_nl
- << "const char * emitter_name," << be_nl
- << "::Components::EventConsumerBase_ptr consumer)"
- << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl << be_nl;
- }
-
- os_ << "if (emitter_name == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
- << "}" << be_uidt;
-
- AST_Component *node = node_;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_emits)
- {
- continue;
- }
-
- AST_Emits *e =
- AST_Emits::narrow_from_decl (d);
-
- this->gen_connect_consumer_block (e);
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "ACE_UNUSED_ARG (consumer);" << be_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::EventConsumerBase_ptr" << be_nl
- << node_->local_name ()
- << "_Servant::disconnect_consumer (" << be_idt_nl
- << "const char * source_name)" << be_uidt_nl
- << "{" << be_idt_nl;
-
- if (swapping_)
- {
- os_ << "this->activate_component ();" << be_nl << be_nl;
- }
-
- os_ << "if (source_name == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
- << "}" << be_uidt;
-
- node = node_;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_emits)
- {
- continue;
- }
-
- AST_Emits *e =
- AST_Emits::narrow_from_decl (d);
-
- this->gen_disconnect_consumer_block (e);
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "throw ::Components::InvalidName ();" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::Components::EmitterDescriptions *" << be_nl
- << node_->local_name ()
- << "_Servant::get_all_emitters (void)" << be_nl
- << "{" << be_idt_nl
- << "::Components::EmitterDescriptions *retval = 0;"
- << be_nl
- << "ACE_NEW_RETURN (retval," << be_nl
- << " ::Components::EmitterDescriptions,"
- << be_nl
- << " 0);" << be_nl << be_nl
- << "::Components::EmitterDescriptions_var "
- << "safe_retval = retval;" << be_nl
- << "safe_retval->length (" << n_emits_
- << "UL);";
-
- node = node_;
- ACE_CDR::ULong slot = 0UL;
-
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_emits)
- {
- continue;
- }
-
- AST_Emits *e =
- AST_Emits::narrow_from_decl (d);
-
- this->gen_emitter_description (e, slot++);
- }
-
- node = node->base_component ();
- }
-
- os_ << be_nl << be_nl
- << "return safe_retval._retn ();" << be_uidt_nl
- << "}";
-
- this->gen_emits_servant_r (node_);
-}
-
-void
-be_visitor_component_svs::gen_connect_consumer_block (
- AST_Emits *e)
-{
- const char *obj_name = e->emits_type ()->full_name ();
- const char *port_name = e->local_name ()->get_string ();
-
- os_ << be_nl << be_nl
- << "if (ACE_OS::strcmp (emitter_name, \""
- << port_name << "\") == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "::" << obj_name
- << "Consumer_var _ciao_consumer =" << be_idt_nl
- << "::" << obj_name
- << "Consumer::_narrow (consumer);" << be_uidt_nl << be_nl
- << "if ( ::CORBA::is_nil (_ciao_consumer.in ()))"
- << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "this->connect_" << port_name
- << " (_ciao_consumer.in ());" << be_nl << be_nl
- << "return;" << be_uidt_nl
- << "}" << be_uidt;
-}
-
-void
-be_visitor_component_svs::gen_disconnect_consumer_block (
- AST_Emits *e)
-{
- const char *port_name = e->local_name ()->get_string ();
-
- os_ << be_nl << be_nl
- << "if (ACE_OS::strcmp (source_name, \""
- << port_name << "\") == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "return this->disconnect_" << port_name
- << " ();" << be_uidt_nl
- << "}" << be_uidt;
-}
-
-void
-be_visitor_component_svs::gen_emitter_description (
- AST_Emits *e,
- ACE_CDR::ULong slot)
-{
- AST_Type *obj = e->emits_type ();
- const char *port_name = e->local_name ()->get_string ();
-
- os_ << be_nl << be_nl
- << "::CIAO::Servant::describe_emit_event_source<"
- << be_idt_nl
- << "::" << obj->full_name () << "Consumer_var> ("
- << be_idt_nl
- << "\"" << port_name << "\"," << be_nl
- << "\"" << obj->repoID () << "\"," << be_nl
- << "this->context_->ciao_emits_" << port_name
- << "_consumer_," << be_nl
- << "safe_retval," << be_nl
- << slot << "UL);" << be_uidt << be_uidt;
-}
-
-void
-be_visitor_component_svs::gen_emits_servant_r (AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_emits)
- {
- continue;
- }
-
- AST_Emits *e =
- AST_Emits::narrow_from_decl (d);
-
- this->gen_emits_servant (e);
- }
-
- node = node->base_component ();
- this->gen_emits_context_r (node);
-}
-
-void
-be_visitor_component_svs::gen_emits_servant (AST_Emits *e)
-{
- const char *obj_name = e->emits_type ()->full_name ();
- const char *port_name = e->local_name ()->get_string ();
-
- os_ << be_nl << be_nl
- << "void" << be_nl
- << node_->local_name () << "_Servant::connect_"
- << port_name << " (" << be_idt_nl
- << "::" << obj_name << "Consumer_ptr c)" << be_uidt_nl
- << "{" << be_idt_nl
- << "this->context_->connect_" << port_name
- << " (c);" << be_uidt_nl
- << "}";
-
- os_ << be_nl << be_nl
- << "::" << obj_name << "Consumer_ptr" << be_nl
- << node_->local_name () << "_Servant::disconnect_"
- << port_name << " (void)" << be_nl
- << "{" << be_idt_nl
- << "return this->context_->disconnect_"
- << port_name << " ();" << be_uidt_nl
- << "}";
-}
-
-void
-be_visitor_component_svs::gen_attr_set_r (AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, 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_attr)
- {
- be_attribute *attr =
- be_attribute::narrow_from_decl (d);
-
- if (attr->readonly ())
- {
- continue;
- }
-
- be_visitor_attribute_component_init v (this->ctx_);
-
- if (v.visit_attribute (attr) == -1)
- {
- }
- }
- }
-
- node = node->base_component ();
- this->gen_attr_set_r (node);
-}
-
-void
-be_visitor_component_svs::gen_populate_r (AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- switch (d->node_type ())
- {
- case AST_Decl::NT_provides:
- os_ << be_nl
- << "obj_var = this->provide_"
- << d->local_name ()->get_string () << "_i ();";
-
- break;
- case AST_Decl::NT_consumes:
- os_ << be_nl
- << "ecb_var = this->get_consumer_"
- << d->local_name ()->get_string () << "_i ();";
-
- break;
- default:
- break;
- }
- }
-
- node = node->base_component ();
- this->gen_populate_r (node);
-}
-
-void
-be_visitor_component_svs::gen_entrypoint (void)
+be_visitor_component_svs::gen_entrypoint (AST_Component *node)
{
ACE_CString sname_str (
- ScopeAsDecl (node_->defined_in ())->full_name ());
+ ScopeAsDecl (node->defined_in ())->full_name ());
const char *sname = sname_str.c_str ();
- const char *lname = node_->local_name ();
+ const char *lname = node->local_name ()->get_string ();
const char *global = (sname_str == "" ? "" : "::");
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
@@ -2658,188 +131,3 @@ be_visitor_component_svs::gen_entrypoint (void)
<< "}";
}
-void
-be_visitor_component_svs::gen_all_factory_registration (void)
-{
- for (UTL_ScopeActiveIterator si (node_, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
- AST_Type *port_type = 0;
-
- switch (d->node_type ())
- {
- case AST_Decl::NT_publishes:
- case AST_Decl::NT_emits:
- case AST_Decl::NT_consumes:
- port_type =
- AST_Field::narrow_from_decl (d)->field_type ();
- this->gen_one_factory_registration (port_type);
- break;
- default:
- break;
- }
- }
-}
-
-void
-be_visitor_component_svs::gen_one_factory_registration (AST_Type *t)
-{
- os_ << be_nl << be_nl
- << "TAO_OBV_REGISTER_FACTORY (" << be_idt_nl
- << "::" << t->full_name () << "_init," << be_nl
- << "::" << t->full_name () << ");" << be_uidt;
-}
-
-void
-be_visitor_component_svs::gen_swapping_get_consumers_r (
- AST_Component *node)
-{
- if (node == 0)
- {
- return;
- }
-
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- if (d->node_type () != AST_Decl::NT_publishes)
- {
- continue;
- }
-
- this->gen_swapping_get_comsumer_block (d->local_name ()->get_string ());
- }
-
- node = node->base_component ();
- this->gen_swapping_get_consumers_r (node);
-}
-
-void
-be_visitor_component_svs::gen_swapping_get_comsumer_block (
- const char * port_name)
-{
- bool static_config =
- be_global->gen_ciao_static_config ();
-
- os_ << be_nl << be_nl
- << "if (ACE_OS::strcmp (publisher_name, \""
- << port_name << "\") == 0)" << be_idt_nl
- << "{" << be_idt_nl
- << "_ciao_size = this->_ciao_publishes_"
- << port_name << "_.size ();" << be_nl << be_nl
- << "ACE_NEW_THROW_EX (tmp," << be_nl
- << " ::Components::"
- << "ConsumerDescriptions (_ciao_size)," << be_nl
- << " ::CORBA::NO_MEMORY ());";
-
- if (! static_config)
- {
- os_ << be_nl << be_nl
- << "{" << be_idt_nl
- << "ACE_READ_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
- << " mon," << be_nl
- << " this->" << port_name
- << "_lock_," << be_nl
- << " 0);";
- }
-
- os_ << be_nl << be_nl
- << "for (" << tao_cg->upcase (port_name)
- << "_TABLE::const_iterator iter =" << be_idt_nl
- << " this->ciao_publishes_" << port_name
- << "_.begin ();" << be_uidt_nl
- << " iter != this->ciao_publishes_" << port_name
- << ".end ();" << be_nl
- << " ++iter, ++_ciao_index)" << be_idt_nl
- << "{" << be_idt_nl
- << "if ( ::CORBA::is_nil (iter->second.in ()))" << be_idt_nl
- << "{" << be_idt_nl
- << "throw ::Components::InvalidConnection ();" << be_uidt_nl
- << "}" << be_uidt_nl << be_nl
- << "::Components::ConsumerDescription * cd = 0;" << be_nl
- << "ACE_NEW_THROW_EX (cd," << be_nl
- << " OBV_Components::ConsumerDescription,"
- << be_nl
- << " ::CORBA::NO_MEMORY ());"
- << be_nl << be_nl
- << "::Components::ConsumerDescription_var safe = cd;"
- << be_nl
- << "safe->name (\"\");" << be_nl
- << "safe->type_id (\"\");" << be_nl
- << "safe->consumer (iter->second.in ());"
- << be_nl << be_nl
- << "retval[_ciao_index] = safe;" << be_uidt_nl
- << "}" << be_uidt;
-
- if (! static_config)
- {
- os_ << be_uidt_nl
- << "}";
- }
-
- os_ << be_uidt_nl << be_nl
- << "return retval._retn ();" << be_uidt_nl
- << "}";
-}
-
-void
-be_visitor_component_svs::compute_slots (AST_Component *node)
-{
- while (node != 0)
- {
- for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
- !si.is_done ();
- si.next ())
- {
- AST_Decl *d = si.item ();
-
- switch (d->node_type ())
- {
- case AST_Decl::NT_provides:
- ++n_provides_;
- break;
- case AST_Decl::NT_uses:
- ++n_uses_;
- break;
- case AST_Decl::NT_publishes:
- ++n_publishes_;
- break;
- case AST_Decl::NT_emits:
- ++n_emits_;
- break;
- case AST_Decl::NT_consumes:
- ++n_consumes_;
- break;
- default:
- break;
- }
- }
-
- node = node->base_component ();
- }
-}
-
-Component_Op_Attr_Generator::Component_Op_Attr_Generator (
- be_visitor_scope * visitor)
- : visitor_ (visitor)
-{
-}
-
-int
-Component_Op_Attr_Generator::emit (be_interface * /* derived_interface */,
- TAO_OutStream * /* os */,
- be_interface * base_interface)
-{
- if (base_interface->node_type () == AST_Decl::NT_component)
- {
- return 0;
- }
-
- return visitor_->visit_scope (base_interface);
-}
-
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
index 688165f3566..ac7f0d795e9 100644
--- a/modules/TAO/TAO_IDL/be/be_visitor_component/context_svh.cpp
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/context_svh.cpp
@@ -108,7 +108,15 @@ be_visitor_context_svh::visit_component (be_component *node)
<< "// defined in " << global << sname
<< "::CCM_" << lname << "_Context.";
- this->gen_context_r (node);
+ if (this->gen_context_r (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_context_svh")
+ ACE_TEXT ("::visit_component - ")
+ ACE_TEXT ("gen_context_r() ")
+ ACE_TEXT ("failed\n")),
+ -1);
+ }
if (swapping_)
{
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/context_svs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/context_svs.cpp
new file mode 100644
index 00000000000..fac362541e8
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/context_svs.cpp
@@ -0,0 +1,816 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// context_svs.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for a context class in the
+// servant sourece.
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+be_visitor_context_svs::be_visitor_context_svs (be_visitor_context *ctx)
+ : be_visitor_scope (ctx),
+ node_ (0),
+ os_ (*ctx->stream ()),
+ swapping_ (be_global->gen_component_swapping ()),
+ static_config_ (be_global->gen_ciao_static_config ())
+{
+}
+
+be_visitor_context_svs::~be_visitor_context_svs (void)
+{
+}
+
+int
+be_visitor_context_svs::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 ();
+ const char *lname = node_->local_name ();
+ const char *global = (sname_str == "" ? "" : "::");
+
+ os_ << be_nl
+ << lname <<"_Context::" << lname << "_Context ("
+ << be_idt << be_idt_nl
+ << "::Components::CCMHome_ptr h," << be_nl
+ << "::CIAO::Container_ptr c," << be_nl
+ << lname << "_Servant * sv)" << be_uidt_nl
+ << ": ::CIAO::Context_Impl_Base (h, c)," << be_idt_nl
+ << "::CIAO::Context_Impl<" << be_idt_nl
+ << global << sname << "::CCM_"
+ << lname << "_Context," << be_nl
+ << lname << "_Servant," << be_nl
+ << "::" << node->full_name () << "> (h, c, sv)";
+
+ if (swapping_)
+ {
+ os_ << "," << be_uidt_nl
+ << "::CIAO::Upgradeable_Context_Impl<" << be_idt_nl
+ << global << sname << "::CCM_" << lname
+ << "_Context," << be_nl
+ << lname << "_Servant," << be_nl
+ << "::" << node_->full_name ()
+ << "> (h, c, sv)";
+ }
+
+ os_ << be_uidt << be_uidt << be_uidt_nl
+ << "{" << be_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << lname << "_Context::~"
+ << lname << "_Context (void)" << be_nl
+ << "{" << be_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "/// CIAO-specific." << be_nl
+ << lname << "_Context *" << be_nl
+ << lname
+ << "_Context::_narrow ( ::Components::SessionContext_ptr p)"
+ << be_nl
+ << "{" << be_idt_nl
+ << "return dynamic_cast<" << lname
+ << "_Context *> (p);" << be_uidt_nl
+ << "}";
+
+ if (this->gen_context_r (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_context_svs")
+ ACE_TEXT ("::visit_component - ")
+ ACE_TEXT ("gen_context_r() ")
+ ACE_TEXT ("failed\n")),
+ -1);
+ }
+
+ if (swapping_)
+ {
+ os_ << be_nl << be_nl
+ << "/// Operations defined in " << sname
+ << "::CCM_" << lname << "_Context" << be_nl
+ << "/// that enable component swapping in the container"
+ << be_nl << be_nl
+ << "::Components::ConsumerDescriptions *" << be_nl
+ << lname << "_Context::get_registered_consumers ("
+ << be_idt_nl
+ << "const char * publisher_name)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "if (publisher_name == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "::Components::ConsumerDescriptions * tmp = 0;"
+ << be_nl
+ << "::Components::ConsumerDescriptions_var retval;"
+ << be_nl
+ << "::CORBA::ULong _ciao_index = 0UL;" << be_nl
+ << "::CORBA::ULong _ciao_size = 0UL;" << be_nl
+ << "ACE_UNUSED_ARG (tmp);" << be_nl
+ << "ACE_UNUSED_ARG (retval);" << be_nl
+ << "ACE_UNUSED_ARG (_ciao_index);" << be_nl
+ << "ACE_UNUSED_ARG (_ciao_size);";
+
+ this->gen_swapping_get_consumers_r (node);
+
+ os_ << be_nl << be_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}";
+ }
+
+ return 0;
+}
+
+int
+be_visitor_context_svs::visit_uses (be_uses *node)
+{
+ AST_Type *obj = node->uses_type ();
+ const char *port_name = node->local_name ()->get_string ();
+ bool is_multiple = node->is_multiple ();
+
+ if (is_multiple)
+ {
+ this->gen_uses_multiplex (obj, port_name);
+ }
+ else
+ {
+ this->gen_uses_simplex (obj, port_name);
+ }
+
+ return 0;
+}
+
+int
+be_visitor_context_svs::visit_publishes (be_publishes *node)
+{
+ AST_Type *obj = node->publishes_type ();
+ const char *port_name =
+ node->local_name ()->get_string ();
+ const char *fname = obj->full_name ();
+ const char *lname = obj->local_name ()->get_string ();
+ ACE_CString sname_str (
+ ScopeAsDecl (obj->defined_in ())->full_name ());
+ const char *sname = sname_str.c_str ();
+ const char *global = (sname_str == "" ? "" : "::");
+
+ os_ << be_nl << be_nl
+ << "void" << be_nl
+ << node_->local_name () << "_Context::push_"
+ << port_name << " (" << be_idt_nl
+ << "::" << fname << " * ev)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (! static_config_)
+ {
+ os_ << "ACE_READ_GUARD (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->" << port_name
+ << "_lock_);" << be_nl << be_nl;
+ }
+
+ os_ << "for (" << tao_cg->upcase (port_name)
+ << "_TABLE::const_iterator iter =" << be_nl
+ << " this->ciao_publishes_" << port_name
+ << "_.begin ();" << be_nl
+ << " iter != this->ciao_publishes_" << port_name
+ << "_.end ();" << be_nl
+ << " ++iter)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "iter->second->push_" << lname << " (ev);"
+ << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "ACE_CString source_id (this->_ciao_instance_id ());"
+ << be_nl
+ << "source_id += \"_" << port_name << "\";"
+ << be_nl << be_nl
+ << "for (" << tao_cg->upcase (port_name)
+ << "_GENERIC_TABLE::const_iterator giter =" << be_nl
+ << " this->ciao_publishes_" << port_name
+ << "_generic_.begin ();" << be_nl
+ << " giter != this->ciao_publishes_"
+ << port_name << "_generic_.end ();" << be_nl
+ << " ++giter)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "giter->second->ciao_push_event (ev," << be_nl
+ << " source_id.c_str (),"
+ << be_nl
+ << " " << global
+ << sname << "::_tc_" << lname << ");" << be_uidt_nl
+ << "}" << be_uidt << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::Cookie *" << be_nl
+ << node_->local_name () << "_Context::subscribe_"
+ << port_name << " (" << be_idt_nl
+ << "::" << fname << "Consumer_ptr c)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "if ( ::CORBA::is_nil (c))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "std::pair<" << tao_cg->upcase (port_name)
+ << "_TABLE::iterator, bool> result;" << be_nl
+ << tao_cg->upcase (port_name)
+ << "_TABLE::value_type entry;" << be_nl
+ << "entry.first = reinterpret_cast<ptrdiff_t> (c);"
+ << be_nl
+ << "entry.second = ::" << fname
+ << "Consumer::_duplicate (c);" << be_nl << be_nl;
+
+ if (! static_config_)
+ {
+ os_ << "{" << be_idt_nl
+ << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->" << port_name
+ << "_lock_," << be_nl
+ << " 0);" << be_nl << be_nl;
+ }
+
+ os_ << "result = this->ciao_publishes_" << port_name
+ << "_.insert (entry);";
+
+ if (! static_config_)
+ {
+ os_ << be_uidt_nl
+ << "}";
+ }
+
+ os_ << be_nl << be_nl
+ << "if (! result.second)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "ACE_ERROR_RETURN ((LM_ERROR," << be_nl
+ << " ACE_TEXT (\"subscribe on %s failed\\n\"),"
+ << be_nl
+ << " ACE_TEXT (\"" << port_name
+ << "\"))," << be_nl
+ << " 0);" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "::Components::Cookie * retv = 0;" << be_nl
+ << "ACE_NEW_THROW_EX (retv," << be_nl
+ << " ::CIAO::Cookie_Impl (entry.first),"
+ << be_nl
+ << " ::CORBA::NO_MEMORY ());"
+ << be_nl << be_nl
+ << "return retv;" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::Cookie *" << be_nl
+ << node_->local_name () << "_Context::subscribe_"
+ << port_name << "_generic (" << be_idt_nl
+ << "::Components::EventConsumerBase_ptr c)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "if ( ::CORBA::is_nil (c))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "std::pair<" << tao_cg->upcase (port_name)
+ << "_GENERIC_TABLE::iterator, bool> result;" << be_nl
+ << tao_cg->upcase (port_name)
+ << "_GENERIC_TABLE::value_type entry;" << be_nl
+ << "entry.first = reinterpret_cast<ptrdiff_t> (c);"
+ << be_nl
+ << "entry.second =" << be_idt_nl
+ << "::Components::EventConsumerBase::_duplicate (c);"
+ << be_uidt_nl << be_nl;
+
+ if (! static_config_)
+ {
+ os_ << "{" << be_idt_nl
+ << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->" << port_name
+ << "_lock_," << be_nl
+ << " 0);" << be_nl << be_nl;
+ }
+
+ os_ << "result =" << be_idt_nl
+ << "this->ciao_publishes_" << port_name
+ << "_generic_.insert (entry);" << be_uidt;
+
+ if (! static_config_)
+ {
+ os_ << be_uidt_nl
+ << "}";
+ }
+
+ os_ << be_nl << be_nl
+ << "if (! result.second)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "ACE_ERROR_RETURN ((LM_ERROR," << be_nl
+ << " ACE_TEXT (\"generic subscribe \")"
+ << be_nl
+ << " ACE_TEXT (\"on %s failed\\n\"),"
+ << be_nl
+ << " ACE_TEXT (\"" << port_name
+ << "\"))," << be_nl
+ << " 0);" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "::Components::Cookie * retv = 0;" << be_nl
+ << "ACE_NEW_THROW_EX (retv," << be_nl
+ << " ::CIAO::Cookie_Impl (entry.first),"
+ << be_nl
+ << " ::CORBA::NO_MEMORY ());"
+ << be_nl << be_nl
+ << "return retv;" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::" << fname << "Consumer_ptr" << be_nl
+ << node_->local_name () << "_Context::unsubscribe_"
+ << port_name << " (" << be_idt_nl
+ << "::Components::Cookie * ck)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "ptrdiff_t key = 0UL;" << be_nl
+ << tao_cg->upcase (port_name)
+ << "_TABLE::size_type n = 0UL;" << be_nl << be_nl
+ << "if (ck == 0 || ! ::CIAO::Cookie_Impl::extract (ck, key))"
+ << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl;
+
+ if (! static_config_)
+ {
+ os_ << "{" << be_idt_nl
+ << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->" << port_name
+ << "_lock_," << be_nl
+ << " ::" << fname
+ << "Consumer::_nil ());" << be_nl << be_nl;
+ }
+
+ os_ << tao_cg->upcase (port_name) << "_TABLE::iterator iter ="
+ << be_idt_nl
+ << "this->ciao_publishes_" << port_name << "_.find (key);"
+ << be_uidt_nl << be_nl
+ << "if (iter != this->ciao_publishes_" << port_name
+ << "_.end ())" << be_idt_nl
+ << "{" << be_idt_nl
+ << "::" << fname
+ << "Consumer_var retv = iter->second;" << be_nl
+ << "n = this->ciao_publishes_" << port_name
+ << "_.erase (key);" << be_nl << be_nl
+ << "if (n == 1UL)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return retv._retn ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << tao_cg->upcase (port_name)
+ << "_GENERIC_TABLE::iterator giter =" << be_idt_nl
+ << "this->ciao_publishes_" << port_name
+ << "_generic_.find (key);" << be_uidt_nl << be_nl
+ << "if (giter == this->ciao_publishes_" << port_name
+ << "_generic_.end ())" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "n = this->ciao_publishes_" << port_name
+ << "_generic_.erase (key);";
+
+ if (! static_config_)
+ {
+ os_ << be_uidt_nl
+ << "}";
+ }
+
+ os_ << be_nl << be_nl
+ << "if (n != 1UL)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "return ::" << fname << "Consumer::_nil ();"
+ << be_uidt_nl
+ << "}";
+
+ return 0;
+}
+
+int
+be_visitor_context_svs::visit_emits (be_emits *node)
+{
+ AST_Type *obj = node->emits_type ();
+ const char *port_name =
+ node->local_name ()->get_string ();
+
+ const char *fname = obj->full_name ();
+ const char *lname = obj->local_name ()->get_string ();
+
+ os_ << be_nl << be_nl
+ << "void" << be_nl
+ << node_->local_name () << "_Context::push_" << port_name
+ << " (" << be_idt_nl
+ << "::" << fname << " * ev)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "if (! ::CORBA::is_nil (this->ciao_emits_"
+ << port_name << "_consumer_.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "this->ciao_emits_" << port_name << "_consumer_->push_"
+ << lname << " (ev);" << be_uidt_nl
+ << "}" << be_uidt << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "void" << be_nl
+ << node_->local_name () << "_Context::connect_" << port_name
+ << " (" << be_idt_nl
+ << "::" << fname << "Consumer_ptr c)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "if ( ::CORBA::is_nil (c))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "if (! ::CORBA::is_nil (this->ciao_emits_"
+ << port_name << "_consumer_.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::AlreadyConnected ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "this->ciao_emits_" << port_name
+ << "_consumer_ =" << be_idt_nl
+ << "::" << fname << "Consumer::_duplicate (c);"
+ << be_uidt << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::" << fname << "Consumer_ptr" << be_nl
+ << node_->local_name () << "_Context::disconnect_"
+ << port_name << " (void)" << be_nl
+ << "{" << be_idt_nl
+ << "if ( ::CORBA::is_nil (this->ciao_emits_"
+ << port_name << "_consumer_.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::NoConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "return this->ciao_emits_" << port_name
+ << "_consumer_._retn ();" << be_uidt_nl
+ << "}";
+
+ return 0;
+}
+
+int
+be_visitor_context_svs::visit_extended_port (be_extended_port *)
+{
+ return 0;
+}
+
+int
+be_visitor_context_svs::visit_mirror_port (be_mirror_port *)
+{
+ // TODO
+ return 0;
+}
+
+int
+be_visitor_context_svs::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_svs")
+ 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);
+}
+
+void
+be_visitor_context_svs::gen_swapping_get_consumers_r (
+ AST_Component *node)
+{
+ if (node == 0)
+ {
+ return;
+ }
+
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_publishes)
+ {
+ continue;
+ }
+
+ this->gen_swapping_get_consumer_block (
+ d->local_name ()->get_string ());
+ }
+
+ node = node->base_component ();
+ this->gen_swapping_get_consumers_r (node);
+}
+
+void
+be_visitor_context_svs::gen_swapping_get_consumer_block (
+ const char * port_name)
+{
+ os_ << be_nl << be_nl
+ << "if (ACE_OS::strcmp (publisher_name, \""
+ << port_name << "\") == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "_ciao_size = this->_ciao_publishes_"
+ << port_name << "_.size ();" << be_nl << be_nl
+ << "ACE_NEW_THROW_EX (tmp," << be_nl
+ << " ::Components::"
+ << "ConsumerDescriptions (_ciao_size)," << be_nl
+ << " ::CORBA::NO_MEMORY ());";
+
+ if (! static_config_)
+ {
+ os_ << be_nl << be_nl
+ << "{" << be_idt_nl
+ << "ACE_READ_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->" << port_name
+ << "_lock_," << be_nl
+ << " 0);";
+ }
+
+ os_ << be_nl << be_nl
+ << "for (" << tao_cg->upcase (port_name)
+ << "_TABLE::const_iterator iter =" << be_idt_nl
+ << " this->ciao_publishes_" << port_name
+ << "_.begin ();" << be_uidt_nl
+ << " iter != this->ciao_publishes_" << port_name
+ << ".end ();" << be_nl
+ << " ++iter, ++_ciao_index)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "if ( ::CORBA::is_nil (iter->second.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "::Components::ConsumerDescription * cd = 0;" << be_nl
+ << "ACE_NEW_THROW_EX (cd," << be_nl
+ << " OBV_Components::ConsumerDescription,"
+ << be_nl
+ << " ::CORBA::NO_MEMORY ());"
+ << be_nl << be_nl
+ << "::Components::ConsumerDescription_var safe = cd;"
+ << be_nl
+ << "safe->name (\"\");" << be_nl
+ << "safe->type_id (\"\");" << be_nl
+ << "safe->consumer (iter->second.in ());"
+ << be_nl << be_nl
+ << "retval[_ciao_index] = safe;" << be_uidt_nl
+ << "}" << be_uidt;
+
+ if (! static_config_)
+ {
+ os_ << be_uidt_nl
+ << "}";
+ }
+
+ os_ << be_uidt_nl << be_nl
+ << "return retval._retn ();" << be_uidt_nl
+ << "}";
+}
+
+void
+be_visitor_context_svs::gen_uses_simplex (
+ AST_Type *obj,
+ const char *port_name)
+{
+ const char *fname = obj->full_name ();
+
+ os_ << be_nl << be_nl
+ << "::" << fname << "_ptr" << be_nl
+ << node_->local_name () << "_Context::get_connection_"
+ << port_name << " (void)" << be_nl
+ << "{" << be_idt_nl
+ << "return ::" << fname << "::_duplicate (" << be_idt_nl
+ << "this->ciao_uses_" << port_name << "_.in ());"
+ << be_uidt << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "void" << be_nl
+ << node_->local_name () << "_Context::connect_"
+ << port_name << " (" << be_idt_nl
+ << "::" << fname << "_ptr c)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "if (! ::CORBA::is_nil (this->ciao_uses_"
+ << port_name << "_.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::AlreadyConnected ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "if ( ::CORBA::is_nil (c))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "this->ciao_uses_" << port_name << "_ =" << be_idt_nl
+ << "::" << fname << "::_duplicate (c);"
+ << be_uidt << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::" << fname << "_ptr" << be_nl
+ << node_->local_name () << "_Context::disconnect_"
+ << port_name << " (void)" << be_nl
+ << "{" << be_idt_nl
+ << "if ( ::CORBA::is_nil (this->ciao_uses_"
+ << port_name << "_.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::NoConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "return this->ciao_uses_" << port_name
+ << "_._retn ();" << be_uidt_nl
+ << "}";
+}
+
+void
+be_visitor_context_svs::gen_uses_multiplex (
+ AST_Type *obj,
+ const char *port_name)
+{
+ const char *fname = obj->full_name ();
+ bool static_config = be_global->gen_ciao_static_config ();
+
+ os_ << be_nl << be_nl
+ << "::" << node_->full_name () << "::" << port_name
+ << "Connections *" << be_nl
+ << node_->local_name () << "_Context::get_connections_"
+ << port_name << " (void)" << be_nl
+ << "{" << be_idt_nl;
+
+ if (! static_config)
+ {
+ os_ << "ACE_READ_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->" << port_name
+ << "_lock_," << be_nl
+ << " 0);" << be_nl << be_nl;
+ }
+
+ os_ << "::" << node_->full_name () << "::" << port_name
+ << "Connections * tmp_retv = 0;" << be_nl
+ << "ACE_NEW_THROW_EX (tmp_retv," << be_nl
+ << " ::" << node_->full_name ()
+ << "::" << port_name << "Connections (" << be_nl
+ << " this->ciao_uses_"
+ << port_name << "_.size ())," << be_nl
+ << " ::CORBA::NO_MEMORY ());"
+ << be_nl << be_nl
+ << "::" << node_->full_name () << "::" << port_name
+ << "Connections_var retv = tmp_retv;" << be_nl
+ << "retv->length (this->ciao_uses_" << port_name
+ << "_.size ());" << be_nl
+ << "::CORBA::ULong i = 0UL;" << be_nl << be_nl
+ << "for (" << tao_cg->upcase (port_name)
+ << "_TABLE::const_iterator iter =" << be_nl
+ << " this->ciao_uses_" << port_name << "_.begin ();"
+ << be_nl
+ << " iter != this->ciao_uses_"
+ << port_name << "_.end ();" << be_nl
+ << " ++iter, ++i)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "retv[i].objref = iter->second;" << be_nl << be_nl
+ << "ACE_NEW_THROW_EX (retv[i].ck.inout ()," << be_nl
+ << " ::CIAO::Cookie_Impl (iter->first),"
+ << be_nl
+ << " ::CORBA::NO_MEMORY ());" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "return retv._retn (); " << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::Cookie *" << be_nl
+ << node_->local_name () << "_Context::connect_"
+ << port_name << " (" << be_idt_nl
+ << "::" << fname << "_ptr c)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "if ( ::CORBA::is_nil (c))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "std::pair<" << tao_cg->upcase (port_name)
+ << "_TABLE::iterator, bool> result;" << be_nl
+ << tao_cg->upcase (port_name)
+ << "_TABLE::value_type entry;" << be_nl
+ << "entry.first = reinterpret_cast<ptrdiff_t> (c);" << be_nl
+ << "entry.second = ::" << fname
+ << "::_duplicate (c);";
+
+ if (! static_config)
+ {
+ os_ << be_nl << be_nl
+ << "{" << be_idt_nl
+ << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->" << port_name
+ << "_lock_," << be_nl
+ << " 0);";
+ }
+
+ os_ << be_nl << be_nl
+ << "result = this->ciao_uses_" << port_name
+ << "_.insert (entry);";
+
+ if (! static_config)
+ {
+ os_ << be_uidt_nl
+ << "}";
+ }
+
+ os_ << be_nl << be_nl
+ << "if (! result.second)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();"
+ << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "::Components::Cookie * ck = 0;" << be_nl
+ << "ACE_NEW_THROW_EX (ck," << be_nl
+ << " ::CIAO::Cookie_Impl (entry.first),"
+ << be_nl
+ << " ::CORBA::NO_MEMORY ());"
+ << be_nl << be_nl
+ << "return ck;" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::" << fname << "_ptr" << be_nl
+ << node_->local_name () << "_Context::disconnect_"
+ << port_name << " (" << be_idt_nl
+ << "::Components::Cookie * ck)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "::" << fname << "_var retv;" << be_nl
+ << "ptrdiff_t key = 0UL;" << be_nl
+ << tao_cg->upcase (port_name)
+ << "_TABLE::size_type n = 0UL;" << be_nl << be_nl
+ << "if (ck == 0 || ! ::CIAO::Cookie_Impl::extract (ck, key))"
+ << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt;
+
+ if (! static_config)
+ {
+ os_ << be_nl << be_nl
+ << "{" << be_idt_nl
+ << "ACE_WRITE_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->" << port_name
+ << "_lock_," << be_nl
+ << " ::" << fname
+ << "::_nil ());";
+ }
+
+ os_ << be_nl << be_nl
+ << tao_cg->upcase (port_name)
+ << "_TABLE::iterator iter =" << be_idt_nl
+ << "this->ciao_uses_" << port_name
+ << "_.find (key);" << be_uidt_nl << be_nl
+ << "if (iter == this->ciao_uses_" << port_name
+ << "_.end ())" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "retv = iter->second;" << be_nl
+ << "n = this->ciao_uses_" << port_name
+ << "_.erase (key);";
+
+ if (! static_config)
+ {
+ os_ << be_uidt_nl
+ << "}";
+ }
+
+ os_ << be_nl << be_nl
+ << "if (n != 1UL)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "return retv._retn ();" << be_uidt_nl
+ << "}";
+}
+
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
index e13f9402e70..2f9146fed1b 100644
--- a/modules/TAO/TAO_IDL/be/be_visitor_component/facet_svh.cpp
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_svh.cpp
@@ -73,7 +73,7 @@ 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);
}
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/facet_svs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_svs.cpp
new file mode 100644
index 00000000000..f1208567eaa
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_svs.cpp
@@ -0,0 +1,77 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// facet_svs.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for a facet servant class in the
+// servant source.
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+be_visitor_facet_svs::be_visitor_facet_svs (be_visitor_context *ctx)
+ : be_visitor_scope (ctx),
+ os_ (*ctx->stream ())
+{
+}
+
+be_visitor_facet_svs::~be_visitor_facet_svs (void)
+{
+}
+
+int
+be_visitor_facet_svs::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_svs::visit_provides (be_provides *node)
+{
+ if (node->gen_facet_svnt_defn (os_) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_facet_svs")
+ ACE_TEXT ("::visit_provides - ")
+ ACE_TEXT ("gen_facet_svnt_defn() ")
+ ACE_TEXT ("failed\n")),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+be_visitor_facet_svs::visit_extended_port (be_extended_port *node)
+{
+ be_visitor_extended_port_facet_svs visitor (this->ctx_);
+
+ return visitor.visit_extended_port (node);
+}
+
+int
+be_visitor_facet_svs::visit_mirror_port (be_mirror_port *)
+{
+ // TODO
+ return 0;
+}
+
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svs.cpp
new file mode 100644
index 00000000000..cd72435b444
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svs.cpp
@@ -0,0 +1,1727 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// servant_svs.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for a servant class in the
+// servant source file.
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+be_visitor_servant_svs::be_visitor_servant_svs (be_visitor_context *ctx)
+ : be_visitor_scope (ctx),
+ node_ (0),
+ op_scope_ (0),
+ os_ (*ctx->stream ()),
+ export_macro_ (be_global->svnt_export_macro ()),
+ swapping_ (be_global->gen_component_swapping ()),
+ n_provides_ (0UL),
+ n_uses_ (0UL),
+ n_publishes_ (0UL),
+ n_emits_ (0UL),
+ n_consumes_ (0UL)
+{
+ /// 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_svs::~be_visitor_servant_svs (void)
+{
+}
+
+int
+be_visitor_servant_svs::visit_component (be_component *node)
+{
+ node_ = node;
+
+ n_provides_ = 0UL;
+ n_uses_ = 0UL;
+ n_publishes_ = 0UL;
+ n_emits_ = 0UL;
+ n_consumes_ = 0UL;
+
+ this->compute_slots (node_);
+
+ AST_Decl *scope = ScopeAsDecl (node_->defined_in ());
+ ACE_CString sname_str (scope->full_name ());
+ const char *sname = sname_str.c_str ();
+ const char *lname = node->local_name ();
+ const char *global = (sname_str == "" ? "" : "::");
+
+ os_ << be_nl << be_nl
+ << lname << "_Servant::"
+ << lname << "_Servant (" << be_idt << be_idt_nl
+ << global << sname << "::CCM_" << lname
+ << "_ptr exe," << 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
+ << ": ::CIAO::Servant_Impl_Base (h, hs, c),"
+ << be_idt_nl
+ << "::CIAO::Servant_Impl<" << be_idt_nl
+ << "::" << node_->full_skel_name ()
+ << "," << be_nl
+ << global << sname << "::CCM_"
+ << lname << "," << be_nl
+ << lname << "_Context> (exe, h, hs, c)," << be_uidt_nl
+ << "ins_name_ (ins_name)" << be_uidt << be_uidt_nl
+ << "{" << be_idt_nl
+ << "ACE_NEW (this->context_," << be_nl
+ << " " << lname << "_Context (h, c, this));"
+ << be_nl << be_nl
+ << "/// Set the instance id of the component on the context."
+ << be_nl
+ << "this->context_->_ciao_instance_id (this->ins_name_);";
+
+ if (be_global->gen_ciao_valuefactory_reg ())
+ {
+ this->gen_obv_factory_registration_r (node);
+ }
+
+ os_ << be_nl << be_nl
+ << "try" << be_idt_nl
+ << "{" << be_idt_nl
+ << "::Components::SessionComponent_var scom =" << be_idt_nl
+ << "::Components::SessionComponent::_narrow (exe);"
+ << be_uidt_nl << be_nl
+ << "if (! ::CORBA::is_nil (scom.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "scom->set_session_context (this->context_);" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "this->populate_port_tables ();" << be_uidt_nl
+ << "}" << be_uidt_nl
+ << "catch (const ::CORBA::Exception &)" << be_idt_nl
+ << "{" << be_nl
+ << "}" << be_uidt << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << lname << "_Servant::~"
+ << lname << "_Servant (void)" << be_nl
+ << "{" << be_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "void" << be_nl
+ << lname << "_Servant::set_attributes (" << be_idt_nl
+ << "const ::Components::ConfigValues & descr)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl << be_nl;
+ }
+
+ os_ << "for ( ::CORBA::ULong i = 0; i < descr.length (); ++i)"
+ << be_idt_nl
+ << "{" << be_idt_nl
+ << "const char * descr_name = descr[i]->name ();" << be_nl
+ << "::CORBA::Any & descr_value = descr[i]->value ();";
+
+ this->gen_attr_set_r (node_);
+
+ os_ << be_nl << be_nl
+ << "ACE_UNUSED_ARG (descr_name);" << be_nl
+ << "ACE_UNUSED_ARG (descr_value);" << be_uidt_nl
+ << "}" << be_uidt << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "/// Supported operations and attributes.";
+
+ this->op_scope_ = node;
+
+ /// The overload of traverse_inheritance_graph() used here
+ /// doesn't automatically prime the queues.
+ node_->get_insert_queue ().reset ();
+ node_->get_del_queue ().reset ();
+ node_->get_insert_queue ().enqueue_tail (node);
+
+ Component_Op_Attr_Generator op_attr_gen (this);
+
+ int status =
+ node->traverse_inheritance_graph (op_attr_gen,
+ &os_,
+ false,
+ false);
+
+ if (status == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_component_svs::"
+ "visit_component - "
+ "inheritance graph traversal failed\n"),
+ -1);
+ }
+
+ os_ << be_nl << be_nl
+ << "/// All ports and component attributes.";
+
+ // Port operations that require scope traversal to get all the
+ // possible string name matches.
+ this->gen_provides_top ();
+ this->gen_uses_top ();
+ this->gen_publishes_top ();
+ this->gen_emits_top ();
+
+ // This call will generate all other operations and attributes,
+ // including inherited ones.
+ if (this->gen_servant_r (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_component_svs::"
+ "visit_component - "
+ "gen_servant_r() failed\n"),
+ -1);
+ }
+
+ os_ << be_nl << be_nl
+ << "/// Private method to trigger population of the port"
+ << be_nl
+ << "/// tables (facets and event consumers)." << be_nl
+ << "void" << be_nl
+ << node_->local_name ()
+ << "_Servant::populate_port_tables (void)" << be_nl
+ << "{" << be_idt_nl
+ << "::CORBA::Object_var obj_var;" << be_nl
+ << "::Components::EventConsumerBase_var ecb_var;"
+ << be_nl;
+
+ this->gen_populate_r (node);
+
+ os_ << be_uidt_nl
+ << "}";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svs::visit_operation (be_operation *node)
+{
+ AST_Decl::NodeType nt =
+ ScopeAsDecl (node->defined_in ())->node_type ();
+
+ // Components have implied IDL operations added to the AST, but
+ // we are interested only in supported interface operations.
+ if (nt == AST_Decl::NT_component)
+ {
+ return 0;
+ }
+
+ be_visitor_operation_svs v (this->ctx_);
+ v.for_facets (false);
+ v.scope (this->op_scope_);
+
+ return v.visit_operation (node);
+}
+
+int
+be_visitor_servant_svs::visit_attribute (be_attribute *node)
+{
+ be_visitor_attribute v (this->ctx_);
+
+ v.for_facets (false);
+ v.op_scope (this->op_scope_);
+
+ return v.visit_attribute (node);
+}
+
+int
+be_visitor_servant_svs::visit_provides (be_provides *node)
+{
+ AST_Type *obj = node->provides_type ();
+ const char *obj_name = obj->full_name ();
+ const char *port_name = node->local_name ()->get_string ();
+ AST_Decl *scope = ScopeAsDecl (obj->defined_in ());
+ ACE_CString sname_str (scope->full_name ());
+ const char *sname = sname_str.c_str ();
+
+ // Avoid '_cxx_' prefix.
+ const char *lname =
+ obj->original_local_name ()->get_string ();
+
+ const char *global = (sname_str == "" ? "" : "::");
+ const char *prefix_connector = (sname_str == "" ? "" : "_");
+
+ os_ << be_nl << be_nl
+ << "::" << obj_name << "_ptr" << be_nl
+ << node_->local_name () << "_Servant::provide_"
+ << port_name << " (void)" << be_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl << be_nl;
+ }
+
+ os_ << "if ( ::CORBA::is_nil (this->provide_"
+ << port_name << "_.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "::CORBA::Object_var obj =" << be_idt_nl
+ << "this->provide_" << port_name << "_i ();"
+ << be_uidt_nl << be_nl
+ << "::" << obj_name << "_var fo =" << be_idt_nl
+ << "::" << obj_name << "::_narrow (obj.in ());"
+ << be_uidt_nl << be_nl
+ << "this->provide_" << port_name << "_ = fo;" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "return" << be_idt_nl
+ << "::" << obj_name << "::_duplicate (this->provide_"
+ << port_name << "_.in ());" << be_uidt << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::CORBA::Object_ptr" << be_nl
+ << node_->local_name () << "_Servant::provide_"
+ << port_name << "_i (void)" << be_nl
+ << "{" << be_idt_nl
+ << "::CORBA::Object_ptr ret =" << be_idt_nl
+ << "this->lookup_facet (\"" << port_name << "\");"
+ << be_uidt_nl << be_nl
+ << "if (! ::CORBA::is_nil (ret))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return ret;" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "typedef" << be_idt_nl
+ << "::CIAO::Port_Activator_T<" << be_idt_nl
+ << "::CIAO_FACET" << prefix_connector
+ << scope->flat_name () << "::" << lname
+ << "_Servant," << be_nl
+ << global << sname << "::CCM_" << lname << "," << be_nl
+ << "::Components::CCMContext," << be_nl
+ << node_->local_name () << "_Servant>" << be_uidt_nl
+ << "MACRO_MADNESS_TYPEDEF;" << be_uidt_nl << be_nl
+ << "MACRO_MADNESS_TYPEDEF * tmp = 0;" << be_nl
+ << "ACE_CString obj_id (this->ins_name_);" << be_nl
+ << "obj_id += \"_" << port_name << "\";" << be_nl << be_nl
+ << "ACE_NEW_THROW_EX (" << be_idt_nl
+ << "tmp," << be_nl
+ << "MACRO_MADNESS_TYPEDEF (" << be_idt_nl
+ << "obj_id.c_str ()," << be_nl
+ << "\"" << port_name << "\"," << be_nl
+ << "::CIAO::Port_Activator_Types::FACET," << be_nl
+ << "0," << be_nl
+ << "this->context_," << be_nl
+ << "this)," << be_uidt_nl
+ << "::CORBA::NO_MEMORY ());" << be_uidt_nl << be_nl
+ << "::CIAO::Port_Activator_var pa = tmp;" << be_nl << be_nl
+ << "::CIAO::Servant_Activator_var sa =" << be_idt_nl
+ << "this->container_->ports_servant_activator ();"
+ << be_uidt_nl << be_nl
+ << "if (! sa->register_port_activator (pa._retn ()))"
+ << be_idt_nl
+ << "{" << be_idt_nl
+ << "return ::" << obj_name << "::_nil ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "::CORBA::Object_var obj =" << be_idt_nl
+ << "this->container_->generate_reference (" << be_idt_nl
+ << "obj_id.c_str ()," << be_nl
+ << "\"" << obj->repoID () << "\"," << be_nl
+ << "::CIAO::Container_Types::FACET_CONSUMER_t);"
+ << be_uidt_nl << be_uidt_nl
+ << "this->add_facet (\"" << port_name << "\", obj.in ());"
+ << be_nl << be_nl
+ << "return obj._retn ();" << be_uidt_nl
+ << "}";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svs::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_nl << be_nl
+ << (is_multiple ? "::Components::Cookie *" : "void")
+ << be_nl
+ << node_->local_name () << "_Servant::connect_"
+ << port_name << " (" << be_idt_nl
+ << "::" << obj_name << "_ptr c)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (is_multiple)
+ {
+ os_ << "::Components::Cookie * cookie =" << be_idt_nl;
+ }
+
+ os_ << "this->context_->connect_" << port_name
+ << " (c);" << be_nl;
+
+ if (is_multiple)
+ {
+ os_ << be_uidt_nl;
+ }
+
+ os_ << "this->add_receptacle (\"" << port_name
+ << "\", c, " << (is_multiple ? "cookie" : "0")
+ << ");";
+
+ if (is_multiple)
+ {
+ os_ << be_nl << be_nl
+ << "return cookie;";
+ }
+
+ os_ << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::" << obj_name << "_ptr" << be_nl
+ << node_->local_name () << "_Servant::disconnect_"
+ << port_name << " (";
+
+ if (is_multiple)
+ {
+ os_ << be_idt_nl
+ << "::Components::Cookie * ck" << be_uidt;
+ }
+ else
+ {
+ os_ << "void";
+ }
+
+ os_ << ")" << be_nl
+ << "{" << be_idt_nl
+ << "return this->context_->disconnect_"
+ << port_name << " (" << (is_multiple ? "ck" : "")
+ << ");" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::";
+
+ if (is_multiple)
+ {
+ os_ << node_->full_name () << "::" << port_name
+ << "Connections *";
+ }
+ else
+ {
+ os_ << obj_name << "_ptr";
+ }
+
+ os_ << be_nl
+ << node_->local_name () << "_Servant::get_connection"
+ << (is_multiple ? "s" : "") << "_"
+ << port_name << " (void)" << be_nl
+ << "{" << be_idt_nl
+ << "return this->context_->get_connection"
+ << (is_multiple ? "s" : "") << "_"
+ << port_name << " ();" << be_uidt_nl
+ << "}";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svs::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_nl << be_nl
+ << "::Components::Cookie *" << be_nl
+ << node_->local_name () << "_Servant::subscribe_"
+ << port_name << " (" << be_idt_nl
+ << "::" << obj_name << "Consumer_ptr c)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl;
+ }
+
+ os_ << "return this->context_->subscribe_" << port_name
+ << " (c);" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::Cookie *" << be_nl
+ << node_->local_name () << "_Servant::subscribe_"
+ << port_name << "_generic (" << be_idt_nl
+ << "::Components::EventConsumerBase_ptr c)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl;
+ }
+
+ os_ << "return this->context_->subscribe_" << port_name
+ << "_generic (c);" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::" << obj_name << "Consumer_ptr" << be_nl
+ << node_->local_name () << "_Servant::unsubscribe_"
+ << port_name << " (" << be_idt_nl
+ << "::Components::Cookie * ck)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl;
+ }
+
+ os_ << "return this->context_->unsubscribe_" << port_name
+ << " (ck);" << be_uidt_nl
+ << "}";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svs::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
+ << "void" << be_nl
+ << node_->local_name () << "_Servant::connect_"
+ << port_name << " (" << be_idt_nl
+ << "::" << obj_name << "Consumer_ptr c)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "this->context_->connect_" << port_name
+ << " (c);" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::" << obj_name << "Consumer_ptr" << be_nl
+ << node_->local_name () << "_Servant::disconnect_"
+ << port_name << " (void)" << be_nl
+ << "{" << be_idt_nl
+ << "return this->context_->disconnect_"
+ << port_name << " ();" << be_uidt_nl
+ << "}";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svs::visit_consumes (be_consumes *node)
+{
+ AST_Type *obj = node->consumes_type ();
+ const char *port_name = node->local_name ()->get_string ();
+
+ const char *comp_lname = node_->local_name ();
+ ACE_CString comp_sname_str (
+ ScopeAsDecl (node_->defined_in ())->full_name ());
+ const char *comp_sname = comp_sname_str.c_str ();
+ const char *global = (comp_sname_str == "" ? "" : "::");
+
+ const char *lname = obj->local_name ()->get_string ();
+ const char *fname = obj->full_name ();
+
+ os_ << be_nl << be_nl
+ << comp_lname << "_Servant::" << lname << "Consumer_"
+ << port_name << "_Servant::" << lname << "Consumer_"
+ << port_name << "_Servant (" << be_idt << be_idt_nl
+ << global << comp_sname << "::CCM_" << comp_lname
+ << "_ptr executor," << be_nl
+ << global << comp_sname << "::CCM_" << comp_lname
+ << "_Context_ptr c)" << be_uidt_nl
+ << ": executor_ ( " << global << comp_sname << "::CCM_"
+ << comp_lname << "::_duplicate (executor))," << be_idt_nl
+ << "ctx_ ( " << global << comp_sname
+ << "::CCM_" << comp_lname
+ << "_Context::_duplicate (c))" << be_uidt << be_uidt_nl
+ << "{" << be_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << comp_lname << "_Servant::" << lname << "Consumer_"
+ << port_name << "_Servant::~" << lname << "Consumer_"
+ << port_name << "_Servant (void)" << be_nl
+ << "{" << be_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::CORBA::Object_ptr" << be_nl
+ << comp_lname << "_Servant::" << lname << "Consumer_"
+ << port_name << "_Servant::_get_component (void)" << be_nl
+ << "{" << be_idt_nl
+ << "return this->ctx_->get_CCM_object ();" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "void" << be_nl
+ << comp_lname << "_Servant::" << lname << "Consumer_"
+ << port_name << "_Servant::push_" << lname
+ << " (" << be_idt_nl
+ << "::" << fname << " * evt)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "this->executor_->push_" << port_name
+ << " (evt);" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "/// Inherited from ::Components::EventConsumerBase."
+ << be_nl
+ << "void" << be_nl
+ << comp_lname << "_Servant::" << lname << "Consumer_"
+ << port_name << "_Servant::push_event (" << be_idt_nl
+ << "::Components::EventBase * ev)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "::" << fname << " * ev_type =" << be_idt_nl
+ << "::" << fname << "::_downcast (ev);"
+ << be_uidt_nl << be_nl
+ << "if (ev_type != 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "this->push_" << lname << " (ev_type);" << be_nl
+ << "return;" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "throw ::Components::BadEventType ();" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "/// CIAO-specific."
+ << be_nl
+ << "void" << be_nl
+ << comp_lname << "_Servant::" << lname << "Consumer_"
+ << port_name << "_Servant::ciao_push_event (" << be_idt_nl
+ << "::Components::EventBase * ev," << be_nl
+ << "const char * /* source_id */," << be_nl
+ << "::CORBA::TypeCode_ptr /* tc */)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "this->push_event (ev);" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "/// CIAO-specific."
+ << be_nl
+ << "::CORBA::Boolean" << be_nl
+ << comp_lname << "_Servant::" << lname << "Consumer_"
+ << port_name << "_Servant::ciao_is_substitutable ("
+ << be_idt_nl
+ << "const char * event_repo_id)" << be_uidt_nl
+ << "{" << be_idt_nl
+ << "if (event_repo_id == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "CORBA::ORB_ptr orb = TAO_ORB_Core_instance ()->orb ();"
+ << be_nl << be_nl
+ << "CORBA::ValueFactory f =" << be_idt_nl
+ << "orb->lookup_value_factory (event_repo_id);"
+ << be_uidt_nl << be_nl
+ << "if (f == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return false;" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "CORBA::ValueBase_var v = f->create_for_unmarshal ();"
+ << be_nl
+ << "f->_remove_ref ();" << be_nl << be_nl
+ << "if (v.in () == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return false;" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "return dynamic_cast< ::" << fname
+ << " *> (v.in ()) != 0;" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::" << fname << "Consumer_ptr" << be_nl
+ << node_->local_name () << "_Servant::get_consumer_"
+ << port_name << " (void)" << be_nl
+ << "{" << be_idt_nl
+ << "if (! ::CORBA::is_nil (this->consumes_" << port_name
+ << "_.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return ::" << fname
+ << "Consumer::_duplicate (this->consumes_"
+ << port_name << "_.in ());" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "::Components::EventConsumerBase_var obj =" << be_idt_nl
+ << "this->get_consumer_" << port_name << "_i ();"
+ << be_uidt_nl << be_nl
+ << "::" << fname << "Consumer_var eco =" << be_idt_nl
+ << "::" << fname << "Consumer::_narrow (obj.in ());"
+ << be_uidt_nl << be_nl
+ << "this->consumes_" << port_name << "_ = eco;" << be_nl
+ << "return" << be_idt_nl
+ << "::" << fname << "Consumer::_duplicate (" << be_idt_nl
+ << "this->consumes_" << port_name << "_.in ());"
+ << be_uidt << be_uidt << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::EventConsumerBase_ptr" << be_nl
+ << node_->local_name () << "_Servant::get_consumer_"
+ << port_name << "_i (void)" << be_nl
+ << "{" << be_idt_nl
+ << "::Components::EventConsumerBase_ptr ret =" << be_idt_nl
+ << "this->lookup_consumer (\"" << port_name << "\");"
+ << be_uidt_nl << be_nl
+ << "if (! ::CORBA::is_nil (ret))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return ret;" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "typedef" << be_idt_nl
+ << "::CIAO::Port_Activator_T<" << be_idt_nl
+ << node_->local_name () << "_Servant::" << lname
+ << "Consumer_" << port_name << "_Servant," << be_nl
+ << global << comp_sname << "::CCM_" << comp_lname
+ << "," << be_nl
+ << global << comp_sname << "::CCM_" << comp_lname
+ << "_Context," << be_nl
+ << node_->local_name () << "_Servant>" << be_uidt_nl
+ << "MACRO_MADNESS_TYPEDEF;" << be_uidt_nl << be_nl
+ << "MACRO_MADNESS_TYPEDEF * tmp = 0;" << be_nl
+ << "ACE_CString obj_id (this->ins_name_);" << be_nl
+ << "obj_id += \"_" << port_name << "\";" << be_nl << be_nl
+ << "ACE_NEW_THROW_EX (" << be_idt_nl
+ << "tmp," << be_nl
+ << "MACRO_MADNESS_TYPEDEF (" << be_idt_nl
+ << "obj_id.c_str ()," << be_nl
+ << "\"" << port_name << "\"," << be_nl
+ << "::CIAO::Port_Activator_Types::SINK," << be_nl
+ << "this->executor_.in ()," << be_nl
+ << "this->context_," << be_nl
+ << "this)," << be_uidt_nl
+ << "::CORBA::NO_MEMORY ());" << be_uidt_nl << be_nl
+ << "::CIAO::Port_Activator_var pa = tmp;" << be_nl << be_nl
+ << "::CIAO::Servant_Activator_var sa =" << be_idt_nl
+ << "this->container_->ports_servant_activator ();"
+ << be_uidt_nl << be_nl
+ << "if (! sa->register_port_activator (tmp))"
+ << be_idt_nl
+ << "{" << be_idt_nl
+ << "return ::" << fname << "Consumer::_nil ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "::CORBA::Object_var obj =" << be_idt_nl
+ << "this->container_->generate_reference (" << be_idt_nl
+ << "obj_id.c_str ()," << be_nl
+ << "\"";
+
+ ACE_CString work (obj->repoID ());
+ ACE_CString result (work.substr (0, work.rfind (':')));
+ result += "Consumer:1.0";
+
+ os_ << result.c_str ();
+
+ os_ << "\"," << be_nl
+ << "::CIAO::Container_Types::FACET_CONSUMER_t);"
+ << be_uidt_nl << be_uidt_nl
+ << "::Components::EventConsumerBase_var ecb =" << be_idt_nl
+ << "::Components::EventConsumerBase::_narrow (obj.in ());"
+ << be_uidt_nl << be_nl
+ << "this->add_consumer (\"" << port_name << "\", ecb.in ());"
+ << be_nl << be_nl
+ << "return ecb._retn ();" << be_uidt_nl
+ << "}";
+
+ return 0;
+}
+
+int
+be_visitor_servant_svs::visit_extended_port (be_extended_port *)
+{
+ return 0;
+}
+
+int
+be_visitor_servant_svs::visit_mirror_port (be_mirror_port *)
+{
+ // TODO
+ return 0;
+}
+
+int
+be_visitor_servant_svs::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_svs")
+ 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_svs::gen_obv_factory_registration_r (
+ AST_Component *node)
+{
+ if (node == 0)
+ {
+ return;
+ }
+
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+ AST_Type *port_type = 0;
+
+ switch (d->node_type ())
+ {
+ case AST_Decl::NT_publishes:
+ case AST_Decl::NT_emits:
+ case AST_Decl::NT_consumes:
+ port_type =
+ AST_Field::narrow_from_decl (d)->field_type ();
+ this->gen_obv_factory_registration (port_type);
+ break;
+ default:
+ break;
+ }
+ }
+
+ node = node->base_component ();
+ this->gen_obv_factory_registration_r (node);
+}
+
+void
+be_visitor_servant_svs::gen_obv_factory_registration (AST_Type *t)
+{
+ if (be_global->gen_ciao_valuefactory_reg ())
+ {
+ const char *fname = t->full_name ();
+
+ os_ << be_nl << be_nl
+ << "TAO_OBV_REGISTER_FACTORY (" << be_idt_nl
+ << "::" << fname << "_init," << be_nl
+ << "::" << fname << ");" << be_uidt;
+ }
+}
+
+void
+be_visitor_servant_svs::compute_slots (AST_Component *node)
+{
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ switch (d->node_type ())
+ {
+ case AST_Decl::NT_provides:
+ ++n_provides_;
+ break;
+ case AST_Decl::NT_uses:
+ ++n_uses_;
+ break;
+ case AST_Decl::NT_publishes:
+ ++n_publishes_;
+ break;
+ case AST_Decl::NT_emits:
+ ++n_emits_;
+ break;
+ case AST_Decl::NT_consumes:
+ ++n_consumes_;
+ break;
+ default:
+ break;
+ }
+ }
+
+ node = node->base_component ();
+ }
+}
+
+int
+be_visitor_servant_svs::gen_attr_set_r (AST_Component *node)
+{
+ if (node == 0)
+ {
+ return 0;
+ }
+
+ for (UTL_ScopeActiveIterator si (node, 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_attr)
+ {
+ be_attribute *attr =
+ be_attribute::narrow_from_decl (d);
+
+ be_visitor_attribute_component_init v (this->ctx_);
+
+ if (v.visit_attribute (attr) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("be_visitor_servant_svs")
+ ACE_TEXT ("::gen_attr_set_r - ")
+ ACE_TEXT ("visit_attribute() ")
+ ACE_TEXT ("failed\n")),
+ -1);
+ }
+ }
+ }
+
+ node = node->base_component ();
+ return this->gen_attr_set_r (node);
+}
+
+void
+be_visitor_servant_svs::gen_provides_top (void)
+{
+ os_ << be_nl << be_nl
+ << "/// CIAO-specific." << be_nl
+ << "::CORBA::Object_ptr" << be_nl
+ << node_->local_name ()
+ << "_Servant::get_facet_executor (" << be_idt_nl
+ << "const char * name)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl << be_nl;
+ }
+
+ os_ << "if (name == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
+ << "}" << be_uidt;
+
+ AST_Component *node = node_;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_provides)
+ {
+ continue;
+ }
+
+ this->gen_facet_executor_block (
+ d->local_name ()->get_string ());
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "return ::CORBA::Object::_nil ();" << be_uidt_nl
+ << "}";
+}
+
+void
+be_visitor_servant_svs::gen_facet_executor_block (
+ const char *port_name)
+{
+ os_ << be_nl << be_nl
+ << "if (ACE_OS::strcmp (name, \"" << port_name
+ << "\") == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return this->executor_->get_" << port_name
+ << " ();" << be_uidt_nl
+ << "}" << be_uidt;
+}
+
+void
+be_visitor_servant_svs::gen_publishes_top (void)
+{
+ os_ << be_nl << be_nl
+ << "::Components::Cookie *" << be_nl
+ << node_->local_name () << "_Servant::subscribe ("
+ << be_idt_nl
+ << "const char * publisher_name," << be_nl
+ << "::Components::EventConsumerBase_ptr subscribe)"
+ << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl << be_nl;
+ }
+
+ os_ << "ACE_UNUSED_ARG (subscribe);" << be_nl << be_nl
+ << "if (publisher_name == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}" << be_uidt;
+
+ AST_Component *node = node_;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_publishes)
+ {
+ continue;
+ }
+
+ AST_Publishes *p =
+ AST_Publishes::narrow_from_decl (d);
+
+ this->gen_subscribe_block (p);
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::EventConsumerBase_ptr" << be_nl
+ << node_->local_name () << "_Servant::unsubscribe ("
+ << be_idt_nl
+ << "const char * publisher_name," << be_nl
+ << "::Components::Cookie * ck)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl << be_nl;
+ }
+
+ os_ << "ACE_UNUSED_ARG (ck);" << be_nl << be_nl
+ << "if (publisher_name == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}" << be_uidt;
+
+ node = node_;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_publishes)
+ {
+ continue;
+ }
+
+ AST_Publishes *p =
+ AST_Publishes::narrow_from_decl (d);
+
+ this->gen_unsubscribe_block (p);
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::PublisherDescriptions *" << be_nl
+ << node_->local_name ()
+ << "_Servant::get_all_publishers (void)" << be_nl
+ << "{" << be_idt_nl
+ << "::Components::PublisherDescriptions *retval = 0;"
+ << be_nl
+ << "ACE_NEW_RETURN (retval," << be_nl
+ << " ::Components::PublisherDescriptions,"
+ << be_nl
+ << " 0);" << be_nl << be_nl
+ << "::Components::PublisherDescriptions_var "
+ << "safe_retval = retval;" << be_nl
+ << "safe_retval->length (" << n_publishes_
+ << "UL);";
+
+ node = node_;
+ ACE_CDR::ULong slot = 0UL;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_publishes)
+ {
+ continue;
+ }
+
+ AST_Publishes *p =
+ AST_Publishes::narrow_from_decl (d);
+
+ this->gen_event_source_description (p, slot++);
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "return safe_retval._retn ();" << be_uidt_nl
+ << "}";
+}
+
+void
+be_visitor_servant_svs::gen_subscribe_block (
+ AST_Publishes *p)
+{
+ const char *obj_name = p->publishes_type ()->full_name ();
+ const char *port_name = p->local_name ()->get_string ();
+
+ os_ << be_nl << be_nl
+ << "if (ACE_OS::strcmp (publisher_name, \""
+ << port_name << "\") == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "::" << obj_name << "Consumer_var sub =" << be_idt_nl
+ << "::" << obj_name << "Consumer::_narrow (subscribe);"
+ << be_uidt_nl << be_nl
+ << "if ( ::CORBA::is_nil (sub.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "::CORBA::Boolean const substitutable =" << be_idt_nl
+ << "subscribe->ciao_is_substitutable (" << be_idt_nl
+ << "::" << obj_name
+ << "::_tao_obv_static_repository_id ());"
+ << be_uidt << be_uidt_nl << be_nl
+ << "if (substitutable)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return this->subscribe_" << port_name
+ << "_generic (subscribe);" << be_uidt_nl
+ << "}" << be_uidt_nl
+ << "else" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt << be_uidt_nl
+ << "}" << be_uidt_nl
+ << "else" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return this->subscribe_" << port_name
+ << " (sub.in ());" << be_uidt_nl
+ << "}" << be_uidt << be_uidt_nl
+ << "}" << be_uidt;
+}
+
+void
+be_visitor_servant_svs::gen_unsubscribe_block (
+ AST_Publishes *p)
+{
+ const char *port_name = p->local_name ()->get_string ();
+
+ os_ << be_nl << be_nl
+ << "if (ACE_OS::strcmp (publisher_name, \""
+ << port_name << "\") == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return this->unsubscribe_" << port_name
+ << " (ck);" << be_uidt_nl
+ << "}" << be_uidt;
+}
+
+void
+be_visitor_servant_svs::gen_event_source_description (
+ AST_Publishes *p,
+ ACE_CDR::ULong slot)
+{
+ AST_Type *obj = p->publishes_type ();
+ const char *port_name = p->local_name ()->get_string ();
+
+ os_ << be_nl << be_nl;
+
+ if (! be_global->gen_ciao_static_config ())
+ {
+ os_ << "{" << be_idt_nl
+ << "ACE_READ_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->context_->"
+ << port_name << "_lock_," << be_nl
+ << " 0);" << be_nl << be_nl;
+ }
+
+ os_ << "::CIAO::Servant::describe_pub_event_source<"
+ << be_idt_nl
+ << "::" << obj->full_name () << "Consumer_var> ("
+ << be_idt_nl
+ << "\"" << port_name << "\"," << be_nl
+ << "\"" << obj->repoID () << "\"," << be_nl
+ << "this->context_->ciao_publishes_"
+ << port_name << "_," << be_nl
+ << "safe_retval," << be_nl
+ << slot << "UL);" << be_uidt << be_uidt;
+
+ if (! be_global->gen_ciao_static_config ())
+ {
+ os_ << be_uidt_nl
+ << "}";
+ }
+}
+
+void
+be_visitor_servant_svs::gen_uses_top (void)
+{
+ os_ << be_nl << be_nl
+ << "::Components::Cookie *" << be_nl
+ << node_->local_name () << "_Servant::connect (" << be_idt_nl
+ << "const char * name," << be_nl
+ << "::CORBA::Object_ptr connection)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl << be_nl;
+ }
+
+ os_ << "/// If the component has no receptacles, "
+ << "arg will be unused." << be_nl
+ << "ACE_UNUSED_ARG (connection);" << be_nl << be_nl
+ << "if (name == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}" << be_uidt;
+
+ AST_Component *node = node_;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_uses)
+ {
+ continue;
+ }
+
+ AST_Uses *u =
+ AST_Uses::narrow_from_decl (d);
+
+ this->gen_connect_block (u);
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::CORBA::Object_ptr" << be_nl
+ << node_->local_name () << "_Servant::disconnect ("
+ << be_idt_nl
+ << "const char * name," << be_nl
+ << "::Components::Cookie * ck)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl << be_nl;
+ }
+
+ os_ << "ACE_UNUSED_ARG (ck);" << be_nl << be_nl
+ << "if (name == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
+ << "}" << be_uidt;
+
+ node = node_;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_uses)
+ {
+ continue;
+ }
+
+ AST_Uses *u =
+ AST_Uses::narrow_from_decl (d);
+
+ this->gen_disconnect_block (u);
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::ReceptacleDescriptions *" << be_nl
+ << node_->local_name ()
+ << "_Servant::get_all_receptacles (void)" << be_nl
+ << "{" << be_idt_nl
+ << "::Components::ReceptacleDescriptions * retval = 0;"
+ << be_nl
+ << "ACE_NEW_RETURN (retval," << be_nl
+ << " ::Components::ReceptacleDescriptions,"
+ << be_nl
+ << " 0);" << be_nl
+ << "::Components::ReceptacleDescriptions_var "
+ << "safe_retval = retval;" << be_nl
+ << "safe_retval->length (" << n_uses_
+ << "UL);";
+
+ node = node_;
+ ACE_CDR::ULong slot = 0UL;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_uses)
+ {
+ continue;
+ }
+
+ AST_Uses *u =
+ AST_Uses::narrow_from_decl (d);
+
+ this->gen_receptacle_description (u, slot++);
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "return safe_retval._retn ();" << be_uidt_nl
+ << "}";
+}
+
+void
+be_visitor_servant_svs::gen_connect_block (AST_Uses *u)
+{
+ 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_nl << be_nl
+ << "if (ACE_OS::strcmp (name, \"" << port_name
+ << "\") == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "::" << obj_name << "_var _ciao_conn =" << be_idt_nl
+ << "::" << obj_name << "::_narrow (connection);"
+ << be_uidt_nl << be_nl
+ << "if ( ::CORBA::is_nil (_ciao_conn.in ()))" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl;
+
+ if (! is_multiple)
+ {
+ os_ << "ACE_CString receptacle_name (\"" << port_name
+ << "\");" << be_nl
+ << "receptacle_name += \'_\';" << be_nl
+ << "receptacle_name += "
+ << "this->context_->_ciao_instance_id ();" << be_nl
+ << "::CORBA::PolicyList_var policy_list =" << be_idt_nl
+ << "this->container_->get_receptacle_policy "
+ << "(receptacle_name.c_str ());" << be_uidt_nl << be_nl
+ << "if (policy_list->length () != 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "::CORBA::Object_var over_ridden_object ="
+ << be_idt_nl
+ << "_ciao_conn->_set_policy_overrides (policy_list.in (),"
+ << be_nl
+ << " CORBA::SET_OVERRIDE);"
+ << be_uidt_nl
+ << "_ciao_conn =" << be_idt_nl
+ << "::" << obj_name << "::_narrow (over_ridden_object.in ());"
+ << be_uidt << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl;
+ }
+
+ os_ << "/// " << (is_multiple ? "Multiplex" : "Simplex")
+ << " connect." << be_nl
+ << (is_multiple ? "return " : "") << "this->connect_"
+ << port_name << " (_ciao_conn.in ());";
+
+ if (! is_multiple)
+ {
+ os_ << be_nl << be_nl
+ << "return 0;";
+ }
+
+ os_ << be_uidt_nl
+ << "}" << be_uidt;
+}
+
+void
+be_visitor_servant_svs::gen_disconnect_block (AST_Uses *u)
+{
+ const char *port_name = u->local_name ()->get_string ();
+ bool is_multiple = u->is_multiple ();
+
+ os_ << be_nl << be_nl
+ << "if (ACE_OS::strcmp (name, \"" << port_name
+ << "\") == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "/// " << (is_multiple ? "Multiplex" : "Simplex")
+ << " disconnect." << be_nl;
+
+ if (is_multiple)
+ {
+ os_ << "if (ck == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::CookieRequired ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl;
+ }
+
+ os_ << "return this->disconnect_" << port_name
+ << " (" << (is_multiple ? "ck" : "") << ");" << be_uidt_nl
+ << "}" << be_uidt;
+}
+
+void
+be_visitor_servant_svs::gen_receptacle_description (
+ AST_Uses *u,
+ ACE_CDR::ULong slot)
+{
+ AST_Type *obj = u->uses_type ();
+ const char *port_name = u->local_name ()->get_string ();
+ bool is_multiple = u->is_multiple ();
+
+ os_ << be_nl << be_nl;
+
+ bool gen_guard =
+ is_multiple && ! be_global->gen_ciao_static_config ();
+
+ if (gen_guard)
+ {
+ os_ << "{" << be_idt_nl
+ << "ACE_READ_GUARD_RETURN (TAO_SYNCH_MUTEX," << be_nl
+ << " mon," << be_nl
+ << " this->context_->"
+ << port_name << "_lock_," << be_nl
+ << " 0);" << be_nl << be_nl;
+ }
+
+ os_ << "::CIAO::Servant::describe_"
+ << (is_multiple ? "multiplex" : "simplex")
+ << "_receptacle<" << be_idt_nl
+ << "::" << obj->full_name () << "_var> (" << be_idt_nl
+ << "\"" << port_name << "\"," << be_nl
+ << "\"" << obj->repoID () << "\"," << be_nl
+ << "this->context_->ciao_uses_"
+ << port_name << "_," << be_nl
+ << "safe_retval," << be_nl
+ << slot << "UL);" << be_uidt << be_uidt;
+
+ if (gen_guard)
+ {
+ os_ << be_uidt_nl
+ << "}";
+ }
+}
+
+void
+be_visitor_servant_svs::gen_emits_top (void)
+{
+ os_ << be_nl << be_nl
+ << "void" << be_nl
+ << node_->local_name () << "_Servant::connect_consumer ("
+ << be_idt_nl
+ << "const char * emitter_name," << be_nl
+ << "::Components::EventConsumerBase_ptr consumer)"
+ << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl << be_nl;
+ }
+
+ os_ << "if (emitter_name == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
+ << "}" << be_uidt;
+
+ AST_Component *node = node_;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_emits)
+ {
+ continue;
+ }
+
+ AST_Emits *e =
+ AST_Emits::narrow_from_decl (d);
+
+ this->gen_connect_consumer_block (e);
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "ACE_UNUSED_ARG (consumer);" << be_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::EventConsumerBase_ptr" << be_nl
+ << node_->local_name ()
+ << "_Servant::disconnect_consumer (" << be_idt_nl
+ << "const char * source_name)" << be_uidt_nl
+ << "{" << be_idt_nl;
+
+ if (swapping_)
+ {
+ os_ << "this->activate_component ();" << be_nl << be_nl;
+ }
+
+ os_ << "if (source_name == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::CORBA::BAD_PARAM ();" << be_uidt_nl
+ << "}" << be_uidt;
+
+ node = node_;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_emits)
+ {
+ continue;
+ }
+
+ AST_Emits *e =
+ AST_Emits::narrow_from_decl (d);
+
+ this->gen_disconnect_consumer_block (e);
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "throw ::Components::InvalidName ();" << be_uidt_nl
+ << "}";
+
+ os_ << be_nl << be_nl
+ << "::Components::EmitterDescriptions *" << be_nl
+ << node_->local_name ()
+ << "_Servant::get_all_emitters (void)" << be_nl
+ << "{" << be_idt_nl
+ << "::Components::EmitterDescriptions *retval = 0;"
+ << be_nl
+ << "ACE_NEW_RETURN (retval," << be_nl
+ << " ::Components::EmitterDescriptions,"
+ << be_nl
+ << " 0);" << be_nl << be_nl
+ << "::Components::EmitterDescriptions_var "
+ << "safe_retval = retval;" << be_nl
+ << "safe_retval->length (" << n_emits_
+ << "UL);";
+
+ node = node_;
+ ACE_CDR::ULong slot = 0UL;
+
+ while (node != 0)
+ {
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ if (d->node_type () != AST_Decl::NT_emits)
+ {
+ continue;
+ }
+
+ AST_Emits *e =
+ AST_Emits::narrow_from_decl (d);
+
+ this->gen_emitter_description (e, slot++);
+ }
+
+ node = node->base_component ();
+ }
+
+ os_ << be_nl << be_nl
+ << "return safe_retval._retn ();" << be_uidt_nl
+ << "}";
+}
+
+void
+be_visitor_servant_svs::gen_connect_consumer_block (
+ AST_Emits *e)
+{
+ const char *obj_name = e->emits_type ()->full_name ();
+ const char *port_name = e->local_name ()->get_string ();
+
+ os_ << be_nl << be_nl
+ << "if (ACE_OS::strcmp (emitter_name, \""
+ << port_name << "\") == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "::" << obj_name
+ << "Consumer_var _ciao_consumer =" << be_idt_nl
+ << "::" << obj_name
+ << "Consumer::_narrow (consumer);" << be_uidt_nl << be_nl
+ << "if ( ::CORBA::is_nil (_ciao_consumer.in ()))"
+ << be_idt_nl
+ << "{" << be_idt_nl
+ << "throw ::Components::InvalidConnection ();" << be_uidt_nl
+ << "}" << be_uidt_nl << be_nl
+ << "this->connect_" << port_name
+ << " (_ciao_consumer.in ());" << be_nl << be_nl
+ << "return;" << be_uidt_nl
+ << "}" << be_uidt;
+}
+
+void
+be_visitor_servant_svs::gen_disconnect_consumer_block (
+ AST_Emits *e)
+{
+ const char *port_name = e->local_name ()->get_string ();
+
+ os_ << be_nl << be_nl
+ << "if (ACE_OS::strcmp (source_name, \""
+ << port_name << "\") == 0)" << be_idt_nl
+ << "{" << be_idt_nl
+ << "return this->disconnect_" << port_name
+ << " ();" << be_uidt_nl
+ << "}" << be_uidt;
+}
+
+void
+be_visitor_servant_svs::gen_emitter_description (
+ AST_Emits *e,
+ ACE_CDR::ULong slot)
+{
+ AST_Type *obj = e->emits_type ();
+ const char *port_name = e->local_name ()->get_string ();
+
+ os_ << be_nl << be_nl
+ << "::CIAO::Servant::describe_emit_event_source<"
+ << be_idt_nl
+ << "::" << obj->full_name () << "Consumer_var> ("
+ << be_idt_nl
+ << "\"" << port_name << "\"," << be_nl
+ << "\"" << obj->repoID () << "\"," << be_nl
+ << "this->context_->ciao_emits_" << port_name
+ << "_consumer_," << be_nl
+ << "safe_retval," << be_nl
+ << slot << "UL);" << be_uidt << be_uidt;
+}
+
+void
+be_visitor_servant_svs::gen_populate_r (AST_Component *node)
+{
+ if (node == 0)
+ {
+ return;
+ }
+
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next ())
+ {
+ AST_Decl *d = si.item ();
+
+ switch (d->node_type ())
+ {
+ case AST_Decl::NT_provides:
+ os_ << be_nl
+ << "obj_var = this->provide_"
+ << d->local_name ()->get_string () << "_i ();";
+
+ break;
+ case AST_Decl::NT_consumes:
+ os_ << be_nl
+ << "ecb_var = this->get_consumer_"
+ << d->local_name ()->get_string () << "_i ();";
+
+ break;
+ default:
+ break;
+ }
+ }
+
+ node = node->base_component ();
+ this->gen_populate_r (node);
+}
+
+// ==========================================================
+
+Component_Op_Attr_Generator::Component_Op_Attr_Generator (
+ be_visitor_scope * visitor)
+ : visitor_ (visitor)
+{
+}
+
+int
+Component_Op_Attr_Generator::emit (be_interface * /* derived_interface */,
+ TAO_OutStream * /* os */,
+ be_interface * base_interface)
+{
+ if (base_interface->node_type () == AST_Decl::NT_component)
+ {
+ return 0;
+ }
+
+ return visitor_->visit_scope (base_interface);
+}
+
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 99772ed0e5e..f01088ff129 100644
--- a/modules/TAO/TAO_IDL/be_include/be_visitor_component.h
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component.h
@@ -38,6 +38,9 @@
#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/facet_svs.h"
+#include "be_visitor_component/context_svs.h"
+#include "be_visitor_component/servant_svs.h"
#include "be_visitor_component/component_ex_idl.h"
#include "be_visitor_component/component_exh.h"
#include "be_visitor_component/component_exs.h"
diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_svs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_svs.h
index 7ab586b7111..8456b92b55f 100644
--- a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_svs.h
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_svs.h
@@ -39,134 +39,14 @@ public:
~be_visitor_component_svs (void);
virtual int visit_component (be_component *node);
- virtual int visit_operation (be_operation *node);
- virtual int visit_attribute (be_attribute *node);
private:
- int gen_facets (void);
+ void gen_entrypoint (AST_Component *node);
- int gen_facet_ops_attrs (be_interface *node);
-
- void gen_context_class (void);
-
- int gen_servant_class (void);
-
- int gen_component_attrs_r (AST_Component *node);
-
- int gen_component_attrs (AST_Component *node);
-
- void gen_provides_top (void);
-
- void gen_facet_executor_block (const char *port_name);
-
- void gen_provides_r (AST_Component *node);
-
- void gen_provides (AST_Provides *p);
-
- void gen_uses_context_r (AST_Component *node);
-
- void gen_uses_context (AST_Uses *u);
-
- void gen_uses_context_simplex (AST_Type *obj,
- const char *port_name);
-
- void gen_uses_context_multiplex (AST_Type *obj,
- const char *port_name);
-
- void gen_uses_servant_top (void);
-
- void gen_connect_block (AST_Uses *u);
-
- void gen_disconnect_block (AST_Uses *u);
-
- void gen_uses_servant_r (AST_Component *node);
-
- void gen_uses_servant (AST_Uses *u);
-
- void gen_receptacle_description (AST_Uses *u,
- ACE_CDR::ULong slot);
-
- void gen_publishes_context_r (AST_Component *node);
-
- void gen_publishes_context (AST_Publishes *p);
-
- void gen_publishes_servant_top (void);
-
- void gen_subscribe_block (AST_Publishes *p);
-
- void gen_unsubscribe_block (AST_Publishes *p);
-
- void gen_event_source_description (AST_Publishes *p,
- ACE_CDR::ULong slot);
-
- void gen_publishes_servant_r (AST_Component *node);
-
- void gen_publishes_servant (AST_Publishes *p);
-
- void gen_consumes_r (AST_Component *node);
-
- void gen_consumes (AST_Consumes *c);
-
- void gen_emits_context_r (AST_Component *node);
-
- void gen_emits_context (AST_Emits *e);
-
- void gen_emits_servant_top (void);
-
- void gen_connect_consumer_block (AST_Emits *e);
-
- void gen_disconnect_consumer_block (AST_Emits *e);
-
- void gen_emitter_description (AST_Emits *e,
- ACE_CDR::ULong slot);
-
- void gen_emits_servant_r (AST_Component *node);
-
- void gen_emits_servant (AST_Emits *e);
-
- void gen_attr_set_r (AST_Component *node);
-
- void gen_populate_r (AST_Component *node);
-
- void gen_entrypoint (void);
-
- void gen_all_factory_registration (void);
- void gen_one_factory_registration (AST_Type *t);
-
- void gen_swapping_get_consumers_r (AST_Component *node);
- void gen_swapping_get_comsumer_block (const char *port_name);
-
- void compute_slots (AST_Component *node);
-
private:
- be_component *node_;
- be_interface *op_scope_;
TAO_OutStream &os_;
ACE_CString export_macro_;
- static bool in_facets_;
- bool swapping_;
- ACE_CDR::ULong n_provides_;
- ACE_CDR::ULong n_uses_;
- ACE_CDR::ULong n_publishes_;
- ACE_CDR::ULong n_emits_;
- ACE_CDR::ULong n_consumes_;
-};
-
-/// Worker class passed to traverse_inheritance_graph(),
-/// collects supported operations and attributes.
-class Component_Op_Attr_Generator
- : public TAO_IDL_Inheritance_Hierarchy_Worker
-{
-public:
- Component_Op_Attr_Generator (be_visitor_scope * visitor);
-
- virtual int emit (be_interface * derived_interface,
- TAO_OutStream * os,
- be_interface * base_interface);
-
-private:
- be_visitor_scope * visitor_;
};
-
+
#endif /* _BE_COMPONENT_COMPONENT_SVS_H_ */
diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/context_svs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/context_svs.h
new file mode 100644
index 00000000000..7663b40c98a
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/context_svs.h
@@ -0,0 +1,69 @@
+//
+// $Id$
+//
+/* -*- c++ -*- */
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// context_svs.h
+//
+// = DESCRIPTION
+// Concrete visitor for the Component node.
+// This provides for code generation for the Context
+// class definition
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+#ifndef _BE_COMPONENT_CONTEXT_SVS_H_
+#define _BE_COMPONENT_CONTEXT_SVS_H_
+
+class be_visitor_context_svs : public be_visitor_scope
+{
+ //
+ // = TITLE
+ // be_visitor_context_svs
+ //
+ // = DESCRIPTION
+ // This is a concrete visitor to generate the context class defn
+ // for a component.
+ //
+ //
+public:
+ be_visitor_context_svs (be_visitor_context *ctx);
+
+ ~be_visitor_context_svs (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);
+
+ void gen_swapping_get_consumers_r (AST_Component *node);
+ void gen_swapping_get_consumer_block (const char *port_name);
+
+ void gen_uses_simplex (AST_Type *obj,
+ const char *port_name);
+ void gen_uses_multiplex (AST_Type *obj,
+ const char *port_name);
+
+
+private:
+ be_component *node_;
+ TAO_OutStream &os_;
+ bool swapping_;
+ bool static_config_;
+};
+
+#endif /* _BE_COMPONENT_CONTEXT_SVS_H_ */
+
diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_svs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_svs.h
new file mode 100644
index 00000000000..ebbce6631b7
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_svs.h
@@ -0,0 +1,52 @@
+//
+// $Id$
+//
+/* -*- c++ -*- */
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// facet_svs.h
+//
+// = DESCRIPTION
+// Concrete visitor for the Component node.
+// This provides for code generation for the facet servant
+// class definition
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+#ifndef _BE_COMPONENT_FACET_SVS_H_
+#define _BE_COMPONENT_FACET_SVS_H_
+
+class be_visitor_facet_svs : public be_visitor_scope
+{
+ //
+ // = TITLE
+ // be_visitor_facet_svs
+ //
+ // = DESCRIPTION
+ // This is a concrete visitor to generate the facet servant defn
+ // for a component.
+ //
+ //
+public:
+ be_visitor_facet_svs (be_visitor_context *ctx);
+
+ ~be_visitor_facet_svs (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_;
+};
+
+#endif /* _BE_COMPONENT_FACET_SVS_H_ */
+
diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/servant_svs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/servant_svs.h
new file mode 100644
index 00000000000..45055bfa81b
--- /dev/null
+++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/servant_svs.h
@@ -0,0 +1,126 @@
+//
+// $Id$
+//
+/* -*- c++ -*- */
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// servant_svs.h
+//
+// = DESCRIPTION
+// Concrete visitor for the Component node.
+// This provides for code generation for the Servant
+// class definition
+//
+// = AUTHOR
+// Jeff Parsons
+//
+// ============================================================================
+
+#ifndef _BE_COMPONENT_SERVANT_SVS_H_
+#define _BE_COMPONENT_SERVANT_SVS_H_
+
+class be_visitor_servant_svs : public be_visitor_scope
+{
+ //
+ // = TITLE
+ // be_visitor_servant_svs
+ //
+ // = DESCRIPTION
+ // This is a concrete visitor to generate the servant class decl
+ // for a component.
+ //
+ //
+public:
+ be_visitor_servant_svs (be_visitor_context *ctx);
+
+ ~be_visitor_servant_svs (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_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);
+
+ void compute_slots (AST_Component *node);
+
+ void gen_obv_factory_registration_r (AST_Component *node);
+ void gen_obv_factory_registration (AST_Type *t);
+
+ int gen_attr_set_r (AST_Component *node);
+
+ void gen_provides_top (void);
+
+ void gen_facet_executor_block (const char *port_name);
+
+ void gen_uses_top (void);
+
+ void gen_connect_block (AST_Uses *u);
+
+ void gen_disconnect_block (AST_Uses *u);
+
+ void gen_receptacle_description (AST_Uses *u,
+ ACE_CDR::ULong slot);
+
+ void gen_publishes_top (void);
+
+ void gen_subscribe_block (AST_Publishes *p);
+
+ void gen_unsubscribe_block (AST_Publishes *p);
+
+ void gen_event_source_description (AST_Publishes *p,
+ ACE_CDR::ULong slot);
+
+ void gen_emits_top (void);
+
+ void gen_connect_consumer_block (AST_Emits *e);
+
+ void gen_disconnect_consumer_block (AST_Emits *e);
+
+ void gen_emitter_description (AST_Emits *e,
+ ACE_CDR::ULong slot);
+
+ void gen_populate_r (AST_Component *node);
+
+private:
+ be_component *node_;
+ be_interface *op_scope_;
+ TAO_OutStream &os_;
+ ACE_CString export_macro_;
+ bool swapping_;
+ ACE_CDR::ULong n_provides_;
+ ACE_CDR::ULong n_uses_;
+ ACE_CDR::ULong n_publishes_;
+ ACE_CDR::ULong n_emits_;
+ ACE_CDR::ULong n_consumes_;
+};
+
+/// Worker class passed to traverse_inheritance_graph(),
+/// collects supported operations and attributes.
+class Component_Op_Attr_Generator
+ : public TAO_IDL_Inheritance_Hierarchy_Worker
+{
+public:
+ Component_Op_Attr_Generator (be_visitor_scope * visitor);
+
+ virtual int emit (be_interface * derived_interface,
+ TAO_OutStream * os,
+ be_interface * base_interface);
+
+private:
+ be_visitor_scope * visitor_;
+};
+
+#endif /* _BE_COMPONENT_SERVANT_SVS_H_ */
+