diff options
author | alex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-19 20:57:57 +0000 |
---|---|---|
committer | alex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-06-19 20:57:57 +0000 |
commit | 1180d651510ce6c868961edae0c9371b0989a20c (patch) | |
tree | eb1989544572bfa204d842863c3b3593bb4e76e5 | |
parent | d168312421a14d0f606254d61003e290eaf5eb1a (diff) | |
download | ATCD-1180d651510ce6c868961edae0c9371b0989a20c.tar.gz |
Sat Jun 19 15:46:22 1999 Alexander Babu Arulanthu <alex@cs.wustl.edu>
17 files changed, 3101 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_argument/ami_arglist.cpp b/TAO/TAO_IDL/be/be_visitor_argument/ami_arglist.cpp new file mode 100644 index 00000000000..943b74b6a3f --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_argument/ami_arglist.cpp @@ -0,0 +1,323 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// arglist.cpp +// +// = DESCRIPTION +// Visitor that generates the parameters in an Operation signature +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#include "idl.h" +#include "be.h" +#include "be_visitor_argument.h" + +ACE_RCSID(be_visitor_argument, ami_arglist, "$Id$") + + +// ************************************************************ +// be_visitor_args_arglist for parameter list in method declarations and +// definitions for AMI stubs. +// ************************************************************ + +be_visitor_args_ami_arglist::be_visitor_args_ami_arglist (be_visitor_context *ctx) + : be_visitor_args (ctx) +{ +} + +be_visitor_args_ami_arglist::~be_visitor_args_ami_arglist (void) +{ +} + +int +be_visitor_args_ami_arglist::visit_argument (be_argument *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + this->ctx_->node (node); // save the argument node + + // retrieve the type + be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_args_arglist::" + "visit_argument - " + "Bad argument type\n"), + -1); + } + + os->indent (); // start with current indentation level + + // Different types have different mappings when used as in/out or + // inout parameters. Let this visitor deal with the type + + int result = bt->accept (this); + if (result == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_args_arglist::" + "visit_argument - " + "cannot accept visitor\n"), + -1); + } + + // Print the variable name only if the type was printed already. + if (result) + *os << " " << node->local_name () << ",\n"; + + return 0; +} + +int +be_visitor_args_ami_arglist::visit_array (be_array *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << "const " << this->type_name (node); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_enum (be_enum *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << this->type_name (node); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_interface (be_interface *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: // inout + *os << this->type_name (node, "_ptr"); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_interface_fwd (be_interface_fwd *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: // inout + *os << this->type_name (node, "_ptr"); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_native (be_native *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << this->type_name (node); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_predefined_type (be_predefined_type *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + // check if the type is an any + if (node->pt () == AST_PredefinedType::PT_any) + { + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << "const " << this->type_name (node) << " &"; + return 1; + /* NOT REACHED */ + } + } + else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object + { + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << this->type_name (node, "_ptr"); + return 1; + /* NOT REACHED */ + } // end switch direction + } // end else if + else // simple predefined types + { + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << this->type_name (node); + return 1; + /* NOT REACHED */ + } // end switch direction + } // end of else + + return 0; +} + +int +be_visitor_args_ami_arglist::visit_sequence (be_sequence *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << "const " << this->type_name (node) << " &"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_string (be_string *) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << "const char *"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_structure (be_structure *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << "const " << this->type_name (node) << " &"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_union (be_union *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << "const " << this->type_name (node) << " &"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_typedef (be_typedef *node) +{ + this->ctx_->alias (node); + + int result = node->primitive_base_type ()->accept (this); + if (result == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_args_ami_arglist::" + "visit_typedef - " + "accept on primitive type failed\n"), + -1); + } + + this->ctx_->alias (0); + + return result; +} + + +#ifdef IDL_HAS_VALUETYPE + +int +be_visitor_args_ami_arglist::visit_valuetype (be_valuetype *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << this->type_name (node) << " *"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_arglist::visit_valuetype_fwd (be_valuetype_fwd *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_IN: + case AST_Argument::dir_INOUT: + *os << "const " << this->type_name (node) << " *"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +#endif /* IDL_HAS_VALUETYPE */ diff --git a/TAO/TAO_IDL/be/be_visitor_argument/ami_handler_arglist.cpp b/TAO/TAO_IDL/be/be_visitor_argument/ami_handler_arglist.cpp new file mode 100644 index 00000000000..8ccbe559bb4 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_argument/ami_handler_arglist.cpp @@ -0,0 +1,320 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_arglist.cpp +// +// = DESCRIPTION +// Visitor that generates the parameters in an operation of the AMI +// Reply Handler. +// +// = AUTHOR +// Aniruddha Gokhale and Alexander Babu Arulanthu +// <alex@cs.wustl.edu> +// +// ============================================================================ + +#include "idl.h" +#include "be.h" +#include "be_visitor_argument.h" + +ACE_RCSID(be_visitor_argument, ami_handler_arglist, "$Id$") + + +// ************************************************************ +// Visitor for parameter list in AMI Handler call back declarations +// and definitions. +// ************************************************************ + +be_visitor_args_ami_handler_arglist::be_visitor_args_ami_handler_arglist (be_visitor_context *ctx) + : be_visitor_args (ctx) +{ +} + +be_visitor_args_ami_handler_arglist::~be_visitor_args_ami_handler_arglist (void) +{ +} + +int +be_visitor_args_ami_handler_arglist::visit_argument (be_argument *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + this->ctx_->node (node); // save the argument node + + // retrieve the type + be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_args_ami_handler_arglist::" + "visit_argument - " + "Bad argument type\n"), + -1); + } + + os->indent (); // start with current indentation level + + // Different types have different mappings when used as in/out or + // inout parameters. Let this visitor deal with the type + + int result = bt->accept (this); + if (result == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_args_ami_handler_arglist::" + "visit_argument - " + "cannot accept visitor\n"), + -1); + } + // Print the variable name only if the type was printed already. + if (result) + *os << " " << node->local_name () << ",\n"; + + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_array (be_array *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << "const " << this->type_name (node); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_enum (be_enum *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << this->type_name (node); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_interface (be_interface *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << this->type_name (node, "_ptr"); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_interface_fwd (be_interface_fwd *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << this->type_name (node, "_ptr"); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_native (be_native *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << this->type_name (node); + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_predefined_type (be_predefined_type *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get output stream + + // check if the type is an any + if (node->pt () == AST_PredefinedType::PT_any) + { + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << "const " << this->type_name (node) << " &"; + return 1; + /* NOT REACHED */ + } // end switch direction + } // end of if + else if (node->pt () == AST_PredefinedType::PT_pseudo) // e.g., CORBA::Object + { + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << this->type_name (node, "_ptr"); + return 1; + /* NOT REACHED */ + } // end switch direction + } // end else if + else // simple predefined types + { + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << this->type_name (node); + return 1; + /* NOT REACHED */ + } // end switch direction + } // end of else + + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_sequence (be_sequence *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << "const " << this->type_name (node) << " &"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_string (be_string *) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << "const char *"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_structure (be_structure *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << "const " << this->type_name (node) << " &"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_union (be_union *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << "const " << this->type_name (node) << " &"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_typedef (be_typedef *node) +{ + this->ctx_->alias (node); + if (node->primitive_base_type ()->accept (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_args_ami_handler_arglist::" + "visit_typedef - " + "accept on primitive type failed\n"), + -1); + } + this->ctx_->alias (0); + return 0; +} + + +#ifdef IDL_HAS_VALUETYPE + +int +be_visitor_args_ami_handler_arglist::visit_valuetype (be_valuetype *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << this->type_name (node) << " *"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +int +be_visitor_args_ami_handler_arglist::visit_valuetype_fwd (be_valuetype_fwd *node) +{ + TAO_OutStream *os = this->ctx_->stream (); // get the stream + + switch (this->direction ()) + { + case AST_Argument::dir_INOUT: + case AST_Argument::dir_OUT: + *os << "const " << this->type_name (node) << " *"; + return 1; + /* NOT REACHED */ + } + return 0; +} + +#endif /* IDL_HAS_VALUETYPE */ diff --git a/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_ch.cpp new file mode 100644 index 00000000000..857630cdbe5 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_interface/ami_handler_ch.cpp @@ -0,0 +1,233 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_ch.cpp +// +// = DESCRIPTION +// Visitor generating AMI Reply Handler code for Interfaces in the +// client header. +// +// = AUTHOR +// Aniruddha Gokhale and Alexander Babu Arulanthu +// <alex@cs.wustl.edu> +// +// ============================================================================ + +#include "idl.h" +#include "idl_extern.h" +#include "be.h" + +#include "be_visitor_interface.h" + +ACE_RCSID(be_visitor_interface, ami_handler_ch, "$Id$") + + +// ************************************************************ +// Interface visitor for server header +// ************************************************************ + +be_visitor_interface_ami_handler_ch::be_visitor_interface_ami_handler_ch (be_visitor_context *ctx) + : be_visitor_interface (ctx) +{ +} + +be_visitor_interface_ami_handler_ch::~be_visitor_interface_ami_handler_ch (void) +{ +} + +int +be_visitor_interface_ami_handler_ch::visit_interface (be_interface *node) +{ + TAO_OutStream *os; // output stream + static char namebuf [NAMEBUFSIZE]; // holds the class name + + if (node->srv_hdr_gen () || node->imported ()) + return 0; + + ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); + + os = this->ctx_->stream (); + + // Generate the skeleton class name. + + // Start with whatever indentation level we are at. + os->indent (); + + // We shall have a POA_ prefix only if we are at the topmost level. + if (!node->is_nested ()) + { + // we are outermost + ACE_OS::sprintf (namebuf, + "POA_AMI_%s_Handler", + node->local_name ()->get_string ()); + } + else + { + ACE_OS::sprintf (namebuf, + "AMI_%s_Handler", + node->local_name ()->get_string ()); + } + + *os << "class " << namebuf << ";" << be_nl; + + // generate the _ptr declaration + *os << "typedef " << namebuf << " *" << namebuf + << "_ptr;" << be_nl; + + // Now generate the class definition. + // This class will inherit from the Messaging::ReplyHandler class. + *os << "class " << idl_global->export_macro () + << " " << namebuf + << " : public POA_Messaging::ReplyHandler" + << be_nl; + + // Body of the class definition. + *os << be_nl + << "{" << be_nl; + + // Default constructor. + *os << "protected:" << be_idt_nl + << namebuf << " (void);\n" << be_uidt_nl; + + // Public portion starts. + *os << "public:" << be_idt_nl + + // Copy constructor. + << namebuf << " (const " << namebuf << "& rhs);" << be_nl + + // Destructor. + << "virtual ~" << namebuf << " (void);\n\n" + + << be_nl; + + // Methods. + + // _is_a. + *os << "virtual CORBA::Boolean _is_a (" << be_idt << be_idt_nl + << "const char* logical_type_id," << be_nl + << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl + << "TAO_default_environment ()" + << be_uidt << be_uidt_nl + << ");\n" << be_uidt_nl; + + // _down_cast. + *os << "virtual void* _downcast (" << be_idt << be_idt_nl + << "const char* logical_type_id" << be_uidt_nl + << ");\n" << be_uidt_nl; + + // add a skeleton for our _is_a method + *os << "static void _is_a_skel (" << be_idt << be_idt_nl + << "CORBA::ServerRequest &req," << be_nl + << "void *obj," << be_nl + << "void *context," << be_nl + << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl + << "TAO_default_environment ()" + << be_uidt << be_uidt_nl + << ");\n" << be_uidt_nl; + + // add a skeleton for our _non_existent method + *os << "static void _non_existent_skel (" << be_idt << be_idt_nl + << "CORBA::ServerRequest &req," << be_nl + << "void *obj," << be_nl + << "void *context," << be_nl + << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl + << "TAO_default_environment ()" + << be_uidt << be_uidt_nl + << ");\n" << be_uidt_nl; + + // add the dispatch method + *os << "virtual void _dispatch (" << be_idt << be_idt_nl + << "CORBA::ServerRequest &_tao_req," << be_nl + << "void *_tao_context," << be_nl + << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl + << "TAO_default_environment ()" + << be_uidt << be_uidt_nl + << ");\n" << be_uidt_nl; + + // Print out the _this() method. + *os << node->name () << " *_this (" << be_idt << be_idt_nl + << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl + << "TAO_default_environment ()" + << be_uidt << be_uidt_nl + << ");\n" << be_uidt_nl; + + // The _interface_repository_id method. + *os << "virtual const char* _interface_repository_id " + << "(void) const;\n\n"; + + // The _create_collocated_objref method. + *os << "virtual void* _create_collocated_objref" + << "(const char*, CORBA::ULong type, TAO_Stub *sobj);" + << be_nl << be_nl; + + // Generate code for elements in the scope (e.g., operations). + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ami_handler_ch::" + "visit_interface - " + "codegen for scope failed\n"), + -1); + } + + // Generate skeletons for operations of our base classes. These skeletons + // just cast the pointer to the appropriate type before invoking the call. + if (node->traverse_inheritance_graph (be_interface::gen_skel_helper, os) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ami_handler_ch::" + "visit_interface - " + "inheritance graph traversal failed\n"), + -1); + } + + *os << be_uidt_nl << "};\n\n"; + +#if 0 + // + // @@ Alex: Do this: + // + // Generate the collocated class + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_INTERFACE_COLLOCATED_SH); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (node->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ami_handler_ch::" + "visit_interface - " + "codegen for collocated class failed\n"), + -1); + } + + // generate the TIE class. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SH); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (node->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_interface_ami_handler_ch::" + "visit_interface - " + "codegen for TIE class failed\n"), + -1); + } +#endif /* 0 */ + + *os << "\n"; + +#if 0 + ctx.stream (tao_cg->server_template_header ()); +#endif /* 0 */ + + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_arglist.cpp new file mode 100644 index 00000000000..bda8132715e --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_arglist.cpp @@ -0,0 +1,174 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_arglist.cpp +// +// = DESCRIPTION +// Visitor generating code for the parameter list of the Operation signature. +// +// = AUTHOR +// Alexander Babu Arulanthu <alex@cs.wustl.edu> +// +// ============================================================================ + +#include "idl.h" +#include "idl_extern.h" +#include "be.h" + +#include "be_visitor_operation.h" + +ACE_RCSID(be_visitor_operation, ami_arglist, "$Id$") + + +// ************************************************************ +// operation visitor to generate the argument list for the AMI +// stub. +// We have separated code generation for this from the 4 main +// visitors to avoid code duplication and tight coupling + // ************************************************************ + +be_visitor_operation_ami_arglist::be_visitor_operation_ami_arglist (be_visitor_context + *ctx) + : be_visitor_scope (ctx) +{ +} + +be_visitor_operation_ami_arglist::~be_visitor_operation_ami_arglist (void) +{ +} + +int +be_visitor_operation_ami_arglist::visit_operation (be_operation *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + *os << " (" << be_idt << be_idt << "\n"; + + + // Start with current indentation level. + os->indent (); + + + be_decl *interface = + be_interface::narrow_from_scope (node->defined_in ())->decl (); + if (interface == 0) + cerr << "Invalid interface"; + + // AMI Handler argument. + *os << "AMI_" + << interface->fullname () + << "_ptr " + << "ami_handler" + << ",\n"; + // #endif /* TAO_IDL_HAS_AMI */ + + // all we do is hand over code generation to our scope + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_arglist::" + "visit_operation - " + "codegen for scope failed\n"), + -1); + } + + + // @@ When some out arguments are skipped, the indentation seems to + // get messed up. Fix that. (Alex). + + // Last argument - is always CORBA::Environment. + os->indent (); + *os << "CORBA::Environment &ACE_TRY_ENV"; + *os << " = " << be_idt_nl + << "TAO_default_environment ()" + << be_uidt; + + // Done with the argument list. + *os << be_uidt_nl << ")" << be_uidt << "\n"; + + return 0; +} + +int +be_visitor_operation_ami_arglist::visit_argument (be_argument *node) +{ + // Get the visitor that will dump the argument's mapping in the operation + // signature. + be_visitor_context ctx (*this->ctx_); + + // First grab the interface definition inside which this operation is + // defined. We need this since argument types may very well be declared + // inside the scope of the interface node. In such cases, we would like to + // generate the appropriate relative scoped names. + be_operation *op = this->ctx_->be_scope_as_operation (); + if (!op) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_arglist::" + "visit_argument - " + "Bad operation\n"), + -1); + } + + // We need the interface node in which this operation was defined. However, + // if this operation node was an attribute node in disguise, we get this + // information from the context + be_interface *intf; + intf = this->ctx_->attribute () + ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) + : be_interface::narrow_from_scope (op->defined_in ()); + + if (!intf) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_arglist::" + "visit_argument - " + "Bad interface\n"), + -1); + } + ctx.scope (intf); // set new scope + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_OPERATION_AMI_ARGLIST: + ctx.state (TAO_CodeGen::TAO_ARGUMENT_AMI_ARGLIST); + break; + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_arglist::" + "visit_argument - " + "Bad context\n"), + -1); + } + } + + // grab a visitor + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_arglist::" + "visit_argument - " + "Bad visitor\n"), + -1); + } + if (node->accept (visitor) == -1) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_arglist::" + "visit_argument - " + "codegen for ami_arglist failed\n"), + -1); + } + delete visitor; + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp new file mode 100644 index 00000000000..a7d21e61502 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp @@ -0,0 +1,93 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_ch.cpp +// +// = DESCRIPTION +// Visitor generating AMI stub code for Operation node in the +// client header. +// +// = AUTHOR +// Alexander Babu Arulanthu <alex@cs.wustl.edu> +// +// ============================================================================ + +#include "idl.h" +#include "idl_extern.h" +#include "be.h" + +#include "be_visitor_operation.h" + +ACE_RCSID(be_visitor_operation, operation_ami_ch, "$Id$") + + +// ****************************************************** +// Visitor for generating AMI stub for "operation" in client header. +// ****************************************************** + +be_visitor_operation_ami_ch::be_visitor_operation_ami_ch (be_visitor_context *ctx) + : be_visitor_operation (ctx) +{ +} + +be_visitor_operation_ami_ch::~be_visitor_operation_ami_ch (void) +{ +} + +int +be_visitor_operation_ami_ch::visit_operation (be_operation *node) +{ + TAO_OutStream *os; // output stream + + os = this->ctx_->stream (); + this->ctx_->node (node); // save the node + + os->indent (); // start with the current indentation level + + // every operation is declared virtual in the client code + *os << "virtual "; + + // STEP I: Return type is void. + *os << "void "; + + // STEP 2: generate the operation name. + + // First the sendc prefix. + *os << "sendc_"; + *os << node->local_name (); + + // STEP 3: generate the argument list with the appropriate + // mapping. For these we grab a visitor that generates the + // parameter listing. + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_OPERATION_AMI_ARGLIST); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_operation_ami_ch::" + "visit_operation - " + "Bad visitor to return type\n"), + -1); + } + + if (node->accept (visitor) == -1) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_ch::" + "visit_operation - " + "codegen for argument list failed\n"), + -1); + } + delete visitor; + + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp new file mode 100644 index 00000000000..058f7ad1908 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp @@ -0,0 +1,901 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_cs.cpp +// +// = DESCRIPTION +// Visitor generating code for Operation in the stubs file. +// +// = AUTHOR +// Aniruddha Gokhale and Alexander Babu Arulanthu +// <alex@cs.wustl.edu> +// +// ============================================================================ + +#include "idl.h" +#include "idl_extern.h" +#include "be.h" + +#include "be_visitor_operation.h" + +ACE_RCSID(be_visitor_operation, operation_ami_cs, "$Id$") + + +// ************************************************************ +// Operation visitor for client stubs +// ************************************************************ + +be_visitor_operation_ami_cs::be_visitor_operation_ami_cs (be_visitor_context *ctx) + : be_visitor_operation (ctx) +{ +} + +be_visitor_operation_ami_cs::~be_visitor_operation_ami_cs (void) +{ +} + +// Processing to be done after every element in the scope is +// processed. +int +be_visitor_operation_ami_cs::post_process (be_decl *bd) +{ + // 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"; + return 0; +} + +int +be_visitor_operation_ami_cs::visit_operation (be_operation *node) +{ + TAO_OutStream *os; // output stream + be_visitor_context ctx; // visitor context + be_visitor *visitor; // visitor + + os = this->ctx_->stream (); + this->ctx_->node (node); // save the node for future use + + os->indent (); // start with the current indentation level + + // Generate the return type mapping. Return type is simply void. + *os << "void" << be_nl; + + // Generate the operation name. + + // Grab the scope name. + 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_cs::" + "visit_operation - " + "scope name is nil\n"), + -1); + + // Generate the scope::operation name. + *os << parent->fullname () + << "::" + << "sendc_" + << node->local_name ()->get_string (); + + // Generate the argument list with the appropriate mapping (same as + // in the header file) + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_AMI_ARGLIST); + visitor = tao_cg->make_visitor (&ctx); + if ((!visitor) || (node->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "visit_operation - " + "codegen for argument list failed\n"), + -1); + } + delete visitor; + + // 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; + + // Create the return type node. Return type is void. + be_predefined_type *bt = 0; + ACE_NEW_RETURN (bt, + be_predefined_type (AST_PredefinedType::PT_void, + new UTL_ScopedName + (new Identifier + ("void", 1, 0, I_FALSE), 0), + 0), + -1); + + // generate any pre stub info if and only if none of our parameters is of the + // native type + 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 + if (this->gen_pre_stub_info (node, bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "visit_operation - " + "gen_pre_stub_info failed\n"), + -1); + } + } + + if (node->has_native ()) // native exists => no stub + { + if (this->gen_raise_exception (bt, + "CORBA::MARSHAL", + "") == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "visit_operation - " + "codegen for return var failed\n"), + -1); + } + } + else + { + // 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 + if (this->gen_raise_exception (bt, "CORBA::INV_OBJREF", + "") == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "visit_operation - " + "codegen for checking exception failed\n"), + -1); + + } + *os << be_uidt_nl << "\n"; + + // do any pre marshal and invoke processing with return type. This + // includes allocating memory, initialization. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_PRE_INVOKE_CS); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (bt->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "visit_operation - " + "codegen for retval pre invoke failed\n"), + -1); + } + + // 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_ami_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_ami_cs::" + "visit_operation - " + "codegen for marshal and invoke failed\n"), + -1); + + } + + // No return values. + *os << "return;"; + } // end of if (!native) + + *os << be_uidt_nl << "}\n\n"; + + return 0; +} + +int +be_visitor_operation_ami_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 + + // retrieve the type for this argument + bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "visit_argument - " + "Bad argument type\n"), + -1); + } + + os->indent (); + *os << "{" << bt->tc_name () << ", "; + switch (node->direction ()) + { + case AST_Argument::dir_IN: + *os << "PARAM_IN, "; + break; + case AST_Argument::dir_INOUT: + *os << "PARAM_INOUT, "; + break; + case AST_Argument::dir_OUT: + *os << "PARAM_OUT, "; + break; + } + *os << "0}"; + + return 0; +} + +int +be_visitor_operation_ami_cs::gen_raise_exception (be_type *bt, + const char *excep, + const char *completion_status) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_visitor *visitor; + be_visitor_context ctx; + + if (this->void_return_type (bt)) + { + *os << "ACE_THROW (" + << excep << " (" << completion_status << "));\n"; + } + else + { + *os << "ACE_THROW_RETURN (" + << excep << " (" << completion_status << "), "; + + // return the appropriate return value + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (bt->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "gen_raise_exception - " + "codegen for return var failed\n"), + -1); + } + *os << ");\n"; + } + return 0; +} + +int +be_visitor_operation_ami_cs::gen_check_exception (be_type *bt) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_visitor *visitor; + be_visitor_context ctx; + + os->indent (); + // check if there is an exception + if (this->void_return_type (bt)) + { + *os << "ACE_CHECK;\n"; + //<< "_tao_environment);\n"; + } + else + { + *os << "ACE_CHECK_RETURN ("; + // << "_tao_environment, "; + + // return the appropriate return value + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (bt->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "gen_check_exception - " + "codegen failed\n"), + -1); + } + *os << ");\n"; + } + + return 0; +} + +// ************************************************************ +// Operation visitor for interpretive client stubs +// ************************************************************ + +be_interpretive_visitor_operation_ami_cs:: +be_interpretive_visitor_operation_ami_cs (be_visitor_context *ctx) + : be_visitor_operation_ami_cs (ctx) +{ +} + +be_interpretive_visitor_operation_ami_cs::~be_interpretive_visitor_operation_ami_cs (void) +{ +} + +// concrete implementation of the template methods + +int +be_interpretive_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, + be_type *bt) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_visitor *visitor; + be_visitor_context ctx; + + // Generate the TAO_Param_Data table + os->indent (); + *os << "static const TAO_Param_Data "; + // check if we are an attribute node in disguise + 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->flatname () << + "_paramdata [] = " << be_nl; + *os << "{\n"; + os->incr_indent (); + + // entry for the return type + *os << "{" << bt->tc_name () << ", PARAM_RETURN, 0}"; + if (node->nmembers () > 0) + *os << ",\n"; + + // generate entries for the param data table for arguments + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interpretive_visitor_operation_ami_cs::" + "gen_pre_stub_info - " + "visit scope failed\n"), + -1); + } + *os << "\n"; + os->decr_indent (); + *os << "}; // " << node->flatname () << "_paramdata\n\n"; + + // 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_; + ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (node->accept (visitor) == -1)) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) " + "be_interpretive_visitor_operation_ami_cs::" + "gen_pre_stub_info - " + "Exceptionlist generation error\n"), + -1); + } + } + + // now generate the calldata table + os->indent (); + *os << "static const TAO_Call_Data "; + // check if we are an attribute node in disguise + 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->flatname () + << "_calldata = " << be_nl + << "{" + << "\""; + // check if we are an attribute node in disguise + 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->local_name () << "\", "; + + // are we oneway or two operation? + if (node->flags () == AST_Operation::OP_oneway) + { + *os << "0, "; // for false + } + else + { + *os << "1, "; // for true + } + // insert the size of the paramdata table i.e., number of arguments + 1 + // for return type + *os << (node->argument_count () + 1) << ", "; + + // insert the address of the paramdata table + // first check if we are an attribute node in disguise + 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->flatname () << "_paramdata, "; + + // insert exception list (if any) - node for attributes + if (this->ctx_->attribute ()) + *os << "0, 0};\n\n"; + else + { + if (node->exceptions ()) + { + *os << node->exceptions ()->length () + << ", _tao_" << node->flatname () << "_exceptiondata};\n\n"; + } + else + *os << "0, 0};\n\n"; + } + return 0; +} + +int +be_interpretive_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation + *node, + be_type *bt) +{ + TAO_OutStream *os = this->ctx_->stream (); + be_visitor *visitor; + be_visitor_context ctx; + + os->indent (); + *os << "void* _tao_arguments[" + << node->argument_count () + 1 << "];" << be_nl + << "const void** _tao_arg = ACE_const_cast (const void**,_tao_arguments);" << be_nl + << "*_tao_arg = "; + + // pass the appropriate return value to docall + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_CS); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (bt->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interpretive_visitor_operation_ami_cs::" + "gen_marshal_and_invoke - " + "codegen for return var in do_static_call failed\n"), + -1); + } + *os << "; _tao_arg++;\n"; + + // pass each argument to do_static_call + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (node->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interpretive_visitor_operation_ami_cs::" + "gen_marshal_and_invoke - " + "codegen for return var in do_static_call failed\n"), + -1); + } + + // call do_static_call with appropriate number of arguments + os->indent (); + *os << "istub->do_static_call (" << be_idt_nl + << "ACE_TRY_ENV, " << be_nl + << "&"; + // check if we are an attribute node in disguise + 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->flatname () << "_calldata," << be_nl + << "_tao_arguments" << be_uidt_nl + << ");\n"; + + os->indent (); + // check if there is an exception + if (this->gen_check_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_interpretive_visitor_operation_ami_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + + } + + // do any post processing for the arguments + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_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_ami_cs::" + "visit_operation - " + "codegen for args post do_static_call failed\n"), + -1); + } + + // do any post processing for the retval + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_POST_INVOKE_CS); + visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (bt->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "visit_operation - " + "codegen for return type post do_static_call failed\n"), + -1); + } + + return 0; +} + +// ************************************************************ +// Operation visitor for compiled client stubs +// ************************************************************ + +be_compiled_visitor_operation_ami_cs:: +be_compiled_visitor_operation_ami_cs (be_visitor_context *ctx) + : be_visitor_operation_ami_cs (ctx) +{ +} + +be_compiled_visitor_operation_ami_cs::~be_compiled_visitor_operation_ami_cs (void) +{ +} + +// concrete implementation of the template methods + +int +be_compiled_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, + be_type *) +{ + + // 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 ()) + { + be_visitor_context ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor || (node->accept (visitor) == -1)) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) " + "be_compiled_visitor_operation_ami_cs::" + "gen_pre_stub_info - " + "Exceptionlist generation error\n"), + -1); + } + } + + return 0; +} + +int +be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (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->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 + << "_tao_call.start (ACE_TRY_ENV);" << be_nl; + // check if there is an exception + if (this->gen_check_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + + } + + // 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 << be_nl + << "TAO_OutputCDR &_tao_out = _tao_call.out_stream ();" + << be_nl + << "if (!(\n" << be_idt << be_idt << be_idt; + + // marshal each in and inout argument + 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); + if (!visitor || (node->accept (visitor) == -1)) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "gen_marshal_and_invoke - " + "codegen for return var in do_static_call failed\n"), + -1); + } + *os << be_uidt << be_uidt_nl + << "))" << be_nl; + + // if marshaling fails, raise exception + if (this->gen_raise_exception (bt, "CORBA::MARSHAL", + "") == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "gen_marshal_and invoke - " + "codegen for return var failed\n"), + -1); + } + *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);"; + } + } + + *os << be_uidt_nl; + // check if there is an exception + if (this->gen_check_exception (bt) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "gen_marshal_and_invoke - " + "codegen for checking exception failed\n"), + -1); + } + + *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; + + if (this->gen_raise_exception (bt, + "CORBA::UNKNOWN", + "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES") == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "gen_marshal_and invoke - " + "codegen for return var failed\n"), + -1); + } + + *os << be_uidt_nl + << "}" << be_nl + << "break;" << be_nl + << be_uidt_nl << "}" << be_nl; + + // the code below this is for 2way operations only + + if (this->void_return_type (bt) && + !this->has_param_type (node, AST_Argument::dir_INOUT) && + !this->has_param_type (node, AST_Argument::dir_OUT)) + { + return 0; + } + + // Do any post_invoke stuff that might be necessary. + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_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_cs::" + "gen_marshal_and_invoke - " + "codegen for args in post do_static_call\n"), + -1); + } + + + // Generate any temporary variables to demarshal the arguments + ctx = *this->ctx_; + be_visitor_compiled_args_decl vis1 (new be_visitor_context (ctx)); + if (node->accept (&vis1) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "gen_pre_stub_info - " + "codegen for pre args failed\n"), + -1); + } + + if (!this->void_return_type (bt)) + { + // Generate any temporary variables to demarshal the return value + ctx = *this->ctx_; + be_visitor_context *new_ctx = + new be_visitor_context (ctx); + be_visitor_operation_compiled_rettype_post_docall vis2 (new_ctx); + if (bt->accept (&vis2) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "gen_pre_stub_info - " + "codegen rettype [post docall] 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 + *os << "TAO_InputCDR &_tao_in = _tao_call.inp_stream ();" << be_nl + << "if (!(\n" << be_idt << be_idt << be_idt; + + if (!this->void_return_type (bt)) + { + // demarshal the return val + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_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_cs::" + "gen_marshal_and_invoke - " + "codegen for return var failed\n"), + -1); + } + } + + if (this->has_param_type (node, AST_Argument::dir_INOUT) || + this->has_param_type (node, AST_Argument::dir_OUT)) + { + if (!this->void_return_type (bt)) + *os << " &&\n"; + + // demarshal each out and inout argument + ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_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_cs::" + "gen_marshal_and_invoke - " + "codegen for return var failed\n"), + -1); + } + } + + if (!this->void_return_type (bt) || + this->has_param_type (node, AST_Argument::dir_INOUT) || + this->has_param_type (node, AST_Argument::dir_OUT)) + { + + *os << be_uidt << be_uidt << be_nl + << "))" << be_nl; + // if marshaling fails, raise exception + if (this->gen_raise_exception (bt, "CORBA::MARSHAL", + "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES") == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "gen_marshal_and invoke - " + "codegen for return var failed\n"), + -1); + } + *os << be_uidt; + } + + return 0; +} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_arglist.cpp new file mode 100644 index 00000000000..66d6b5763bb --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_arglist.cpp @@ -0,0 +1,181 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_arglist.cpp +// +// = DESCRIPTION +// Visitor generating code for the parameter list of the AMI +// Handler's call back Operation signature. +// +// = AUTHOR +// Aniruddha Gokhale and Alexander Babu Arulanthu +// <alex@cs.wustl.edu> +// +// ============================================================================ + +#include "idl.h" +#include "idl_extern.h" +#include "be.h" + +#include "be_visitor_operation.h" + +ACE_RCSID(be_visitor_operation, ami_handler_arglist, "$Id$") + + +// ************************************************************ +// operation visitor to generate the argument list. +// We have separated code generation for this from the 4 main +// visitors to avoid code duplication and tight coupling +// ************************************************************ + +be_visitor_operation_ami_handler_arglist::be_visitor_operation_ami_handler_arglist (be_visitor_context *ctx) + : be_visitor_operation (ctx) +{ +} + +be_visitor_operation_ami_handler_arglist::~be_visitor_operation_ami_handler_arglist (void) +{ +} + +int +be_visitor_operation_ami_handler_arglist::visit_operation (be_operation *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + *os << " (" << be_idt << be_idt << "\n"; + + // All we do is hand over code generation to our scope. + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_handler_arglist::" + "visit_operation - " + "codegen for scope failed\n"), + -1); + } + + // No argument for exception. What will you do if you get the + // exception from the call back method? + + // Arglist is over. + *os << be_uidt_nl << ")" << be_uidt; + + // @@ No THROW SPECs. You can do anything if the call back guy + // throws an exception. But I am not too sure about + // this. (Alex). + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGLIST: + // Each method is pure virtual in the header. + *os << " = 0;\n\n"; + break; + default: + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist::" + "visit_operation - " + "Bad operation\n"), + -1); + } + + return 0; +} + +int +be_visitor_operation_ami_handler_arglist::visit_argument (be_argument *node) +{ + // Get the visitor that will dump the argument's mapping in the + // operation signature. + be_visitor_context ctx (*this->ctx_); + + // first grab the interface definition inside which this operation is + // defined. We need this since argument types may very well be declared + // inside the scope of the interface node. In such cases, we would like to + // generate the appropriate relative scoped names. + be_operation *op = this->ctx_->be_scope_as_operation (); + if (!op) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist::" + "visit_argument - " + "Bad operation\n"), + -1); + } + + // We need the interface node in which this operation was defined. However, + // if this operation node was an attribute node in disguise, we get this + // information from the context. + be_interface *intf; + intf = this->ctx_->attribute () + ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) + : be_interface::narrow_from_scope (op->defined_in ()); + + if (!intf) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist::" + "visit_argument - " + "Bad interface\n"), + -1); + } + ctx.scope (intf); // set new scope + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGLIST: + ctx.state (TAO_CodeGen::TAO_ARGUMENT_AMI_HANDLER_ARGLIST); + break; + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist::" + "visit_argument - " + "Bad context\n"), + -1); + } + } + + // Grab a visitor. + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_handler_arglist::" + "visit_argument - " + "Bad visitor\n"), + -1); + } + if (node->accept (visitor) == -1) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist::" + "visit_argument - " + "codegen for ami_handler_arglist failed\n"), + -1); + } + delete visitor; + return 0; +} + +int +be_visitor_operation_ami_handler_arglist::post_process (be_decl *bd) +{ + TAO_OutStream *os = this->ctx_->stream (); + + // if we are not the last node in the list of arguments, generate a comma + // else decide if we are generating code to support true exceptions - in + // which case there will not be any CORBA::Environment parameter + if (!this->last_node (bd)) + { + *os << ",\n"; + } + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_arglist_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_arglist_ch.cpp new file mode 100644 index 00000000000..121f7509a5b --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_arglist_ch.cpp @@ -0,0 +1,181 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_arglist_ch.cpp +// +// = DESCRIPTION +// Visitor generating code for the parameter list of the AMI +// Handler's call back Operation signature. +// +// = AUTHOR +// Aniruddha Gokhale and Alexander Babu Arulanthu +// <alex@cs.wustl.edu> +// +// ============================================================================ + +#include "idl.h" +#include "idl_extern.h" +#include "be.h" + +#include "be_visitor_operation.h" + +ACE_RCSID(be_visitor_operation, ami_handler_arglist_ch, "$Id$") + + +// ************************************************************ +// operation visitor to generate the argument list. +// We have separated code generation for this from the 4 main +// visitors to avoid code duplication and tight coupling +// ************************************************************ + +be_visitor_operation_ami_handler_arglist_ch::be_visitor_operation_ami_handler_arglist_ch (be_visitor_context *ctx) + : be_visitor_operation (ctx) +{ +} + +be_visitor_operation_ami_handler_arglist_ch::~be_visitor_operation_ami_handler_arglist_ch (void) +{ +} + +int +be_visitor_operation_ami_handler_arglist_ch::visit_operation (be_operation *node) +{ + TAO_OutStream *os = this->ctx_->stream (); + + *os << " (" << be_idt << be_idt << "\n"; + + // All we do is hand over code generation to our scope. + if (this->visit_scope (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_handler_arglist_ch::" + "visit_operation - " + "codegen for scope failed\n"), + -1); + } + + // No argument for exception. What will you do if you get the + // exception from the call back method? + + // Arglist is over. + *os << be_uidt_nl << ")" << be_uidt; + + // @@ No THROW SPECs. You can do anything if the call back guy + // throws an exception. But I am not too sure about + // this. (Alex). + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGLIST_CH: + // Each method is pure virtual in the header. + *os << " = 0;\n\n"; + break; + default: + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist_ch::" + "visit_operation - " + "Bad operation\n"), + -1); + } + + return 0; +} + +int +be_visitor_operation_ami_handler_arglist_ch::visit_argument (be_argument *node) +{ + // Get the visitor that will dump the argument's mapping in the + // operation signature. + be_visitor_context ctx (*this->ctx_); + + // first grab the interface definition inside which this operation is + // defined. We need this since argument types may very well be declared + // inside the scope of the interface node. In such cases, we would like to + // generate the appropriate relative scoped names. + be_operation *op = this->ctx_->be_scope_as_operation (); + if (!op) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist_ch::" + "visit_argument - " + "Bad operation\n"), + -1); + } + + // We need the interface node in which this operation was defined. However, + // if this operation node was an attribute node in disguise, we get this + // information from the context. + be_interface *intf; + intf = this->ctx_->attribute () + ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) + : be_interface::narrow_from_scope (op->defined_in ()); + + if (!intf) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist_ch::" + "visit_argument - " + "Bad interface\n"), + -1); + } + ctx.scope (intf); // set new scope + + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGLIST: + ctx.state (TAO_CodeGen::TAO_ARGUMENT_AMI_HANDLER_ARGLIST); + break; + default: + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist_ch::" + "visit_argument - " + "Bad context\n"), + -1); + } + } + + // Grab a visitor. + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist_ch::" + "visit_argument - " + "Bad visitor\n"), + -1); + } + if (node->accept (visitor) == -1) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_ami_handler_arglist_ch::" + "visit_argument - " + "codegen for ami_handler_arglist_ch failed\n"), + -1); + } + delete visitor; + return 0; +} + +int +be_visitor_operation_ami_handler_arglist_ch::post_process (be_decl *bd) +{ + TAO_OutStream *os = this->ctx_->stream (); + + // if we are not the last node in the list of arguments, generate a comma + // else decide if we are generating code to support true exceptions - in + // which case there will not be any CORBA::Environment parameter + if (!this->last_node (bd)) + { + *os << ",\n"; + } + return 0; +} + diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_operation_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_operation_ch.cpp new file mode 100644 index 00000000000..bc54b1b3710 --- /dev/null +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_operation_ch.cpp @@ -0,0 +1,117 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_operation_ch.cpp +// +// = DESCRIPTION +// Visitor generating code for AMI Handler call back operation in +// the client header. +// +// = AUTHOR +// Aniruddha Gokhale and Alexander Babu Arulanthu +// <alex@cs.wustl.edu> +// +// ============================================================================ + +#include "idl.h" +#include "idl_extern.h" +#include "be.h" + +#include "be_visitor_operation.h" + +ACE_RCSID(be_visitor_operation, ami_handler_operation_ch, "$Id$") + + +// ************************************************************ +// Operation visitor for server header +// ************************************************************ + +be_visitor_operation_ami_handler_operation_ch::be_visitor_operation_ami_handler_operation_ch (be_visitor_context *ctx) + : be_visitor_operation (ctx) +{ +} + +be_visitor_operation_ami_handler_operation_ch::~be_visitor_operation_ami_handler_operation_ch (void) +{ +} + +int +be_visitor_operation_ami_handler_operation_ch::visit_operation (be_operation *node) +{ + TAO_OutStream *os; // output stream + + os = this->ctx_->stream (); + this->ctx_->node (node); // save the node + + os->indent (); // start with the current indentation level + + // every operation is declared virtual in the client code + *os << "virtual "; + + // STEP I: generate the return type. Return type is simpy void. + *os << "void "; + + // STEP 2: generate the operation name. + *os << " " << node->local_name (); + + // STEP 3: generate the argument list with the appropriate + // mapping. For these we grab a visitor that generates the + // parameter listing. + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGLIST); + be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) + { + ACE_ERROR_RETURN ((LM_ERROR, + "be_visitor_operation_ami_handler_operation_ch::" + "visit_operation - " + "Bad visitor to return type\n"), + -1); + } + + if (node->accept (visitor) == -1) + { + delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_handler_operation_ch::" + "visit_operation - " + "codegen for argument list failed\n"), + -1); + } + delete visitor; + + // Generate the corresponding static skeleton method for this + // operation only if there was no "native" type. + if (!node->has_native ()) + { + os->indent (); + *os << "static void "; + // Check if we are an attribute node in disguise + 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->local_name () << + "_skel (" << be_idt << be_idt_nl + << "CORBA::ServerRequest &_tao_req, " << be_nl + << "void *_tao_obj, " << be_nl + << "void *_tao_context, " << be_nl + << "CORBA::Environment &ACE_TRY_ENV = " << be_idt_nl + << "TAO_default_environment ()" + << be_uidt << be_uidt_nl + << ");" << be_uidt << "\n\n"; + } + + return 0; +} diff --git a/TAO/TAO_IDL/be_include/be_visitor_argument/ami_arglist.h b/TAO/TAO_IDL/be_include/be_visitor_argument/ami_arglist.h new file mode 100644 index 00000000000..d5f11ad86b5 --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_argument/ami_arglist.h @@ -0,0 +1,96 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_arglist.h +// +// = DESCRIPTION +// Visitor for generation of code for Arguments as parameter lists +// in the operation signature of an AMI stub. +// +// = AUTHOR +// Aniruddha Gokhale & Alexander Babu Arulanthu <alex@cs.wustl.edu> +// +// ============================================================================ + +#ifndef _BE_VISITOR_ARGUMENT_AMI_ARGLIST_H_ +#define _BE_VISITOR_ARGUMENT_AMI_ARGLIST_H_ + +class be_visitor_args_ami_arglist : public be_visitor_args +{ + // + // = TITLE + // Generates the code for arguments output. + // + // = DESCRIPTION + // At several stages in the code generation a node of type + // "be_operation" is visited, and the code for its arguments must + // be generated. + // Sometimes the argument declarations must be generated (such as + // in the class declaration), other the arguments names (such as + // in method invocations). + // This class implements the declaration output, in other words, + // it outputs both the arguments and their types. + // +public: + be_visitor_args_ami_arglist (be_visitor_context *ctx); + // Constructor. + + virtual ~be_visitor_args_ami_arglist (void); + // Destructor. + + virtual int visit_argument (be_argument *node); + // Visit the argument node. + + // = visit all the nodes that can be the types for the argument. + + virtual int visit_array (be_array *node); + // visit array type + + virtual int visit_enum (be_enum *node); + // visit the enum node + + virtual int visit_interface (be_interface *node); + // visit interface + + virtual int visit_interface_fwd (be_interface_fwd *node); + // visit interface forward + + + virtual int visit_native (be_native *node); + // visit native node + + virtual int visit_predefined_type (be_predefined_type *node); + // visit predefined type + + virtual int visit_sequence (be_sequence *node); + // visit sequence type + + virtual int visit_string (be_string *node); + // visit string type + + virtual int visit_structure (be_structure *node); + // visit structure type + + virtual int visit_union (be_union *node); + // visit union type + + virtual int visit_typedef (be_typedef *node); + // visit the typedef type + +#ifdef IDL_HAS_VALUETYPE + virtual int visit_valuetype (be_valuetype *node); + // visit valuetype + + virtual int visit_valuetype_fwd (be_valuetype_fwd *node); + // visit valuetype_fwd +#endif /* IDL_HAS_VALUETYPE */ +}; + +#endif /* _BE_VISITOR_ARGUMENT_ARGLIST_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_argument/ami_handler_arglist.h b/TAO/TAO_IDL/be_include/be_visitor_argument/ami_handler_arglist.h new file mode 100644 index 00000000000..63882f11020 --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_argument/ami_handler_arglist.h @@ -0,0 +1,96 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_arglist.h +// +// = DESCRIPTION +// Visitor for generation of code for Arguments as parameter lists +// in the operation signature of an AMI stub. +// +// = AUTHOR +// Aniruddha Gokhale & Alexander Babu Arulanthu <alex@cs.wustl.edu> +// +// ============================================================================ + +#ifndef _BE_VISITOR_ARGUMENT_AMI_HANDLER_ARGLIST_H_ +#define _BE_VISITOR_ARGUMENT_AMI_HANDLER_ARGLIST_H_ + +class be_visitor_args_ami_handler_arglist : public be_visitor_args +{ + // + // = TITLE + // Generates the code for arguments output. + // + // = DESCRIPTION + // At several stages in the code generation a node of type + // "be_operation" is visited, and the code for its arguments must + // be generated. + // Sometimes the argument declarations must be generated (such as + // in the class declaration), other the arguments names (such as + // in method invocations). + // This class implements the declaration output, in other words, + // it outputs both the arguments and their types. + // +public: + be_visitor_args_ami_handler_arglist (be_visitor_context *ctx); + // Constructor. + + virtual ~be_visitor_args_ami_handler_arglist (void); + // Destructor. + + virtual int visit_argument (be_argument *node); + // Visit the argument node. + + // = visit all the nodes that can be the types for the argument. + + virtual int visit_array (be_array *node); + // visit array type + + virtual int visit_enum (be_enum *node); + // visit the enum node + + virtual int visit_interface (be_interface *node); + // visit interface + + virtual int visit_interface_fwd (be_interface_fwd *node); + // visit interface forward + + + virtual int visit_native (be_native *node); + // visit native node + + virtual int visit_predefined_type (be_predefined_type *node); + // visit predefined type + + virtual int visit_sequence (be_sequence *node); + // visit sequence type + + virtual int visit_string (be_string *node); + // visit string type + + virtual int visit_structure (be_structure *node); + // visit structure type + + virtual int visit_union (be_union *node); + // visit union type + + virtual int visit_typedef (be_typedef *node); + // visit the typedef type + +#ifdef IDL_HAS_VALUETYPE + virtual int visit_valuetype (be_valuetype *node); + // visit valuetype + + virtual int visit_valuetype_fwd (be_valuetype_fwd *node); + // visit valuetype_fwd +#endif /* IDL_HAS_VALUETYPE */ +}; + +#endif /* _BE_VISITOR_ARGUMENT_ARGLIST_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_interface/ami_handler_ch.h b/TAO/TAO_IDL/be_include/be_visitor_interface/ami_handler_ch.h new file mode 100644 index 00000000000..ec5b0136d7d --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_interface/ami_handler_ch.h @@ -0,0 +1,47 @@ +// +// $Id$ +// +/* -*- c++ -*- */ +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_ch.h +// +// = DESCRIPTION +// Concrete visitor for the Interface node. +// This provides for code generation in the server header +// +// = AUTHOR +// Aniruddha Gokhale and Alexander Babu Arulanthu +// <alex@cs.wustl.edu> +// +// ============================================================================ + +#ifndef _BE_INTERFACE_AMI_HANDLER_CH_H_ +#define _BE_INTERFACE_AMI_HANDLER_CH_H_ + +class be_visitor_interface_ami_handler_ch : public be_visitor_interface +{ + // + // = TITLE + // be_visitor_interface_ami_handler_ch + // + // = DESCRIPTION + // This is a concrete visitor to generate the server header for interface + // + // +public: + be_visitor_interface_ami_handler_ch (be_visitor_context *ctx); + // constructor + + ~be_visitor_interface_ami_handler_ch (void); + // destructor + + virtual int visit_interface (be_interface *node); + // set the right context and make a visitor +}; + +#endif /* _BE_INTERFACE_AMI_HANDLER_CH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_arglist.h b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_arglist.h new file mode 100644 index 00000000000..26c09921b7e --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_arglist.h @@ -0,0 +1,54 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_arglist.h +// +// = DESCRIPTION +// Visitor for generating IDL Stub code for IDL operations. This +// generates the operation signature for the IDL stub. +// +// = AUTHOR +// Alexander Babu Arulanthu <alex@cs.wustl.edu> +// +// ============================================================================ + +#ifndef _BE_VISITOR_OPERATION_AMI_ARGLIST_H_ +#define _BE_VISITOR_OPERATION_AMI_ARGLIST_H_ + +// ****************************************************************************** +// Operation visitor for argument list - generates parameters in the signature +// ****************************************************************************** + +class be_visitor_operation_ami_arglist : public be_visitor_scope +{ + // + // = TITLE + // be_visitor_operaion_ami_arglist + // + // = DESCRIPTION + // This is a visitor to generate operation argument list for an + // AMI stub. + // + // +public: + be_visitor_operation_ami_arglist (be_visitor_context *ctx); + // constructor + + ~be_visitor_operation_ami_arglist (void); + // destructor + + int visit_operation (be_operation *node); + // visit the operation + + int visit_argument (be_argument *node); + // visit each argument +}; + +#endif /* _BE_VISITOR_OPERATION_AMI_ARGLIST_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_ch.h b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_ch.h new file mode 100644 index 00000000000..2377916168d --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_ch.h @@ -0,0 +1,51 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_ch.h +// +// = DESCRIPTION +// Visitor for generating AMI stub code for IDL operations in +// client header. +// +// = AUTHOR +// Alexander Babu Arulanthu <alex@cs.wustl.edu> +// +// ============================================================================ + +#ifndef _BE_VISITOR_OPERATION_AMI_CH_H_ +#define _BE_VISITOR_OPERATION_AMI_CH_H_ + +// ************************************************************ +// Operation visitor to generate AMI stubs for client header +// ************************************************************ + +class be_visitor_operation_ami_ch : public be_visitor_operation +{ + // + // = TITLE + // be_visitor_operation_ami_ch. + // + // = DESCRIPTION + // This is a concrete visitor to generate the AMI stubs in the + // client header for operation. + // + // +public: + be_visitor_operation_ami_ch (be_visitor_context *ctx); + // constructor + + ~be_visitor_operation_ami_ch (void); + // destructor + + virtual int visit_operation (be_operation *node); + // visit operation. +}; + +#endif /* _BE_VISITOR_OPERATION_AMI_CH_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_cs.h b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_cs.h new file mode 100644 index 00000000000..40208d792ea --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_cs.h @@ -0,0 +1,125 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_cs.h +// +// = DESCRIPTION +// Visitor for generating code for IDL operations in client stubs +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef _BE_VISITOR_OPERATION_AMI_CS_H_ +#define _BE_VISITOR_OPERATION_AMI_CS_H_ + +// ************************************************************ +// Operation visitor for client stubs +// ************************************************************ + +class be_visitor_operation_ami_cs : public be_visitor_operation +{ + // + // = TITLE + // be_visitor_operation_ami_cs + // + // = DESCRIPTION + // This is a concrete visitor to generate the client stubs for operation + // + // +public: + be_visitor_operation_ami_cs (be_visitor_context *ctx); + // constructor + + ~be_visitor_operation_ami_cs (void); + // destructor + + virtual int visit_operation (be_operation *node); + // visit operation. + + virtual int visit_argument (be_argument *node); + // visit argument to generate ParamData entries + + // = template methods + virtual int gen_pre_stub_info (be_operation *, be_type *) = 0; + // generate any info before the actual code for the stub is generated + + virtual int gen_marshal_and_invoke (be_operation *, be_type *) = 0; + // generate code that marshals the arguments and transmits them + + // =helper + 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); + // helper that generates code for raising an exception + + virtual int gen_check_exception (be_type *); + // helper that generates code for checking for an exception + +}; + +// specialized visitors + +class be_interpretive_visitor_operation_ami_cs : public be_visitor_operation_ami_cs +{ + // + // = TITLE + // be_interpretive_visitor_operation_ami_cs + // + // = DESCRIPTION + // This is a concrete visitor to generate the client stubs for operation + // using interpretive marshaling. + // + // +public: + be_interpretive_visitor_operation_ami_cs (be_visitor_context *); + // ctor + + ~be_interpretive_visitor_operation_ami_cs (void); + // dtor + + virtual int gen_pre_stub_info (be_operation *, be_type *); + // generate any info before the actual code for the stub is generated + + virtual int gen_marshal_and_invoke (be_operation *, be_type *); + // generate code that marshals the arguments and transmits them + +}; + +class be_compiled_visitor_operation_ami_cs : public be_visitor_operation_ami_cs +{ + // + // = TITLE + // be_compiled_visitor_operation_ami_cs + // + // = DESCRIPTION + // This is a concrete visitor to generate the client stubs for operation + // using compiled marshaling. + // + // +public: + be_compiled_visitor_operation_ami_cs (be_visitor_context *); + // ctor + + ~be_compiled_visitor_operation_ami_cs (void); + // dtor + + virtual int gen_pre_stub_info (be_operation *, be_type *); + // generate any info before the actual code for the stub is generated + + virtual int gen_marshal_and_invoke (be_operation *, be_type *); + // generate code that marshals the arguments and transmits them +}; + +#endif /* _BE_VISITOR_OPERATION_AMI_CS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_arglist.h b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_arglist.h new file mode 100644 index 00000000000..c3bbc7aaedc --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_arglist.h @@ -0,0 +1,57 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_arglist.h +// +// = DESCRIPTION +// Visitor for generating code for IDL operations. This generates the +// operation signature. +// +// = AUTHOR +// Aniruddha Gokhale +// +// ============================================================================ + +#ifndef _BE_VISITOR_OPERATION_AMI_HANDLER_ARGLIST_H_ +#define _BE_VISITOR_OPERATION_AMI_HANDLER_ARGLIST_H_ + +// ****************************************************************************** +// Operation visitor for argument list - generates parameters in the signature +// ****************************************************************************** + +class be_visitor_operation_ami_handler_arglist : public be_visitor_operation +{ + // + // = TITLE + // be_visitor_operaion_ami_handler_arglist + // + // = DESCRIPTION + // This is a visitor to generate operation argument list + // + // +public: + be_visitor_operation_ami_handler_arglist (be_visitor_context *ctx); + // constructor + + ~be_visitor_operation_ami_handler_arglist (void); + // destructor + + virtual int visit_operation (be_operation *node); + // visit the operation + + virtual int visit_argument (be_argument *node); + // visit each argument + + virtual int post_process (be_decl *); + // stuff to o/p after each element of the scope is handled + +}; + +#endif /* _BE_VISITOR_OPERATION_AMI_HANDLER_ARGLIST_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_operation_ch.h b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_operation_ch.h new file mode 100644 index 00000000000..cb7640b40b0 --- /dev/null +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_operation_ch.h @@ -0,0 +1,52 @@ +// +// $Id$ +// + +// ============================================================================ +// +// = LIBRARY +// TAO IDL +// +// = FILENAME +// ami_handler_operation_ch.h +// +// = DESCRIPTION +// Visitor for generating code for AMI Handler call back operations +// in client header. +// +// = AUTHOR +// Aniruddha Gokhale and Alexander Babu Arulanthu +// <alex@cs.wustl.edu> +// +// ============================================================================ + +#ifndef _BE_VISITOR_OPERATION_AMI_HANDLER_OPERATION_CH_H_ +#define _BE_VISITOR_OPERATION_AMI_HANDLER_OPERATION_CH_H_ + +// ************************************************************ +// Operation visitor for server header +// ************************************************************ + +class be_visitor_operation_ami_handler_operation_ch : public be_visitor_operation +{ + // + // = TITLE + // be_visitor_ami_handler_operation_ch + // + // = DESCRIPTION + // This is a concrete visitor to generate the server header for operation + // + // +public: + be_visitor_operation_ami_handler_operation_ch (be_visitor_context *ctx); + // constructor + + ~be_visitor_operation_ami_handler_operation_ch (void); + // destructor + + virtual int visit_operation (be_operation *node); + // visit operation. + +}; + +#endif /* _BE_VISITOR_OPERATION_AMI_HANDLER_OPERATION_CH_H_ */ |