summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-16 21:26:27 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-16 21:26:27 +0000
commitac2b5d61c13088948fe69cb78dd39a7802d9da86 (patch)
tree14653978b3cb60da4fc87031854b6f725b85898e
parenta34587420678f87c07ab78c2cb80de62c1a39b54 (diff)
downloadATCD-ac2b5d61c13088948fe69cb78dd39a7802d9da86.tar.gz
Extended my fix for anonymous sequences inside arrays to
work for sequences that contain recursive types.
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array.cpp1
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp2
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp28
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp10
-rw-r--r--TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp138
-rw-r--r--TAO/TAO_IDL/be/be_visitor_factory.cpp2
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_array.h1
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_array/cdr_op_ci.h2
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_array/cdr_op_cs.h90
9 files changed, 238 insertions, 36 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_array.cpp b/TAO/TAO_IDL/be/be_visitor_array.cpp
index 395a98fb319..3e09618fa28 100644
--- a/TAO/TAO_IDL/be/be_visitor_array.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array.cpp
@@ -33,5 +33,6 @@
#include "be_visitor_array/any_op_cs.cpp"
#include "be_visitor_array/cdr_op_ch.cpp"
#include "be_visitor_array/cdr_op_ci.cpp"
+#include "be_visitor_array/cdr_op_cs.cpp"
ACE_RCSID(be, be_visitor_array, "$Id$")
diff --git a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp
index b08c960285d..a31d97c3c58 100644
--- a/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array/array_ci.cpp
@@ -54,7 +54,7 @@ int be_visitor_array_ci::visit_array (be_array *node)
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_visitor_field_cdr_op_ch::"
+ "(%N:%l) be_visitor_array_ci::"
"visit_array - "
"bad base type\n"),
-1);
diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp
index 3af1abc3abd..776217da5d5 100644
--- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ch.cpp
@@ -82,34 +82,6 @@ be_visitor_array_cdr_op_ch::visit_array (be_array *node)
*os << node->name () << "_forany &);" << be_nl;
}
- // If we contain an anonymous sequence,
- // generate code for the sequence here.
-
- // retrieve the type
- be_type *bt = be_type::narrow_from_decl (node->base_type ());
- if (!bt)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_visitor_array_cdr_op_ch::"
- "visit_array - "
- "bad base type\n"),
- -1);
- }
-
- if (bt->node_type () == AST_Decl::NT_sequence)
- {
- if (this->gen_anonymous_base_type (bt,
- TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH)
- == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_visitor_array_cdr_op_ch::"
- "visit_array - "
- "gen_anonymous_base_type failed\n"),
- -1);
- }
- }
-
node->cli_hdr_cdr_op_gen (1);
return 0;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp
index 5995c25313b..49df957f765 100644
--- a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_ci.cpp
@@ -66,7 +66,7 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node)
if (!bt)
{
ACE_ERROR_RETURN ((LM_ERROR,
- "be_visitor_array_cdr_op_ci::"
+ "(%N:%l) be_visitor_array_cdr_op_ci::"
"visit_array - "
"Bad base type\n"),
-1);
@@ -77,14 +77,14 @@ be_visitor_array_cdr_op_ci::visit_array (be_array *node)
if (bt->node_type () == AST_Decl::NT_sequence)
{
- // @@ (JP) TODO - change state arg to _CI when the rest of
- // the cdr_op files get unhacked.
+ // CDR operators for sequences are now declared in the .i file,
+ // so we pass this state to the function.
if (this->gen_anonymous_base_type (bt,
- TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS)
+ TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH)
== -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_visitor_field_cdr_op_ch::"
+ "(%N:%l) be_visitor_array_cdr_op_ci::"
"visit_array - "
"gen_anonymous_base_type failed\n"),
-1);
diff --git a/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp
new file mode 100644
index 00000000000..11cfd6b6598
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_array/cdr_op_cs.cpp
@@ -0,0 +1,138 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// cdr_op_cs.cpp
+//
+// = DESCRIPTION
+// Visitor for code generation of Arrays for the CDR operators in the client
+// stubs.
+//
+// = AUTHOR
+// Jeff Parsons <parsons@cs.wustl.edu>
+//
+// ============================================================================
+
+#include "idl.h"
+#include "idl_extern.h"
+#include "be.h"
+
+#include "be_visitor_array.h"
+
+// ***************************************************************************
+// Array visitor for generating CDR operator declarations in the client
+// stubs file
+// ***************************************************************************
+
+be_visitor_array_cdr_op_cs::be_visitor_array_cdr_op_cs
+(be_visitor_context *ctx)
+ : be_visitor_decl (ctx)
+{
+}
+
+be_visitor_array_cdr_op_cs::~be_visitor_array_cdr_op_cs (void)
+{
+}
+
+int
+be_visitor_array_cdr_op_cs::visit_array (be_array *node)
+{
+ // retrieve the base type
+ be_type *bt = be_type::narrow_from_decl (node->base_type ());
+ if (!bt)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_cdr_op_cs::"
+ "visit_array - "
+ "Bad base type\n"),
+ -1);
+ }
+
+ // If we contain an anonymous sequence,
+ // generate code for the sequence here.
+
+ if (bt->node_type () == AST_Decl::NT_sequence)
+ {
+ if (this->gen_anonymous_base_type (bt,
+ TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS)
+ == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_array_cdr_op_cs::"
+ "visit_array - "
+ "gen_anonymous_base_type failed\n"),
+ -1);
+ }
+ }
+
+ return 0;
+}
+
+// Just do nothing for all the base types
+
+int
+be_visitor_array_cdr_op_cs::visit_enum (be_enum *)
+{
+ return 0;
+}
+
+int
+be_visitor_array_cdr_op_cs::visit_interface (be_interface *)
+{
+ return 0;
+}
+
+int
+be_visitor_array_cdr_op_cs::visit_interface_fwd (be_interface_fwd *)
+{
+ return 0;
+}
+
+int
+be_visitor_array_cdr_op_cs::visit_predefined_type (be_predefined_type *)
+{
+ return 0;
+}
+
+int
+be_visitor_array_cdr_op_cs::visit_sequence (be_sequence *)
+{
+ return 0;
+}
+
+int
+be_visitor_array_cdr_op_cs::visit_string (be_string *)
+{
+ return 0;
+}
+
+int
+be_visitor_array_cdr_op_cs::visit_structure (be_structure *)
+{
+ return 0;
+}
+
+int
+be_visitor_array_cdr_op_cs::visit_union (be_union *)
+{
+ return 0;
+}
+
+int
+be_visitor_array_cdr_op_cs::visit_typedef (be_typedef *)
+{
+ return 0;
+}
+
+// helper
+int
+be_visitor_array_cdr_op_cs::visit_node (be_type *bt)
+{
+ return 0;
+}
diff --git a/TAO/TAO_IDL/be/be_visitor_factory.cpp b/TAO/TAO_IDL/be/be_visitor_factory.cpp
index bbb90a662dd..e0ff7f482cf 100644
--- a/TAO/TAO_IDL/be/be_visitor_factory.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_factory.cpp
@@ -448,7 +448,7 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx)
case TAO_CodeGen::TAO_ARRAY_CDR_OP_CI:
return new be_visitor_array_cdr_op_ci (new_ctx);
case TAO_CodeGen::TAO_ARRAY_CDR_OP_CS:
- return new be_visitor_decl (new_ctx);
+ return new be_visitor_array_cdr_op_cs (new_ctx);
case TAO_CodeGen::TAO_ARGUMENT_AMI:
// @@ Alex: I am not sure about this case, yet (Alex).
diff --git a/TAO/TAO_IDL/be_include/be_visitor_array.h b/TAO/TAO_IDL/be_include/be_visitor_array.h
index 8b001cb6f01..619792ff8b1 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_array.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_array.h
@@ -32,5 +32,6 @@
#include "be_visitor_array/any_op_cs.h"
#include "be_visitor_array/cdr_op_ch.h"
#include "be_visitor_array/cdr_op_ci.h"
+#include "be_visitor_array/cdr_op_cs.h"
#endif /* TAO_BE_VISITOR_ARRAY_H */
diff --git a/TAO/TAO_IDL/be_include/be_visitor_array/cdr_op_ci.h b/TAO/TAO_IDL/be_include/be_visitor_array/cdr_op_ci.h
index 266e2696623..ef8caeabe43 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_array/cdr_op_ci.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_array/cdr_op_ci.h
@@ -23,7 +23,7 @@
#define _BE_VISITOR_ARRAY_CDR_OP_CI_H_
// ************************************************************
-// class be_visitor_array_cs
+// class be_visitor_array_cdr_op_ci
// ************************************************************
class be_visitor_array_cdr_op_ci : public be_visitor_decl
diff --git a/TAO/TAO_IDL/be_include/be_visitor_array/cdr_op_cs.h b/TAO/TAO_IDL/be_include/be_visitor_array/cdr_op_cs.h
new file mode 100644
index 00000000000..f89811cd9a8
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_array/cdr_op_cs.h
@@ -0,0 +1,90 @@
+//
+// $Id$
+//
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO IDL
+//
+// = FILENAME
+// cdr_op_cs.h
+//
+// = DESCRIPTION
+// The array's own CDR operators are generated in the .i file, but if the
+// array contains an anonymous sequence, those CDR operators will not
+// get generated on their own, and, since the sequence may contain a
+// recursive type, they must also be generated in the .cpp file. That is
+// the sole purpose of this visitor type.
+//
+// = AUTHOR
+// Jeff Parsons <parsons@cs.wustl.edu>
+//
+// ============================================================================
+
+#ifndef _BE_VISITOR_ARRAY_CDR_OP_CS_H_
+#define _BE_VISITOR_ARRAY_CDR_OP_CS_H_
+
+// ************************************************************
+// class be_visitor_array_cdr_op_cs
+// ************************************************************
+
+class be_visitor_array_cdr_op_cs : public be_visitor_decl
+{
+ //
+ // = TITLE
+ // be_visitor_array_cdr_op_cs
+ //
+ // = DESCRIPTION
+ // This is a concrete visitor for array that generates the CDR operator
+ // implementations for the array's element type, if that type is
+ // an anonymous sequence.
+ //
+
+public:
+ be_visitor_array_cdr_op_cs (be_visitor_context *ctx);
+ // constructor
+
+ ~be_visitor_array_cdr_op_cs (void);
+ // destructor
+
+ virtual int visit_array (be_array *node);
+ // visit array
+
+ // = Visitor methods on array types
+
+ virtual int visit_enum (be_enum *node);
+ // visit an enum
+
+ virtual int visit_interface (be_interface *node);
+ // visit an interface
+
+ virtual int visit_interface_fwd (be_interface_fwd *node);
+ // visit an interface forward node
+
+ virtual int visit_predefined_type (be_predefined_type *node);
+ // visit a predefined type node
+
+ virtual int visit_sequence (be_sequence *node);
+ // visit sequence
+
+ virtual int visit_string (be_string *node);
+ // visit string
+
+ virtual int visit_structure (be_structure *node);
+ // visit structure
+
+ virtual int visit_typedef (be_typedef *node);
+ // visit typedef
+
+ virtual int visit_union (be_union *node);
+ // visit union
+
+protected:
+
+ int visit_node (be_type *);
+ // helper that does the common job
+
+};
+
+#endif /* _BE_VISITOR_ARRAY_CDR_OP_CS_H_ */