diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-02-04 16:48:59 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-02-04 16:48:59 +0000 |
commit | 74726b1426daa6db7016097cac90de62e14062c8 (patch) | |
tree | 10489250153b54a62f537bca7ca6367bbfd61dda /TAO/TAO_IDL/be/be_visitor_operation | |
parent | 1a0ff1fa322e7f4c226e901b7153ce24e2aa68ce (diff) | |
download | ATCD-74726b1426daa6db7016097cac90de62e14062c8.tar.gz |
ChangeLogTag: Mon Feb 4 10:47:52 2002 Jeff Parsons <parsons@cs.wustl.edu>
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_operation')
8 files changed, 282 insertions, 177 deletions
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 b63dcab75dc..5421e5ebb95 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 @@ -16,7 +16,9 @@ #include "be_visitor_operation.h" -be_visitor_amh_rh_operation_ss::be_visitor_amh_rh_operation_ss (be_visitor_context *ctx) +be_visitor_amh_rh_operation_ss::be_visitor_amh_rh_operation_ss ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -39,8 +41,13 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) 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 ()); + { + intf = be_interface::narrow_from_scope ( + this->ctx_->attribute()->defined_in () + ); + } if (!intf) { @@ -55,7 +62,8 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) intf->compute_full_name ("TAO_", "", buf); ACE_CString response_handler_implementation_name ("POA_"); response_handler_implementation_name += buf; - delete[] buf; + delete [] buf; + buf = 0; // Step 1 : Generate return type: always void *os << be_nl << "void" << be_nl @@ -66,9 +74,13 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) { // now check if we are a "get" or "set" operation if (node->nmembers () == 1) // set - *os << "_set_"; + { + *os << "_set_"; + } else - *os << "_get_"; + { + *os << "_get_"; + } } *os << node->local_name (); @@ -76,20 +88,10 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) // Step 2 : Generate the params of the method be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_rh_operation_ss::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_amh_rh_operation_ss::" "visit_operation - " @@ -97,8 +99,6 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) -1); } - delete visitor; - int is_an_exception_reply = 0; // Find out if the operation is one of the *_excep() operations, the @@ -112,13 +112,16 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) { if (node->nmembers () == 1) { - UTL_ScopeActiveIterator i (node, UTL_Scope::IK_decls); + UTL_ScopeActiveIterator i (node, + UTL_Scope::IK_decls); + if (!i.is_done ()) { be_argument *argument = be_argument::narrow_from_decl (i.item ()); be_valuetype *vt = be_valuetype::narrow_from_decl (argument->field_type ()); + if (vt != 0 && vt->original_interface () == intf->original_interface () && ACE_OS::strstr (vt->full_name (), "ExceptionHolder") != 0) @@ -135,9 +138,6 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) << "ACE_TRY" << be_nl << "{" << be_nl << "ACE_UNUSED_ARG (holder);" << be_nl - // << " holder->raise_" << node->local_name () - // << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_nl - // << " ACE_TRY_CHECK;" << be_nl << "}" << be_nl << "ACE_CATCH (CORBA::Exception, ex)" << be_nl << "{" << be_nl @@ -167,7 +167,6 @@ int be_visitor_amh_rh_operation_ss::marshal_params (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; be_visitor_context ctx; // Now make sure that we have some in and inout parameters. Otherwise, there @@ -184,11 +183,10 @@ be_visitor_amh_rh_operation_ss::marshal_params (be_operation *node) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - visitor = tao_cg->make_visitor (&ctx); + be_compiled_visitor_operation_argument_invoke visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_amh_rh_operation_ss::" "gen_demarshal_params - " @@ -207,6 +205,7 @@ be_visitor_amh_rh_operation_ss::marshal_params (be_operation *node) "(%N:%l) gen_raise_exception failed\n"), -1); } + *os << be_uidt << "\n"; } 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 3df34d98d0d..4d5d252ab47 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp @@ -34,7 +34,9 @@ ACE_RCSID(be_visitor_operation, amh_sh, "$Id$") // Visitor for generating AMH skeleton for "operation" in skeleton header. // ****************************************************** -be_visitor_amh_operation_sh::be_visitor_amh_operation_sh (be_visitor_context *ctx) +be_visitor_amh_operation_sh::be_visitor_amh_operation_sh ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -48,7 +50,9 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) { // If there is an argument of type "native", return immediately. if (node->has_native ()) - return 0; + { + return 0; + } // Output stream. TAO_OutStream *os = this->ctx_->stream (); @@ -69,11 +73,15 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) { be_argument *argument = be_argument::narrow_from_decl (i.item ()); + if (argument == 0 || argument->direction () == AST_Argument::dir_OUT) - continue; + { + continue; + } *os << ","; + if (arglist_visitor.visit_argument (argument) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -82,15 +90,21 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) "codegen for upcall args failed\n"), -1); } + *os << be_nl; } + *os << "ACE_ENV_ARG_DECL" << be_uidt_nl << ")" << be_uidt; if (be_global->use_raw_throw ()) - *os << be_idt_nl << "throw ("; + { + *os << be_idt_nl << "throw ("; + } else - *os << be_idt_nl << "ACE_THROW_SPEC (("; + { + *os << be_idt_nl << "ACE_THROW_SPEC (("; + } *os << be_idt_nl << "CORBA::SystemException"; @@ -104,7 +118,6 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) } *os << " = 0;\n" << be_nl; - return 0; } @@ -118,11 +131,14 @@ be_visitor_amh_operation_sh::visit_attribute (be_attribute *node) { *os << "ACE_ENV_SINGLE_ARG_DECL"; } + *os << be_uidt_nl << ")" << be_uidt_nl << "ACE_THROW_SPEC ((CORBA::SystemException)) = 0;\n" << be_nl; if (node->readonly ()) - return 0; + { + return 0; + } this->generate_shared_prologue (node, os, "_set_"); @@ -135,7 +151,9 @@ be_visitor_amh_operation_sh::visit_attribute (be_attribute *node) be_visitor_args_arglist visitor (&ctx); if (visitor.visit_argument (&the_argument) == -1) - return -1; + { + return -1; + } *os << the_argument.local_name (); @@ -143,6 +161,7 @@ be_visitor_amh_operation_sh::visit_attribute (be_attribute *node) { *os << be_nl << "ACE_ENV_SINGLE_ARG_DECL"; } + *os << be_uidt_nl << ")" << be_uidt_nl << "ACE_THROW_SPEC ((CORBA::SystemException)) = 0;\n" << be_nl; @@ -150,9 +169,11 @@ be_visitor_amh_operation_sh::visit_attribute (be_attribute *node) } void -be_visitor_amh_operation_sh::generate_shared_prologue (be_decl *node, - TAO_OutStream *os, - const char *skel_prefix) +be_visitor_amh_operation_sh::generate_shared_prologue ( + be_decl *node, + TAO_OutStream *os, + const char *skel_prefix + ) { os->indent (); *os << be_nl << "// TAO_IDL - Generated from " @@ -172,8 +193,13 @@ be_visitor_amh_operation_sh::generate_shared_prologue (be_decl *node, // information from the context 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 ()); + { + intf = be_interface::narrow_from_scope ( + this->ctx_->attribute()->defined_in () + ); + } if (intf == 0) { @@ -202,5 +228,6 @@ be_visitor_amh_operation_sh::generate_shared_prologue (be_decl *node, intf->compute_full_name ("AMH_", "ResponseHandler_ptr", buf); *os << buf << " _tao_rh" << be_nl; - delete[] buf; + delete [] buf; + buf = 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 73a0a577385..f0e40e41975 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp @@ -16,7 +16,9 @@ #include "be_visitor_operation.h" -be_visitor_amh_operation_ss::be_visitor_amh_operation_ss (be_visitor_context *ctx) +be_visitor_amh_operation_ss::be_visitor_amh_operation_ss ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -30,13 +32,17 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) { // If there is an argument of type "native", return immediately. if (node->has_native ()) - return 0; + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); if (this->generate_shared_prologue (node, os, "") == -1) - return -1; + { + return -1; + } int argument_count = node->count_arguments_with_direction (AST_Argument::dir_IN @@ -60,7 +66,9 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) if (argument == 0 || argument->direction () == AST_Argument::dir_OUT) - continue; + { + continue; + } if (vardecl_visitor.visit_argument (argument) == -1) { @@ -72,7 +80,6 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) } } - *os << be_nl << "TAO_InputCDR &_tao_in =" << " _tao_server_request.incoming ();\n" << be_nl @@ -92,9 +99,12 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) { be_argument *argument = be_argument::narrow_from_decl (sj.item ()); + if (argument == 0 || argument->direction () == AST_Argument::dir_OUT) - continue; + { + continue; + } *os << "&& "; @@ -106,6 +116,7 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) "codegen for demarshal failed\n"), -1); } + *os << be_nl; } @@ -120,11 +131,14 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) "(%N:%l) gen_raise_exception failed\n"), -1); } + *os << be_uidt << "\n"; } if (this->generate_shared_section (node, os) == -1) - return -1; + { + return -1; + } { be_visitor_context ctx (*this->ctx_); @@ -138,11 +152,15 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) { be_argument *argument = be_argument::narrow_from_decl (i.item ()); + if (argument == 0 || argument->direction () == AST_Argument::dir_OUT) - continue; + { + continue; + } *os << ","; + if (argument->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -151,13 +169,17 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) "codegen for upcall args failed\n"), -1); } + *os << be_nl; } + *os << "ACE_ENV_ARG_PARAMETER"; } if (this->generate_shared_epilogue (os) == -1) - return -1; + { + return -1; + } return 0; @@ -170,33 +192,43 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) this->ctx_->node (node); if (this->generate_shared_prologue (node, os, "_get_") == -1) - return -1; + { + return -1; + } if (this->generate_shared_section (node, os) == -1) - return -1; + { + return -1; + } *os << "ACE_ENV_ARG_PARAMETER"; if (this->generate_shared_epilogue (os) == -1) - return -1; + { + return -1; + } if (node->readonly ()) - return 0; + { + return 0; + } if (this->generate_shared_prologue (node, os, "_set_") == -1) - return -1; + { + return -1; + } be_argument the_argument (AST_Argument::dir_IN, node->field_type (), node->name ()); - { be_visitor_context ctx (*this->ctx_); be_visitor_args_vardecl_ss visitor (&ctx); if (visitor.visit_argument (&the_argument) == -1) - return -1; - } + { + return -1; + } *os << be_nl << "TAO_InputCDR &_tao_in =" @@ -211,7 +243,9 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) be_visitor_args_marshal_ss visitor (&ctx); if (visitor.visit_argument (&the_argument) == -1) - return -1; + { + return -1; + } } *os << be_uidt_nl << "))" << be_idt_nl; @@ -225,16 +259,21 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) "(%N:%l) gen_raise_exception failed\n"), -1); } + *os << be_uidt << "\n"; if (this->generate_shared_section (node, os) == -1) - return -1; + { + return -1; + } *os << ", " << node->local_name () << be_nl << "ACE_ENV_ARG_PARAMETER"; if (this->generate_shared_epilogue (os) == -1) - return -1; + { + return -1; + } return 0; } @@ -267,7 +306,8 @@ be_visitor_amh_operation_ss::generate_shared_prologue (be_decl *node, intf->compute_full_name ("AMH_", "", buf); ACE_CString amh_skel_name ("POA_"); amh_skel_name += buf; - delete[] buf; + delete [] buf; + buf = 0; os->indent (); *os << "void" << be_nl @@ -306,12 +346,14 @@ be_visitor_amh_operation_ss::generate_shared_section (be_decl *node, char *buf; intf->compute_full_name ("AMH_", "ResponseHandler", buf); ACE_CString response_handler_name (buf); - delete[] buf; + delete [] buf; + buf = 0; intf->compute_full_name ("TAO_AMH_", "ResponseHandler", buf); ACE_CString response_handler_implementation_name ("POA_"); response_handler_implementation_name += buf; - delete[] buf; + delete [] buf; + buf = 0; *os << be_nl << response_handler_name.c_str () << "_var _tao_rh =" << be_idt_nl diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp index 8bf51c89647..ed5ef268658 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp @@ -31,57 +31,72 @@ ACE_RCSID(be_visitor_operation, ami_exception_holder_operation_cs, "$Id$") // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_ami_exception_holder_operation_cs::be_visitor_operation_ami_exception_holder_operation_cs (be_visitor_context *ctx) +be_visitor_operation_ami_exception_holder_operation_cs:: +be_visitor_operation_ami_exception_holder_operation_cs ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } -be_visitor_operation_ami_exception_holder_operation_cs::~be_visitor_operation_ami_exception_holder_operation_cs (void) +be_visitor_operation_ami_exception_holder_operation_cs:: +~be_visitor_operation_ami_exception_holder_operation_cs (void) { } int -be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_operation *node) +be_visitor_operation_ami_exception_holder_operation_cs::visit_operation ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - be_type *bt; // type node - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); // Start with the current indentation level. os->indent (); // Init the return type variable. - bt = be_type::narrow_from_decl (node->return_type ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_ami_exception_holder_operation_cs::" - "visit_operation - " - "Bad return type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_ami_exception_holder_operation_cs::" + "visit_operation - " + "Bad return type\n" + ), + -1 + ); } // Generate the return type. Return type is simply void. *os << "void " << be_nl; // Get the scope name. - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + if (parent == 0) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ami_exception_holder_operation_cs::" - "visit_operation - " - "scopeless operation :-<\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_ami_exception_holder_operation_cs::" + "visit_operation - " + "scopeless operation :-<\n" + ), + -1 + ); } be_interface *parent_interface = be_interface::narrow_from_decl (parent); - if (parent_interface->is_nested () && - parent_interface->defined_in ()->scope_node_type () == AST_Decl::NT_module) - *os << "OBV_"; + AST_Decl::NodeType nt = + parent_interface->defined_in ()->scope_node_type (); + + if (parent_interface->is_nested () && nt == AST_Decl::NT_module) + { + *os << "OBV_"; + } // Here we do not have our overridden be_interface methods, // so the interface type strategy does not work here. @@ -97,14 +112,20 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper { // now check if we are a "get" or "set" operation if (node->nmembers () == 1) // set - *os << "set_"; + { + *os << "set_"; + } else - *os << "get_"; + { + *os << "get_"; + } } *os << node->local_name () << "("; if (!be_global->exception_support ()) - *os << "ACE_ENV_SINGLE_ARG_DECL"; + { + *os << "ACE_ENV_SINGLE_ARG_DECL"; + } *os << ")" << be_uidt; @@ -132,14 +153,15 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper *os << "static TAO_Exception_Data " << "exceptions_data [] = " << be_nl; *os << "{" << be_idt_nl; - // Initialize an iterator to iterate thru the exception list. - UTL_ExceptlistActiveIterator ei (node->exceptions ()); int excep_count = 0; AST_Decl *d = 0; + // Initialize an iterator to iterate thru the exception list. // Continue until each element is visited. - while (!ei.is_done ()) + // Iterator must be explicitly advanced inside the loop. + for (UTL_ExceptlistActiveIterator ei (node->exceptions ()); + !ei.is_done ();) { d = ei.item (); @@ -149,7 +171,7 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper *os << d->name () << "::_alloc" << be_uidt_nl << "}"; - excep_count++; + ++excep_count; ei.next (); if (!ei.is_done ()) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp index 455a6619aae..f957bcb3397 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp @@ -32,8 +32,9 @@ ACE_RCSID(be_visitor_operation, exceptlist_cs, "$Id$") // visitor to generate the exception list for operations // **************************************************************************** -be_visitor_operation_exceptlist_cs::be_visitor_operation_exceptlist_cs (be_visitor_context - *ctx) +be_visitor_operation_exceptlist_cs::be_visitor_operation_exceptlist_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -55,13 +56,13 @@ be_visitor_operation_exceptlist_cs::visit_operation (be_operation *node) << "_exceptiondata [] = " << be_nl; *os << "{" << be_idt_nl; - // Initialize an iterator to iterate thru the exception list. - UTL_ExceptlistActiveIterator ei (node->exceptions ()); - AST_Decl *d = 0; + // Initialize an iterator to iterate thru the exception list. // Continue until each element is visited. - while (!ei.is_done ()) + // Iterator must be advanced explicitly inside the loop. + for (UTL_ExceptlistActiveIterator ei (node->exceptions ()); + !ei.is_done ();) { d = ei.item (); @@ -77,7 +78,6 @@ be_visitor_operation_exceptlist_cs::visit_operation (be_operation *node) { *os << "," << be_nl; } - } *os << be_uidt_nl << "};\n\n"; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp index daefb28aa37..483f72c2553 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp @@ -31,28 +31,28 @@ ACE_RCSID(be_visitor_operation, interceptors_exceptlist, "$Id$") // Operation visitor for exception list // ************************************************************ -be_visitor_operation_interceptors_exceptlist::be_visitor_operation_interceptors_exceptlist (be_visitor_context *ctx) +be_visitor_operation_interceptors_exceptlist:: +be_visitor_operation_interceptors_exceptlist (be_visitor_context *ctx) : be_visitor_operation (ctx) { } -be_visitor_operation_interceptors_exceptlist::~be_visitor_operation_interceptors_exceptlist (void) +be_visitor_operation_interceptors_exceptlist:: +~be_visitor_operation_interceptors_exceptlist (void) { } int be_visitor_operation_interceptors_exceptlist::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - // be_type *bt; // type node - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); // Start with the current indentation level. os->indent (); + TAO_CodeGen::CG_STATE state = this->ctx_->state (); - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST) + if (state == TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST) { return this->gen_exceptlist (node); } @@ -65,12 +65,12 @@ be_visitor_operation_interceptors_exceptlist::visit_operation (be_operation *nod } int -be_visitor_operation_interceptors_exceptlist::gen_exceptlist (be_operation *node) +be_visitor_operation_interceptors_exceptlist::gen_exceptlist ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); // Generate the exception data array. *os << be_nl @@ -78,13 +78,13 @@ be_visitor_operation_interceptors_exceptlist::gen_exceptlist (be_operation *node << "_exceptiondata[] = " << be_nl; *os << "{" << be_idt_nl; - // Initialize an iterator to iterate thru the exception list. - UTL_ExceptlistActiveIterator ei (node->exceptions ()); - be_exception *excp = 0; + // Initialize an iterator to iterate thru the exception list. // Continue until each element is visited. - while (!ei.is_done ()) + // Iterator must be advanced explicitly inside the loop. + for (UTL_ExceptlistActiveIterator ei (node->exceptions ()); + !ei.is_done ();) { excp = be_exception::narrow_from_decl (ei.item ()); @@ -97,18 +97,15 @@ be_visitor_operation_interceptors_exceptlist::gen_exceptlist (be_operation *node "be_exception::narrow_from_decl failed\n"), -1 ); - } *os << excp->tc_name (); - ei.next (); if (!ei.is_done ()) { *os << "," << be_nl; } - } *os << be_uidt_nl << "};" << be_nl; @@ -121,7 +118,8 @@ be_visitor_operation_interceptors_exceptlist::gen_exceptlist (be_operation *node << "{" << be_idt_nl << "CORBA::TypeCode_ptr tcp = _tao_" << node->flat_name () << "_exceptiondata[i];" << be_nl - << "TAO_Pseudo_Object_Manager<CORBA::TypeCode,CORBA::TypeCode_var> tcp_object (&tcp, 1);" << be_nl + << "TAO_Pseudo_Object_Manager<CORBA::TypeCode, " + << "CORBA::TypeCode_var> tcp_object (&tcp, 1);" << be_nl << "(*exception_list)[i] = tcp_object;" << be_uidt_nl << "}\n" << be_uidt; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index 864423484dd..89a76431275 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -27,12 +27,12 @@ ACE_RCSID(be_visitor_operation, operation, "$Id$") - // ************************************************************ - // Generic Operation visitor - // ************************************************************ +// ************************************************************ +// Generic Operation visitor +// ************************************************************ - be_visitor_operation::be_visitor_operation (be_visitor_context *ctx) - : be_visitor_scope (ctx) +be_visitor_operation::be_visitor_operation (be_visitor_context *ctx) + : be_visitor_scope (ctx) { } @@ -41,17 +41,22 @@ be_visitor_operation::~be_visitor_operation (void) } +// Is the operation return type void? int be_visitor_operation::void_return_type (be_type *bt) { - // is the operation return type void? + if (bt->node_type () == AST_Decl::NT_pre_defined) + { + AST_PredefinedType::PredefinedType pdt = + be_predefined_type::narrow_from_decl (bt)->pt (); - if (bt->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (bt)->pt () - == AST_PredefinedType::PT_void)) - return 1; - else - return 0; + if (pdt == AST_PredefinedType::PT_void) + { + return 1; + } + } + + return 0; } int @@ -72,7 +77,7 @@ be_visitor_operation::count_non_out_parameters (be_operation *node) // size_t count = 0; - // initialize an iterator to iterate thru our scope + // Initialize an iterator to iterate thru our scope. for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next ()) @@ -81,21 +86,22 @@ be_visitor_operation::count_non_out_parameters (be_operation *node) be_argument::narrow_from_decl (si.item ()); // We do not generate insertion operators for valuetypes - // yet. Do not include them in the count. + // yet. Do not include them in the count. be_valuetype *vt = be_valuetype::narrow_from_decl (bd->field_type ()); if (bd && (bd->direction () != AST_Argument::dir_OUT) && !vt) - count++; - + { + ++count; + } } return count; } -//Method to generate the throw specs for exceptions that are thrown by the -//operation +// Method to generate the throw specs for exceptions that are thrown by the +// operation. int be_visitor_operation::gen_throw_spec (be_operation *node) { @@ -112,10 +118,11 @@ be_visitor_operation::gen_throw_spec (be_operation *node) *os << be_idt_nl << throw_spec_open << be_idt_nl << "CORBA::SystemException"; + if (node->exceptions ()) { - // initialize an iterator to iterate thru the exception list + // Initialize an iterator to iterate thru the exception list. for (UTL_ExceptlistActiveIterator ei (node->exceptions ()); !ei.is_done (); ei.next ()) @@ -128,7 +135,8 @@ be_visitor_operation::gen_throw_spec (be_operation *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation" "gen_throw_spec - " - "bad exception node\n"), -1); + "bad exception node\n"), + -1); } @@ -137,7 +145,6 @@ be_visitor_operation::gen_throw_spec (be_operation *node) } *os << be_uidt_nl << throw_spec_close << be_uidt; - return 0; } @@ -145,32 +152,38 @@ int be_visitor_operation::gen_environment_decl (int argument_emitted, be_operation *node) { - // generate the CORBA::Environment parameter for the alternative mapping + // Generate the CORBA::Environment parameter for the alternative mapping. if (be_global->exception_support ()) - return 0; + { + return 0; + } - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); // Use ACE_ENV_SINGLE_ARG_DECL or ACE_ENV_ARG_DECL depending on // whether the operation node has parameters. const char *env_decl = "ACE_ENV_SINGLE_ARG_DECL"; + if (argument_emitted || node->argument_count () > 0) - env_decl = "ACE_ENV_ARG_DECL"; + { + env_decl = "ACE_ENV_ARG_DECL"; + } *os << be_nl; + switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_ARGLIST_CH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_SH: - // last argument - is always CORBA::Environment + // Last argument is always CORBA::Environment. *os << env_decl << "_WITH_DEFAULTS"; break; case TAO_CodeGen::TAO_OPERATION_ARGLIST_IS: case TAO_CodeGen::TAO_OPERATION_ARGLIST_IH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_BASE_PROXY_IMPL_CH: - // last argument - is always ACE_ENV_ARG_DECL + // Last argument is always CORBA::Environment. *os << env_decl; break; default: @@ -181,14 +194,15 @@ be_visitor_operation::gen_environment_decl (int argument_emitted, return 0; } -// Method that returns the appropriate CORBA::Environment variable +// Method that returns the appropriate CORBA::Environment variable. const char * be_visitor_operation::gen_environment_var () { static const char *ace_try_env_decl = "ACE_DECLARE_NEW_CORBA_ENV;"; static const char *null_env_decl = ""; - // check if we are generating stubs/skeletons for true C++ exception support + // Check if we are generating stubs/skeletons for + // true C++ exception support. if (be_global->exception_support ()) { return ace_try_env_decl; @@ -215,6 +229,7 @@ be_visitor_operation::gen_raise_exception (be_type *return_type, int is_void = return_type == 0 || this->void_return_type (return_type); + if (is_void) { *os << "ACE_THROW ("; @@ -223,6 +238,7 @@ be_visitor_operation::gen_raise_exception (be_type *return_type, { *os << "ACE_THROW_RETURN ("; } + *os << exception_name << " (" << exception_arguments << ")"; if (is_void) @@ -230,13 +246,15 @@ be_visitor_operation::gen_raise_exception (be_type *return_type, *os << ");\n"; return 0; } + *os << ","; - // Non-void return type.... + // Non-void return type. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS); be_visitor_operation_rettype_return_cs visitor (&ctx); + if (return_type->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -245,8 +263,8 @@ be_visitor_operation::gen_raise_exception (be_type *return_type, "codegen for return var failed\n"), -1); } - *os << ");\n"; + *os << ");\n"; return 0; } @@ -268,6 +286,7 @@ be_visitor_operation::gen_check_exception (be_type *return_type) ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS); be_visitor_operation_rettype_return_cs visitor (&ctx); + if (return_type->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -276,8 +295,8 @@ be_visitor_operation::gen_check_exception (be_type *return_type) "codegen for return var failed\n"), -1); } - *os << ");\n"; + *os << ");\n"; return 0; } @@ -293,12 +312,13 @@ be_visitor_operation::gen_check_interceptor_exception (be_type *return_type) return 0; } - // Non-void return type.... + // Non-void return type. *os << "TAO_INTERCEPTOR_CHECK_RETURN ("; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS); be_visitor_operation_rettype_return_cs visitor (&ctx); + if (return_type->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -307,7 +327,7 @@ be_visitor_operation::gen_check_interceptor_exception (be_type *return_type) "codegen for return var failed\n"), -1); } - *os << ");\n"; + *os << ");\n"; return 0; } 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 7b3d8a12ab8..a02cdaa5c9b 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp @@ -33,23 +33,27 @@ ACE_RCSID(be_visitor_operation, operation_cs, "$Id$") be_visitor_operation_cs::be_visitor_operation_cs (be_visitor_context *ctx) : be_visitor_operation (ctx) - // operation_name_ (0) +// operation_name_ (0) { } be_visitor_operation_cs::~be_visitor_operation_cs (void) { - // delete[] operation_name_; +// delete[] operation_name_; } -// processing to be done after every element in the scope is processed +// Processing to be done after every element in the scope is processed. int be_visitor_operation_cs::post_process (be_decl *bd) { - // all we do here is to insert a comma and a newline + // All we do here is to insert a comma and a newline. TAO_OutStream *os = this->ctx_->stream (); + if (!this->last_node (bd)) - *os << ",\n"; + { + *os << ",\n"; + } + return 0; } @@ -77,9 +81,9 @@ be_visitor_operation_cs::visit_operation (be_operation *node) return 0; } - os->indent (); // start with the current indentation level + os->indent (); - // retrieve the operation return type + // Retrieve the operation return type. be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) @@ -94,11 +98,10 @@ be_visitor_operation_cs::visit_operation (be_operation *node) // Generate the return type mapping (same as in the header file) be_visitor_context ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype rt_visitor = (&ctx); - if ((!visitor) || (bt->accept (visitor) == -1)) + if (bt->accept (&rt_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -106,8 +109,6 @@ be_visitor_operation_cs::visit_operation (be_operation *node) -1); } - delete visitor; - // Generate the operation name *os << " " << node->name (); @@ -115,11 +116,10 @@ be_visitor_operation_cs::visit_operation (be_operation *node) // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_arglist al_visitor (&ctx); - if ((!visitor) || (node->accept (visitor) == -1)) + if (node->accept (&al_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -127,8 +127,6 @@ be_visitor_operation_cs::visit_operation (be_operation *node) -1); } - delete visitor; - *os << "{" << be_idt_nl; *os << this->gen_environment_var (); @@ -260,13 +258,11 @@ be_visitor_operation_cs::visit_operation (be_operation *node) int be_visitor_operation_cs::visit_argument (be_argument *node) { - // this method is used to generate the ParamData table entry + // This method is used to generate the ParamData table entry. TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; // argument type + be_type *bt = be_type::narrow_from_decl (node->field_type ()); - // retrieve the type for this argument - bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -278,6 +274,7 @@ be_visitor_operation_cs::visit_argument (be_argument *node) os->indent (); *os << "{" << bt->tc_name () << ", "; + switch (node->direction ()) { case AST_Argument::dir_IN: @@ -290,7 +287,7 @@ be_visitor_operation_cs::visit_argument (be_argument *node) *os << "PARAM_OUT, "; break; } - *os << "0}"; + *os << "0}"; return 0; } |