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_assign_op ())
67 *os
<< "//Implementation Skeleton Copy Assignment" << 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 () << "::operator=(const "
73 << be_global
->impl_class_prefix () << node
->flat_name ()
74 << be_global
->impl_class_suffix () << "& t)" <<be_idt_nl
76 << "return *this;" << be_uidt_nl
77 << "}" << be_nl
<< be_uidt_nl
;
80 // Generate code for elements in the scope (e.g., operations).
82 if (this->visit_scope (node
) == -1)
84 ACE_ERROR_RETURN ((LM_ERROR
,
85 "be_visitor_interface_is::"
87 "codegen for scope failed\n"),
92 node
->traverse_inheritance_graph (
93 be_visitor_interface_is::method_helper
,
99 ACE_ERROR_RETURN ((LM_ERROR
,
100 "be_visitor_interface_is::"
102 "traversal of inhertance graph failed\n"),
110 // Helper method to generate the members in the scope of the base classes.
112 be_visitor_interface_is::method_helper (be_interface
*derived
,
116 if (ACE_OS::strcmp (derived
->flat_name (), node
->flat_name ()) != 0)
118 be_visitor_context ctx
;
119 ctx
.state (TAO_CodeGen::TAO_ROOT_IS
);
120 ctx
.interface (derived
);
122 be_visitor_interface_is
visitor (&ctx
);
124 if (visitor
.visit_scope (node
) == -1)
127 ACE_ERROR_RETURN ((LM_ERROR
,
128 "be_visitor_interface_is::"