2 //=============================================================================
6 * Visitor generating code for homes in the exec impl source.
10 //=============================================================================
14 be_visitor_home_exs::be_visitor_home_exs (be_visitor_context
*ctx
)
15 : be_visitor_scope (ctx
),
18 os_ (*ctx
->stream ()),
19 comment_start_border_ ("/**"),
20 comment_end_border_ (" */"),
21 your_code_here_ ("/* Your code here. */"),
22 export_macro_ (be_global
->exec_export_macro ())
26 be_visitor_home_exs::~be_visitor_home_exs ()
31 be_visitor_home_exs::visit_home (be_home
*node
)
33 if (node
->imported ())
39 comp_
= node_
->managed_component ();
41 /// Use 'CIAO_' + component's flat name.
43 << "namespace CIAO_" << comp_
->flat_name () << "_Impl" << be_nl
46 if (this->gen_exec_class () == -1)
48 ACE_ERROR_RETURN ((LM_ERROR
,
49 ACE_TEXT ("be_visitor_home_exs::")
50 ACE_TEXT ("visit_home - ")
51 ACE_TEXT ("gen_servant_class() failed\n")),
55 this->gen_entrypoint ();
64 be_visitor_home_exs::visit_operation (be_operation
*node
)
66 be_visitor_operation_exs
v (this->ctx_
);
68 return v
.visit_operation (node
);
72 be_visitor_home_exs::visit_attribute (be_attribute
*node
)
74 be_visitor_attribute
v (this->ctx_
);
76 return v
.visit_attribute (node
);
80 be_visitor_home_exs::visit_factory (be_factory
*node
)
82 AST_Decl
*scope
= ScopeAsDecl (comp_
->defined_in ());
83 ACE_CString
sname_str (scope
->full_name ());
84 const char *sname
= sname_str
.c_str ();
85 const char *lname
= comp_
->local_name ()->get_string ();
86 const char *global
= (sname_str
== "" ? "" : "::");
89 << "::Components::EnterpriseComponent_ptr" << be_nl
90 << node_
->original_local_name ()->get_string ()
91 << "_exec_i::" << node
->local_name ();
93 be_visitor_operation_arglist
visitor (this->ctx_
);
94 visitor
.unused (true);
96 if (visitor
.visit_factory (node
) == -1)
98 ACE_ERROR_RETURN ((LM_ERROR
,
99 ACE_TEXT ("be_visitor_home_exs::")
100 ACE_TEXT ("visit_factory - ")
101 ACE_TEXT ("codegen for arglist failed\n")),
107 << your_code_here_
<< be_nl
108 << "return " << global
<< sname
<< "::CCM_"
109 << lname
<< "::_nil ();" << be_uidt_nl
116 be_visitor_home_exs::gen_exec_class ()
118 // No '_cxx_' prefix.
120 node_
->original_local_name ()->get_string ();
123 << comment_start_border_
<< be_nl
124 << " * Home Executor Implementation Class: "
125 << lname
<< "_exec_i" << be_nl
126 << comment_end_border_
;
129 << lname
<< "_exec_i::" << lname
<< "_exec_i ()" << be_nl
134 << lname
<< "_exec_i::~" << lname
<< "_exec_i ()" << be_nl
142 if (this->visit_scope (h
) != 0)
144 ACE_ERROR_RETURN ((LM_ERROR
,
145 ACE_TEXT ("be_visitor_home_exs::")
146 ACE_TEXT ("gen_exec_class - ")
147 ACE_TEXT ("codegen for scope ")
148 ACE_TEXT ("failed\n")),
152 for (long i
= 0; i
< h
->n_inherits (); ++i
)
154 // A closure of all the supported interfaces is stored
155 // in the base class 'pd_inherits_flat' member.
157 dynamic_cast<be_interface
*> (h
->inherits ()[i
]);
159 bi
->get_insert_queue ().reset ();
160 bi
->get_del_queue ().reset ();
161 bi
->get_insert_queue ().enqueue_tail (bi
);
163 Home_Exec_Op_Attr_Generator
op_attr_gen (this);
166 bi
->traverse_inheritance_graph (op_attr_gen
,
173 ACE_ERROR_RETURN ((LM_ERROR
,
174 ACE_TEXT ("be_visitor_home_exs::")
175 ACE_TEXT ("gen_exec_class - ")
176 ACE_TEXT ("traverse_inheritance_graph() ")
177 ACE_TEXT ("failed for %s\n"),
183 h
= dynamic_cast<be_home
*> (h
->base_home ());
187 << "// Implicit operations.";
190 << "::Components::EnterpriseComponent_ptr" << be_nl
191 << lname
<< "_exec_i::create ()" << be_nl
193 << "::Components::EnterpriseComponent_ptr retval ="
195 << "::Components::EnterpriseComponent::_nil ();"
196 << be_uidt_nl
<< be_nl
197 << "ACE_NEW_THROW_EX (" << be_idt_nl
198 << "retval," << be_nl
199 << comp_
->original_local_name ()->get_string ()
200 << "_exec_i," << be_nl
201 << "::CORBA::NO_MEMORY ());"
202 << be_uidt_nl
<< be_nl
203 << "return retval;" << be_uidt_nl
210 be_visitor_home_exs::gen_entrypoint ()
213 << "extern \"C\" " << export_macro_
.c_str ()
214 << " ::Components::HomeExecutorBase_ptr" << be_nl
215 << "create_" << node_
->flat_name ()
216 << "_Impl ()" << be_nl
218 << "::Components::HomeExecutorBase_ptr retval =" << be_idt_nl
219 << "::Components::HomeExecutorBase::_nil ();"
220 << be_uidt_nl
<< be_nl
221 << "ACE_NEW_NORETURN (" << be_idt_nl
222 << "retval," << be_nl
223 << node_
->original_local_name ()->get_string ()
224 << "_exec_i);" << be_uidt_nl
<< be_nl
225 << "return retval;" << be_uidt_nl
229 Home_Exec_Op_Attr_Generator::Home_Exec_Op_Attr_Generator (
230 be_visitor_scope
* visitor
)
236 Home_Exec_Op_Attr_Generator::emit (be_interface
* /* derived_interface */,
237 TAO_OutStream
* /* os */,
238 be_interface
* base_interface
)
240 return visitor_
->visit_scope (base_interface
);