field_cs.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 1,169 行 · 第 1/3 页
CPP
1,169 行
*os << "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ".ptr ();" << be_uidt_nl;
*os << "}";
return 0;
}
int
be_visitor_valuetype_field_cs::visit_valuetype (be_valuetype *node)
{
be_decl *ub = this->ctx_->node ();
be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ());
be_type *bt;
// Check if we are visiting this node via a visit to a typedef node.
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
if (!ub || !bu)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_cs::"
"visit_interface - "
"bad context information\n"),
-1);
}
TAO_OutStream *os = this->ctx_->stream ();
*os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
*os << "// Accessor to set the member." << be_nl
<< this->pre_op () << "void" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name () << " (" << bt->name ()
<< "* val)" << be_nl
<< "{" << be_idt_nl;
*os << "CORBA::add_ref (val);" << be_nl
<< "this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< " = val;" << be_uidt_nl;
*os << "}" << be_nl << be_nl;
*os << "// Retrieve the member" << be_nl
<< this->pre_op () << bt->name () << " *" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name () << " () const"
<< be_nl
<< "{" << be_idt_nl;
*os << "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ".ptr ();" << be_uidt_nl;
*os << "}";
return 0;
}
int
be_visitor_valuetype_field_cs::visit_valuetype_fwd (be_valuetype_fwd *node)
{
be_decl *ub = this->ctx_->node ();
be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ());
be_type *bt;
// Check if we are visiting this node via a visit to a typedef node.
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
if (!ub || !bu)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_cs::"
"visit_interface - "
"bad context information\n"),
-1);
}
TAO_OutStream *os = this->ctx_->stream ();
*os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
*os << "// Accessor to set the member." << be_nl
<< this->pre_op () << "void" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name () << " (" << bt->name ()
<< "* val)" << be_nl
<< "{" << be_idt_nl;
*os << "CORBA::add_ref (val);" << be_nl
<< "this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< " = val;" << be_uidt_nl;
*os << "}" << be_nl << be_nl;
*os << "// Retrieve the member." << be_nl
<< this->pre_op () << bt->name () << " *" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name () << " () const"
<< be_nl
<< "{" << be_idt_nl;
*os << "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix
()
<< ".ptr ();" << be_uidt_nl;
*os << "}";
return 0;
}
int
be_visitor_valuetype_field_cs::visit_predefined_type (be_predefined_type *node)
{
be_decl *ub = this->ctx_->node ();
be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ());
be_type *bt;
// Check if we are visiting this node via a visit to a typedef node.
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
if (!ub || !bu)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_cs::"
"visit_predef... - "
"bad context information\n"),
-1);
}
TAO_OutStream *os = this->ctx_->stream ();
*os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
*os << "// Accessor to set the member." << be_nl
<< this->pre_op () << "void" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name ()
<< " (" << bt->name ();
AST_PredefinedType::PredefinedType pt = node->pt ();
if (pt == AST_PredefinedType::PT_pseudo
|| pt == AST_PredefinedType::PT_object)
{
*os << "_ptr";
}
else if (pt == AST_PredefinedType::PT_any)
{
*os << " &";
}
*os << " val)" << be_nl
<< "{" << be_idt_nl;
switch (pt)
{
case AST_PredefinedType::PT_pseudo:
case AST_PredefinedType::PT_object:
*os << "this->" << bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix () << " = "
<< bt->name () << "::_duplicate (val);" << be_uidt_nl;
break;
case AST_PredefinedType::PT_any:
*os << "this->" << bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix () << " = val;" << be_uidt_nl;
break;
case AST_PredefinedType::PT_void:
break;
default:
*os << "// Set the value." << be_nl
<< "this->" << bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< " = val;" << be_uidt_nl;
break;
}
*os << "}" << be_nl << be_nl;
switch (node->pt ())
{
case AST_PredefinedType::PT_pseudo:
case AST_PredefinedType::PT_object:
*os << "// Retrieve the member" << be_nl
<< this->pre_op () << bt->name () << "_ptr" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name ()
<< " (void) const" << be_nl
<< "{" << be_idt_nl
<< "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ".in ();" << be_uidt_nl
<< "}";
break;
case AST_PredefinedType::PT_any:
*os << "// Retrieve the member." << be_nl
<< this->pre_op () << "const " << bt->name () << " &" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name ()
<< " (void) const" << be_nl
<< "{" << be_idt_nl
<< "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ";" << be_uidt_nl
<< "}" << be_nl << be_nl;
*os << "// Retrieve the member" << be_nl
<< this->pre_op () << bt->name () << " &" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name ()
<< " (void)" << be_nl
<< "{" << be_idt_nl
<< "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ";" << be_uidt_nl
<< "}";
break;
case AST_PredefinedType::PT_void:
break;
default:
*os << "// Retrieve the member" << be_nl
<< this->pre_op () << bt->name () << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name ()
<< " (void) const" << be_nl
<< "{" << be_idt_nl
<< "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ";" << be_uidt_nl
<< "}";
break;
}
return 0;
}
int
be_visitor_valuetype_field_cs::visit_sequence (be_sequence *node)
{
be_decl *ub = this->ctx_->node ();
be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ());
be_type *bt;
// Check if we are visiting this node via a visit to a typedef node.
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
if (!ub || !bu)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_cs::"
"visit_sequence - "
"bad context information\n"),
-1);
}
TAO_OutStream *os = this->ctx_->stream ();
if (bt->node_type () != AST_Decl::NT_typedef // not a typedef
&& bt->is_child (bu)) // bt is defined inside the union
{
be_visitor_context ctx (*this->ctx_);
ctx.node (node);
be_visitor_sequence_cs visitor (&ctx);
if (node->accept (&visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_cs::"
"visit_sequence - "
"codegen failed\n"),
-1);
}
}
*os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
// (1) set from a const
*os << "// Accessor to set the member." << be_nl
<< this->pre_op () << "void" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name ()
<< " (const " << bt->name () << " &val)" << be_nl
<< "{" << be_idt_nl;
*os << "this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< " = val;" << be_uidt_nl;
*os << "}" << be_nl << be_nl;
*os << "// Readonly get method." << be_nl
<< this->pre_op () << "const " << bt->name () << " &" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name ()
<< " (void) const" << be_nl
<< "{" << be_idt_nl
<< "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ";" << be_uidt_nl
<< "}" << be_nl << be_nl;
*os << "// Read/write get method." << be_nl
<< this->pre_op () << bt->name () << " &" << be_nl;
this->op_name (bu,
os);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?