Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / TAO_IDL / be / be_visitor_operation / operation_cs.cpp
blob0a97ddb3e8d74811e48f1eae1923b4e7858b6378
2 //=============================================================================
3 /**
4 * @file operation_cs.cpp
6 * Visitor generating code for Operation in the stubs file.
8 * @author Aniruddha Gokhale & Angelo Corsaro
9 */
10 //=============================================================================
12 #include "operation.h"
14 // ************************************************************
15 // Operation visitor for client stubs
16 // ************************************************************
18 be_visitor_operation_cs::be_visitor_operation_cs (be_visitor_context *ctx)
19 : be_visitor_operation (ctx)
23 be_visitor_operation_cs::~be_visitor_operation_cs ()
27 // Processing to be done after every element in the scope is processed.
28 int
29 be_visitor_operation_cs::post_process (be_decl *bd)
31 // All we do here is to insert a comma and a newline.
32 TAO_OutStream *os = this->ctx_->stream ();
34 if (!this->last_node (bd))
36 *os << "," << be_nl;
39 return 0;
42 int
43 be_visitor_operation_cs::visit_operation (be_operation *node)
45 UTL_Scope *s =
46 this->ctx_->attribute ()
47 ? this->ctx_->attribute ()->defined_in ()
48 : node->defined_in ();
50 be_interface *intf = dynamic_cast<be_interface*> (s);
52 if (intf == nullptr)
54 be_porttype *pt = dynamic_cast<be_porttype*> (s);
56 if (pt == nullptr)
58 ACE_ERROR_RETURN ((LM_ERROR,
59 ACE_TEXT ("be_visitor_operation_cs::")
60 ACE_TEXT ("visit_operation - ")
61 ACE_TEXT ("bad scope\n")),
62 -1);
64 else
66 intf = this->ctx_->interface ();
68 if (intf == nullptr)
70 ACE_ERROR_RETURN ((LM_ERROR,
71 ACE_TEXT ("be_visitor_operation_cs::")
72 ACE_TEXT ("visit_operation - ")
73 ACE_TEXT ("bad scope\n")),
74 -1);
79 TAO_OutStream *os = this->ctx_->stream ();
80 this->ctx_->node (node); // save the node for future use
82 if (node->is_local ())
84 return 0;
87 TAO_INSERT_COMMENT (os);
89 // Retrieve the operation return type.
90 be_type *bt = dynamic_cast<be_type*> (node->return_type ());
92 if (!bt)
94 ACE_ERROR_RETURN ((LM_ERROR,
95 ACE_TEXT ("be_visitor_operation_cs::")
96 ACE_TEXT ("visit_operation - ")
97 ACE_TEXT ("bad return type\n")),
98 -1);
101 // Generate the return type mapping (same as in the header file)
102 be_visitor_context ctx = *this->ctx_;
103 be_visitor_operation_rettype rt_visitor = (&ctx);
105 if (bt->accept (&rt_visitor) == -1)
107 ACE_ERROR_RETURN ((LM_ERROR,
108 ACE_TEXT ("be_visitor_operation_cs::")
109 ACE_TEXT ("visit_operation - ")
110 ACE_TEXT ("codegen for return type failed\n")),
111 -1);
114 // Generate the operation name
115 *os << be_nl
116 << intf->name () << "::" << node->local_name ();
118 // Generate the argument list with the appropriate mapping (same as
119 // in the header file)
120 ctx = *this->ctx_;
121 be_visitor_operation_arglist al_visitor (&ctx);
123 if (node->accept (&al_visitor) == -1)
125 ACE_ERROR_RETURN ((LM_ERROR,
126 ACE_TEXT ("be_visitor_operation_cs::")
127 ACE_TEXT ("visit_operation - ")
128 ACE_TEXT ("codegen for argument list failed\n")),
129 -1);
132 if (this->gen_stub_operation_body (node, bt) == -1)
134 ACE_ERROR_RETURN ((LM_ERROR,
135 ACE_TEXT ("be_visitor_operation_cs::")
136 ACE_TEXT ("visit_operation - ")
137 ACE_TEXT ("codegen for stub body failed\n")),
138 -1);
141 /// If we are in a reply handler, are not an execp_* operation,
142 /// and have no native args, then generate the AMI static
143 /// reply stub declaration.
144 if (intf != nullptr
145 && intf->is_ami_rh ()
146 && !node->is_excep_ami ()
147 && !node->has_native ())
149 be_visitor_operation_ami_handler_reply_stub_operation_cs v (
150 this->ctx_);
152 int status = v.visit_operation (node);
154 if (status == -1)
156 ACE_ERROR_RETURN ((LM_ERROR,
157 ACE_TEXT ("be_visitor_operation_cs::")
158 ACE_TEXT ("visit_operation - ")
159 ACE_TEXT ("codegen for AMI reply stub failed\n")),
160 -1);
164 return 0;
168 be_visitor_operation_cs::visit_argument (be_argument *node)
170 // This method is used to generate the ParamData table entry.
172 TAO_OutStream *os = this->ctx_->stream ();
173 be_type *bt = dynamic_cast<be_type*> (node->field_type ());
175 if (!bt)
177 ACE_ERROR_RETURN ((LM_ERROR,
178 ACE_TEXT ("be_visitor_operation_cs::")
179 ACE_TEXT ("visit_argument - ")
180 ACE_TEXT ("bad argument type\n")),
181 -1);
184 os->indent ();
185 *os << "{" << bt->tc_name () << ", ";
187 switch (node->direction ())
189 case AST_Argument::dir_IN:
190 *os << "PARAM_IN, ";
191 break;
192 case AST_Argument::dir_INOUT:
193 *os << "PARAM_INOUT, ";
194 break;
195 case AST_Argument::dir_OUT:
196 *os << "PARAM_OUT, ";
197 break;
200 *os << "0}";
202 return 0;