1 #include "be_visitor_attr_assign.h"
3 #include "be_visitor_context.h"
5 #include "be_component.h"
7 #include "be_eventtype.h"
9 #include "be_predefined_type.h"
10 #include "be_sequence.h"
11 #include "be_string.h"
12 #include "be_structure.h"
13 #include "be_typedef.h"
15 #include "be_valuebox.h"
16 #include "be_valuetype.h"
18 be_visitor_attr_assign::be_visitor_attr_assign (
19 be_visitor_context
*ctx
)
20 : be_visitor_decl (ctx
),
22 attr_name_string_ ("this->")
26 be_visitor_attr_assign::~be_visitor_attr_assign ()
31 be_visitor_attr_assign::visit_array (be_array
*node
)
34 << this->attr_name_string_
.c_str () << " = "
35 << "::" << node
->full_name () << "_dup ("
36 << this->attr_name_
<< ");";
42 be_visitor_attr_assign::visit_component (be_component
*node
)
45 << this->attr_name_string_
.c_str () << " = "
46 << "::" << node
->full_name () << "::_duplicate ("
47 << this->attr_name_
<< ");";
53 be_visitor_attr_assign::visit_enum (be_enum
*)
56 << this->attr_name_string_
.c_str () << " = "
57 << this->attr_name_
<< ";";
63 be_visitor_attr_assign::visit_eventtype (be_eventtype
*)
66 << this->attr_name_
<< "->_add_ref ();" << be_nl
67 << this->attr_name_string_
.c_str () << " = "
68 << this->attr_name_
<< ";";
74 be_visitor_attr_assign::visit_home (be_home
*node
)
77 << this->attr_name_string_
.c_str () << " = "
78 << "::" << node
->full_name () << "::_duplicate ("
79 << this->attr_name_
<< ");";
85 be_visitor_attr_assign::visit_interface (
89 << this->attr_name_string_
.c_str () << " = "
90 << "::" << node
->full_name () << "::_duplicate ("
91 << this->attr_name_
<< ");";
97 be_visitor_attr_assign::visit_predefined_type (
101 << this->attr_name_string_
.c_str () << " = "
102 << this->attr_name_
<< ";";
107 /// Unused if anonymous types are not allowed.
109 be_visitor_attr_assign::visit_sequence (be_sequence
*)
111 be_type
*bt
= this->ctx_
->alias ();
115 /// Support anonymous types?
120 << "::" << bt
->full_name () << " * _ciao_tmp = 0;" << be_nl
121 << "ACE_NEW (" << be_idt_nl
122 << "_ciao_tmp," << be_nl
123 << bt
->full_name () << " (" << this->attr_name_
124 << "));" << be_uidt_nl
<< be_nl
125 << this->attr_name_string_
.c_str () << " = _ciao_tmp;";
131 be_visitor_attr_assign::visit_string (be_string
*node
)
134 << this->attr_name_string_
.c_str () << " = "
135 << "::CORBA::" << (node
->width () == (ssize_t
) sizeof (char) ? "" : "w")
136 << "string_dup (" << this->attr_name_
<< ");";
142 be_visitor_attr_assign::visit_structure (be_structure
*node
)
145 << "::" << node
->full_name () << " * _ciao_tmp = 0;" << be_nl
146 << "ACE_NEW (" << be_idt_nl
147 << "_ciao_tmp," << be_nl
148 << "::" << node
->full_name () << ");" << be_uidt_nl
<< be_nl
149 << "*_ciao_tmp = " << this->attr_name_
<< ";" << be_nl
150 << this->attr_name_string_
.c_str () << " = _ciao_tmp;";
156 be_visitor_attr_assign::visit_typedef (be_typedef
*node
)
158 this->ctx_
->alias (node
);
159 int const status
= node
->primitive_base_type ()->accept (this);
163 ACE_ERROR_RETURN ((LM_ERROR
,
164 "be_visitor_memkber_type_decl::"
166 "accept on primitive type failed\n"),
170 this->ctx_
->alias (nullptr);
175 be_visitor_attr_assign::visit_union (be_union
*node
)
178 << "::" << node
->full_name () << " * _ciao_tmp = 0;" << be_nl
179 << "ACE_NEW (" << be_idt_nl
180 << "_ciao_tmp," << be_nl
181 << "::" << node
->full_name () << ");" << be_uidt_nl
<< be_nl
182 << "*_ciao_tmp = " << this->attr_name_
<< ";" << be_nl
183 << this->attr_name_string_
.c_str () << " = _ciao_tmp;";
189 be_visitor_attr_assign::visit_valuebox (be_valuebox
*)
192 << this->attr_name_
<< "->_add_ref ();" << be_nl
193 << this->attr_name_string_
.c_str () << " = "
194 << this->attr_name_
<< ";";
200 be_visitor_attr_assign::visit_valuetype (be_valuetype
*)
203 << this->attr_name_
<< "->_add_ref ();" << be_nl
204 << this->attr_name_string_
.c_str () << " = "
205 << this->attr_name_
<< ";";
211 be_visitor_attr_assign::attr_name (const char *name
)
213 // No need for copying, the lifetime of the attr
214 // the arg is from is longer than that of this visitor.
215 this->attr_name_
= name
;
217 // Add to this string for convenience, it's generated
218 // in each method above at least once.
219 this->attr_name_string_
+= this->ctx_
->port_prefix ();
220 this->attr_name_string_
+= name
;
221 this->attr_name_string_
+= '_';