diff options
Diffstat (limited to 'modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp')
-rw-r--r-- | modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp | 306 |
1 files changed, 90 insertions, 216 deletions
diff --git a/modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp b/modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp index 6d2b4e11807..43c1ffc95bc 100644 --- a/modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp +++ b/modules/TAO/TAO_IDL/be/be_visitor_home/home_svs.cpp @@ -111,19 +111,71 @@ be_visitor_home_svs::visit_argument (be_argument *node) int be_visitor_home_svs::visit_factory (be_factory *node) { - be_visitor_factory_svs v (this->ctx_, - node_, - comp_, - this->for_finder_); - - if (v.visit_factory (node) != 0) + os_ << be_nl << be_nl + << "::" << comp_->name () << "_ptr" << be_nl + << node_->original_local_name ()->get_string () + << "_Servant::" << node->local_name (); + + be_visitor_operation_arglist al_visitor (this->ctx_); + al_visitor.unused (this->for_finder_); + + if (al_visitor.visit_factory (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_svs::") - ACE_TEXT ("visit_factory - ") - ACE_TEXT ("traversal failed\n")), + "be_visitor_factory_svs::" + "visit_factory - " + "codegen for argument list failed\n"), -1); } + + os_ << be_nl + << "{" << be_idt_nl; + + if (this->for_finder_) + { + os_ << "throw ::CORBA::NO_IMPLEMENT (CORBA::OMGVMCID | 8," + << be_nl + << " CORBA::COMPLETED_NO);"; + } + else + { + ACE_CString comp_sname_str ( + ScopeAsDecl (comp_->defined_in ())->full_name ()); + const char *comp_sname = comp_sname_str.c_str (); + const char *comp_lname = comp_->local_name ()->get_string (); + const char *global = (comp_sname_str == "" ? "" : "::"); + + os_ << "::Components::EnterpriseComponent_var _ciao_ec =" + << be_idt_nl + << "this->executor_->" << node->local_name () << " ("; + + if (node->argument_count () > 0) + { + os_ << be_idt_nl; + + if (this->visit_scope (node) != 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_factory_svs::" + "visit_factory - " + "codegen for scope failed\n"), + -1); + } + + os_ << be_uidt; + } + + os_ << ");" << be_uidt_nl << be_nl + << global << comp_sname << "::CCM_" << comp_lname + << "_var _ciao_comp =" << be_idt_nl + << global << comp_sname << "::CCM_" << comp_lname + << "::_narrow (_ciao_ec.in ());" << be_uidt_nl << be_nl + << "return this->_ciao_activate_component " + << "(_ciao_comp.in ());"; + } + + os_ << be_uidt_nl + << "}"; // In case it was set for the call above. this->for_finder_ = false; @@ -236,217 +288,39 @@ be_visitor_home_svs::gen_servant_class (void) -1); } - h = be_home::narrow_from_decl (h->base_home ()); - } - -/* - this->gen_ops_attrs (); - - os_ << be_nl << be_nl - << "/// Factory operations."; - - this->gen_factories_r (node_); - - os_ << be_nl << be_nl - << "/// Finder operations."; - - this->gen_finders_r (node_); -*/ - return 0; -} - -int -be_visitor_home_svs::gen_ops_attrs (void) -{ - os_ << be_nl << be_nl - << "/// All home operations and attributes."; - - node_->get_insert_queue ().reset (); - node_->get_del_queue ().reset (); - node_->get_insert_queue ().enqueue_tail (node_); - - Home_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_home_svs::") - ACE_TEXT ("gen_ops_attrs - ") - ACE_TEXT ("traverse_inheritance_graph() ") - ACE_TEXT ("failed\n")), - -1); - } - - return 0; -} - -int -be_visitor_home_svs::gen_factories (void) -{ - return this->gen_factories_r (node_); -} - -int -be_visitor_home_svs::gen_factories_r (AST_Home *node) -{ - if (node == 0) - { - return 0; - } - - if (this->gen_init_ops (node->factories (), false) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_svs::") - 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_svs::gen_finders (void) -{ - os_ << be_nl << be_nl - << "// Finder operations."; - - return this->gen_finders_r (node_); -} - -int -be_visitor_home_svs::gen_finders_r (AST_Home *node) -{ - if (node == 0) - { - return 0; - } - - if (this->gen_init_ops (node->finders (), true) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_svs::") - 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_svs::gen_init_ops (AST_Home::INIT_LIST & list, - bool finder_list) -{ - AST_Operation **op = 0; - ACE_CString comp_sname_str ( - ScopeAsDecl (comp_->defined_in ())->full_name ()); - const char *comp_sname = comp_sname_str.c_str (); - const char *comp_lname = comp_->local_name ()->get_string (); - const char *global = (comp_sname_str == "" ? "" : "::"); - - 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); - - // Retrieve the operation return type. - be_type *bt = be_type::narrow_from_decl (bop->return_type ()); - - if (bt == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_home_svs::" - "gen_init_ops - " - "Bad return type\n"), - -1); - } - - os_ << be_nl << be_nl; - - be_visitor_operation_rettype rt_visitor (this->ctx_); - - if (bt->accept (&rt_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_home_svs::" - "gen_init_ops - " - "codegen for return type failed\n"), - -1); - } - - os_ << be_nl - << node_->original_local_name ()->get_string () - << "_Servant::" << bop->local_name (); - - be_visitor_operation_arglist al_visitor (this->ctx_); - - // Finder operations are as yet unimplemented in CIAO, so - // any args will be unused and should be commented out. - al_visitor.unused (finder_list); - - if (bop->accept (&al_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_home_svs::" - "gen_init_ops - " - "codegen for argument list failed\n"), - -1); - } - - os_ << be_nl - << "{" << be_idt_nl; - - if (finder_list) + for (long i = 0; i < h->n_inherits (); ++i) { - os_ << "throw ::CORBA::NO_IMPLEMENT ();"; - } - else - { - os_ << "::Components::EnterpriseComponent_var _ciao_ec =" - << be_idt_nl - << "this->executor_->" << bop->local_name () << " ("; - - if (bop->argument_count () != 0) + // 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]); + + bi->get_insert_queue ().reset (); + bi->get_del_queue ().reset (); + bi->get_insert_queue ().enqueue_tail (bi); + + Home_Op_Attr_Generator op_attr_gen (this); + + int status = + bi->traverse_inheritance_graph (op_attr_gen, + &os_, + false, + false); + + if (status == -1) { - os_ << be_idt_nl; - - if (this->visit_scope (bop) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("be_visitor_home_svs") - ACE_TEXT ("::gen_init_ops - ") - ACE_TEXT ("visit_scope() failed\n")), - -1); - } - - os_ << be_uidt; + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("be_visitor_home_svs::") + ACE_TEXT ("gen_servant_class - ") + ACE_TEXT ("traverse_inheritance_graph() ") + ACE_TEXT ("failed for %s\n"), + bi->full_name ()), + -1); } - os_ << ");" << be_uidt_nl << be_nl - << global << comp_sname << "::CCM_" << comp_lname - << "_var _ciao_comp =" << be_idt_nl - << global << comp_sname << "::CCM_" << comp_lname - << "::_narrow (_ciao_ec.in ());" << be_uidt_nl << be_nl - << "return this->_ciao_activate_component " - << "(_ciao_comp.in ());"; - } - - os_ << be_uidt_nl - << "}"; + } + + h = be_home::narrow_from_decl (h->base_home ()); } return 0; |