2 //=============================================================================
4 * @file operation_ch.cpp
6 * Visitor generating code for Operation node in the client header.
8 * @author Aniruddha Gokhale
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 ()
28 be_visitor_operation_ch::visit_operation (be_operation
*node
)
30 TAO_OutStream
*os
= this->ctx_
->stream ();
32 this->ctx_
->node (node
);
36 // STEP I: generate the return type.
37 be_type
*bt
= dynamic_cast<be_type
*> (node
->return_type ());
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")),
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
;
58 *os
<< "/// Getter for " << node
->local_name() << " attribute" << be_nl
59 << "/// @return value of " << node
->local_name() << " attribute" << be_nl
;
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::"
73 "codegen for return type failed\n"),
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.
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::"
93 "codegen for argument list failed\n"),
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.
104 && intf
->is_ami_rh ()
105 && !node
->is_excep_ami ()
106 && !node
->has_native ())
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,"
114 << "::CORBA::ULong reply_status);" << be_uidt
;