diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-15 02:01:38 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-05-15 02:01:38 +0000 |
commit | b234c2916c3491857a513f95abffa449d2c5c6b7 (patch) | |
tree | 31c071dc6dcc7f6a36112257784f620b3a1cb402 | |
parent | bf6365f6d8c82609b9dc5775b79b6ec6fb67c54c (diff) | |
download | ATCD-b234c2916c3491857a513f95abffa449d2c5c6b7.tar.gz |
ChangeLogTag:Fri May 14 21:00:21 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
6 files changed, 170 insertions, 22 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_cs.cpp index 5a48798d678..e8105746d40 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/compiled_marshal_cs.cpp @@ -170,19 +170,16 @@ int be_visitor_args_compiled_marshal_cs::visit_array (be_array *node) case AST_Argument::dir_IN: break; case AST_Argument::dir_INOUT: - *os << node->name () << "_forany (" - << arg->local_name () << ")"; + *os << "_tao_argument_" << arg->local_name (); break; case AST_Argument::dir_OUT: if (node->size_type () == be_decl::VARIABLE) { - *os << node->name () << "_forany (" - << arg->local_name () << ".ptr ())"; + *os << "_tao_argument_" << arg->local_name (); } else { - *os << node->name () << "_forany (" - << arg->local_name () << ")"; + *os << "_tao_argument_" << arg->local_name (); } break; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp index 221eeb62daf..b0ef3c02985 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp @@ -30,7 +30,7 @@ ACE_RCSID(be_visitor_operation, argument_marshal, "$Id$") // ************************************************************ -// operation visitor to handle the passing of arguments to the CDR operators +// operation visitor to handle the passing of arguments to the CDR operators // ************************************************************ be_compiled_visitor_operation_argument_marshal:: @@ -68,7 +68,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) @@ -80,13 +80,13 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } break; @@ -98,7 +98,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } break; @@ -129,12 +129,12 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) case AST_Argument::dir_IN: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_IN; + be_compiled_visitor_operation_argument_marshal::TAO_ARG_IN; break; case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_INOUT; + be_compiled_visitor_operation_argument_marshal::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // these arguments don't get printed for the << operator on the stub @@ -150,12 +150,12 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_INOUT; + be_compiled_visitor_operation_argument_marshal::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_OUT; + be_compiled_visitor_operation_argument_marshal::TAO_ARG_OUT; break; } break; @@ -170,3 +170,116 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) return 0; } +// **************************************************************** + +be_visitor_compiled_args_decl::be_visitor_compiled_args_decl (be_visitor_context *ctx) + : be_visitor_scope (ctx) +{ +} + +int +be_visitor_compiled_args_decl::visit_operation (be_operation *node) +{ + return this->visit_scope (node); +} + +int +be_visitor_compiled_args_decl::visit_argument (be_argument *node) +{ + this->ctx_->node (node); // save the argument node + + // retrieve the type of the argument + be_type *bt = be_type::narrow_from_decl (node->field_type ()); + + return bt->accept (this); +} + +// visit array +int +be_visitor_compiled_args_decl::visit_array (be_array *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + // retrieve the field node + be_argument *f = this->ctx_->be_node_as_argument (); + if (f == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_compiled_args_decl::" + "visit_array - " + "cannot retrieve argument node\n" + ), -1); + } + + // for anonymous arrays, the type name has a _ prepended. We compute + // the fullname with or without the underscore and use it later on. + char fname [NAMEBUFSIZE]; // to hold the full and + + ACE_OS::memset (fname, '\0', NAMEBUFSIZE); + if (!this->ctx_->alias () // not a typedef + && node->is_child (this->ctx_->scope ())) + { + // for anonymous arrays ... + // we have to generate a name for us that has an underscope + // prepended to our local name. This needs to be inserted after + // the parents's name + + if (node->is_nested ()) + { + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + ACE_OS::sprintf (fname, "%s::_%s", parent->fullname (), + node->local_name ()->get_string ()); + } + else + { + ACE_OS::sprintf (fname, "_%s", node->fullname ()); + } + } + else + { + // typedefed node + ACE_OS::sprintf (fname, "%s", node->fullname ()); + } + + if (f->direction () != AST_Argument::dir_IN) + { + *os << fname << "_forany " + << "_tao_argument_" << f->local_name () << " (" + << be_idt << be_idt_nl; + *os << f->local_name (); + if (f->direction () == AST_Argument::dir_OUT) + { + // *os << ".ptr ()"; + } +#if 0 + *os << "(ACE_const_cast (" << be_idt << be_idt_nl + << fname << "_slice*," << be_nl + << f->local_name () << be_uidt_nl + << ")" << be_uidt; +#endif + *os << be_uidt_nl << ");" << be_uidt_nl; + } + return 0; +} + +// visit typedef type +int +be_visitor_compiled_args_decl::visit_typedef (be_typedef *node) +{ + this->ctx_->alias (node); + + // the node to be visited in the base primitve type that gets typedefed + be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_compiled_args_decl::" + "visit_typedef - " + "Bad primitive type\n" + ), -1); + } + + this->ctx_->alias (0); + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/compiled_marshal.cpp b/TAO/TAO_IDL/be/be_visitor_operation/compiled_marshal.cpp index 4ae2012f87d..6014e7af16a 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/compiled_marshal.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/compiled_marshal.cpp @@ -129,8 +129,9 @@ int be_visitor_operation_rettype_compiled_marshal::visit_array (be_array *node) } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { - *os << node->name () << "_forany (" - << "_tao_retval" << ")"; + *os << "_tao_retval_forany"; + // *os << node->name () << "_forany (" + // << "_tao_retval" << ")"; } else { 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 fb0fed7fe57..9df843f51c1 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp @@ -619,17 +619,15 @@ int be_compiled_visitor_operation_cs::gen_pre_stub_info (be_operation *node, be_type *) { - be_visitor *visitor; - be_visitor_context ctx; // Check if this operation raises any exceptions. In that case, we must // generate a list of exception typecodes. This is not valid for // attributes if (!this->ctx_->attribute ()) { - ctx = *this->ctx_; + be_visitor_context ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor *visitor = tao_cg->make_visitor (&ctx); if (!visitor || (node->accept (visitor) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, @@ -641,6 +639,8 @@ be_compiled_visitor_operation_cs::gen_pre_stub_info (be_operation *node, } } + TAO_OutStream *os = this->ctx_->stream (); + return 0; } @@ -814,6 +814,19 @@ be_compiled_visitor_operation_cs::gen_marshal_and_invoke (be_operation "codegen for args in post do_static_call\n"), -1); } + + + // Generate any temporary variables to demarshal the arguments + be_visitor_context ctx = *this->ctx_; + be_visitor_compiled_args_decl visitor (&ctx); + if (node->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_compiled_visitor_operation_cs::" + "gen_pre_stub_info - " + "codegen for pre args failed\n"), + -1); + } // check if there was a user exception, else demarshal the // return val (if any) and parameters (if any) that came with // the response message 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 c713feb4258..d564a97ca8f 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,9 @@ be_visitor_operation_rettype_vardecl_cs::visit_array (be_array *node) bt = node; os->indent (); - *os << bt->name () << "_slice *_tao_retval = 0;\n"; + *os << bt->name () << "_slice *_tao_retval = 0;" << be_nl + << node->name () << "_forany _tao_retval_forany (" + << "_tao_retval" << ");\n"; return 0; } diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/argument_marshal.h b/TAO/TAO_IDL/be_include/be_visitor_operation/argument_marshal.h index e483d001735..2a4802db351 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/argument_marshal.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/argument_marshal.h @@ -63,4 +63,26 @@ private: LAST_ARG_PRINTED last_arg_printed_; }; +// **************************************************************** + +class be_visitor_compiled_args_decl : public be_visitor_scope +{ + // + // = TITLE + // be_visitor_compiled_args_decl + // + // = DESCRIPTION + // This is a visitor to generate variables declarations in the + // compiled marshaling stubs. + // +public: + be_visitor_compiled_args_decl (be_visitor_context *ctx); + // constructor + + int visit_array (be_array *node); + int visit_typedef (be_typedef *node); + int visit_argument (be_argument *node); + int visit_operation (be_operation *node); +}; + #endif /* _BE_VISITOR_OPERATION_ARGUMENT_MARSHAL_H_ */ |