Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_interface / interface_is.cpp
blob4d69dc9c88fbd6c7fd72dfaed13fccda202462e0
2 //=============================================================================
3 /**
4 * @file interface_is.cpp
6 * Visitor generating code for Interfaces in the implementation skeletons file.
8 * @author Yamuna Krishnamurthy (yamuna@cs.wustl.edu)
9 */
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 ()
23 int
24 be_visitor_interface_is::visit_interface (be_interface *node)
26 if (node->impl_skel_gen () || node->imported () || node->is_abstract ())
28 return 0;
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 ()
48 << " ()" << be_nl;
50 *os << "{" << be_nl
51 << "}" << be_nl_2;
53 os->indent ();
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 ()
60 << " ()" << be_nl;
62 *os << "{" <<be_nl;
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
75 << "{" << 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::"
86 "visit_interface - "
87 "codegen for scope failed\n"),
88 -1);
91 int status =
92 node->traverse_inheritance_graph (
93 be_visitor_interface_is::method_helper,
97 if (status == -1)
99 ACE_ERROR_RETURN ((LM_ERROR,
100 "be_visitor_interface_is::"
101 "visit_interface - "
102 "traversal of inhertance graph failed\n"),
103 -1);
106 return 0;
110 // Helper method to generate the members in the scope of the base classes.
112 be_visitor_interface_is::method_helper (be_interface *derived,
113 be_interface *node,
114 TAO_OutStream *os)
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);
121 ctx.stream (os);
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::"
129 "method_helper\n"),
130 -1);
135 return 0;