2 //=============================================================================
4 * @file component_svs.cpp
6 * Visitor generating code for Components in the servant source.
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 ()
34 be_visitor_component_svs::visit_component (be_component
*node
)
36 if (node
->imported ())
41 /// Use 'CIAO_' + component's flat name.
43 << "namespace CIAO_" << node
->flat_name ()
47 // be_visitor_context_svts context_visitor (this->ctx_);
49 // if (context_visitor.visit_component (node) == -1)
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")),
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")),
69 this->gen_entrypoint (node
);
78 be_visitor_component_svs::visit_connector (be_connector
*node
)
80 return this->visit_component (node
);
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
== "" ? "" : "::");
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
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
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
115 << " c));" << be_uidt
<< be_uidt_nl
116 << "}" << be_uidt_nl
<< be_nl
117 << "return retval;" << be_uidt_nl