Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_component / component_svs.cpp
blobd5030f230131afe4572c817233eae330436cd942
2 //=============================================================================
3 /**
4 * @file component_svs.cpp
6 * Visitor generating code for Components in the servant source.
8 * @author Jeff Parsons
9 */
10 //=============================================================================
12 #include "component.h"
14 be_visitor_component_svs::be_visitor_component_svs (be_visitor_context *ctx)
15 : be_visitor_component (ctx),
16 os_ (*ctx->stream ()),
17 export_macro_ (be_global->svnt_export_macro ())
19 /// All existing CIAO examples set the servant export values in the CIDL
20 /// compiler to equal the IDL compiler's skel export values. Below is a
21 /// partial effort to decouple them, should be completely decoupled
22 /// sometime. See comment in codegen.cpp, line 1173.
23 if (export_macro_ == "")
25 export_macro_ = be_global->skel_export_macro ();
29 be_visitor_component_svs::~be_visitor_component_svs ()
33 int
34 be_visitor_component_svs::visit_component (be_component *node)
36 if (node->imported ())
38 return 0;
41 /// Use 'CIAO_' + component's flat name.
42 os_ << be_nl_2
43 << "namespace CIAO_" << node->flat_name ()
44 << "_Impl" << be_nl
45 << "{" << be_idt;
47 // be_visitor_context_svts context_visitor (this->ctx_);
49 // if (context_visitor.visit_component (node) == -1)
50 // {
51 // ACE_ERROR_RETURN ((LM_ERROR,
52 // ACE_TEXT ("be_visitor_component_svs::")
53 // ACE_TEXT ("visit_component - ")
54 // ACE_TEXT ("context visitor failed\n")),
55 // -1);
56 // }
58 be_visitor_servant_svs servant_visitor (this->ctx_);
60 if (servant_visitor.visit_component (node) == -1)
62 ACE_ERROR_RETURN ((LM_ERROR,
63 ACE_TEXT ("be_visitor_component_svs::")
64 ACE_TEXT ("visit_component - ")
65 ACE_TEXT ("servant visitor failed\n")),
66 -1);
69 this->gen_entrypoint (node);
71 os_ << be_uidt_nl
72 << "}";
74 return 0;
77 int
78 be_visitor_component_svs::visit_connector (be_connector *node)
80 return this->visit_component (node);
83 void
84 be_visitor_component_svs::gen_entrypoint (AST_Component *node)
86 ACE_CString sname_str (
87 ScopeAsDecl (node->defined_in ())->full_name ());
88 const char *sname = sname_str.c_str ();
89 const char *lname = node->local_name ()->get_string ();
90 const char *global = (sname_str == "" ? "" : "::");
92 os_ << be_nl_2
93 << "extern \"C\" " << export_macro_.c_str ()
94 << " ::PortableServer::Servant" << be_nl
95 << "create_" << node->flat_name ()
96 << "_Servant (" << be_idt_nl
97 << "::Components::EnterpriseComponent_ptr p," << be_nl
98 << "::CIAO::" << be_global->ciao_container_type ()
99 << "_Container_ptr c," << be_nl
100 << "const char * ins_name)" << be_uidt_nl
101 << "{" << be_idt_nl
102 << global << sname << "::CCM_" << lname
103 << "_var x =" << be_idt_nl
104 << global << sname << "::CCM_" << lname
105 << "::_narrow (p);" << be_uidt_nl << be_nl
106 << "::PortableServer::Servant retval = 0;" << be_nl
107 << "if (! ::CORBA::is_nil (x.in ()))" << be_idt_nl
108 << "{" << be_idt_nl
109 << "ACE_NEW_NORETURN (retval," << be_nl
110 << " " << lname << "_Servant (" << be_idt_nl
111 << " x.in ()," << be_nl
112 << " ::Components::CCMHome::_nil ()," << be_nl
113 << " ins_name," << be_nl
114 << " 0," << be_nl
115 << " c));" << be_uidt << be_uidt_nl
116 << "}" << be_uidt_nl << be_nl
117 << "return retval;" << be_uidt_nl
118 << "}";