2 //=============================================================================
4 * @file sequence_base.cpp
6 * Visitor generating code for the base type of the Sequence
8 * @author Aniruddha Gokhale
10 //=============================================================================
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 ()
30 be_visitor_sequence_base::visit_predefined_type (be_predefined_type
*node
)
32 TAO_OutStream
*os
= this->ctx_
->stream ();
34 *os
<< "::" << node
->name ();
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 ();
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");
64 *os
<< bt
->nested_type_name (this->ctx_
->scope ()->decl ());
76 be_visitor_sequence_base::visit_sequence (be_sequence
*node
)
78 return this->visit_node (node
);
82 be_visitor_sequence_base::visit_interface (be_interface
*node
)
84 return this->visit_node (node
);
88 be_visitor_sequence_base::visit_interface_fwd (be_interface_fwd
*node
)
90 return this->visit_node (node
);
94 be_visitor_sequence_base::visit_valuebox (be_valuebox
*node
)
96 return this->visit_node (node
);
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.
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::"
171 "accept on primitive type failed\n"),
175 this->ctx_
->alias (nullptr);
179 be_visitor_sequence_base_template_args::
180 be_visitor_sequence_base_template_args (be_visitor_context
*ctx
,
182 : be_visitor_sequence_base (ctx
),
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 ();
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");
215 *os
<< bt
->name () << ",";
216 *os
<< bt
->name () << "_var";
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 ();
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");
246 *os
<< bt
->name () << ",";
247 *os
<< bt
->name () << "_var";
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";