summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2005-03-11 09:22:20 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2005-03-11 09:22:20 +0000
commitfc431fa451f0e6575c0fe035dd93007005942a30 (patch)
tree631ff46fe6518764606b50c92bf7eba3ef2d007d
parent365ecd3742cd9f2b46db5c14f0716e57dc2c866e (diff)
downloadATCD-fc431fa451f0e6575c0fe035dd93007005942a30.tar.gz
*** empty log message ***
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp14
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typecode/valuetype_typecode.cpp102
-rw-r--r--TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp6
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_typecode/valuetype_typecode.h65
4 files changed, 176 insertions, 11 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp
index c4f403e0661..4270e9ecd18 100644
--- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp
@@ -62,7 +62,7 @@ Scoped_Compute_Queue_Guard::~Scoped_Compute_Queue_Guard (void)
// TypeCode Definitions
// ******************************************************
-be_visitor_typecode_defn::be_visitor_typecode_defn (be_visitor_context *ctx)
+be_visitor_typecode_defn::be_visitor_typecode_defn (be_visitor_context * ctx)
: be_visitor_scope (ctx),
computed_tc_size_ (0),
computed_encap_len_ (0),
@@ -70,6 +70,11 @@ be_visitor_typecode_defn::be_visitor_typecode_defn (be_visitor_context *ctx)
tc_offset_ (0),
index_ (-1)
{
+ if (be_global->gen_anyop_files ())
+ {
+ // Switch streams. (ctx better be a copy!)
+ this->ctx_->stream (tao_cg->anyop_source ());
+ }
}
be_visitor_typecode_defn::~be_visitor_typecode_defn (void)
@@ -263,13 +268,6 @@ be_visitor_typecode_defn::gen_nested_namespace_end (be_module *node)
int
be_visitor_typecode_defn::visit_type (be_type *node)
{
- if (be_global->gen_anyop_files ())
- {
- // Switch streams, ctx will be reassigned when this
- // pass is done.
- this->ctx_->stream (tao_cg->anyop_source ());
- }
-
TAO_OutStream *os = this->ctx_->stream ();
// reset the queue
diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/valuetype_typecode.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/valuetype_typecode.cpp
new file mode 100644
index 00000000000..b36c0b3bceb
--- /dev/null
+++ b/TAO/TAO_IDL/be/be_visitor_typecode/valuetype_typecode.cpp
@@ -0,0 +1,102 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file struct_typecode.cpp
+ *
+ * $Id$
+ *
+ * Structure TypeCode generation visitor.
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+
+#include <string>
+
+
+TAO::be_visitor_struct_typecode::be_visitor_struct_typecode (
+ be_visitor_context * ctx,
+ bool is_exception)
+ : be_visitor_typecode_defn (ctx),
+ is_exception_ (is_exception)
+{
+}
+
+int
+TAO::be_visitor_struct_typecode::visit_structure (AST_Structure * 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_fields_")
+ + node->flat_name ());
+
+ // Generate array containing struct field characteristics.
+ os << "static TAO::TypeCode::Field<char const *> const "
+ << fields_name.c_str ()
+ << "[] =" << be_idt_nl
+ << "{" << be_idt_nl;
+
+ if (this->visit_members (node) != 0)
+ return -1;
+
+ os << be_uidt_nl
+ << "};" << be_uidt_nl << be_nl;
+
+ // Generate the TypeCode instantiation.
+ os
+ << "static TAO::TypeCode::Struct<char const *," << be_nl
+ << " TAO::TypeCode::Field<char const *> const *," << be_nl
+ << " CORBA::tk_"
+ << (this->is_exception_ ? "except" : "struct") << "," << 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
+ << "_tao_fields_" << node->flat_name () << "," << be_nl
+ << node->nfields () << ");" << be_uidt_nl
+ << be_uidt_nl;
+
+ return
+ this->gen_typecode_ptr (be_type::narrow_from_decl (node));
+}
+
+int
+TAO::be_visitor_struct_typecode::visit_members (AST_Structure * 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_valuetype/valuetype_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp
index 869e85a1e6b..9a219bc8a01 100644
--- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp
@@ -47,10 +47,10 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node)
if (be_global->tc_support ())
{
be_visitor_context 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);
+ be_visitor_valuetype_typecode tc_visitor (&ctx);
- if (node->accept (&tc_visitor) == -1)
+ if (tc_visitor.visit_valuetype (node) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_valuetype_cs::"
diff --git a/TAO/TAO_IDL/be_include/be_visitor_typecode/valuetype_typecode.h b/TAO/TAO_IDL/be_include/be_visitor_typecode/valuetype_typecode.h
new file mode 100644
index 00000000000..a58fa8fd932
--- /dev/null
+++ b/TAO/TAO_IDL/be_include/be_visitor_typecode/valuetype_typecode.h
@@ -0,0 +1,65 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file struct_typecode.h
+ *
+ * $Id$
+ *
+ * Structure TypeCode generation visitor.
+ *
+ * @author Ossama Othman <ossama@dre.vanderbilt.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_BE_VISITOR_STRUCT_TYPECODE_H
+#define TAO_BE_VISITOR_STRUCT_TYPECODE_H
+
+#include "ace/pre.h"
+
+namespace TAO
+{
+
+ /**
+ * @class be_visitor_struct_typecode
+ *
+ * @brief Structure TypeCode generation visitor.
+ *
+ * Structure TypeCode generation visitor.
+ */
+ class be_visitor_struct_typecode
+ : public be_visitor_typecode_defn
+ {
+ public:
+
+ /// Constructor.
+ be_visitor_struct_typecode (be_visitor_context * ctx,
+ bool is_exception);
+
+ /// Visit a structure.
+ /**
+ * @todo The legacy method name "@c visit_structure()" 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_structure (AST_Structure * node);
+
+ private:
+
+ /// Generate structure field related TypeCode code.
+ int visit_members (AST_Structure * node);
+
+ private:
+
+ /// Does the TypeCode refer to a CORBA exception?
+ bool const is_exception_;
+
+ };
+
+}
+
+#include "ace/post.h"
+
+#endif /* TAO_BE_VISITOR_STRUCT_TYPECODE_H */