2 //=============================================================================
6 * Visitor generating code for operations for the TIE class.
8 * @author Aniruddha Gokhale
10 //=============================================================================
12 #include "operation.h"
14 be_visitor_operation_tie_ss::be_visitor_operation_tie_ss (
15 be_visitor_context
*ctx
)
16 : be_visitor_scope (ctx
)
20 be_visitor_operation_tie_ss::~be_visitor_operation_tie_ss ()
24 int be_visitor_operation_tie_ss::visit_operation (be_operation
*node
)
26 /// These implied IDL operations are not to be processed on
27 /// the skeleton side.
28 if (node
->is_sendc_ami ())
33 TAO_OutStream
*os
= this->ctx_
->stream ();
35 be_interface
*intf
= this->ctx_
->interface ();
39 ACE_ERROR_RETURN ((LM_ERROR
,
40 "be_visitor_operation_tie_ss::"
42 "bad interface scope\n"),
46 // Retrieve the operation return type.
47 be_type
*bt
= dynamic_cast<be_type
*> (node
->return_type ());
51 ACE_ERROR_RETURN ((LM_ERROR
,
52 "(%N:%l) be_visitor_operation_tie_ss::"
58 // Although unlikely it is possible that the 'T' in 'template class<T>' will
59 // conflict with an argument name...
60 ACE_CString
template_name ("T");
61 bool template_name_ok
= false;
63 while (!template_name_ok
)
65 template_name_ok
= true;
67 for (UTL_ScopeActiveIterator
si (node
, UTL_Scope::IK_decls
);
68 ! si
.is_done () && template_name_ok
;
71 // Check for conflicts between the arg name and the proposed template
74 dynamic_cast<AST_Argument
*> (si
.item ());
76 if (! ACE_OS::strcmp (arg
->local_name ()->get_string (),
77 template_name
.c_str ()))
80 template_name_ok
= false;
84 if (! template_name_ok
)
86 // We had a clash - postfix an underscore and try again
91 TAO_INSERT_COMMENT (os
);
93 *os
<< "template <class " << template_name
.c_str () << ">" << be_nl
;
95 // Generate the return type mapping (same as in the header file).
96 be_visitor_context
ctx (*this->ctx_
);
97 be_visitor_operation_rettype
oro_visitor (&ctx
);
99 if (bt
->accept (&oro_visitor
) == -1)
101 ACE_ERROR_RETURN ((LM_ERROR
,
102 "(%N:%l) be_visitor_operation_tie_ss::"
104 "codegen for return type failed\n"),
108 *os
<< " " << intf
->full_skel_name () << "_tie<"
109 << template_name
.c_str () << ">::"
110 << this->ctx_
->port_prefix ().c_str ()
111 << node
->local_name () << " ";
113 // STEP 4: generate the argument list with the appropriate mapping (same as
114 // in the header file)
116 be_visitor_operation_arglist
oao_visitor (&ctx
);
118 if (node
->accept (&oao_visitor
) == -1)
120 ACE_ERROR_RETURN ((LM_ERROR
,
121 "(%N:%l) be_visitor_operation_cs::"
123 "codegen for argument list failed\n"),
127 *os
<< be_nl
<< "{" << be_idt_nl
;
129 be_predefined_type
*pdt
= dynamic_cast<be_predefined_type
*> (bt
);
131 if (pdt
== nullptr || pdt
->pt () != AST_PredefinedType::PT_void
)
136 *os
<< "this->ptr_->" << node
->local_name () << " (" << be_idt
;
139 ctx
.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS
);
140 be_visitor_operation_argument
ocau_visitor (&ctx
);
142 if (node
->accept (&ocau_visitor
) == -1)
144 ACE_ERROR_RETURN ((LM_ERROR
,
145 "(%N:%l) be_visitor_operation_ss::"
147 "codegen for making upcall failed\n"),
152 *os
<< ");" << be_uidt_nl
;