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 / tie_ss.cpp
blob98b36380c269e3a5d4a947e261f1deea206c1c40
2 //=============================================================================
3 /**
4 * @file tie_ss.cpp
6 * Visitor generating code for operations for the TIE class.
8 * @author Aniruddha Gokhale
9 */
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 ())
30 return 0;
33 TAO_OutStream *os = this->ctx_->stream ();
35 be_interface *intf = this->ctx_->interface ();
37 if (!intf)
39 ACE_ERROR_RETURN ((LM_ERROR,
40 "be_visitor_operation_tie_ss::"
41 "visit_operation - "
42 "bad interface scope\n"),
43 -1);
46 // Retrieve the operation return type.
47 be_type *bt = dynamic_cast<be_type*> (node->return_type ());
49 if (!bt)
51 ACE_ERROR_RETURN ((LM_ERROR,
52 "(%N:%l) be_visitor_operation_tie_ss::"
53 "visit_operation - "
54 "Bad return type\n"),
55 -1);
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;
69 si.next ())
71 // Check for conflicts between the arg name and the proposed template
72 // class identifier
73 AST_Argument *arg =
74 dynamic_cast<AST_Argument*> (si.item ());
76 if (! ACE_OS::strcmp (arg->local_name ()->get_string (),
77 template_name.c_str ()))
79 // clash !
80 template_name_ok = false;
84 if (! template_name_ok)
86 // We had a clash - postfix an underscore and try again
87 template_name += "_";
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::"
103 "visit_operation - "
104 "codegen for return type failed\n"),
105 -1);
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)
115 ctx = *this->ctx_;
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::"
122 "visit_operation - "
123 "codegen for argument list failed\n"),
124 -1);
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)
133 *os << "return ";
136 *os << "this->ptr_->" << node->local_name () << " (" << be_idt;
138 ctx = *this->ctx_;
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::"
146 "visit_operation - "
147 "codegen for making upcall failed\n"),
148 -1);
151 *os << be_uidt_nl;
152 *os << ");" << be_uidt_nl;
153 *os << "}";
155 return 0;