diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-06-19 16:54:50 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-06-19 16:54:50 +0000 |
commit | 34f54f20caa17ec2baca1bb976c97ef06c536168 (patch) | |
tree | cff33b16a5688e293066731c3b26b225f090e4bc | |
parent | 378c4e248869900c3c9415254eab5c15e4a568ef (diff) | |
download | ATCD-34f54f20caa17ec2baca1bb976c97ef06c536168.tar.gz |
ChangeLogTag: Wed Jun 19 11:47:26 2002 Jeff Parsons <parsons@cs.wustl.edu>
49 files changed, 2192 insertions, 2331 deletions
diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index e655e8eda06..15834f9d83a 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -462,9 +462,9 @@ be_interface::gen_def_ctors_helper (be_interface* node, static int first = 0; - if(node != base) + if (node != base) { - if(first) + if (first) { *os << be_global->impl_class_prefix () << base->flat_name () << be_global->impl_class_suffix () << " ()"; @@ -500,16 +500,14 @@ be_interface::gen_stub_ctor (TAO_OutStream *os) << "TAO_Stub *objref," << be_nl << "CORBA::Boolean _tao_collocated," << be_nl << "TAO_Abstract_ServantBase *servant" << be_uidt_nl - << ")" // constructor + << ")" << be_nl; - *os << ": CORBA_Object (objref, _tao_collocated, servant)" - << be_uidt_nl; - *os << "{" << be_idt_nl - << "this->" << this->flat_name () - << "_setup_collocation (_tao_collocated);"; + *os << ": CORBA_Object (objref, _tao_collocated, servant)"; if (this->has_mixed_parentage_) { + *os << be_idt; + int status = this->traverse_inheritance_graph ( be_interface::gen_abstract_init_helper, @@ -523,7 +521,19 @@ be_interface::gen_stub_ctor (TAO_OutStream *os) "be_interface::gen_stub_ctor - " "inheritance graph traversal failed\n")); } + + *os << "," << be_nl + << "CORBA_AbstractBase (objref, _tao_collocated, servant)" + << be_uidt << be_uidt; } + else + { + *os << be_uidt; + } + + *os << be_nl << "{" << be_idt_nl + << "this->" << this->flat_name () + << "_setup_collocation (_tao_collocated);"; *os << be_uidt_nl << "}" << be_nl << be_nl; @@ -1155,10 +1165,23 @@ be_interface::gen_operation_table (const char *flat_name, // Start the table generation. *os << "static const TAO_operation_db_entry " << flat_name << - "_operations [] = {\n"; + "_operations [] = {" << be_nl; os->incr_indent (0); + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); + + // Insert ourselves in the queue. + if (insert_queue.enqueue_tail (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interface::gen_operation_table - " + "error generating entries\n"), + -1); + } + // Traverse the graph. TAO_IDL_Gen_OpTable_Worker worker (skeleton_class_name); @@ -1170,29 +1193,21 @@ be_interface::gen_operation_table (const char *flat_name, } // Generate the skeleton for the is_a method. - os->indent (); - *os << "{\"_is_a\", &" << skeleton_class_name - << "::_is_a_skel},\n"; + << "::_is_a_skel}," << be_nl; this->skel_count_++; - os->indent (); - *os << "{\"_non_existent\", &" << skeleton_class_name - << "::_non_existent_skel},\n"; + << "::_non_existent_skel}," << be_nl; this->skel_count_++; - os->indent (); - *os << "{\"_interface\", &" << skeleton_class_name - << "::_interface_skel}\n"; + << "::_interface_skel}" << be_uidt_nl; this->skel_count_++; - os->decr_indent (); - *os << "};\n" << be_nl; *os << "static const CORBA::Long _tao_" << flat_name << "_optable_size = sizeof (ACE_Hash_Map_Entry<const char *," @@ -1288,8 +1303,22 @@ be_interface::gen_operation_table (const char *flat_name, // Add the gperf input header. this->gen_gperf_input_header (os); + // Make sure the queues are empty. + this->insert_queue.reset (); + this->del_queue.reset (); + + // Insert ourselves in the queue. + if (insert_queue.enqueue_tail (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interface::gen_operation_table - " + "error generating entries\n"), + -1); + } + // Traverse the graph. TAO_IDL_Gen_OpTable_Worker worker (skeleton_class_name); + if (this->traverse_inheritance_graph (worker, os) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -1300,21 +1329,23 @@ be_interface::gen_operation_table (const char *flat_name, // Generate the skeleton for the is_a method. os->indent (); + *os << "_is_a, &" << skeleton_class_name - << "::_is_a_skel\n"; + << "::_is_a_skel" << be_nl; + this->skel_count_++; - os->indent (); *os << "_non_existent, &" << skeleton_class_name - << "::_non_existent_skel\n"; + << "::_non_existent_skel" << be_nl; + this->skel_count_++; - os->indent (); *os << "_interface, &" << skeleton_class_name << "::_interface_skel\n"; + this->skel_count_++; // Input to the gperf is ready. Run gperf and get things @@ -1515,7 +1546,7 @@ be_interface::analyze_parentage (AST_Interface **parents, } } - if (this->has_mixed_parentage_ == I_TRUE) + if (this->has_mixed_parentage_) { be_global->mixed_parentage_interfaces.enqueue_tail (this); } @@ -2440,22 +2471,24 @@ be_interface::gen_abstract_init_helper (be_interface *node, return 0; } - if (node->is_nested () && base->is_nested ()) + *os << ","; + + if (base->is_nested ()) { UTL_Scope *parent_scope = base->defined_in (); AST_Decl *parent_decl = ScopeAsDecl (parent_scope); *os << be_nl - << "this->ACE_NESTED_CLASS (" + << "ACE_NESTED_CLASS (" << parent_decl->name () << ", " << base->local_name () - << ")::obj_ = this;"; + << ") (objref, _tao_collocated, servant)"; } else { *os << be_nl - << "this->" << base->name () - << "::obj_ = this;"; + << base->name () + << " (objref, _tao_collocated, servant)"; } return 0; diff --git a/TAO/TAO_IDL/be/be_valuetype.cpp b/TAO/TAO_IDL/be/be_valuetype.cpp index 424cd38ed7e..8b47df4c2a7 100644 --- a/TAO/TAO_IDL/be/be_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_valuetype.cpp @@ -315,8 +315,8 @@ be_valuetype::gen_var_impl (char *local_name, // which reclaims amguity between T(T*) and T(const T_var &) *cs << fname << "::" << lname << " (const " << local_name << "* p)" << be_nl; - *cs << " : ptr_ (ACE_const_cast(" - << local_name << "*, p))" << be_nl; + *cs << " : ptr_ (ACE_const_cast (" + << local_name << " *, p))" << be_nl; *cs << "{}" << be_nl << be_nl; // The additional ptr () member function. This member function must be @@ -350,7 +350,7 @@ be_valuetype::gen_var_impl (char *local_name, // Assignment operator. *cs << fname << " &" << be_nl; *cs << fname << "::operator= (" << local_name - << "* p)" << be_nl; + << " *p)" << be_nl; *cs << "{" << be_idt_nl; *cs << "CORBA::remove_ref (this->ptr_);" << be_nl; @@ -369,7 +369,7 @@ be_valuetype::gen_var_impl (char *local_name, *cs << "{" << be_idt_nl; *cs << "CORBA::remove_ref (this->ptr_);" << be_nl - << local_name << "* tmp = p.ptr ();" << be_nl + << local_name << " *tmp = p.ptr ();" << be_nl << "CORBA::add_ref (tmp);" << be_nl << "this->ptr_ = tmp;" << be_uidt_nl; @@ -396,7 +396,7 @@ be_valuetype::gen_var_impl (char *local_name, *cs << "}" << be_nl << be_nl; // operator-> - *cs << full_name << "* " << be_nl; + *cs << full_name << " *" << be_nl; *cs << fname << "::operator-> (void) const" << be_nl; *cs << "{" << be_idt_nl; @@ -405,7 +405,7 @@ be_valuetype::gen_var_impl (char *local_name, *cs << "}" << be_nl << be_nl; // in, inout, out, and _retn. - *cs << full_name << "*" << be_nl; + *cs << full_name << " *" << be_nl; *cs << fname << "::in (void) const" << be_nl; *cs << "{" << be_idt_nl; @@ -413,7 +413,7 @@ be_valuetype::gen_var_impl (char *local_name, *cs << "}" << be_nl << be_nl; - *cs << full_name << "* &" << be_nl; + *cs << full_name << " *&" << be_nl; *cs << fname << "::inout (void)" << be_nl; *cs << "{" << be_idt_nl; @@ -421,7 +421,7 @@ be_valuetype::gen_var_impl (char *local_name, *cs << "}" << be_nl << be_nl; - *cs << full_name << "* &" << be_nl; + *cs << full_name << " *&" << be_nl; *cs << fname << "::out (void)" << be_nl; *cs << "{" << be_idt_nl; @@ -431,7 +431,7 @@ be_valuetype::gen_var_impl (char *local_name, *cs << "}" << be_nl << be_nl; - *cs << full_name << "* " << be_nl; + *cs << full_name << " *" << be_nl; *cs << fname << "::_retn (void)" << be_nl; *cs << "{" << be_idt_nl; @@ -556,7 +556,7 @@ be_valuetype::gen_out_impl (char *, // Constructor from a pointer. *cs << fname << "::" << lname << " (" << this->local_name () - << "* &p)" << be_nl; + << " *&p)" << be_nl; *cs << " : ptr_ (p)" << be_nl; *cs << "{" << be_idt_nl; @@ -578,7 +578,7 @@ be_valuetype::gen_out_impl (char *, // Copy constructor. *cs << fname << "::" << lname << " (const " << lname << " &p)" << be_nl; - *cs << " : ptr_ (ACE_const_cast (" << lname << "&,p).ptr_)" << be_nl; + *cs << " : ptr_ (ACE_const_cast (" << lname << "&, p).ptr_)" << be_nl; *cs << "{}" << be_nl << be_nl; // Assignment operator from _out &. @@ -587,7 +587,7 @@ be_valuetype::gen_out_impl (char *, " &p)" << be_nl; *cs << "{" << be_idt_nl; - *cs << "this->ptr_ = ACE_const_cast (" << lname << "&,p).ptr_;" << be_nl; + *cs << "this->ptr_ = ACE_const_cast (" << lname << "&, p).ptr_;" << be_nl; *cs << "return *this;" << be_uidt_nl; *cs << "}" << be_nl << be_nl; @@ -598,7 +598,7 @@ be_valuetype::gen_out_impl (char *, << "_var &p)" << be_nl; *cs << "{" << be_idt_nl; - *cs << this->local_name () << "* tmp = p.ptr ();" << be_nl + *cs << this->local_name () << " *tmp = p.ptr ();" << be_nl << "CORBA::add_ref (tmp);" << be_nl << "this->ptr_ = tmp;" << be_nl; *cs << "return *this;" << be_uidt_nl; @@ -608,7 +608,7 @@ be_valuetype::gen_out_impl (char *, // Assignment operator from *. *cs << fname << " &" << be_nl; *cs << fname << "::operator= (" << this->local_name () - << "* p)" << be_nl; + << " *p)" << be_nl; *cs << "{" << be_idt_nl; *cs << "this->ptr_ = p;" << be_nl; @@ -618,14 +618,14 @@ be_valuetype::gen_out_impl (char *, // Other extra methods - cast operator (). *cs << fname << "::operator " << this->name () - << "* &() // cast" << be_nl; + << "*& () // cast" << be_nl; *cs << "{" << be_idt_nl; *cs << "return this->ptr_;" << be_uidt_nl; *cs << "}" << be_nl << be_nl; // ptr function. - *cs << this->name () << "* &" << be_nl; + *cs << this->name () << " *&" << be_nl; *cs << fname << "::ptr (void) // ptr" << be_nl; *cs << "{" << be_idt_nl; *cs << "return this->ptr_;" << be_uidt_nl; @@ -633,13 +633,14 @@ be_valuetype::gen_out_impl (char *, *cs << "}" << be_nl << be_nl; // operator-> - *cs << this->name () << "* " << be_nl; + *cs << this->name () << " *" << be_nl; *cs << fname << "::operator-> (void)" << be_nl; *cs << "{" << be_idt_nl; *cs << "return this->ptr_;" << be_uidt_nl; *cs << "}" << be_nl << be_nl; + *cs << "// *************************************************************" << be_nl << be_nl; @@ -647,33 +648,44 @@ be_valuetype::gen_out_impl (char *, } int -be_valuetype::gen_helper_header (char* , - char* ) +be_valuetype::gen_helper_header (char*, + char*) { TAO_OutStream *os = 0; os = tao_cg->client_header (); *os << be_nl - << "//@@ Boris: begin experimental" << be_nl - << "TAO_NAMESPACE CORBA" << be_nl + << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "TAO_NAMESPACE CORBA" << be_nl << "{" << be_idt_nl << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" << this->full_name () << " *);" << be_nl << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" - << this->full_name () << " *);" - << be_uidt_nl + << this->full_name () << " *);"; +/* + if (this->supports_abstract ()) + { + *os << be_nl + << "TAO_NAMESPACE_STORAGE_CLASS void add_ref (" + << "OBV_" << this->full_name () << " *);" << be_nl + << "TAO_NAMESPACE_STORAGE_CLASS void remove_ref (" + << "OBV_" << this->full_name () << " *);"; + } +*/ + *os << be_uidt_nl << "}" << be_nl - << "TAO_NAMESPACE_CLOSE" << be_nl - << "//@@ Boris: end experimental" << be_nl << be_nl; + << "TAO_NAMESPACE_CLOSE" << be_nl << be_nl; return 0; } int -be_valuetype::gen_helper_inline (char* , - char* ) +be_valuetype::gen_helper_inline (char*, + char*) { TAO_OutStream *os = 0; @@ -683,8 +695,10 @@ be_valuetype::gen_helper_inline (char* , // is not getting generated... Actually this is a much bigger // problem. Just hacking it up for the timebeing.. + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "#if defined (__ACE_INLINE__)" << be_nl - << "//@@ Boris: begin experimental" << be_nl << "TAO_NAMESPACE CORBA" << be_nl << "{" << be_idt_nl @@ -695,7 +709,6 @@ be_valuetype::gen_helper_inline (char* , << be_uidt_nl << "}" << be_nl << "TAO_NAMESPACE_CLOSE" << be_nl - << "//@@ Boris: end experimental" << be_nl << "#endif /*__ACE_INLINE__*/"<< be_nl; return 0; @@ -710,34 +723,26 @@ be_valuetype::gen_helper_stubs (char* , os = tao_cg->client_stubs (); - *os << "//@@ Boris: begin experimental" << be_nl - // add_ref - << "void" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "void" << be_nl << "CORBA::add_ref (" << this->full_name () << " * vt)" << be_nl - << "{" - << be_idt_nl - << "if (vt != 0)" << be_nl - << "{" - << be_idt_nl - << "vt->_add_ref ();" - << be_uidt_nl - << "}" - << be_uidt_nl - << "}" << be_nl << be_nl - // remove_ref - << "void" << be_nl + << "{" << be_idt_nl + << "if (vt != 0)" << be_idt_nl + << "{" << be_idt_nl + << "vt->_add_ref ();" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + *os << "void" << be_nl << "CORBA::remove_ref (" << this->full_name () << " * vt)" << be_nl - << "{" - << be_idt_nl - << "if (vt != 0)" << be_nl - << "{" - << be_idt_nl - << "vt->_remove_ref ();" - << be_uidt_nl - << "}" - << be_uidt_nl - << "}" << be_nl << be_nl - << "//@@ Boris: end experimental" << be_nl; + << "{" << be_idt_nl + << "if (vt != 0)" << be_idt_nl + << "{" << be_idt_nl + << "vt->_remove_ref ();" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; return 0; } @@ -993,7 +998,7 @@ be_valuetype::abstract_supports_helper (be_interface *, *os << "ACE_NESTED_CLASS (" << parent_decl->name () << ", " - << base->local_name (); + << base->local_name () << ")"; } else { @@ -1004,27 +1009,12 @@ be_valuetype::abstract_supports_helper (be_interface *, } int -be_valuetype::gen_abstract_init_helper (be_interface *node, - be_interface *base, +be_valuetype::gen_abstract_init_helper (be_interface *, + be_interface *, TAO_OutStream *os) { - if (node->is_nested () && base->is_nested ()) - { - UTL_Scope *parent_scope = base->defined_in (); - AST_Decl *parent_decl = ScopeAsDecl (parent_scope); - - *os << be_nl - << "this->ACE_NESTED_CLASS (" - << parent_decl->name () << ", " - << base->local_name () - << ")::val_ = this;"; - } - else - { - *os << be_nl - << "this->" << base->name () - << "::val_ = this;"; - } +// *os << be_nl +// << "this->value_ = this;"; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp index 887099d631a..7c7c3531ece 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/any_op_cs.cpp @@ -50,19 +50,18 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) *os << be_nl << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - os->indent (); - if (!node->is_local ()) { - os->indent (); - // Generate the Any <<= and >>= operator declarations // Any <<= and >>= operators. - *os << "void operator<<= (CORBA::Any &_tao_any, " - << node->full_name () << "_ptr _tao_elem)" << be_nl + *os << "void" << be_nl + << "operator<<= (" << be_idt << be_idt_nl + << "CORBA::Any &_tao_any," << be_nl + << node->full_name () << "_ptr _tao_elem" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl << "TAO_OutputCDR stream;" << be_nl - << "if (stream << _tao_elem)" << be_nl + << "if (stream << _tao_elem)" << be_idt_nl << "{" << be_idt_nl << "_tao_any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << ", " << be_nl @@ -72,26 +71,34 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) << node->full_name () << "::_duplicate (_tao_elem)," << be_nl << node->name () << "::_tao_any_destructor" << be_uidt_nl << ");" << be_uidt << be_uidt_nl - << "}" << be_uidt_nl - << "}\n" << be_nl; - - *os << "CORBA::Boolean operator>>= (const CORBA::Any &_tao_any, " - << node->full_name () << "_ptr &_tao_elem)" << be_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; + + *os << "CORBA::Boolean" << be_nl + << "operator>>= (" << be_idt << be_idt_nl + << "const CORBA::Any &_tao_any," << be_nl + << node->full_name () << "_ptr &_tao_elem" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl << "_tao_elem = " << node->full_name () << "::_nil ();" << be_nl << "CORBA::TypeCode_var type = _tao_any.type ();" << be_nl << be_nl - << "CORBA::Boolean result = type->equivalent (" << node->tc_name () - << " ACE_ENV_ARG_PARAMETER);" << be_nl + << "CORBA::Boolean result =" << be_idt_nl + << "type->equivalent (" << be_idt << be_idt_nl + << node->tc_name () << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl << be_nl << "if (!result)" << be_idt_nl - << "return 0; // not equivalent" << be_uidt_nl << be_nl + << "{" << be_idt_nl + << "return 0; // not equivalent" << be_uidt_nl + << "}" << be_uidt_nl << be_nl << "TAO_InputCDR stream (" << be_idt << be_idt_nl << "_tao_any._tao_get_cdr ()," << be_nl << "_tao_any._tao_byte_order ()" << be_uidt_nl - << ");" << be_uidt_nl - << "if (stream >> _tao_elem)" << be_nl + << ");" << be_uidt_nl << be_nl + << "if (stream >> _tao_elem)" << be_idt_nl << "{" << be_idt_nl << "((CORBA::Any *)&_tao_any)->_tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl @@ -100,7 +107,7 @@ be_visitor_interface_any_op_cs::visit_interface (be_interface *node) << node->name () << "::_tao_any_destructor" << be_uidt_nl << ");" << be_uidt_nl << "return 1;" << be_uidt_nl - << "}" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl << "}" << be_nl << "ACE_CATCHANY" << be_nl << "{" << be_idt_nl diff --git a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp index fe949a9f22f..9717c686dda 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/base_proxy_impl_ch.cpp @@ -154,7 +154,9 @@ be_visitor_interface_base_proxy_impl_ch::gen_abstract_ops_helper ( &item_new_name, op->is_local (), op->is_abstract ()); - + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); ctx.state (TAO_CodeGen::TAO_OPERATION_BASE_PROXY_IMPL_CH); be_visitor_operation_base_proxy_impl_ch op_visitor (&ctx); op_visitor.visit_operation (&new_op); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp index 97ca519c180..b25161cd35a 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/cdr_op_cs.cpp @@ -108,13 +108,39 @@ be_visitor_interface_cdr_op_cs::visit_interface (be_interface *node) << "{" << be_idt_nl << "return 0;" << be_uidt_nl << "}" << be_uidt_nl << be_nl - << "// narrow to the right type" << be_nl; - *os << "_tao_objref =" << be_idt_nl - << node->full_name () << "::_unchecked_narrow (" - << be_idt << be_idt_nl - << "obj.in ()" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl; + << "// Narrow to the right type." << be_nl; + + if (node->is_abstract ()) + { + *os << "if (obj->_is_objref ())" << be_idt_nl + << "{" << be_idt_nl + << "_tao_objref =" << be_idt_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "obj.in ()" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl + << "}" << be_uidt_nl + << "else" << be_idt_nl + << "{" << be_idt_nl + << "_tao_objref =" << be_idt_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "obj._retn ()" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + } + else + { + *os << "_tao_objref =" << be_idt_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "obj.in ()" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + } + *os << "ACE_TRY_CHECK;" << be_nl; *os << "return 1;" << be_uidt_nl; *os << "}" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp index 34b9ab7a8cc..407c1952eb9 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_sh.cpp @@ -131,7 +131,9 @@ be_visitor_interface_direct_proxy_impl_sh::gen_abstract_ops_helper ( &item_new_name, op->is_local (), op->is_abstract ()); - + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); ctx.state (TAO_CodeGen::TAO_OPERATION_DIRECT_COLLOCATED_SH); be_visitor_operation_direct_collocated_sh op_visitor (&ctx); op_visitor.visit_operation (&new_op); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp index 682cb033560..78b2cb27843 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/direct_proxy_impl_ss.cpp @@ -106,8 +106,9 @@ be_visitor_interface_direct_proxy_impl_ss::gen_abstract_ops_helper ( 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_DIRECT_COLLOCATED_SS); be_visitor_operation_direct_proxy_impl_ss op_visitor (&ctx); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp index daa38fec381..d22df743fd8 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_cs.cpp @@ -129,8 +129,9 @@ be_visitor_interface_interceptors_cs::gen_abstract_ops_helper ( 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_INTERCEPTORS_CS); be_visitor_operation_interceptors_cs op_visitor (&ctx); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp index 73ea3e39982..6860fc7faf7 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interceptors_ss.cpp @@ -123,8 +123,9 @@ be_visitor_interface_interceptors_ss::gen_abstract_ops_helper ( 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_INTERCEPTORS_SS); be_visitor_operation_interceptors_ss op_visitor (&ctx); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp index e77085cb02b..cdfd2843495 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp @@ -166,6 +166,23 @@ be_visitor_interface::is_amh_rh_node (be_interface *node) return 0; } +void +be_visitor_interface::add_abstract_op_args (AST_Operation *old_op, + be_operation &new_op) +{ + AST_Decl *d = 0; + + for (UTL_ScopeActiveIterator si (old_op, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + d = si.item (); + new_op.add_to_scope (d); + } + + new_op.be_add_exceptions (old_op->exceptions ()); +} + // All common visit methods for interface visitor. int diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp index 0d00f73cd42..467b7c46f93 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp @@ -240,6 +240,12 @@ be_visitor_interface_ch::visit_interface (be_interface *node) << "_ptr)0;" << be_uidt_nl << "}" << be_uidt_nl << be_nl; + if (node->is_abstract ()) + { + *os << "static foo_ptr _downcast (CORBA::AbstractBase_ptr abs);" + << be_nl << be_nl; + } + // No Any operator for local interfaces. if (! node->is_local () && be_global->any_support ()) { @@ -284,19 +290,26 @@ be_visitor_interface_ch::visit_interface (be_interface *node) << be_nl << be_nl; // The _interface_repository_id method. - *os << "virtual const char* _interface_repository_id (void) const;\n" - << be_uidt_nl; + *os << "virtual const char* _interface_repository_id (void) const;"; + + if (node->is_abstract ()) + { + *os << be_nl << be_nl + << "virtual void *_tao_obv_narrow (ptr_arith_t type_id);"; + } if (! node->is_local () && ! node->is_abstract ()) { // Add the Proxy Broker member variable. - *os << "private:" << be_idt_nl + *os << be_uidt_nl + << "private:" << be_idt_nl << node->base_proxy_broker_name () << " *" << "the" << node->base_proxy_broker_name () - << "_;" << be_nl << be_uidt_nl; + << "_;"; } - *os << "protected:" << be_idt_nl; + *os << be_uidt_nl << be_nl + << "protected:" << be_idt_nl; if (! node->is_local () && ! node->is_abstract ()) { @@ -315,41 +328,42 @@ be_visitor_interface_ch::visit_interface (be_interface *node) } else { - *os << node->local_name () << " (void);" << be_nl << be_nl; + // Protected default constructor for abstract interfaces. + *os << node->local_name () << " (void);" << be_nl; + + // Protected copy constructor for abstract interfaces. + *os << node->local_name () << " (const " + << node->local_name () << " &);" << be_nl; } - // Local and abstract interfaces don't support stub objects. - if (! node->is_local () && ! node->is_abstract ()) + // Local interfaces don't support stub objects. + if (! node->is_local ()) { *os << node->local_name () << " (" << be_idt << be_idt_nl << "TAO_Stub *objref, " << be_nl << "CORBA::Boolean _tao_collocated = 0," << be_nl << "TAO_Abstract_ServantBase *servant = 0" << be_uidt_nl - << ");" << be_uidt_nl << be_nl; + << ");" << be_uidt_nl; + } + + // Protected destructor. + *os << "virtual ~" << node->local_name () << " (void);"; + if (! node->is_abstract ()) + { // Friends declarations. - *os << "friend class " << node->remote_proxy_impl_name () << ";" + *os << be_nl << be_nl + << "friend class " << node->remote_proxy_impl_name () << ";" << be_nl << "friend class " << node->thru_poa_proxy_impl_name () << ";" << be_nl - << "friend class " << node->direct_proxy_impl_name () << ";" - << be_nl << be_nl; - } - - // Protected copy constructor for abstract interfaces. - if (node->is_abstract ()) - { - *os << node->local_name () << " (const " - << node->local_name () << " &);" << be_nl << be_nl; + << "friend class " << node->direct_proxy_impl_name () << ";"; } - // Protected destructor. - *os << "virtual ~" << node->local_name () << " (void);" - << be_uidt_nl << be_nl; - // Private copy constructor and assignment operator. These are not // allowed, hence they are private. - *os << "private:" << be_idt_nl; + *os << be_uidt_nl << be_nl + << "private:" << be_idt_nl; // Abstract interfaces have a *protected* copy constructor. if (! node->is_abstract ()) @@ -371,6 +385,7 @@ be_visitor_interface_ch::visit_interface (be_interface *node) *os << "};" << be_nl << be_nl; // Don't support smart proxies for local interfaces. + // @@@ (JP) This is TODO for abstract interfaces. if (! node->is_local () && ! node->is_abstract ()) { // Smart Proxy related classes. @@ -476,7 +491,9 @@ be_visitor_interface_ch::gen_abstract_ops_helper (be_interface *node, &item_new_name, op->is_local (), op->is_abstract ()); - + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); ctx.state (TAO_CodeGen::TAO_OPERATION_CH); be_visitor_operation_ch op_visitor (&ctx); op_visitor.visit_operation (&new_op); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp index 107a6b9067e..af50193a815 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ci.cpp @@ -82,6 +82,17 @@ be_visitor_interface_ci::visit_interface (be_interface *node) << " (const " << node->local_name () << " &rhs)" << be_idt_nl << ": CORBA_AbstractBase (rhs)" << be_uidt_nl << "{}" << be_nl << be_nl; + + *os << "ACE_INLINE" << be_nl + << node->name () << "::" << node->local_name () + << " (" << be_idt << be_idt_nl + << "TAO_Stub *objref," << be_nl + << "CORBA::Boolean _tao_collocated," << be_nl + << "TAO_Abstract_ServantBase *servant" << be_uidt_nl + << ")" << be_nl + << ": CORBA_AbstractBase (objref, _tao_collocated, servant)" + << be_uidt_nl + << "{}" << be_nl; } else { diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp index a7c8676bb80..3d712b05e18 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp @@ -143,8 +143,6 @@ be_visitor_interface_cs::visit_interface (be_interface *node) *os << "void" << be_nl << "CORBA::release (" << node->name () << "_ptr p)" << be_nl << "{" << be_idt_nl - << "CORBA::Object_ptr obj = p;" << be_nl - << "CORBA::release (obj);" << be_nl << "CORBA::AbstractBase_ptr abs = p;" << be_nl << "CORBA::release (abs);" << be_uidt_nl << "}" << be_nl << be_nl; @@ -179,53 +177,53 @@ be_visitor_interface_cs::visit_interface (be_interface *node) be_visitor_context ctx = (*this->ctx_); - if (! node->is_abstract ()) + // Interceptor classes. The interceptors helper classes must be + // defined before the interface operations because they are used in + // the implementation of said operations. + + ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS); + be_visitor_interface_interceptors_cs ii_visitor (&ctx); + + if (node->accept (&ii_visitor) == -1) { - // Interceptor classes. The interceptors helper classes must be - // defined before the interface operations because they are used in - // the implementation of said operations. + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_cs::" + "visit_interface - " + "codegen for interceptors classes failed\n"), + -1); + } - ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS); - be_visitor_interface_interceptors_cs ii_visitor (&ctx); + if (!node->is_local () && ! node->is_abstract ()) + { + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS); + be_visitor_interface_remote_proxy_impl_cs irpi_visitor (&ctx); - if (node->accept (&ii_visitor) == -1) + if (node->accept (&irpi_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "visit_interface - " - "codegen for interceptors classes failed\n"), + "codegen for Base Proxy Broker class failed\n"), -1); } - if (!node->is_local ()) - { - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS); - be_visitor_interface_remote_proxy_impl_cs irpi_visitor (&ctx); - - if (node->accept (&irpi_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_cs::" - "visit_interface - " - "codegen for Base Proxy Broker class failed\n"), - -1); - } - - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CS); - be_visitor_interface_remote_proxy_broker_cs irpb_visitor (&ctx); + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CS); + be_visitor_interface_remote_proxy_broker_cs irpb_visitor (&ctx); - if (node->accept (&irpb_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_cs::" - "visit_interface - " - "codegen for Base Proxy Broker class failed\n"), - -1); - } + if (node->accept (&irpb_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_cs::" + "visit_interface - " + "codegen for Base Proxy Broker class failed\n"), + -1); } + } + if (! node->is_abstract ()) + { // Generate the destructor and default constructor. *os << be_nl; *os << "// TAO_IDL - Generated from " << be_nl @@ -296,11 +294,12 @@ be_visitor_interface_cs::visit_interface (be_interface *node) } } - *os << be_uidt_nl << "}" << be_nl << be_nl; + *os << be_uidt_nl << "}"; } } - *os << node->name () << "::~" << node->local_name () + *os << be_nl << be_nl + << node->name () << "::~" << node->local_name () << " (void)" << be_nl; *os << "{}" << be_nl << be_nl; @@ -323,8 +322,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) *os << "void" << be_nl << node->name () << "::_add_ref (void)" << be_nl << "{" << be_idt_nl - << "this->CORBA_Object::_add_ref ();" << be_nl - << "this->CORBA_AbstractBase::_add_ref ();" << be_uidt_nl + << "this->CORBA_Object::_add_ref ();" << be_uidt_nl << "}" << be_nl << be_nl; } @@ -391,124 +389,45 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << "::_unchecked_narrow (obj ACE_ENV_ARG_PARAMETER);" << be_uidt_nl << "}" << be_nl << be_nl; - // The _unchecked_narrow method - - *os << node->full_name () << "_ptr " << be_nl - << node->full_name () << "::_unchecked_narrow (" - << be_idt << be_idt_nl; - if (node->is_abstract ()) { - *os << "CORBA::AbstractBase_ptr obj" << be_nl; + this->gen_abstract_unchecked_narrow (node, + bt, + os); } else { - *os << "CORBA::Object_ptr obj" << be_nl; + this->gen_concrete_unchecked_narrow (node, + bt, + os); } - *os << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << "if (CORBA::is_nil (obj))" << be_idt_nl - << "{" << be_idt_nl - << "return " << bt->nested_type_name (this->ctx_->scope ()) - << "::_nil ();" << be_uidt_nl - << "}" << be_uidt_nl << be_nl; - - - if (! node->is_local () && ! node->is_abstract ()) + if (node->is_abstract ()) { - // Remote _uncheck_narrow implementation. - *os << "if (! obj->_is_local ())" << be_idt_nl + *os << node->full_name () << "_ptr" << be_nl + << node->full_name () + << "::_downcast (CORBA::AbstractBase_ptr abs)" << be_nl << "{" << be_idt_nl - << "TAO_Stub* stub = obj->_stubobj ();" << be_nl << be_nl - << "if (stub)" << be_idt_nl + << "if (CORBA::is_nil (abs))" << be_idt_nl << "{" << be_idt_nl - << "stub->_incr_refcnt ();" << be_uidt_nl + << "return " << node->local_name () << "::_nil ();" << be_uidt_nl << "}" << be_uidt_nl << be_nl - // Declare the default proxy. - << bt->nested_type_name (this->ctx_->scope ()) - << "_ptr default_proxy = " - << bt->nested_type_name (this->ctx_->scope ()) - <<"::_nil ();\n\n"; - - // If the policy dictates that the proxy be collocated, use the - // function to create one. - os->indent (); + << "return (" << node->local_name () + << "_ptr) abs->_tao_obv_narrow ((ptr_arith_t) &_downcast);" + << be_uidt_nl + << "}" << be_nl << be_nl; - *os << "if (! CORBA::is_nil (stub->servant_orb_var ().ptr ())" - << be_idt << be_idt_nl - << "&& stub->servant_orb_var ()->orb_core ()->optimize_collocation_objects ()" - << be_nl - << "&& obj->_is_collocated ()" << be_nl - << "&& " << node->flat_client_enclosing_scope () - << node->base_proxy_broker_name () - << "_Factory_function_pointer != 0)" << be_uidt_nl + *os << "void *" << be_nl + << node->full_name () + << "::_tao_obv_narrow (ptr_arith_t type_id)" << be_nl << "{" << be_idt_nl - << "ACE_NEW_RETURN (" << be_idt << be_idt_nl // 2 idt - << "default_proxy," << be_nl - << "::" << bt->name () - << " (" << be_idt << be_idt_nl // 3 idt - << "stub," << be_nl - << "1," << be_nl - << "obj->_servant ()" << be_uidt_nl << ")," << be_uidt_nl - << bt->nested_type_name (this->ctx_->scope ()) - << "::_nil ()" << be_uidt_nl << ");" - << be_uidt << be_uidt_nl // 1 idt - << "}" << be_uidt_nl << be_nl; // 0 idt - - - // The default proxy will either be returned else be transformed to - // a smart one! - *os << "if (CORBA::is_nil (default_proxy))" << be_idt_nl + << "if (type_id == (ptr_arith_t) &_downcast)" << be_idt_nl << "{" << be_idt_nl - << "ACE_NEW_RETURN (" << be_idt << be_idt_nl - << "default_proxy," << be_nl - << "::" << bt->name () << " (" << be_idt << be_idt_nl - << "stub," << be_nl - << "0," << be_nl - << "obj->_servant ()" << be_uidt_nl - << ")," << be_uidt_nl - << bt->nested_type_name (this->ctx_->scope ()) - << "::_nil ()" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl - << "}" << be_uidt_nl << be_nl; - - if (be_global->gen_smart_proxies ()) - { - *os << "return TAO_" << node->flat_name () - << "_PROXY_FACTORY_ADAPTER::instance ()->create_proxy (default_proxy);" - << be_uidt_nl; - } - else - { - *os << "return default_proxy;" << be_uidt_nl; - } - - *os << "}" << be_uidt_nl - << "else " << be_idt_nl - << "{" << be_idt_nl; - } - - *os << "return" << be_idt_nl - << "ACE_reinterpret_cast (" << be_idt << be_idt_nl - << node->local_name () << "_ptr," << be_nl - << "obj->_tao_QueryInterface (" << be_idt << be_idt_nl - << "ACE_reinterpret_cast (" << be_idt << be_idt_nl - << "ptr_arith_t," << be_nl - << "&" << node->local_name () - << "::_tao_class_id" << be_uidt_nl - << ")" << be_uidt << be_uidt_nl - << ")" << be_uidt << be_uidt_nl - << ");" << be_uidt << be_uidt << be_uidt_nl; - - if (! node->is_local () && ! node->is_abstract ()) - { - *os << "}" << be_uidt << be_uidt_nl; + << "return this;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "return 0;" << be_uidt_nl + << "}" << be_nl << be_nl; } - - *os << "}" << be_nl << be_nl; - // The _duplicate method *os << node->full_name () << "_ptr" << be_nl @@ -523,8 +442,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << "return obj;" << be_uidt_nl << "}" << be_nl << be_nl; - // Generate the is_a method. _is_a is not supported on local - // or abstract objects. + // Generate the is_a method (not supported on local objects). if (! node->is_local ()) { os->indent (); @@ -660,9 +578,7 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << "this->_add_ref ();" << be_uidt_nl << "}" << be_uidt_nl << be_nl << "return retv;" << be_uidt_nl - << "}\n\n"; - - os->indent (); + << "}" << be_nl << be_nl; *os << "const char* " << node->full_name () << "::_interface_repository_id (void) const" @@ -670,22 +586,20 @@ be_visitor_interface_cs::visit_interface (be_interface *node) << "{" << be_idt_nl << "return \"" << node->repoID () << "\";" << be_uidt_nl - << "}\n\n"; + << "}" << be_uidt_nl << be_nl; - os->decr_indent (0); + // 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_abstract ()) { - // 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); - } - // Smart Proxy classes. if (! node->is_local ()) { @@ -771,8 +685,9 @@ be_visitor_interface_cs::gen_abstract_ops_helper (be_interface *node, 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); @@ -787,3 +702,163 @@ be_visitor_interface_cs::gen_abstract_ops_helper (be_interface *node, return 0; } +void +be_visitor_interface_cs::gen_concrete_unchecked_narrow (be_interface *node, + be_type *bt, + TAO_OutStream *os) +{ + *os << node->full_name () << "_ptr " << be_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "CORBA::Object_ptr obj" << be_nl + << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "if (CORBA::is_nil (obj))" << be_idt_nl + << "{" << be_idt_nl + << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + + if (! node->is_local ()) + { + // Remote _unchecked_narrow implementation. + *os << "if (! obj->_is_local ())" << be_idt_nl + << "{" << be_idt_nl + << "TAO_Stub* stub = obj->_stubobj ();" << be_nl << be_nl + << "if (stub != 0)" << be_idt_nl + << "{" << be_idt_nl + << "stub->_incr_refcnt ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + // Declare the default proxy. + *os << bt->nested_type_name (this->ctx_->scope ()) + << "_ptr default_proxy = " + << bt->nested_type_name (this->ctx_->scope ()) + <<"::_nil ();" << be_nl << be_nl; + + // If the policy didtates that the proxy be collocated, use the + // function to create one. + *os << "if (" << be_idt << be_idt_nl + << "!CORBA::is_nil (stub->servant_orb_var ().ptr ()) &&" << be_nl + << "stub->servant_orb_var ()->orb_core ()->optimize_collocation_objects () &&" + << be_nl + << "obj->_is_collocated () &&" << be_nl + << node->flat_client_enclosing_scope () << node->base_proxy_broker_name () + << "_Factory_function_pointer != 0" << be_uidt_nl << ")" + << be_nl << "{" + << be_idt_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "default_proxy," << be_nl + << "::" << bt->name () + << " (" << be_idt << be_idt_nl + << "stub," << be_nl + << "1," << be_nl + << "obj->_servant ()" << be_uidt_nl << ")," << be_uidt_nl + << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ()" << be_uidt_nl << ");" + << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + + // The default proxy will either be returned else be transformed to + // a smart one! + *os << "if (CORBA::is_nil (default_proxy))" << be_idt_nl + << "{" << be_idt_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "default_proxy," << be_nl + << "::" << bt->name () << " (" << be_idt << be_idt_nl + << "stub," << be_nl + << "0," << be_nl + << "obj->_servant ()" << be_uidt_nl + << ")," << be_uidt_nl + << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ()" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + if (be_global->gen_smart_proxies ()) + { + *os << "return TAO_" << node->flat_name () + << "_PROXY_FACTORY_ADAPTER::instance ()->create_proxy (default_proxy);" + << be_uidt_nl; + } + else + { + *os << "return default_proxy;" << be_uidt_nl; + } + + *os << "}" << be_uidt_nl + << "else " << be_idt_nl; + } + else + { + *os << be_idt; + } + + // Local _unchecked_narrow. + *os << "return" << be_idt_nl + << "ACE_reinterpret_cast (" << be_idt << be_idt_nl + << node->local_name () << "_ptr," << be_nl + << "obj->_tao_QueryInterface (" << be_idt << be_idt_nl + << "ACE_reinterpret_cast (" << be_idt << be_idt_nl + << "ptr_arith_t," << be_nl + << "&" << node->local_name () << "::_tao_class_id" << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt << be_uidt_nl; + + *os << "}" << be_nl << be_nl; +} + +void +be_visitor_interface_cs::gen_abstract_unchecked_narrow (be_interface *node, + be_type *bt, + TAO_OutStream *os) +{ + *os << node->full_name () << "_ptr " << be_nl + << node->full_name () << "::_unchecked_narrow (" + << be_idt << be_idt_nl + << "CORBA::AbstractBase_ptr obj" << be_nl + << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl + << ")" << be_uidt_nl + << "{" << be_idt_nl + << "if (CORBA::is_nil (obj))" << be_idt_nl + << "{" << be_idt_nl + << "return " << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ();" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + // Declare the default proxy. + *os << bt->nested_type_name (this->ctx_->scope ()) + << "_ptr default_proxy = " + << bt->nested_type_name (this->ctx_->scope ()) + <<"::_nil ();" << be_nl << be_nl; + + *os << "if (obj->_is_objref ())" << be_idt_nl + << "{" << be_idt_nl; + + *os << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "default_proxy," << be_nl + << "::" << bt->name () << " (" << be_idt << be_idt_nl + << "obj->_stubobj ()," << be_nl + << "0," << be_nl + << "obj->_servant ()" << be_uidt_nl + << ")," << be_uidt_nl + << bt->nested_type_name (this->ctx_->scope ()) + << "::_nil ()" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt_nl; + + *os << "else" << be_idt_nl + << "{" << be_idt_nl + << "default_proxy = " << bt->name () << "::_downcast (obj);" + << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + *os << "return default_proxy;" << be_uidt_nl; + + *os << "}" << be_nl << be_nl; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp index 488ca9ee094..4e60bb600f5 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp @@ -361,7 +361,9 @@ be_visitor_interface_sh::gen_abstract_ops_helper ( &item_new_name, op->is_local (), op->is_abstract ()); - + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); ctx.state (TAO_CodeGen::TAO_OPERATION_SH); be_visitor_operation_sh op_visitor (&ctx); op_visitor.visit_operation (&new_op); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp index 555118958d8..5b31adb0ea9 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp @@ -427,8 +427,9 @@ be_visitor_interface_ss::gen_abstract_ops_helper (be_interface *node, 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_SS); be_visitor_operation_ss op_visitor (&ctx); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp index 7815575cfa6..c43cf1a98a2 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_ch.cpp @@ -135,7 +135,9 @@ be_visitor_interface_remote_proxy_impl_ch::gen_abstract_ops_helper ( &item_new_name, op->is_local (), op->is_abstract ()); - + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); ctx.state (TAO_CodeGen::TAO_OPERATION_PROXY_IMPL_XH); be_visitor_operation_proxy_impl_xh op_visitor (&ctx); op_visitor.visit_operation (&new_op); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp index 948f03d86d5..8d9f84ac942 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/remote_proxy_impl_cs.cpp @@ -122,8 +122,9 @@ be_visitor_interface_remote_proxy_impl_cs::gen_abstract_ops_helper ( 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_REMOTE_PROXY_IMPL_CS); be_visitor_operation_remote_proxy_impl_cs op_visitor (&ctx); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp index 8c82eb6f2dd..5e975bbfd6f 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_sh.cpp @@ -138,7 +138,9 @@ be_visitor_interface_thru_poa_proxy_impl_sh::gen_abstract_ops_helper ( &item_new_name, op->is_local (), op->is_abstract ()); - + new_op.set_defined_in (node); + be_visitor_interface::add_abstract_op_args (op, + new_op); ctx.state (TAO_CodeGen::TAO_OPERATION_THRU_POA_COLLOCATED_SH); be_visitor_operation_proxy_impl_xh op_visitor (&ctx); op_visitor.visit_operation (&new_op); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp index 3c6d9f4550e..9a13057b46a 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/thru_poa_proxy_impl_ss.cpp @@ -112,8 +112,9 @@ be_visitor_interface_thru_poa_proxy_impl_ss::gen_abstract_ops_helper ( 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_THRU_POA_COLLOCATED_SS); be_visitor_operation_thru_poa_proxy_impl_ss op_visitor (&ctx); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp index 444bdeddc8a..6e6bee2d9b2 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/arglist.cpp @@ -104,7 +104,7 @@ be_visitor_operation_arglist::visit_operation (be_operation *node) case TAO_CodeGen::TAO_OPERATION_ARGLIST_CH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_IH: - if (node->is_local () || node->defined_in ()->is_abstract ()) + if (node->is_local ()) { *os << " = 0;" << be_nl << be_nl; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp index 1ddb56dbe60..2c84d1e4fec 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp @@ -144,8 +144,16 @@ be_visitor_operation_interceptors_cs::generate_class_declaration ( } *os << " (" << be_idt << be_idt_nl - << "TAO_GIOP_Invocation *_tao_invocation," << be_nl - << "CORBA::Object_ptr _tao_target"; + << "TAO_GIOP_Invocation *_tao_invocation," << be_nl; + + if (node->defined_in ()->is_abstract ()) + { + *os << "CORBA::AbstractBase_ptr _tao_target"; + } + else + { + *os << "CORBA::Object_ptr _tao_target"; + } // Generate the argument list with the appropriate mapping. For these // we grab a visitor that generates the parameter listing. @@ -459,8 +467,16 @@ be_visitor_operation_interceptors_cs::generate_class_definition ( } *os << " (" << be_idt << be_idt_nl - << "TAO_GIOP_Invocation *_tao_invocation," << be_nl - << "CORBA::Object_ptr _tao_target"; + << "TAO_GIOP_Invocation *_tao_invocation," << be_nl; + + if (node->defined_in ()->is_abstract ()) + { + *os << "CORBA::AbstractBase_ptr _tao_target"; + } + else + { + *os << "CORBA::Object_ptr _tao_target"; + } // Generate the argument list with the appropriate mapping. For these // we grab a visitor that generates the parameter listing. diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index 53a1574f633..a710d6f41a2 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -27,15 +27,16 @@ ACE_RCSID (be_visitor_operation, // ************************************************************ be_visitor_operation::be_visitor_operation (be_visitor_context *ctx) - : be_visitor_scope (ctx) + : be_visitor_scope (ctx), + operation_name_ (0) { } be_visitor_operation::~be_visitor_operation (void) { + delete [] operation_name_; } - // Is the operation return type void? int be_visitor_operation::void_return_type (be_type *bt) @@ -135,7 +136,7 @@ be_visitor_operation::gen_throw_spec (be_operation *node) } - *os << be_nl << ", " << excp->name (); + *os << "," << be_nl << excp->name (); } } @@ -333,3 +334,935 @@ be_visitor_operation::gen_check_interceptor_exception (be_type *return_type) *os << ");\n"; return 0; } + +int +be_visitor_operation::gen_stub_operation_body ( + be_operation *node, + be_type *return_type + ) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_visitor_context ctx; + const char *target = "_collocated_tao_target_"; + + if (node->defined_in ()->is_abstract ()) + { + target = "this"; + } + + // Generate the actual code for the stub. However, if any of the argument + // types is "native", we flag a MARSHAL exception. + // last argument - is always ACE_ENV_ARG_PARAMETER + *os << "{" << be_idt_nl; + *os << this->gen_environment_var () << "\n"; + + // Generate any pre stub info if and only if none of our parameters is of + // the native type. + if (!node->has_native ()) + { + // native type does not exist. + + // Generate any "pre" stub information such as tables or declarations + // This is a template method and the actual work will be done by the + // derived class + if (this->gen_pre_stub_info (node) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "gen_pre_stub_info failed\n" + ), + -1 + ); + } + } + + // Declare return type. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS); + be_visitor_operation_rettype_vardecl_cs rd_visitor (&ctx); + + if (return_type->accept (&rd_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for return var decl failed\n"), + -1); + } + + if (node->has_native ()) // native exists => no stub + { + if (this->gen_raise_exception (return_type, + "CORBA::MARSHAL", + "") == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for return var failed\n" + ), + -1 + ); + } + } + else + { + // Generate code that retrieves the underlying stub object and then + // invokes do_static_call on it. + *os << "TAO_Stub *istub = " << target << "->_stubobj ();" + << be_nl << be_nl + << "if (istub == 0)" << be_idt_nl + << "{" << be_idt_nl; + + // If the stub object was bad, then we raise a system exception. + if (this->gen_raise_exception (return_type, "CORBA::INTERNAL", "") == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for checking exception failed\n" + ), + -1 + ); + } + + *os << be_uidt; + + os->indent (); + + *os << "}" << be_uidt_nl << be_nl; + + // Do any pre marshal and invoke processing with return type. This + // includes allocating memory, initialization. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_PRE_INVOKE_CS); + be_visitor_operation_rettype_pre_invoke_cs rpi_visitor (&ctx); + + if (return_type->accept (&rpi_visitor) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for retval pre invoke failed\n" + ), + -1 + ); + } + + // Do any pre marshal and invoke stuff with arguments. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS); + be_visitor_operation_argument api_visitor (&ctx); + + if (node->accept (&api_visitor) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for argument pre invoke failed\n" + ), + -1 + ); + } + + // Generate the code for marshaling in the parameters and transmitting + // them. + if (this->gen_marshal_and_invoke (node, return_type) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for marshal and invoke failed\n" + ), + -1 + ); + + } + + if (!this->void_return_type (return_type)) + { + // Now generate the normal successful return statement. + if (return_type->size_type () == AST_Type::VARIABLE + || return_type->base_node_type () == AST_Decl::NT_array) + { + *os << "return _tao_retval._retn ();"; + } + else + { + *os << "return _tao_retval;"; + } + } + } // end of if (!native) + + *os << be_uidt_nl << "}\n\n"; + + return 0; +} + +int +be_visitor_operation::gen_pre_stub_info ( + be_operation *node + ) +{ + // Check if this operation raises any exceptions. In that case, we must + // generate a list of exception typecodes. This is not valid for + // attributes. + if (!this->ctx_->attribute ()) + { + be_visitor_context ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); + be_visitor_operation_exceptlist_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) " + "be_visitor_operation_cs::" + "gen_pre_stub_info - " + "Exceptionlist generation error\n"), + -1); + } + } + + return 0; +} + +int +be_visitor_operation::gen_marshal_and_invoke ( + be_operation *node, + be_type *bt + ) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_visitor_context ctx; + const char *target = "_collocated_tao_target_"; + + if (node->defined_in ()->is_abstract ()) + { + target = "this"; + } + + + os->indent (); + + *os << be_nl; + + // Create the GIOP_Invocation and grab the outgoing CDR stream. + switch (node->flags ()) + { + case AST_Operation::OP_oneway: + *os << "TAO_GIOP_Oneway_Invocation _tao_call "; + break; + default: + *os << "TAO_GIOP_Twoway_Invocation _tao_call "; + } + + // Do we have "_set_" or "_get_" prepended? + size_t ext = this->ctx_->attribute () ? 5 : 0; + + // Do we have any arguments in the operation that needs marshalling + int flag = + node->count_arguments_with_direction (AST_Argument::dir_IN + | AST_Argument::dir_INOUT); + + *os << "(" << be_idt << be_idt_nl + << "istub," << be_nl + << this->compute_operation_name (node) + << "," << be_nl + << ACE_OS::strlen (node->original_local_name ()->get_string ()) + ext + << "," << be_nl + << flag + << "," <<be_nl + << "istub->orb_core ()" << be_uidt_nl + << ");" << be_uidt_nl; + + *os << be_nl + << "int _invoke_status;" << be_nl; + + // Generate code to obtain the client request interceptors from the + // ORB. + *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)" << be_nl; + *os << "TAO_ClientRequestInterceptor_Adapter _tao_vfr (" + << be_idt << be_idt_nl + << "istub->orb_core ()->client_request_interceptors ()," << be_nl + << "&_tao_call," << be_nl + << "_invoke_status" + << be_uidt_nl + << ");" << be_uidt_nl; + + *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; + + // The connection retry loop. + *os << be_nl + << "for (;;)" << be_idt_nl + << "{" << be_idt_nl + << "_invoke_status = TAO_INVOKE_EXCEPTION;" << be_nl; + + + *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; + + *os << "TAO_ClientRequestInfo_" << node->flat_name (); + + // We need the interface node in which this operation was defined. However, + // if this operation node was an attribute node in disguise, we get this + // information from the context and add a "_get"/"_set" to the flat + // name to get around the problem of overloaded methods which are + // generated for attributes. + if (this->ctx_->attribute ()) + { + bt = be_type::narrow_from_decl (node->return_type ()); + + if (!bt) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_interceptors_ch::" + "visit_operation - " + "Bad return type\n"), + -1); + } + + // Grab the right visitor to generate the return type if its not + // void it means it is not the accessor. + if (!this->void_return_type (bt)) + { + *os << "_get"; + } + else + { + *os << "_set"; + } + } + + *os << " _tao_ri (" << be_idt << be_idt_nl + << "&_tao_call," << be_nl + << target; + + // Generate the formal argument fields which are passed + // to the RequestInfo object. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS); + be_visitor_operation_interceptors_arglist iia_visitor (&ctx); + + if (node->accept (&iia_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for arglist failed\n"), + -1); + } + + *os << be_uidt_nl << ");" << be_uidt_nl; + + if (this->gen_check_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; + + // Prepare the request header. + *os << be_nl << "CORBA::Short _tao_response_flag = "; + + switch (node->flags ()) + { + case AST_Operation::OP_oneway: + *os << "_tao_call.sync_scope ();" << be_nl + << "TAO_INTERCEPTOR (_tao_ri.response_expected (0));" << be_nl; + break; + default: + *os << "TAO_TWOWAY_RESPONSE_FLAG;" << be_nl + << "TAO_INTERCEPTOR (_tao_ri.response_expected (1));" << be_nl; + } + + *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; + + *os << be_nl << "ACE_TRY" << be_idt_nl + << "{" << be_idt_nl; + + // Invoke send_request() interception point. + // This is done before the Invocation::start() call so that a + // connection can be avoided if send_request() throws an exception, + // i.e. this is an optimization. + *os << "_tao_vfr.send_request (" << be_idt << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl + << "ACE_TRY_CHECK;" << be_nl; + + // _invoke_status is potentially set (via a reference) in + // TAO_ClientRequestInterceptor_Adapter::send_request() so check its + // value. If a location forward or transport retry occured, then we + // need to restart the loop so that the ClientRequestInfo object is + // setup for the re-issued request. + // + // Note that since we're invoking the send_request() interception + // point before the Invocation::start() call, i.e. before a + // connection is ever made, we're actually able to forward requests + // for oneways via the PortableInterceptor::ForwardRequest exception + // too! + *os << be_nl + << "if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_call.restart_flag (1);" << be_nl + << "continue;" << be_uidt_nl + << "}" << be_uidt_nl; + + *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; + + + *os << be_nl + << "_tao_call.start (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_nl; + + // Check if there is an exception. + if (this->gen_check_interceptor_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + *os << be_nl + << "_tao_call.prepare_header (" << be_idt << be_idt_nl + << "ACE_static_cast (CORBA::Octet, _tao_response_flag)" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl; + + // Check if there is an exception. + if (this->gen_check_interceptor_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + // Now make sure that we have some in and inout parameters. Otherwise, there + // is nothing to be marshaled in. + if (this->has_param_type (node, AST_Argument::dir_IN) || + this->has_param_type (node, AST_Argument::dir_INOUT)) + { + *os << be_nl + << "TAO_OutputCDR &_tao_out = _tao_call.out_stream ();" + << be_nl << be_nl + << "if (!(" << be_idt << be_idt_nl; + + // Marshal each in and inout argument. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); + be_visitor_operation_argument_invoke oai_visitor (&ctx); + + if (node->accept (&oai_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for return var in " + "do_static_call failed\n"), + -1); + } + + *os << be_nl + << "))" << be_uidt_nl + << "{" << be_idt_nl; + + // If marshaling fails, raise exception. + if (this->gen_raise_interceptor_exception (bt, "CORBA::MARSHAL", "") + == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and invoke - " + "codegen for return var failed\n"), + -1); + } + + *os << be_uidt_nl << be_nl; + *os << "}" << be_uidt_nl << be_nl; + } + else + { + *os << be_nl << be_nl; + } + + *os << "_invoke_status =" << be_idt_nl; + + if (node->flags () == AST_Operation::OP_oneway) + { + // Oneway operation. + *os << "_tao_call.invoke (ACE_ENV_SINGLE_ARG_PARAMETER);"; + } + else + { + if (node->exceptions ()) + { + *os << "_tao_call.invoke (_tao_" << node->flat_name () + << "_exceptiondata, " + << node->exceptions ()->length () + << " ACE_ENV_ARG_PARAMETER);"; + } + else + { + *os << "_tao_call.invoke (0, 0 ACE_ENV_ARG_PARAMETER);"; + } + } + + *os << be_uidt_nl; + + // Check if there is an exception. + if (this->gen_check_interceptor_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + *os << be_nl + << "if (_invoke_status == TAO_INVOKE_EXCEPTION)" << be_idt_nl + << "{" << be_idt_nl; + + // Unlisted user exception received by client. + int status = this->gen_raise_interceptor_exception ( + bt, + "CORBA::UNKNOWN", + "TAO_OMG_VMCID | 1, CORBA::COMPLETED_YES" + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and invoke - " + "codegen for return var failed\n"), + -1); + } + + *os << be_uidt_nl << "}" << be_uidt_nl; + + // Note that we no longer turn this code generation off if it's a + // one way operation since the sync scope policy may actually allow + // things such as LOCATION_FORWARD replies to be propagated back to + // the client (e.g. SYNC_WITH_TARGET). + *os << "else if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl + << "{" << be_idt_nl + << "TAO_INTERCEPTOR (" << be_idt << be_idt_nl + << "_tao_ri.reply_status (_invoke_status);" << be_nl + << "_tao_vfr.receive_other (" << be_idt << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl + << "ACE_TRY_CHECK;" << be_uidt_nl + << ")" << be_uidt_nl + << be_nl + << "continue;" << be_uidt_nl + << "}" << be_uidt_nl + << be_nl; + + // If we reach here, we are ready to proceed. + // the code below this is for twoway operations only. + + if (!this->void_return_type (bt) + || this->has_param_type (node, AST_Argument::dir_INOUT) + || this->has_param_type (node, AST_Argument::dir_OUT)) + + { + // Do any post_invoke stuff that might be necessary. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); + be_visitor_operation_argument oapi_visitor (&ctx); + + if (node->accept (&oapi_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for args in post do_static_call\n"), + -1); + } + + // Generate any temporary variables to demarshal the arguments. + be_visitor_args_decl vis1 (&ctx); + + if (node->accept (&vis1) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_pre_stub_info - " + "codegen for pre args failed\n"), + -1); + } + + if (!this->void_return_type (bt)) + { + // Generate any temporary variables to demarshal the return value. + be_visitor_operation_rettype_post_invoke_cs vis2 (&ctx); + + if (bt->accept (&vis2) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_pre_stub_info - " + "codegen rettype [post invoke] failed\n"), + -1); + } + } + + // Check if there was a user exception, else demarshal the + // return val (if any) and parameters (if any) that came with + // the response message. + *os << be_nl + << "TAO_InputCDR &_tao_in = _tao_call.inp_stream ();" + << be_nl << be_nl + << "if (!(" << be_idt << be_idt_nl; + + if (!this->void_return_type (bt)) + { + // Demarshal the return value. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); + be_visitor_operation_rettype_marshal_ss ori_visitor (&ctx); + + if (node->accept (&ori_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for return var failed\n"), + -1); + } + } + + if (this->has_param_type (node, AST_Argument::dir_INOUT) + || this->has_param_type (node, AST_Argument::dir_OUT)) + { + if (!this->void_return_type (bt)) + { + *os << " &&" << be_nl; + } + + // Demarshal each out and inout argument. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); + be_visitor_operation_argument_invoke oai_visitor (&ctx); + + if (node->accept (&oai_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for return var failed\n"), + -1); + } + } + + *os << be_nl + << "))" << be_uidt_nl + << "{" << be_idt_nl; + + // If marshaling fails, raise exception. + int status = this->gen_raise_interceptor_exception ( + bt, + "CORBA::MARSHAL", + "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES" + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and invoke - " + "codegen for return var failed\n"), + -1); + } + + *os << be_uidt_nl << "}" << be_uidt_nl; + } + + *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; + + // Populate the ClientRequestInfo object with result, if any, of the + // invocation. + if (!this->void_return_type (bt)) + { + // Here's what we are going to do to have a uniform way of getting the + // return value updated for the Request Info: + // declare a operation_retval type object and assign the + // _tao_retval._retn () to it. + // We pass this to the result updation method (note: it hasnt + // got destroyed) + // We then put it back into the original _tao_retval + // object. + // And finally the _retn () is returned from the operation w.o + // causing any problems. + + // Generate the return type mapping (same as in the header file) + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); + be_visitor_operation_rettype oro_visitor (&ctx); + + if (bt->accept (&oro_visitor) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for return type failed\n" + ), + -1 + ); + } + + if (bt->size_type () == AST_Type::VARIABLE + || bt->base_node_type () == AST_Decl::NT_array) + { + *os << " _tao_retval_info =" << be_idt_nl + << "_tao_retval._retn ();" << be_uidt_nl + << "_tao_ri.result (_tao_retval_info);" << be_nl + << "_tao_retval = _tao_retval_info;" << be_nl; + } + else + { + *os << " _tao_retval_info =" << be_idt_nl + << "_tao_retval;" << be_uidt_nl + << "_tao_ri.result (_tao_retval_info);" << be_nl; + } + } + + // Oneway operations don't have receive_reply() interception since + // once the request goes over the wire, its the end of the story! + // However, we still need to call an ending interception point + // (receive_other()) to satisfy the General Flow Rules. + if (node->flags () != AST_Operation::OP_oneway) + { + // If we get this far (in the generated code) then we + // successfully completed the request, i.e. no connection retry + // will occur, nor will a LOCATION_FORWARD. + // Invoke receive_reply() interception point. + *os << be_nl + << "_tao_ri.reply_status (_invoke_status);" << be_nl + << "_tao_vfr.receive_reply (" << be_idt << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl; + } + else if (node->flags () == AST_Operation::OP_oneway) + { + // Invoke receive_other() interception point. + *os << be_nl + << "_tao_ri.reply_status (_invoke_status);" << be_nl + << "_tao_vfr.receive_other (" << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_nl; + } + + *os << "ACE_TRY_CHECK;" + << be_uidt_nl + << "}" << be_uidt_nl; + + // Note that we do NOT catch the PortableInterceptor::ForwardRequest + // exception here. It is caught in the + // TAO_ClientRequestInterceptor_Adapter class. This is necessary to + // prevent applications from being able to throw the exception in an + // effort to get an easy (but illegal) way to forward a request. + + *os << "ACE_CATCHANY" << be_idt_nl + << "{" << be_idt_nl; + + // Update the exception field of the ClientRequestInfo. + *os << "_tao_ri.exception (&ACE_ANY_EXCEPTION);"<< be_nl; + + *os << "_tao_vfr.receive_exception (" << be_idt << be_idt_nl + << "&_tao_ri" << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt_nl + << "ACE_TRY_CHECK;" << be_nl; + + // The receive_exception() interception point may have thrown a + // PortableInterceptor::ForwardRequest exception. In that event, + // the connection retry loop must be restarted so do not rethrow the + // caught exception. + *os << be_nl + << "PortableInterceptor::ReplyStatus _tao_status =" << be_idt_nl + << "_tao_ri.reply_status (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl + << "ACE_TRY_CHECK;" << be_nl; + + *os << be_nl + << "if (_tao_status == PortableInterceptor::SYSTEM_EXCEPTION" << be_nl + << " || _tao_status == PortableInterceptor::USER_EXCEPTION)" + << be_idt_nl + << "{" << be_idt_nl; + + if (be_global->use_raw_throw ()) + { + *os << "throw;"; + } + else + { + *os << "ACE_RE_THROW;"; + } + + *os << be_uidt_nl + << "}" << be_uidt << be_uidt_nl; + + *os << "}" << be_uidt_nl + << "ACE_ENDTRY;" << be_nl; + + if (this->gen_check_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + // The receive_exception() or receive_other() interception point may + // have thrown a PortableInterceptor::ForwardRequest exception. In + // that event, the connection retry loop must be restarted. Note + // that the _invoke_status variable is not set by the interceptor + // support code, so we must explicitly check the status in the + // ClientRequestInfo object. + *os << be_nl + << "PortableInterceptor::ReplyStatus _tao_status =" << be_idt_nl + << "_tao_ri.reply_status (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl; + + if (this->gen_check_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + *os << be_nl + << "if (_tao_status == PortableInterceptor::LOCATION_FORWARD" << be_nl + << " || _tao_status == PortableInterceptor::TRANSPORT_RETRY)" + << be_idt_nl + << "{" << be_idt_nl + << "continue;" << be_uidt_nl + << "}" << be_uidt_nl; + + *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; + + *os << be_nl << "break;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; + + return 0; +} + +int +be_visitor_operation::gen_raise_interceptor_exception ( + be_type *bt, + const char *excep, + const char *completion_status + ) +{ + TAO_OutStream *os = this->ctx_->stream (); + + if (this->void_return_type (bt)) + { + if (be_global->use_raw_throw ()) + { + *os << "throw " << excep << "(" << completion_status << ");"; + } + else + { + *os << "TAO_INTERCEPTOR_THROW (" << be_idt << be_idt_nl + << excep << " (" << be_idt << be_idt_nl + << completion_status << be_uidt_nl + << ")" << be_uidt << be_uidt_nl + << ");" << be_uidt; + } + } + else + { + if (bt->size_type () == AST_Type::VARIABLE + || bt->base_node_type () == AST_Decl::NT_array) + { + *os << "TAO_INTERCEPTOR_THROW_RETURN (" << be_idt << be_idt_nl + << excep << " (" << be_idt << be_idt_nl + << completion_status << be_uidt_nl + << ")," << be_uidt_nl + << "0" << be_uidt_nl + << ");" << be_uidt; + } + else + { + *os << "TAO_INTERCEPTOR_THROW_RETURN (" << be_idt << be_idt_nl + << excep << " (" << be_idt << be_idt_nl + << completion_status << be_uidt_nl + << ")," << be_uidt_nl + << "_tao_retval" << be_uidt_nl + << ");" << be_uidt; + } + } + + return 0; +} + +const char* +be_visitor_operation::compute_operation_name ( + be_operation *node + ) +{ + if (this->operation_name_ == 0) + { + // Length for two double quotes and the null termination char. + size_t len = 3; + + if (this->ctx_->attribute ()) + { + // "Added length for "_set_" or "_get_". + len += 5; + } + + len += ACE_OS::strlen (node->original_local_name ()->get_string ()); + + ACE_NEW_RETURN (this->operation_name_, + char [len], + 0); + + ACE_OS::strcpy (this->operation_name_, "\""); + + if (this->ctx_->attribute ()) + { + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + ACE_OS::strcat (this->operation_name_, "_set_"); + } + else + { + ACE_OS::strcat (this->operation_name_, "_get_"); + } + } + + ACE_OS::strcat (this->operation_name_, + node->original_local_name ()->get_string ()); + ACE_OS::strcat (this->operation_name_, "\""); + } + + return this->operation_name_; +} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp index 37aa726e00b..4cea8a38b26 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp @@ -122,129 +122,140 @@ be_visitor_operation_cs::visit_operation (be_operation *node) -1); } - *os << "{" << be_idt_nl; - *os << this->gen_environment_var (); - - if (be_global->exception_support ()) - { - *os << be_nl << be_nl; - } - - // For what follows, the return type node nust be unaliased. - if (bt->node_type () == AST_Decl::NT_typedef) + // @@@ (JP) No collocation for abstract interface operations yet. We + // are generating the code as if there were no proxies, and using + // the (concrete interface's) stub info that we got over the wire. + if (intf->is_abstract ()) { - be_typedef *btd = be_typedef::narrow_from_decl (bt); - bt = btd->primitive_base_type (); + return this->gen_stub_operation_body (node, + bt); } - - AST_Decl::NodeType bnt = bt->base_node_type (); - be_predefined_type *bpt = 0; - AST_PredefinedType::PredefinedType pdt = AST_PredefinedType::PT_void; - - if (bnt == AST_Decl::NT_pre_defined) + else { - bpt = be_predefined_type::narrow_from_decl (bt); - pdt = bpt->pt (); + *os << "{" << be_idt_nl; + *os << this->gen_environment_var (); - if (pdt == AST_PredefinedType::PT_longlong) + if (be_global->exception_support ()) { - *os << "CORBA::LongLong _tao_check_retval = " - << "ACE_CDR_LONGLONG_INITIALIZER;" << be_nl << be_nl; + *os << be_nl << be_nl; } - else if (pdt == AST_PredefinedType::PT_longdouble) + + // For what follows, the return type node nust be unaliased. + if (bt->node_type () == AST_Decl::NT_typedef) { - *os << "CORBA::LongDouble _tao_check_retval = " - << "ACE_CDR_LONG_DOUBLE_INITIALIZER;" << be_nl << be_nl; + be_typedef *btd = be_typedef::narrow_from_decl (bt); + bt = btd->primitive_base_type (); } - } - // Generate code that retrieves the proper proxy implementation - // using the proxy broker available, and perform the call - // using the proxy implementation provided by the broker. + AST_Decl::NodeType bnt = bt->base_node_type (); + be_predefined_type *bpt = 0; + AST_PredefinedType::PredefinedType pdt = AST_PredefinedType::PT_void; - *os << intf->base_proxy_impl_name () << " &proxy = " << be_idt_nl - << "this->the" << intf->base_proxy_broker_name () - << "_->select_proxy (this ACE_ENV_ARG_PARAMETER);" << be_uidt_nl; - - if (!this->void_return_type (bt)) - { - *os << "ACE_CHECK_RETURN ("; - - if (bnt == AST_Decl::NT_enum) - { - // The enum is a unique type, so we must cast. - *os << "(" << bt->name () << ")0);"; - } - else if (bnt == AST_Decl::NT_struct || bnt == AST_Decl::NT_union) + if (bnt == AST_Decl::NT_pre_defined) { - if (bt->size_type () == AST_Type::FIXED) + bpt = be_predefined_type::narrow_from_decl (bt); + pdt = bpt->pt (); + + if (pdt == AST_PredefinedType::PT_longlong) { - // For a fixed size struct or union the return value - // is not a pointer, so we call the default constructor - // and return the result. - *os << bt->name () << " ());"; + *os << "CORBA::LongLong _tao_check_retval = " + << "ACE_CDR_LONGLONG_INITIALIZER;" << be_nl << be_nl; } - else + else if (pdt == AST_PredefinedType::PT_longdouble) { - *os << "0);"; + *os << "CORBA::LongDouble _tao_check_retval = " + << "ACE_CDR_LONG_DOUBLE_INITIALIZER;" << be_nl << be_nl; } } - else if (bnt == AST_Decl::NT_pre_defined) + + // Generate code that retrieves the proper proxy implementation + // using the proxy broker available, and perform the call + // using the proxy implementation provided by the broker. + + *os << intf->base_proxy_impl_name () << " &proxy = " << be_idt_nl + << "this->the" << intf->base_proxy_broker_name () + << "_->select_proxy (this ACE_ENV_ARG_PARAMETER);" << be_uidt_nl; + + if (!this->void_return_type (bt)) { - if (pdt == AST_PredefinedType::PT_longlong - || pdt == AST_PredefinedType::PT_longdouble) + *os << "ACE_CHECK_RETURN ("; + + if (bnt == AST_Decl::NT_enum) { - *os << "_tao_check_retval);" << be_nl - << "ACE_UNUSED_ARG (_tao_check_retval);"; + // The enum is a unique type, so we must cast. + *os << "(" << bt->name () << ")0);"; + } + else if (bnt == AST_Decl::NT_struct || bnt == AST_Decl::NT_union) + { + if (bt->size_type () == AST_Type::FIXED) + { + // For a fixed size struct or union the return value + // is not a pointer, so we call the default constructor + // and return the result. + *os << bt->name () << " ());"; + } + else + { + *os << "0);"; + } + } + else if (bnt == AST_Decl::NT_pre_defined) + { + if (pdt == AST_PredefinedType::PT_longlong + || pdt == AST_PredefinedType::PT_longdouble) + { + *os << "_tao_check_retval);" << be_nl + << "ACE_UNUSED_ARG (_tao_check_retval);"; + } + else + { + *os << "0);"; + } } else { *os << "0);"; } + + *os << be_nl << be_nl + << "return "; } else { - *os << "0);"; + *os << "ACE_CHECK;" << be_nl << be_nl; } - *os << be_nl << be_nl - << "return "; - } - else - { - *os << "ACE_CHECK;" << be_nl << be_nl; - } + *os << "proxy." << node->local_name () + << " (" << be_idt << be_idt_nl << "this"; - *os << "proxy." << node->local_name () - << " (" << be_idt << be_idt_nl << "this"; + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + AST_Decl *d = si.item (); - for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); - !si.is_done (); - si.next ()) - { - AST_Decl *d = si.item (); + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "bad node in this scope\n"), + -1); + } - if (d == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), - -1); - } + be_decl *decl = be_decl::narrow_from_decl (d); - be_decl *decl = be_decl::narrow_from_decl (d); + *os << "," << be_nl + << decl->local_name(); + } - *os << "," << be_nl - << decl->local_name(); - } + if (!be_global->exception_support ()) + { + *os << " ACE_ENV_ARG_PARAMETER"; + } - if (!be_global->exception_support ()) - { - *os << " ACE_ENV_ARG_PARAMETER"; + *os << be_uidt_nl << ");" << be_uidt << be_uidt_nl << "}\n\n"; } - *os << be_uidt_nl << ");" << be_uidt << be_uidt_nl << "}\n\n"; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp index 16c36304b37..b7a7780c60e 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp @@ -10,15 +10,13 @@ ACE_RCSID (be_visitor_operation, be_visitor_operation_remote_proxy_impl_cs:: be_visitor_operation_remote_proxy_impl_cs (be_visitor_context *ctx) - : be_visitor_operation (ctx), - operation_name_ (0) + : be_visitor_operation (ctx) { } be_visitor_operation_remote_proxy_impl_cs:: ~be_visitor_operation_remote_proxy_impl_cs (void) { - delete [] operation_name_; } // Processing to be done after every element in the scope is processed. @@ -102,160 +100,9 @@ be_visitor_operation_remote_proxy_impl_cs::visit_operation ( -1); } - // Generate the actual code for the stub. However, if any of the argument - // types is "native", we flag a MARSHAL exception. - // last argument - is always ACE_ENV_ARG_PARAMETER - *os << "{" << be_idt_nl; - *os << this->gen_environment_var () << "\n"; - - // Generate any pre stub info if and only if none of our parameters is of - // the native type. - if (!node->has_native ()) - { - // native type does not exist. - - // Generate any "pre" stub information such as tables or declarations - // This is a template method and the actual work will be done by the - // derived class - if (this->gen_pre_stub_info (node) == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "gen_pre_stub_info failed\n" - ), - -1 - ); - } - } - - // Declare return type. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS); - be_visitor_operation_rettype_vardecl_cs rd_visitor (&ctx); - - if (bt->accept (&rd_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for return var decl failed\n"), - -1); - } - - if (node->has_native ()) // native exists => no stub - { - if (this->gen_raise_exception (bt, - "CORBA::MARSHAL", - "") == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for return var failed\n" - ), - -1 - ); - } - } - else - { - // Generate code that retrieves the underlying stub object and then - // invokes do_static_call on it. - *os << "TAO_Stub *istub = _collocated_tao_target_->_stubobj ();" - << be_nl << be_nl - << "if (istub == 0)" << be_idt_nl - << "{" << be_idt_nl; - - // If the stub object was bad, then we raise a system exception. - if (this->gen_raise_exception (bt, "CORBA::INTERNAL", "") == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for checking exception failed\n" - ), - -1 - ); - } - - *os << be_uidt; - - os->indent (); - - *os << "}" << be_uidt_nl << be_nl; - - // Do any pre marshal and invoke processing with return type. This - // includes allocating memory, initialization. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_PRE_INVOKE_CS); - be_visitor_operation_rettype_pre_invoke_cs rpi_visitor (&ctx); - - if (bt->accept (&rpi_visitor) == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for retval pre invoke failed\n" - ), - -1 - ); - } - - // Do any pre marshal and invoke stuff with arguments. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS); - be_visitor_operation_argument api_visitor (&ctx); - - if (node->accept (&api_visitor) == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for argument pre invoke failed\n" - ), - -1 - ); - } - - // Generate the code for marshaling in the parameters and transmitting - // them. - if (this->gen_marshal_and_invoke (node, bt) == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for marshal and invoke failed\n" - ), - -1 - ); - - } - - if (!this->void_return_type (bt)) - { - // Now generate the normal successful return statement. - if (bt->size_type () == AST_Type::VARIABLE - || bt->base_node_type () == AST_Decl::NT_array) - { - *os << "return _tao_retval._retn ();"; - } - else - { - *os << "return _tao_retval;"; - } - } - } // end of if (!native) - - *os << be_uidt_nl << "}\n\n"; - - return 0; + // Generate the code for the operation body. + return this->gen_stub_operation_body (node, + bt); } int @@ -298,757 +145,3 @@ be_visitor_operation_remote_proxy_impl_cs::visit_argument (be_argument *node) return 0; } -int -be_visitor_operation_remote_proxy_impl_cs::gen_pre_stub_info ( - be_operation *node - ) -{ - - // Check if this operation raises any exceptions. In that case, we must - // generate a list of exception typecodes. This is not valid for - // attributes. - if (!this->ctx_->attribute ()) - { - be_visitor_context ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); - be_visitor_operation_exceptlist_cs visitor (&ctx); - - if (node->accept (&visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_visitor_operation_cs::" - "gen_pre_stub_info - " - "Exceptionlist generation error\n"), - -1); - } - } - - return 0; -} - -int -be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( - be_operation *node, - be_type *bt - ) -{ - TAO_OutStream *os = this->ctx_->stream (); - be_visitor_context ctx; - - os->indent (); - - *os << be_nl; - - // Create the GIOP_Invocation and grab the outgoing CDR stream. - switch (node->flags ()) - { - case AST_Operation::OP_oneway: - *os << "TAO_GIOP_Oneway_Invocation _tao_call "; - break; - default: - *os << "TAO_GIOP_Twoway_Invocation _tao_call "; - } - - // Do we have "_set_" or "_get_" prepended? - size_t ext = this->ctx_->attribute () ? 5 : 0; - - // Do we have any arguments in the operation that needs marshalling - int flag = - node->count_arguments_with_direction (AST_Argument::dir_IN - | AST_Argument::dir_INOUT); - - *os << "(" << be_idt << be_idt_nl - << "istub," << be_nl - << this->compute_operation_name (node) - << "," << be_nl - << ACE_OS::strlen (node->original_local_name ()->get_string ()) + ext - << "," << be_nl - << flag - << "," <<be_nl - << "istub->orb_core ()" << be_uidt_nl - << ");" << be_uidt_nl; - - *os << be_nl - << "int _invoke_status;" << be_nl; - - // Generate code to obtain the client request interceptors from the - // ORB. - *os << "\n#if (TAO_HAS_INTERCEPTORS == 1)" << be_nl; - *os << "TAO_ClientRequestInterceptor_Adapter _tao_vfr (" - << be_idt << be_idt_nl - << "istub->orb_core ()->client_request_interceptors ()," << be_nl - << "&_tao_call," << be_nl - << "_invoke_status" - << be_uidt_nl - << ");" << be_uidt_nl; - - *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; - - // The connection retry loop. - *os << be_nl - << "for (;;)" << be_idt_nl - << "{" << be_idt_nl - << "_invoke_status = TAO_INVOKE_EXCEPTION;" << be_nl; - - - *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; - - *os << "TAO_ClientRequestInfo_" << node->flat_name (); - - // We need the interface node in which this operation was defined. However, - // if this operation node was an attribute node in disguise, we get this - // information from the context and add a "_get"/"_set" to the flat - // name to get around the problem of overloaded methods which are - // generated for attributes. - if (this->ctx_->attribute ()) - { - bt = be_type::narrow_from_decl (node->return_type ()); - - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interceptors_ch::" - "visit_operation - " - "Bad return type\n"), - -1); - } - - // Grab the right visitor to generate the return type if its not - // void it means it is not the accessor. - if (!this->void_return_type (bt)) - { - *os << "_get"; - } - else - { - *os << "_set"; - } - } - - *os << " _tao_ri (" << be_idt << be_idt_nl - << "&_tao_call," << be_nl - << "_collocated_tao_target_"; - - // Generate the formal argument fields which are passed - // to the RequestInfo object. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS); - be_visitor_operation_interceptors_arglist iia_visitor (&ctx); - - if (node->accept (&iia_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for arglist failed\n"), - -1); - } - - *os << be_uidt_nl << ");" << be_uidt_nl; - - if (this->gen_check_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; - - // Prepare the request header. - *os << be_nl << "CORBA::Short _tao_response_flag = "; - - switch (node->flags ()) - { - case AST_Operation::OP_oneway: - *os << "_tao_call.sync_scope ();" << be_nl - << "TAO_INTERCEPTOR (_tao_ri.response_expected (0));" << be_nl; - break; - default: - *os << "TAO_TWOWAY_RESPONSE_FLAG;" << be_nl - << "TAO_INTERCEPTOR (_tao_ri.response_expected (1));" << be_nl; - } - - *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; - - *os << be_nl << "ACE_TRY" << be_idt_nl - << "{" << be_idt_nl; - - // Invoke send_request() interception point. - // This is done before the Invocation::start() call so that a - // connection can be avoided if send_request() throws an exception, - // i.e. this is an optimization. - *os << "_tao_vfr.send_request (" << be_idt << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt_nl - << "ACE_TRY_CHECK;" << be_nl; - - // _invoke_status is potentially set (via a reference) in - // TAO_ClientRequestInterceptor_Adapter::send_request() so check its - // value. If a location forward or transport retry occured, then we - // need to restart the loop so that the ClientRequestInfo object is - // setup for the re-issued request. - // - // Note that since we're invoking the send_request() interception - // point before the Invocation::start() call, i.e. before a - // connection is ever made, we're actually able to forward requests - // for oneways via the PortableInterceptor::ForwardRequest exception - // too! - *os << be_nl - << "if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl - << "{" << be_idt_nl - << "_tao_call.restart_flag (1);" << be_nl - << "continue;" << be_uidt_nl - << "}" << be_uidt_nl; - - *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; - - - *os << be_nl - << "_tao_call.start (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_nl; - - // Check if there is an exception. - if (this->gen_check_interceptor_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - *os << be_nl - << "_tao_call.prepare_header (" << be_idt << be_idt_nl - << "ACE_static_cast (CORBA::Octet, _tao_response_flag)" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt_nl; - - // Check if there is an exception. - if (this->gen_check_interceptor_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - // Now make sure that we have some in and inout parameters. Otherwise, there - // is nothing to be marshaled in. - if (this->has_param_type (node, AST_Argument::dir_IN) || - this->has_param_type (node, AST_Argument::dir_INOUT)) - { - *os << be_nl - << "TAO_OutputCDR &_tao_out = _tao_call.out_stream ();" - << be_nl << be_nl - << "if (!(" << be_idt << be_idt_nl; - - // Marshal each in and inout argument. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - be_visitor_operation_argument_invoke oai_visitor (&ctx); - - if (node->accept (&oai_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for return var in " - "do_static_call failed\n"), - -1); - } - - *os << be_nl - << "))" << be_uidt_nl - << "{" << be_idt_nl; - - // If marshaling fails, raise exception. - if (this->gen_raise_interceptor_exception (bt, "CORBA::MARSHAL", "") - == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and invoke - " - "codegen for return var failed\n"), - -1); - } - - *os << be_uidt_nl << be_nl; - *os << "}" << be_uidt_nl << be_nl; - } - else - { - *os << be_nl << be_nl; - } - - *os << "_invoke_status =" << be_idt_nl; - - if (node->flags () == AST_Operation::OP_oneway) - { - // Oneway operation. - *os << "_tao_call.invoke (ACE_ENV_SINGLE_ARG_PARAMETER);"; - } - else - { - if (node->exceptions ()) - { - *os << "_tao_call.invoke (_tao_" << node->flat_name () - << "_exceptiondata, " - << node->exceptions ()->length () - << " ACE_ENV_ARG_PARAMETER);"; - } - else - { - *os << "_tao_call.invoke (0, 0 ACE_ENV_ARG_PARAMETER);"; - } - } - - *os << be_uidt_nl; - - // Check if there is an exception. - if (this->gen_check_interceptor_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - *os << be_nl - << "if (_invoke_status == TAO_INVOKE_EXCEPTION)" << be_idt_nl - << "{" << be_idt_nl; - - // Unlisted user exception received by client. - int status = this->gen_raise_interceptor_exception ( - bt, - "CORBA::UNKNOWN", - "TAO_OMG_VMCID | 1, CORBA::COMPLETED_YES" - ); - - if (status == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and invoke - " - "codegen for return var failed\n"), - -1); - } - - *os << be_uidt_nl << "}" << be_uidt_nl; - - // Note that we no longer turn this code generation off if it's a - // one way operation since the sync scope policy may actually allow - // things such as LOCATION_FORWARD replies to be propagated back to - // the client (e.g. SYNC_WITH_TARGET). - *os << "else if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl - << "{" << be_idt_nl - << "TAO_INTERCEPTOR (" << be_idt << be_idt_nl - << "_tao_ri.reply_status (_invoke_status);" << be_nl - << "_tao_vfr.receive_other (" << be_idt << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt_nl - << "ACE_TRY_CHECK;" << be_uidt_nl - << ")" << be_uidt_nl - << be_nl - << "continue;" << be_uidt_nl - << "}" << be_uidt_nl - << be_nl; - - // If we reach here, we are ready to proceed. - // the code below this is for twoway operations only. - - if (!this->void_return_type (bt) - || this->has_param_type (node, AST_Argument::dir_INOUT) - || this->has_param_type (node, AST_Argument::dir_OUT)) - - { - // Do any post_invoke stuff that might be necessary. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - be_visitor_operation_argument oapi_visitor (&ctx); - - if (node->accept (&oapi_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for args in post do_static_call\n"), - -1); - } - - // Generate any temporary variables to demarshal the arguments. - be_visitor_args_decl vis1 (&ctx); - - if (node->accept (&vis1) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_pre_stub_info - " - "codegen for pre args failed\n"), - -1); - } - - if (!this->void_return_type (bt)) - { - // Generate any temporary variables to demarshal the return value. - be_visitor_operation_rettype_post_invoke_cs vis2 (&ctx); - - if (bt->accept (&vis2) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_pre_stub_info - " - "codegen rettype [post invoke] failed\n"), - -1); - } - } - - // Check if there was a user exception, else demarshal the - // return val (if any) and parameters (if any) that came with - // the response message. - *os << be_nl - << "TAO_InputCDR &_tao_in = _tao_call.inp_stream ();" - << be_nl << be_nl - << "if (!(" << be_idt << be_idt_nl; - - if (!this->void_return_type (bt)) - { - // Demarshal the return value. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - be_visitor_operation_rettype_marshal_ss ori_visitor (&ctx); - - if (node->accept (&ori_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for return var failed\n"), - -1); - } - } - - if (this->has_param_type (node, AST_Argument::dir_INOUT) - || this->has_param_type (node, AST_Argument::dir_OUT)) - { - if (!this->void_return_type (bt)) - { - *os << " &&" << be_nl; - } - - // Demarshal each out and inout argument. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - be_visitor_operation_argument_invoke oai_visitor (&ctx); - - if (node->accept (&oai_visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for return var failed\n"), - -1); - } - } - - *os << be_nl - << "))" << be_uidt_nl - << "{" << be_idt_nl; - - // If marshaling fails, raise exception. - int status = this->gen_raise_interceptor_exception ( - bt, - "CORBA::MARSHAL", - "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES" - ); - - if (status == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and invoke - " - "codegen for return var failed\n"), - -1); - } - - *os << be_uidt_nl << "}" << be_uidt_nl; - } - - *os << "\n#if TAO_HAS_INTERCEPTORS == 1" << be_nl; - - // Populate the ClientRequestInfo object with result, if any, of the - // invocation. - if (!this->void_return_type (bt)) - { - // Here's what we are going to do to have a uniform way of getting the - // return value updated for the Request Info: - // declare a operation_retval type object and assign the - // _tao_retval._retn () to it. - // We pass this to the result updation method (note: it hasnt - // got destroyed) - // We then put it back into the original _tao_retval - // object. - // And finally the _retn () is returned from the operation w.o - // causing any problems. - - // Generate the return type mapping (same as in the header file) - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor_operation_rettype oro_visitor (&ctx); - - if (bt->accept (&oro_visitor) == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for return type failed\n" - ), - -1 - ); - } - - if (bt->size_type () == AST_Type::VARIABLE - || bt->base_node_type () == AST_Decl::NT_array) - { - *os << " _tao_retval_info =" << be_idt_nl - << "_tao_retval._retn ();" << be_uidt_nl - << "_tao_ri.result (_tao_retval_info);" << be_nl - << "_tao_retval = _tao_retval_info;" << be_nl; - } - else - { - *os << " _tao_retval_info =" << be_idt_nl - << "_tao_retval;" << be_uidt_nl - << "_tao_ri.result (_tao_retval_info);" << be_nl; - } - } - - // Oneway operations don't have receive_reply() interception since - // once the request goes over the wire, its the end of the story! - // However, we still need to call an ending interception point - // (receive_other()) to satisfy the General Flow Rules. - if (node->flags () != AST_Operation::OP_oneway) - { - // If we get this far (in the generated code) then we - // successfully completed the request, i.e. no connection retry - // will occur, nor will a LOCATION_FORWARD. - // Invoke receive_reply() interception point. - *os << be_nl - << "_tao_ri.reply_status (_invoke_status);" << be_nl - << "_tao_vfr.receive_reply (" << be_idt << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt_nl; - } - else if (node->flags () == AST_Operation::OP_oneway) - { - // Invoke receive_other() interception point. - *os << be_nl - << "_tao_ri.reply_status (_invoke_status);" << be_nl - << "_tao_vfr.receive_other (" << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_nl; - } - - *os << "ACE_TRY_CHECK;" - << be_uidt_nl - << "}" << be_uidt_nl; - - // Note that we do NOT catch the PortableInterceptor::ForwardRequest - // exception here. It is caught in the - // TAO_ClientRequestInterceptor_Adapter class. This is necessary to - // prevent applications from being able to throw the exception in an - // effort to get an easy (but illegal) way to forward a request. - - *os << "ACE_CATCHANY" << be_idt_nl - << "{" << be_idt_nl; - - // Update the exception field of the ClientRequestInfo. - *os << "_tao_ri.exception (&ACE_ANY_EXCEPTION);"<< be_nl; - - *os << "_tao_vfr.receive_exception (" << be_idt << be_idt_nl - << "&_tao_ri" << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_uidt_nl - << "ACE_TRY_CHECK;" << be_nl; - - // The receive_exception() interception point may have thrown a - // PortableInterceptor::ForwardRequest exception. In that event, - // the connection retry loop must be restarted so do not rethrow the - // caught exception. - *os << be_nl - << "PortableInterceptor::ReplyStatus _tao_status =" << be_idt_nl - << "_tao_ri.reply_status (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl - << "ACE_TRY_CHECK;" << be_nl; - - *os << be_nl - << "if (_tao_status == PortableInterceptor::SYSTEM_EXCEPTION" << be_nl - << " || _tao_status == PortableInterceptor::USER_EXCEPTION)" - << be_idt_nl - << "{" << be_idt_nl; - - if (be_global->use_raw_throw ()) - { - *os << "throw;"; - } - else - { - *os << "ACE_RE_THROW;"; - } - - *os << be_uidt_nl - << "}" << be_uidt << be_uidt_nl; - - *os << "}" << be_uidt_nl - << "ACE_ENDTRY;" << be_nl; - - if (this->gen_check_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - // The receive_exception() or receive_other() interception point may - // have thrown a PortableInterceptor::ForwardRequest exception. In - // that event, the connection retry loop must be restarted. Note - // that the _invoke_status variable is not set by the interceptor - // support code, so we must explicitly check the status in the - // ClientRequestInfo object. - *os << be_nl - << "PortableInterceptor::ReplyStatus _tao_status =" << be_idt_nl - << "_tao_ri.reply_status (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl; - - if (this->gen_check_exception (bt) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" - "gen_marshal_and_invoke - " - "codegen for checking exception failed\n"), - -1); - } - - *os << be_nl - << "if (_tao_status == PortableInterceptor::LOCATION_FORWARD" << be_nl - << " || _tao_status == PortableInterceptor::TRANSPORT_RETRY)" - << be_idt_nl - << "{" << be_idt_nl - << "continue;" << be_uidt_nl - << "}" << be_uidt_nl; - - *os << "\n#endif /* TAO_HAS_INTERCEPTORS */" << be_nl; - - *os << be_nl << "break;" << be_uidt_nl - << "}" << be_uidt_nl << be_nl; - - return 0; -} - -int -be_visitor_operation_remote_proxy_impl_cs::gen_raise_interceptor_exception ( - be_type *bt, - const char *excep, - const char *completion_status - ) -{ - TAO_OutStream *os = this->ctx_->stream (); - - if (this->void_return_type (bt)) - { - if (be_global->use_raw_throw ()) - { - *os << "throw " << excep << "(" << completion_status << ");"; - } - else - { - *os << "TAO_INTERCEPTOR_THROW (" << be_idt << be_idt_nl - << excep << " (" << be_idt << be_idt_nl - << completion_status << be_uidt_nl - << ")" << be_uidt << be_uidt_nl - << ");" << be_uidt; - } - } - else - { - if (bt->size_type () == AST_Type::VARIABLE - || bt->base_node_type () == AST_Decl::NT_array) - { - *os << "TAO_INTERCEPTOR_THROW_RETURN (" << be_idt << be_idt_nl - << excep << " (" << be_idt << be_idt_nl - << completion_status << be_uidt_nl - << ")," << be_uidt_nl - << "0" << be_uidt_nl - << ");" << be_uidt; - } - else - { - *os << "TAO_INTERCEPTOR_THROW_RETURN (" << be_idt << be_idt_nl - << excep << " (" << be_idt << be_idt_nl - << completion_status << be_uidt_nl - << ")," << be_uidt_nl - << "_tao_retval" << be_uidt_nl - << ");" << be_uidt; - } - } - - return 0; -} - -const char* -be_visitor_operation_remote_proxy_impl_cs::compute_operation_name ( - be_operation *node - ) -{ - if (this->operation_name_ == 0) - { - // Length for two double quotes and the null termination char. - size_t len = 3; - - if (this->ctx_->attribute ()) - { - // "Added length for "_set_" or "_get_". - len += 5; - } - - len += ACE_OS::strlen (node->original_local_name ()->get_string ()); - - ACE_NEW_RETURN (this->operation_name_, - char [len], - 0); - - ACE_OS::strcpy (this->operation_name_, "\""); - - if (this->ctx_->attribute ()) - { - // Now check if we are a "get" or "set" operation. - if (node->nmembers () == 1) - { - ACE_OS::strcat (this->operation_name_, "_set_"); - } - else - { - ACE_OS::strcat (this->operation_name_, "_get_"); - } - } - - ACE_OS::strcat (this->operation_name_, - node->original_local_name ()->get_string ()); - ACE_OS::strcat (this->operation_name_, "\""); - } - - return this->operation_name_; -} diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_ch.cpp index 922eb6971ac..69cf3eb4a34 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_ch.cpp @@ -65,7 +65,7 @@ be_visitor_valuetype_any_op_ch::visit_valuetype (be_valuetype *node) *os << be_global->stub_export_macro () << " CORBA::Boolean" << " operator>>= (const CORBA::Any &, " - << node->name () << " *&);\n"; + << node->name () << " *&);" << be_nl; node->cli_hdr_any_op_gen (1); diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_cs.cpp index 8955c59e853..82dff9db21f 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/any_op_cs.cpp @@ -41,37 +41,47 @@ be_visitor_valuetype_any_op_cs::~be_visitor_valuetype_any_op_cs (void) int be_visitor_valuetype_any_op_cs::visit_valuetype (be_valuetype *node) { - if (node->cli_stub_any_op_gen () || node->imported ()) + if (node->cli_stub_any_op_gen () + || node->imported () + || node->is_local ()) { return 0; } TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - // Generate the Any <<= and >>= operator declarations - *os << be_global->stub_export_macro () << " void" << be_nl - << "operator<<= (CORBA::Any &any, " << node->name () - << " *value) // copying" << be_nl + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Copying." << be_nl + << "void" << be_nl + << "operator<<= (" << be_idt << be_idt_nl + << "CORBA::Any &any," << be_nl + << node->name () << " *value" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl - << "TAO_OutputCDR stream;" << be_nl - << "if (stream << value)" << be_nl + << "TAO_OutputCDR stream;" << be_nl << be_nl + << "if (stream << value)" << be_idt_nl << "{" << be_idt_nl << "any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << ", " << be_nl << "TAO_ENCAP_BYTE_ORDER," << be_nl - << "stream.begin ());" << be_uidt << be_uidt << be_uidt_nl - << "}" << be_uidt_nl + << "stream.begin ()" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt << be_uidt_nl << "}" << be_nl << be_nl; - *os << be_global->stub_export_macro () << " void" << be_nl - << "operator<<= (CORBA::Any &any, " << node->name () - << " **value) // non-copying" << be_nl + *os << "// Non-copying." << be_nl + << "void" << be_nl + << "operator<<= (" << be_idt << be_idt_nl + << "CORBA::Any &any," << be_nl + << node->name ()<< " **value" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl - << "TAO_OutputCDR stream;" << be_nl - << "if (stream << *value)" << be_nl + << "TAO_OutputCDR stream;" << be_nl << be_nl + << "if (stream << *value)" << be_idt_nl << "{" << be_idt_nl << "any._tao_replace (" << be_idt << be_idt_nl << node->tc_name () << ", " << be_nl @@ -79,56 +89,65 @@ be_visitor_valuetype_any_op_cs::visit_valuetype (be_valuetype *node) << "stream.begin ()," << be_nl << "1," << be_nl << "*value," << be_nl - << node->name () << "::_tao_any_destructor);" - << be_uidt << be_uidt << be_uidt_nl - << "}" << be_uidt_nl + << node->name () << "::_tao_any_destructor" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "}" << be_uidt << be_uidt_nl << "}" << be_nl << be_nl; - *os << be_global->stub_export_macro () << " CORBA::Boolean" << be_nl - << "operator>>= (const CORBA::Any &any, " - << node->name () << " *&value)" << be_nl + *os << "CORBA::Boolean" << be_nl + << "operator>>= (" << be_idt << be_idt_nl + << "const CORBA::Any &any," << be_nl + << node->name () << " *&value" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl << "ACE_TRY_NEW_ENV" << be_nl << "{" << be_idt_nl << "value = 0;" << be_nl - << "CORBA::TypeCode_var type = any.type ();" << be_nl << be_nl - << "CORBA::Boolean result = type->equivalent (" << node->tc_name () - << " ACE_ENV_ARG_PARAMETER);" << be_nl + << "CORBA::TypeCode_var type = any.type ();" << be_nl + << "CORBA::Boolean result =" << be_idt_nl + << "type->equivalent (" << be_idt << be_idt_nl + << node->tc_name () << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl << "ACE_TRY_CHECK;" << be_nl << be_nl - << "if (!result)" << be_nl + << "if (!result)" << be_idt_nl << "{" << be_idt_nl << "return 0; // not equivalent" << be_uidt_nl - << "}" << be_nl - << "if (any.any_owns_data ())" << be_nl + << "}" << be_uidt_nl << be_nl + << "if (any.any_owns_data ())" << be_idt_nl << "{" << be_idt_nl - << "const " << node->name () << " *const_holder = " + << "const " << node->name () << " *const_holder =" << be_idt_nl << "ACE_static_cast (" << be_idt << be_idt_nl - << "const " << node->name () << "*," << be_nl - << "any.value ());" << be_uidt << be_uidt_nl - << "value = ACE_const_cast (" << be_idt << be_idt_nl - << node->name () << "*," << be_nl - << "const_holder);" << be_uidt << be_uidt_nl + << "const " << node->name () << " *," << be_nl + << "any.value ()" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl + << "value =" << be_idt_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << node->name () << " *," << be_nl + << "const_holder" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl << "return 1;" << be_uidt_nl - << "}" << be_nl - << "else" << be_nl // else any does not own the data + << "}" << be_uidt_nl + << "else" << be_idt_nl // else any does not own the data << "{" << be_idt_nl << node->name () << " *tmp;" << be_nl << "TAO_InputCDR stream (" << be_idt << be_idt_nl << "any._tao_get_cdr ()," << be_nl - << "any._tao_byte_order ());" << be_uidt << be_uidt_nl - << "if (stream >> tmp)" << be_nl + << "any._tao_byte_order ()" << be_uidt_nl + << ");" << be_uidt_nl << be_nl + << "if (stream >> tmp)" << be_idt_nl << "{" << be_idt_nl << "((CORBA::Any *)&any)->_tao_replace (" << be_idt << be_idt_nl << node->tc_name () << "," << be_nl << "1," << be_nl << "ACE_static_cast (void *, tmp)," << be_nl - << node->name () << "::_tao_any_destructor);" << be_uidt << be_uidt_nl + << node->name () << "::_tao_any_destructor" << be_uidt_nl + << ");" << be_uidt_nl << "value = tmp;" << be_nl << "return 1;" << be_uidt_nl - << "}" << be_nl - << be_uidt_nl - << "}" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_uidt << be_uidt_nl << "}" << be_nl << "ACE_CATCHANY" << be_nl << "{" << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_cs.cpp index 2b77fb44e69..597784321ae 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/cdr_op_cs.cpp @@ -66,42 +66,41 @@ be_visitor_valuetype_cdr_op_cs::visit_valuetype (be_valuetype *node) -1); } + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set the sub state as generating code for the output operator. this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_OUTPUT); *os << "CORBA::Boolean" << be_nl - << "operator<< (TAO_OutputCDR &strm, const " - << node->full_name () - << " *_tao_valuetype)" << be_nl + << "operator<< (" << be_idt << be_idt_nl + << "TAO_OutputCDR &strm," << be_nl + << "const " << node->full_name () + << " *_tao_valuetype" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl; - *os << "return CORBA_ValueBase::_tao_marshal (strm," << be_idt_nl - << "ACE_const_cast (" << node->full_name () << "*, _tao_valuetype)," - << be_nl - << "(ptr_arith_t) &" << node->full_name() <<"::_downcast);" - << be_uidt<< be_uidt_nl - << "}\n\n"; + *os << "return" << be_idt_nl + << "CORBA_ValueBase::_tao_marshal (" << be_idt << be_idt_nl + << "strm," << be_nl + << "ACE_const_cast (" << be_idt << be_idt_nl + << node->full_name () << " *," << be_nl + << "_tao_valuetype" << be_uidt_nl + << ")," << be_uidt_nl + << "(ptr_arith_t) &" << node->full_name () <<"::_downcast" + << be_uidt_nl + << ");" << be_uidt << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; *os << "CORBA::Boolean" << be_nl - << "operator>> (TAO_InputCDR &strm, " + << "operator>> (" << be_idt << be_idt_nl + << "TAO_InputCDR &strm," << be_nl << node->full_name () - << " *&_tao_valuetype)" << be_nl + << " *&_tao_valuetype" << be_uidt_nl + << ")" << be_uidt_nl << "{" << be_idt_nl; - *os << "return " << node->full_name() + *os << "return " << node->full_name () << "::_tao_unmarshal (strm, _tao_valuetype);" - -#ifdef obv_marshal_old_version - *os << "CORBA::ValueBase *ptr;" << be_nl - << "int retval = CORBA_ValueBase::_tao_unmarshal (strm," - << be_idt_nl << "ptr, (ptr_arith_t) &" << node->full_name() <<"::_downcast);" - << be_uidt_nl - << "if (retval) {" << be_idt_nl - << "_tao_valuetype = " << node->full_name() << "::_downcast (ptr);" - << be_nl << "if (_tao_valuetype) retval = 1;" - << be_uidt_nl << "}" << be_idt_nl - << "return retval;" -#endif /* obv_marshal_old_version */ - << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; if (!node->is_abstract ()) { diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp index 84247679002..2396ee194fe 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp @@ -94,10 +94,13 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // This is the case of an anonymous array inside a union. + // This is the case of an anonymous array inside a valuetype. be_visitor_context ctx (*this->ctx_); ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CH); @@ -116,7 +119,7 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) // the set method. *os << pre_op () << "void " << ub->local_name () << " (" << "_" << bt->local_name () << ")" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // The get method. *os << pre_op () << "const _" << bt->local_name () << "_slice * " << ub->local_name () @@ -130,8 +133,7 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) // Now use this array as a "type" for the subsequent declarator. // The set method. *os << pre_op () << "void " << ub->local_name () << " (" - << bt->name () << ")" << post_op () << " // set" - << be_nl; + << bt->name () << ")" << post_op () << be_nl; // The get method. *os << pre_op() << bt->name () << "_slice *" << ub->local_name () @@ -139,7 +141,7 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) // The get (read/write) method. *os << pre_op () << "const " << bt->name () << "_slice *" << ub->local_name () - << " (void) const" << post_op () << "\n\n"; + << " (void) const" << post_op () << be_nl << be_nl; } return 0; @@ -173,6 +175,9 @@ be_visitor_valuetype_field_ch::visit_enum (be_enum *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { @@ -194,12 +199,10 @@ be_visitor_valuetype_field_ch::visit_enum (be_enum *node) // Now use this enum as a "type" for the subsequent declarator // the set method. *os << pre_op () << "void " << ub->local_name () << " (" - << bt->name () << ")" << post_op () << " // set" - << be_nl; + << bt->name () << ")" << post_op () << be_nl; // The get method. *os << pre_op () << bt->name () << " " << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; return 0; } @@ -232,15 +235,17 @@ be_visitor_valuetype_field_ch::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set method. *os << pre_op() << "void " << ub->local_name () << " (" << bt->name () << "_ptr" - << ")" << post_op() << " // set" << be_nl; + << ")" << post_op() << be_nl; // Get method. *os << pre_op() << bt->name () << "_ptr " << ub->local_name () - << " (void) const" << post_op() << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op() << be_nl << be_nl; return 0; } @@ -273,15 +278,17 @@ be_visitor_valuetype_field_ch::visit_interface_fwd (be_interface_fwd *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << "_ptr" - << ")" << post_op () << " // set" << be_nl; + << ")" << post_op () << be_nl; // Get method. *os << pre_op () << bt->name () << "_ptr " << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; return 0; } @@ -314,15 +321,17 @@ be_visitor_valuetype_field_ch::visit_valuetype (be_valuetype *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << " *" - << ")" << post_op () << " // set" << be_nl; + << ")" << post_op () << be_nl; // Get method. *os << pre_op () << bt->name () << " *" << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; return 0; } @@ -355,15 +364,17 @@ be_visitor_valuetype_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << " *" - << ")" << post_op () << " // set" << be_nl; + << ")" << post_op () << be_nl; // Get method. *os << pre_op () << bt->name () << " *" << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; return 0; } @@ -396,6 +407,9 @@ be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: @@ -403,28 +417,25 @@ be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << "_ptr)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Get method. *os << pre_op () << bt->name () << "_ptr " << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; break; case AST_PredefinedType::PT_any: // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << ")" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Get method (read-only). *os << pre_op () << "const " << bt->name () << " " << ub->local_name () << " (void) const" - << post_op () << " // get method" - << be_nl << be_nl; + << post_op () << be_nl << be_nl; // Get method (read/write). *os << pre_op () << bt->name () << " " << ub->local_name () << " (void)" - << post_op () << " // get method" - << be_nl << be_nl; + << post_op () << be_nl << be_nl; break; case AST_PredefinedType::PT_void: break; @@ -432,11 +443,10 @@ be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << ")" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Get method. *os << pre_op () << bt->name () << " " << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; } return 0; @@ -470,6 +480,9 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Not a typedef and bt is defined here. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) @@ -503,16 +516,15 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) // Set method. *os << pre_op () << "void " << ub->local_name () << " (const " << bt->name () << " &)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Read-only. *os << pre_op () << "const " << bt->name () << " &" << ub->local_name () << " (void) const" - << post_op () << " // get method (read only)" << be_nl; + << post_op () << be_nl; // Read/write. *os << pre_op () << bt->name () << " &" << ub->local_name () << " (void)" - << post_op () << " // get method (read/write only)" - << be_nl << be_nl; + << post_op () << be_nl << be_nl; return 0; } @@ -534,38 +546,39 @@ be_visitor_valuetype_field_ch::visit_string (be_string *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Three methods to set the string value. if (node->width () == (long) sizeof (char)) { *os << pre_op () << "void " << ub->local_name () << " (char *)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; *os << pre_op () << "void " << ub->local_name () << " (const char *)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; *os << pre_op () << "void " << ub->local_name () << " (const CORBA::String_var&)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Get method. *os << pre_op () << "const char *" << ub->local_name () - << " (void) const" << post_op () << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op () << be_nl << be_nl; } else { *os << pre_op () << "void " << ub->local_name () << " (CORBA::WChar *)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; *os << pre_op () << "void " << ub->local_name () << " (const CORBA::WChar *)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; *os << pre_op () << "void " << ub->local_name () << " (const CORBA::WString_var&)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Get method. *os << pre_op() << "const CORBA::WChar *" << ub->local_name () - << " (void) const" << post_op() << " // get method" - << be_nl << be_nl; + << " (void) const" << post_op() << be_nl << be_nl; } return 0; @@ -599,6 +612,9 @@ be_visitor_valuetype_field_ch::visit_structure (be_structure *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Not a typedef and bt is defined here. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) @@ -621,15 +637,14 @@ be_visitor_valuetype_field_ch::visit_structure (be_structure *node) // Set method. *os << pre_op () << "void " << ub->local_name () << " (const " << bt->name () << " &)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Read-only. *os << pre_op () << "const " << bt->name () << " &"; *os << ub->local_name () << " (void) const" - << post_op () << " // get method (read only)" << be_nl + << post_op () << be_nl // Read/write. << pre_op () << bt->name () << " &" << ub->local_name () - << " (void)" << post_op () << " // get method (read/write only)" - << be_nl << be_nl; + << " (void)" << post_op () << be_nl << be_nl; return 0; } @@ -683,6 +698,9 @@ be_visitor_valuetype_field_ch::visit_union (be_union *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Not a typedef and bt is defined here. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) @@ -705,16 +723,14 @@ be_visitor_valuetype_field_ch::visit_union (be_union *node) // Set method. *os << pre_op () << "void " << ub->local_name () << " (const " << bt->name () << " &)" - << post_op () << " // set" << be_nl; + << post_op () << be_nl; // Read-only. *os << pre_op () << "const " << bt->name () << " &" << ub->local_name () << " (void) const" - << post_op () << " // get method (read only)" - << be_nl; + << post_op () << be_nl; // Read/write. *os << pre_op () << bt->name () << " &" << ub->local_name () - << " (void)" << post_op () << " // get method (read/write only)" - << be_nl << be_nl; + << " (void)" << post_op () << be_nl << be_nl; return 0; } @@ -728,13 +744,13 @@ be_visitor_valuetype_field_ch::setenclosings (const char *pre, } const char* -be_visitor_valuetype_field_ch::pre_op () +be_visitor_valuetype_field_ch::pre_op (void) { return pre_op_; } const char* -be_visitor_valuetype_field_ch::post_op () +be_visitor_valuetype_field_ch::post_op (void) { return post_op_; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp index df9181d1f36..f998a709147 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp @@ -150,10 +150,8 @@ be_visitor_valuetype_field_cs::visit_array (be_array *node) bt->full_name ()); } - os->indent (); - - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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; @@ -194,7 +192,7 @@ be_visitor_valuetype_field_cs::visit_array (be_array *node) *os << "return this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << ";" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; return 0; } @@ -227,10 +225,8 @@ be_visitor_valuetype_field_cs::visit_enum (be_enum *node) TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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; @@ -240,16 +236,12 @@ be_visitor_valuetype_field_cs::visit_enum (be_enum *node) *os << "::" << ub->local_name () << " (" << bt->name () << " val)/" << be_nl - << "{\n"; - - os->incr_indent (); + << "{" << be_idt_nl; *os << "this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () - << " = val;\n"; - - os->decr_indent (); + << " = val;" << be_uidt_nl; *os << "}" << be_nl; @@ -261,18 +253,14 @@ be_visitor_valuetype_field_cs::visit_enum (be_enum *node) *os << "::" << ub->local_name () << " () const" << be_nl - << "{\n"; - - os->incr_indent (); + << "{" << be_idt_nl; *os << "return this->" << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix () - << ";\n"; - - os->decr_indent (); + << ";" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; return 0; } @@ -305,10 +293,8 @@ be_visitor_valuetype_field_cs::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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; @@ -318,15 +304,13 @@ be_visitor_valuetype_field_cs::visit_interface (be_interface *node) *os << "::" << ub->local_name () << " (" << bt->name () << "_ptr val)" << be_nl - << "{\n"; - - os->incr_indent (); + << "{" << be_idt_nl; *os << "this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << " = " << bt->name () << "::_duplicate (val);" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_nl << be_nl; *os << "// Retrieve the member." << be_nl << this->pre_op () << bt->name () << "_ptr " << be_nl; @@ -336,18 +320,14 @@ be_visitor_valuetype_field_cs::visit_interface (be_interface *node) *os << "::" << ub->local_name () << " () const" << be_nl - << "{\n"; - - os->incr_indent (); + << "{" << be_idt_nl; *os << "return this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () - << ".ptr ();\n"; - - os->decr_indent (); + << ".ptr ();" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; return 0; } @@ -380,49 +360,41 @@ be_visitor_valuetype_field_cs::visit_interface_fwd (be_interface_fwd *node) TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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); + this->op_name (bu, + os); *os << "::" << ub->local_name () << " (" << bt->name () << "_ptr val)" << be_nl - << "{\n"; - - os->incr_indent (); + << "{" << be_idt_nl; *os << "this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << " = " << bt->name () << "::_duplicate (val);" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_nl << be_nl; *os << "// Retrieve the member" << be_nl << this->pre_op () << bt->name () << "_ptr " << be_nl; - this->op_name (bu, - os); + this->op_name (bu, + os); *os << "::" << ub->local_name () << " () const" << be_nl - << "{\n"; - - os->incr_indent (); + << "{" << be_idt_nl; *os << "return this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () - << ".ptr ();\n"; + << ".ptr ();" << be_uidt_nl; - os->decr_indent (); - - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; return 0; } @@ -455,50 +427,42 @@ be_visitor_valuetype_field_cs::visit_valuetype (be_valuetype *node) TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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); + this->op_name (bu, + os); *os << "::" << ub->local_name () << " (" << bt->name () - << "* val)// set" << be_nl - << "{\n"; - - os->incr_indent (); + << "* val)" << be_nl + << "{" << be_idt_nl; *os << "CORBA::add_ref (val);" << be_nl << "this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << " = val;" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_nl << be_nl; *os << "// Retrieve the member" << be_nl - << this->pre_op () << bt->name () << "* " << be_nl; + << this->pre_op () << bt->name () << " *" << be_nl; - this->op_name (bu, - os); + this->op_name (bu, + os); *os << "::" << ub->local_name () << " () const" << be_nl - << "{\n"; - - os->incr_indent (); + << "{" << be_idt_nl; *os << "return this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () - << ".ptr ();\n"; - - os->decr_indent (); + << ".ptr ();" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; return 0; } @@ -531,51 +495,43 @@ be_visitor_valuetype_field_cs::visit_valuetype_fwd (be_valuetype_fwd *node) TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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); + this->op_name (bu, + os); *os << "::" << ub->local_name () << " (" << bt->name () << "* val)" << be_nl - << "{\n"; - - os->incr_indent (); + << "{" << be_idt_nl; *os << "CORBA::add_ref (val);" << be_nl << "this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << " = val;" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_nl << be_nl; *os << "// Retrieve the member." << be_nl - << this->pre_op () << bt->name () << "* " << be_nl; + << this->pre_op () << bt->name () << " *" << be_nl; - this->op_name (bu, - os); + this->op_name (bu, + os); *os << "::" << ub->local_name () << " () const" << be_nl - << "{\n"; - - os->incr_indent (); + << "{" << be_idt_nl; *os << "return this->" << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () - << ".ptr ();\n"; - - os->decr_indent (); + << ".ptr ();" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; return 0; } @@ -608,10 +564,8 @@ be_visitor_valuetype_field_cs::visit_predefined_type (be_predefined_type *node) TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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; @@ -680,7 +634,7 @@ be_visitor_valuetype_field_cs::visit_predefined_type (be_predefined_type *node) << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; break; case AST_PredefinedType::PT_any: @@ -712,7 +666,7 @@ be_visitor_valuetype_field_cs::visit_predefined_type (be_predefined_type *node) << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; break; case AST_PredefinedType::PT_void: @@ -731,7 +685,7 @@ be_visitor_valuetype_field_cs::visit_predefined_type (be_predefined_type *node) << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; break; } @@ -785,8 +739,8 @@ be_visitor_valuetype_field_cs::visit_sequence (be_sequence *node) } } - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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 @@ -832,7 +786,7 @@ be_visitor_valuetype_field_cs::visit_sequence (be_sequence *node) << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix() << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } @@ -856,13 +810,13 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) // Three methods to set the string value. - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << be_nl << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // (1) Set method from char* or wchar*. os->indent (); - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << this->pre_op () << "void" << be_nl; this->op_name (bu, @@ -884,7 +838,7 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << " = val;" << be_uidt_nl - << "}" << be_nl; + << "}" << be_nl << be_nl; // (2) Set method from const char * or const wchar*. *os << "// Accessor to set the member." << be_nl @@ -903,9 +857,7 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << " (const CORBA::WChar *val)" << be_nl; } - *os << "{\n"; - - os->incr_indent (); + *os << "{" << be_idt_nl; *os << "// Set the value." << be_nl << "this->" @@ -922,7 +874,7 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << "CORBA::wstring_dup (val);" << be_uidt_nl; } - *os << "}" << be_nl; + *os << "}" << be_nl << be_nl; // (3) Set from const String_var&. *os << "// Accessor to set the member." << be_nl @@ -943,7 +895,6 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) } *os << "{" << be_idt_nl; - *os << ";" << be_nl; *os << "// set the value" << be_nl; if (node->width () == (long) sizeof (char)) @@ -961,7 +912,7 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) << bu->field_pd_postfix () << " = " << ub->local_name () << "_var._retn ();" << be_uidt_nl; - *os << "}" << be_nl; + *os << "}" << be_nl << be_nl; if (node->width () == (long) sizeof (char)) { @@ -982,7 +933,7 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } @@ -1033,8 +984,8 @@ be_visitor_valuetype_field_cs::visit_structure (be_structure *node) } } - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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 @@ -1080,7 +1031,7 @@ be_visitor_valuetype_field_cs::visit_structure (be_structure *node) << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << ";" << be_uidt_nl; - *os << "}\n\n"; + *os << "}" << be_nl << be_nl; return 0; } @@ -1150,8 +1101,8 @@ be_visitor_valuetype_field_cs::visit_union (be_union *node) } } - *os << be_nl << "// TAO_IDL - Generated from " - << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << 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; @@ -1195,7 +1146,7 @@ be_visitor_valuetype_field_cs::visit_union (be_union *node) << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () << ";" << be_uidt_nl - << "}\n\n"; + << "}" << be_nl << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp index 61144ba3f60..836c462aeb8 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp @@ -40,6 +40,9 @@ be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) TAO_OutStream *os = this->ctx_->stream (); this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "CORBA::Boolean" << be_nl; this->class_name (node, os); @@ -66,14 +69,20 @@ be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) this->class_name (inh, os); - *os << "::_tao_marshal_state (strm)) return 0;" << be_nl; + *os << "::_tao_marshal_state (strm))" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; } // Can access base class only via virtual function. else { - *os << "if (!this->_tao_marshal__" + *os << "if (! this->_tao_marshal__" << inh->flat_name () - << " (strm)) return 0;" << be_nl; + << " (strm))" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; } } @@ -87,12 +96,16 @@ be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) this->gen_fields (node, *this->ctx_); - *os << be_uidt_nl << ")" - << be_idt_nl + *os << be_uidt_nl + << " )" << be_idt_nl + << "{" << be_idt_nl << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; // Set the substate as generating code for the input operator. this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_INPUT); @@ -121,13 +134,19 @@ be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) this->class_name (inh, os); - *os << "::_tao_unmarshal_state (strm)) return 0;" << be_nl; + *os << "::_tao_unmarshal_state (strm))" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; } else // only can access base class via virtual function { - *os << "if (!this->_tao_unmarshal__" + *os << "if (! this->_tao_unmarshal__" << inh->flat_name () - << " (strm)) return 0;" << be_nl; + << " (strm))" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl; } } @@ -140,12 +159,16 @@ be_visitor_valuetype_marshal_cs::visit_valuetype (be_valuetype *node) this->gen_fields (node, *this->ctx_); - *os << be_uidt_nl << ")" - << be_idt_nl + *os << be_uidt_nl + << " )" << be_idt_nl + << "{" << be_idt_nl << "return 1;" << be_uidt_nl + << "}" << be_uidt_nl << "else" << be_idt_nl - << "return 0;" << be_uidt_nl << be_uidt_nl - << "}\n\n"; + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl + << "}" << be_nl << be_nl; return 0; } @@ -193,6 +216,7 @@ be_visitor_valuetype_marshal_cs::gen_fields (be_valuetype *node, "bad node in this scope\n"), -1); } + be_field *field = be_field::narrow_from_decl (d); if (field) diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp index e47b851459d..73193e5cdda 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp @@ -915,6 +915,7 @@ be_visitor_valuetype::gen_pd (be_valuetype *node) "bad node in this scope\n"), -1); } + be_field *field = be_field::narrow_from_decl (d); if (!field) @@ -971,7 +972,9 @@ be_visitor_valuetype::gen_field_pd (be_field *node) ctx.state (TAO_CodeGen::TAO_FIELD_CH); be_visitor_field_ch visitor (&ctx); - if (bt->accept(&visitor) == -1) + *os << be_nl; + + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -982,8 +985,8 @@ be_visitor_valuetype::gen_field_pd (be_field *node) // Now output the field name. *os << " " << vt->field_pd_prefix () - << node->local_name () - << vt->field_pd_postfix() << ";" << be_nl; + << node->local_name () + << vt->field_pd_postfix () << ";"; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp index 074e721ab65..7359ed3e09b 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp @@ -46,6 +46,7 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) } TAO_OutStream *os = this->ctx_->stream (); + int status = 0; *os << be_nl << "// TAO_IDL - Generated from" << be_nl << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; @@ -149,24 +150,31 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) *os << "public virtual CORBA_ValueBase"; } - int status = - node->traverse_supports_list_graphs ( - be_valuetype::abstract_supports_helper, - os, - I_TRUE - ); - - if (status == -1) + if (node->supports_abstract ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "traversal of supported interfaces failed\n"), - -1); + *os << be_idt; + + status = + node->traverse_supports_list_graphs ( + be_valuetype::abstract_supports_helper, + os, + I_TRUE + ); + + if (status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_valuetype - " + "traversal of supported interfaces failed\n"), + -1); + } + + *os << be_uidt; } // Generate the body. - *os << be_uidt << be_uidt_nl << "{" << be_nl + *os << be_uidt_nl << "{" << be_nl << "public:" << be_idt_nl; // Generate the _var_type typedef. @@ -176,7 +184,7 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) // Generate the static _downcast operation. // (see OMG 20.17.{4,5}). *os << "static " << node->local_name () << "* " - << "_downcast (CORBA::ValueBase* );" << be_nl + << "_downcast (CORBA::ValueBase *);" << be_nl << "// The address of static _downcast is implicit used as type id\n" << be_nl << "// (TAO extensions or internals)" << be_nl @@ -221,16 +229,20 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) -1); } + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__; + // If we inherit from both CORBA::ValueBase and CORBA::AbstractBase, // we have to add this to avoid ambiguity. if (node->supports_abstract ()) { - *os << be_nl << "virtual void _add_ref (void) = 0;" << be_nl; + *os << be_nl << be_nl << "virtual void _add_ref (void) = 0;" << be_nl; + *os << "virtual void _remove_ref (void) = 0;"; } // Generate the "protected" constructor so that users cannot // instantiate us. - *os << be_uidt_nl << "protected:" << be_idt_nl + *os << be_uidt_nl << be_nl << "protected:" << be_idt_nl << node->local_name () << " (void);" << be_nl << "virtual ~" << node->local_name () << " (void);\n" << be_nl; @@ -245,8 +257,6 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << "_tao_marshal_v (TAO_OutputCDR &);" << be_nl; *os << "virtual CORBA::Boolean " << "_tao_unmarshal_v (TAO_InputCDR &);" << be_nl; - // %! optimize _downcast away: extra parameter with type info - // set (void *) in CDR Stream with the right derived pointer. } @@ -282,8 +292,12 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << node->flat_name () << " (TAO_OutputCDR &) = 0;" << be_nl; *os << "virtual CORBA::Boolean _tao_unmarshal__" - << node->flat_name () << " (TAO_InputCDR &) = 0;" - << be_nl; + << node->flat_name () << " (TAO_InputCDR &) = 0;"; + } + + if (node->supports_abstract ()) + { + *os << be_nl << "virtual CORBA::ValueBase *_tao_to_value (void);"; } } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp index 91ee0780aa3..cea7425e0e3 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp @@ -85,30 +85,37 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) -1); } + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // The _downcast method // %! use ACE_xxx_cast here ? - *os << node->name() << "* " << node->name() - << "::_downcast (CORBA::ValueBase* v)" << be_nl - << "{" << be_idt_nl - << "if (v == 0) return 0;" << be_nl - << "return (" << node->local_name() << "* ) " - << "v->_tao_obv_narrow ((ptr_arith_t) &_downcast);" << be_uidt_nl - << "}\n" << be_nl + *os << node->name () << " *" << be_nl << node->name () + << "::_downcast (CORBA::ValueBase *v)" << be_nl + << "{" << be_idt_nl + << "if (v == 0)" << be_idt_nl + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "return (" << node->local_name () << " *) " + << "v->_tao_obv_narrow ((ptr_arith_t) &_downcast);" << be_uidt_nl + << "}" << be_nl << be_nl; // The _tao_obv_repository_id method - << "const char* " << node->name() - << "::_tao_obv_repository_id () const" << be_nl - << "{" << be_idt_nl - << "return this->_tao_obv_static_repository_id ();" << be_uidt_nl - << "}\n" << be_nl + *os << "const char *" << be_nl + << node->name () << "::_tao_obv_repository_id (void) const" << be_nl + << "{" << be_idt_nl + << "return this->_tao_obv_static_repository_id ();" << be_uidt_nl + << "}" << be_nl << be_nl; // The _tao_obv_narrow method - << "void* " << node->name() + *os << "void *" << be_nl << node->name () << "::_tao_obv_narrow (ptr_arith_t type_id)" << be_nl - << "{" << be_idt_nl - << "if (type_id == (ptr_arith_t) &_downcast)" << be_idt_nl - << "return this;" << be_uidt_nl - << "void *rval = 0;" << be_nl; + << "{" << be_idt_nl + << "if (type_id == (ptr_arith_t) &_downcast)" << be_idt_nl + << "{" << be_idt_nl + << "return this;" << be_uidt_nl + << "}" << be_uidt_nl << be_nl + << "void *rval = 0;" << be_nl; // Find the possible base classes. @@ -121,7 +128,9 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) ++n_inherits_downcastable; - *os << "if (rval == 0)" << be_idt_nl + *os << be_nl + << "if (rval == 0)" << be_idt_nl + << "{" << be_idt_nl << "rval = "; AST_Decl::NodeType nt = @@ -142,18 +151,62 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) *os << inherited->name (); } - *os << "::_tao_obv_narrow (type_id);" << be_uidt_nl; + *os << "::_tao_obv_narrow (type_id);" << be_uidt_nl + << "}" << be_uidt_nl; } - *os << "return rval;" << be_uidt_nl - << "}\n\n"; + if (node->supports_abstract ()) + { + long size = node->n_supports (); + AST_Interface *supported = 0; + + for (long i = 0; i < size; ++i) + { + supported = node->supports ()[i]; + + if (supported->is_abstract ()) + { + *os << be_nl + << "if (rval == 0)" << be_idt_nl + << "{" << be_idt_nl + << "rval = "; + + AST_Decl::NodeType supported_nt = + supported->defined_in ()->scope_node_type (); + + if (supported_nt == AST_Decl::NT_module) + { + be_scope *supported_scope = + be_scope::narrow_from_scope (supported->defined_in ()); + be_decl *supported_scope_decl = supported_scope->decl (); + + *os << "ACE_NESTED_CLASS (" + << supported_scope_decl->name () << "," + << supported->local_name () << ")"; + } + else + { + *os << supported->name (); + } + + *os << "::_tao_obv_narrow (type_id);" << be_uidt_nl + << "}" << be_uidt_nl; + } + } + } + + *os << be_nl << "return rval;" << be_uidt_nl + << "}" << be_nl << be_nl; *os << "void" << be_nl << node->name () << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl << "{" << be_idt_nl - << node->local_name () << " *tmp = ACE_static_cast (" - << node->local_name () << "*, _tao_void_pointer);" << be_nl + << node->local_name () << " *tmp =" << be_idt_nl + << "ACE_static_cast (" << be_idt << be_idt_nl + << node->local_name () << " *," << be_nl + << "_tao_void_pointer" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl << "delete tmp;" << be_uidt_nl << "}" << be_nl << be_nl; @@ -229,10 +282,12 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) << "base," << be_nl << node->local_name () << "::_tao_obv_static_repository_id ()" << be_uidt_nl << ");" << be_uidt << be_uidt_nl << be_nl - << "if (retval == 0 || factory.in () == 0)" << be_idt_nl + << "if (retval == 0)" << be_idt_nl << "{" << be_idt_nl << "return 0;" << be_uidt_nl << "}" << be_uidt_nl << be_nl + << "if (factory.in () != 0)" << be_idt_nl + << "{" << be_idt_nl << "base = factory->create_for_unmarshal ();" << be_nl << be_nl << "if (base == 0)" << be_idt_nl << "{" << be_idt_nl @@ -242,12 +297,22 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) << "if (retval == 0)" << be_idt_nl << "{" << be_idt_nl << "return 0;" << be_uidt_nl + << "}" << be_uidt << be_uidt_nl << "}" << be_uidt_nl << be_nl << "// Now base must be null or point to the unmarshaled object." << be_nl << "// Align the pointer to the right subobject." << be_nl << "new_object = " << node->local_name () << "::_downcast (base);" << be_nl << "return retval;" << be_uidt_nl - << "}\n" << be_nl; + << "}" << be_nl << be_nl; + + if (node->supports_abstract ()) + { + *os << "CORBA::ValueBase *" << be_nl + << node->name () << "::_tao_to_value (void)" << be_nl + << "{" << be_idt_nl + << "return this;" << be_uidt_nl + << "}" << be_nl << be_nl; + } // Generate code for the elements of the valuetype. if (this->visit_scope (node) == -1) diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp index c5fbdbe5693..cb507e4ca8b 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp @@ -80,16 +80,13 @@ be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) if (factory_style == FS_CONCRETE_FACTORY) { // Public constructor. - os << node->local_name () << "_init ();" << be_nl; + os << node->local_name () << "_init (void);" << be_nl; } // Virtual destructor. - os << "virtual ~" << node->local_name () << "_init ();" << be_nl; + os << "virtual ~" << node->local_name () << "_init (void);"; - // custom methods - os << be_nl; - if (this->visit_valuetype_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -99,48 +96,45 @@ be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) -1); } - os << be_nl; - // Generate _downcast method. - os << "static " << node->local_name () << "_init* " - << "_downcast (CORBA_ValueFactoryBase* );" << be_nl; + os << be_nl << be_nl + << "static " << node->local_name () << "_init* " + << "_downcast (CORBA_ValueFactoryBase* );"; if (factory_style == FS_CONCRETE_FACTORY) { //@@ Boris: create_for_unmarshal is still public... // generate create_for_unmarshal - os << be_nl - << "virtual CORBA_ValueBase* " - << "create_for_unmarshal" << " " - << "(void);" << be_nl; + os << be_nl << be_nl + << "virtual CORBA::ValueBase *" + << "create_for_unmarshal (void);"; + + if (node->supports_abstract ()) + { + os << be_nl << be_nl + << "virtual CORBA::AbstractBase_ptr " + << "create_for_unmarshal_abstract (void);"; + } } - os << be_nl; + os << be_nl << be_nl; // Proprietary extensions. os << "// TAO-specific extensions" << be_uidt_nl << "public:" << be_idt_nl; - os << "virtual const char* tao_repository_id (void);\n"; + os << "virtual const char* tao_repository_id (void);"; if (factory_style == FS_ABSTRACT_FACTORY) { // Protected constructor. - os << be_uidt_nl + os << be_uidt_nl << be_nl << "protected:" << be_idt_nl; os << node->local_name () << "_init ();"; } os << be_uidt_nl << "};" << be_nl << be_nl; - ACE_CString conc (node->local_name (), - 0, - 0); - - conc += "_init"; - - node->gen_var_defn ((char *) conc.c_str ()); - // Generate the endif macro. os.gen_endif (); diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp index 4dd8506ef4d..670597cad6c 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ci.cpp @@ -38,185 +38,6 @@ be_visitor_valuetype_init_ci::~be_visitor_valuetype_init_ci (void) int be_visitor_valuetype_init_ci::visit_valuetype (be_valuetype *node) { - if (node->is_abstract ()) - { - return 0; - } - - // There are three possible situations. - // (1) If there is no initializers but at least one operation. - // In this case we don't need to bother about factory. - // - // (2) There are no (operations or initializers) (i.e. only state - // members) then we need a concrete type-specific factory - // class whose create_for_unmarshal creates OBV_ class. - // - // (3) There is at least one operation and at least one initializer. - // In this case we need to generate abstract factory class. - - FactoryStyle factory_style = determine_factory_style (node); - - if (factory_style == FS_NO_FACTORY) // nothing to do - { - return 0; // bail out - } - - // Just generate the factory _var impl. - - // To hold the full and local _var names. - char fname [NAMEBUFSIZE]; - char lname [NAMEBUFSIZE]; - - ACE_OS::memset (fname, - '\0', - NAMEBUFSIZE); - - ACE_OS::sprintf (fname, - "%s_init_var", - node->full_name ()); - - ACE_OS::memset (lname, - '\0', - NAMEBUFSIZE); - - ACE_OS::sprintf (lname, - "%s_init_var", - node->local_name ()); - - TAO_OutStream *ci = tao_cg->client_inline (); - - // Generate the var implementation in the stubs file - // Depending upon the data type, there are some differences which we account - // for over here. - - ci->indent (); // start with whatever was our current indent level - - *ci << "// *************************************************************" - << be_nl; - *ci << "// Operations for class " << fname << be_nl; - *ci << "// *************************************************************\n\n"; - - // Default constructor. - *ci << fname << "::" << lname << - " (void) // default constructor" << be_nl; - *ci << " " << ": ptr_ (0)" << be_nl; - *ci << "{}\n\n"; - - // Constructor from a pointer. - ci->indent (); - *ci << fname << "::" << lname << " (" - << node->local_name () << "_init" << "* p)" << be_nl; - *ci << " : ptr_ (p)" << be_nl; - *ci << "{}" << be_nl << be_nl; - - // Constructor from a const pointer. - // TAO extension - it appears that there are problems with at least g++ - // which reclaims amguity between T(T*) and T(const T_var &) - *ci << fname << "::" << lname << " (const " - << node->local_name () << "_init" << "* p)" << be_nl; - *ci << " : ptr_ (ACE_const_cast (" - << node->local_name () << "_init" << "*, p))" << be_nl; - *ci << "{}" << be_nl << be_nl; - - // The additional ptr () member function. This member function must be - // defined before the remaining member functions including the copy - // constructor because this inline function is used elsewhere. Hence to make - // inlining of this function possible, we must define it before its use. - *ci << node->full_name () << "_init" << "* " << be_nl; - *ci << fname << "::ptr (void) const" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "return this->ptr_;" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - // Copy constructor. - *ci << fname << "::" << lname << " (const " << lname << - " &p) // copy constructor" << be_nl; - *ci << "{" << be_idt_nl - << "p.ptr ()->_add_ref ();" << be_nl - << "this->ptr_ = p.ptr ();" << be_uidt_nl - << "}" << be_nl << be_nl; - - // Destructor. - *ci << fname << "::~" << lname << " (void) // destructor" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "this->ptr_->_remove_ref ();" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - // Assignment operator. - *ci << fname << " &" << be_nl; - *ci << fname << "::operator= (" << node->local_name () << "_init" - << "* p)" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "this->ptr_->_remove_ref ();" << be_nl; - *ci << "this->ptr_ = p;" << be_nl; - *ci << "return *this;" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - // Assignment operator from _var. - *ci << fname << " &" << be_nl; - *ci << fname << "::operator= (const " << lname - << " &p)" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "if (this != &p)" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "this->ptr_->_remove_ref ();" << be_nl - << node->local_name () << "_init" << "* tmp = p.ptr ();" << be_nl - << "tmp->_add_ref ();" << be_nl - << "this->ptr_ = tmp;" << be_uidt_nl; - *ci << "}" << be_nl; - *ci << "return *this;" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - // Other extra methods - cast operator (). - *ci << fname << "::operator const " << node->full_name () << "_init" - << "* () const // cast" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "return this->ptr_;" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - *ci << fname << "::operator " << node->full_name () << "_init" - << "* () // cast " << be_nl; - *ci << "{" << be_idt_nl; - *ci << "return this->ptr_;" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - // operator-> - *ci << node->full_name () << "_init" << "* " << be_nl; - *ci << fname << "::operator-> (void) const" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "return this->ptr_;" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - // in, inout, out, and _retn. - *ci << node->full_name () << "_init" << "*" << be_nl; - *ci << fname << "::in (void) const" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "return this->ptr_;" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - *ci << node->full_name () << "_init" << "* &" << be_nl; - *ci << fname << "::inout (void)" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "return this->ptr_;" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - *ci << node->full_name () << "_init" << "* &" << be_nl; - *ci << fname << "::out (void)" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "this->ptr_->_remove_ref ();" << be_nl; - *ci << "this->ptr_ = 0;" << be_nl; - *ci << "return this->ptr_;" << be_uidt_nl; - *ci << "}" << be_nl << be_nl; - - *ci << node->full_name () << "_init" << "* " << be_nl; - *ci << fname << "::_retn (void)" << be_nl; - *ci << "{" << be_idt_nl; - *ci << "// yield ownership of managed obj reference" << be_nl; - *ci << node->local_name () << "_init" << "* tmp = this->ptr_;" << be_nl; - *ci << "this->ptr_ = 0;" << be_nl; - *ci << "return tmp;" << be_uidt_nl; - *ci << "}\n\n"; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp index 7c249596015..bda1a103b02 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_cs.cpp @@ -56,33 +56,40 @@ be_visitor_valuetype_init_cs::visit_valuetype (be_valuetype *node) FactoryStyle factory_style = determine_factory_style (node); - if (factory_style == FS_NO_FACTORY) // nothing to do + if (factory_style == FS_NO_FACTORY) { - return 0; // bail out + return 0; } - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - - os->indent (); // start with whatever indentation level we are at + TAO_OutStream *os = this->ctx_->stream (); char fname [NAMEBUFSIZE]; // to hold the full and char lname [NAMEBUFSIZE]; // local _out names - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_init", node->full_name ()); + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); + ACE_OS::sprintf (fname, + "%s_init", + node->full_name ()); + + ACE_OS::memset (lname, + '\0', + NAMEBUFSIZE); + ACE_OS::sprintf (lname, + "%s_init", + node->local_name ()); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_init", node->local_name ()); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // ctor - *os << fname << "::" << lname << " ()" << be_nl + *os << fname << "::" << lname << " (void)" << be_nl << "{" << be_nl << "}\n"; // dtor *os << be_nl - << fname << "::~" << lname << " ()" << be_nl + << fname << "::~" << lname << " (void)" << be_nl << "{" << be_nl << "}\n"; //tao_repository_id @@ -92,26 +99,44 @@ be_visitor_valuetype_init_cs::visit_valuetype (be_valuetype *node) << "{" << be_idt_nl << "return " << node->full_name () << "::_tao_obv_static_repository_id ();" - << be_uidt_nl << "}\n"; + << be_uidt_nl << "}"; if (factory_style == FS_CONCRETE_FACTORY) { // generate create_for_unmarshal() - *os << be_nl - << "CORBA_ValueBase* " << be_nl + *os << be_nl << be_nl + << "CORBA_ValueBase *" << be_nl << fname << "::create_for_unmarshal" << " " << "(void)" << be_nl << "{" << be_idt_nl - << "CORBA_ValueBase* ret_val = 0;" << be_nl - << "ACE_NEW_RETURN(ret_val, " << be_nl - << " OBV_" << node->full_name () << ", " << be_nl - << " 0);" << be_nl + << "CORBA_ValueBase *ret_val = 0;" << be_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "ret_val," << be_nl + << "OBV_" << node->full_name () << "," << be_nl + << "0" << be_uidt_nl + << ");" << be_uidt_nl << "return ret_val;" - << be_uidt_nl << "}\n"; + << be_uidt_nl << "}"; + + if (node->supports_abstract ()) + { + *os << be_nl << be_nl + << "CORBA::AbstractBase_ptr" << be_nl + << fname << "::create_for_unmarshal_abstract (void)" << be_nl + << "{" << be_idt_nl + << "CORBA_AbstractBase *ret_val = 0;" << be_nl + << "ACE_NEW_RETURN (" << be_idt << be_idt_nl + << "ret_val," << be_nl + << "OBV_" << node->full_name () << "," << be_nl + << "0" << be_uidt_nl + << ");" << be_uidt_nl + << "return ret_val;" + << be_uidt_nl << "}"; + } } - *os << be_nl; + *os << be_nl << be_nl; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp index d347f2c1fce..45e70d1190b 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp @@ -146,10 +146,18 @@ be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node) -1); } + // If we inherit from both CORBA::ValueBase and CORBA::AbstractBase, + // we have to add this to avoid ambiguity. + if (node->supports_abstract ()) + { + *os << "virtual void _add_ref (void);" << be_nl; + *os << "virtual void _remove_ref (void);"; + } + // Map fields to private data. if (!node->opt_accessor ()) { - *os << be_uidt_nl << "protected:" << be_idt_nl; + *os << be_nl << be_uidt_nl << "protected:" << be_idt_nl; *os << "virtual CORBA::Boolean _tao_marshal__" << node->flat_name () << " (TAO_OutputCDR &);" << be_nl; *os << "virtual CORBA::Boolean _tao_unmarshal__" @@ -159,7 +167,7 @@ be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node) << "CORBA::Boolean " << "_tao_unmarshal_state (TAO_InputCDR &);" << be_uidt_nl << be_nl; - *os << "private:" << be_idt_nl; + *os << "private:" << be_idt; this->gen_pd (node); } @@ -187,31 +195,19 @@ be_visitor_valuetype_obv_ch::visit_field (be_field *node) // Only in OBV_ class, if we are not optimizing accessors (and modifiers). if (!vt->opt_accessor ()) { - be_visitor_context* ctx = new be_visitor_context (*this->ctx_); - ctx->state (TAO_CodeGen::TAO_FIELD_OBV_CH); - be_visitor_valuetype_field_ch *visitor = - new be_visitor_valuetype_field_ch (ctx); + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_FIELD_OBV_CH); + be_visitor_valuetype_field_ch visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_obv_ch::" - "visit_field - bad visitor\n"), - -1); - } + visitor.setenclosings ("virtual ",";"); - visitor->setenclosings ("virtual ",";"); - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_obv_ch::" "visit_field - codegen failed\n"), -1); } - - delete visitor; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp index 405d204cb0f..f4d115dfd23 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp @@ -52,37 +52,60 @@ be_visitor_valuetype_obv_cs::visit_valuetype (be_valuetype *node) TAO_OutStream *os = this->ctx_->stream (); + *os << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // OBV_ class has no accessors or modifiers if we are optimizing // or the valuetype is abstract. - if (!(node->opt_accessor () || node->is_abstract ())) + if (!node->opt_accessor ()) { - os->indent (); - - *os << "CORBA::Boolean " << be_nl + *os << "CORBA::Boolean" << be_nl << node->full_obv_skel_name () << "::_tao_marshal__" << node->flat_name () - << " (TAO_OutputCDR &strm)" + << " (TAO_OutputCDR &strm)" << be_nl << "{" << be_idt_nl - << "return _tao_marshal_state (strm);" << be_nl - << be_uidt_nl << "}\n"; + << "return _tao_marshal_state (strm);" << be_uidt_nl + << "}" << be_nl << be_nl; - *os << "CORBA::Boolean " + *os << "CORBA::Boolean" << be_nl << node->full_obv_skel_name () << "::_tao_unmarshal__" << node->flat_name () - << " (TAO_InputCDR &strm)" + << " (TAO_InputCDR &strm)" << be_nl << "{" << be_idt_nl - << "return _tao_unmarshal_state (strm);" << be_nl - << be_uidt_nl << "}\n"; + << "return _tao_unmarshal_state (strm);" << be_uidt_nl + << "}" << be_nl; if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_obv_cs::" "visit_valuetype - " - "visit_scope failed\n" - ), -1); + "visit_scope failed\n"), + -1); + } + + // If we inherit from both CORBA::ValueBase and CORBA::AbstractBase, + // we have to add this to avoid ambiguity. + if (node->supports_abstract ()) + { + *os << be_nl << "void" << be_nl + << node->full_obv_skel_name () + << "::_add_ref (void)" << be_nl + << "{" << be_idt_nl + << "this->CORBA_DefaultValueRefCountBase::_add_ref ();" + << be_uidt_nl + << "}" << be_nl; + + *os << be_nl << "void" << be_nl + << node->full_obv_skel_name () + << "::_remove_ref (void)" << be_nl + << "{" << be_idt_nl + << "this->CORBA_DefaultValueRefCountBase::_remove_ref ();" + << be_uidt_nl + << "}" << be_nl << be_nl; } - } + } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_sh.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_sh.cpp index bfe0fafaa31..54d3bdb0bd5 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_sh.cpp @@ -116,84 +116,20 @@ be_visitor_valuetype_sh::visit_valuetype (be_valuetype *node) << "public:" << be_idt_nl; // No copy constructor for locality constraint interface. - *os << class_name.c_str () << " (const " << class_name.c_str () << "& rhs);" << be_nl - << "virtual ~" << class_name.c_str () << " (void);\n\n" - << be_nl - << "virtual CORBA::Boolean _is_a (" << be_idt << be_idt_nl - << "const char* logical_type_id" << be_nl - << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl - << ");\n" << be_uidt_nl; - - *os << "virtual void* _downcast (" << be_idt << be_idt_nl - << "const char* logical_type_id" << be_uidt_nl - << ");\n" << be_uidt_nl; - - // Add a skeleton for our _is_a method. - *os << "static void _is_a_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *servant_upcall" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ");\n" << be_uidt_nl; - - // Add a skeleton for our _non_existent method. - *os << "static void _non_existent_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *servant_upcall" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ");\n" << be_uidt_nl; - - // Add a skeleton for our _interface method. - *os << "static void _interface_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest &req," << be_nl - << "void *obj," << be_nl - << "void *servant_upcall" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ");\n" << be_uidt_nl; - - // Add the dispatch method. - *os << "virtual void _dispatch (" << be_idt << be_idt_nl - << "TAO_ServerRequest &req," << be_nl - << "void *_servant_upcall" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ");\n" << be_uidt_nl; - - this->this_method (node); + *os << class_name.c_str () << " (const " << class_name.c_str () + << "& rhs);" << be_nl + << "virtual ~" << class_name.c_str () << " (void);" << be_nl << be_nl; + + *os << "::" << node->full_name () << " *_this (" << be_idt << be_idt_nl + << "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ");" << be_uidt_nl << be_nl; // The _interface_repository_id method. - *os << be_nl - << "virtual const char* _interface_repository_id " - << "(void) const;\n\n"; - - // Generate the _skel operations for the concrete interface we support - // and the for its base classes. - int status = - node->traverse_concrete_inheritance_graph (be_valuetype::gen_skel_helper, - os); - if (status == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_sh::" - "visit_valuetype - " - "concrete supported interface " - "inheritance graph traversal failed\n"), - -1); - } + *os << "virtual const char* _interface_repository_id " + << "(void) const;" << be_uidt_nl; - *os << be_uidt << "};\n\n"; + *os << "};\n\n"; return 0; } -void -be_visitor_valuetype_sh::this_method (be_valuetype *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - // Print out the _this() method. - *os << "::" << node->full_name () << " *_this (" << be_idt << be_idt_nl - << "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl - << ");\n" << be_uidt; -} - diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_si.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_si.cpp index e6b4084079d..d878c4f3957 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_si.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_si.cpp @@ -39,36 +39,6 @@ be_visitor_valuetype_si::~be_visitor_valuetype_si (void) int be_visitor_valuetype_si::visit_valuetype (be_valuetype *node) { - if (node->srv_inline_gen () - || node->imported () - || node->is_local () - || node->is_abstract ()) - { - return 0; - } - - // We generate a skeleton class only if the valuetype supports a - // non-abstract interface. - if (node->supports_concrete () == 0) - { - return 0; - } - - TAO_OutStream *os = this->ctx_->stream (); - - // Generate skeletons for operations of the concrete interface that we - // support (if any) and its base classes. - int status = - node->traverse_concrete_inheritance_graph (be_interface::gen_skel_helper, - os); - if (status == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_si::" - "visit_valuetype - " - "codegen for base class skeletons failed\n"), - -1); - } - + // Nothing needed for now, but the visitor is here just in case. return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ss.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ss.cpp index 75be870f6ab..004da7bfd1b 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ss.cpp @@ -18,6 +18,8 @@ // // ============================================================================ +#include "nr_extern.h" + ACE_RCSID (be_visitor_valuetype, valuetype_ss, "$Id$") @@ -69,15 +71,6 @@ be_visitor_valuetype_ss::visit_valuetype (be_valuetype *node) const char *flat_name = flat_name_holder.c_str (); - if (node->gen_operation_table (flat_name, full_skel_name) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ss::" - "visit_valuetype - " - "codegen for operation table failed\n"), - -1); - } - *os << be_nl << "// TAO_IDL - Generated from " << be_nl << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; @@ -98,260 +91,35 @@ be_visitor_valuetype_ss::visit_valuetype (be_valuetype *node) *os << full_skel_name << "::" << local_name_prefix << node_local_name - << " (void)\n"; - - // Generate optable - *os << "{" << be_idt_nl - << "this->optable_ = &tao_" << flat_name - << "_optable;" << be_uidt_nl - << "}\n\n"; + << " (void)" << be_nl + << "{}" << be_nl << be_nl; - // find if we are at the top scope or inside some module *os << full_skel_name << "::" << local_name_prefix << node_local_name << " (" << "const " << local_name_prefix << node_local_name << "& rhs)"; *os << be_idt_nl - << ":"; + << ": "; - if (this->generate_copy_ctor (node, os) == -1) + if (concrete->is_nested ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ss::visit_valuetype - " - " copy ctor generation failed\n"), - -1); - } + AST_Decl *scope = ScopeAsDecl (concrete->defined_in ()); - - - *os << " TAO_ServantBase (rhs)" << be_uidt_nl - << "{}" << be_nl << be_nl; - - *os << full_skel_name << "::~" - << local_name_prefix << node_local_name - << " (void)" << be_nl; - *os << "{" << be_nl; - *os << "}\n\n"; - - *os << "// TAO_IDL - Generated from " << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - - // Generate code for the _is_a skeleton. - os->indent (); - *os << "void " << full_skel_name - << "::_is_a_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest &_tao_server_request, " << be_nl - << "void * _tao_object_reference," << be_nl - << "void * /* Servant_Upcall */" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ")" << be_uidt_nl; - *os << "{" << be_idt_nl; - *os << "TAO_InputCDR &_tao_in = _tao_server_request.incoming ();" << be_nl; - *os << full_skel_name << " *_tao_impl = (" - << full_skel_name << " *) _tao_object_reference;" << be_nl; - *os << "CORBA::Boolean _tao_retval = 0;" << be_nl; - *os << "CORBA::String_var value;" << be_nl; - *os << "if (!(_tao_in >> value.out ()))" << be_idt_nl; - - if (be_global->use_raw_throw ()) - { - *os << "throw CORBA::MARSHAL ();" << be_uidt_nl << be_nl; - } - else - { - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl << be_nl; - } - - *os << "_tao_retval = _tao_impl->_is_a (value.in () ACE_ENV_ARG_PARAMETER);" - << be_nl; - *os << "ACE_CHECK;" << be_nl << be_nl; - *os << "_tao_server_request.init_reply ();" << be_nl; - *os << "TAO_OutputCDR &_tao_out = _tao_server_request.outgoing ();" - << be_nl; - *os << "if (!(_tao_out << CORBA::Any::from_boolean (_tao_retval)))" - << be_idt_nl; - - if (be_global->use_raw_throw ()) - { - *os << "throw CORBA::MARSHAL ();" << be_uidt << be_uidt_nl; + *os << "ACE_NESTED_CLASS (POA_" << scope->name () << ", " + << concrete->local_name () << ") (rhs)"; } else { - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt << be_uidt_nl; - } - - *os << "}" << be_nl << be_nl; - - - // Generate code for the _non_existent skeleton. - *os << "void " << full_skel_name - << "::_non_existent_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest &_tao_server_request, " << be_nl - << "void * _tao_object_reference," << be_nl - << "void * /* Servant_Upcall */" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ")" << be_uidt_nl; - *os << "{" << be_idt_nl; - *os << full_skel_name << " *_tao_impl = (" - << full_skel_name << " *) _tao_object_reference;" << be_nl; - *os << "CORBA::Boolean _tao_retval =" << be_idt_nl - << "_tao_impl->_non_existent (ACE_ENV_SINGLE_ARG_PARAMETER);" - << be_uidt_nl; - *os << "ACE_CHECK;" << be_nl << be_nl; - *os << "_tao_server_request.init_reply ();" << be_nl; - *os << "TAO_OutputCDR &_tao_out = _tao_server_request.outgoing ();" - << be_nl; - *os << "if (!(_tao_out << CORBA::Any::from_boolean (_tao_retval)))" - << be_idt_nl; - - if (be_global->use_raw_throw ()) - { - *os << "throw CORBA::MARSHAL ();" << be_uidt << be_uidt_nl; - } - else - { - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt << be_uidt_nl; - } - - *os << "}\n\n"; - - // Generate code for the _interface skeleton. - *os << "void " << full_skel_name - << "::_interface_skel (" << be_idt << be_idt_nl - << "TAO_ServerRequest &_tao_server_request, " << be_nl - << "void * _tao_object_reference," << be_nl - << "void * /* Servant_Upcall */" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ")" << be_uidt_nl; - *os << "{" << be_idt_nl; - *os << full_skel_name << " *_tao_impl = (" - << full_skel_name << " *) _tao_object_reference;" << be_nl - << "CORBA_InterfaceDef_ptr _tao_retval = 0;" << be_nl - << "CORBA::Boolean _tao_result = 0;" << be_nl << be_nl; - *os << "TAO_IFR_Client_Adapter *_tao_adapter =" << be_idt_nl - << "ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance (" - << be_idt << be_idt_nl - << "TAO_ORB_Core::ifr_client_adapter_name ()" << be_uidt_nl - << ");" << be_uidt_nl << be_uidt_nl; - *os << "if (_tao_adapter == 0)" << be_idt_nl - << "{" << be_idt_nl - << "ACE_THROW (CORBA::INTF_REPOS ());" << be_uidt_nl - << "}" << be_uidt_nl << be_nl; - *os << "ACE_TRY" << be_idt_nl - << "{" << be_idt_nl - << "_tao_retval = " << be_idt_nl - << "_tao_impl->_get_interface (ACE_ENV_SINGLE_ARG_PARAMETER);" - << be_uidt_nl - << "ACE_TRY_CHECK;" << be_nl << be_nl - << "_tao_server_request.init_reply ();" << be_nl << be_nl - << "TAO_OutputCDR &_tao_out = _tao_server_request.outgoing ();" - << be_nl << be_nl - << "_tao_result =" << be_idt_nl - << "_tao_adapter->interfacedef_cdr_insert (" << be_idt << be_idt_nl - << "_tao_out," << be_nl - << "_tao_retval" << be_uidt_nl - << ");" << be_uidt << be_uidt << be_uidt_nl - << "}" << be_uidt_nl - << "ACE_CATCHALL" << be_idt_nl - << "{" << be_idt_nl - << "_tao_adapter->dispose (_tao_retval);" << be_uidt_nl - << "}" << be_uidt_nl - << "ACE_ENDTRY;" << be_nl << be_nl; - *os << "if (_tao_result == 0)" << be_idt_nl - << "{" << be_idt_nl - << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl - << "}" << be_uidt << be_uidt_nl; - *os << "}\n\n"; - - // Generate code for the _is_a override. - os->indent (); - - *os << "CORBA::Boolean " << full_skel_name - << "::_is_a (" << be_idt << be_idt_nl - << "const char* value" << be_nl - << "ACE_ENV_ARG_DECL_NOT_USED" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl - << "if (" << be_idt << be_idt_nl; - - if (node->traverse_inheritance_graph (be_interface::is_a_helper, os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ss::" - "visit_valuetype - " - "traversal of inhertance graph failed\n"), - -1); - } - - *os << "!ACE_OS::strcmp (" << be_idt << be_idt_nl - << "(char *)value," << be_nl - << "\"IDL:org.omg/CORBA/ValueBase:1.0\"" << be_uidt_nl - << ")"; - - *os << be_uidt << be_uidt_nl - << " )" << be_nl - << "{" << be_idt_nl - << "return 1;" << be_uidt_nl - << "}" << be_uidt_nl - << "else" << be_idt_nl - << "{" << be_idt_nl - << "return 0;" << be_uidt_nl - << "}" << be_uidt << be_uidt_nl - << "}" << be_nl << be_nl; - - // the downcast method. - *os << "void* " << full_skel_name - << "::_downcast (" << be_idt << be_idt_nl - << "const char* logical_type_id" << be_uidt_nl - << ")" << be_uidt_nl - << "{" << be_idt_nl; - - if (this->generate_downcast_implementation (node, os) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ss::" - "visit_valuetype - " - "traverse for downcast implementation failed\n"), - -1); + be_interface *bd = be_interface::narrow_from_decl (concrete); + *os << bd->full_skel_name () << " (rhs)"; } - *os << "if (ACE_OS::strcmp (logical_type_id," << be_nl - << " \"IDL:omg.org/CORBA/ValueBase:1.0\") == 0)" - << be_idt_nl - << "{" << be_idt_nl - << "return ACE_static_cast(PortableServer::Servant, this);" - << be_uidt_nl - << "}" << be_uidt_nl << be_nl; - - *os << "return 0;" << be_uidt_nl - << "}" << be_nl << be_nl; - - *os << "const char* " << full_skel_name - << "::_interface_repository_id (void) const" - << be_nl; - *os << "{" << be_idt_nl; - *os << "return \"" << node->repoID () << "\";" << be_uidt_nl; - *os << "}" << be_nl << be_nl; - - // Print out dispatch method. - this->dispatch_method (node); - - *os << be_nl; - - this->this_method (node); - - *os << "\n\n"; - - return 0; -} - -void -be_visitor_valuetype_ss::this_method (be_valuetype *node) -{ - TAO_OutStream *os = this->ctx_->stream (); + *os << be_uidt_nl << "{}" << be_nl << be_nl; - *os << "// TAO_IDL - Generated from" << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << full_skel_name << "::~" + << local_name_prefix << node_local_name + << " (void)" << be_nl + << "{}" << be_nl << be_nl; // the _this () operation. *os << node->full_name () << " *" << be_nl @@ -393,49 +161,27 @@ be_visitor_valuetype_ss::this_method (be_valuetype *node) *os << "CORBA::Object_var obj = tmp;" << be_nl << "(void) safe_stub.release ();" << be_nl - << "return " << "::" << node->full_name () - << "::_unchecked_narrow (obj.in ());" - << be_uidt_nl - << "}" << be_nl; -} + << "return "; -void -be_visitor_valuetype_ss::dispatch_method (be_valuetype *node) -{ - TAO_OutStream *os = this->ctx_->stream (); - - *os << "// TAO_IDL - Generated from" << be_nl - << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + if (concrete->is_nested ()) + { + UTL_Scope *parent_scope = concrete->defined_in (); + AST_Decl *parent_decl = ScopeAsDecl (parent_scope); - *os << "void " << node->full_skel_name () - << "::_dispatch (" << be_idt << be_idt_nl - << "TAO_ServerRequest &req," << be_nl - << "void *servant_upcall" << be_nl - << "ACE_ENV_ARG_DECL" << be_uidt_nl - << ")" << be_uidt_nl; - *os << "{" << be_idt_nl; - *os << "this->synchronous_upcall_dispatch (req," << be_nl - << " servant_upcall," << be_nl - << " this" << be_nl - << " ACE_ENV_ARG_PARAMETER);" - << be_uidt_nl; - *os << "}" << be_nl; -} + *os << "ACE_NESTED_CLASS (" + << parent_decl->name () << ", " + << concrete->local_name (); + } + else + { + *os << concrete->name (); + } -int -be_visitor_valuetype_ss::generate_downcast_implementation (be_valuetype *node, - TAO_OutStream *os) -{ - return node->traverse_inheritance_graph (be_interface::downcast_helper, - os); -} + *os << "::_unchecked_narrow (obj.in ());" + << be_uidt_nl + << "}" << be_nl << be_nl; -int -be_visitor_valuetype_ss::generate_copy_ctor (be_valuetype *node, - TAO_OutStream *os) -{ - return node->traverse_inheritance_graph (be_interface::copy_ctor_helper, - os); + return 0; } ACE_CString diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp index 9ed1864aba5..8126f1674ee 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype_fwd/valuetype_fwd_ch.cpp @@ -99,7 +99,6 @@ be_visitor_valuetype_fwd_ch::visit_valuetype_fwd (be_valuetype_fwd *node) os->gen_endif (); node->cli_hdr_gen (I_TRUE); - bfd->cli_hdr_gen (I_TRUE); return 0; } diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interface.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interface.h index 9d2b0119d25..edbfcc86077 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/interface.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interface.h @@ -40,6 +40,8 @@ // methods. // +class AST_Operation; + class be_visitor_interface : public be_visitor_scope { // @@ -49,7 +51,6 @@ class be_visitor_interface : public be_visitor_scope // = DESCRIPTION // This is a concrete visitor for interface that abstracts all common tasks // - public: be_visitor_interface (be_visitor_context *ctx); // constructor @@ -98,6 +99,9 @@ public: protected: int is_amh_rh_node (be_interface *node); + + static void add_abstract_op_args (AST_Operation *old_op, + be_operation &new_op); }; #endif /* _BE_INTERFACE_INTERFACE_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_cs.h b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_cs.h index d5e927d7f9e..ea44c2e7d2d 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_interface/interface_cs.h +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/interface_cs.h @@ -47,6 +47,14 @@ public: TAO_OutStream *os); // Helper to generate the definitions for the operations // of any abstract parents we may have. + +protected: + void gen_concrete_unchecked_narrow (be_interface *node, + be_type *bt, + TAO_OutStream *os); + void gen_abstract_unchecked_narrow (be_interface *node, + be_type *bt, + TAO_OutStream *os); }; #endif /* _BE_INTERFACE_INTERFACE_CS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/operation.h b/TAO/TAO_IDL/be_include/be_visitor_operation/operation.h index 68c30431639..967e2157507 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/operation.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/operation.h @@ -76,6 +76,37 @@ public: virtual int gen_check_interceptor_exception (be_type *); // helper that generates code for checking for an exception within // an interceptor try block. + + virtual int gen_stub_operation_body (be_operation *node, + be_type *return_type); + // Generates the code from opening brace to closing brace for + // stub operations. Also called (for now) + // from be_visitor_operation_cs, to generate operation stub + // bodies for abstract interfaces (unless and until abstract + // interfaces are made to interoperate with collocatino). + + virtual int gen_pre_stub_info (be_operation *node); + // generate any info before the actual code for the stub is generated + + virtual int gen_marshal_and_invoke (be_operation *node, + be_type *bt); + // generate code that marshals the arguments and transmits them + + virtual int gen_raise_interceptor_exception ( + be_type *return_type, + const char *exception_name, + const char *exception_arguments + ); + // helper that generates code for raising an exception within + // interceptor's try block + + virtual const char *compute_operation_name (be_operation *node); + // compute the operation_remote_proxy_impl name. + // Notice that this operation_remote_proxy_impl + // _does_ include the double quote. + +private: + char *operation_name_; }; #endif /* _BE_VISITOR_OPERATION_OPERATION_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/remote_proxy_impl_cs.h b/TAO/TAO_IDL/be_include/be_visitor_operation/remote_proxy_impl_cs.h index e71f22a1aa0..51b2b2340e4 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/remote_proxy_impl_cs.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/remote_proxy_impl_cs.h @@ -49,29 +49,10 @@ public: // visit argument to generate ParamData entries // = template methods - virtual int gen_pre_stub_info (be_operation *node); - // generate any info before the actual code for the stub is generated - - virtual int gen_marshal_and_invoke (be_operation *node, - be_type *bt); - // generate code that marshals the arguments and transmits them // =helper virtual int post_process (be_decl *); // stuff to output after every member of the scope is handled - - virtual int gen_raise_interceptor_exception (be_type *return_type, - const char *exception_name, - const char *exception_arguments); - // helper that generates code for raising an exception within - // interceptor's try block - - virtual const char *compute_operation_name (be_operation *node); - // compute the operation_remote_proxy_impl name. Notice that this operation_remote_proxy_impl - // _does_ include the double quote. - -private: - char *operation_name_; }; #endif /* _BE_VISITOR_OPERATION_REMOTE_PROXY_IMPL_OPERATION_REMOTE_PROXY_IMPL_CS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_sh.h b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_sh.h index cdb060b160e..7bc105ebc18 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_sh.h +++ b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_sh.h @@ -41,9 +41,6 @@ public: virtual int visit_valuetype (be_valuetype *node); // set the right context and make a visitor - -protected: - virtual void this_method (be_valuetype *node); }; #endif /* _BE_VALUETYPE_VALUETYPE_SH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_ss.h b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_ss.h index a6cef4dc0e2..57dbef6bdcc 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_ss.h @@ -43,16 +43,9 @@ public: // set the right context and make a visitor protected: - virtual void this_method (be_valuetype *node); - virtual void dispatch_method (be_valuetype *node); - - virtual int generate_downcast_implementation (be_valuetype *node, - TAO_OutStream *os); - virtual int generate_copy_ctor (be_valuetype *node, - TAO_OutStream *os); - virtual ACE_CString generate_flat_name (be_valuetype *node); - virtual ACE_CString generate_local_name (be_valuetype *node); - virtual ACE_CString generate_full_skel_name (be_valuetype *node); + ACE_CString generate_flat_name (be_valuetype *node); + ACE_CString generate_local_name (be_valuetype *node); + ACE_CString generate_full_skel_name (be_valuetype *node); }; #endif /* _BE_VALUETYPE_VALUETYPE_SS_H_ */ diff --git a/TAO/TAO_IDL/driver/drv_preproc.cpp b/TAO/TAO_IDL/driver/drv_preproc.cpp index 6d01acf1b00..9e9601b1cfb 100644 --- a/TAO/TAO_IDL/driver/drv_preproc.cpp +++ b/TAO/TAO_IDL/driver/drv_preproc.cpp @@ -454,6 +454,7 @@ DRV_check_for_include (const char* buf) // we don't want to generate header includes for that. if (ACE_OS::strcmp (file_name, "orb.idl")) { + cout << file_name << endl; idl_global->add_to_included_idl_files (file_name); } } @@ -781,7 +782,7 @@ DRV_pre_proc (const char *myfile) FE_set_yyin (ACE_reinterpret_cast (File *, yyin)); - if (idl_global->compile_flags() & IDL_CF_ONLY_PREPROC) + if (idl_global->compile_flags () & IDL_CF_ONLY_PREPROC) { FILE *preproc = ACE_OS::fopen (tmp_file, "r"); char buffer[ACE_MAXLOGMSGLEN]; @@ -846,7 +847,7 @@ DRV_pre_proc (const char *myfile) } #endif /* ACE_HAS_WINNT4 && ACE_HAS_WINNT4 != 0 */ - if (idl_global->compile_flags() & IDL_CF_ONLY_PREPROC) + if (idl_global->compile_flags () & IDL_CF_ONLY_PREPROC) { ACE_OS::exit (0); } |