summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_visitor_argument/arglist_ami.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/TAO_IDL/be/be_visitor_argument/arglist_ami.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_visitor_argument/arglist_ami.cpp321
1 files changed, 321 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_argument/arglist_ami.cpp b/TAO/TAO_IDL/be/be_visitor_argument/arglist_ami.cpp
new file mode 100644
index 00000000000..12e485067a0
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_argument/arglist_ami.cpp
@@ -0,0 +1,321 @@
+//
+// $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, arglist_ami, "$Id$")
+
+
+// ************************************************************
+// be_visitor_args_arglist for parameter list in method declarations and
+// definitions for AMI stubs.
+// ************************************************************
+
+be_visitor_args_arglist_ami::be_visitor_args_arglist_ami (be_visitor_context *ctx)
+ : be_visitor_args (ctx)
+{
+}
+
+be_visitor_args_arglist_ami::~be_visitor_args_arglist_ami (void)
+{
+}
+
+int
+be_visitor_args_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::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_arglist_ami::"
+ "visit_typedef - "
+ "accept on primitive type failed\n"),
+ -1);
+ }
+
+ this->ctx_->alias (0);
+
+ return result;
+}
+
+
+#ifdef IDL_HAS_VALUETYPE
+
+int
+be_visitor_args_arglist_ami::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_arglist_ami::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 */