diff options
Diffstat (limited to 'modules/TAO/TAO_IDL/be/be_visitor_home/home_exh.cpp')
-rw-r--r-- | modules/TAO/TAO_IDL/be/be_visitor_home/home_exh.cpp | 194 |
1 files changed, 64 insertions, 130 deletions
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_home/home_exh.cpp b/modules/TAO/TAO_IDL/be/be_visitor_home/home_exh.cpp index 9ebdc43053e..c31a1546633 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_home/home_exh.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_home/home_exh.cpp @@ -84,6 +84,31 @@ be_visitor_home_exh::visit_attribute (be_attribute *node) } int +be_visitor_home_exh::visit_factory (be_factory *node) +{ + os_ << be_nl << be_nl + << "virtual ::Components::EnterpriseComponent_ptr" << be_nl + << node->local_name (); + + // We can reuse this visitor. + be_visitor_valuetype_init_arglist_ch v (this->ctx_); + + if (v.visit_factory (node) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_home_exh::") + ACE_TEXT ("visit_factory - ") + ACE_TEXT ("codegen for argument ") + ACE_TEXT ("list failed\n")), + -1); + } + + os_ << ";"; + + return 0; +} + +int be_visitor_home_exh::gen_exec_class (void) { // We don't want a '_cxx_' prefix here. @@ -105,12 +130,46 @@ be_visitor_home_exh::gen_exec_class (void) os_ << be_nl << be_nl << "virtual ~" << lname << "_exec_i (void);"; - this->gen_ops_attrs (); - - this->gen_factories (); - - this->gen_finders (); + be_home *h = node_; + while (h != 0) + { + if (this->visit_scope (h) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_home_exh::") + ACE_TEXT ("gen_exec_class - ") + ACE_TEXT ("visit_scope() failed\n")), + -1); + } + + for (long i = 0; i < h->n_inherits (); ++i) + { + // A closure of all the supported interfaces is stored + // in the base class 'pd_inherits_flat' member. + be_interface *bi = + be_interface::narrow_from_decl (h->inherits ()[i]); + + int status = + bi->traverse_inheritance_graph ( + be_visitor_home_exh::op_attr_decl_helper, + &os_); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_home_exh::") + ACE_TEXT ("gen_exec_class - ") + ACE_TEXT ("traverse_inheritance_graph() ") + ACE_TEXT ("failed on %s\n"), + bi->full_name ()), + -1); + } + } + + h = be_home::narrow_from_decl (h->base_home ()); + } + os_ << be_nl << be_nl << "// Implicit operations."; @@ -124,129 +183,6 @@ be_visitor_home_exh::gen_exec_class (void) return 0; } -int -be_visitor_home_exh::gen_ops_attrs (void) -{ - os_ << be_nl << be_nl - << "// All operations and attributes."; - - int status = - node_->traverse_inheritance_graph ( - be_visitor_home_exh::op_attr_decl_helper, - &os_); - - if (status == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_exh::") - ACE_TEXT ("gen_ops_attrs - ") - ACE_TEXT ("traverse_inheritance_graph() ") - ACE_TEXT ("failed\n")), - -1); - } - - return 0; -} - -int -be_visitor_home_exh::gen_factories (void) -{ - os_ << be_nl << be_nl - << "// Factory operations."; - - return this->gen_factories_r (node_); -} - -int -be_visitor_home_exh::gen_factories_r (AST_Home *node) -{ - if (node == 0) - { - return 0; - } - - if (this->gen_init_ops_i (node->factories ()) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_exh::") - ACE_TEXT ("gen_factories_r - ") - ACE_TEXT ("gen_init_ops_i() failed\n")), - -1); - } - - AST_Home *base = node->base_home (); - - return this->gen_factories_r (base); -} - -int -be_visitor_home_exh::gen_finders (void) -{ - os_ << be_nl << be_nl - << "// Finder operations."; - - return this->gen_finders_r (node_); -} - -int -be_visitor_home_exh::gen_finders_r (AST_Home *node) -{ - if (node == 0) - { - return 0; - } - - if (this->gen_init_ops_i (node->finders ()) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_exh::") - ACE_TEXT ("gen_finders_r - ") - ACE_TEXT ("gen_init_ops_i() failed\n")), - -1); - } - - AST_Home *base = node->base_home (); - - return this->gen_finders_r (base); -} - -int -be_visitor_home_exh::gen_init_ops_i (AST_Home::INIT_LIST & list) -{ - AST_Operation **op = 0; - - for (AST_Home::INIT_LIST::ITERATOR i = list.begin (); - !i.done (); - i.advance ()) - { - i.next (op); - be_operation *bop = be_operation::narrow_from_decl (*op); - - /// Return type for home exec factories and finders is not - /// the same as for the corresponding home servant, so we - /// generate the return type and op name by hand, then finish - /// the operation traversal with an arglist visitor. - os_ << be_nl << be_nl - << "::Components::EnterpriseComponent_ptr" << be_nl - << bop->local_name (); - - be_visitor_operation_arglist visitor (this->ctx_); - - if (visitor.visit_operation (bop) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_exh::") - ACE_TEXT ("gen_init_ops_i - ") - ACE_TEXT ("visit_operation() failed\n")), - -1); - } - - os_ << ";"; - } - - return 0; -} - void be_visitor_home_exh::gen_entrypoint (void) { @@ -273,5 +209,3 @@ be_visitor_home_exh::op_attr_decl_helper (be_interface * /* derived */, /// visit_attribute(), we can get away with this for the declarations. return visitor.visit_scope (ancestor); } - - |