rettype_marshal_ss.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 540 行 · 第 1/2 页
CPP
540 行
//
// rettype_marshal_ss.cpp,v 1.15 2003/12/31 21:28:04 bala Exp
//
// ============================================================================
//
// = LIBRARY
// TAO IDL
//
// = FILENAME
// rettype_marshal_ss.cpp
//
// = DESCRIPTION
// Visitor generating the code that passes retval to the CDR operators. The
// "OUTPUT" substate deals with the server side skeletons whereas the
// "INPUT" substate deals with the client stubs. Also notice that the type
// of parameter passed to the operator depends on the manner in which the
// variable is declared i.e., in the skeleton, we may have _var types but
// not in the stubs.
//
// = AUTHOR
// Aniruddha Gokhale
//
// ============================================================================
ACE_RCSID (be_visitor_operation,
rettype_marshal_ss,
"rettype_marshal_ss.cpp,v 1.15 2003/12/31 21:28:04 bala Exp")
// ****************************************************************************
// visitor for arguments passing to the CDR operators.
// ****************************************************************************
be_visitor_operation_rettype_marshal_ss::
be_visitor_operation_rettype_marshal_ss (be_visitor_context *ctx)
: be_visitor_decl (ctx)
{
}
be_visitor_operation_rettype_marshal_ss::
~be_visitor_operation_rettype_marshal_ss (void)
{
}
int be_visitor_operation_rettype_marshal_ss::visit_operation (
be_operation *node
)
{
this->ctx_->node (node);
be_type *bt = be_type::narrow_from_decl (node->return_type ());
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_argument - "
"Bad argument type\n"),
-1);
}
// Different types have different mappings when used as in/out or
// inout parameters. Let this visitor deal with the type
TAO_OutStream *os = this->ctx_->stream ();
*os << be_nl;
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
{
*os << "(_tao_out << ";
}
else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
{
*os << "(_tao_in >> ";
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_operation - "
"Bad substate\n"),
-1);
}
if (bt->accept (this) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_operation - "
"cannot accept visitor\n"),
-1);
}
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
{
*os << ")";
}
else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
{
*os << ")";
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_operation - "
"Bad substate\n"),
-1);
}
return 0;
}
int be_visitor_operation_rettype_marshal_ss::visit_array (be_array *)
{
TAO_OutStream *os = this->ctx_->stream (); // get output stream
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
{
*os << "_tao_retval_forany";
}
else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
{
*os << "_tao_retval_forany";
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_array - "
"Bad substate\n"),
-1);
}
return 0;
}
int be_visitor_operation_rettype_marshal_ss::visit_enum (be_enum *)
{
TAO_OutStream *os = this->ctx_->stream (); // get output stream
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
{
*os << "_tao_retval";
}
else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
{
*os << "_tao_retval";
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_enum - "
"Bad substate\n"),
-1);
}
return 0;
}
int be_visitor_operation_rettype_marshal_ss::visit_interface (be_interface *)
{
TAO_OutStream *os = this->ctx_->stream (); // get output stream
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
{
*os << "_tao_retval.in ()";
}
else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
{
*os << "_tao_retval.inout ()";
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_interface - "
"Bad substate\n"),
-1);
}
return 0;
}
int be_visitor_operation_rettype_marshal_ss::visit_interface_fwd (be_interface_fwd *)
{
TAO_OutStream *os = this->ctx_->stream (); // get output stream
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
{
*os << "_tao_retval.in ()";
}
else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
{
*os << "_tao_retval.inout ()";
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_interface - "
"Bad substate\n"),
-1);
}
return 0;
}
int be_visitor_operation_rettype_marshal_ss::visit_valuetype (be_valuetype *)
{
TAO_OutStream *os = this->ctx_->stream (); // get output stream
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
{
*os << "_tao_retval.in ()";
}
else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
{
*os << "_tao_retval.inout ()";
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_valuetype - "
"Bad substate\n"),
-1);
}
return 0;
}
int be_visitor_operation_rettype_marshal_ss::visit_valuetype_fwd (be_valuetype_fwd *)
{
TAO_OutStream *os = this->ctx_->stream (); // get output stream
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
{
*os << "_tao_retval.in ()";
}
else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT)
{
*os << "_tao_retval.inout ()";
}
else
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_operation_rettype_compiled_marshal::"
"visit_valuetype - "
"Bad substate\n"),
-1);
}
return 0;
}
int be_visitor_operation_rettype_marshal_ss::visit_predefined_type (be_predefined_type *node)
{
TAO_OutStream *os = this->ctx_->stream (); // get output stream
if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT)
{
switch (node->pt ())
{
case AST_PredefinedType::PT_pseudo:
case AST_PredefinedType::PT_object:
*os << "_tao_retval.in ()";
break;
case AST_PredefinedType::PT_any:
*os << "_tao_retval.in ()";
break;
case AST_PredefinedType::PT_long:
case AST_PredefinedType::PT_ulong:
case AST_PredefinedType::PT_longlong:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?