diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-01-19 01:44:44 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-01-19 01:44:44 +0000 |
commit | f46d7eac28ac9bff3bc3f3e59eb6b91638cad5b9 (patch) | |
tree | 2225a2c09f4294aa6eee3f7458b14e1a2b6f9598 | |
parent | 5e9a2088b29a8fa2ffecf73a78f29dd8f8b7c763 (diff) | |
download | ATCD-f46d7eac28ac9bff3bc3f3e59eb6b91638cad5b9.tar.gz |
ChangeLogTag:Fri Jan 18 17:29:36 2002 Carlos O'Ryan <coryan@uci.edu>
18 files changed, 407 insertions, 354 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 76286d247e2..77bd15279de 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,60 @@ +Fri Jan 18 17:29:36 2002 Carlos O'Ryan <coryan@uci.edu> + + * tao/TAO_Server_Request.h: + * tao/TAO_Server_Request.cpp: + * tao/TAO_AMH_Response_Handler.h: + * tao/TAO_AMH_Response_Handler.cpp: + The TAO_Server_Request class does not depend on + TAO_AMH_Response_Handler anymore, instead of forsing + ServerRequest to know about AMH and make it copy its state to + the AMH_Response_Handler we make AMH_Response_Handler a + friend. That way the AMH_Response_Handler can copy whatever + state it needs. + Add some comments for Mayur about this stuff. + + * TAO_IDL/be/be_visitor_amh_pre_proc.cpp: + Do not generate AMH_*ResponseHandler nodes for AMI nodes or + other implied-IDL nodes. + + * TAO_IDL/be/be_visitor_interface/amh_rh_sh.cpp: + * TAO_IDL/be/be_visitor_interface/amh_rh_ss.cpp: + Fixed inconsistencies in the generated name for the + TAO_AMH_<InterfaceName>ResponseHandler class. + Change the constructor of those generated classes to take the + TAO_ServerRequest parameter. + + + * TAO_IDL/be/be_visitor_interface/interface_sh.cpp: + * TAO_IDL/be/be_visitor_interface/amh_sh.cpp: + Fixed indentation problems. + + * TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp: + Fixed class name in operations (made it consistent with the + generated name in be_visitor_interface/amh_rh_*.cpp). + Fixed exception throwing code (it was hardcoded to use + ACE_THROW, but the IDL compiler should be able to generate raw + throws also). + + * TAO_IDL/be/be_visitor_operation/amh_sh.cpp: + Fixed indentation problem in the generated code. + Improved error messages in case of failure. + Set the visitor context state properly for the arglist visitor. + + * TAO_IDL/be/be_visitor_operation/amh_ss.cpp: + Use the right constructor for the TAO_AMH_*ResponseHandler + class. + + * TAO_IDL/be/be_visitor_operation/operation.cpp: + * TAO_IDL/be/be_visitor_operation/operation_ss.cpp: + * TAO_IDL/be_include/be_visitor_operation/operation.h: + * TAO_IDL/be_include/be_visitor_operation/operation_ss.h: + Move several helper methods to the base class + (be_visitor_operation), because we need them in classes that do + not derive from be_visitor_operation_ss + + * TAO_IDL/ast/ast_decl.cpp: + Fixed small compilation warning. + Fri Jan 18 15:55:59 2002 Ossama Othman <ossama@uci.edu> * tests/Portable_Interceptors/ForwardRequest/client.dsp: @@ -34,14 +91,14 @@ Fri Jan 18 15:41:22 2002 Jeff Parsons <parsons@cs.wustl.edu> Fri Jan 18 13:19:00 2002 Mayur Deshpande <mayur@ics.uci.edu> - * TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp: - * TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp: - * tao/TAO_AMH_Response_handler.h: + * TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp: + * TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp: + * tao/TAO_AMH_Response_handler.h: * tao/TAO_AMH_Response_handler.cpp: - - Added code that now generates AMH-RH code for operation + + Added code that now generates AMH-RH code for operation in skeleton-source file. Changed 'tao_out' CDR stream in - TAO_AMH_Response_Handler so that the variable names of the + TAO_AMH_Response_Handler so that the variable names of the generated IDL code and that in the tao orb_core files match. Fri Jan 18 13:47:26 2002 Jeff Parsons <parsons@cs.wustl.edu> @@ -57,11 +114,11 @@ Fri Jan 18 13:21:28 2002 Jeff Parsons <parsons@cs.wustl.edu> Added patch sent in by Andy Olsen <olsona@uswest.net> that limits the last component of the name of the temporary file - used by gperf to no more than 48 characters, when the + used by gperf to no more than 48 characters, when the platform is QNX. Fri Jan 18 22:16:06 2002 Boris Kolpackov <bosk@ipmce.ru> - + * TAO_IDL/be_include/be_visitor_typecode/typecode_decl.h: * TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h: * TAO_IDL/be_include/be_visitor_valuetype/any_op_ch.h: @@ -79,7 +136,7 @@ Fri Jan 18 22:16:06 2002 Boris Kolpackov <bosk@ipmce.ru> * TAO_IDL/be/be_visitor_factory.cpp: * TAO_IDL/be/be_valuetype.cpp: * TAO_IDL/be/be_visitor_valuetype.cpp: - * tao/Typecode.h: + * tao/Typecode.h: * tao/Marshal.h: * tao/Marshal.i: * tao/Marshal.cpp: @@ -88,7 +145,7 @@ Fri Jan 18 22:16:06 2002 Boris Kolpackov <bosk@ipmce.ru> * tao/append.cpp: * tao/skip.cpp: Added Any and TypeCode support for valuetypes. - + Fri Jan 18 11:50:06 2002 Balachandran Natarajan <bala@cs.wustl.edu> * */Makefile: Regenerated dependencies. diff --git a/TAO/TAO_IDL/ast/ast_decl.cpp b/TAO/TAO_IDL/ast/ast_decl.cpp index a4cbc1d18ff..427c0d37458 100644 --- a/TAO/TAO_IDL/ast/ast_decl.cpp +++ b/TAO/TAO_IDL/ast/ast_decl.cpp @@ -587,7 +587,7 @@ AST_Decl::repoID (char *value) // Forces version to be set to the last id component. delete [] this->version_; this->version_ = 0; - const char *dummy = this->version (); + (void) this->version (); } else if (ACE_OS::strcmp (this->repoID_, value) != 0) { diff --git a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp index 379e64487a1..1de3d0d5d98 100644 --- a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp +++ b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp @@ -58,38 +58,46 @@ be_visitor_amh_pre_proc::visit_module (be_module *node) int be_visitor_amh_pre_proc::visit_interface (be_interface *node) { - if (!node->imported () && !node->is_local ()) - { - AST_Module *module = - AST_Module::narrow_from_scope (node->defined_in ()); - - if (!module) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_pre_proc::" - "visit_interface - module is null\n"), - -1); - - // Create the ResponseHandler class - be_interface *response_handler = this->create_response_handler (node); - if (response_handler != 0) - { - response_handler->set_defined_in (node->defined_in ()); + // Do not generate AMH classes for any sort of implied IDL. + if (node->original_interface () != 0) + return 0; - // Insert the response handler after the node. - module->be_add_interface (response_handler, node); + // don't generate AMH classes for imported or local interfaces + // either... + // @@ Mayur, maybe we do want to insert the AMH node for imported + // interfaces, not because we want to generate code for them, but + // because the (imported-AMH-) node could be needed to generate a + // non-imported, AMH node, for example, for a derived interface. + if (node->imported () || node->is_local ()) + return 0; - // Remember from whom we were cloned - response_handler->original_interface (node); - } - else - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_pre_proc::" - "visit_interface - " - "creating the response handler failed\n"), - -1); - } + AST_Module *module = + AST_Module::narrow_from_scope (node->defined_in ()); + + if (module == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_pre_proc::" + "visit_interface - module is null\n"), + -1); + + // Create the ResponseHandler class + be_interface *response_handler = this->create_response_handler (node); + if (response_handler == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_pre_proc::" + "visit_interface - " + "creating the response handler failed\n"), + -1); } + response_handler->set_defined_in (node->defined_in ()); + + // Insert the response handler after the node. + module->be_add_interface (response_handler, node); + + // Remember from whom we were cloned + response_handler->original_interface (node); + return 0; } @@ -102,12 +110,18 @@ be_visitor_amh_pre_proc::create_response_handler (be_interface *node) class_name += "AMH_"; class_name += node->local_name (); class_name += "ResponseHandler"; - - UTL_ScopedName *amh_name = + + UTL_ScopedName *amh_name = ACE_dynamic_cast(UTL_ScopedName*,node->name ()->copy ()); Identifier *local_name = amh_name->last_component (); local_name->replace_string (class_name.c_str ()); + // @@ Mayur, you are not filling up the list of inherited classes, + // however, you *are* using that same list in the amh_rh_sh.cpp and + // amh_rh_sh.cpp file... you need to fill up the list, i.e. discover + // the inherited classes in the original interface, change their + // names and then use the symbol table to look up the + // AMH-response-handler nodes. be_interface *response_handler = new be_interface (amh_name, // name 0, // list of inherited diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_sh.cpp index fc0614f7c33..d31ac7d10d7 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_sh.cpp @@ -41,11 +41,17 @@ be_visitor_amh_rh_interface_sh::visit_interface (be_interface *node) os->indent (); - // Generate the skeleton class name. - // this is AMH_intf_ResponseHandler - ACE_CString rh_base_class_name = node->local_name ();; - // and this is TAO_AMH_intf_ResponseHandler + // Generate the skeleton class name, use the AMH-node name as a + // basis, this is AMH_<InterfaceName>ResponseHandler... + ACE_CString rh_base_class_name = node->local_name (); + // ...and prepend either the "TAO_" prefix... ACE_CString rh_skel_class_name = "TAO_"; + if (!node->is_nested ()) + { + // ...or the "POA_TAO_" prefix if we are in the global + // namespace.... + rh_skel_class_name = "POA_TAO_"; + } rh_skel_class_name += rh_base_class_name.c_str (); *os << "class " << rh_skel_class_name.c_str () << ";" << be_nl; @@ -63,25 +69,14 @@ be_visitor_amh_rh_interface_sh::visit_interface (be_interface *node) // Now generate the class definition *os << "class " << be_global->skel_export_macro () << " " << rh_skel_class_name.c_str () << be_idt_nl - << ": public " << inherit_client_parent.c_str () << be_nl - << ", public " << inherit_tao_parent.c_str (); - - long n_parents = node->n_inherits (); - for (int i = 0; i < n_parents; ++i) - { - *os << be_nl << ", public virtual " - << node->inherits ()[i]->name (); - } + << ": public " << inherit_tao_parent.c_str () + << ", public " << inherit_client_parent.c_str () << be_nl; *os << be_uidt_nl << "{" << be_nl - << "protected:" << be_idt_nl - << rh_skel_class_name.c_str () << " (void);\n" << be_uidt_nl - << "public:" << be_idt_nl; - - // No copy constructor for locality constraint interface. - *os << rh_skel_class_name.c_str () << " (const " - << rh_skel_class_name.c_str () << "& rhs);" << be_nl - << "virtual ~" << rh_skel_class_name.c_str () << " (void);\n\n"; + << "public:" << be_idt_nl + << rh_skel_class_name.c_str () << " (TAO_ServerRequest &sr);" << be_nl + << "virtual ~" << rh_skel_class_name.c_str () << " (void);" + << be_nl; // Generate code for elements in the scope (e.g., operations). if (this->visit_scope (node) == -1) @@ -96,4 +91,3 @@ be_visitor_amh_rh_interface_sh::visit_interface (be_interface *node) *os << be_uidt_nl << "};\n\n"; return 0; } - diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_ss.cpp index ab996a1eb40..bff5bf11d3d 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_rh_ss.cpp @@ -4,7 +4,7 @@ * * $Id$ * -* Specialized interface visitor for AMH-ResponseHandler that generates code for +* Specialized interface visitor for AMH-ResponseHandler that generates code for * RH in the skeleton source files. * * @author Mayur Deshpande <mayur@ics.uci.edu> @@ -42,59 +42,45 @@ be_visitor_amh_rh_interface_ss::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); - os->indent (); - - // Generate the skeleton class name. - // this is AMH_intf_ResponseHandler - ACE_CString rh_base_class_name = node->local_name (); - // and this is TAO_AMH_intf_ResponseHandler + // @@ Mayur, the exact same code is duplicated in amh_rh_sh.cpp, + // need to fix that... + // Generate the skeleton class name, use the AMH-node name as a + // basis, this is AMH_<InterfaceName>ResponseHandler... + ACE_CString rh_base_class_name = node->local_name (); + // ...and prepend either the "TAO_" prefix... ACE_CString rh_skel_class_name = "TAO_"; - rh_skel_class_name += rh_base_class_name.c_str (); - - // constructor - *os << "// skeleton constructor\n"; - // find if we are at the top scope or inside some module if (!node->is_nested ()) { - // we are outermost. So the POA_ prefix is prepended to our name - *os << node->full_skel_name () << "::POA_" << node->local_name () - << " (void)\n"; - } - else - { - // the POA_ prefix is prepended to our outermost module name - *os << node->full_skel_name () << "::" << rh_skel_class_name.c_str() - << " (void)\n"; + // ...or the "POA_TAO_" prefix if we are in the global + // namespace.... + rh_skel_class_name = "POA_TAO_"; } + rh_skel_class_name += rh_base_class_name.c_str (); + + // constructor + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl; - if (node->traverse_inheritance_graph - (be_interface::copy_ctor_helper, os) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ss::visit_interface - " - " copy ctor generation failed\n"), -1); - *os << " TAO_ServantBase (rhs)" << be_uidt_nl - << "{}" << be_nl << be_nl; + *os << rh_skel_class_name.c_str() << "::" << be_nl + << " " << rh_skel_class_name.c_str() + << " (TAO_ServerRequest &sr)" << be_nl + << " : TAO_AMH_Response_Handler (sr)" << be_nl + << " , " << node->full_name () << " ()" << be_nl + << "{" << be_nl + << "}\n\n"; - *os << "// skeleton destructor" << be_nl; + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl; - if (!node->is_nested ()) - { - // we are outermost. So the POA_ prefix is prepended to our name - *os << node->full_skel_name () << "::~POA_" << node->local_name () << - " (void)" << be_nl; - } - else - { - // the POA_ prefix is prepended to our outermost module name - *os << node->full_skel_name () << "::~" << rh_skel_class_name.c_str() << - " (void)" << be_nl; - } + *os << rh_skel_class_name.c_str() << "::" << be_nl + << " ~" << rh_skel_class_name.c_str() + << " (void)" << be_nl; *os << "{" << be_nl; *os << "}\n\n"; // generate code for elements in the scope (e.g., operations) - // We'll rely on the base class (be_visitor_scope) to do the + // We'll rely on the base class (be_visitor_scope) to do the // right thing for us. if (this->visit_scope (node) == -1) { diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp index a1b464dbf02..a237f017cfc 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp @@ -146,13 +146,14 @@ be_visitor_amh_interface_sh::visit_interface (be_interface *node) this->this_method (node); // The _interface_repository_id method. - *os << "virtual const char* _interface_repository_id " - << "(void) const;\n\n"; + *os << be_nl + << "virtual const char* _interface_repository_id " + << "(void) const;\n"; if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" + "(%N:%l) be_visitor_amh_interface_sh::" "visit_interface - " "codegen for scope failed\n"), -1); @@ -374,5 +375,5 @@ be_visitor_amh_interface_sh::this_method (be_interface *node) // AMH one. *os << non_amh_name.c_str () << " *_this (" << be_idt << be_idt_nl << "TAO_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl - << be_uidt_nl << ");\n" << be_uidt_nl; + << ");\n" << be_uidt; } 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 be413dd8294..b0062f701ee 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp @@ -187,7 +187,8 @@ be_visitor_interface_sh::visit_interface (be_interface *node) this->this_method (node); // The _interface_repository_id method. - *os << "virtual const char* _interface_repository_id " + *os << be_nl + << "virtual const char* _interface_repository_id " << "(void) const;\n\n"; // Generate code for elements in the scope (e.g., operations). @@ -313,7 +314,7 @@ be_visitor_interface_sh::this_method (be_interface *node) // Print out the _this() method. *os << "::" << node->full_name () << " *_this (" << be_idt << be_idt_nl << "TAO_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl - << ");\n" << be_uidt_nl; + << ");\n" << be_uidt; } int diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp index cf792b4bbf8..b6d5fc3c1de 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp @@ -1,13 +1,13 @@ //============================================================================= /** -* @file amh_rh_ss.cpp -* -* $Id$ -* -* Creates code for AMH-RH operations. -* -* @author Mayur Deshpande <mayur@ics.uci.edu> -*/ + * @file amh_rh_ss.cpp + * + * $Id$ + * + * Creates code for AMH-RH operations. + * + * @author Mayur Deshpande <mayur@ics.uci.edu> + */ //============================================================================= #include "idl.h" @@ -37,10 +37,10 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) // Output stream. TAO_OutStream *os = this->ctx_->stream (); - be_interface *intf; - intf = this->ctx_->attribute () - ? be_interface::narrow_from_scope (this->ctx_->attribute()->defined_in ()) - : be_interface::narrow_from_scope (node->defined_in ()); + be_interface *intf = + be_interface::narrow_from_scope (node->defined_in ()); + if (this->ctx_->attribute () != 0) + intf = be_interface::narrow_from_scope (this->ctx_->attribute()->defined_in ()); if (!intf) { @@ -51,10 +51,15 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) -1); } + char *buf; + intf->compute_full_name ("TAO_", "", buf); + ACE_CString response_handler_implementation_name ("POA_"); + response_handler_implementation_name += buf; + delete[] buf; + // Step 1 : Generate return type: always void - os->indent (); - *os << "virtual void " - << "TAO_" << intf->full_skel_name () << "::"; + *os << be_nl << "void" << be_nl + << response_handler_implementation_name.c_str () << "::"; // Check if we are an attribute node in disguise if (this->ctx_->attribute ()) @@ -96,11 +101,11 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) // Step 3: Generate actual code for the method *os << "{" << be_idt_nl - << "init_reply ();" << be_nl << be_nl; + << "this->init_reply ();" << be_nl << be_nl; marshal_params (node); - *os << "send_reply ();" << be_uidt_nl + *os << "this->send_reply ();" << be_uidt_nl << "}" << be_nl; return 0; @@ -141,9 +146,20 @@ be_visitor_amh_rh_operation_ss::marshal_params (be_operation *node) -1); } - *os << be_uidt_nl << "))" - << "ACE_THROW (CORBA::MARSHAL());" << be_nl << be_nl; - }; + *os << be_uidt_nl << "))\n" << be_idt; + + // If marshaling fails, raise exception. + if (this->gen_raise_exception (0, + "CORBA::MARSHAL", + "", + "") == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) gen_raise_exception failed\n"), + -1); + } + *os << be_uidt << "\n"; + } return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp index e6d25fc6779..43af2b1998e 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp @@ -126,17 +126,25 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) if (node->argument_count () > 0) { - *os << ","; + *os << "," << be_nl; } - be_visitor_operation_arglist arglist_visitor (this->ctx_); + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); + + be_visitor_operation_arglist arglist_visitor (&ctx); if (arglist_visitor.visit_scope (node) == -1) - return -1; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) - visit_scope failed\n"), -1); + if (arglist_visitor.gen_environment_decl (1, node) == -1) - return -1; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) - gen_environment_decl failed\n"), -1); + *os << be_uidt_nl << ")" << be_uidt; if (arglist_visitor.gen_throw_spec (node) == -1) - return -1; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) - gen_throe_spec failed\n"), -1); *os << " = 0;\n" << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp index 066dc8580bf..d4763415245 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp @@ -96,10 +96,6 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) << "_tao_object_reference" << be_uidt << be_uidt_nl << ");" << be_uidt_nl; - // Declare a return type variable. - // AMH operations do not have return | OUT - *os << "_tao_server_request.argument_flag (0);" << be_nl; - // Declare variables for arguments. be_visitor_context ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); @@ -138,7 +134,7 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) *os << be_nl << response_handler_name.c_str () << "_var _tao_rh =" << be_idt_nl << "new " << response_handler_implementation_name.c_str () - << ";" << be_uidt_nl; + << " (_tao_server_request);" << be_uidt_nl; // Make the upcall. *os << be_nl << "_tao_impl->" @@ -191,22 +187,18 @@ be_visitor_amh_operation_ss::demarshal_params (be_operation *node) *os << be_uidt_nl << "))\n" << be_idt; - // Look into this in detail later - /* // If marshaling fails, raise exception. - if (this->gen_raise_exception (bt, "CORBA::MARSHAL", - "", - "ACE_TRY_ENV") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" - "gen_marshal_and invoke - " - "codegen for return var failed\n"), - -1); - } - - *os << be_uidt << "\n"; - */ - }; + // If marshaling fails, raise exception. + if (this->gen_raise_exception (0, + "CORBA::MARSHAL", + "", + "") == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) gen_raise_exception failed\n"), + -1); + } + *os << be_uidt << "\n"; + } return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index da3f0613443..95fffeefd59 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -236,3 +236,65 @@ be_visitor_operation::gen_environment_var () return null_env_decl; } } + +int +be_visitor_operation::gen_raise_exception (be_type *, + const char *excep, + const char *completion_status, + const char * /* env */) +{ + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + if (be_global->use_raw_throw ()) + { + *os << "throw "; + } + else + { + *os << "ACE_THROW ("; + } + + *os << excep << "(" << completion_status << ")"; + + if (be_global->use_raw_throw ()) + { + *os << ";\n"; + } + else + { + *os << ");\n"; + } + + return 0; +} + +int +be_visitor_operation::gen_check_exception (be_type *, + const char * /* env */) +{ + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + // Check if there is an exception. + *os << "ACE_CHECK;\n"; + + return 0; +} + +int +be_visitor_operation::gen_check_interceptor_exception (be_type *, + const char * /* env */) +{ + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + // Check if there is an exception. + *os << "TAO_INTERCEPTOR_CHECK;\n"; + + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp index e1b14bb6861..b5791b226c5 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp @@ -610,15 +610,15 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, TAO_OutStream *os = this->ctx_->stream (); be_visitor *visitor; be_visitor_context ctx; - + // Setup parameters for marshaling and marshal them into the // outgoing stream. // The code below this is for 2way operations only. - + // We will be here only if we are 2way // first initialize a reply message *os << "_tao_server_request.init_reply ();" << be_nl << be_nl; - + // We still need the following check because we maybe 2way and yet have no // parameters and a void return type. if (this->void_return_type (bt) && @@ -627,19 +627,19 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, { return 0; } - + // Create temporary variables for the out and return parameters. if (!this->void_return_type (bt)) { ctx = *this->ctx_; - + be_visitor_context *new_ctx = 0; ACE_NEW_RETURN (new_ctx, be_visitor_context (ctx), 0); be_visitor_operation_rettype_post_upcall_ss visitor (new_ctx); - + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -649,7 +649,7 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, -1); } } - + // Generate any temporary variables to demarshal the arguments. ctx = *this->ctx_; be_visitor_args_post_upcall_ss vis1 (new be_visitor_context (ctx)); @@ -731,66 +731,6 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, return 0; } -int -be_visitor_operation_ss::gen_raise_exception (be_type *, - const char *excep, - const char *completion_status, - const char * /* env */) -{ - TAO_OutStream *os = this->ctx_->stream (); - - os->indent (); - - if (be_global->use_raw_throw ()) - { - *os << "throw "; - } - else - { - *os << "ACE_THROW ("; - } - - *os << excep << "(" << completion_status << ")"; - - if (be_global->use_raw_throw ()) - { - *os << ";\n"; - } - else - { - *os << ");\n"; - } - - return 0; -} - -int -be_visitor_operation_ss::gen_check_exception (be_type *, - const char * /* env */) -{ - TAO_OutStream *os = this->ctx_->stream (); - - os->indent (); - - // Check if there is an exception. - *os << "ACE_CHECK;\n"; - - return 0; -} - -int -be_visitor_operation_ss::gen_check_interceptor_exception (be_type *, const char * /* env */) -{ - TAO_OutStream *os = this->ctx_->stream (); - - os->indent (); - - // Check if there is an exception. - *os << "TAO_INTERCEPTOR_CHECK;\n"; - - return 0; -} - const char * be_visitor_operation_ss::compute_operation_name (be_operation *node) { 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 26dcf0da215..0e4e4a419b2 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/operation.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/operation.h @@ -63,6 +63,19 @@ public: virtual const char *gen_environment_var (void); // generate the environment variable declaration + + virtual int gen_raise_exception (be_type *, + const char *excep, + const char *status, + const char *env); + // helper that generates code for raising an exception + + virtual int gen_check_exception (be_type *, const char *env); + // helper that generates code for checking for an exception + + virtual int gen_check_interceptor_exception (be_type *, const char *env); + // helper that generates code for checking for an exception within + // an interceptor try block. }; #endif /* _BE_VISITOR_OPERATION_OPERATION_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/operation_ss.h b/TAO/TAO_IDL/be_include/be_visitor_operation/operation_ss.h index eec9632fe95..0dad13c8147 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/operation_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/operation_ss.h @@ -65,19 +65,6 @@ public: virtual int post_process (be_decl *); // stuff to output after every member of the scope is handled - virtual int gen_raise_exception (be_type *, - const char *excep, - const char *status, - const char *env); - // helper that generates code for raising an exception - - virtual int gen_check_exception (be_type *, const char *env); - // helper that generates code for checking for an exception - - virtual int gen_check_interceptor_exception (be_type *, const char *env); - // helper that generates code for checking for an exception within - // an interceptor try block. - virtual const char *compute_operation_name (be_operation *node); // Compute the servant operation name to invoke. Notice that // this method _does_ include the double-quotes. diff --git a/TAO/tao/TAO_AMH_Response_Handler.cpp b/TAO/tao/TAO_AMH_Response_Handler.cpp index 0da44411033..5ccdd977f12 100644 --- a/TAO/tao/TAO_AMH_Response_Handler.cpp +++ b/TAO/tao/TAO_AMH_Response_Handler.cpp @@ -1,6 +1,7 @@ // $Id$ #include "TAO_AMH_Response_Handler.h" +#include "tao/TAO_Server_Request.h" #include "tao/Transport.h" #include "tao/CDR.h" #include "tao/ORB_Core.h" @@ -10,56 +11,49 @@ #include "tao/GIOP_Utils.h" #include "tao/debug.h" - -TAO_AMH_Response_Handler::TAO_AMH_Response_Handler () - : argument_flag_(1), - exception_type_ (TAO_GIOP_NO_EXCEPTION), - once_only_(0) +TAO_AMH_Response_Handler:: +TAO_AMH_Response_Handler (TAO_ServerRequest &server_request) + : mesg_base_ (server_request.mesg_base_) + , request_id_ (server_request.request_id_) + , response_expected_ (server_request.response_expected_) + , transport_ (TAO_Transport::_duplicate (server_request.transport ())) + , orb_core_ (server_request.orb_core ()) + , argument_flag_ (1) + , exception_type_ (TAO_GIOP_NO_EXCEPTION) + , once_only_ (0) { + // @@ Mayur: I think only *servers* can use the AMH_Response_Handler + // class, right? If that is the case we need to come up with an + // scheme to move the AMH_Response_Handler class to the PortableServer + // library. Growing the footprint of a pure-client to support AMH + // makes no sense. } TAO_AMH_Response_Handler::~TAO_AMH_Response_Handler (void) { + // @@ Mayur: what if the class is destroyed before a reply is sent + // to the client? IMHO, we should send some sort of system + // exception (maybe CORBA::NO_RESPONSE or CORBA::INV_ORDER), with a + // clear minor code to indicate the problem. + // release the transport TAO_Transport::release (transport_); } - -void -TAO_AMH_Response_Handler::mesg_base (TAO_Pluggable_Messaging *mesg_base) -{ - this->mesg_base_ = mesg_base; -} - -void -TAO_AMH_Response_Handler::request_id (CORBA::ULong request_id) -{ - this->request_id_ = request_id; -} - -void -TAO_AMH_Response_Handler::response_expected (CORBA::Boolean response_expected) -{ - this->response_expected_ = response_expected; -} - -void -TAO_AMH_Response_Handler::transport (TAO_Transport *transport) -{ - this->transport_ = transport; -} - -/*void -TAO_AMH_Response_Handler::reply_service_info (IOP::ServiceContext &service_context) -{ -this->reply_service_context_.set_context (service_context); -}*/ - - - +// @@ Mayur: change the signature of this function to use +// TAO_ENV_SINGLE_ARG_DECL... and then change the generated code in +// the IDL compiler too! void TAO_AMH_Response_Handler::init_reply (void) { + // @@ Mayur: as you pointed out this stuff is not thread safe, also, + // I would use the "state pattern".. + // { + // ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + // if (once_only_ != NO_REQUEST_SENT) + // // Raise exception + // once_only_ = SENDING_REQUEST; + // } once_only_ ++; // equals 1 if called for first time if (once_only_ == 1) { @@ -102,6 +96,14 @@ TAO_AMH_Response_Handler::init_reply (void) void TAO_AMH_Response_Handler::send_reply (void) { + // @@ Mayur: as you pointed out this stuff is not thread safe, also, + // I would use the "state pattern".. + // { + // ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->mutex_); + // if (once_only_ != SENDING_REQUEST) + // // Raise exception + // once_only_ = REQUEST_SENT; + // } if (once_only_ == 2) // should not be necessary, but just precautionary { diff --git a/TAO/tao/TAO_AMH_Response_Handler.h b/TAO/tao/TAO_AMH_Response_Handler.h index 8293a80d7f8..03b918bfd77 100644 --- a/TAO/tao/TAO_AMH_Response_Handler.h +++ b/TAO/tao/TAO_AMH_Response_Handler.h @@ -1,30 +1,20 @@ // -*- C++ -*- -// @@ Mayur the following comment is not properly formated. I'm going -// to give you are free copy of Emacs so you can get it right. - // @@ Mayur the canonical naming convention is to call this file // "AMH_Response_Handler.h", without the TAO_ prefix. The // Server_Request.h class is a deviation from the rules. /** -* @file TAO_AMH_Response_Handler.h -* -* $Id$ -* -* @author Mayur Deshpande (mayur@ics.uci..edu) -* -*/ - + * @file TAO_AMH_Response_Handler.h + * + * $Id$ + * + * @author Mayur Deshpande (mayur@ics.uci..edu) + * + */ #ifndef TAO_AMH_RESPONSE_HANDLER_H #define TAO_AMH_RESPONSE_HANDLER_H -// @@ Mayur, please do not commit commented out code into the repo.... -//#include "tao/CDR.h" -//#include "tao/ORB_Core.h" -//#include "tao/ORB.h" -//#include "tao/Pluggable_Messaging_Utils.h" -//#include "tao/GIOP_Utils.h" #include "tao/Service_Context.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) @@ -35,50 +25,67 @@ class TAO_Transport; class TAO_Pluggable_Messaging; class TAO_Output_CDR; class TAO_ORB_Core; +class TAO_ServerRequest; -class TAO_AMH_Response_Handler +class TAO_Export TAO_AMH_Response_Handler { public: // @@ Mayur, please document the class and all its methods using the // Doxygen style.... - TAO_AMH_Response_Handler (); + TAO_AMH_Response_Handler (TAO_ServerRequest &server_request); virtual ~TAO_AMH_Response_Handler (void); + // @@ Mayur, it looks like the following two methods are *only* used + // by derived classes, can we make them protected? + // @@ Also: you may want to call them _tao_init_reply() and + // _tao_send_reply(), otherwise they pollute the user namespace. + // What if the user has: + // + // // IDL + // interface Foo { + // void init_reply (); + // }; + // // implied-IDL + // local interface AMH_FooResponseHandler { + // void init_reply (); // uh-oh... + // }; + // void init_reply (void); void send_reply (void); - // @@ Mayur: why do you have 5 modifiers? Aren't all these - // attributes changed simultaneously? - void mesg_base (TAO_Pluggable_Messaging *mesg_base); - void request_id (CORBA::ULong request_id); - void response_expected (CORBA::Boolean response_expected); - void transport (TAO_Transport *transport); - //void reply_service_info (IOP::ServiceContext &service_context); - - - // @@ Mayur please do no use public fields unless you have a very - // good reason for it... better to use an accessor... - TAO_OutputCDR _tao_out_; - - private: // @@ Mayur please document the fields of the class too! TAO_Pluggable_Messaging *mesg_base_; CORBA::ULong request_id_; // copy CORBA::Boolean response_expected_; TAO_Transport *transport_; - TAO_Service_Context reply_service_context_; //copy - CORBA::Boolean argument_flag_; - /// A pointer to the ORB Core for the context where the request was /// created. TAO_ORB_Core *orb_core_; + TAO_Service_Context reply_service_context_; //copy + CORBA::Boolean argument_flag_; + // TAO_GIOP_ReplyStatusType exception_type_; /// Exception type (will be NO_EXCEPTION in the majority of the cases). CORBA::ULong exception_type_; int once_only_; + +protected: + /// The outgoing CDR stream + /** + * The IDL-generated ResponseHandler implementations used this field + * to marshal the response. + * Making it a field instead of a public accessor makes the code in + * the generated ResponseHandler implementation a lot more readable. + */ + TAO_OutputCDR _tao_out; + +private: + // Private and undefined, standard C++ idiom to prohibit copying. + ACE_UNIMPLEMENTED_FUNC (TAO_AMH_Response_Handler (const TAO_AMH_Response_Handler&)) + ACE_UNIMPLEMENTED_FUNC (TAO_AMH_Response_Handler& operator= (const TAO_AMH_Response_Handler&)) }; #endif /* TAO_AMH_RESPONSE_HANDLER_H */ diff --git a/TAO/tao/TAO_Server_Request.cpp b/TAO/tao/TAO_Server_Request.cpp index e418bcaafb5..5303381f18c 100644 --- a/TAO/tao/TAO_Server_Request.cpp +++ b/TAO/tao/TAO_Server_Request.cpp @@ -120,40 +120,6 @@ TAO_ServerRequest::~TAO_ServerRequest (void) TAO_Transport::release (this->transport_); } -// @@ Mayur: the name of this method is confusing... it is not -// "instantiating" anything, it is "transferring state" or "copying -// state" or "initializing an AMH Response_Handler" or something of -// that nature, but no objects are instantiated. Please try to make -// the method name match its function. The method is not -// const-correct either, this method does not modify the state of the -// ServerRequest object, therefore it should be const... - -// @@ Mayur: is this a good application of "Dependency Inversion"? -// What is the more general class? ServerRequest or -// AMH_Response_Handler? The former, right? So shouldn't the -// dependency be in the opposite direction, i.e. AMH_Response_Handler -// should call ServerRequest instead of the other way around? -// If necessary you can expose more accessors, or grant "friend" -// access to ServerRequest (the latter is yucky). - -// @@ Mayur: I think only *servers* can use the AMH_Response_Handler -// class, right? If that is the case we need to come up with an -// scheme to move the AMH_Response_Handler class to the PortableServer -// library. Growing the footprint of a pure-client to support AMH -// makes no sense. -void -TAO_ServerRequest::instantiate_AMH_Handler (TAO_AMH_Response_Handler* response_handler) -{ - // @@ Mayur: please don't forget to use the this-> prefix when - // accessing a member field or a method.... - response_handler->mesg_base (mesg_base_); - response_handler->request_id (request_id ()); - response_handler->response_expected (response_expected_); - response_handler->transport (TAO_Transport::_duplicate (transport())); - //response_handler->reply_service_info (reply_service_info ()); -} - - CORBA::ORB_ptr TAO_ServerRequest::orb (void) { diff --git a/TAO/tao/TAO_Server_Request.h b/TAO/tao/TAO_Server_Request.h index 201c0c58a71..b0ad2299124 100644 --- a/TAO/tao/TAO_Server_Request.h +++ b/TAO/tao/TAO_Server_Request.h @@ -38,13 +38,9 @@ #include "PICurrent.h" #endif /* TAO_HAS_INTERCEPTORS == 1 */ -// Added by Mayur 10/12 -#include "TAO_AMH_Response_Handler.h" -// Mayur 10/12 - - class TAO_Pluggable_Messaging; class TAO_Transport; +class TAO_AMH_Response_Handler; /** * @class TAO_ServerRequest @@ -57,6 +53,20 @@ class TAO_Transport; class TAO_Export TAO_ServerRequest { public: + /// Declare TAO_AMH_Response_Handler a friend + /** + * The TAO_AMH_Response_Handler class needs to copy part of the + * state in a TAO_ServerRequest, however, we do not want to expose + * that state as public members of this class, neither do we want to + * add modifiers to the TAO_AMH_Response_Handler class that would + * allow us (the TAO_ServerRequest class) to set the state. + * + * Lucky for us, C++ is a language for adult developers, and allow + * us to use the evil "friend" declaration. + * + */ + friend class TAO_AMH_Response_Handler; + // Constructors. TAO_ServerRequest (TAO_Pluggable_Messaging *mesg_base, @@ -79,9 +89,6 @@ public: /// Destructor. virtual ~TAO_ServerRequest (void); - /// Create an AMH Handler with all necessary data copied into it - void instantiate_AMH_Handler (TAO_AMH_Response_Handler* response_handler); - /** * @name Request attributes. */ |