diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-01-28 19:41:52 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-01-28 19:41:52 +0000 |
commit | c2567583e0d36e806faf02de95847b3da4080df7 (patch) | |
tree | b2571cc48dc1c1168b10a43e28433b74ac8a4c09 /TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp | |
parent | 1c5ac6ad2f543502652e0ddc6520e2424163bf51 (diff) | |
download | ATCD-c2567583e0d36e806faf02de95847b3da4080df7.tar.gz |
ChangeLogTag:Mon Jan 28 11:38:22 2002 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp')
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp | 219 |
1 files changed, 111 insertions, 108 deletions
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 470e0e5a5cd..2b21a13be43 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp @@ -35,47 +35,88 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); - if (this->generate_shared_prolog (node, os, "") == -1) + if (this->generate_shared_prologue (node, os, "") == -1) return -1; - { - // Declare variables for arguments. - be_visitor_context ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor || (node->accept (visitor) == -1)) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_operation_ss::" - "visit_operation - " - "codegen for return var decl failed\n"), - -1); - } - delete visitor; - } - int argument_count = node->count_arguments_with_direction (AST_Argument::dir_IN | AST_Argument::dir_INOUT); if (argument_count != 0) { - // Avoid warnings in generated code due to unused arguments. + // Declare variables for arguments. + be_visitor_context vardecl_ctx = *this->ctx_; + vardecl_ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); + + be_visitor_args_vardecl_ss vardecl_visitor (&vardecl_ctx); + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) + { + be_argument *argument = + be_argument::narrow_from_decl (si.item ()); + + if (argument == 0 + || argument->direction () == AST_Argument::dir_OUT) + continue; + + if (vardecl_visitor.visit_argument (argument) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_operation_ss::" + "visit_operation - " + "codegen for return var decl failed\n"), + -1); + } + } + + *os << be_nl << "TAO_InputCDR &_tao_in =" - << " _tao_server_request.incoming ();\n\n"; - } + << " _tao_server_request.incoming ();\n" << be_nl + << "if (!(1" << be_idt_nl; - // Demarshal parameters. - if (this->demarshal_params (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_operation_ss::" - "visit_operation - " - "demarshal_params failed\n"), - -1); + // Marshal each in and inout argument. + be_visitor_context marshal_ctx = *this->ctx_; + marshal_ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS); + marshal_ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); + + be_visitor_args_marshal_ss marshal_visitor (&marshal_ctx); + for (UTL_ScopeActiveIterator sj (node, UTL_Scope::IK_decls); + !sj.is_done (); + sj.next ()) + { + be_argument *argument = + be_argument::narrow_from_decl (sj.item ()); + if (argument == 0 + || argument->direction () == AST_Argument::dir_OUT) + continue; + + *os << "&& "; + + if (marshal_visitor.visit_argument (argument) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_compiled_visitor_operation_ss::" + "visit_operation - " + "codegen for demarshal failed\n"), + -1); + } + *os << be_nl; + } + + *os << "))" << be_nl; + + // 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"; } if (this->generate_shared_section (node, os, argument_count) == -1) @@ -84,15 +125,30 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) { be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS); - be_visitor_operation_argument visitor (&ctx); - if (node->accept (&visitor) == -1) + be_visitor_args_upcall_ss visitor (&ctx); + + for (UTL_ScopeActiveIterator i (node, UTL_Scope::IK_decls); + !i.is_done (); + i.next ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_operation_ss::" - "visit_operation - " - "codegen for upcall args failed\n"), - -1); + be_argument *argument = + be_argument::narrow_from_decl (i.item ()); + if (argument == 0 + || argument->direction () == AST_Argument::dir_OUT) + continue; + + *os << ","; + if (argument->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_operation_ss::" + "visit_operation - " + "codegen for upcall args failed\n"), + -1); + } + *os << be_nl; } + *os << "TAO_ENV_ARG_PARAMETER"; } if (this->generate_shared_epilogue (os) == -1) @@ -108,7 +164,7 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); - if (this->generate_shared_prolog (node, os, "_get_") == -1) + if (this->generate_shared_prologue (node, os, "_get_") == -1) return -1; if (this->generate_shared_section (node, os, 0) == -1) @@ -122,7 +178,7 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) if (node->readonly ()) return 0; - if (this->generate_shared_prolog (node, os, "_set_") == -1) + if (this->generate_shared_prologue (node, os, "_set_") == -1) return -1; be_argument the_argument (AST_Argument::dir_IN, @@ -151,25 +207,25 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) if (visitor.visit_argument (&the_argument) == -1) return -1; + } - *os << be_uidt_nl << "))" << be_idt_nl; + *os << be_uidt_nl << "))" << be_idt_nl; - // 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"; - } + // 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"; if (this->generate_shared_section (node, os, 1) == -1) return -1; - *os << node->local_name () + *os << ", " << node->local_name () << be_nl << "TAO_ENV_ARG_PARAMETER"; if (this->generate_shared_epilogue (os) == -1) @@ -179,9 +235,9 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) } int -be_visitor_amh_operation_ss::generate_shared_prolog (be_decl *node, - TAO_OutStream *os, - const char *skel_prefix) +be_visitor_amh_operation_ss::generate_shared_prologue (be_decl *node, + TAO_OutStream *os, + const char *skel_prefix) { *os << "// TAO_IDL - Generated from " << __FILE__ << ":" << __LINE__ << be_nl; @@ -263,9 +319,6 @@ be_visitor_amh_operation_ss::generate_shared_section (be_decl *node, << node->local_name () << " (_tao_rh.in ()" << be_idt << be_idt_nl; - if (argument_count != 0) - *os << ","; - return 0; } @@ -278,53 +331,3 @@ be_visitor_amh_operation_ss::generate_shared_epilogue (TAO_OutStream *os) return 0; } - -int -be_visitor_amh_operation_ss::demarshal_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 - // is nothing to be marshaled in. - if (this->has_param_type (node, AST_Argument::dir_IN) || - this->has_param_type (node, AST_Argument::dir_INOUT)) - { - os->indent (); - - // demarshal the in and inout arguments - *os << "if (!(\n" << be_idt; - - // Marshal each in and inout argument. - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS); - 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_ss::" - "gen_demarshal_params - " - "codegen for demarshal failed\n"), - -1); - } - - *os << be_uidt_nl << "))" << be_idt_nl; - - // 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; -} |