summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-10 00:46:59 +0000
committeralex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-06-10 00:46:59 +0000
commit9a846d8e2440d0adf337f885eab8b58f280bfb54 (patch)
treefe0b135acb43f8ddfebbc9f29728feb61feab5e6
parent33433e5e1b4d5eabff2e20dd834f6939f5f49aec (diff)
downloadATCD-9a846d8e2440d0adf337f885eab8b58f280bfb54.tar.gz
Wed Jun 9 19:19:43 1999 Alexander Babu Arulanthu <alex@cs.wustl.edu>
-rw-r--r--TAO/TAO_IDL/be/be_visitor_operation/arglist_ami.cpp152
-rw-r--r--TAO/TAO_IDL/be/be_visitor_operation/operation_ami.cpp93
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_operation/arglist_ami.h54
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_operation/operation_ami.h51
4 files changed, 350 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_operation/arglist_ami.cpp b/TAO/TAO_IDL/be/be_visitor_operation/arglist_ami.cpp
new file mode 100644
index 00000000000..028ffd9c55d
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_operation/arglist_ami.cpp
@@ -0,0 +1,152 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// arglist_ami.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, arglist_ami, "$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_arglist_ami::be_visitor_operation_arglist_ami (be_visitor_context
+ *ctx)
+ : be_visitor_scope (ctx)
+{
+}
+
+be_visitor_operation_arglist_ami::~be_visitor_operation_arglist_ami (void)
+{
+}
+
+int
+be_visitor_operation_arglist_ami::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_arglist_ami::"
+ "visit_operation - "
+ "codegen for scope failed\n"),
+ -1);
+ }
+
+ // 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_arglist_ami::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_arglist_ami::"
+ "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_arglist_ami::"
+ "visit_argument - "
+ "Bad interface\n"),
+ -1);
+ }
+ ctx.scope (intf); // set new scope
+
+ switch (this->ctx_->state ())
+ {
+ case TAO_CodeGen::TAO_OPERATION_ARGLIST_AMI:
+ ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_AMI);
+ break;
+ default:
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_arglist_ami::"
+ "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_arglist_ami::"
+ "visit_argument - "
+ "Bad visitor\n"),
+ -1);
+ }
+ if (node->accept (visitor) == -1)
+ {
+ delete visitor;
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_arglist_ami::"
+ "visit_argument - "
+ "codegen for arglist_ami failed\n"),
+ -1);
+ }
+ delete visitor;
+ return 0;
+}
diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ami.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ami.cpp
new file mode 100644
index 00000000000..b6e33ac7934
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ami.cpp
@@ -0,0 +1,93 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// operation_ami.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, "$Id$")
+
+
+// ******************************************************
+// Visitor for generating AMI stub for "operation" in client header.
+// ******************************************************
+
+be_visitor_operation_ami::be_visitor_operation_ami (be_visitor_context *ctx)
+ : be_visitor_operation (ctx)
+{
+}
+
+be_visitor_operation_ami::~be_visitor_operation_ami (void)
+{
+}
+
+int
+be_visitor_operation_ami::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_ARGLIST_AMI);
+ be_visitor *visitor = tao_cg->make_visitor (&ctx);
+ if (!visitor)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "be_visitor_operation_ami::"
+ "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::"
+ "visit_operation - "
+ "codegen for argument list failed\n"),
+ -1);
+ }
+ delete visitor;
+
+ return 0;
+}
diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/arglist_ami.h b/TAO/TAO_IDL/be_include/be_visitor_operation/arglist_ami.h
new file mode 100644
index 00000000000..532e6463974
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_operation/arglist_ami.h
@@ -0,0 +1,54 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// arglist_ami.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_ARGLIST_AMI_H_
+#define _BE_VISITOR_OPERATION_ARGLIST_AMI_H_
+
+// ******************************************************************************
+// Operation visitor for argument list - generates parameters in the signature
+// ******************************************************************************
+
+class be_visitor_operation_arglist_ami : public be_visitor_scope
+{
+ //
+ // = TITLE
+ // be_visitor_operaion_arglist_ami
+ //
+ // = DESCRIPTION
+ // This is a visitor to generate operation argument list for an
+ // AMI stub.
+ //
+ //
+public:
+ be_visitor_operation_arglist_ami (be_visitor_context *ctx);
+ // constructor
+
+ ~be_visitor_operation_arglist_ami (void);
+ // destructor
+
+ int visit_operation (be_operation *node);
+ // visit the operation
+
+ int visit_argument (be_argument *node);
+ // visit each argument
+};
+
+#endif /* _BE_VISITOR_OPERATION_ARGLIST_AMI_H_ */
diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/operation_ami.h b/TAO/TAO_IDL/be_include/be_visitor_operation/operation_ami.h
new file mode 100644
index 00000000000..f2003a6db22
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_operation/operation_ami.h
@@ -0,0 +1,51 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// operation_ami.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_OPERATION_AMI_H_
+#define _BE_VISITOR_OPERATION_OPERATION_AMI_H_
+
+// ************************************************************
+// Operation visitor to generate AMI stubs for client header
+// ************************************************************
+
+class be_visitor_operation_ami : public be_visitor_operation
+{
+ //
+ // = TITLE
+ // be_visitor_operation_ami.
+ //
+ // = DESCRIPTION
+ // This is a concrete visitor to generate the AMI stubs in the
+ // client header for operation.
+ //
+ //
+public:
+ be_visitor_operation_ami (be_visitor_context *ctx);
+ // constructor
+
+ ~be_visitor_operation_ami (void);
+ // destructor
+
+ virtual int visit_operation (be_operation *node);
+ // visit operation.
+};
+
+#endif /* _BE_VISITOR_OPERATION_OPERATION_AMI_H_ */