summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2003-10-07 17:14:32 +0000
committerbala <balanatarajan@users.noreply.github.com>2003-10-07 17:14:32 +0000
commit0bfabf17e90bab43608c953eb73d4632af204327 (patch)
treeea7e81392bbcdd9391ead1949ec773d49bd7a3d9
parent3491cdce737ac6f95c3aecb54dbb2c21f0d248df (diff)
downloadATCD-0bfabf17e90bab43608c953eb73d4632af204327.tar.gz
ChangeLogTag:Tue Oct 7 09:35:57 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
-rw-r--r--TAO/ChangeLog_ref6
-rw-r--r--TAO/TAO_IDL/be/be_visitor_traits.cpp266
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_traits.h51
3 files changed, 323 insertions, 0 deletions
diff --git a/TAO/ChangeLog_ref b/TAO/ChangeLog_ref
index a1bb185e0aa..357d68519ec 100644
--- a/TAO/ChangeLog_ref
+++ b/TAO/ChangeLog_ref
@@ -1,3 +1,9 @@
+Tue Oct 7 09:35:57 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
+
+ * TAO_IDL/be/be_visitor_traits.cpp:
+ * TAO_IDL/be_include/be_visitor_traits.h: Added them back to the
+ repository.
+
Mon Oct 06 05:11:57 2003 Balachandran Natarajan <bala@dre.vanderbilt.edu>
* tao/Abstract_Servant_Base.h:
diff --git a/TAO/TAO_IDL/be/be_visitor_traits.cpp b/TAO/TAO_IDL/be/be_visitor_traits.cpp
new file mode 100644
index 00000000000..36032f9b35d
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_traits.cpp
@@ -0,0 +1,266 @@
+//=============================================================================
+/**
+* @file be_visitor_traits.cpp
+*
+* $Id$
+*
+* This visitor generates template specializations for traits of various
+* kinds for IDL declarations. These specialized template classes are then
+* used in other template classes in the ORB.
+*
+* @author Jeff Parsons <j.parsons@vanderbilt.edu>
+*/
+//=============================================================================
+
+#include "be_visitor_traits.h"
+#include "be_visitor_context.h"
+#include "be_root.h"
+#include "be_module.h"
+#include "be_interface.h"
+#include "be_valuetype.h"
+#include "be_interface_fwd.h"
+#include "be_valuetype_fwd.h"
+#include "be_eventtype.h"
+#include "be_eventtype_fwd.h"
+#include "be_typedef.h"
+#include "be_helper.h"
+#include "be_extern.h"
+
+ACE_RCSID (be,
+ be_visitor_traits,
+ "$Id$")
+
+be_visitor_traits::be_visitor_traits (be_visitor_context *ctx)
+ : be_visitor_scope (ctx)
+{
+}
+
+be_visitor_traits::~be_visitor_traits (void)
+{
+}
+
+int
+be_visitor_traits::visit_root (be_root *node)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ *os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
+ << "// " << __FILE__ << ":" << __LINE__;
+
+ *os << be_nl << be_nl
+ << "// Traits specializations." << be_nl
+ << "namespace TAO" << be_nl
+ << "{" << be_idt;
+
+ if (this->visit_scope (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_traits::"
+ "visit_root - visit scope failed\n"),
+ -1);
+ }
+
+ *os << be_uidt_nl
+ << "};";
+
+ return 0;
+}
+
+int
+be_visitor_traits::visit_module (be_module *node)
+{
+ if (this->visit_scope (node) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_traits::"
+ "visit_module - visit scope failed\n"),
+ -1);
+ }
+
+ return 0;
+}
+
+int
+be_visitor_traits::visit_interface (be_interface *node)
+{
+ if (node->cli_traits_gen ())
+ {
+ return 0;
+ }
+
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // Since the three blocks below generate specialized (i.e., non-template)
+ // classes, we don't want to generate them unless it's necessary - thus
+ // the logic surrounding each one.
+
+ // I think we need to generate this only for non-defined forward
+ // declarations.
+ if (!node->imported () && !node->is_defined ())
+ {
+ os->gen_ifdef_macro (node->flat_name (), "traits");
+
+ *os << be_nl << be_nl
+ << "ACE_TEMPLATE_SPECIALIZATION" << be_nl
+ << "struct " << be_global->stub_export_macro () << " Objref_Traits<"
+ << node->name () << ">" << be_nl
+ << "{" << be_idt_nl
+ << "static " << node->name () << "_ptr tao_duplicate ("
+ << be_idt << be_idt_nl
+ << node->name () << "_ptr" << be_uidt_nl
+ << ");" << be_uidt_nl
+ << "static void tao_release (" << be_idt << be_idt_nl
+ << node->name () << "_ptr" << be_uidt_nl
+ << ");" << be_uidt_nl
+ << "static " << node->name () << "_ptr tao_nil (void);" << be_nl
+ << "static CORBA::Boolean tao_marshal (" << be_idt << be_idt_nl
+ << node->name () << "_ptr p," << be_nl
+ << "TAO_OutputCDR & cdr" << be_uidt_nl
+ << ");" << be_uidt << be_uidt_nl
+ << "};";
+
+ os->gen_endif ();
+ }
+
+ if (this->visit_scope (node) != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_traits::"
+ "visit_interface - visit scope failed\n"),
+ -1);
+ }
+
+ node->cli_traits_gen (I_TRUE);
+ return 0;
+}
+
+int
+be_visitor_traits::visit_interface_fwd (be_interface_fwd *node)
+{
+ if (node->cli_traits_gen ())
+ {
+ return 0;
+ }
+
+ be_interface *fd =
+ be_interface::narrow_from_decl (node->full_definition ());
+
+ // The logic in visit_interface() should handle what gets generated
+ // and what doesn't.
+ if (this->visit_interface (fd) != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_traits::"
+ "visit_interface_fwd - code generation failed\n"),
+ -1);
+ }
+
+ node->cli_traits_gen (I_TRUE);
+ return 0;
+}
+
+int
+be_visitor_traits::visit_valuetype (be_valuetype *node)
+{
+ if (node->cli_traits_gen ())
+ {
+ return 0;
+ }
+
+ TAO_OutStream *os = this->ctx_->stream ();
+
+ // I think we need to generate this only for non-defined forward
+ // declarations.
+ if (!node->imported () && !node->is_defined ())
+ {
+ os->gen_ifdef_macro (node->flat_name (), "traits");
+
+ *os << be_nl << be_nl
+ << "ACE_TEMPLATE_SPECIALIZATION" << be_nl
+ << "struct " << be_global->stub_export_macro () << " Value_Traits<"
+ << node->name () << ">" << be_nl
+ << "{" << be_idt_nl
+ << "static void tao_add_ref (" << node->name () << " *);" << be_nl
+ << "static void tao_remove_ref (" << node->name () << " *);"
+ << be_uidt_nl
+ << "};";
+
+ os->gen_endif ();
+ }
+
+ int status = this->visit_scope (node);
+
+ if (status != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_traits::"
+ "visit_valuetype - visit scope failed\n"),
+ -1);
+ }
+
+ node->cli_traits_gen (I_TRUE);
+ return 0;
+}
+
+int
+be_visitor_traits::visit_valuetype_fwd (be_valuetype_fwd *node)
+{
+ if (node->cli_traits_gen ())
+ {
+ return 0;
+ }
+
+ be_valuetype *fd =
+ be_valuetype::narrow_from_decl (node->full_definition ());
+
+ // The logic in visit_valuetype() should handle what gets generated
+ // and what doesn't.
+ int status = this->visit_valuetype (fd);
+
+ if (status != 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_traits::"
+ "visit_valuetype_fwd - code generation failed\n"),
+ -1);
+ }
+
+ node->cli_traits_gen (I_TRUE);
+ return 0;
+}
+
+int
+be_visitor_traits::visit_eventtype (be_eventtype *node)
+{
+ return this->visit_valuetype (node);
+}
+
+int
+be_visitor_traits::visit_eventtype_fwd (be_eventtype_fwd *node)
+{
+ return this->visit_valuetype_fwd (node);
+}
+
+int
+be_visitor_traits::visit_typedef (be_typedef *node)
+{
+ this->ctx_->alias (node);
+
+ // Make a decision based on the primitive base type.
+ be_type *bt = node->primitive_base_type ();
+
+ if (!bt || (bt->accept (this) == -1))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N:%l) be_visitor_traits::"
+ "visit_typedef - "
+ "Bad primitive type\n"),
+ -1);
+ }
+
+ this->ctx_->alias (0);
+ node->cli_traits_gen (I_TRUE);
+ return 0;
+}
+
+
diff --git a/TAO/TAO_IDL/be_include/be_visitor_traits.h b/TAO/TAO_IDL/be_include/be_visitor_traits.h
new file mode 100644
index 00000000000..ed7890c9105
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_traits.h
@@ -0,0 +1,51 @@
+//=============================================================================
+/**
+* @file be_visitor_traits.h
+*
+* $Id$
+*
+* This visitor generates template specializations for traits of various
+* kinds for IDL declarations. These specialized template classes are then
+* used in other template classes in the ORB.
+*
+* @author Jeff Parsons <j.parsons@vanderbilt.edu>
+*/
+//=============================================================================
+#ifndef TAO_BE_VISITOR_TRAITS_H
+#define TAO_BE_VISITOR_TRAITS_H
+
+#include "be_visitor_scope.h"
+
+/**
+ * @class be_visitor_traits
+ *
+ * @brief Generates specialized template traits declarations.
+ */
+class be_visitor_traits : public be_visitor_scope
+{
+public:
+ be_visitor_traits (be_visitor_context *ctx);
+
+ virtual ~be_visitor_traits (void);
+
+ virtual int visit_root (be_root *node);
+
+ virtual int visit_module (be_module *node);
+
+ virtual int visit_interface (be_interface *node);
+
+ virtual int visit_interface_fwd (be_interface_fwd *node);
+
+ virtual int visit_valuetype (be_valuetype *node);
+
+ virtual int visit_valuetype_fwd (be_valuetype_fwd *node);
+
+ virtual int visit_eventtype (be_eventtype *node);
+
+ virtual int visit_eventtype_fwd (be_eventtype_fwd *node);
+
+ virtual int visit_typedef (be_typedef *node);
+};
+
+
+#endif // TAO_BE_VISITOR_TRAITS_H