📄 interface_cs.cpp
字号:
//
// interface_cs.cpp,v 1.98 2004/01/01 14:50:41 bala Exp
// ============================================================================
//
// = LIBRARY
// TAO IDL
//
// = FILENAME
// interface_cs.cpp
//
// = DESCRIPTION
// Visitor generating code for Interfaces in the client stubs file.
//
// = AUTHOR
// Aniruddha Gokhale
//
// ============================================================================
ACE_RCSID (be_visitor_interface,
interface_cs,
"interface_cs.cpp,v 1.98 2004/01/01 14:50:41 bala Exp")
// ************************************************************
// Interface visitor for client stubs
// ************************************************************
be_visitor_interface_cs::be_visitor_interface_cs (be_visitor_context *ctx)
: be_visitor_interface (ctx)
{
}
be_visitor_interface_cs::~be_visitor_interface_cs (void)
{
}
int
be_visitor_interface_cs::visit_interface (be_interface *node)
{
if (node->imported () || node->cli_stub_gen ())
{
return 0;
}
be_type *bt;
// Set the right type.
if (this->ctx_->alias ())
{
bt = this->ctx_->alias ();
}
else
{
bt = node;
}
TAO_OutStream *os = this->ctx_->stream ();
*os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__;
if (node->is_defined ())
{
*os << be_nl << be_nl
<< "// Traits specializations for " << node->name () << ".";
*os << be_nl << be_nl
<< "ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION" << be_nl
<< node->name () << "_ptr" << be_nl
<< "TAO::Objref_Traits<" << node->name () << ">::tao_duplicate ("
<< be_idt << be_idt_nl
<< node->name () << "_ptr p" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "return " << node->name () << "::_duplicate (p);" << be_uidt_nl
<< "}";
*os << be_nl << be_nl
<< "ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION" << be_nl
<< "void" << be_nl
<< "TAO::Objref_Traits<" << node->name () << ">::tao_release ("
<< be_idt << be_idt_nl
<< node->name () << "_ptr p" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "CORBA::release (p);" << be_uidt_nl
<< "}";
*os << be_nl << be_nl
<< "ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION" << be_nl
<< node->name () << "_ptr" << be_nl
<< "TAO::Objref_Traits<" << node->name () << ">::tao_nil (void)"
<< be_nl
<< "{" << be_idt_nl
<< "return " << node->name () << "::_nil ();" << be_uidt_nl
<< "}";
*os << be_nl << be_nl
<< "ACE_TEMPLATE_CLASS_MEMBER_SPECIALIZATION" << be_nl
<< "CORBA::Boolean" << be_nl
<< "TAO::Objref_Traits<" << node->name () << ">::tao_marshal ("
<< be_idt << be_idt_nl
<< node->name () << "_ptr p," << be_nl
<< "TAO_OutputCDR & cdr" << be_uidt_nl
<< ")" << be_uidt_nl
<< "{" << be_idt_nl
<< "return p->marshal (cdr);" << be_uidt_nl
<< "}";
}
if (node->has_mixed_parentage ())
{
*os << be_nl << be_nl
<< "void" << be_nl
<< "CORBA::release ("
<< node->name ()
<< "_ptr p)" << be_nl
<< "{" << be_idt_nl
<< "CORBA::AbstractBase_ptr abs = p;" << be_nl
<< "CORBA::release (abs);" << be_uidt_nl
<< "}";
*os << be_nl << be_nl
<< "CORBA::Boolean" << be_nl
<< "CORBA::is_nil ("
<< node->name ()
<< "_ptr p)" << be_nl
<< "{" << be_idt_nl
<< "CORBA::Object_ptr obj = p;" << be_nl
<< "return CORBA::is_nil (obj);" << be_uidt_nl
<< "}";
}
// Generate the proxy broker factory function pointer definition.
*os << be_nl << be_nl
<< "// Function pointer for collocation factory initialization."
<< be_nl
<< "TAO::Collocation_Proxy_Broker * " << be_nl
<< "(*" << node->flat_client_enclosing_scope ()
<< node->base_proxy_broker_name ()
<< "_Factory_function_pointer) ("
<< be_idt << be_idt_nl
<< "CORBA::Object_ptr obj" << be_uidt_nl
<< ") = 0;" << be_uidt;
// Generate code for the elements of the interface.
if (this->visit_scope (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interface_cs::"
"visit_interface - "
"codegen for scope failed\n"),
-1);
}
if (node->is_local ())
{
*os << be_nl << be_nl
<< node->name () << "::" << node->local_name ()
<< " (void)" << be_nl
<< "{}";
}
if (! node->is_abstract () && ! node->is_local ())
{
*os << be_nl << be_nl
<< node->name () << "::" << node->local_name ()
<< " (int collocated)" << be_nl
<< " : the" << node->base_proxy_broker_name () << "_ (0)" << be_nl
<< "{" << be_idt_nl
<< "this->" << node->flat_name ()
<< "_setup_collocation (collocated);" << be_uidt_nl
<< be_uidt << "}";
}
if (! node->is_local ())
{
*os << be_nl << be_nl
<< "void" << be_nl
<< node->name () << "::" << node->flat_name ()
<< "_setup_collocation (int collocated)" << be_nl
<< "{" << be_idt_nl
<< "if (collocated)" << be_idt_nl
<< "{" << be_idt_nl
<< "this->the" << node->base_proxy_broker_name ()
<< "_ =" << be_idt_nl
<< "::" << node->flat_client_enclosing_scope ()
<< node->base_proxy_broker_name ()
<< "_Factory_function_pointer (";
if (node->is_abstract ())
{
*os << be_idt << be_idt_nl
<< "this->equivalent_objref ()" << be_uidt_nl
<< ");" << be_uidt;
}
else
{
*os << "this);";
}
*os << be_uidt << be_uidt_nl
<< "}" << be_uidt;
// Now we setup the immediate parents.
int n_parents = node->n_inherits ();
int has_parent = 0;
if (n_parents > 0)
{
for (int i = 0; i < n_parents; ++i)
{
be_interface *inherited =
be_interface::narrow_from_decl (node->inherits ()[i]);
if (has_parent == 0)
{
*os << be_nl;
}
has_parent = 1;
*os << be_nl
<< "this->" << inherited->flat_name ()
<< "_setup_collocation" << " (collocated);";
}
}
*os << be_uidt_nl << "}";
}
*os << be_nl << be_nl
<< node->name () << "::~" << node->local_name ()
<< " (void)" << be_nl;
*os << "{}" << be_nl << be_nl;
if (be_global->any_support ())
{
*os << "void " << be_nl
<< node->name ()
<< "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl
<< "{" << be_idt_nl
<< node->local_name () << " *_tao_tmp_pointer =" << be_idt_nl
<< "ACE_static_cast ("
<< node->local_name () << " *, _tao_void_pointer);" << be_uidt_nl
<< "CORBA::release (_tao_tmp_pointer);" << be_uidt_nl
<< "}" << be_nl << be_nl;
}
if (node->has_mixed_parentage ())
{
*os << "void" << be_nl
<< node->name () << "::_add_ref (void)" << be_nl
<< "{" << be_idt_nl
<< "this->ACE_NESTED_CLASS (CORBA, Object)::_add_ref ();"
<< be_uidt_nl
<< "}" << be_nl << be_nl;
}
// The _narrow method
if (this->gen_xxx_narrow ("narrow",
node) == false)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interface_cs::"
"visit_interface - "
"_narrow () method codegen failed\n"),
-1);
}
// The _unchecked_narrow method
if (this->gen_xxx_narrow ("unchecked_narrow",
node) == false)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_interface_cs::"
"visit_interface - "
"_unchecked_narrow () method codegen"
" failed\n"),
-1);
}
// The _duplicate method
*os << node->full_name () << "_ptr" << be_nl
<< node->full_name () << "::_duplicate ("
<< bt->local_name ()
<< "_ptr obj)" << be_nl
<< "{" << be_idt_nl
<< "if (! CORBA::is_nil (obj))" << be_idt_nl
<< "{" << be_idt_nl
<< "obj->_add_ref ();" << be_uidt_nl
<< "}" << be_uidt_nl << be_nl
<< "return obj;" << be_uidt_nl
<< "}" << be_nl << be_nl;
*os << "CORBA::Boolean" << be_nl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -