Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_sequence / sequence_base.cpp
blobb4257eb0324b3d803e644c15059804a71af9a475
2 //=============================================================================
3 /**
4 * @file sequence_base.cpp
6 * Visitor generating code for the base type of the Sequence
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "sequence.h"
14 // ****************************************************************
15 // We have to generate the parameters for the template that implements
16 // each sequence type.
17 // ****************************************************************
19 be_visitor_sequence_base::be_visitor_sequence_base (be_visitor_context *ctx)
20 : be_visitor_decl (ctx)
24 be_visitor_sequence_base::~be_visitor_sequence_base ()
29 int
30 be_visitor_sequence_base::visit_predefined_type (be_predefined_type *node)
32 TAO_OutStream *os = this->ctx_->stream ();
34 *os << "::" << node->name ();
36 return 0;
39 // helper
40 int
41 be_visitor_sequence_base::visit_node (be_type *node)
43 TAO_OutStream *os = this->ctx_->stream ();
44 be_type *bt = nullptr;
46 if (this->ctx_->alias ())
48 bt = this->ctx_->alias ();
50 else
52 bt = node;
55 if (this->ctx_->state () == TAO_CodeGen::TAO_SEQUENCE_BASE_CH)
57 if (this->ctx_->sub_state ()
58 == TAO_CodeGen::TAO_ARRAY_SEQ_CH_TEMPLATE_VAR)
60 *os << bt->nested_type_name (this->ctx_->scope ()->decl (), "_var");
62 else
64 *os << bt->nested_type_name (this->ctx_->scope ()->decl ());
67 else
69 *os << bt->name ();
72 return 0;
75 int
76 be_visitor_sequence_base::visit_sequence (be_sequence *node)
78 return this->visit_node (node);
81 int
82 be_visitor_sequence_base::visit_interface (be_interface *node)
84 return this->visit_node (node);
87 int
88 be_visitor_sequence_base::visit_interface_fwd (be_interface_fwd *node)
90 return this->visit_node (node);
93 int
94 be_visitor_sequence_base::visit_valuebox (be_valuebox *node)
96 return this->visit_node (node);
99 int
100 be_visitor_sequence_base::visit_valuetype (be_valuetype *node)
102 return this->visit_node (node);
106 be_visitor_sequence_base::visit_valuetype_fwd (be_valuetype_fwd *node)
108 return this->visit_node (node);
112 be_visitor_sequence_base::visit_string (be_string *)
114 // NO-OP, we have ad-hoc classes from strings.
115 return 0;
119 be_visitor_sequence_base::visit_structure (be_structure *node)
121 return this->visit_node (node);
125 be_visitor_sequence_base::visit_structure_fwd (be_structure_fwd *node)
127 return this->visit_node (node);
131 be_visitor_sequence_base::visit_union (be_union *node)
133 return this->visit_node (node);
137 be_visitor_sequence_base::visit_union_fwd (be_union_fwd *node)
139 return this->visit_node (node);
143 be_visitor_sequence_base::visit_enum (be_enum *node)
145 return this->visit_node (node);
149 be_visitor_sequence_base::visit_exception (be_exception *node)
151 return this->visit_node (node);
155 be_visitor_sequence_base::visit_array (be_array *node)
157 return this->visit_node (node);
161 be_visitor_sequence_base::visit_typedef (be_typedef *node)
163 // Set the alias node.
164 this->ctx_->alias (node);
166 if (node->primitive_base_type ()->accept (this) == -1)
168 ACE_ERROR_RETURN ((LM_ERROR,
169 "be_visitor_sequence_base::"
170 "visit_typedef - "
171 "accept on primitive type failed\n"),
172 -1);
175 this->ctx_->alias (nullptr);
176 return 0;
179 be_visitor_sequence_base_template_args::
180 be_visitor_sequence_base_template_args (be_visitor_context *ctx,
181 be_sequence *seq)
182 : be_visitor_sequence_base (ctx),
183 beseq_ (seq)
188 be_visitor_sequence_base_template_args::
189 ~be_visitor_sequence_base_template_args ()
194 be_visitor_sequence_base_template_args::visit_interface (be_interface *node)
196 TAO_OutStream *os = this->ctx_->stream ();
197 be_type *bt = nullptr;
199 if (this->ctx_->alias ())
201 bt = this->ctx_->alias ();
203 else
205 bt = node;
208 if (this->ctx_->state () == TAO_CodeGen::TAO_SEQUENCE_BASE_CH)
210 *os << bt->nested_type_name (this->ctx_->scope ()->decl ()) << ",";
211 *os << bt->nested_type_name (this->ctx_->scope ()->decl (), "_var");
213 else
215 *os << bt->name () << ",";
216 *os << bt->name () << "_var";
219 return 0;
223 be_visitor_sequence_base_template_args::visit_interface_fwd (
224 be_interface_fwd *node
227 TAO_OutStream *os = this->ctx_->stream ();
228 be_type *bt = nullptr;
230 if (this->ctx_->alias ())
232 bt = this->ctx_->alias ();
234 else
236 bt = node;
239 if (this->ctx_->state () == TAO_CodeGen::TAO_SEQUENCE_BASE_CH)
241 *os << bt->nested_type_name (this->ctx_->scope ()->decl ()) << ",";
242 *os << bt->nested_type_name (this->ctx_->scope ()->decl (), "_var");
244 else
246 *os << bt->name () << ",";
247 *os << bt->name () << "_var";
250 return 0;
254 be_visitor_sequence_base_template_args::visit_valuetype (be_valuetype *node)
256 return this->visit_interface (node);
260 be_visitor_sequence_base_template_args::visit_valuetype_fwd (
261 be_valuetype_fwd *node
264 return this->visit_interface_fwd (node);
268 be_visitor_sequence_base_template_args::visit_predefined_type (
269 be_predefined_type *node
272 TAO_OutStream *os = this->ctx_->stream ();
273 *os << "::" << node->name ();
275 if (beseq_->managed_type () == be_sequence::MNG_PSEUDO
276 || beseq_->managed_type () == be_sequence::MNG_OBJREF)
278 *os << ", ::" << node->name () << "_var";
281 return 0;