2 //=============================================================================
4 * @file operation_svs.cpp
6 * Visitor generating code for Operation in the CIAO servants file.
10 //=============================================================================
12 #include "operation.h"
13 #include "be_visitor_operation/operation_svs.h"
15 be_visitor_operation_svs::be_visitor_operation_svs (
16 be_visitor_context
*ctx
)
17 : be_visitor_scope (ctx
),
22 be_visitor_operation_svs::~be_visitor_operation_svs ()
27 be_visitor_operation_svs::visit_operation (be_operation
*node
)
29 this->ctx_
->node (node
);
34 if (this->ctx_
->state () == TAO_CodeGen::TAO_ROOT_SVTS
)
36 os_
<< "template <typename BASE, typename EXEC, typename CONTEXT>"
39 // Retrieve the operation return type.
40 be_type
*bt
= dynamic_cast<be_type
*> (node
->return_type ());
44 ACE_ERROR_RETURN ((LM_ERROR
,
45 "be_visitor_operation_svs::"
51 // Generate the return type mapping (same as in the header file)
52 be_visitor_context ctx
= *this->ctx_
;
53 be_visitor_operation_rettype
rt_visitor (&ctx
);
55 if (bt
->accept (&rt_visitor
) == -1)
57 ACE_ERROR_RETURN ((LM_ERROR
,
58 "be_visitor_operation_svs::"
60 "codegen for return type failed\n"),
64 // Generate the operation name, avoiding possible _cxx_ prefix.
65 // USE STATE con the context!!!!!!!
66 if (this->ctx_
->state () == TAO_CodeGen::TAO_ROOT_SVTS
)
69 << scope_
->original_local_name ()->get_string ()
70 << "_Servant_T<BASE, EXEC, CONTEXT>";
75 << scope_
->original_local_name ()->get_string ()
79 os_
<< "::" << node
->local_name ();
81 // Generate the argument list with the appropriate mapping (same as
82 // in the header file)
84 be_visitor_operation_arglist
al_visitor (&ctx
);
86 if (node
->accept (&al_visitor
) == -1)
88 ACE_ERROR_RETURN ((LM_ERROR
,
89 "be_visitor_operation_svs::"
91 "codegen for argument list failed\n"),
95 return this->gen_op_body (node
);
99 be_visitor_operation_svs::gen_op_body (be_operation
*node
)
104 ACE_CString
sname_str (ScopeAsDecl (scope_
->defined_in ())->full_name ());
105 const char *global
= (sname_str
== "" ? "" : "::");
107 if (this->ctx_
->state () == TAO_CodeGen::TAO_ROOT_SVTS
)
109 os_
<< "typename EXEC::_var_type executor = " << be_idt_nl
110 << "EXEC::_duplicate (this->executor_.in ());" << be_uidt
;
114 os_
<< "::" << sname_str
<< global
<< "CCM_" << scope_
->original_local_name ()
115 << "_var executor = " << be_idt_nl
116 << "::" << sname_str
<< global
<< "CCM_" << scope_
->original_local_name ()
117 << "::_duplicate (this->executor_.in ());" << be_uidt
;
121 << "if (::CORBA::is_nil (executor.in ()))"
124 << "throw ::CORBA::INV_OBJREF ();" << be_uidt_nl
125 << "}" << be_uidt_nl
<< be_nl
;
127 bool const vrt
= node
->void_return_type ();
134 os_
<< "executor->" << node
->local_name () << " (";
136 if (node
->argument_count () == 0)
144 if (this->visit_scope (node
) == -1)
146 ACE_ERROR_RETURN ((LM_ERROR
,
147 ACE_TEXT ("be_visitor_operation_svs")
148 ACE_TEXT ("::gen_op_body - ")
149 ACE_TEXT ("visit_scope() failed\n")),
161 be_visitor_operation_svs::visit_argument (be_argument
*node
)
163 os_
<< node
->local_name ();
169 be_visitor_operation_svs::post_process (be_decl
*bd
)
171 if (this->last_node (bd
))
173 os_
<< ");" << be_uidt
;
184 be_visitor_operation_svs::scope (be_decl
*node
)