2 //=============================================================================
6 * Visitor generating code for a facet servant class in the
11 //=============================================================================
13 #include "interface.h"
15 be_visitor_facet_svts::be_visitor_facet_svts (be_visitor_context
*ctx
)
16 : be_visitor_interface (ctx
)
20 be_visitor_facet_svts::~be_visitor_facet_svts ()
25 be_visitor_facet_svts::visit_interface (be_interface
*node
)
27 if (node
->imported () ||
28 node
->svnt_src_facet_gen () ||
29 idl_global
->ami_connector_seen_
||
30 node
->original_interface () ||
36 const char *lname
= node
->local_name ();
39 dynamic_cast<be_scope
*> (node
->defined_in ())->decl ();
41 ACE_CString
sname_str (scope
->full_name ());
43 const char *global
= (sname_str
== "" ? "" : "::");
45 ACE_CString
suffix (scope
->flat_name ());
49 suffix
= ACE_CString ("_") + suffix
;
53 << "namespace CIAO_FACET" << suffix
.c_str () << be_nl
56 os_
<< "template <typename BASE, typename EXEC, typename CONTEXT>" << be_nl
57 << lname
<< "_Servant_T<BASE, EXEC, CONTEXT>::"
58 << lname
<< "_Servant_T (" << be_idt
<< be_idt_nl
59 << "typename EXEC::_ptr_type executor," << be_nl
60 << "::Components::CCMContext_ptr ctx)" << be_uidt_nl
61 << ": " << global
<< "CIAO::Facet_Servant_Base_T<BASE, EXEC, "
62 << "CONTEXT> (executor, ctx)"
67 os_
<< be_nl_2
<< "template <typename BASE, typename EXEC, typename CONTEXT>" << be_nl
68 << lname
<< "_Servant_T<BASE, EXEC, CONTEXT>::~"
69 << lname
<< "_Servant_T ()" << be_nl
73 bool is_intf
= node
->node_type () == AST_Decl::NT_interface
;
77 be_interface
*op_scope
=
78 dynamic_cast<be_interface
*> (node
);
81 << "// All facet operations and attributes.";
83 /// The overload of traverse_inheritance_graph() used here
84 /// doesn't automatically prime the queues.
85 op_scope
->get_insert_queue ().reset ();
86 op_scope
->get_del_queue ().reset ();
87 op_scope
->get_insert_queue ().enqueue_tail (op_scope
);
89 be_facet_op_attr_defn_helper
helper (op_scope
);
92 op_scope
->traverse_inheritance_graph (helper
,
99 ACE_ERROR_RETURN ((LM_ERROR
,
100 ACE_TEXT ("be_provides::")
101 ACE_TEXT ("gen_facet_svnt_defn - ")
102 ACE_TEXT ("traverse_inheritance_graph() ")
103 ACE_TEXT ("failed\n")),
108 os_
<< be_uidt_nl
<< "}";
110 node
->svnt_src_facet_gen (true);
114 // ********************************************
116 be_facet_op_attr_defn_helper::be_facet_op_attr_defn_helper (
117 be_interface
*op_scope
)
118 : op_scope_ (op_scope
)
123 be_facet_op_attr_defn_helper::emit (be_interface
* /* derived_interface */,
125 be_interface
*base_interface
)
127 AST_Decl::NodeType nt
= base_interface
->node_type ();
129 if (nt
== AST_Decl::NT_component
|| nt
== AST_Decl::NT_connector
)
134 be_visitor_context ctx
;
136 ctx
.state (TAO_CodeGen::TAO_ROOT_SVTS
);
138 for (UTL_ScopeActiveIterator
i (base_interface
, UTL_Scope::IK_decls
);
142 AST_Decl
*d
= i
.item ();
143 AST_Decl::NodeType nt
= d
->node_type ();
147 case AST_Decl::NT_op
:
150 dynamic_cast<be_operation
*> (d
);
152 /// If AMI implied IDL was generated for the
153 /// original interface, we don't want those
154 /// extra operations in the facet servant.
155 if (op
->is_sendc_ami ())
160 be_visitor_operation_svs
v (&ctx
);
163 if (v
.visit_operation (op
) == -1)
165 ACE_ERROR_RETURN ((LM_ERROR
,
166 ACE_TEXT ("be_facet_op_attr_defn_helper")
167 ACE_TEXT ("::emit - ")
168 ACE_TEXT ("visit_operation() failed\n")),
174 case AST_Decl::NT_attr
:
177 dynamic_cast<be_attribute
*> (d
);
179 be_visitor_attribute
v (&ctx
);
180 v
.op_scope (op_scope_
);
182 if (v
.visit_attribute (attr
) == -1)
184 ACE_ERROR_RETURN ((LM_ERROR
,
185 ACE_TEXT ("be_facet_op_attr_defn_helper")
186 ACE_TEXT ("::emit - ")
187 ACE_TEXT ("visit_attribute() failed\n")),
201 // ********************************************