cdr_op_ci.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 1,019 行 · 第 1/3 页
CPP
1,019 行
// Check what is the code generations substate. Are we generating code for
// the in/out operators for our parent or for us?
switch (this->ctx_->sub_state ())
{
case TAO_CodeGen::TAO_CDR_INPUT:
*os << "(strm >> _tao_aggregate." << f->local_name () << ".out ())";
break;
case TAO_CodeGen::TAO_CDR_OUTPUT:
if (node->is_defined ())
{
*os << "CORBA::Object::marshal (" << be_idt << be_idt_nl
<< "_tao_aggregate." << f->local_name () << ".in ()," << be_nl
<< "strm" << be_uidt_nl
<< ")" << be_uidt;
}
else
{
AST_Decl *parent = ScopeAsDecl (node->defined_in ());
if (parent != 0 && parent->node_type () != AST_Decl::NT_root)
{
*os << parent->name () << "::";
}
*os << "TAO::Objref_Traits<" << node->name () << ">::tao_marshal ("
<< be_idt << be_idt_nl
<< "_tao_aggregate." << f->local_name () << ".in ()," << be_nl
<< "strm" << be_uidt_nl
<< ")" << be_uidt;
}
break;
case TAO_CodeGen::TAO_CDR_SCOPE:
// Nothing to be done because an interface cannot be declared inside a
// structure.
break;
default:
// Error.
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_interface_fwd - "
"bad sub state\n"),
-1);
}
return 0;
}
// Visit value type.
int
be_visitor_field_cdr_op_ci::visit_valuetype (be_valuetype *)
{
TAO_OutStream *os = this->ctx_->stream ();
be_field *f = this->ctx_->be_node_as_field ();
if (!f)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_valuetype - "
"cannot retrieve field node\n"),
-1);
}
// Check what is the code generations substate. Are we generating code for
// the in/out operators for our parent or for us?
switch (this->ctx_->sub_state ())
{
case TAO_CodeGen::TAO_CDR_INPUT:
*os << "(strm >> _tao_aggregate." << f->local_name () << ".out ())";
break;
case TAO_CodeGen::TAO_CDR_OUTPUT:
*os << "(strm << _tao_aggregate." << f->local_name () << ".in ())";
break;
case TAO_CodeGen::TAO_CDR_SCOPE:
// Nothing to be done because a valuetype cannot be declared inside a
// structure.
break;
default:
// Error.
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_valuetype - "
"bad sub state\n"),
-1);
}
return 0;
}
// Visit value forward type.
int
be_visitor_field_cdr_op_ci::visit_valuetype_fwd (be_valuetype_fwd *)
{
TAO_OutStream *os = this->ctx_->stream ();
// Retrieve the field node.
be_field *f = this->ctx_->be_node_as_field ();
if (f == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_valuetype_fwd - "
"cannot retrieve field node\n"),
-1);
}
// Check what is the code generations substate. Are we generating code for
// the in/out operators for our parent or for us?
switch (this->ctx_->sub_state ())
{
case TAO_CodeGen::TAO_CDR_INPUT:
*os << "(strm >> _tao_aggregate." << f->local_name () << ".out ())";
break;
case TAO_CodeGen::TAO_CDR_OUTPUT:
*os << "(strm << _tao_aggregate." << f->local_name () << ".in ())";
break;
case TAO_CodeGen::TAO_CDR_SCOPE:
// Nothing to be done because a valuetype cannot be declared inside a
// structure.
break;
default:
// Error.
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_valuetype_fwd - "
"bad sub state\n"),
-1);
}
return 0;
}
// Visit predefined type.
int
be_visitor_field_cdr_op_ci::visit_predefined_type (be_predefined_type *node)
{
TAO_OutStream *os = this->ctx_->stream ();
// Retrieve the field node.
be_field *f = this->ctx_->be_node_as_field ();
if (f == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_predefined_type - "
"cannot retrieve field node\n"),
-1);
}
AST_PredefinedType::PredefinedType pt = node->pt ();
// Check what is the code generations substate. Are we generating code for
// the in/out operators for our parent or for us?
switch (this->ctx_->sub_state ())
{
case TAO_CodeGen::TAO_CDR_INPUT:
if (pt == AST_PredefinedType::PT_pseudo
|| pt == AST_PredefinedType::PT_object)
{
*os << "(strm >> _tao_aggregate." << f->local_name ()
<< ".out ())";
}
else if (pt == AST_PredefinedType::PT_char)
{
*os << "(strm >> CORBA::Any::to_char (_tao_aggregate."
<< f->local_name () << "))";
}
else if (pt == AST_PredefinedType::PT_wchar)
{
*os << "(strm >> CORBA::Any::to_wchar (_tao_aggregate."
<< f->local_name () << "))";
}
else if (pt == AST_PredefinedType::PT_octet)
{
*os << "(strm >> CORBA::Any::to_octet (_tao_aggregate."
<< f->local_name () << "))";
}
else if (pt == AST_PredefinedType::PT_boolean)
{
*os << "(strm >> CORBA::Any::to_boolean (_tao_aggregate."
<< f->local_name () << "))";
}
else
{
*os << "(strm >> _tao_aggregate." << f->local_name () << ")";
}
break;
case TAO_CodeGen::TAO_CDR_OUTPUT:
if (pt == AST_PredefinedType::PT_pseudo
|| pt == AST_PredefinedType::PT_object)
{
*os << "(strm << _tao_aggregate." << f->local_name () << ".in ())";
}
else if (pt == AST_PredefinedType::PT_char)
{
*os << "(strm << CORBA::Any::from_char (_tao_aggregate."
<< f->local_name () << "))";
}
else if (pt == AST_PredefinedType::PT_wchar)
{
*os << "(strm << CORBA::Any::from_wchar (_tao_aggregate."
<< f->local_name () << "))";
}
else if (pt == AST_PredefinedType::PT_octet)
{
*os << "(strm << CORBA::Any::from_octet (_tao_aggregate."
<< f->local_name () << "))";
}
else if (pt == AST_PredefinedType::PT_boolean)
{
*os << "(strm << CORBA::Any::from_boolean (_tao_aggregate."
<< f->local_name () << "))";
}
else
{
*os << "(strm << _tao_aggregate." << f->local_name () << ")";
}
break;
case TAO_CodeGen::TAO_CDR_SCOPE:
// Nothing to be done.
break;
default:
// Error.
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_array - "
"bad sub state\n"),
-1);
}
return 0;
}
// Visit sequence type.
int
be_visitor_field_cdr_op_ci::visit_sequence (be_sequence *node)
{
TAO_OutStream *os = this->ctx_->stream ();
// Retrieve the field node.
be_field *f = this->ctx_->be_node_as_field ();
if (f == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_sequence - "
"cannot retrieve field node\n"),
-1);
}
// Check what is the code generations substate. Are we generating code for
// the in/out operators for our parent or for us?
switch (this->ctx_->sub_state ())
{
case TAO_CodeGen::TAO_CDR_INPUT:
*os << "(strm >> _tao_aggregate." << f->local_name () << ")";
return 0;
case TAO_CodeGen::TAO_CDR_OUTPUT:
*os << "(strm << _tao_aggregate." << f->local_name () << ")";
return 0;
case TAO_CodeGen::TAO_CDR_SCOPE:
// Proceed further.
break;
default:
// Error.
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_sequence - "
"bad sub state\n"),
-1);
}
if (node->node_type () != AST_Decl::NT_typedef
&& node->is_child (this->ctx_->scope ()))
// Not a typedef AND
// node is defined inside the structure.
{
// Anonymous sequence.
// Instantiate a visitor context with a copy of our context. This info
// will be modified based on what type of node we are visiting.
be_visitor_context ctx (*this->ctx_);
// Set the node to be the node being visited. The scope is
// still the same.
ctx.node (node);
// Generate the inline code for structs.
be_visitor_sequence_cdr_op_ci visitor (&ctx);
if (node->accept (&visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_sequence - "
"codegen failed\n"),
-1);
}
}
return 0;
}
// Visit string type.
int
be_visitor_field_cdr_op_ci::visit_string (be_string *)
{
TAO_OutStream *os = this->ctx_->stream ();
// Retrieve the field node.
be_field *f = this->ctx_->be_node_as_field ();
if (f == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_cdr_op_ci::"
"visit_string - "
"cannot retrieve field node\n"),
-1);
}
// check what is the code generation's substate. Are we generating code for
// the in/out operators for our parent or for us?
switch (this->ctx_->sub_state ())
{
case TAO_CodeGen::TAO_CDR_INPUT:
*os << "(strm >> _tao_aggregate." << f->local_name () << ".out ())";
break;
case TAO_CodeGen::TAO_CDR_OUTPUT:
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?