summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2005-03-17 08:13:50 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2005-03-17 08:13:50 +0000
commit543e6b928a5c2531e96be3310dfc34d2a230a0ac (patch)
treea422fbb330ce4deffb97909e3fd608e83273c15d
parente959aa4c9eb2b0cfb9e0f5bddb1f1ec8f042b4d1 (diff)
downloadATCD-543e6b928a5c2531e96be3310dfc34d2a230a0ac.tar.gz
*** empty log message ***
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp103
-rw-r--r--TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp5
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_typecode/union_typecode.h59
-rw-r--r--TAO/tao/TypeCode/Union_TypeCode.h4
4 files changed, 165 insertions, 6 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp
new file mode 100644
index 00000000000..783bd55d0ed
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_typecode/union_typecode.cpp
@@ -0,0 +1,103 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file union_typecode.cpp
+ *
+ * $Id$
+ *
+ * Union TypeCode generation visitor.
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+
+#include <string>
+
+
+TAO::be_visitor_union_typecode::be_visitor_union_typecode (
+ be_visitor_context * ctx)
+ : be_visitor_typecode_defn (ctx)
+{
+}
+
+int
+TAO::be_visitor_union_typecode::visit_union (be_union * node)
+{
+ TAO_OutStream & os = *this->ctx_->stream ();
+
+ os << be_nl << be_nl
+ << "// TAO_IDL - Generated from" << be_nl
+ << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
+
+
+ std::string const fields_name (std::string ("_tao_cases_")
+ + node->flat_name ());
+
+ // Generate array containing union case characteristics.
+ os << "static TAO::TypeCode::Case<char const *> const "
+ << fields_name.c_str ()
+ << "[] =" << be_idt_nl
+ << "{" << be_idt_nl;
+
+ if (this->visit_cases (node) != 0)
+ return -1;
+
+ os << be_uidt_nl
+ << "};" << be_uidt_nl << be_nl;
+
+ // Generate the TypeCode instantiation.
+ os
+ << "static TAO::TypeCode::Union<char const *," << be_nl
+ << " TAO::TypeCode::Union_Field<char const *> const *," << be_nl
+ << " TAO::Null_RefCount_Policy> const"
+ << be_idt_nl
+ << "_tao_tc_" << node->flat_name () << " (" << be_idt_nl
+ << "\"" << node->repoID () << "\"," << be_nl
+ << "\"" << node->original_local_name () << "\"," << be_nl
+ << node->disc_type ()->tc_name () << "," << be_nl
+ << "_tao_cases_" << node->flat_name () << "," << be_nl
+ << node->nfields () << ","
+ << node->default_index () "," << be_nl
+ << default_member_name,
+ << default_member_type
+ << ");" << be_uidt_nl
+ << be_uidt_nl;
+
+ return
+ this->gen_typecode_ptr (be_type::narrow_from_decl (node));
+}
+
+int
+TAO::be_visitor_union_typecode::visit_cases (be_union * node)
+{
+ AST_Field ** member_ptr = 0;
+
+ size_t const count = node->nfields ();
+
+ TAO_OutStream & os = *this->ctx_->stream ();
+
+ for (size_t i = 0; i < count; ++i)
+ {
+ node->field (member_ptr, i);
+
+ be_decl * const member_decl =
+ be_decl::narrow_from_decl (*member_ptr);
+
+ be_type * const member_type =
+ be_type::narrow_from_decl ((*member_ptr)->field_type ());
+
+ os << "{ "
+ << "\"" << member_decl->original_local_name () << "\", "
+ << "&" << member_type->tc_name ()
+ << " }";
+
+ if (i < count - 1)
+ os << ",";
+
+ os << be_nl;
+ }
+
+ return 0;
+}
diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp
index f9801d2d421..7480844e9ee 100644
--- a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp
@@ -277,9 +277,8 @@ int be_visitor_union_cs::visit_union (be_union *node)
if (be_global->tc_support ())
{
ctx = *this->ctx_;
- ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE);
-
- be_visitor_typecode_defn tc_visitor (&ctx);
+ // ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE);
+ TAO::be_visitor_union_typecode tc_visitor (&ctx);
if (tc_visitor.visit_union (node) == -1)
{
diff --git a/TAO/TAO_IDL/be_include/be_visitor_typecode/union_typecode.h b/TAO/TAO_IDL/be_include/be_visitor_typecode/union_typecode.h
new file mode 100644
index 00000000000..c2127af498e
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_typecode/union_typecode.h
@@ -0,0 +1,59 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file union_typecode.h
+ *
+ * $Id$
+ *
+ * Union TypeCode generation visitor.
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_BE_VISITOR_UNION_TYPECODE_H
+#define TAO_BE_VISITOR_UNION_TYPECODE_H
+
+#include "ace/pre.h"
+
+namespace TAO
+{
+
+ /**
+ * @class be_visitor_union_typecode
+ *
+ * @brief Union TypeCode generation visitor.
+ *
+ * Union TypeCode generation visitor.
+ */
+ class be_visitor_union_typecode
+ : public be_visitor_typecode_defn
+ {
+ public:
+
+ /// Constructor.
+ be_visitor_union_typecode (be_visitor_context * ctx);
+
+ /// Visit a union.
+ /**
+ * @todo The legacy method name "@c visit_union()" is
+ * redundant since it is obvious from the argument what kind
+ * of TypeCode is being visited. It will be changed once
+ * the rest of the legacy method names and their call sites
+ * are updated accordingly.
+ */
+ virtual int visit_union (be_union * node);
+
+ private:
+
+ /// Generate union field related TypeCode code.
+ int visit_cases (be_union * node);
+
+ };
+
+}
+
+#include "ace/post.h"
+
+#endif /* TAO_BE_VISITOR_UNION_TYPECODE_H */
diff --git a/TAO/tao/TypeCode/Union_TypeCode.h b/TAO/tao/TypeCode/Union_TypeCode.h
index 911f076c1c2..98df9331715 100644
--- a/TAO/tao/TypeCode/Union_TypeCode.h
+++ b/TAO/tao/TypeCode/Union_TypeCode.h
@@ -55,9 +55,7 @@ namespace TAO
CORBA::TypeCode_ptr * discriminant_type,
case_type const * cases,
CORBA::ULong ncases,
- CORBA::Long default_index,
- char const * default_member_name,
- CORBA::TypeCode_ptr * default_member_type);
+ CORBA::Long default_index);
/**
* @name TAO-specific @c CORBA::TypeCode Methods