2 //=============================================================================
6 * Visitor generating AMH skeleton code for Operation node in the
9 * @author Mayur Deshpande <mayur@ics.uci.edu>
11 //=============================================================================
13 #include "operation.h"
15 be_visitor_amh_operation_sh::be_visitor_amh_operation_sh (
16 be_visitor_context
*ctx
)
17 : be_visitor_operation (ctx
)
21 be_visitor_amh_operation_sh::~be_visitor_amh_operation_sh ()
26 be_visitor_amh_operation_sh::visit_operation (be_operation
*node
)
28 /// If there is an argument of type "native", return immediately.
29 if (node
->has_native ())
34 /// These are not for the server side.
35 if (node
->is_sendc_ami ())
41 TAO_OutStream
*os
= this->ctx_
->stream ();
42 this->ctx_
->node (node
);
44 this->generate_shared_prologue (node
, os
, "");
46 be_visitor_context
ctx (*this->ctx_
);
47 be_visitor_args_arglist
arglist_visitor (&ctx
);
48 arglist_visitor
.set_fixed_direction (AST_Argument::dir_IN
);
51 for (UTL_ScopeActiveIterator
i (node
, UTL_Scope::IK_decls
);
55 be_argument
*argument
=
56 dynamic_cast<be_argument
*> (i
.item ());
58 if (argument
== nullptr
59 || argument
->direction () == AST_Argument::dir_OUT
)
66 if (arglist_visitor
.visit_argument (argument
) == -1)
68 ACE_ERROR_RETURN ((LM_ERROR
,
69 "(%N:%l) be_visitor_amh_operation_sh::"
71 "codegen for upcall args failed\n"),
77 << ") = 0;" << be_uidt_nl
;
83 be_visitor_amh_operation_sh::visit_attribute (be_attribute
*node
)
85 TAO_OutStream
*os
= this->ctx_
->stream ();
86 this->generate_shared_prologue (node
, os
, "_get_");
89 << ") = 0;" << be_uidt_nl
;
91 if (node
->readonly ())
96 this->generate_shared_prologue (node
, os
, "_set_");
100 be_argument
the_argument (AST_Argument::dir_IN
,
103 be_visitor_context
ctx (*this->ctx_
);
104 be_visitor_args_arglist
visitor (&ctx
);
106 int status
= visitor
.visit_argument (&the_argument
);
108 the_argument
.destroy ();
115 *os
<< be_uidt_nl
<< ") = 0;" << be_uidt_nl
;
121 be_visitor_amh_operation_sh::generate_shared_prologue (
124 const char *skel_prefix
)
126 TAO_INSERT_COMMENT (os
);
128 *os
<< "static void " << skel_prefix
129 << this->ctx_
->port_prefix ().c_str ()
130 << node
->local_name ()
131 << "_skel (" << be_idt
<< be_idt_nl
132 << "TAO_ServerRequest &_tao_req," << be_nl
133 << "TAO::Portable_Server::Servant_Upcall *_tao_obj," << be_nl
134 << "TAO_ServantBase *_tao_servant_upcall"
135 << ");" << be_uidt_nl
<< be_uidt_nl
;
137 // We need the interface node in which this operation was defined. However,
138 // if this operation node was an attribute node in disguise, we get this
139 // information from the context
141 dynamic_cast<be_interface
*> (node
->defined_in ());
143 if (this->ctx_
->attribute () != nullptr)
145 intf
= dynamic_cast<be_interface
*> (
146 this->ctx_
->attribute()->defined_in ()
152 ACE_ERROR ((LM_ERROR
,
153 "(%N:%l) be_visitor_amh_operation_sh::"
155 "bad interface scope\n"));
159 // Step 1 : Generate return type: always void
160 *os
<< "virtual void ";
162 // Step 2: Generate the method name
163 *os
<< node
->local_name() << " (" << be_idt
<< be_idt_nl
;
165 // STEP 3: Generate the argument list with the appropriate
166 // mapping. For these we grab a visitor that generates the
167 // parameter listing. We also generate the ResponseHandler
168 // argument 'on the fly' and add it to the argument list
171 // @@ TODO this must be kept consistent with the code in
172 // be_visitor_interface/amh_sh.cpp
173 intf
->compute_full_name ("AMH_", "ResponseHandler_ptr", buf
);
175 *os
<< buf
<< " _tao_rh";
176 // buf was allocated by ACE_OS::strdup, so we must use free instead