field_ch.cpp
来自「这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用」· C++ 代码 · 共 668 行 · 第 1/2 页
CPP
668 行
}
else
{
*os << bt->name () << "_var";
}
return 0;
}
int
be_visitor_field_ch::visit_predefined_type (be_predefined_type *node)
{
TAO_OutStream *os = this->ctx_->stream ();
be_type *bt;
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
if (node->pt () == AST_PredefinedType::PT_object)
{
*os << bt->name () << "_var";
}
else if (node->pt () == AST_PredefinedType::PT_pseudo)
{
// This was a typedefed array.
// ACE_NESTED_CLASS macro generated by nested_type_name
// is necessary if the struct, union, or valuetype containing this
// field was not defined inside a module. In such a case, VC++
// complains that the non-module scope is not yet fully defined.
UTL_Scope *holds_container = this->ctx_->scope ()->defined_in ();
AST_Decl *hc_decl = ScopeAsDecl (holds_container);
if (hc_decl->node_type () != AST_Decl::NT_module)
{
*os << bt->nested_type_name (this->ctx_->scope (), "_var");
}
else
{
*os << bt->name () << "_var";
}
}
else
{
// This was a typedefed array.
// ACE_NESTED_CLASS macro generated by nested_type_name
// is necessary if the struct, union, or valuetype containing this
// field was not defined inside a module. In such a case, VC++
// complains that the non-module scope is not yet fully defined.
UTL_Scope *holds_container = this->ctx_->scope ()->defined_in ();
AST_Decl *hc_decl = ScopeAsDecl (holds_container);
if (hc_decl->node_type () != AST_Decl::NT_module)
{
*os << bt->nested_type_name (this->ctx_->scope ());
}
else
{
*os << bt->name ();
}
}
return 0;
}
int
be_visitor_field_ch::visit_sequence (be_sequence *node)
{
TAO_OutStream *os = this->ctx_->stream ();
be_type *bt;
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
if (!this->ctx_->alias ()
&& node->is_child (this->ctx_->scope ()))
{
// Put the field node into the (anonymous) sequence node, to be
// used later for unique name generation.
be_field *member_node =
be_field::narrow_from_decl (this->ctx_->node ());
node->field_node (member_node);
be_visitor_context ctx (*this->ctx_);
ctx.node (node);
// First generate the sequence declaration.
be_visitor_sequence_ch visitor (&ctx);
if (node->accept (&visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_sequence - "
"codegen failed\n"),
-1);
}
// If we are being reused by valutype, this would get generated
// in the private section of the OBV_xx class, so we must
// generate the typedef for that case elsewhere.
if (this->ctx_->scope ()->node_type () != AST_Decl::NT_valuetype)
{
// Generate the anonymous sequence member typedef.
be_decl *bs = this->ctx_->scope ();
*os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
*os << "typedef " << bt->nested_type_name (bs)
<< " _" << this->ctx_->node ()->local_name ()
<< "_seq;" << be_nl;
}
}
// ACE_NESTED_CLASS macro generated by nested_type_name
// is not necessary in all cases.
be_typedef *tdef = be_typedef::narrow_from_decl (bt);
// This was a typedefed array.
// ACE_NESTED_CLASS macro generated by nested_type_name
// is necessary if the struct, union, or valuetype containing this
// field was not defined inside a module. In such a case, VC++
// complains that the non-module scope is not yet fully defined.
UTL_Scope *holds_container = this->ctx_->scope ()->defined_in ();
AST_Decl *hc_decl = ScopeAsDecl (holds_container);
if (hc_decl->node_type () != AST_Decl::NT_module
|| !tdef)
{
*os << bt->nested_type_name (this->ctx_->scope ());
}
else
{
*os << bt->name ();
}
return 0;
}
int
be_visitor_field_ch::visit_string (be_string *node)
{
TAO_OutStream *os = this->ctx_->stream ();
if (node->width () == (long) sizeof (char))
{
*os << "TAO_String_Manager";
}
else
{
*os << "TAO_WString_Manager";
}
return 0;
}
int
be_visitor_field_ch::visit_structure (be_structure *node)
{
TAO_OutStream *os = this->ctx_->stream ();
be_type *bt;
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
if (!this->ctx_->alias () // not a typedef
&& node->is_child (this->ctx_->scope ()))
{
be_visitor_context ctx (*this->ctx_);
ctx.node (node);
be_visitor_structure_ch visitor (&ctx);
if (node->accept (&visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_struct - "
"codegen failed\n"),
-1);
}
}
// This was a typedefed array.
// ACE_NESTED_CLASS macro generated by nested_type_name
// is necessary if the struct, union, or valuetype containing this
// field was not defined inside a module. In such a case, VC++
// complains that the non-module scope is not yet fully defined.
UTL_Scope *holds_container = this->ctx_->scope ()->defined_in ();
AST_Decl *hc_decl = ScopeAsDecl (holds_container);
if (hc_decl->node_type () != AST_Decl::NT_module)
{
*os << bt->nested_type_name (this->ctx_->scope ());
}
else
{
*os << bt->name ();
}
return 0;
}
// Visit typedefed type.
int
be_visitor_field_ch::visit_typedef (be_typedef *node)
{
this->ctx_->alias (node);
// Make a decision based on the primitive base type.
be_type *bt = node->primitive_base_type ();
if (!bt || (bt->accept (this) == -1))
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_typedef - "
"Bad primitive type\n"),
-1);
}
// Reset the alias.
this->ctx_->alias (0);
return 0;
}
// visit union type
int
be_visitor_field_ch::visit_union (be_union *node)
{
TAO_OutStream *os = this->ctx_->stream ();
be_type *bt;
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
if (!this->ctx_->alias ()
&& node->is_child (this->ctx_->scope ()))
{
be_visitor_context ctx (*this->ctx_);
ctx.node (node);
be_visitor_union_ch visitor (&ctx);
if (node->accept (&visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_field_ch::"
"visit_union - "
"codegen failed\n"),
-1);
}
}
*os << be_nl << be_nl;
// This was a typedefed array.
// ACE_NESTED_CLASS macro generated by nested_type_name
// is necessary if the struct, union, or valuetype containing this
// field was not defined inside a module. In such a case, VC++
// complains that the non-module scope is not yet fully defined.
UTL_Scope *holds_container = this->ctx_->scope ()->defined_in ();
AST_Decl *hc_decl = ScopeAsDecl (holds_container);
if (hc_decl->node_type () != AST_Decl::NT_module)
{
*os << bt->nested_type_name (this->ctx_->scope ());
}
else
{
*os << bt->name ();
}
return 0;
}
int
be_visitor_field_ch::visit_component (
be_component *node
)
{
return this->visit_interface (node);
}
int
be_visitor_field_ch::visit_component_fwd (
be_component_fwd *node
)
{
return this->visit_interface_fwd (node);
}
int
be_visitor_field_ch::visit_eventtype (
be_eventtype *node
)
{
return this->visit_valuetype (node);
}
int
be_visitor_field_ch::visit_eventtype_fwd (
be_eventtype_fwd *node
)
{
return this->visit_valuetype_fwd (node);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?