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
;
60 *os
<< "/// Getter for " << node
->local_name() << " attribute" << be_nl
61 << "/// @return value of " << node
->local_name() << " attribute" << be_nl
;
66 // Grab the right visitor to generate the return type.
67 be_visitor_context
ctx (*this->ctx_
);
68 be_visitor_operation_rettype
or_visitor (&ctx
);
70 if (bt
->accept (&or_visitor
) == -1)
72 ACE_ERROR_RETURN ((LM_ERROR
,
73 "(%N:%l) be_visitor_operation_ch::"
75 "codegen for return type failed\n"),
79 // STEP 2: generate the operation name. The port prefix should
80 // be an empty string except for operations from attributes
81 // defined in a porttype.
82 *os
<< " " << node
->local_name ();
84 // STEP 3: generate the argument list with the appropriate mapping. For these
85 // we grab a visitor that generates the parameter listing.
87 ctx
.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH
);
88 be_visitor_operation_arglist
oa_visitor (&ctx
);
90 if (node
->accept (&oa_visitor
) == -1)
92 ACE_ERROR_RETURN ((LM_ERROR
,
93 "(%N:%l) be_visitor_operation_ch::"
95 "codegen for argument list failed\n"),
100 dynamic_cast<be_interface
*> (node
->defined_in ());
102 /// If we are in a reply handler, are not an excep_* operation,
103 /// and have no native args, then generate the AMI static
104 /// reply stub declaration.
106 && intf
->is_ami_rh ()
107 && !node
->is_excep_ami ()
108 && !node
->has_native ())
111 << "static void" << be_nl
112 << node
->local_name () << "_reply_stub (" << be_idt_nl
113 << "TAO_InputCDR &_tao_reply_cdr," << be_nl
114 << "::Messaging::ReplyHandler_ptr _tao_reply_handler,"
116 << "::CORBA::ULong reply_status);" << be_uidt
;