📄 interface_cs.cpp
字号:
<< node->full_name () << "::_is_a (" << be_idt << be_idt_nl
<< "const char *value" << be_nl;
if (node->is_local () || node->is_abstract ())
*os << "ACE_ENV_ARG_DECL_NOT_USED";
else
*os << "ACE_ENV_ARG_DECL";
*os << be_uidt_nl << ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "if (" << be_idt << be_idt_nl;
int status =
node->traverse_inheritance_graph (be_interface::is_a_helper,
os);
if (status == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interface_cs::"
"visit_interface - "
"_is_a method codegen failed\n"),
-1);
}
if (node->is_abstract () || node->has_mixed_parentage ())
{
*os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl
<< "(char *)value," << be_nl
<< "\"IDL:omg.org/CORBA/AbstractBase:1.0\"" << be_uidt_nl
<< ")";
}
else if (node->is_local ())
{
*os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl
<< "(char *)value," << be_nl
<< "\"IDL:omg.org/CORBA/LocalObject:1.0\"" << be_uidt_nl
<< ")";
}
if (node->has_mixed_parentage () || node->is_local ())
{
*os << " ||" << be_uidt_nl;
}
else if (node->is_abstract ())
{
*os << be_uidt << be_uidt_nl;
}
if (! node->is_abstract ())
{
*os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl
<< "(char *)value," << be_nl
<< "\"IDL:omg.org/CORBA/Object:1.0\"" << be_uidt_nl
<< ")" << be_uidt << be_uidt_nl;
}
*os << " )" << be_nl
<< "{" << be_idt_nl
<< "return 1; // success using local knowledge" << be_uidt_nl
<< "}" << be_uidt_nl
<< "else" << be_idt_nl
<< "{" << be_idt_nl;
if (node->is_abstract () || node->is_local ())
{
*os << "return 0;" << be_uidt_nl;
}
else
{
*os << "return this->ACE_NESTED_CLASS (CORBA, Object)::_is_a ("
<< be_idt << be_idt_nl
<< "value" << be_nl
<< "ACE_ENV_ARG_PARAMETER" << be_uidt_nl
<< ");" << be_uidt << be_uidt_nl;
}
*os << "}" << be_uidt << be_uidt_nl
<< "}" << be_nl << be_nl;
*os << "const char* " << node->full_name ()
<< "::_interface_repository_id (void) const"
<< be_nl
<< "{" << be_idt_nl
<< "return \"" << node->repoID ()
<< "\";" << be_uidt_nl
<< "}";
*os << be_nl << be_nl
<< "CORBA::Boolean" << be_nl;
if (node->is_local ())
{
*os << node->name () << "::marshal (TAO_OutputCDR &)" << be_nl
<< "{" << be_idt_nl
<< "return 0;" << be_uidt_nl
<< "}";
}
else
{
*os << node->name () << "::marshal (TAO_OutputCDR &cdr)" << be_nl
<< "{" << be_idt_nl
<< "return (cdr << this);" << be_uidt_nl
<< "}";
}
if (! node->is_abstract ())
{
// Smart Proxy classes.
if (! node->is_local () && be_global->gen_smart_proxies ())
{
be_visitor_context ctx (*this->ctx_);
ctx.state (TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS);
be_visitor_interface_smart_proxy_cs isp_visitor (&ctx);
if (node->accept (&isp_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"be_visitor_interface_cs::"
"visit_interface - "
"codegen for smart proxy classes failed\n"),
-1);
}
}
}
if (be_global->tc_support ())
{
be_visitor_context ctx = *this->ctx_;
ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE);
be_visitor_typecode_defn tc_visitor (&ctx);
if (node->accept (&tc_visitor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interface_cs::"
"visit_interface - "
"TypeCode definition failed\n"),
-1);
}
}
return 0;
}
bool
be_visitor_interface_cs::gen_xxx_narrow (const char *pre,
be_interface *node)
{
TAO_OutStream *os = this->ctx_->stream ();
*os << node->full_name () << "_ptr" << be_nl
<< node->full_name () << "::_" << pre << " ("
<< be_idt << be_idt_nl;
if (node->is_abstract ())
{
*os << "CORBA::AbstractBase_ptr";
}
else
{
*os << "CORBA::Object_ptr";
}
*os << " _tao_objref" << be_nl
<< "ACE_ENV_ARG_DECL"
<< (node->is_local () ? "_NOT_USED" : "")
<< be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl;
if (node->is_local ())
{
*os << "if (CORBA::is_nil (_tao_objref))" << be_idt_nl
<< "{" << be_idt_nl
<< "return " << node->local_name () << "::_nil ();" << be_uidt_nl
<< "}" << be_uidt_nl << be_nl
<< node->local_name () << "_ptr proxy =" << be_idt_nl
<< "dynamic_cast<" << node->local_name () << "_ptr> (_tao_objref);"
<< be_uidt_nl << be_nl
<< "return " << node->local_name () << "::_duplicate (proxy);" << be_uidt_nl
<< "}" << be_nl << be_nl;
}
else if (be_global->gen_smart_proxies () &&
!node->is_abstract ())
{
*os << node->full_name () << " *proxy = 0;" << be_nl << be_nl
<< "proxy = TAO::Narrow_Utils<"
<< node->local_name () << ">::" << pre << " (";
*os << be_idt << be_idt_nl
<< "_tao_objref," << be_nl
<< "\"" << node->repoID () << "\"," << be_nl
<< node->flat_client_enclosing_scope ()
<< node->base_proxy_broker_name ()
<< "_Factory_function_pointer" << be_nl
<< "ACE_ENV_ARG_PARAMETER" << be_uidt_nl
<< ");" << be_uidt << be_nl
<< "return TAO_" << node->flat_name ()
<< "_PROXY_FACTORY_ADAPTER::instance ()->create_proxy (proxy);"
<< be_uidt << be_uidt_nl
<< "}" << be_nl << be_nl;
}
else
{
*os << "return" << be_idt_nl;
if (!node->is_abstract ())
{
*os << "TAO::Narrow_Utils<"
<< node->local_name () << ">::" << pre << " (";
}
else
{
*os << "TAO::AbstractBase_Narrow_Utils<"
<< node->local_name () << ">::" << pre <<" (";
}
*os << be_idt << be_idt_nl
<< "_tao_objref," << be_nl
<< "\"" << node->repoID () << "\"," << be_nl
<< node->flat_client_enclosing_scope ()
<< node->base_proxy_broker_name ()
<< "_Factory_function_pointer" << be_nl
<< "ACE_ENV_ARG_PARAMETER" << be_uidt_nl
<< ");" << be_uidt << be_uidt << be_uidt_nl
<< "}" << be_nl << be_nl;
}
return true;
}
int
be_visitor_interface_cs::gen_abstract_ops_helper (be_interface *node,
be_interface *base,
TAO_OutStream *os)
{
if (node == base)
{
return 0;
}
AST_Decl *d = 0;
be_visitor_context ctx;
ctx.stream (os);
for (UTL_ScopeActiveIterator si (base, UTL_Scope::IK_decls);
!si.is_done ();
si.next ())
{
d = si.item ();
if (d == 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interface_cs::"
"abstract_base_ops_helper - "
"bad node in this scope\n"),
-1);
}
if (d->node_type () == AST_Decl::NT_op)
{
UTL_ScopedName *item_new_name = 0;
ACE_NEW_RETURN (item_new_name,
UTL_ScopedName (d->local_name ()->copy (),
0),
-1);
UTL_ScopedName *base = (UTL_ScopedName *)node->name ()->copy ();
base->nconc (item_new_name);
AST_Operation *op = AST_Operation::narrow_from_decl (d);
be_operation new_op (op->return_type (),
op->flags (),
0,
op->is_local (),
op->is_abstract ());
new_op.set_defined_in (node);
be_visitor_interface::add_abstract_op_args (op,
new_op);
new_op.set_name (base);
ctx.state (TAO_CodeGen::TAO_OPERATION_CS);
be_visitor_operation_cs op_visitor (&ctx);
op_visitor.visit_operation (&new_op);
base->destroy ();
delete base;
base = 0;
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -