2 //=============================================================================
6 * Visitor generating code for homes in the exec impl header.
10 //=============================================================================
14 be_visitor_home_exh::be_visitor_home_exh (be_visitor_context
*ctx
)
15 : be_visitor_scope (ctx
),
18 os_ (*ctx
->stream ()),
19 export_macro_ (be_global
->exec_export_macro ())
23 be_visitor_home_exh::~be_visitor_home_exh ()
28 be_visitor_home_exh::visit_home (be_home
*node
)
30 if (node
->imported ())
36 comp_
= node_
->managed_component ();
38 /// Use 'CIAO_' + component's flat name.
40 << "namespace CIAO_" << comp_
->flat_name () << "_Impl" << be_nl
43 if (this->gen_exec_class () == -1)
45 ACE_ERROR_RETURN ((LM_ERROR
,
46 ACE_TEXT ("be_visitor_home_exh::")
47 ACE_TEXT ("visit_home - ")
48 ACE_TEXT ("gen_servant_class() failed\n")),
52 this->gen_entrypoint ();
61 be_visitor_home_exh::visit_operation (be_operation
*node
)
63 be_visitor_operation_ch
v (this->ctx_
);
64 return v
.visit_operation (node
);
68 be_visitor_home_exh::visit_attribute (be_attribute
*node
)
70 be_visitor_attribute
v (this->ctx_
);
71 return v
.visit_attribute (node
);
75 be_visitor_home_exh::visit_factory (be_factory
*node
)
78 << "/// @copydoc " << node
->full_name () << be_nl
79 << "virtual ::Components::EnterpriseComponent_ptr" << be_nl
80 << node
->local_name ();
82 // We can reuse this visitor.
83 be_visitor_valuetype_init_arglist_ch
v (this->ctx_
);
85 if (v
.visit_factory (node
) != 0)
87 ACE_ERROR_RETURN ((LM_ERROR
,
88 ACE_TEXT ("be_visitor_home_exh::")
89 ACE_TEXT ("visit_factory - ")
90 ACE_TEXT ("codegen for argument ")
91 ACE_TEXT ("list failed\n")),
101 be_visitor_home_exh::gen_exec_class ()
103 // We don't want a '_cxx_' prefix here.
105 node_
->original_local_name ()->get_string ();
109 << " * Home Executor Implementation Class: "
110 << lname
<< "_exec_i" << be_nl
112 << "class " << export_macro_
.c_str () << " " << lname
113 << "_exec_i" << be_idt_nl
114 << ": public virtual " << lname
<< "_Exec," << be_idt_nl
115 << "public virtual ::CORBA::LocalObject"
116 << be_uidt
<< be_uidt_nl
118 << "public:" << be_idt
;
121 << "/// Constructor" << be_nl
122 << lname
<< "_exec_i ();";
125 << "/// Destructor" << be_nl
126 << "virtual ~" << lname
<< "_exec_i ();";
132 if (this->visit_scope (h
) != 0)
134 ACE_ERROR_RETURN ((LM_ERROR
,
135 ACE_TEXT ("be_visitor_home_exh::")
136 ACE_TEXT ("gen_exec_class - ")
137 ACE_TEXT ("visit_scope() failed\n")),
141 for (long i
= 0; i
< h
->n_inherits (); ++i
)
143 // A closure of all the supported interfaces is stored
144 // in the base class 'pd_inherits_flat' member.
146 dynamic_cast<be_interface
*> (h
->inherits ()[i
]);
149 bi
->traverse_inheritance_graph (
150 be_visitor_home_exh::op_attr_decl_helper
,
155 ACE_ERROR_RETURN ((LM_ERROR
,
156 ACE_TEXT ("be_visitor_home_exh::")
157 ACE_TEXT ("gen_exec_class - ")
158 ACE_TEXT ("traverse_inheritance_graph() ")
159 ACE_TEXT ("failed on %s\n"),
165 h
= dynamic_cast<be_home
*> (h
->base_home ());
169 << "/// Factory method";
172 << "virtual ::Components::EnterpriseComponent_ptr create ();";
181 be_visitor_home_exh::gen_entrypoint ()
184 << "/// Factory method for " << node_
->full_name () << be_nl
185 << "extern \"C\" " << export_macro_
.c_str ()
186 << " ::Components::HomeExecutorBase_ptr" << be_nl
187 << "create_" << node_
->flat_name ()
192 be_visitor_home_exh::op_attr_decl_helper (be_interface
* /* derived */,
193 be_interface
*ancestor
,
196 /// We're in a static method, so we have to instantiate a temporary
197 /// visitor and context.
198 be_visitor_context ctx
;
199 ctx
.state (TAO_CodeGen::TAO_ROOT_EXH
);
201 be_visitor_home_exh
visitor (&ctx
);
203 /// Since this visitor overriddes only visit_operation() and
204 /// visit_attribute(), we can get away with this for the declarations.
205 return visitor
.visit_scope (ancestor
);