diff options
author | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-04 18:22:04 +0000 |
---|---|---|
committer | mk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-04 18:22:04 +0000 |
commit | f69b921c536791a965bfafddffcec6ed708073eb (patch) | |
tree | 83efd2beb07cd4d084c9e2419646fa1299372704 | |
parent | 54add6ed788ff69b7caaad6e2b59bf3b9b6b63af (diff) | |
download | ATCD-f69b921c536791a965bfafddffcec6ed708073eb.tar.gz |
Reply Handler Sekelton Generation
6 files changed, 408 insertions, 232 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_ss.cpp index 510a89d3328..3291a6c4757 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_ss.cpp @@ -60,6 +60,10 @@ int be_visitor_args_compiled_marshal_ss::visit_argument (be_argument *node) TAO_OutStream *os = this->ctx_->stream (); // get output stream + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state () == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGS_DEMARSHAL_CS) + return 0; + if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { switch (this->direction ()) diff --git a/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp index 57702ecd178..be63bc8dbec 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/upcall_ss.cpp @@ -75,6 +75,12 @@ int be_visitor_args_upcall_ss::visit_array (be_array *node) be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; + os->indent (); switch (this->direction ()) { @@ -119,6 +125,12 @@ int be_visitor_args_upcall_ss::visit_interface (be_interface *) TAO_OutStream *os = this->ctx_->stream (); // get output stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; + os->indent (); switch (this->direction ()) { @@ -153,6 +165,12 @@ int be_visitor_args_upcall_ss::visit_interface_fwd (be_interface_fwd *) TAO_OutStream *os = this->ctx_->stream (); // get output stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; + os->indent (); switch (this->direction ()) { @@ -189,6 +207,12 @@ int be_visitor_args_upcall_ss::visit_valuetype (be_valuetype *) TAO_OutStream *os = this->ctx_->stream (); // get output stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; + os->indent (); switch (this->direction ()) { @@ -223,6 +247,12 @@ int be_visitor_args_upcall_ss::visit_valuetype_fwd (be_valuetype_fwd *) TAO_OutStream *os = this->ctx_->stream (); // get output stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; + os->indent (); switch (this->direction ()) { @@ -260,6 +290,11 @@ int be_visitor_args_upcall_ss::visit_predefined_type (be_predefined_type *node) TAO_OutStream *os = this->ctx_->stream (); // get output stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; os->indent (); // check if the type is an any @@ -328,6 +363,11 @@ int be_visitor_args_upcall_ss::visit_sequence (be_sequence *) TAO_OutStream *os = this->ctx_->stream (); // get the stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; os->indent (); switch (this->direction ()) @@ -352,6 +392,11 @@ int be_visitor_args_upcall_ss::visit_string (be_string *) TAO_OutStream *os = this->ctx_->stream (); // get the stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; os->indent (); switch (this->direction ()) @@ -386,6 +431,11 @@ int be_visitor_args_upcall_ss::visit_structure (be_structure *node) TAO_OutStream *os = this->ctx_->stream (); // get the stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; os->indent (); switch (this->direction ()) @@ -413,6 +463,11 @@ int be_visitor_args_upcall_ss::visit_union (be_union *node) TAO_OutStream *os = this->ctx_->stream (); // get the stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS) + return 0; os->indent (); switch (this->direction ()) diff --git a/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp index b07cbd35be4..bf7f3a5bc36 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/vardecl_ss.cpp @@ -81,6 +81,12 @@ int be_visitor_args_vardecl_ss::visit_array (be_array *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -122,6 +128,40 @@ int be_visitor_args_vardecl_ss::visit_enum (be_enum *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + os->indent (); + *os << bt->name () << " " << arg->local_name () << ";" << be_nl + << bt->name () << "_forany _tao_forany_" + << arg->local_name () << " (" << be_idt << be_idt_nl + << arg->local_name () << be_uidt_nl + << ");\n" << be_uidt; + break; + + case AST_Argument::dir_OUT: + os->indent (); + if (node->size_type () == be_type::VARIABLE) + { + *os << bt->name () << "_var " << arg->local_name () + << ";\n\n"; + } + else + { + *os << bt->name () << " " << arg->local_name () + << ";\n\n"; + } + break; + } + return 0; + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -146,6 +186,12 @@ int be_visitor_args_vardecl_ss::visit_interface (be_interface *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -193,6 +239,16 @@ int be_visitor_args_vardecl_ss::visit_interface_fwd (be_interface_fwd *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -255,6 +311,13 @@ int be_visitor_args_vardecl_ss::visit_predefined_type (be_predefined_type *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + + // check if the type is an any if (node->pt () == AST_PredefinedType::PT_any) { @@ -339,6 +402,12 @@ int be_visitor_args_vardecl_ss::visit_sequence (be_sequence *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -368,6 +437,11 @@ int be_visitor_args_vardecl_ss::visit_string (be_string *) TAO_OutStream *os = this->ctx_->stream (); // get output stream be_argument *arg = this->ctx_->be_node_as_argument (); // get the argument // node + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; switch (this->direction ()) { @@ -412,6 +486,12 @@ int be_visitor_args_vardecl_ss::visit_structure (be_structure *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -454,6 +534,12 @@ int be_visitor_args_vardecl_ss::visit_union (be_union *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -529,6 +615,12 @@ int be_compiled_visitor_args_vardecl_ss::visit_interface (be_interface *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -557,6 +649,13 @@ int be_compiled_visitor_args_vardecl_ss::visit_interface_fwd (be_interface_fwd * else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -588,6 +687,12 @@ int be_compiled_visitor_args_vardecl_ss::visit_valuetype (be_valuetype *node) else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + switch (this->direction ()) { case AST_Argument::dir_IN: @@ -617,6 +722,12 @@ be_compiled_visitor_args_vardecl_ss::visit_valuetype_fwd (be_valuetype_fwd *node else bt = node; + // If we use it in conjunction with AMI Reply Handlers we do + // not want to generate declarations for IN arguments + if (this->direction () == AST_Argument::dir_IN + && this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS) + return 0; + switch (this->direction ()) { case AST_Argument::dir_IN: diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_skeleton_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_skeleton_cs.cpp index d55ba3e919c..8a386dc6212 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_skeleton_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_skeleton_cs.cpp @@ -25,8 +25,8 @@ #include "be_visitor_operation.h" ACE_RCSID(be_visitor_operation, ami_handler_skeleton_cs, "$Id$") - - + + // ************************************************************ // Operation visitor for client stubs // ************************************************************ @@ -58,13 +58,13 @@ be_visitor_operation_ami_handler_skeleton_cs::visit_operation (be_operation *nod be_type *bt; // type node be_visitor_context ctx; // visitor context be_visitor *visitor; // visitor - + os = this->ctx_->stream (); this->ctx_->node (node); // save the node for future use - + // Start with the current indentation level. os->indent (); - + // Init the return type variable. bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) @@ -89,7 +89,7 @@ be_visitor_operation_ami_handler_skeleton_cs::visit_operation (be_operation *nod "scopeless operation :-<\n"), -1); } - + // Genereate scope name. *os << parent->compute_name ("AMI_", "_Handler"); @@ -98,13 +98,15 @@ be_visitor_operation_ami_handler_skeleton_cs::visit_operation (be_operation *nod // Generate the argument list. *os << "TAO_InputCDR &_tao_reply_cdr, " << be_nl - << "Messaging::ReplyHandler_ptr _tao_reply_handler) - + << "Messaging::ReplyHandler_ptr _tao_reply_handler," << be_nl + << "CORBA::Environment &ACE_TRY_ENV"<< be_uidt << be_uidt_nl + << ")" << be_nl; + // 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 CORBA::Environment *os << "{" << be_idt_nl; - + // Deal with differences between IDL mapping for true C++ exceptions and // alternate mapping. Since our code uses the ACE_TRY_ENV variable in a // number of places, for the true exception case, we will have to explicitly @@ -116,7 +118,7 @@ be_visitor_operation_ami_handler_skeleton_cs::visit_operation (be_operation *nod 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 @@ -129,86 +131,88 @@ be_visitor_operation_ami_handler_skeleton_cs::visit_operation (be_operation *nod -1); } } + + os->indent(); + + *os << "// Retrieve Reply Handler object." << be_nl; + *os << parent->compute_name ("AMI_", "_Handler") << "_var " + << "_tao_reply_handler_object =" << be_idt_nl; + + *os << parent->compute_name ("AMI_", "_Handler") << + << "::_narrow(_tao_reply_handler, ACE_TRY_ENV);" << be_uidt_nl; + + +os << "ACE_CHECK;" << be_nl << be_nl + << "// @@ Error handling " << be_nl << be_nl; + + *os << "//Demarshall all the arguments." << be_nl; - // Declaring return type is not necessary. Since return type is - // void. + // declare a return type variable + be_visitor_context ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (bt->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) ami_handler_skeleton_cs::" + "visit_operation - " + "codegen for return var decl failed\n"), + -1); + } - // Native exists => no stub. - if (node->has_native ()) + // declare variables for arguments + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_DECL_CS); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (node->accept (visitor) == -1)) { - if (this->gen_raise_exception (bt, "CORBA::MARSHAL", "") == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ami_handler_skeleton_cs::" - "visit_operation - " - "codegen for return var failed\n"), - -1); - } + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) ami_handler_skeleton_cs::" + "visit_operation - " + "codegen for return var decl failed\n"), + -1); } - else + + // Demarshal parameters + if (this->gen_demarshal_params (node, bt) == -1) { - // Generate code that retrieves the underlying stub object and then - // invokes do_static_call on it. - *os << be_nl - << "TAO_Stub *istub = this->_stubobj ();" << be_nl - << "if (istub == 0)" << be_idt_nl; - - // If the stub object was bad, then we raise a system - // exception. - *os << "ACE_THROW (CORBA::INTERNAL ());"; - - *os << be_uidt_nl << be_nl; - - // do any pre marshal and invoke stuff with arguments - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_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_cs::" - "visit_operation - " - "codegen for marshal and invoke failed\n"), - -1); - - } - - // Return type is void, - - } // end of if (!native) - - *os << be_uidt_nl << "}\n\n"; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%1) ami_handler_skeleton_cs::" + "visit_operation - " + "gen_demarshal_params failed\n"), + -1); + } - // Generate the skeleton method. + // Invoke the callback method + *os << "// Invoke the call back method." << be_nl + << "_tao_reply_handler_object->" + << node->local_name () << " (" << be_idt_nl; - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_SKELETON_CS); - visitor = tao_cg->make_visitor (&Ctx); + // if we have a non-void return type then pass it as the first argument + if (!this->void_return_type (bt)) + *os << "_tao_ami_result," << be_nl; + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_UPCALL_CS); + visitor = tao_cg->make_visitor (&ctx); if (!visitor || (node->accept (visitor) == -1)) { delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_cs::" + "(%N:%l) ami_handler_skeleton_cs::" "visit_operation - " - "codegen for AMI Handler skeleton failed\n"), + "codegen for making upcall failed\n"), -1); } - delete visitor; - visitor = 0; + *os << be_uidt_nl << ");" << be_nl; + *os << "ACE_CHECK;" << be_nl; + + *os << be_uidt_nl << "}" << be_nl << be_nl; + + // Generate the skeleton method. + return 0; } @@ -216,7 +220,7 @@ int be_visitor_operation_ami_handler_skeleton_cs::visit_argument (be_argument *node) { // this method is used to generate the ParamData table entry - + TAO_OutStream *os = this->ctx_->stream (); be_type *bt; // argument type @@ -621,163 +625,56 @@ be_compiled_visitor_operation_ami_handler_skeleton_cs::gen_pre_stub_info (be_ope int be_compiled_visitor_operation_ami_handler_skeleton_cs:: -gen_marshal_and_invoke (be_operation *node, - be_type *bt) +gen_demarshal_params (be_operation *node, + be_type *bt) { TAO_OutStream *os = this->ctx_->stream (); be_visitor *visitor; be_visitor_context ctx; - - os->indent (); - - // 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 "; - } - *os << "(" << be_idt << be_idt_nl - << "istub," << be_nl; - - if (this->ctx_->attribute ()) - { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "\"_set_\""; - else - *os << "\"_get_\""; - } - - *os << "\"" << node->original_local_name () - << "\"," << be_nl - << "istub->orb_core ()" << be_uidt_nl - << ");" << be_uidt_nl; - - *os << "\n" << be_nl - << "for (;;)" << be_nl - << "{" << be_idt_nl; - - *os << "ACE_TRY_ENV.clear ();" << be_nl; - *os << "_tao_call.start (ACE_TRY_ENV);\n"; - // Check if there is an exception. - *os << "ACE_CHECK;"; - - // Now make sure that we have some AMI result parameter or OUT or - // INOUT parameters. Otherwise, there is nothing to be marshaled - // in. - if (!this->void_return_type (bt) || - this->has_param_type (node, AST_Argument::dir_OUT) || - this->has_param_type (node, AST_Argument::dir_INOUT)) + + if (!this->void_return_type (bt)) { - *os << be_nl - << "TAO_OutputCDR &_tao_out = _tao_call.out_stream ();" - << be_nl - << "if (!(\n" << be_idt << be_idt << be_idt; - - // Marshal the ami result argument, if the return type is not - // void. - if (!this->void_return_type (bt)) - { - *os << "(_tao_out << _tao_ami_result)"; - - // Print the && if there are OUT or INOUT arguements in the - // signature. - if (this->has_param_type (node, AST_Argument::dir_OUT) || - this->has_param_type (node, AST_Argument::dir_INOUT)) - *os << " &&"; - } - *os << be_nl; - -#if 0 - // @@ This for giving the _tao_ami_result argument only. But - // this may be needed for some data types. - // But the one that is above is ok for basic types. - // @@ We may need to do this. + // demarshal the return val ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RESULT_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DEMARSHAL_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); visitor = tao_cg->make_visitor (&ctx); if (!visitor || (node->accept (visitor) == -1)) { delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_compiled_visitor_operation_ami_handler_skeleton_cs::" - "gen_marshal_and_invoke - " - "codegen for return var in do_static_call failed\n"), + "gen_demarshal_params - " + "codegen for return var failed\n"), -1); } delete visitor; - visitor = 0; -#endif /* 0 */ - - // Marshal each out and inout argument. + visitor= 0; + } + + if (this->has_param_type (node, AST_Argument::dir_INOUT) || + this->has_param_type (node, AST_Argument::dir_OUT)) + { + // demarshal each in and inout argument ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_INVOKE_CS); - ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_MARSHAL_CS); + ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); visitor = tao_cg->make_visitor (&ctx); if (!visitor || (node->accept (visitor) == -1)) { delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_handler_skeleton_cs :" - "gen_marshal_and_invoke - " - "codegen for return var in do_static_call failed\n"), + "(%N:%l) be_compiled_visitor_operation_ami_handler_skeleton_cs::" + "gen_marshal_params - " + "codegen for args failed\n"), -1); } - *os << be_uidt << be_uidt_nl - << "))" << be_nl; - - // if marshaling fails, raise exception. - *os << "ACE_THROW (CORBA::MARSHAL ());"; - - *os << be_uidt; - } - - *os << be_nl - << "int _invoke_status =" << be_idt_nl; - if (node->flags () == AST_Operation::OP_oneway) - { - // oneway operation - *os << "_tao_call.invoke (ACE_TRY_ENV);"; - } - else - { - if (node->exceptions ()) - { - *os << "_tao_call.invoke (_tao_" << node->flatname () - << "_exceptiondata, " - << node->exceptions ()->length () - << ", ACE_TRY_ENV);"; - } - else - { - *os << "_tao_call.invoke (0, 0, ACE_TRY_ENV);"; - } + delete visitor; + visitor = 0; } - - *os << be_uidt_nl; - - // Check if there is an exception. - *os << "ACE_CHECK;"; - *os << be_nl - << "if (_invoke_status == TAO_INVOKE_RESTART)" << be_idt_nl - << "continue;" << be_uidt_nl - << "// if (_invoke_status == TAO_INVOKE_EXCEPTION)" << be_idt_nl - << "// cannot happen" << be_uidt_nl - << "if (_invoke_status != TAO_INVOKE_OK)" << be_nl - << "{" << be_idt_nl; - - // Check if there is an exception. - *os << "ACE_THROW (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES));"; - - *os << be_uidt_nl - << "}" << be_nl - << "break;" << be_nl - << be_uidt_nl << "}" << be_nl; + *os << be_uidt_nl << "))\n" << be_idt; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp index ef2a2f1a922..35dfb1fe475 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp @@ -56,10 +56,11 @@ be_visitor_operation_argument::post_process (be_decl *bd) switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_UPCALL_CS: case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS: case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: case TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS: - *os << ",\n"; + *os << "," << be_nl; break; default: break; @@ -90,6 +91,7 @@ be_visitor_operation_argument::visit_operation (be_operation *node) switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_UPCALL_CS: case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS: // applicable only to these cases where the actual upcall is made @@ -167,6 +169,9 @@ be_visitor_operation_argument::visit_argument (be_argument *node) case TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS: ctx.state (TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS); break; + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_DECL_CS: + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_VARDECL_CS); + break; case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: ctx.state (TAO_CodeGen::TAO_ARGUMENT_DEMARSHAL_SS); break; @@ -182,6 +187,9 @@ be_visitor_operation_argument::visit_argument (be_argument *node) case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); break; + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARG_UPCALL_CS: + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_ARGUMENT_UPCALL_CS); + break; case TAO_CodeGen::TAO_OPERATION_ARG_POST_UPCALL_SS: ctx.state (TAO_CodeGen::TAO_ARGUMENT_POST_UPCALL_SS); break; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_cs.cpp index 2dc75fbe214..1093490547c 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_cs.cpp @@ -56,7 +56,14 @@ be_visitor_operation_rettype_vardecl_cs::visit_array (be_array *node) bt = node; os->indent (); - *os << bt->name () << "_slice *_tao_retval = 0;\n\n"; + + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "_slice *_tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "_slice *_tao_retval = 0;"; + + *os << be_nl << be_nl; + return 0; } @@ -72,7 +79,13 @@ be_visitor_operation_rettype_vardecl_cs::visit_enum (be_enum *node) bt = node; os->indent (); - *os << bt->name () << " _tao_retval = (" << bt->name () << ")0;\n"; + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << " _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << " _tao_retval = (" << bt->name () << ")0;"; + + *os << be_nl << be_nl; + return 0; } @@ -88,7 +101,13 @@ be_visitor_operation_rettype_vardecl_cs::visit_interface (be_interface *node) bt = node; os->indent (); - *os << bt->name () << "_ptr _tao_retval = " << bt->name () << "::_nil ();\n"; + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "_ptr _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "_ptr _tao_retval = " << bt->name () << "::_nil ();"; + + *os << be_nl << be_nl; + return 0; } @@ -104,7 +123,13 @@ be_visitor_operation_rettype_vardecl_cs::visit_interface_fwd (be_interface_fwd * bt = node; os->indent (); - *os << bt->name () << "_ptr _tao_retval = " << bt->name () << "::_nil ();\n"; + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "_ptr _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "_ptr _tao_retval = " << bt->name () << "::_nil ();"; + + *os << be_nl << be_nl; + return 0; } @@ -122,7 +147,14 @@ be_visitor_operation_rettype_vardecl_cs::visit_valuetype (be_valuetype *node) bt = node; os->indent (); - *os << bt->name () << "* _tao_retval = 0;\n"; + + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "* _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "* _tao_retval = 0;"; + + *os << be_nl << be_nl; + return 0; } @@ -138,7 +170,13 @@ be_visitor_operation_rettype_vardecl_cs::visit_valuetype_fwd (be_valuetype_fwd * bt = node; os->indent (); - *os << bt->name () << "* _tao_retval = 0;\n"; + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "* _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "* _tao_retval = 0;"; + + *os << be_nl << be_nl; + return 0; } @@ -159,19 +197,31 @@ be_visitor_operation_rettype_vardecl_cs::visit_predefined_type (be_predefined_ty { case AST_PredefinedType::PT_pseudo: os->indent (); - *os << bt->name () << "_ptr _tao_retval = 0;\n"; + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "_ptr _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "_ptr _tao_retval = 0;"; break; case AST_PredefinedType::PT_any: os->indent (); - *os << bt->name () << " *_tao_retval = 0;\n"; + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "* _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "* _tao_retval = 0;"; break; case AST_PredefinedType::PT_void: break; default: os->indent (); - *os << bt->name () << " _tao_retval = 0;\n"; + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << " _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << " _tao_retval = 0;"; break; } + + *os << be_nl << be_nl; + return 0; } @@ -189,7 +239,12 @@ be_visitor_operation_rettype_vardecl_cs::visit_sequence (be_sequence *node) bt = node; os->indent (); - *os << bt->name () << " *_tao_retval = 0;\n"; + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "* _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "* _tao_retval = 0;"; + + *os << be_nl << be_nl; return 0; } @@ -199,7 +254,12 @@ be_visitor_operation_rettype_vardecl_cs::visit_string (be_string * /* node*/) TAO_OutStream *os = this->ctx_->stream (); // grab the out stream os->indent (); - *os << "char *_tao_retval = 0;\n"; + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) + *os << bt->name () << "char* _tao_ami_result;"; + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + *os << "char* _tao_retval = 0;"; + + *os << be_nl << be_nl; return 0; } @@ -215,14 +275,34 @@ be_visitor_operation_rettype_vardecl_cs::visit_structure (be_structure *node) bt = node; os->indent (); - // based on whether we are variable or not, we return a pointer or the - // aggregate type - if (node->size_type () == be_decl::VARIABLE) - *os << bt->name () << " *_tao_retval = 0;\n"; - else + + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) { - *os << bt->name () << " _tao_retval;" << be_nl; - *os << "ACE_OS::memset (&_tao_retval, 0, sizeof (" << bt->name () << "));\n"; + // based on whether we are variable or not, we return a pointer or the + // aggregate type + if (node->size_type () == be_decl::VARIABLE) + { + *os << bt->name () << "* _tao_ami_result;" << be_nl; + } + else + { + *os << bt->name () << " _tao_ami_result;" << be_nl; + } + } + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + { + // based on whether we are variable or not, we return a pointer or the + // aggregate type + if (node->size_type () == be_decl::VARIABLE) + { + *os << bt->name () << "* _tao_retval = 0;" << be_nl; + } + else + { + *os << bt->name () << " _tao_retval;" << be_nl; + *os << "ACE_OS::memset (&_tao_retval, 0, sizeof (" << bt->name () << "));" + << be_nl; + } } return 0; } @@ -255,13 +335,34 @@ be_visitor_operation_rettype_vardecl_cs::visit_union (be_union *node) bt = node; os->indent (); - // based on whether we are variable or not, we return a pointer or the - // aggregate type - if (node->size_type () == be_decl::VARIABLE) - *os << bt->name () << " *_tao_retval = 0;\n"; - else + + if (this->ctx_->state() == TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_RETVAL_DECL_CS) { - *os << bt->name () << " _tao_retval;\n"; + // based on whether we are variable or not, we return a pointer or the + // aggregate type + if (node->size_type () == be_decl::VARIABLE) + { + *os << bt->name () << "* _tao_ami_result = 0;"; + } + else + { + *os << bt->name () << " _tao_ami_result;"; + } } + else if (this->ctx_->state() == TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS) + { + // based on whether we are variable or not, we return a pointer or the + // aggregate type + if (node->size_type () == be_decl::VARIABLE) + { + *os << bt->name () << "* _tao_retval = 0;"; + } + else + { + *os << bt->name () << " _tao_retval;"; + } + } + + *os << be_nl; return 0; } |