Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_root / root_sth.cpp
blob2eed2e11736dc145eaf233d467c1cd790a51dbe7
2 //=============================================================================
3 /**
4 * @file root_sth.cpp
6 * Visitor generating code for Root in the server template header
8 * @author Jeff Parsons
9 */
10 //=============================================================================
12 #include "root.h"
14 be_visitor_root_sth::be_visitor_root_sth (be_visitor_context *ctx)
15 : be_visitor_root (ctx)
19 be_visitor_root_sth::~be_visitor_root_sth ()
23 int
24 be_visitor_root_sth::visit_root (be_root *node)
26 if (! be_global->gen_tie_classes ())
28 return 0;
31 if (this->init () == -1)
33 ACE_ERROR_RETURN ((LM_ERROR,
34 ACE_TEXT ("be_visitor_root_sth::init - ")
35 ACE_TEXT ("failed to initialize\n")),
36 -1);
39 if (this->visit_scope (node) == -1)
41 ACE_ERROR_RETURN ((LM_ERROR,
42 ACE_TEXT ("be_visitor_root_sth::visit_root - ")
43 ACE_TEXT ("codegen for scope failed\n")),
44 -1);
47 (void) tao_cg->end_server_template_header ();
49 return 0;
52 int
53 be_visitor_root_sth::visit_module (be_module *node)
55 if (node->imported ())
57 return 0;
60 TAO_OutStream *os = tao_cg->server_template_header ();
62 // Generate the skeleton class name.
64 TAO_INSERT_COMMENT (os);
66 // Now generate the class definition. The prefix POA_ is prepended to our
67 // name only if we are the outermost module.
68 *os << "namespace ";
70 if (node->is_nested ())
72 // We are inside another module.
73 *os << node->local_name () << be_nl;
75 else
77 // We are outermost module.
78 *os << "POA_" << node->local_name () << be_nl;
81 *os << "{" << be_idt;
83 if (this->visit_scope (node) == -1)
85 ACE_ERROR_RETURN ((LM_ERROR,
86 "(%N:%l) be_visitor_root_sth::"
87 "visit_module - "
88 "codegen for scope failed\n"),
89 -1);
92 *os << be_uidt_nl << "} // module " << node->name ();
94 return 0;
97 int
98 be_visitor_root_sth::visit_interface (be_interface *node)
100 if (node->imported () || node->is_local ())
102 return 0;
105 // Generate the TIE class.
107 this->ctx_->node (node);
108 be_visitor_interface_tie_sh visitor (this->ctx_);
110 if (node->accept (&visitor) == -1)
112 ACE_ERROR_RETURN ((LM_ERROR,
113 "be_visitor_root_sth::"
114 "visit_interface - "
115 "codegen for TIE class failed\n"),
116 -1);
119 return 0;
123 be_visitor_root_sth::visit_component (be_component *node)
125 return this->visit_interface (node);
129 be_visitor_root_sth::init ()
131 /// First open the server-side file for writing
132 int status =
133 tao_cg->start_server_template_header (
134 be_global->be_get_server_template_hdr_fname ());
136 if (status == -1)
138 ACE_ERROR_RETURN ((LM_ERROR,
139 ACE_TEXT ("be_visitor_root_sth::init - ")
140 ACE_TEXT ("Error opening server ")
141 ACE_TEXT ("template header file\n")),
142 -1);
145 /// Initialize the stream.
146 this->ctx_->stream (tao_cg->server_template_header ());
147 return 0;