field_cs.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 1,169 行 · 第 1/3 页
CPP
1,169 行
*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
<< "}";
return 0;
}
int
be_visitor_valuetype_field_cs::visit_string (be_string *node)
{
be_decl *ub = this->ctx_->node ();
be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ());
if (!ub || !bu)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_cs::"
"visit_string - "
"bad context information\n"),
-1);
}
TAO_OutStream *os = this->ctx_->stream ();
// Three methods to set the string value.
*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);
if (node->width () == (long) sizeof (char))
{
*os << "::" << ub->local_name () << " (char *val)";
}
else
{
*os << "::" << ub->local_name () << " (CORBA::WChar *val)";
}
*os << be_nl
<< "{" << be_idt_nl;
*os << "this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< " = (val);" << be_uidt_nl
<< "}" << be_nl << be_nl;
// (2) Set method from const char * or const wchar*.
*os << "// Accessor to set the member." << be_nl
<< this->pre_op () << "void" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name ();
if (node->width () == (long) sizeof (char))
{
*os << " (const char *val)" << be_nl;
}
else
{
*os << " (const CORBA::WChar *val)" << be_nl;
}
*os << "{" << be_idt_nl;
*os << "// Set the value." << be_nl
<< "this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< " = ";
if (node->width () == (long) sizeof (char))
{
*os << "CORBA::string_dup (val);" << be_uidt_nl;
}
else
{
*os << "CORBA::wstring_dup (val);" << be_uidt_nl;
}
*os << "}" << be_nl << be_nl;
// (3) Set from const String_var&.
*os << "// Accessor to set the member." << be_nl
<< this->pre_op () << "void" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name ();
if (node->width () == (long) sizeof (char))
{
*os << " (const CORBA::String_var &val)" << be_nl;
}
else
{
*os << " (const CORBA::WString_var &val)" << be_nl;
}
*os << "{" << be_idt_nl;
if (node->width () == (long) sizeof (char))
{
*os << "CORBA::String_var " << ub->local_name ();
}
else
{
*os << "CORBA::WString_var " << ub->local_name ();
}
*os << "_var = val;" << be_nl
<< "this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< " = "
<< ub->local_name () << "_var._retn ();" << be_uidt_nl;
*os << "}" << be_nl << be_nl;
if (node->width () == (long) sizeof (char))
{
*os << this->pre_op () << "const char *" << be_nl;
}
else
{
*os << this->pre_op () << "const CORBA::WChar *" << be_nl;
}
this->op_name (bu,
os);
*os << "::" << ub->local_name ()
<< " (void) const // get method" << be_nl
<< "{" << be_idt_nl
<< "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ";" << be_uidt_nl
<< "}";
return 0;
}
int
be_visitor_valuetype_field_cs::visit_structure (be_structure *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_structure - "
"bad context information\n"),
-1);
}
TAO_OutStream *os = this->ctx_->stream ();
if (bt->node_type () != AST_Decl::NT_typedef
&& bt->is_child (bu))
{
be_visitor_context ctx (*this->ctx_);
ctx.node (node);
be_visitor_structure_cs visitor (&ctx);
if (node->accept (&visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_cs::"
"visit_structure - "
"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;
*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;
*os << "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ";" << be_uidt_nl;
*os << "}" << be_nl;
*os << "// Read/write get method." << be_nl
<< this->pre_op () << bt->name () << " &" << be_nl;
this->op_name (bu,
os);
*os << "::" << ub->local_name () << " (void)" << be_nl
<< "{" << be_idt_nl;
*os << "return this->"
<< bu->field_pd_prefix () << ub->local_name ()
<< bu->field_pd_postfix ()
<< ";" << be_uidt_nl;
*os << "}";
return 0;
}
int
be_visitor_valuetype_field_cs::visit_typedef (be_typedef *node)
{
this->ctx_->alias (node);
be_type *bt = node->primitive_base_type ();
if (!bt || (bt->accept (this) == -1))
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_cs::"
"visit_typedef - "
"Bad primitive type\n"),
-1);
}
this->ctx_->alias (0);
return 0;
}
int
be_visitor_valuetype_field_cs::visit_union (be_union *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_union - "
"bad context information\n"),
-1);
}
TAO_OutStream *os = this->ctx_->stream ();
if (bt->node_type () != AST_Decl::NT_typedef
&& bt->is_child (bu))
{
be_visitor_context ctx (*this->ctx_);
ctx.node (node);
be_visitor_union_cs visitor (&ctx);
if (node->accept (&visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_field_cs::"
"visit_union - "
"codegen failed\n"),
-1);
}
}
*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 ()
<< " (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;
*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;
*os << "// Read/write get method." << 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
<< "}";
return 0;
}
void
be_visitor_valuetype_field_cs::setenclosings (const char *pre)
{
this->pre_op_ = pre;
}
const char*
be_visitor_valuetype_field_cs::pre_op ()
{
return this->pre_op_;
}
// Retrieve the fully scoped skeleton name.
void
be_visitor_valuetype_field_cs::op_name (be_valuetype *node,
TAO_OutStream *os)
{
if (this->in_obv_space_)
{
*os << node->full_obv_skel_name ();
}
else
{
*os << node->name ();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?