2 //=============================================================================
4 * @file interface_is.cpp
6 * Visitor generating code for Interfaces in the implementation skeletons file.
8 * @author Yamuna Krishnamurthy (yamuna@cs.wustl.edu)
10 //=============================================================================
12 #include "interface.h"
14 be_visitor_interface_is::be_visitor_interface_is (be_visitor_context
*ctx
)
15 : be_visitor_interface (ctx
)
19 be_visitor_interface_is::~be_visitor_interface_is ()
24 be_visitor_interface_is::visit_interface (be_interface
*node
)
26 if (node
->impl_skel_gen () || node
->imported () || node
->is_abstract ())
31 this->ctx_
->interface (node
);
32 TAO_OutStream
*os
= this->ctx_
->stream ();
34 // Generate the skeleton class name.
36 if (be_global
->gen_impl_debug_info ())
38 TAO_INSERT_COMMENT (os
);
41 *os
<< "// Implementation skeleton constructor" << be_nl
;
43 // Find if we are at the top scope or inside some module.
44 *os
<< be_global
->impl_class_prefix () << node
->flat_name ()
45 << be_global
->impl_class_suffix () <<"::"
46 << be_global
->impl_class_prefix () << node
->flat_name ()
47 << be_global
->impl_class_suffix ()
54 *os
<< "// Implementation skeleton destructor" << be_nl
;
56 *os
<< be_global
->impl_class_prefix () << node
->flat_name ()
57 << be_global
->impl_class_suffix () <<"::~"
58 << be_global
->impl_class_prefix () << node
->flat_name ()
59 << be_global
->impl_class_suffix ()
63 *os
<< "}" << be_nl_2
;
65 if (be_global
->gen_copy_ctor () && !node
->is_local ())
67 *os
<< "//Implementation Skeleton Copy Constructor" << be_nl
;
69 *os
<< be_global
->impl_class_prefix () << node
->flat_name ()
70 << be_global
->impl_class_suffix () <<"::"
71 << be_global
->impl_class_prefix () << node
->flat_name ()
72 << be_global
->impl_class_suffix () << " (const "
73 << be_global
->impl_class_prefix () << node
->flat_name ()
74 << be_global
->impl_class_suffix () << "& rhs)" << be_idt_nl
75 << ": TAO_Abstract_ServantBase (rhs)," << be_nl
76 << " TAO_ServantBase (rhs)";
78 if (node
->traverse_inheritance_graph (be_interface::copy_ctor_helper
,
82 ACE_ERROR_RETURN ((LM_ERROR
,
83 "be_visitor_interface_is::visit_interface - "
84 " copy ctor generation failed\n"),
88 if (!node
->is_local ())
92 if (node
->is_nested ())
94 be_decl
*scope
= nullptr;
95 scope
= dynamic_cast<be_scope
*> (node
->defined_in ())->decl ();
97 *os
<< " POA_" << scope
->name () << "::"
98 << node
->local_name () << " (rhs)";
102 *os
<< " " << node
->full_skel_name () << " (rhs)";
108 << "}" << be_nl
<< be_uidt_nl
;
111 if (be_global
->gen_assign_op ())
113 *os
<< "//Implementation Skeleton Copy Assignment" << be_nl
;
115 *os
<< be_global
->impl_class_prefix () << node
->flat_name ()
116 << be_global
->impl_class_suffix () << "& "
117 << be_global
->impl_class_prefix () << node
->flat_name ()
118 << be_global
->impl_class_suffix () << "::operator=(const "
119 << be_global
->impl_class_prefix () << node
->flat_name ()
120 << be_global
->impl_class_suffix () << "& t)" <<be_idt_nl
122 << "return *this;" << be_uidt_nl
123 << "}" << be_nl
<< be_uidt_nl
;
126 // Generate code for elements in the scope (e.g., operations).
128 if (this->visit_scope (node
) == -1)
130 ACE_ERROR_RETURN ((LM_ERROR
,
131 "be_visitor_interface_is::"
133 "codegen for scope failed\n"),
138 node
->traverse_inheritance_graph (
139 be_visitor_interface_is::method_helper
,
145 ACE_ERROR_RETURN ((LM_ERROR
,
146 "be_visitor_interface_is::"
148 "traversal of inhertance graph failed\n"),
156 // Helper method to generate the members in the scope of the base classes.
158 be_visitor_interface_is::method_helper (be_interface
*derived
,
162 if (ACE_OS::strcmp (derived
->flat_name (), node
->flat_name ()) != 0)
164 be_visitor_context ctx
;
165 ctx
.state (TAO_CodeGen::TAO_ROOT_IS
);
166 ctx
.interface (derived
);
168 be_visitor_interface_is
visitor (&ctx
);
170 if (visitor
.visit_scope (node
) == -1)
173 ACE_ERROR_RETURN ((LM_ERROR
,
174 "be_visitor_interface_is::"