summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2005-03-25 10:04:58 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2005-03-25 10:04:58 +0000
commit0af8f7944bac9f6b0e5afc287968df5c3b807fc5 (patch)
treec33d2b86d91e7280ef3592dbb59955ec01e0a2ca
parenta6f6b72179bd8562577bc3dfec26bc7b997ded90 (diff)
downloadATCD-0af8f7944bac9f6b0e5afc287968df5c3b807fc5.tar.gz
*** empty log message ***
-rw-r--r--TAO/TAO_IDL/be/be_sequence.cpp42
-rw-r--r--TAO/TAO_IDL/be/be_string.cpp70
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typecode/alias_typecode.cpp28
-rw-r--r--TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp108
-rw-r--r--TAO/TAO_IDL/be_include/be_sequence.h7
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h8
6 files changed, 212 insertions, 51 deletions
diff --git a/TAO/TAO_IDL/be/be_sequence.cpp b/TAO/TAO_IDL/be/be_sequence.cpp
index 4626a99936f..baa84866259 100644
--- a/TAO/TAO_IDL/be/be_sequence.cpp
+++ b/TAO/TAO_IDL/be/be_sequence.cpp
@@ -697,6 +697,48 @@ be_sequence::field_node (be_field *node)
this->field_node_ = node;
}
+// Overriden method.
+void
+be_sequence::compute_tc_name (void)
+{
+ // Sequence TypeCodes can only be accessed through an alias
+ // TypeCode. Generate a TypeCode name that is meant for internal
+ // use alone.
+
+// Identifier * tao_id = 0;
+// ACE_NEW (tao_id,
+// Identifier ("TAO"));
+
+ Identifier * tao_id = 0;
+ ACE_NEW (tao_id,
+ Identifier (""));
+
+ ACE_NEW (this->tc_name_,
+ UTL_ScopedName (tao_id,
+ 0));
+
+ char bound[30] = { 0 };
+
+ ACE_OS::sprintf (bound,
+ "_%u",
+ this->max_size ()->ev ()->u.ulval);
+
+ ACE_CString local_tc_name =
+ ACE_CString (this->flat_name ())
+ + ACE_CString (bound);
+
+ Identifier * id = 0;
+ ACE_NEW (id,
+ Identifier (local_tc_name.c_str ()));
+
+ UTL_ScopedName * conc_name = 0;
+ ACE_NEW (conc_name,
+ UTL_ScopedName (id,
+ 0));
+
+ this->tc_name_->nconc (conc_name);
+}
+
const char *
be_sequence::smart_fwd_helper_name (AST_Decl *ctx_scope,
be_type *elem)
diff --git a/TAO/TAO_IDL/be/be_string.cpp b/TAO/TAO_IDL/be/be_string.cpp
index c431bb52b1e..84424cdc35e 100644
--- a/TAO/TAO_IDL/be/be_string.cpp
+++ b/TAO/TAO_IDL/be/be_string.cpp
@@ -42,8 +42,8 @@ be_string::be_string (void)
}
be_string::be_string (AST_Decl::NodeType nt,
- UTL_ScopedName *n,
- AST_Expression *v,
+ UTL_ScopedName * n,
+ AST_Expression * v,
long width)
: COMMON_Base (),
AST_Decl (nt,
@@ -67,18 +67,62 @@ be_string::be_string (AST_Decl::NodeType nt,
void
be_string::compute_tc_name (void)
{
- // Start with the head as the CORBA namespace.
- Identifier *corba_id = 0;
- ACE_NEW (corba_id,
- Identifier ("CORBA"));
+ Identifier * id = 0;
- ACE_NEW (this->tc_name_,
- UTL_ScopedName (corba_id,
- 0));
+ AST_Expression zero (static_cast<unsigned long> (0));
+
+ if (*this->max_size () == &zero)
+ {
+ // If the string is unbounded, use the string TypeCode
+ // constants.
+
+ // Start with the head as the CORBA namespace.
+ Identifier * corba_id = 0;
+ ACE_NEW (corba_id,
+ Identifier ("CORBA"));
+
+ ACE_NEW (this->tc_name_,
+ UTL_ScopedName (corba_id,
+ 0));
+
+ ACE_NEW (id,
+ Identifier (this->width () == 1
+ ? "_tc_string"
+ : "_tc_wstring"));
+ }
+ else
+ {
+ // We have a bounded string. Generate a TypeCode name that is
+ // meant for internal use alone.
+
+// Identifier * tao_id = 0;
+// ACE_NEW (tao_id,
+// Identifier ("TAO"));
+
+ Identifier * tao_id = 0;
+ ACE_NEW (tao_id,
+ Identifier (""));
+
+ ACE_NEW (this->tc_name_,
+ UTL_ScopedName (tao_id,
+ 0));
+
+// char bound[30] = { 0 };
+
+// ACE_OS::sprintf (bound,
+// "_%u",
+// this->max_size ()->ev ()->u.ulval);
+
+// ACE_CString local_tc_name =
+// ACE_CString (this->width () == 1
+// ? "_tc_string"
+// : "_tc_wstring")
+// + ACE_CString (bound);
+
+ ACE_NEW (id,
+ Identifier (this->flat_name ()));
- Identifier *id = 0;
- ACE_NEW (id,
- Identifier ("_tc_string"));
+ }
UTL_ScopedName *conc_name = 0;
ACE_NEW (conc_name,
@@ -89,7 +133,7 @@ be_string::compute_tc_name (void)
}
int
-be_string::accept (be_visitor *visitor)
+be_string::accept (be_visitor * visitor)
{
return visitor->visit_string (this);
}
diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/alias_typecode.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/alias_typecode.cpp
index 2c0d9152209..492dced517a 100644
--- a/TAO/TAO_IDL/be/be_visitor_typecode/alias_typecode.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_typecode/alias_typecode.cpp
@@ -52,32 +52,8 @@ TAO::be_visitor_alias_typecode::visit_typedef (be_typedef * node)
<< "\"" << node->original_local_name () << "\"," << be_nl
<< "&";
- if (base->is_nested ()
- && base->defined_in ()->scope_node_type () == AST_Decl::NT_module)
- {
- be_module * const module =
- be_module::narrow_from_scope (base->defined_in ());
-
- ACE_ASSERT (module);
-
- for (UTL_IdListActiveIterator i (module->name ());
- !i.is_done ();
- i.next ())
- {
- char * const module_name = i.item ()->get_string ();
-
- if (ACE_OS::strcmp (module_name, "") != 0)
- {
- os << "::";
- }
-
- os << module_name;
- }
-
- os << "::_tao_tc_" << base->flat_name ();
- }
- else
- os << "&" << base->tc_name ();
+ int const success = this->gen_base_typecode_name (base);
+ ACE_ASSERT (success == 0);
os << ");" << be_uidt_nl
<< be_uidt_nl;
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 f2ae5961b22..988ce15738e 100644
--- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp
@@ -404,6 +404,16 @@ be_visitor_typecode_defn::gen_typecode_ptr (be_type * node)
{
TAO_OutStream & os = *this->ctx_->stream ();
+ if (node->node_type () == AST_Decl::NT_string
+ || node->node_type () == AST_Decl::NT_wstring
+ || node->node_type () == AST_Decl::NT_sequence)
+ {
+ // Don't bother generating a TypeCode_ptr for these types. They
+ // are only accessible through an alias TypeCode.
+
+ return 0;
+ }
+
// Is our enclosing scope a module? We need this check because for
// platforms that support namespaces, the typecode must be declared
// extern.
@@ -456,6 +466,58 @@ be_visitor_typecode_defn::gen_typecode_ptr (be_type * node)
return 0;
}
+
+int
+be_visitor_typecode_defn::gen_base_typecode_name (be_type * base)
+{
+ TAO_OutStream & os = *this->ctx_->stream ();
+
+ if (base->is_nested ()
+ && base->defined_in ()->scope_node_type () == AST_Decl::NT_module)
+ {
+ if (base->node_type () != AST_Decl::NT_string
+ && base->node_type () != AST_Decl::NT_wstring
+ && base->node_type () != AST_Decl::NT_sequence)
+ {
+ // Only generate scope names if types other than the ones
+ // listed above since the corresponding TypeCodes are at the
+ // file scope.
+
+// be_module * const module =
+// be_module::narrow_from_scope (base->defined_in ());
+
+// ACE_ASSERT (module);
+
+// for (UTL_IdListActiveIterator i (module->name ());
+// !i.is_done ();
+// i.next ())
+// {
+// char * const module_name = i.item ()->get_string ();
+
+// if (ACE_OS::strcmp (module_name, "") != 0)
+// {
+// os << "::";
+// }
+
+// os << module_name;
+// }
+
+ os << base->tc_name ();
+ }
+ else
+ {
+ // Internally used TypeCodes.
+
+ os << "::_tao_tc_" << base->tc_name ();
+ }
+ }
+ else
+ os << "::_tao_tc_"
+ << base->tc_name ();
+
+ return 0;
+}
+
int
be_visitor_typecode_defn::visit_array (be_array *node)
{
@@ -681,15 +743,34 @@ be_visitor_typecode_defn::visit_sequence (be_sequence * node)
<< "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
+ // generate typecode for the base type
+ this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE_NESTED);
+
+ if (!base || base->accept (this) == -1)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("(%N:%l) be_visitor_typecode_defn")
+ ACE_TEXT ("::visit_sequence) - ")
+ ACE_TEXT ("failed to generate base typecode\n")),
+ -1);
+ }
+
// Generate the TypeCode instantiation.
- os
- << "static TAO::TypeCode::Sequence<TAO::Null_RefCount_Policy> const"
- << be_idt_nl
- << "_tao_tc_" << node->flat_name () << " (" << be_idt_nl
- << "CORBA::tk_sequence," << be_nl
- << "&" << base->tc_name () << "," << be_nl
- << node->max_size () << ");" << be_uidt_nl
- << be_uidt_nl;
+ os << "static TAO::TypeCode::Sequence<TAO::Null_RefCount_Policy> const"
+ << be_idt_nl
+ << "_tao_tc_"
+// << node->flat_name () << "_" << node->max_size()
+ << node->tc_name ()
+ << " (" << be_idt_nl
+ << "CORBA::tk_sequence," << be_nl
+ << "&";
+
+ int const success = this->gen_base_typecode_name (base);
+ ACE_ASSERT (success == 0);
+
+ os << "," << be_nl
+ << node->max_size () << ");" << be_uidt_nl
+ << be_uidt_nl;
return this->gen_typecode_ptr (node);
}
@@ -697,16 +778,19 @@ be_visitor_typecode_defn::visit_sequence (be_sequence * node)
int
be_visitor_typecode_defn::visit_string (be_string * node)
{
+ if (node->max_size ()->ev()->u.ulval == 0)
+ {
+ // No need to generate a TypeCode for unbounded strings. Just
+ // use the {w}string TypeCode constant.
+ return 0;
+ }
+
TAO_OutStream & os = *this->ctx_->stream ();
os << be_nl << be_nl
<< "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
- os << be_nl << be_nl
- << "// WORK DAMN IT!" << be_nl
- << "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
-
// Generate the TypeCode instantiation.
os
<< "static TAO::TypeCode::String<TAO::Null_RefCount_Policy> const"
diff --git a/TAO/TAO_IDL/be_include/be_sequence.h b/TAO/TAO_IDL/be_include/be_sequence.h
index 7e3fb06f448..f6ae364d559 100644
--- a/TAO/TAO_IDL/be_include/be_sequence.h
+++ b/TAO/TAO_IDL/be_include/be_sequence.h
@@ -1,3 +1,5 @@
+// -*- C++ -*-
+
// $Id$
// ============================================================================
@@ -102,6 +104,11 @@ public:
virtual char *gen_name (void);
// Helper to create_name, also used by the traits visitor.
+protected:
+
+ virtual void compute_tc_name (void);
+ // Computes the fully scoped typecode name.
+
private:
const char *smart_fwd_helper_name (AST_Decl *elem_scope,
be_type *elem);
diff --git a/TAO/TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h b/TAO/TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h
index fc8f3e521db..04d8fc3a5db 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_typecode/typecode_defn.h
@@ -275,6 +275,14 @@ protected:
*/
int gen_typecode_ptr (be_type * node);
+ /// Generate the base type TypeCode name.
+ /**
+ * Generate the fully qualified base TypeCode name. Predominantly
+ * useful for TypeCodes that contain base/content TypeCodes
+ * (e.g. alias, sequence, etc).
+ */
+ int gen_base_typecode_name (be_type * base);
+
private:
//