Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_field / field_cs.cpp
blobda3a08de2f8ee3ed3f1ead693d3edf57f80c2d02
2 //=============================================================================
3 /**
4 * @file field_cs.cpp
6 * Visitor generating code for Field in the client stubs file.
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "field.h"
13 #include "be_visitor_array/array_cs.h"
14 #include "be_visitor_enum/enum_cs.h"
15 #include "be_visitor_sequence/sequence_cs.h"
16 #include "be_visitor_structure/structure_cs.h"
17 #include "be_visitor_union/union_cs.h"
19 // **********************************************
20 // Visitor for field in the client stubs file.
21 // **********************************************
23 be_visitor_field_cs::be_visitor_field_cs (be_visitor_context *ctx)
24 : be_visitor_decl (ctx)
28 be_visitor_field_cs::~be_visitor_field_cs ()
32 int
33 be_visitor_field_cs::visit_field (be_field *node)
35 be_type *bt = dynamic_cast<be_type*> (node->field_type ());
37 if (!bt)
39 ACE_ERROR_RETURN ((LM_ERROR,
40 "(%N:%l) be_visitor_field_cs::"
41 "visit_field - "
42 "Bad field type\n"),
43 -1);
46 this->ctx_->node (node);
48 if (bt->accept (this) == -1)
50 ACE_ERROR_RETURN ((LM_ERROR,
51 "(%N:%l) be_visitor_field_cs::"
52 "visit_field - "
53 "codegen for field type failed\n"),
54 -1);
57 return 0;
60 int
61 be_visitor_field_cs::visit_array (be_array *node)
63 if (!this->ctx_->alias ()
64 && node->is_child (this->ctx_->scope ()->decl ()))
66 be_visitor_context ctx (*this->ctx_);
67 ctx.node (node);
68 be_visitor_array_cs visitor (&ctx);
70 if (node->accept (&visitor) == -1)
72 ACE_ERROR_RETURN ((LM_ERROR,
73 "(%N:%l) be_visitor_field_cs::"
74 "visit_array - "
75 "codegen failed\n"),
76 -1);
80 return 0;
83 int
84 be_visitor_field_cs::visit_enum (be_enum *node)
86 if (node->node_type () != AST_Decl::NT_typedef
87 && node->is_child (this->ctx_->scope ()->decl ()))
89 be_visitor_context ctx (*this->ctx_);
90 ctx.node (node);
91 be_visitor_enum_cs visitor (&ctx);
93 if (node->accept (&visitor) == -1)
95 ACE_ERROR_RETURN ((LM_ERROR,
96 "(%N:%l) be_visitor_field_cs::"
97 "visit_enum - "
98 "codegen failed\n"),
99 -1);
103 return 0;
107 be_visitor_field_cs::visit_sequence (be_sequence *node)
109 if (node->node_type () != AST_Decl::NT_typedef
110 && node->is_child (this->ctx_->scope ()->decl ()))
112 be_visitor_context ctx (*this->ctx_);
113 ctx.node (node);
114 be_visitor_sequence_cs visitor (&ctx);
116 if (node->accept (&visitor) == -1)
118 ACE_ERROR_RETURN ((LM_ERROR,
119 "(%N:%l) be_visitor_field_cs::"
120 "visit_sequence - "
121 "codegen failed\n"),
122 -1);
126 return 0;
130 be_visitor_field_cs::visit_map (be_map *)
132 return 0;
136 be_visitor_field_cs::visit_structure (be_structure *node)
138 if (node->node_type () != AST_Decl::NT_typedef
139 && node->is_child (this->ctx_->scope ()->decl ()))
141 be_visitor_context ctx (*this->ctx_);
142 ctx.node (node);
143 be_visitor_structure_cs visitor (&ctx);
145 if (node->accept (&visitor) == -1)
147 ACE_ERROR_RETURN ((LM_ERROR,
148 "(%N:%l) be_visitor_field_cs::"
149 "visit_struct - "
150 "codegen failed\n"),
151 -1);
155 return 0;
159 be_visitor_field_cs::visit_structure_fwd (
160 be_structure_fwd *node)
162 be_structure *s =
163 dynamic_cast<be_structure*> (node->full_definition ());
165 return this->visit_structure (s);
169 be_visitor_field_cs::visit_typedef (be_typedef *node)
171 this->ctx_->alias (node);
172 be_type *bt = node->primitive_base_type ();
174 if (!bt || (bt->accept (this) == -1))
176 ACE_ERROR_RETURN ((LM_ERROR,
177 "(%N:%l) be_visitor_union_branch_public_ci::"
178 "visit_typedef - "
179 "Bad primitive type\n"),
180 -1);
183 this->ctx_->alias (nullptr);
184 return 0;
188 be_visitor_field_cs::visit_union (be_union *node)
190 if (node->node_type () != AST_Decl::NT_typedef
191 && node->is_child (this->ctx_->scope ()->decl ()))
193 be_visitor_context ctx (*this->ctx_);
194 ctx.node (node);
195 be_visitor_union_cs visitor (&ctx);
197 if (node->accept (&visitor) == -1)
199 ACE_ERROR_RETURN ((LM_ERROR,
200 "(%N:%l) be_visitor_field_cs::"
201 "visit_union - "
202 "codegen failed\n"),
203 -1);
207 return 0;
211 be_visitor_field_cs::visit_union_fwd (be_union_fwd *node)
213 be_union *u =
214 dynamic_cast<be_union*> (node->full_definition ());
216 return this->visit_union (u);