2 //=============================================================================
4 * @file operation_cs.cpp
6 * Visitor generating code for Operation in the stubs file.
8 * @author Aniruddha Gokhale & Angelo Corsaro
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.
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
))
43 be_visitor_operation_cs::visit_operation (be_operation
*node
)
46 this->ctx_
->attribute ()
47 ? this->ctx_
->attribute ()->defined_in ()
48 : node
->defined_in ();
50 be_interface
*intf
= dynamic_cast<be_interface
*> (s
);
54 be_porttype
*pt
= dynamic_cast<be_porttype
*> (s
);
58 ACE_ERROR_RETURN ((LM_ERROR
,
59 ACE_TEXT ("be_visitor_operation_cs::")
60 ACE_TEXT ("visit_operation - ")
61 ACE_TEXT ("bad scope\n")),
66 intf
= this->ctx_
->interface ();
70 ACE_ERROR_RETURN ((LM_ERROR
,
71 ACE_TEXT ("be_visitor_operation_cs::")
72 ACE_TEXT ("visit_operation - ")
73 ACE_TEXT ("bad scope\n")),
79 TAO_OutStream
*os
= this->ctx_
->stream ();
80 this->ctx_
->node (node
); // save the node for future use
82 if (node
->is_local ())
87 TAO_INSERT_COMMENT (os
);
89 // Retrieve the operation return type.
90 be_type
*bt
= dynamic_cast<be_type
*> (node
->return_type ());
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")),
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")),
114 // Generate the operation name
116 << intf
->name () << "::" << node
->local_name ();
118 // Generate the argument list with the appropriate mapping (same as
119 // in the header file)
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")),
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")),
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.
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 (
152 int status
= v
.visit_operation (node
);
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")),
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 ());
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")),
185 *os
<< "{" << bt
->tc_name () << ", ";
187 switch (node
->direction ())
189 case AST_Argument::dir_IN
:
192 case AST_Argument::dir_INOUT
:
193 *os
<< "PARAM_INOUT, ";
195 case AST_Argument::dir_OUT
:
196 *os
<< "PARAM_OUT, ";