📄 psdl_struct_visitor.cpp
字号:
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << "}"; ps_si->nl ();
*ps_si << "if (_tao_any.any_owns_data ())"; ps_si->nl ();
*ps_si << "{";
ps_si->incr_indent (0); ps_si->nl ();
*ps_si << "_tao_elem = ACE_static_cast (";
ps_si->incr_indent (0); ps_si->nl ();
*ps_si << "const " << this->struct_name_ << "*,"; ps_si->nl ();
*ps_si << "_tao_any.value ()";
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << ");"; ps_si->nl ();
*ps_si << "return 1;"; ps_si->nl ();
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << "}"; ps_si->nl ();
*ps_si << "else"; ps_si->nl ();
*ps_si << "{";
ps_si->incr_indent (0); ps_si->nl ();
*ps_si << this->struct_name_ << " *tmp;"; ps_si->nl ();
*ps_si << "ACE_NEW_RETURN (";
ps_si->incr_indent (0); ps_si->nl ();
*ps_si << "tmp,"; ps_si->nl ();
*ps_si << this->struct_name_ << ","; ps_si->nl ();
*ps_si << "0"; ps_si->nl ();
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << ");"; ps_si->nl ();
*ps_si << ""; ps_si->nl ();
*ps_si << "TAO_InputCDR stream (";
ps_si->incr_indent (0); ps_si->nl ();
*ps_si << "_tao_any._tao_get_cdr (),"; ps_si->nl ();
*ps_si << "_tao_any._tao_byte_order ()";
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << ");"; ps_si->nl ();
*ps_si << "if (stream >> *tmp)"; ps_si->nl ();
*ps_si << "{";
ps_si->incr_indent (0); ps_si->nl ();
*ps_si << "((CORBA::Any *)&_tao_any)->_tao_replace (";
ps_si->incr_indent (0); ps_si->nl ();
*ps_si << "_tc_" << this->struct_name_ << ","; ps_si->nl ();
*ps_si << "1,"; ps_si->nl ();
*ps_si << "ACE_static_cast (void *, tmp),"; ps_si->nl ();
*ps_si << this->struct_name_ << "::_tao_any_destructor";
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << ");"; ps_si->nl ();
*ps_si << "_tao_elem = tmp;"; ps_si->nl ();
*ps_si << "return 1;";
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << "}"; ps_si->nl ();
*ps_si << "else"; ps_si->nl ();
*ps_si << "{";
ps_si->incr_indent (0); ps_si->nl ();
*ps_si << "delete tmp;";
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << "}";
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << "}";
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << "}"; ps_si->nl ();
*ps_si << "ACE_CATCHANY"; ps_si->nl ();
*ps_si << "{";
ps_si->nl ();
*ps_si << "}"; ps_si->nl ();
*ps_si << "ACE_ENDTRY;"; ps_si->nl ();
*ps_si << "return 0;"; ps_si->nl ();
ps_si->decr_indent (0); ps_si->nl ();
*ps_si << "}";
ps_si->reset ();
ps_si->nl (); ps_si->nl ();
return;
}
void
TAO_PSDL_Struct_Visitor::print_class_for_structure (ACE_CString struct_name)
{
// Get a pointer to PSDL_Stream of the stub header.
TAO_PSDL_Stream *ps_sh = TAO_PSDL_Scope::instance ()->get_sh ();
*ps_sh << "class " << struct_name.c_str () << "_var\n";
*ps_sh << "{\n";
*ps_sh << "public:\n";
*ps_sh << " " << struct_name << "_var (void);\n";
*ps_sh << " " << struct_name << "_var (" << struct_name
<< " *);\n";
*ps_sh << " " << struct_name << "_var (const " << struct_name
<< "_var &);\n";
*ps_sh << " ~" << struct_name << "_var (void"
<< ");\n";
ps_sh->nl ();
*ps_sh << " " << struct_name << "_var"
<< " &operator= (" << struct_name
<< " *);\n";
*ps_sh << " " << struct_name << "_var"
<< " &operator= (const " << struct_name
<< "_var &);\n";
*ps_sh << " " << struct_name
<< " *operator-> (void);\n";
*ps_sh << " const " << struct_name
<< " *operator-> (void) const;\n";
ps_sh->nl ();
*ps_sh << " operator const "
<< struct_name << "&() const;\n";
*ps_sh << " operator "
<< struct_name << "&();\n";
*ps_sh << " operator "
<< struct_name << "&() const;\n";
*ps_sh << " // Variable-size types only.\n";
*ps_sh << " operator "
<< struct_name << "*&();\n";
*ps_sh << " // in inout, out, _retn\n";
*ps_sh << " const " << struct_name << "&in (void) const;\n";
*ps_sh << " " << struct_name << " &inout (void);\n";
*ps_sh << " " << struct_name << " *&out (void);\n";
*ps_sh << " " << struct_name << " *_retn (void);\n";
*ps_sh << " " << struct_name << " *ptr (void) const;\n";
*ps_sh << "private:\n";
*ps_sh << " " << struct_name << " *ptr_;\n";
*ps_sh << "};\n";
*ps_sh << "class " << struct_name << "_out \n";
*ps_sh << "{\n";
*ps_sh << " public:\n";
*ps_sh << " " << struct_name << "_out ("
<< struct_name << " *&);\n";
*ps_sh << " " << struct_name << "_out ("
<< struct_name << "_var &);\n";
*ps_sh << " " << struct_name << "_out (const "
<< struct_name << "_out &);\n";
*ps_sh << " " << struct_name << "_out &operator= (const "
<< struct_name << "_out &);\n";
*ps_sh << " " << struct_name << "_out &operator= ("
<< struct_name << " *);\n";
*ps_sh << " operator " << struct_name << " *&();\n";
*ps_sh << " " << struct_name << " *&ptr (void);\n";
*ps_sh << " " << struct_name << " *operator-> (void);\n";
ps_sh->nl ();
*ps_sh << " private:\n";
*ps_sh << " " << struct_name << " *&ptr_;\n";
*ps_sh << " // Assignment from T_var not allowed.\n";
*ps_sh << " void operator= (const " << struct_name << "_var &);\n";
*ps_sh << " };\n";
*ps_sh << "TAO_NAMESPACE_STORAGE_CLASS ::CORBA::TypeCode_ptr"
<< " _tc_" << struct_name << ";";
ps_sh->nl ();
ps_sh->nl ();
*ps_sh << " void operator<<= (CORBA::Any &, const " << struct_name << " &);"
<< "// copying version";
ps_sh->nl ();
*ps_sh << " void operator<<= (CORBA::Any &, " << struct_name << "*);"
<< "// noncopying version";
ps_sh->nl ();
*ps_sh << " CORBA::Boolean operator>>= "
<< "(const CORBA::Any &, " << struct_name << " *&);"
<< "// deprecated";
ps_sh->nl ();
*ps_sh << " CORBA::Boolean operator>>= "
<< "(const CORBA::Any &, const " << struct_name << " *&);";
ps_sh->nl ();
ps_sh->nl ();
*ps_sh << "#ifndef __ACE_INLINE__";
ps_sh->incr_indent (0);
ps_sh->nl ();
ps_sh->nl ();
*ps_sh << " CORBA::Boolean operator<< "
<< "(TAO_OutputCDR &, const " << struct_name << " &);";
ps_sh->nl ();
*ps_sh << " CORBA::Boolean operator>> (TAO_InputCDR &, " << struct_name << " &);";
ps_sh->decr_indent (0);
ps_sh->nl ();
ps_sh->nl ();
*ps_sh << "#endif /* __ACE_INLINE__ */";
ps_sh->nl ();
ps_sh->nl ();
}
void
TAO_PSDL_Struct_Visitor::gen_code_for_sinline (void)
{
TAO_PSDL_Stream *ps_sin = TAO_PSDL_Scope::instance ()->get_sinline ();
if (ps_sin == 0)
{
ACE_DEBUG ((LM_DEBUG,
"Null pointer to the psdl inline file\n"));
}
ps_sin->reset ();
*ps_sin << "// ********************************************************";
ps_sin->nl ();
*ps_sin << "// Inline operations for class " << this->struct_name_ << "_var"; ps_sin->nl ();
*ps_sin << "// ********************************************************";
ps_sin->nl ();
ps_sin->nl ();
*ps_sin << "ACE_INLINE"; ps_sin->nl ();
*ps_sin << this->struct_name_ << "_var::" << this->struct_name_ << "_var (void) // default constructor";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << ": ptr_ (0)";
ps_sin->decr_indent (0);
ps_sin->nl ();
*ps_sin << "{}";
ps_sin->nl ();
ps_sin->nl ();
*ps_sin << "ACE_INLINE"; ps_sin->nl ();
*ps_sin << this->struct_name_ << "_var::" << this->struct_name_ << "_var (" << this->struct_name_ << " *p)";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << ": ptr_ (p)";
ps_sin->decr_indent (0);
ps_sin->nl ();
*ps_sin << "{}";
ps_sin->nl ();
ps_sin->nl ();
*ps_sin << "ACE_INLINE"; ps_sin->nl ();
*ps_sin << this->struct_name_ << "_var::" << this->struct_name_ << "_var (const ::" << this->struct_name_ << "_var &p) // copy constructor"; ps_sin->nl ();
*ps_sin << "{";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "if (p.ptr_)";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "ACE_NEW (this->ptr_, ::" << this->struct_name_ << " (*p.ptr_));";
ps_sin->decr_indent (0);
ps_sin->nl ();
*ps_sin << "else";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "this->ptr_ = 0;";
ps_sin->decr_indent (0);
ps_sin->decr_indent (0);
ps_sin->nl ();
*ps_sin << "}";
ps_sin->nl ();
ps_sin->nl ();
*ps_sin << "ACE_INLINE"; ps_sin->nl ();
*ps_sin << this->struct_name_ << "_var::~" << this->struct_name_ << "_var (void) // destructor"; ps_sin->nl ();
*ps_sin << "{";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "delete this->ptr_;";
ps_sin->decr_indent (0);
ps_sin->nl ();
*ps_sin << "}";
ps_sin->nl ();
ps_sin->nl ();
*ps_sin << "ACE_INLINE " << this->struct_name_ << "_var &"; ps_sin->nl ();
*ps_sin << this->struct_name_ << "_var::operator= (" << this->struct_name_ << " *p)"; ps_sin->nl ();
*ps_sin << "{";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "delete this->ptr_;"; ps_sin->nl ();
*ps_sin << "this->ptr_ = p;"; ps_sin->nl ();
*ps_sin << "return *this;";
ps_sin->decr_indent (0);
ps_sin->nl ();
*ps_sin << "}";
ps_sin->nl ();
ps_sin->nl ();
*ps_sin << "ACE_INLINE ::" << this->struct_name_ << "_var &"; ps_sin->nl ();
*ps_sin << this->struct_name_ << "_var::operator= (const ::" << this->struct_name_ << "_var &p)"; ps_sin->nl ();
*ps_sin << "{";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "if (this != &p)";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "{";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "if (p.ptr_ == 0)";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "{";
ps_sin->incr_indent (0);
ps_sin->nl ();
*ps_sin << "delete this->ptr_;"; ps_sin->nl ();
*ps_sin << "this->ptr_ = 0;";
ps_sin->decr_indent (0);
ps_sin->nl ();
*ps_sin << "}";
ps_sin->decr_indent (0); ps_sin->nl ();
*ps_sin << "else";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -