summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-10 21:20:41 +0000
committermk1 <mk1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-10 21:20:41 +0000
commitec44306c0c0a70415801847c0f9b47f4edc878a6 (patch)
treebfea245d93eec0d4e5fe274de042152bfad7131b
parente8435bbd28e1ea5e063f7426c6324ff73af29044 (diff)
downloadATCD-ec44306c0c0a70415801847c0f9b47f4edc878a6.tar.gz
ChangeLogTag: Sat Jul 10 15:30:00 1999 Michael Kircher <mk1@cs.wustl.edu>
-rw-r--r--TAO/TAO_IDL/be/be_visitor_operation/ami_handler_thru_poa_collocated_cs.cpp200
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_thru_poa_collocated_cs.h58
2 files changed, 258 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_thru_poa_collocated_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_thru_poa_collocated_cs.cpp
new file mode 100644
index 00000000000..d9d86773fff
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_thru_poa_collocated_cs.cpp
@@ -0,0 +1,200 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// ami_handler_thru_poa_collocated_cs.cpp
+//
+// = DESCRIPTION
+// Visitor generating code for thru_poa_collocated Operation in the skeleton.
+//
+// = AUTHOR
+// Aniruddha Gokhale
+// Michael Kircher
+//
+// ============================================================================
+
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
+
+#include "be_visitor_operation.h"
+
+ACE_RCSID(be_visitor_operation, ami_handler_thru_poa_collocated_cs, "$Id$")
+
+
+// *************************************************************************
+// be_visitor_operation_ami_handler_thru_poa_collocated_cs --
+// This visitor generates code for the thru_poa_collocated operation signature in a
+// server skeletons file
+// *************************************************************************
+
+be_visitor_operation_ami_handler_thru_poa_collocated_cs::be_visitor_operation_ami_handler_thru_poa_collocated_cs
+(be_visitor_context *ctx)
+ : be_visitor_scope (ctx)
+{
+}
+
+be_visitor_operation_ami_handler_thru_poa_collocated_cs::~be_visitor_operation_ami_handler_thru_poa_collocated_cs (void)
+{
+}
+
+int be_visitor_operation_ami_handler_thru_poa_collocated_cs::visit_operation (be_operation *node)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // 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 (node->defined_in ());
+
+ if (!intf)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_operation_ami_handler_thru_poa_collocated_cs::"
+ "visit_operation - "
+ "bad interface scope\n"),
+ -1);
+ }
+
+ // retrieve the operation return type
+ be_type *bt = be_type::narrow_from_decl (node->return_type ());
+ if (!bt)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_operation_ami_handler_thru_poa_collocated_cs::"
+ "visit_operation - "
+ "Bad return type\n"),
+ -1);
+ }
+
+
+
+ *os << "void " << intf->full_coll_name (be_interface::THRU_POA) << "::"
+ << node->local_name () << " ";
+
+ // Generate the argument list with the appropriate mapping (same as
+ // in the header file)
+ // Generate the argument list with the appropriate mapping (same as
+ // in the header file).
+ be_visitor_context ctx (*this->ctx_);
+ ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_ARGLIST_CS);
+ be_visitor *visitor = tao_cg->make_visitor (&ctx);
+ if ((!visitor) || (node->accept (visitor) == -1))
+ {
+ delete visitor;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_operation_ami_handler_thru_poa_collocated_cs::"
+ "visit_operation - "
+ "codegen for argument list failed\n"),
+ -1);
+ }
+ delete visitor;
+
+
+ *os << "{" << be_idt_nl;
+
+ // @@ Michael: Not sure about this one.
+#if 0
+ if (!idl_global->exception_support ())
+ *os << "ACE_DECLARE_NEW_CORBA_ENV;" << be_nl;
+#endif /* 0 */
+
+ *os <<"TAO_Object_Adapter::Servant_Upcall servant_upcall ("
+ << be_idt << be_idt_nl
+ << "*this->_stubobj ()->servant_orb_var ()->orb_core ()->object_adapter ()"
+ << be_uidt_nl
+ << ");" << be_uidt_nl
+ << "servant_upcall.prepare_for_upcall (" << be_idt << be_idt_nl
+ << "this->_object_key ()," << be_nl
+ << "\"" << node->original_local_name () << "\"";
+ if (!idl_global->exception_support ())
+ *os << "," << be_nl
+ << "ACE_TRY_ENV" << be_uidt_nl
+ << ");\n" << be_uidt;
+ else
+ *os << be_uidt_nl << ");\n" << be_uidt;
+
+ // check if there is an exception
+ if (!idl_global->exception_support ())
+ {
+ os->indent ();
+ *os << "ACE_CHECK;\n";
+ }
+
+ os->indent ();
+ *os << "ACE_reinterpret_cast (" << be_idt << be_idt_nl
+ << intf->full_skel_name () << "_ptr," << be_nl
+ << "servant_upcall.servant ()->_downcast (" << be_idt << be_idt_nl
+ << "\"" << intf->repoID () << "\"" << be_uidt_nl
+ << ")" << be_uidt << be_uidt_nl
+ << ")" << be_uidt;
+
+ if (this->gen_invoke (ctx, node) == -1)
+ return -1;
+
+ os->indent ();
+ *os << "return;";
+
+ *os << be_uidt_nl
+ << "}\n\n";
+
+ return 0;
+}
+
+int be_visitor_operation_ami_handler_thru_poa_collocated_cs::gen_invoke (be_visitor_context &ctx,
+ be_operation *node)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ *os << "->" << node->local_name () << " ("
+ << be_idt << be_idt << "\n";
+
+ // retrieve the operation return type
+ be_type *bt = be_type::narrow_from_decl (node->return_type ());
+ if (!this->void_return_type (bt))
+ {
+ os->indent ();
+ *os << "_tao_retval,\n";
+ }
+
+ ctx = *this->ctx_;
+ ctx.state (TAO_CodeGen::TAO_AMI_HANDLER_OPERATION_COLLOCATED_ARG_UPCALL_CS);
+ be_visitor *visitor = tao_cg->make_visitor (&ctx);
+ if (!visitor || (node->accept (visitor) == -1))
+ {
+ delete visitor;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_operation_ami_handler_thru_poa_collocated_cs::"
+ "gen_invoke - "
+ "codegen for making upcall failed\n"),
+ -1);
+ }
+
+ // end the upcall
+ *os << be_uidt_nl
+ << ");\n" << be_uidt;
+ return 0;
+}
+
+
+int
+be_visitor_operation_ami_handler_thru_poa_collocated_cs::void_return_type (be_type *bt)
+{
+ // is the operation return type void?
+
+ if (bt->node_type () == AST_Decl::NT_pre_defined
+ && (be_predefined_type::narrow_from_decl (bt)->pt ()
+ == AST_PredefinedType::PT_void))
+ return 1;
+ else
+ return 0;
+}
diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_thru_poa_collocated_cs.h b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_thru_poa_collocated_cs.h
new file mode 100644
index 00000000000..b5eff14e374
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_thru_poa_collocated_cs.h
@@ -0,0 +1,58 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// ami_handler_thru_poa_collocated_cs.h
+//
+// = DESCRIPTION
+// Visitor for generating code for IDL operations for the thru_poa collocated case
+// inside of the servant skeleton
+//
+// = AUTHOR
+// Aniruddha Gokhale
+// Michael Kircher
+//
+// ============================================================================
+
+#ifndef _BE_VISITOR_OPERATION_AMI_HANDLER_THRU_POA_COLLOCATED_CS_H_
+#define _BE_VISITOR_OPERATION_AMI_HANDLER_THRU_POA_COLLOCATED_CS_H_
+
+// *****************************************************************
+// Operation visitor for server skeletons for the thru_poa collocated class
+// *****************************************************************
+
+class be_visitor_operation_ami_handler_thru_poa_collocated_cs : public be_visitor_scope
+{
+ //
+ // = TITLE
+ // be_visitor_operation_ss
+ //
+ // = DESCRIPTION
+ // This is a concrete visitor to generate the server skeletons for
+ // operation in the thru_poa collocated class
+ //
+ //
+public:
+ be_visitor_operation_ami_handler_thru_poa_collocated_cs (be_visitor_context *ctx);
+ // constructor
+
+ ~be_visitor_operation_ami_handler_thru_poa_collocated_cs (void);
+ // destructor
+
+ virtual int visit_operation (be_operation *node);
+ // visit operation node.
+
+ virtual int gen_invoke (be_visitor_context &ctx, be_operation *node);
+ // A helper method to generate operation invocation code.
+
+ virtual int void_return_type (be_type *bt);
+ // is my return type void?
+};
+
+#endif /* _BE_VISITOR_OPERATION_AMI_HANDLER_THRU_POA_COLLOCATED_CS_H_ */