interceptors_cs.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 892 行 · 第 1/2 页
CPP
892 行
if (node->defined_in ()->is_abstract ())
{
*os << "CORBA::AbstractBase_ptr _tao_target";
}
else
{
*os << "CORBA::Object_ptr _tao_target";
}
// Generate the argument list with the appropriate mapping. For these
// we grab a visitor that generates the parameter listing.
ctx = *this->ctx_;
ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CS);
be_visitor_operation_interceptors_arglist toiia_visitor (&ctx);
if (node->accept (&toiia_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_cs::"
"visit_operation - "
"codegen for argument pre invoke failed\n"),
-1);
}
os->indent ();
*os << be_uidt_nl << ")" << be_uidt_nl;
// Generate the member list and set each member but before that,
// its necessary to pass on some args to the base class.
os->indent ();
*os << " : TAO_ClientRequestInfo_i (_tao_invocation, _tao_target)";
ctx = *this->ctx_;
ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_CS);
be_visitor_operation_interceptors_arglist oiai_visitor (&ctx);
if (node->accept (&oiai_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_cs::"
"visit_operation - "
"codegen for argument pre invoke failed\n"),
-1);
}
os->decr_indent ();
*os << be_nl << "{}\n\n";
// -----------------------------------------------------------------
// PortableInterceptor::ClientRequestInfo::arguments()
// -----------------------------------------------------------------
*os << "Dynamic::ParameterList *" << be_nl;
// The interceptors cant modify "in" and "out" parameters.
*os << "TAO_ClientRequestInfo_" << node->flat_name ();
// We need the interface node in which this operation was defined. However,
// if this operation node was an attribute node in disguise, we get this
// information from the context and add a "_get"/"_set" to the flat
// name to get around the problem of overloaded methods which are
// generated for attributes.
if (this->ctx_->attribute ())
{
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void it means it is not the accessor.
if (!this->void_return_type (bt))
{
*os << "_get";
}
else
{
*os << "_set";
}
}
*os << "::arguments (ACE_ENV_SINGLE_ARG_DECL)" << be_idt_nl
<< "ACE_THROW_SPEC ((CORBA::SystemException))"<< be_uidt_nl
<< "{" << be_idt_nl;
if (be_global->any_support ())
{
*os << "// Generate the argument list on demand." << be_nl
<< "Dynamic::ParameterList *parameter_list =" << be_idt_nl
<< "TAO_RequestInfo_Util::make_parameter_list "
<< "(ACE_ENV_SINGLE_ARG_PARAMETER);"
<< be_uidt_nl
<< "ACE_CHECK_RETURN (0);" << be_nl
<< be_nl;
size_t parameter_count = this->count_non_out_parameters (node);
if (node->argument_count () == 0
|| parameter_count == 0
// Now make sure that we have some in and inout
// parameters. Otherwise, there is nothing to be put into
// the Dyanmic::Paramlist.
|| (!(this->has_param_type (node, AST_Argument::dir_IN))
&& !(this->has_param_type (node, AST_Argument::dir_INOUT))))
{
*os << "return parameter_list;";
}
else
{
*os << "Dynamic::ParameterList_var safe_parameter_list = "
<< "parameter_list;" << be_nl;
// Precompute the length of the Dynamic::ParameterList. This is
// a nice optimization since it reduces the number of additional
// allocations to one, instead of one for each argument, in
// addition to remove all copying that occured when growing the
// sequence for each parameter.
*os << be_nl
<< "parameter_list->length (" << parameter_count << ");"
<< be_nl;
*os << "CORBA::ULong len = 0;";
// The insertion operator is different for different nodes. We
// change our scope to go to the argument scope to be able to
// decide this.
ctx = *this->ctx_;
ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST);
be_visitor_operation_interceptors_arglist oip_visitor (&ctx);
if (node->accept (&oip_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_cs::"
"visit_operation - "
"codegen for argument pre invoke failed\n"),
-1);
}
*os << be_nl
<< "return safe_parameter_list._retn ();";
}
}
else
{
if (be_global->use_raw_throw ())
{
*os << "throw (CORBA::NO_IMPLEMENT ());" << be_nl
<< "return 0;";
}
else
{
*os << "ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);";
}
}
*os << be_uidt_nl << "}";
// -----------------------------------------------------------------
// PortableInterceptor::ClientRequestInfo::exceptions()
// -----------------------------------------------------------------
*os << be_nl << be_nl
<< "Dynamic::ExceptionList *" << be_nl;
*os << "TAO_ClientRequestInfo_" << node->flat_name ();
// We need the interface node in which this operation was defined. However,
// if this operation node was an attribute node in disguise, we get this
// information from the context and add a "_get"/"_set" to the flat
// name to get around the problem of overloaded methods which are
// generated for attributes.
if (this->ctx_->attribute ())
{
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void it means it is not the accessor.
if (!this->void_return_type (bt))
{
*os << "_get";
}
else
{
*os << "_set";
}
}
*os << "::exceptions (ACE_ENV_SINGLE_ARG_DECL)"<< be_idt_nl
<< "ACE_THROW_SPEC ((CORBA::SystemException))" << be_uidt_nl
<< "{" << be_idt_nl;
if (be_global->tc_support ())
{
*os << "// Generate the exception list on demand." << be_nl
<< "Dynamic::ExceptionList *exception_list =" << be_idt_nl
<< "TAO_RequestInfo_Util::make_exception_list "
<< "(ACE_ENV_SINGLE_ARG_PARAMETER);"
<< be_uidt_nl
<< "ACE_CHECK_RETURN (0);" << be_nl
<< be_nl;
if (!node->exceptions ())
{
*os << "return exception_list;";
}
else
{
*os << "Dynamic::ExceptionList_var safe_exception_list = "
<< "exception_list;" << be_nl;
// We change our scope to be able to generate the exceptionlist.
ctx = *this->ctx_;
ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST);
be_visitor_operation_interceptors_exceptlist oie_visitor (&ctx);
if (node->accept (&oie_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_cs::"
"visit_operation - "
"codegen for exceptlist failed\n"),
-1);
}
*os << be_nl
<< "return safe_exception_list._retn ();";
}
}
else
{
if (be_global->use_raw_throw ())
{
*os << "throw (CORBA::NO_IMPLEMENT ());" << be_nl
<< "return 0;";
}
else
{
*os << "ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);";
}
}
*os << be_uidt_nl << "}\n\n";
os->decr_indent ();
// -----------------------------------------------------------------
// PortableInterceptor::ClientRequestInfo::result()
// -----------------------------------------------------------------
*os << "CORBA::Any * " << be_nl;
*os << "TAO_ClientRequestInfo_" << node->flat_name ();
// We need the interface node in which this operation was defined. However,
// if this operation node was an attribute node in disguise, we get this
// information from the context and add a "_get"/"_set" to the flat
// name to get around the problem of overloaded methods which are
// generated for attributes.
if (this->ctx_->attribute ())
{
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void it means it is not the accessor.
if (!this->void_return_type (bt))
{
*os << "_get";
}
else
{
*os << "_set";
}
}
*os << "::result (ACE_ENV_SINGLE_ARG_DECL)" << be_idt_nl
<< "ACE_THROW_SPEC ((CORBA::SystemException))" << be_uidt_nl
<< "{" << be_idt_nl;
if (be_global->any_support ())
{
*os << "// Generate the result on demand." << be_nl;
bt = be_type::narrow_from_decl (node->return_type ());
if (this->void_return_type (bt))
{
// Return an Any with tk_void TypeCode.
*os << "const CORBA::Boolean tk_void_any = 1;" << be_nl
<< "CORBA::Any *result_any =" << be_idt_nl
<< "TAO_RequestInfo_Util::make_any "
<< "(tk_void_any ACE_ENV_ARG_PARAMETER);"
<< be_uidt_nl
<< "ACE_CHECK_RETURN (0);" << be_nl
<< be_nl
<< "return result_any;";
}
else
{
*os << "const CORBA::Boolean tk_void_any = 0;" << be_nl
<< "CORBA::Any *result_any =" << be_idt_nl
<< "TAO_RequestInfo_Util::make_any "
<< "(tk_void_any ACE_ENV_ARG_PARAMETER);"
<< be_uidt_nl
<< "ACE_CHECK_RETURN (0);" << be_nl
<< be_nl
<< "CORBA::Any_var safe_result_any = "
<< "result_any;" << be_nl << be_nl;
// Generate the insertion of result into Any.
ctx = *this->ctx_;
be_visitor_operation_interceptors_result oir_visitor (&ctx);
if (bt->accept (&oir_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_cs::"
"visit_operation - "
"codegen for result failed\n"),
-1);
}
*os << "return safe_result_any._retn ();";
}
}
else
{
if (be_global->use_raw_throw ())
{
*os << "throw (CORBA::NO_IMPLEMENT ());" << be_nl
<< "return 0;";
}
else
{
*os << "ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0);";
}
}
*os << be_uidt_nl << "}\n\n";
os->decr_indent ();
// -----------------------------------------------------------------
// Update the result.
// -----------------------------------------------------------------
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type accessor if
// its not void since we cant have a private member to be of void
// type.
if (!this->void_return_type (bt))
{
*os << "void " << be_nl;
*os << "TAO_ClientRequestInfo_"<< node->flat_name ();
// We need the interface node in which this operation was defined.
// However, if this operation node was an attribute node in disguise,
// we get this information from the context and add a "_get"/"_set"
// to the flat name to get around the problem of overloaded methods
// which are generated for attributes.
if (this->ctx_->attribute ())
{
bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interceptors_ch::"
"visit_operation - "
"Bad return type\n"),
-1);
}
// Grab the right visitor to generate the return type if its not
// void it means it is not the accessor.
if (!this->void_return_type (bt))
{
*os << "_get";
}
else
{
*os << "_set";
}
}
*os << "::"
<< "result (";
ctx = *this->ctx_;
be_visitor_operation_rettype or_visitor (&ctx);
if (bt->accept (&or_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_operation_cs::"
"visit_operation - "
"codegen for retval pre invoke failed\n"),
-1);
}
os->indent ();
*os << " result)" << be_uidt << be_uidt << be_uidt_nl
<< "{" << be_idt_nl
<< "// Update the result. " << be_nl
<< "this->_result = result;" << be_uidt_nl
<< "}";
}
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?