diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-10-22 19:22:08 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-10-22 19:22:08 +0000 |
commit | 21a1d5deeba34ba364fb10a668157de5e9da6e2b (patch) | |
tree | 30988794eb890f524a2a2acb68ef2bd72c4dcfa0 | |
parent | f4ba83ba457583ef3a469c9e2a7daeffed9f8b22 (diff) | |
download | ATCD-21a1d5deeba34ba364fb10a668157de5e9da6e2b.tar.gz |
ChangeLogTag: Thu Oct 22 19:21:26 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
46 files changed, 1089 insertions, 973 deletions
diff --git a/modules/TAO/ChangeLog b/modules/TAO/ChangeLog index 7c0b9c8aab2..6e92ac40a25 100644 --- a/modules/TAO/ChangeLog +++ b/modules/TAO/ChangeLog @@ -1,3 +1,75 @@ +Thu Oct 22 19:21:26 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu> + + * TAO_IDL/be/be_visitor_component/facet_exs.cpp: + * TAO_IDL/be/be_visitor_component/executor_exh.cpp: + * TAO_IDL/be/be_visitor_component/executor_exs.cpp: + * TAO_IDL/be/be_visitor_component/facet_exh.cpp: + * TAO_IDL/be_include/be_visitor_component/executor_exh.h: + * TAO_IDL/be_include/be_visitor_component/executor_exs.h: + * TAO_IDL/be_include/be_visitor_component/facet_exh.h: + * TAO_IDL/be_include/be_visitor_component/facet_exs.h: + + New files, containing new visitors that handle code + generation class-by-class in the executor implementation. + + * TAO_IDL/be/be_provides.cpp: + * TAO_IDL/be/be_attribute.cpp: + * TAO_IDL/be/be_consumes.cpp: + * TAO_IDL/be/be_field.cpp: + * TAO_IDL/be/be_publishes.cpp: + * TAO_IDL/be/be_uses.cpp: + * TAO_IDL/be/be_emits.cpp: + * TAO_IDL/be/be_sequence.cpp: + * TAO_IDL/be_include/be_field.h: + * TAO_IDL/be_include/be_publishes.h: + * TAO_IDL/be_include/be_component.h: + * TAO_IDL/be_include/be_uses.h: + * TAO_IDL/be_include/be_provides.h: + * TAO_IDL/be_include/be_attribute.h: + * TAO_IDL/be_include/be_emits.h: + * TAO_IDL/be_include/be_consumes.h: + * TAO_IDL/be_include/be_sequence.h: + + Add non-virtual override of frontend methods that + fetch the referenced provides, uses, publishes, emits, + consumes, field, or base type. This addition concentrates + the narrowing to the backend type so it need not be + done over and over in the visitors. + + * TAO_IDL/be/be_visitor_component.cpp: + * TAO_IDL/be_include/be_visitor_component.h: + + Added new visitor files. + + * TAO_IDL/be/be_interface.cpp: + * TAO_IDL/be_include/be_interface.h: + + Renamed static method facet_op_attr_decl_helper to + op_attr_decl_helper, since its use is now more general. + + * TAO_IDL/be_include/be_visitor_component/component_exh.h: + * TAO_IDL/be_include/be_visitor_component/component_exs.h: + * TAO_IDL/be/be_visitor_component/component_exh.cpp: + * TAO_IDL/be/be_visitor_component/component_exs.cpp: + + Split code out of these visitors and distributed it + among the new visitors. + + * TAO_IDL/be/be_visitor_operation/operation_exs.cpp: + * TAO_IDL/be/be_visitor_operation/operation_svs.cpp: + * TAO_IDL/be/be_visitor_interface/interface_svs.cpp: + * TAO_IDL/be/be_visitor_component/context_ex_idl.cpp: + * TAO_IDL/be/be_visitor_component/executor_ex_idl.cpp: + * TAO_IDL/be/be_visitor_component/servant_svh.cpp: + * TAO_IDL/be/be_visitor_component/facet_ex_idl.cpp: + * TAO_IDL/be/be_visitor_component/servant_svs.cpp: + * TAO_IDL/be/be_visitor_attribute.cpp: + * TAO_IDL/be/be_visitor_attribute/attribute.cpp: + * TAO_IDL/be_include/be_visitor_operation/operation_svs.h: + * TAO_IDL/be_include/be_visitor_component/component.h: + + Minor or cosmetic changes. + Wed Oct 21 20:40:45 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/be/be_visitor_extended_port.cpp: diff --git a/modules/TAO/TAO_IDL/be/be_attribute.cpp b/modules/TAO/TAO_IDL/be/be_attribute.cpp index e7108ecfcf8..b3189eacd69 100644 --- a/modules/TAO/TAO_IDL/be/be_attribute.cpp +++ b/modules/TAO/TAO_IDL/be/be_attribute.cpp @@ -86,7 +86,13 @@ be_attribute::be_attribute (bool ro, } } - +be_type * +be_attribute::field_type (void) const +{ + return + be_type::narrow_from_decl ( + this->AST_Attribute::field_type ()); +} int be_attribute::accept (be_visitor *visitor) diff --git a/modules/TAO/TAO_IDL/be/be_consumes.cpp b/modules/TAO/TAO_IDL/be/be_consumes.cpp index b6f5c807eeb..fb0635a2288 100644 --- a/modules/TAO/TAO_IDL/be/be_consumes.cpp +++ b/modules/TAO/TAO_IDL/be/be_consumes.cpp @@ -26,6 +26,14 @@ be_consumes::~be_consumes (void) { } +be_eventtype * +be_consumes::consumes_type (void) const +{ + return + be_eventtype::narrow_from_decl ( + this->AST_Consumes::consumes_type ()); +} + int be_consumes::accept (be_visitor *visitor) { diff --git a/modules/TAO/TAO_IDL/be/be_emits.cpp b/modules/TAO/TAO_IDL/be/be_emits.cpp index 8cf22061232..125481c0209 100644 --- a/modules/TAO/TAO_IDL/be/be_emits.cpp +++ b/modules/TAO/TAO_IDL/be/be_emits.cpp @@ -26,6 +26,14 @@ be_emits::~be_emits (void) { } +be_eventtype * +be_emits::emits_type (void) const +{ + return + be_eventtype::narrow_from_decl ( + this->AST_Emits::emits_type ()); +} + int be_emits::accept (be_visitor *visitor) { diff --git a/modules/TAO/TAO_IDL/be/be_field.cpp b/modules/TAO/TAO_IDL/be/be_field.cpp index 978a09eeb37..013058376e4 100644 --- a/modules/TAO/TAO_IDL/be/be_field.cpp +++ b/modules/TAO/TAO_IDL/be/be_field.cpp @@ -60,6 +60,14 @@ be_field::be_field (AST_Type *ft, } } +be_type * +be_field::field_type (void) const +{ + return + be_type::narrow_from_decl ( + this->AST_Field::field_type ()); +} + void be_field::gen_member_ostream_operator (TAO_OutStream *os, const char *instance_name, diff --git a/modules/TAO/TAO_IDL/be/be_interface.cpp b/modules/TAO/TAO_IDL/be/be_interface.cpp index c0826001e02..274bd7ac99f 100644 --- a/modules/TAO/TAO_IDL/be/be_interface.cpp +++ b/modules/TAO/TAO_IDL/be/be_interface.cpp @@ -2480,9 +2480,9 @@ be_interface::gen_abstract_init_helper (be_interface *node, } int -be_interface::facet_op_attr_decl_helper (be_interface * /*derived */, - be_interface *ancestor, - TAO_OutStream *os) +be_interface::op_attr_decl_helper (be_interface * /*derived */, + be_interface *ancestor, + TAO_OutStream *os) { if (be_component::narrow_from_decl (ancestor) != 0) { diff --git a/modules/TAO/TAO_IDL/be/be_provides.cpp b/modules/TAO/TAO_IDL/be/be_provides.cpp index f0929bef0cd..4fb62c9c584 100644 --- a/modules/TAO/TAO_IDL/be/be_provides.cpp +++ b/modules/TAO/TAO_IDL/be/be_provides.cpp @@ -37,6 +37,14 @@ be_provides::~be_provides (void) { } +be_type * +be_provides::provides_type (void) const +{ + return + be_type::narrow_from_decl ( + this->AST_Provides::provides_type ()); +} + int be_provides::gen_facet_svnt_decl (TAO_OutStream &os) { @@ -98,7 +106,7 @@ be_provides::gen_facet_svnt_decl (TAO_OutStream &os) int status = intf->traverse_inheritance_graph ( - be_interface::facet_op_attr_decl_helper, + be_interface::op_attr_decl_helper, &os); if (status == -1) @@ -300,7 +308,6 @@ be_facet_op_attr_defn_helper::emit (be_interface * /* derived_interface */, be_operation::narrow_from_decl (d); be_visitor_operation_svs v (&ctx); - v.for_facets (true); v.scope (op_scope_); if (v.visit_operation (op) == -1) diff --git a/modules/TAO/TAO_IDL/be/be_publishes.cpp b/modules/TAO/TAO_IDL/be/be_publishes.cpp index 508bd5e9626..fe9b3acba46 100644 --- a/modules/TAO/TAO_IDL/be/be_publishes.cpp +++ b/modules/TAO/TAO_IDL/be/be_publishes.cpp @@ -26,6 +26,14 @@ be_publishes::~be_publishes (void) { } +be_eventtype * +be_publishes::publishes_type (void) const +{ + return + be_eventtype::narrow_from_decl ( + this->AST_Publishes::publishes_type ()); +} + int be_publishes::accept (be_visitor *visitor) { diff --git a/modules/TAO/TAO_IDL/be/be_sequence.cpp b/modules/TAO/TAO_IDL/be/be_sequence.cpp index cf85ef74961..bb0d944fc18 100644 --- a/modules/TAO/TAO_IDL/be/be_sequence.cpp +++ b/modules/TAO/TAO_IDL/be/be_sequence.cpp @@ -36,10 +36,6 @@ #include "ace/Log_Msg.h" -ACE_RCSID (be, - be_sequence, - "$Id$") - be_sequence::be_sequence (void) : COMMON_Base (), AST_Decl (), @@ -149,6 +145,14 @@ be_sequence::be_sequence (AST_Expression *v, } } +be_type * +be_sequence::base_type (void) const +{ + return + be_type::narrow_from_decl ( + this->AST_Sequence::base_type ()); +} + // Helper to create_name. char * be_sequence::gen_name (void) diff --git a/modules/TAO/TAO_IDL/be/be_uses.cpp b/modules/TAO/TAO_IDL/be/be_uses.cpp index 461414e65f2..9fcb3ae93d0 100644 --- a/modules/TAO/TAO_IDL/be/be_uses.cpp +++ b/modules/TAO/TAO_IDL/be/be_uses.cpp @@ -28,6 +28,14 @@ be_uses::~be_uses (void) { } +be_type * +be_uses::uses_type (void) const +{ + return + be_type::narrow_from_decl ( + this->AST_Uses::uses_type ()); +} + int be_uses::accept (be_visitor *visitor) { diff --git a/modules/TAO/TAO_IDL/be/be_visitor_attribute.cpp b/modules/TAO/TAO_IDL/be/be_visitor_attribute.cpp index 59e23a5a07f..88f3910e46d 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_attribute.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_attribute.cpp @@ -54,7 +54,3 @@ #include "be_visitor_attribute/set_from_extracted.cpp" #include "be_visitor_attribute/component_init.cpp" -ACE_RCSID (be, - be_visitor_attribute, - "$Id$") - diff --git a/modules/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp b/modules/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp index d667dca1898..540e8304543 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp @@ -18,10 +18,6 @@ // // ============================================================================ -ACE_RCSID (be_visitor_attribute, - attribute, - "$Id$") - // Attribute gets mapped to one or possibly two operations based on whether // it is readonly or not. The two operations "get" and "set" the value of the // attribute. @@ -177,7 +173,6 @@ be_visitor_attribute::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_ROOT_SVS: { be_visitor_operation_svs visitor (&ctx); - visitor.for_facets (this->for_facets_); visitor.scope (this->op_scope_); status = get_op.accept (&visitor); break; @@ -391,7 +386,6 @@ be_visitor_attribute::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_ROOT_SVS: { be_visitor_operation_svs visitor (&ctx); - visitor.for_facets (this->for_facets_); visitor.scope (this->op_scope_); status = set_op.accept (&visitor); break; diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component.cpp index 9bb059e4d6e..86390b42de3 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_component.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_component.cpp @@ -82,7 +82,11 @@ #include "be_visitor_component/executor_ex_idl.cpp" #include "be_visitor_component/context_ex_idl.cpp" #include "be_visitor_component/component_exh.cpp" +#include "be_visitor_component/facet_exh.cpp" +#include "be_visitor_component/executor_exh.cpp" #include "be_visitor_component/component_exs.cpp" +#include "be_visitor_component/facet_exs.cpp" +#include "be_visitor_component/executor_exs.cpp" #include "be_visitor_component/any_op_ch.cpp" #include "be_visitor_component/any_op_cs.cpp" #include "be_visitor_component/cdr_op_ch.cpp" diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/component_exh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/component_exh.cpp index 810594d8654..e245b1a26f4 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_component/component_exh.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/component_exh.cpp @@ -18,20 +18,14 @@ // // ============================================================================ -ACE_RCSID (be_visitor_component, - component_exh, - "$Id$") - -// ****************************************************** -// Component visitor for CIAO exec impl header -// ****************************************************** - be_visitor_component_exh::be_visitor_component_exh (be_visitor_context *ctx) - : be_visitor_component (ctx), - node_ (0), - os_ (*ctx->stream ()), - export_macro_ (be_global->exec_export_macro ()) + : be_visitor_component_scope (ctx) { + // This is initialized in the base class to svnt_export_macro() + // or skel_export_macro(), since there are many more visitor + // classes generating servant code. So we can just override + // all that here + export_macro_ = be_global->exec_export_macro (); } be_visitor_component_exh::~be_visitor_component_exh (void) @@ -41,404 +35,48 @@ be_visitor_component_exh::~be_visitor_component_exh (void) int be_visitor_component_exh::visit_component (be_component *node) { - if (node->imported ()) - { - return 0; - } - - node_ = node; - /// 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; - if (this->gen_facets () == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_component_exh::") - ACE_TEXT ("visit_component - ") - ACE_TEXT ("gen_facets() failed\n")), - -1); - } + be_visitor_facet_exh facet_visitor (this->ctx_); - if (this->gen_exec_class () == -1) + // (JP) Should this be visit_component_scope(), i.e., + // generate inherited facets as well? Probably the + // behavior should be tied to the LEM force-all option. + if (facet_visitor.visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_component_exh::") ACE_TEXT ("visit_component - ") - ACE_TEXT ("gen_servant_class() failed\n")), + ACE_TEXT ("facet visitor failed\n")), -1); } - this->gen_entrypoint (); - - os_ << be_uidt_nl - << "}"; - - return 0; -} - -int -be_visitor_component_exh::visit_operation (be_operation *node) -{ - be_visitor_operation_ch v (this->ctx_); - return v.visit_operation (node); -} - -int -be_visitor_component_exh::visit_attribute (be_attribute *node) -{ - be_visitor_attribute v (this->ctx_); - return v.visit_attribute (node); -} - -int -be_visitor_component_exh::gen_facets (void) -{ - 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); - - be_type *impl = - be_type::narrow_from_decl (p->provides_type ()); - - // We don't want a '_cxx_' prefix here. - const char *lname = - impl->original_local_name ()->get_string (); - - AST_Decl *s = ScopeAsDecl (impl->defined_in ()); - ACE_CString sname_str = - IdentifierHelper::orig_sn (s->name (), false); - const char *sname = sname_str.c_str (); - const char *global = (sname_str == "" ? "" : "::"); - - os_ << be_nl - << "class " << export_macro_.c_str () << " " - << lname << "_exec_i" << be_idt_nl - << ": public virtual " << global << sname << "::CCM_" - << lname << "," << be_idt_nl - << "public virtual ::CORBA::LocalObject" - << be_uidt << be_uidt_nl - << "{" << be_nl - << "public:" << be_idt_nl - << lname << "_exec_i (void);" << be_nl - << "virtual ~" << lname << "_exec_i (void);"; - - if (impl->node_type () == AST_Decl::NT_interface) - { - be_interface *intf = - be_interface::narrow_from_decl (impl); - - os_ << be_nl << be_nl - << "// Operations and attributes from ::" - << intf->full_name (); - - if (this->gen_facet_ops_attrs (intf) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_component_exh::gen_facet - " - "gen_facet_ops_attrs() failed\n"), - -1); - } - } - - os_ << be_uidt_nl - << "};" << be_nl; - } - - return 0; -} - -int -be_visitor_component_exh::gen_facet_ops_attrs (be_interface *node) -{ - int status = - node->traverse_inheritance_graph ( - be_visitor_component_exh::op_attr_decl_helper, - &os_); - - if (status == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_component_exh::") - ACE_TEXT ("gen_facet_ops_attrs - ") - ACE_TEXT ("traverse_inheritance_graph() failed\n")), - -1); - } - - return 0; -} - -int -be_visitor_component_exh::gen_exec_class (void) -{ - AST_Decl *scope = ScopeAsDecl (node_->defined_in ()); - ACE_CString sname_str (scope->full_name ()); - const char *sname = sname_str.c_str (); - - // No _cxx_ prefix. - const char *lname = - node_->original_local_name ()->get_string (); + be_visitor_executor_exh exec_visitor (this->ctx_); - const char *global = (sname_str == "" ? "" : "::"); - - os_ << be_nl - << "class " << export_macro_.c_str () << " " << lname - << "_exec_i" << be_idt_nl - << ": public virtual " << lname << "_Exec," << be_idt_nl - << "public virtual ::CORBA::LocalObject" - << be_uidt << be_uidt_nl - << "{" << be_nl - << "public:" << be_idt_nl; - - os_ << lname << "_exec_i (void);"; - - os_ << be_nl - << "virtual ~" << lname << "_exec_i (void);"; - - os_ << be_nl << be_nl - << "// Supported operations and attributes."; - - int status = - node_->traverse_inheritance_graph ( - be_visitor_component_exh::op_attr_decl_helper, - &os_, - false, - false); - - if (status == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_component_exh::") - ACE_TEXT ("gen_exec_class - ") - ACE_TEXT ("traverse_inheritance_graph() failed\n")), - -1); - } - - os_ << be_nl << be_nl - << "// Component attributes."; - - status = this->gen_component_attrs_r (node_); - - if (status == -1) + if (exec_visitor.visit_component (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_component_exh::") - ACE_TEXT ("gen_exec_class - ") - ACE_TEXT ("gen_component_attrs_r() failed\n")), + ACE_TEXT ("visit_component - ") + ACE_TEXT ("exec visitor failed\n")), -1); } os_ << be_nl << be_nl - << "// Port operations."; - - this->gen_provides_r (node_); - this->gen_consumes_r (node_); - - this->gen_non_type_specific (); - - os_ << be_uidt_nl << be_nl - << "private:" << be_idt_nl - << global << sname << "::CCM_" << lname - << "_Context_var context_;" - << be_uidt_nl - << "};"; - - return 0; -} - -int -be_visitor_component_exh::gen_component_attrs_r (AST_Component *node) -{ - if (node == 0) - { - return 0; - } - - /// 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_exh::") - ACE_TEXT ("gen_component_attrs_r - ") - ACE_TEXT ("be_attribute::accept() failed\n")), - -1); - } - } - - node = node->base_component (); - return this->gen_component_attrs_r (node); -} - -void -be_visitor_component_exh::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); - - be_type *impl = - be_type::narrow_from_decl (p->provides_type ()); - - this->gen_provides (impl, p->local_name ()->get_string ()); - } - - node = node->base_component (); - this->gen_provides_r (node); -} - -void -be_visitor_component_exh::gen_provides (AST_Type *obj, - const char *port_name) -{ - AST_Decl *scope = ScopeAsDecl (obj->defined_in ()); - ACE_CString sname_str (scope->full_name ()); - const char *sname = sname_str.c_str (); - - // No '_cxx_' prefix. - const char *lname = - obj->original_local_name ()->get_string (); - - const char *global = (sname_str == "" ? "" : "::"); - - os_ << be_nl << be_nl - << "virtual " << global << sname << "::CCM_" - << lname << "_ptr" << be_nl - << "get_" << port_name << " (void);"; -} - -void -be_visitor_component_exh::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); - - be_type *impl = - be_type::narrow_from_decl (c->consumes_type ()); - - this->gen_consumes (impl->full_name (), - c->local_name ()->get_string ()); - } - - node = node->base_component (); - this->gen_consumes_r (node); -} - -void -be_visitor_component_exh::gen_consumes (const char *obj_name, - const char *port_name) -{ - os_ << be_nl << be_nl - << "virtual void" << be_nl - << "push_" << port_name << " (" << be_idt_nl - << "::" << obj_name << " * ev);" << be_uidt; -} - -void -be_visitor_component_exh::gen_non_type_specific (void) -{ - os_ << be_nl << be_nl - << "// Operations from Components::SessionComponent."; - - os_ << be_nl << be_nl - << "virtual void" << be_nl - << "set_session_context (" << be_idt_nl - << "::Components::SessionContext_ptr ctx);" << be_uidt; - - os_ << be_nl << be_nl - << "virtual void configuration_complete (void);"; - - os_ << be_nl << be_nl - << "virtual void ccm_activate (void);" << be_nl - << "virtual void ccm_passivate (void);" << be_nl - << "virtual void ccm_remove (void);"; -} - -void -be_visitor_component_exh::gen_entrypoint (void) -{ - os_ << be_nl << be_nl << "extern \"C\" " << export_macro_.c_str () << " ::Components::EnterpriseComponent_ptr" << be_nl - << "create_" << node_->flat_name () + << "create_" << node->flat_name () << "_Impl (void);"; -} -int -be_visitor_component_exh::op_attr_decl_helper (be_interface * /*derived */, - be_interface *ancestor, - TAO_OutStream *os) -{ - if (be_component::narrow_from_decl (ancestor) != 0) - { - return 0; - } - /// We're in a static method, so we have to instantiate a temporary - /// visitor and context. - be_visitor_context ctx; - ctx.state (TAO_CodeGen::TAO_ROOT_EXH); - ctx.stream (os); - be_visitor_component_exh visitor (&ctx); - - /// Since this visitor overriddes only visit_operation() and - /// visit_attribute(), we can get away with this for the declarations. - return visitor.visit_scope (ancestor); + os_ << be_uidt_nl + << "}"; + + return 0; } diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/component_exs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/component_exs.cpp index bdaf85ba2af..a48f72b90b8 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_component/component_exs.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/component_exs.cpp @@ -18,24 +18,15 @@ // // ============================================================================ -ACE_RCSID (be_visitor_component, - component_exs, - "$Id$") - -// ****************************************************** -// Component visitor for CIAO exec impl source -// ****************************************************** - -be_visitor_component_exs::be_visitor_component_exs (be_visitor_context *ctx) - : be_visitor_component (ctx), - node_ (0), - op_scope_ (0), - os_ (*ctx->stream ()), - comment_border_ ("//==============================" - "=============================="), - your_code_here_ ("/* Your code here. */"), - export_macro_ (be_global->exec_export_macro ()) +be_visitor_component_exs::be_visitor_component_exs ( + be_visitor_context *ctx) + : be_visitor_component_scope (ctx) { + // This is initialized in the base class to svnt_export_macro() + // or skel_export_macro(), since there are many more visitor + // classes generating servant code. So we can just override + // all that here. + export_macro_ = be_global->exec_export_macro (); } be_visitor_component_exs::~be_visitor_component_exs (void) @@ -45,450 +36,42 @@ be_visitor_component_exs::~be_visitor_component_exs (void) int be_visitor_component_exs::visit_component (be_component *node) { - node_ = node; - /// 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_facet_exs facet_visitor (this->ctx_); - if (this->gen_facets () == -1) + // (JP) Should this be visit_component_scope(), i.e., + // generate inherited facets as well? Probably the + // behavior should be tied to the LEM force-all option. + if (facet_visitor.visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_component_exs::") ACE_TEXT ("visit_component - ") - ACE_TEXT ("gen_facets() failed\n")), + ACE_TEXT ("facet visitor failed\n")), -1); } + + be_visitor_executor_exs exec_visitor (this->ctx_); - if (this->gen_exec_class () == -1) + if (exec_visitor.visit_component (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("be_visitor_component_exs::") ACE_TEXT ("visit_component - ") - ACE_TEXT ("gen_servant_class() failed\n")), - -1); - } - - this->gen_entrypoint (); - - os_ << be_uidt_nl - << "}"; - - return 0; -} - -int -be_visitor_component_exs::visit_operation (be_operation *node) -{ - be_visitor_operation_exs v (this->ctx_); - v.scope (op_scope_); - return v.visit_operation (node); -} - -int -be_visitor_component_exs::visit_attribute (be_attribute *node) -{ - be_visitor_attribute v (this->ctx_); - v.op_scope (op_scope_); - return v.visit_attribute (node); -} - -int -be_visitor_component_exs::gen_facets (void) -{ - 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); - - be_type *impl = - be_type::narrow_from_decl (p->provides_type ()); - - // We don't want any '_cxx_' prefix here. - const char *lname = - impl->original_local_name ()->get_string (); - - os_ << be_nl - << comment_border_ << be_nl - << "// Facet Executor Implementation Class: " - << lname << "_exec_i" << be_nl - << comment_border_; - - os_ << be_nl << be_nl - << lname << "_exec_i::" << lname - << "_exec_i (void)" << be_nl - << "{" << be_nl - << "}"; - - os_ << be_nl << be_nl - << lname << "_exec_i::~" << lname - << "_exec_i (void)" << be_nl - << "{" << be_nl - << "}"; - - if (impl->node_type () == AST_Decl::NT_interface) - { - be_interface *intf = - be_interface::narrow_from_decl (impl); - - op_scope_ = intf; - - if (this->gen_facet_ops_attrs (intf) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_component_exs::gen_facet - " - "gen_facet_ops_attrs() failed\n"), - -1); - } - } - } - - return 0; -} - -int -be_visitor_component_exs::gen_facet_ops_attrs (be_interface *node) -{ - os_ << be_nl << be_nl - << "// Operations from ::" << node->full_name (); - - /// 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_Exec_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, - ACE_TEXT ("be_visitor_component_exs::") - ACE_TEXT ("gen_facet_ops_attrs - ") - ACE_TEXT ("traverse_inheritance_graph() ") - ACE_TEXT ("failed\n")), - -1); - } - - return 0; -} - -int -be_visitor_component_exs::gen_exec_class (void) -{ - const char *lname = node_->local_name (); - - // In the interest of pretty formatting.... - 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) - { - os_ << be_nl; - break; - } - } - - os_ << be_nl - << comment_border_ << be_nl - << "// Component Executor Implementation Class: " - << lname << "_exec_i" << be_nl - << comment_border_; - - os_ << be_nl << be_nl - << lname << "_exec_i::" << lname << "_exec_i (void)" << be_nl - << "{" << be_nl - << "}"; - - os_ << be_nl << be_nl - << lname << "_exec_i::~" << lname << "_exec_i (void)" << be_nl - << "{" << be_nl - << "}"; - - os_ << be_nl << be_nl - << "// Supported operations and attributes."; - - 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_Exec_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, - ACE_TEXT ("be_visitor_component_exs::") - ACE_TEXT ("gen_exec_class - ") - ACE_TEXT ("traverse_inheritance_graph() failed\n")), + ACE_TEXT ("exec visitor failed\n")), -1); } os_ << be_nl << be_nl - << "// Component attributes."; - - status = this->gen_component_attrs_r (node_); - - if (status == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_component_exs::") - ACE_TEXT ("gen_exec_class - ") - ACE_TEXT ("gen_component_attrs_r() failed\n")), - -1); - } - - os_ << be_nl << be_nl - << "// Port operations."; - - this->gen_provides_r (node_); - this->gen_consumes_r (node_); - - this->gen_non_type_specific (); - - return 0; -} - -int -be_visitor_component_exs::gen_component_attrs_r (AST_Component *node) -{ - if (node == 0) - { - return 0; - } - - /// 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_exs::") - ACE_TEXT ("gen_component_attrs_r - ") - ACE_TEXT ("be_attribute::accept() failed\n")), - -1); - } - } - - node = node->base_component (); - return this->gen_component_attrs_r (node); -} - -void -be_visitor_component_exs::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); - - be_type *impl = - be_type::narrow_from_decl (p->provides_type ()); - - this->gen_provides (impl, p->local_name ()); - } - - node = node->base_component (); - this->gen_provides_r (node); -} - -void -be_visitor_component_exs::gen_provides (AST_Type *obj, - Identifier *port_id) -{ - AST_Decl *scope = ScopeAsDecl (obj->defined_in ()); - ACE_CString sname_str (scope->full_name ()); - const char *sname = sname_str.c_str (); - - // No '_cxx_' prefix. - const char *lname = obj->original_local_name ()->get_string (); - - const char *global = (sname_str == "" ? "" : "::"); - - const char *port_name = port_id->get_string (); - - os_ << be_nl << be_nl - << global << sname << "::CCM_" << lname - << "_ptr" << be_nl - << node_->local_name () << "_exec_i::get_" - << port_name << " (void)" << be_nl - << "{" << be_idt_nl - << your_code_here_ << be_nl - << "return " << global << sname << "::CCM_" - << lname << "::_nil ();" << be_uidt_nl - << "}"; -} - -void -be_visitor_component_exs::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); - - be_type *impl = - be_type::narrow_from_decl (c->consumes_type ()); - - this->gen_consumes (impl, c->local_name ()); - } - - node = node->base_component (); - this->gen_consumes_r (node); -} - -void -be_visitor_component_exs::gen_consumes (AST_Type *obj, - Identifier *port_id) -{ - const char *port_name = port_id->get_string (); - - os_ << be_nl << be_nl - << "void" << be_nl - << node_->original_local_name () << "_exec_i::push_" - << port_name << " (" << be_idt_nl - << "::" << IdentifierHelper::orig_sn (obj->name (), false).c_str () - << " * /* ev */)" << be_uidt_nl - << "{" << be_idt_nl - << your_code_here_ << be_uidt_nl - << "}"; -} - -void -be_visitor_component_exs::gen_non_type_specific (void) -{ - os_ << be_nl << be_nl - << "// Operations from Components::SessionComponent."; - - 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 - << "void" << be_nl - << node_->local_name () - << "_exec_i::set_session_context (" << be_idt_nl - << "::Components::SessionContext_ptr ctx)" << be_uidt_nl - << "{" << be_idt_nl - << "this->context_ =" << be_idt_nl - << global << sname << "::CCM_" << lname - << "_Context::_narrow (ctx);" << be_uidt_nl << be_nl - << "if ( ::CORBA::is_nil (this->context_.in ()))" << be_idt_nl - << "{" << be_idt_nl - << "throw ::CORBA::INTERNAL ();" << be_uidt_nl - << "}" << be_uidt << be_uidt_nl - << "}"; - - os_ << be_nl << be_nl - << "void" << be_nl - << node_->local_name () - << "_exec_i::configuration_complete (void)" << be_nl - << "{" << be_idt_nl - << your_code_here_ << be_uidt_nl - << "}"; - - os_ << be_nl << be_nl - << "void" << be_nl - << node_->local_name () - << "_exec_i::ccm_activate (void)" << be_nl - << "{" << be_idt_nl - << your_code_here_ << be_uidt_nl - << "}"; - - os_ << be_nl << be_nl - << "void" << be_nl - << node_->local_name () - << "_exec_i::ccm_passivate (void)" << be_nl - << "{" << be_idt_nl - << your_code_here_ << be_uidt_nl - << "}"; - - os_ << be_nl << be_nl - << "void" << be_nl - << node_->local_name () - << "_exec_i::ccm_remove (void)" << be_nl - << "{" << be_idt_nl - << your_code_here_ << be_uidt_nl - << "}"; -} - -void -be_visitor_component_exs::gen_entrypoint (void) -{ - os_ << be_nl << be_nl << "extern \"C\" " << export_macro_.c_str () << " ::Components::EnterpriseComponent_ptr" << be_nl - << "create_" << node_->flat_name () + << "create_" << node->flat_name () << "_Impl (void)" << be_nl << "{" << be_idt_nl << "::Components::EnterpriseComponent_ptr retval =" @@ -497,14 +80,21 @@ be_visitor_component_exs::gen_entrypoint (void) << be_uidt_nl << be_nl << "ACE_NEW_NORETURN (" << be_idt_nl << "retval," << be_nl - << node_->local_name () << "_exec_i);" + << node->local_name () << "_exec_i);" << be_uidt_nl << be_nl << "return retval;" << be_uidt_nl << "}"; + + os_ << be_uidt_nl + << "}"; + + return 0; } +// ================================================== + Component_Exec_Op_Attr_Generator::Component_Exec_Op_Attr_Generator ( - be_visitor_scope * visitor) + be_visitor_scope * visitor) : visitor_ (visitor) { } diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/context_ex_idl.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/context_ex_idl.cpp index 9d73f8d46bc..caf3f4bcef6 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_component/context_ex_idl.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/context_ex_idl.cpp @@ -88,8 +88,7 @@ int be_visitor_context_ex_idl::visit_uses ( be_uses *node) { - be_type *impl = - be_type::narrow_from_decl (node->uses_type ()); + be_type *impl = node->uses_type (); os_ << be_nl << "::"; @@ -120,8 +119,7 @@ int be_visitor_context_ex_idl::visit_publishes ( be_publishes *node) { - be_type *impl = - be_type::narrow_from_decl (node->publishes_type ()); + be_eventtype *impl = node->publishes_type (); os_ << be_nl << "void push_" << node->local_name ()->get_string () @@ -136,8 +134,7 @@ int be_visitor_context_ex_idl::visit_emits ( be_emits *node) { - be_type *impl = - be_type::narrow_from_decl (node->emits_type ()); + be_eventtype *impl = node->emits_type (); os_ << be_nl << "void push_" << node->local_name ()->get_string () diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/executor_ex_idl.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/executor_ex_idl.cpp index 9b627ee2fa5..025de3897bf 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_component/executor_ex_idl.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/executor_ex_idl.cpp @@ -93,7 +93,7 @@ be_visitor_executor_ex_idl::visit_attribute ( os_ << be_nl << (rd_only ? "readonly " : "") << "attribute "; - be_type *ft = be_type::narrow_from_decl (node->field_type ()); + be_type *ft = node->field_type (); os_ << IdentifierHelper::type_name (ft, this); os_ << " " @@ -117,8 +117,7 @@ be_visitor_executor_ex_idl::visit_sequence ( // Keep output statements separate because of side effects. os_ << "sequence<"; - be_type *bt = - be_type::narrow_from_decl (node->base_type ()); + be_type *bt = node->base_type (); os_ << IdentifierHelper::type_name (bt, this); @@ -155,8 +154,7 @@ int be_visitor_executor_ex_idl::visit_provides ( be_provides *node) { - be_type *impl = - be_type::narrow_from_decl (node->provides_type ()); + be_type *impl = node->provides_type (); AST_Decl *scope = ScopeAsDecl (impl->defined_in ()); @@ -180,8 +178,7 @@ int be_visitor_executor_ex_idl::visit_consumes ( be_consumes *node) { - be_type *impl = - be_type::narrow_from_decl (node->consumes_type ()); + be_eventtype *impl = node->consumes_type (); os_ << be_nl << "void push_" << node->local_name ()->get_string () diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/executor_exh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/executor_exh.cpp new file mode 100644 index 00000000000..c0a39f30b43 --- /dev/null +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/executor_exh.cpp @@ -0,0 +1,171 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// executor_exh.cpp +// +// = DESCRIPTION +// Visitor generating code in the exec impl header. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +be_visitor_executor_exh::be_visitor_executor_exh ( + be_visitor_context *ctx) + : be_visitor_component_scope (ctx) +{ + // This is initialized in the base class to svnt_export_macro() + // or skel_export_macro(), since there are many more visitor + // classes generating servant code. So we can just override + // all that here. + export_macro_ = be_global->exec_export_macro (); +} + +be_visitor_executor_exh::~be_visitor_executor_exh (void) +{ +} + +int +be_visitor_executor_exh::visit_attribute (be_attribute *node) +{ + be_visitor_attribute v (this->ctx_); + return v.visit_attribute (node); +} + +int +be_visitor_executor_exh::visit_component (be_component *node) +{ + AST_Decl *scope = ScopeAsDecl (node->defined_in ()); + ACE_CString sname_str (scope->full_name ()); + const char *sname = sname_str.c_str (); + + // No _cxx_ prefix. + const char *lname = + node->original_local_name ()->get_string (); + + const char *global = (sname_str == "" ? "" : "::"); + + os_ << be_nl + << "class " << export_macro_.c_str () << " " << lname + << "_exec_i" << be_idt_nl + << ": public virtual " << lname << "_Exec," << be_idt_nl + << "public virtual ::CORBA::LocalObject" + << be_uidt << be_uidt_nl + << "{" << be_nl + << "public:" << be_idt_nl; + + os_ << lname << "_exec_i (void);"; + + os_ << be_nl + << "virtual ~" << lname << "_exec_i (void);"; + + os_ << be_nl << be_nl + << "// Supported operations and attributes."; + + int status = + node->traverse_inheritance_graph ( + be_interface::op_attr_decl_helper, + &os_, + false, + false); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_executor_exh::") + ACE_TEXT ("visit_component - ") + ACE_TEXT ("traverse_inheritance_graph() ") + ACE_TEXT ("failed\n")), + -1); + } + + os_ << be_nl << be_nl + << "// Component attributes and port operations."; + + status = this->visit_component_scope (node); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_facet_exh::") + ACE_TEXT ("visit_component - ") + ACE_TEXT ("visit_component_scope() ") + ACE_TEXT ("failed\n")), + -1); + } + + os_ << be_nl << be_nl + << "// Operations from Components::SessionComponent."; + + os_ << be_nl << be_nl + << "virtual void" << be_nl + << "set_session_context (" << be_idt_nl + << "::Components::SessionContext_ptr ctx);" << be_uidt; + + os_ << be_nl << be_nl + << "virtual void configuration_complete (void);"; + + os_ << be_nl << be_nl + << "virtual void ccm_activate (void);" << be_nl + << "virtual void ccm_passivate (void);" << be_nl + << "virtual void ccm_remove (void);"; + + os_ << be_uidt_nl << be_nl + << "private:" << be_idt_nl + << global << sname << "::CCM_" << lname + << "_Context_var context_;" + << be_uidt_nl + << "};"; + + return 0; +} + +int +be_visitor_executor_exh::visit_provides (be_provides *node) +{ + be_type *impl = node->provides_type (); + const char *port_name = node->local_name ()->get_string (); + + AST_Decl *scope = ScopeAsDecl (impl->defined_in ()); + ACE_CString sname_str (scope->full_name ()); + const char *sname = sname_str.c_str (); + + // No '_cxx_' prefix. + const char *lname = + impl->original_local_name ()->get_string (); + + const char *global = (sname_str == "" ? "" : "::"); + + os_ << be_nl << be_nl + << "virtual " << global << sname << "::CCM_" + << lname << "_ptr" << be_nl + << "get_" << port_name << " (void);"; + + return 0; +} + +int +be_visitor_executor_exh::visit_consumes (be_consumes *node) +{ + const char *obj_name = + node->consumes_type ()->full_name (); + + const char *port_name = + node->local_name ()->get_string (); + + os_ << be_nl << be_nl + << "virtual void" << be_nl + << "push_" << port_name << " (" << be_idt_nl + << "::" << obj_name << " * ev);" << be_uidt; + + return 0; +} + diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/executor_exs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/executor_exs.cpp new file mode 100644 index 00000000000..ad4467628e8 --- /dev/null +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/executor_exs.cpp @@ -0,0 +1,240 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// executor_exs.cpp +// +// = DESCRIPTION +// Visitor generating code in the exec impl source. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +be_visitor_executor_exs::be_visitor_executor_exs ( + be_visitor_context *ctx) + : be_visitor_component_scope (ctx), + op_scope_ (0), + comment_border_ ("//==============================" + "=============================="), + your_code_here_ ("/* Your code here. */") +{ +} + +be_visitor_executor_exs::~be_visitor_executor_exs (void) +{ +} + +int +be_visitor_executor_exs::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_exs v (this->ctx_); + v.scope (op_scope_); + return v.visit_operation (node); +} + +int +be_visitor_executor_exs::visit_attribute (be_attribute *node) +{ + be_visitor_attribute v (this->ctx_); + v.op_scope (op_scope_); + return v.visit_attribute (node); +} + +int +be_visitor_executor_exs::visit_component (be_component *node) +{ + // In the interest of pretty formatting, if we have generated + // at least one facet executor impl class, add a linebreak. + 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) + { + os_ << be_nl; + break; + } + } + + node_ = node; + + const char *lname = node->local_name (); + + os_ << be_nl + << comment_border_ << be_nl + << "// Component Executor Implementation Class: " + << lname << "_exec_i" << be_nl + << comment_border_; + + os_ << be_nl << be_nl + << lname << "_exec_i::" << lname << "_exec_i (void)" << be_nl + << "{" << be_nl + << "}"; + + os_ << be_nl << be_nl + << lname << "_exec_i::~" << lname << "_exec_i (void)" << be_nl + << "{" << be_nl + << "}"; + + os_ << be_nl << be_nl + << "// Supported operations and attributes."; + + 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_Exec_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, + ACE_TEXT ("be_visitor_executor_exs::") + ACE_TEXT ("visit_component - ") + ACE_TEXT ("traverse_inheritance_graph() ") + ACE_TEXT ("failed\n")), + -1); + } + + os_ << be_nl << be_nl + << "// Component attributes and port operations."; + + if (this->visit_component_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_component_exs::") + ACE_TEXT ("visit_component - ") + ACE_TEXT ("scope traversal failed\n")), + -1); + } + + os_ << be_nl << be_nl + << "// Operations from Components::SessionComponent."; + + AST_Decl *scope = ScopeAsDecl (node->defined_in ()); + ACE_CString sname_str (scope->full_name ()); + const char *sname = sname_str.c_str (); + const char *global = (sname_str == "" ? "" : "::"); + + os_ << be_nl << be_nl + << "void" << be_nl + << lname << "_exec_i::set_session_context (" << be_idt_nl + << "::Components::SessionContext_ptr ctx)" << be_uidt_nl + << "{" << be_idt_nl + << "this->context_ =" << be_idt_nl + << global << sname << "::CCM_" << lname + << "_Context::_narrow (ctx);" << be_uidt_nl << be_nl + << "if ( ::CORBA::is_nil (this->context_.in ()))" << be_idt_nl + << "{" << be_idt_nl + << "throw ::CORBA::INTERNAL ();" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}"; + + os_ << be_nl << be_nl + << "void" << be_nl + << lname << "_exec_i::configuration_complete (void)" + << be_nl + << "{" << be_idt_nl + << your_code_here_ << be_uidt_nl + << "}"; + + os_ << be_nl << be_nl + << "void" << be_nl + << lname << "_exec_i::ccm_activate (void)" << be_nl + << "{" << be_idt_nl + << your_code_here_ << be_uidt_nl + << "}"; + + os_ << be_nl << be_nl + << "void" << be_nl + << lname << "_exec_i::ccm_passivate (void)" << be_nl + << "{" << be_idt_nl + << your_code_here_ << be_uidt_nl + << "}"; + + os_ << be_nl << be_nl + << "void" << be_nl + << lname << "_exec_i::ccm_remove (void)" << be_nl + << "{" << be_idt_nl + << your_code_here_ << be_uidt_nl + << "}"; + + return 0; +} + +int +be_visitor_executor_exs::visit_provides (be_provides *node) +{ + be_type *obj = node->provides_type (); + 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 (); + const char *global = (sname_str == "" ? "" : "::"); + + // No '_cxx_' prefix. + const char *lname = obj->original_local_name ()->get_string (); + + os_ << be_nl << be_nl + << global << sname << "::CCM_" << lname + << "_ptr" << be_nl + << node_->local_name () << "_exec_i::get_" + << port_name << " (void)" << be_nl + << "{" << be_idt_nl + << your_code_here_ << be_nl + << "return " << global << sname << "::CCM_" + << lname << "::_nil ();" << be_uidt_nl + << "}"; + + return 0; +} + +int +be_visitor_executor_exs::visit_consumes (be_consumes *node) +{ + be_eventtype *obj = node->consumes_type (); + const char *port_name = node->local_name ()->get_string (); + + os_ << be_nl << be_nl + << "void" << be_nl + << node_->original_local_name () << "_exec_i::push_" + << port_name << " (" << be_idt_nl + << "::" << IdentifierHelper::orig_sn (obj->name (), false).c_str () + << " * /* ev */)" << be_uidt_nl + << "{" << be_idt_nl + << your_code_here_ << be_uidt_nl + << "}"; + + return 0; +} + diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/facet_ex_idl.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_ex_idl.cpp index bfc9143f120..7bf8ebe2328 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_component/facet_ex_idl.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_ex_idl.cpp @@ -31,8 +31,7 @@ be_visitor_facet_ex_idl::~be_visitor_facet_ex_idl (void) int be_visitor_facet_ex_idl::visit_provides (be_provides *node) { - be_type *impl = - be_type::narrow_from_decl (node->provides_type ()); + be_type *impl = node->provides_type (); if (impl->ex_idl_facet_gen ()) { diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/facet_exh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_exh.cpp new file mode 100644 index 00000000000..5a38a9c7332 --- /dev/null +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_exh.cpp @@ -0,0 +1,93 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// facet_exh.cpp +// +// = DESCRIPTION +// Visitor generating code for facets in the exec impl header. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +be_visitor_facet_exh::be_visitor_facet_exh ( + be_visitor_context *ctx) + : be_visitor_component_scope (ctx) +{ + // This is initialized in the base class to svnt_export_macro() + // or skel_export_macro(), since there are many more visitor + // classes generating servant code. So we can just override + // all that here. + export_macro_ = be_global->exec_export_macro (); +} + +be_visitor_facet_exh::~be_visitor_facet_exh (void) +{ +} + +int +be_visitor_facet_exh::visit_provides (be_provides *node) +{ + be_type *impl = node->provides_type (); + + // We don't want a '_cxx_' prefix here. + const char *lname = + impl->original_local_name ()->get_string (); + + AST_Decl *s = ScopeAsDecl (impl->defined_in ()); + ACE_CString sname_str = + IdentifierHelper::orig_sn (s->name (), false); + const char *sname = sname_str.c_str (); + const char *global = (sname_str == "" ? "" : "::"); + + os_ << be_nl + << "class " << export_macro_.c_str () << " " + << lname << "_exec_i" << be_idt_nl + << ": public virtual " << global << sname << "::CCM_" + << lname << "," << be_idt_nl + << "public virtual ::CORBA::LocalObject" + << be_uidt << be_uidt_nl + << "{" << be_nl + << "public:" << be_idt_nl + << lname << "_exec_i (void);" << be_nl + << "virtual ~" << lname << "_exec_i (void);"; + + if (impl->node_type () == AST_Decl::NT_interface) + { + be_interface *intf = + be_interface::narrow_from_decl (impl); + + os_ << be_nl << be_nl + << "// Operations and attributes from ::" + << intf->full_name (); + + int status = + intf->traverse_inheritance_graph ( + be_interface::op_attr_decl_helper, + &os_); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_facet_exh::") + ACE_TEXT ("visit_provides - ") + ACE_TEXT ("traverse_inheritance_graph() ") + ACE_TEXT ("failed\n")), + -1); + } + } + + os_ << be_uidt_nl + << "};" << be_nl; + + return 0; +} + diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/facet_exs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_exs.cpp new file mode 100644 index 00000000000..7e097ed3302 --- /dev/null +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/facet_exs.cpp @@ -0,0 +1,135 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// facet_exs.cpp +// +// = DESCRIPTION +// Visitor generating code for facets in the exec impl source. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +be_visitor_facet_exs::be_visitor_facet_exs ( + be_visitor_context *ctx) + : be_visitor_component_scope (ctx), + op_scope_ (0), + comment_border_ ("//==============================" + "=============================="), + your_code_here_ ("/* Your code here. */") +{ +} + +be_visitor_facet_exs::~be_visitor_facet_exs (void) +{ +} + +int +be_visitor_facet_exs::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_exs v (this->ctx_); + v.scope (op_scope_); + return v.visit_operation (node); +} + +int +be_visitor_facet_exs::visit_attribute (be_attribute *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_attribute v (this->ctx_); + v.op_scope (op_scope_); + return v.visit_attribute (node); +} + +int +be_visitor_facet_exs::visit_provides (be_provides *node) +{ + be_type *impl = node->provides_type (); + + // We don't want any '_cxx_' prefix here. + const char *lname = + impl->original_local_name ()->get_string (); + + os_ << be_nl + << comment_border_ << be_nl + << "// Facet Executor Implementation Class: " + << lname << "_exec_i" << be_nl + << comment_border_; + + os_ << be_nl << be_nl + << lname << "_exec_i::" << lname + << "_exec_i (void)" << be_nl + << "{" << be_nl + << "}"; + + os_ << be_nl << be_nl + << lname << "_exec_i::~" << lname + << "_exec_i (void)" << be_nl + << "{" << be_nl + << "}"; + + if (impl->node_type () == AST_Decl::NT_interface) + { + be_interface *intf = + be_interface::narrow_from_decl (impl); + + op_scope_ = intf; + + os_ << be_nl << be_nl + << "// Operations from ::" << intf->full_name (); + + /// The overload of traverse_inheritance_graph() used here + /// doesn't automatically prime the queues. + intf->get_insert_queue ().reset (); + intf->get_del_queue ().reset (); + intf->get_insert_queue ().enqueue_tail (intf); + + Component_Exec_Op_Attr_Generator op_attr_gen (this); + + int status = + intf->traverse_inheritance_graph (op_attr_gen, + &os_, + false, + false); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_facet_exs::") + ACE_TEXT ("visit_provides - ") + ACE_TEXT ("traverse_inheritance_graph() ") + ACE_TEXT ("failed\n")), + -1); + } + } + + return 0; +} + diff --git a/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svh.cpp index 599c6ab5cde..16a87f76e1e 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svh.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svh.cpp @@ -82,7 +82,7 @@ be_visitor_servant_svh::visit_component (be_component *node) int status = node_->traverse_inheritance_graph ( - be_interface::facet_op_attr_decl_helper, + be_interface::op_attr_decl_helper, &os_, false, false); 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 index 63de03b1fd1..a0d07860624 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svs.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_component/servant_svs.cpp @@ -240,7 +240,6 @@ be_visitor_servant_svs::visit_operation (be_operation *node) } be_visitor_operation_svs v (this->ctx_); - v.for_facets (false); v.scope (this->op_scope_); return v.visit_operation (node); diff --git a/modules/TAO/TAO_IDL/be/be_visitor_interface/interface_svs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_interface/interface_svs.cpp index eff1c1316ac..f249b93d711 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_interface/interface_svs.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_interface/interface_svs.cpp @@ -61,7 +61,6 @@ int be_visitor_interface_svs::visit_operation (be_operation *node) { be_visitor_operation_svs v (this->ctx_); - v.for_facets (true); v.scope (be_interface::narrow_from_decl (this->ctx_->scope ())); return v.visit_operation (node); diff --git a/modules/TAO/TAO_IDL/be/be_visitor_operation/operation_exs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_operation/operation_exs.cpp index 450554e9e55..ca4b7c9f9da 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_operation/operation_exs.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_operation/operation_exs.cpp @@ -18,14 +18,6 @@ // // ============================================================================ -ACE_RCSID (be_visitor_operation, - operation_exs, - "$Id$") - -// ************************************************************ -// Operation visitor for CIAO executor implementations -// ************************************************************ - be_visitor_operation_exs::be_visitor_operation_exs (be_visitor_context *ctx) : be_visitor_scope (ctx), os_ (*ctx->stream ()), diff --git a/modules/TAO/TAO_IDL/be/be_visitor_operation/operation_svs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_operation/operation_svs.cpp index 3a33a0f72e1..cce85a96209 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_operation/operation_svs.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_operation/operation_svs.cpp @@ -18,18 +18,10 @@ // // ============================================================================ -ACE_RCSID (be_visitor_operation, - operation_svs, - "$Id$") - -// ************************************************************ -// Operation visitor for CIAO servant implementations -// ************************************************************ - -be_visitor_operation_svs::be_visitor_operation_svs (be_visitor_context *ctx) +be_visitor_operation_svs::be_visitor_operation_svs ( + be_visitor_context *ctx) : be_visitor_scope (ctx), scope_ (0), - for_facets_ (false), swapping_ (be_global->gen_component_swapping ()) { } @@ -174,12 +166,6 @@ be_visitor_operation_svs::post_process (be_decl *bd) } void -be_visitor_operation_svs::for_facets (bool val) -{ - this->for_facets_ = val; -} - -void be_visitor_operation_svs::scope (be_interface *node) { this->scope_ = node; diff --git a/modules/TAO/TAO_IDL/be_include/be_attribute.h b/modules/TAO/TAO_IDL/be_include/be_attribute.h index d1a3526208a..64ccd06f370 100644 --- a/modules/TAO/TAO_IDL/be_include/be_attribute.h +++ b/modules/TAO/TAO_IDL/be_include/be_attribute.h @@ -34,15 +34,16 @@ class be_attribute : public virtual AST_Attribute, { public: be_attribute (void); - // Default constructor. be_attribute (bool ro, AST_Type *ft, UTL_ScopedName *n, bool local, bool abstract); - // Constructor. + // Non-virtual override of frontend method. + be_type *field_type (void) const; + // Visiting. virtual int accept (be_visitor *visitor); diff --git a/modules/TAO/TAO_IDL/be_include/be_component.h b/modules/TAO/TAO_IDL/be_include/be_component.h index a682a141491..ff27ae29b08 100644 --- a/modules/TAO/TAO_IDL/be_include/be_component.h +++ b/modules/TAO/TAO_IDL/be_include/be_component.h @@ -46,7 +46,7 @@ public: be_component *base_component (void) const; // Override of the AST method to eliminate narrowing of - // the return value. + // the return value. Non-virtual. virtual void redefine (AST_Interface *from); // Catch BE-specific members before delegating to the base class. diff --git a/modules/TAO/TAO_IDL/be_include/be_consumes.h b/modules/TAO/TAO_IDL/be_include/be_consumes.h index a306d4dc385..d03f1bf61d9 100644 --- a/modules/TAO/TAO_IDL/be_include/be_consumes.h +++ b/modules/TAO/TAO_IDL/be_include/be_consumes.h @@ -20,8 +20,11 @@ public: virtual ~be_consumes (void); + // Non-virtual override of frontend method. + be_eventtype *consumes_type (void) const; + // Narrowing. - DEF_NARROW_FROM_DECL(be_consumes); + DEF_NARROW_FROM_DECL (be_consumes); // Visiting. virtual int accept (be_visitor *visitor); diff --git a/modules/TAO/TAO_IDL/be_include/be_emits.h b/modules/TAO/TAO_IDL/be_include/be_emits.h index 509ff5361de..370b5263954 100644 --- a/modules/TAO/TAO_IDL/be_include/be_emits.h +++ b/modules/TAO/TAO_IDL/be_include/be_emits.h @@ -20,8 +20,11 @@ public: virtual ~be_emits (void); + // Non-virtual override of frontend method. + be_eventtype *emits_type (void) const; + // Narrowing. - DEF_NARROW_FROM_DECL(be_emits); + DEF_NARROW_FROM_DECL (be_emits); // Visiting. virtual int accept (be_visitor *visitor); diff --git a/modules/TAO/TAO_IDL/be_include/be_field.h b/modules/TAO/TAO_IDL/be_include/be_field.h index 610cd6e848c..9e06830d94a 100644 --- a/modules/TAO/TAO_IDL/be_include/be_field.h +++ b/modules/TAO/TAO_IDL/be_include/be_field.h @@ -38,6 +38,9 @@ public: UTL_ScopedName *n, Visibility vis = vis_NA); + // Non-virtual override of frontend method. + be_type *field_type (void) const; + // Generate debugging ostream operator for members. void gen_member_ostream_operator (TAO_OutStream *os, const char *instance_name, diff --git a/modules/TAO/TAO_IDL/be_include/be_interface.h b/modules/TAO/TAO_IDL/be_include/be_interface.h index 1453c13461a..698601849c0 100644 --- a/modules/TAO/TAO_IDL/be_include/be_interface.h +++ b/modules/TAO/TAO_IDL/be_include/be_interface.h @@ -285,9 +285,9 @@ public: /// Helper method passed to traverse_inheritance_graph(), /// collects supported operations and attributes. - static int facet_op_attr_decl_helper (be_interface *node, - be_interface *base, - TAO_OutStream *os); + static int op_attr_decl_helper (be_interface *node, + be_interface *base, + TAO_OutStream *os); int gen_operation_table (const char *flat_name, const char *skeleton_class_name); diff --git a/modules/TAO/TAO_IDL/be_include/be_provides.h b/modules/TAO/TAO_IDL/be_include/be_provides.h index 48078440ada..317f597f76a 100644 --- a/modules/TAO/TAO_IDL/be_include/be_provides.h +++ b/modules/TAO/TAO_IDL/be_include/be_provides.h @@ -21,6 +21,9 @@ public: virtual ~be_provides (void); + // Non-virtual override of frontend method. + be_type *provides_type (void) const; + // Common code called by visitors. int gen_facet_svnt_decl (TAO_OutStream &os); int gen_facet_svnt_defn (TAO_OutStream &os); diff --git a/modules/TAO/TAO_IDL/be_include/be_publishes.h b/modules/TAO/TAO_IDL/be_include/be_publishes.h index 96579fb6697..b9ea0e185e6 100644 --- a/modules/TAO/TAO_IDL/be_include/be_publishes.h +++ b/modules/TAO/TAO_IDL/be_include/be_publishes.h @@ -20,6 +20,9 @@ public: virtual ~be_publishes (void); + // Non-virtual override of frontend method. + be_eventtype *publishes_type (void) const; + // Narrowing. DEF_NARROW_FROM_DECL(be_publishes); diff --git a/modules/TAO/TAO_IDL/be_include/be_sequence.h b/modules/TAO/TAO_IDL/be_include/be_sequence.h index 598f89a679e..70c27400f61 100644 --- a/modules/TAO/TAO_IDL/be_include/be_sequence.h +++ b/modules/TAO/TAO_IDL/be_include/be_sequence.h @@ -63,6 +63,9 @@ public: bool local, bool abstract); + // Non-virtual override of frontend method. + be_type *base_type (void) const; + virtual int create_name (be_typedef *node); // Create a name for ourselves. If we are typedefed, then we get the name of // the typedef node, else we generate a name for ourselves. diff --git a/modules/TAO/TAO_IDL/be_include/be_uses.h b/modules/TAO/TAO_IDL/be_include/be_uses.h index 3a0fa8b6460..ca8cc8c83ac 100644 --- a/modules/TAO/TAO_IDL/be_include/be_uses.h +++ b/modules/TAO/TAO_IDL/be_include/be_uses.h @@ -21,6 +21,9 @@ public: virtual ~be_uses (void); + // Non-virtual override of frontend method. + be_type *uses_type (void) const; + // Narrowing. DEF_NARROW_FROM_DECL(be_uses); 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 4a008f7c9fe..bd65fdcacee 100644 --- a/modules/TAO/TAO_IDL/be_include/be_visitor_component.h +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component.h @@ -47,7 +47,11 @@ #include "be_visitor_component/executor_ex_idl.h" #include "be_visitor_component/context_ex_idl.h" #include "be_visitor_component/component_exh.h" +#include "be_visitor_component/facet_exh.h" +#include "be_visitor_component/executor_exh.h" #include "be_visitor_component/component_exs.h" +#include "be_visitor_component/facet_exs.h" +#include "be_visitor_component/executor_exs.h" #include "be_visitor_component/any_op_ch.h" #include "be_visitor_component/any_op_cs.h" #include "be_visitor_component/cdr_op_ch.h" diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component.h index 1bb54989a6a..8991bb75fb4 100644 --- a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component.h +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component.h @@ -36,10 +36,8 @@ class be_visitor_component : public be_visitor_interface public: be_visitor_component (be_visitor_context *ctx); - // constructor ~be_visitor_component (void); - // destructor virtual int visit_attribute (be_attribute *node); // This is the only type of declaration a component may contain. diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_exh.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_exh.h index 6f97ad9725f..48020c07bca 100644 --- a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_exh.h +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_exh.h @@ -22,14 +22,16 @@ #ifndef _BE_COMPONENT_COMPONENT_EXH_H_ #define _BE_COMPONENT_COMPONENT_EXH_H_ -class be_visitor_component_exh : public be_visitor_component +class be_visitor_component_exh + : public be_visitor_component_scope { // // = TITLE // be_visitor_component_exh // // = DESCRIPTION - // This is a concrete visitor to generate the servant header for component. + // This is a concrete visitor to generate + // the executor implementation header for components. // // public: @@ -38,43 +40,6 @@ public: ~be_visitor_component_exh (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); - - int gen_facet_ops_attrs (be_interface *node); - - int gen_exec_class (void); - - int gen_component_attrs_r (AST_Component *node); - - void gen_provides_r (AST_Component *node); - - void gen_provides (AST_Type *obj, - const char *port_name); - - void gen_consumes_r (AST_Component *node); - - void gen_consumes (const char *obj_name, - const char *port_name); - - /// Base class overrides and CIAO-specific code. - void gen_non_type_specific (void); - - void gen_entrypoint (void); - - /// Helper method passed to traverse_inheritance_graph(), - /// collects supported operations and attributes. - static int op_attr_decl_helper (be_interface *, - be_interface *, - TAO_OutStream *); - -private: - be_component *node_; - TAO_OutStream &os_; - ACE_CString export_macro_; }; #endif /* _BE_COMPONENT_COMPONENT_EXH_H_ */ diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_exs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_exs.h index f92b3fa6ed6..2f40c66ea7b 100644 --- a/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_exs.h +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/component_exs.h @@ -22,7 +22,8 @@ #ifndef _BE_COMPONENT_COMPONENT_EXS_H_ #define _BE_COMPONENT_COMPONENT_EXS_H_ -class be_visitor_component_exs : public be_visitor_component +class be_visitor_component_exs + : public be_visitor_component_scope { // // = TITLE @@ -39,44 +40,14 @@ public: ~be_visitor_component_exs (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); - - int gen_facet_ops_attrs (be_interface *node); - - int gen_exec_class (void); - - int gen_component_attrs_r (AST_Component *node); - - void gen_provides_r (AST_Component *node); - - void gen_provides (AST_Type *obj, - Identifier *port_id); - - void gen_consumes_r (AST_Component *node); - - void gen_consumes (AST_Type *obj, - Identifier *port_id); - - /// Base class overrides and CIAO-specific code. - void gen_non_type_specific (void); - - void gen_entrypoint (void); - -private: - be_component *node_; - be_interface *op_scope_; - TAO_OutStream &os_; - const char *comment_border_; - const char *your_code_here_; - ACE_CString export_macro_; }; +// ============================================= + /// Worker class passed to traverse_inheritance_graph(), -/// collects supported operations and attributes. +/// collects supported operations and attributes. Not used +/// by this visitor but by 2 visitors spawned from this one, +/// hence the central location for the code. class Component_Exec_Op_Attr_Generator : public TAO_IDL_Inheritance_Hierarchy_Worker { diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/executor_exh.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/executor_exh.h new file mode 100644 index 00000000000..641d1c9cf74 --- /dev/null +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/executor_exh.h @@ -0,0 +1,48 @@ +// +// $Id$ +// +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// executor_exh.h +// +// = DESCRIPTION +// This provides code generation in the exec impl header, +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#ifndef _BE_COMPONENT_EXECUTOR_EXH_H_ +#define _BE_COMPONENT_EXECUTOR_EXH_H_ + +class be_visitor_executor_exh + : public be_visitor_component_scope +{ + // + // = TITLE + // be_visitor_executor_exh + // + // = DESCRIPTION + // This is a concrete visitor to generate + // the executor implementation class declaration. + // + // +public: + be_visitor_executor_exh (be_visitor_context *ctx); + + ~be_visitor_executor_exh (void); + + virtual int visit_attribute (be_attribute *node); + virtual int visit_component (be_component *node); + virtual int visit_provides (be_provides *node); + virtual int visit_consumes (be_consumes *node); +}; + +#endif /* _BE_COMPONENT_EXECUTOR_EXH_H_ */ + diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/executor_exs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/executor_exs.h new file mode 100644 index 00000000000..bd8c6871dfa --- /dev/null +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/executor_exs.h @@ -0,0 +1,54 @@ +// +// $Id$ +// +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// executor_exs.h +// +// = DESCRIPTION +// This provides code generation in the exec impl source. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#ifndef _BE_COMPONENT_EXECUTOR_EXS_H_ +#define _BE_COMPONENT_EXECUTOR_EXS_H_ + +class be_visitor_executor_exs + : public be_visitor_component_scope +{ + // + // = TITLE + // be_visitor_executor_exs + // + // = DESCRIPTION + // This is a concrete visitor to generate + // the executor implementation source. + // + // +public: + be_visitor_executor_exs (be_visitor_context *ctx); + + ~be_visitor_executor_exs (void); + + virtual int visit_operation (be_operation *node); + virtual int visit_attribute (be_attribute *node); + virtual int visit_component (be_component *node); + virtual int visit_provides (be_provides *node); + virtual int visit_consumes (be_consumes *node); + +private: + be_interface *op_scope_; + const char *comment_border_; + const char *your_code_here_; +}; + +#endif /* _BE_COMPONENT_EXECUTOR_EXS_H_ */ + diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_exh.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_exh.h new file mode 100644 index 00000000000..972ac12fcf3 --- /dev/null +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_exh.h @@ -0,0 +1,45 @@ +// +// $Id$ +// +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// facet_exh.h +// +// = DESCRIPTION +// This provides code generation for facets in the exec impl header, +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#ifndef _BE_COMPONENT_FACET_EXH_H_ +#define _BE_COMPONENT_FACET_EXH_H_ + +class be_visitor_facet_exh + : public be_visitor_component_scope +{ + // + // = TITLE + // be_visitor_facet_exh + // + // = DESCRIPTION + // This is a concrete visitor to generate + // the executor implementation header for facets. + // + // +public: + be_visitor_facet_exh (be_visitor_context *ctx); + + ~be_visitor_facet_exh (void); + + virtual int visit_provides (be_provides *node); +}; + +#endif /* _BE_COMPONENT_FACET_EXH_H_ */ + diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_exs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_exs.h new file mode 100644 index 00000000000..4a0966f233f --- /dev/null +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_component/facet_exs.h @@ -0,0 +1,52 @@ +// +// $Id$ +// +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO_IDL_BE +// +// = FILENAME +// facet_exs.h +// +// = DESCRIPTION +// This provides code generation for facets in the exec impl source. +// +// = AUTHOR +// Jeff Parsons +// +// ============================================================================ + +#ifndef _BE_COMPONENT_FACET_EXS_H_ +#define _BE_COMPONENT_FACET_EXS_H_ + +class be_visitor_facet_exs + : public be_visitor_component_scope +{ + // + // = TITLE + // be_visitor_facet_exs + // + // = DESCRIPTION + // This is a concrete visitor to generate + // the executor implementation source for facets. + // + // +public: + be_visitor_facet_exs (be_visitor_context *ctx); + + ~be_visitor_facet_exs (void); + + virtual int visit_operation (be_operation *node); + virtual int visit_attribute (be_attribute *node); + virtual int visit_provides (be_provides *node); + +private: + be_interface *op_scope_; + const char *comment_border_; + const char *your_code_here_; +}; + +#endif /* _BE_COMPONENT_FACET_EXS_H_ */ + diff --git a/modules/TAO/TAO_IDL/be_include/be_visitor_operation/operation_svs.h b/modules/TAO/TAO_IDL/be_include/be_visitor_operation/operation_svs.h index 7a75ecf2b39..80110eaa08d 100644 --- a/modules/TAO/TAO_IDL/be_include/be_visitor_operation/operation_svs.h +++ b/modules/TAO/TAO_IDL/be_include/be_visitor_operation/operation_svs.h @@ -47,7 +47,6 @@ public: virtual int post_process (be_decl *bd); - void for_facets (bool val); void scope (be_interface *node); private: @@ -55,7 +54,6 @@ private: private: be_interface *scope_; - bool for_facets_; bool swapping_; }; |