2 //=============================================================================
6 * generic visitor for Argument node
8 * @author Aniruddha Gokhale
10 //=============================================================================
15 be_visitor_args::be_visitor_args (be_visitor_context
*ctx
)
16 : be_visitor_decl (ctx
),
21 be_visitor_args::~be_visitor_args ()
25 int be_visitor_args::visit_argument (be_argument
*)
30 // Helper that returns the type name either as a nested type name (for header
31 // files) or as a fully scoped name. In addition, we make sure that if the type
32 // is an alias, we use that name.
34 be_visitor_args::type_name (be_type
*node
,
37 static char namebuf
[NAMEBUFSIZE
];
38 ACE_OS::memset (namebuf
,
44 // Use the typedefed name if that is the one
45 // used in the IDL defn.
46 if (this->ctx_
->alias ())
48 bt
= this->ctx_
->alias ();
55 ACE_OS::sprintf (namebuf
,
61 ACE_OS::strcat (namebuf
,
68 // Helper that returns the direction type of the argument
69 AST_Argument::Direction
70 be_visitor_args::direction ()
72 if (this->fixed_direction_
!= -1)
74 return AST_Argument::Direction (this->fixed_direction_
);
77 // Grab the argument node. We know that our context has stored the right
80 dynamic_cast<be_argument
*> (this->ctx_
->node ());
82 return arg
->direction ();
86 be_visitor_args::set_fixed_direction (AST_Argument::Direction direction
)
88 this->fixed_direction_
= direction
;
92 be_visitor_args::gen_pd_arg (be_predefined_type
*node
,
95 TAO_CodeGen::CG_SUB_STATE ss
= this->ctx_
->sub_state ();
96 AST_Argument::Direction d
= this->direction ();
98 bool in_arg
= (d
== AST_Argument::dir_IN
);
99 bool out_arg
= (d
== AST_Argument::dir_OUT
);
100 bool out_stream
= (ss
== TAO_CodeGen::TAO_CDR_OUTPUT
);
101 bool in_stream
= (ss
== TAO_CodeGen::TAO_CDR_INPUT
);
103 bool skip
= (in_arg
&& for_stub
&& in_stream
)
104 || (in_arg
&& !for_stub
&& out_stream
)
105 || (out_arg
&& for_stub
&& out_stream
)
106 || (out_arg
&& !for_stub
&& in_stream
);
113 TAO_OutStream
*os
= this->ctx_
->stream ();
114 const char *var_call
= "";
115 const char *any_deref
= "";
117 AST_PredefinedType::PredefinedType pt
= node
->pt ();
118 bool is_any
= (pt
== AST_PredefinedType::PT_any
);
122 if (in_stream
&& out_arg
)
124 var_call
= ".ptr ()";
132 if (is_any
&& !out_arg
)
139 var_call
= ".out ()";
142 ACE_CString to_from_str
= (in_stream
143 ? "::ACE_InputCDR::to_"
144 : "::ACE_OutputCDR::from_");
146 const char *to_from
= to_from_str
.c_str ();
149 dynamic_cast<be_argument
*> (this->ctx_
->node ());
150 const char *lname
= arg
->local_name ()->get_string ();
154 case AST_PredefinedType::PT_any
:
157 case AST_PredefinedType::PT_pseudo
:
158 case AST_PredefinedType::PT_object
:
159 *os
<< lname
<< var_call
;
161 case AST_PredefinedType::PT_char
:
162 *os
<< to_from
<< "char (" << lname
<< ")";
164 case AST_PredefinedType::PT_wchar
:
165 *os
<< to_from
<< "wchar (" << lname
<< ")";
167 case AST_PredefinedType::PT_boolean
:
168 *os
<< to_from
<< "boolean (" << lname
<< ")";
170 case AST_PredefinedType::PT_octet
:
171 *os
<< to_from
<< "octet (" << lname
<< ")";