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_ch.cpp
blobbb59f46d9460425471102a793bea8f8df605a79b
2 //=============================================================================
3 /**
4 * @file operation_ch.cpp
6 * Visitor generating code for Operation node in the client header.
8 * @author Aniruddha Gokhale
9 */
10 //=============================================================================
12 #include "operation.h"
14 // ******************************************************
15 // Primary visitor for "operation" in client header.
16 // ******************************************************
18 be_visitor_operation_ch::be_visitor_operation_ch (be_visitor_context *ctx)
19 : be_visitor_operation (ctx)
23 be_visitor_operation_ch::~be_visitor_operation_ch ()
27 int
28 be_visitor_operation_ch::visit_operation (be_operation *node)
30 TAO_OutStream *os = this->ctx_->stream ();
32 this->ctx_->node (node);
34 *os << be_nl_2;
36 // STEP I: generate the return type.
37 be_type *bt = dynamic_cast<be_type*> (node->return_type ());
39 if (!bt)
41 ACE_ERROR_RETURN ((LM_ERROR,
42 ACE_TEXT ("be_visitor_operation_ch::")
43 ACE_TEXT ("visit_operation - ")
44 ACE_TEXT ("Bad return type\n")),
45 -1);
47 //Only if we are generating exec header file, generate DOxygen documentation
48 if (this->ctx_->state () == TAO_CodeGen::TAO_ROOT_EXH)
50 if (this->void_return_type (bt))
52 *os << "/// Setter for " << node->local_name() << " attribute" << be_nl
53 << "/// @param[in] " << node->local_name() << " - New value for "
54 << node->local_name() << " attribute" << be_nl;
56 else
58 *os << "/// Getter for " << node->local_name() << " attribute" << be_nl
59 << "/// @return value of " << node->local_name() << " attribute" << be_nl;
62 *os << "virtual ";
64 // Grab the right visitor to generate the return type.
65 be_visitor_context ctx (*this->ctx_);
66 be_visitor_operation_rettype or_visitor (&ctx);
68 if (bt->accept (&or_visitor) == -1)
70 ACE_ERROR_RETURN ((LM_ERROR,
71 "(%N:%l) be_visitor_operation_ch::"
72 "visit_operation - "
73 "codegen for return type failed\n"),
74 -1);
77 // STEP 2: generate the operation name. The port prefix should
78 // be an empty string except for operations from attributes
79 // defined in a porttype.
80 *os << " " << node->local_name ();
82 // STEP 3: generate the argument list with the appropriate mapping. For these
83 // we grab a visitor that generates the parameter listing.
84 ctx = *this->ctx_;
85 ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH);
86 be_visitor_operation_arglist oa_visitor (&ctx);
88 if (node->accept (&oa_visitor) == -1)
90 ACE_ERROR_RETURN ((LM_ERROR,
91 "(%N:%l) be_visitor_operation_ch::"
92 "visit_operation - "
93 "codegen for argument list failed\n"),
94 -1);
97 be_interface *intf =
98 dynamic_cast<be_interface*> (node->defined_in ());
100 /// If we are in a reply handler, are not an excep_* operation,
101 /// and have no native args, then generate the AMI static
102 /// reply stub declaration.
103 if (intf != nullptr
104 && intf->is_ami_rh ()
105 && !node->is_excep_ami ()
106 && !node->has_native ())
108 *os << be_nl_2
109 << "static void" << be_nl
110 << node->local_name () << "_reply_stub (" << be_idt_nl
111 << "TAO_InputCDR &_tao_reply_cdr," << be_nl
112 << "::Messaging::ReplyHandler_ptr _tao_reply_handler,"
113 << be_nl
114 << "::CORBA::ULong reply_status);" << be_uidt;
117 return 0;