summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-10-31 13:56:55 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2005-10-31 13:56:55 +0000
commitc05dfdfe356bc486cb389764510a0d1a290c1c02 (patch)
tree8b015bb44777d7b55b9ce765577cfc4430c53856
parentb7d33cac1a53238938a0ce371a25f56b50c494a0 (diff)
downloadATCD-c05dfdfe356bc486cb389764510a0d1a290c1c02.tar.gz
ChangeLogTag: Fri Oct 28 23:55:14 UTC 2005 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--TAO/TAO_IDL/ast/ast_type.cpp4
-rw-r--r--TAO/TAO_IDL/be/be_valuetype.cpp51
-rw-r--r--TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp113
-rw-r--r--TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp8
-rw-r--r--TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp91
-rw-r--r--TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp120
-rw-r--r--TAO/TAO_IDL/be_include/be_valuetype.h7
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype.h4
-rw-r--r--TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_obv_cs.h12
-rw-r--r--TAO/TAO_IDL/include/ast_attribute.h3
10 files changed, 287 insertions, 126 deletions
diff --git a/TAO/TAO_IDL/ast/ast_type.cpp b/TAO/TAO_IDL/ast/ast_type.cpp
index 06115de836d..7cdbc9b7463 100644
--- a/TAO/TAO_IDL/ast/ast_type.cpp
+++ b/TAO/TAO_IDL/ast/ast_type.cpp
@@ -345,9 +345,7 @@ AST_Type::nested_name (const char* local_name,
use_next = ACE_OS::strstr (use_curr, "::");
// If the scopes are identical, don't supply them.
- if (ACE_OS::strcmp (def_name,
- use_name)
- == 0)
+ if (ACE_OS::strcmp (def_name, use_name) == 0)
{
if (prefix != 0)
{
diff --git a/TAO/TAO_IDL/be/be_valuetype.cpp b/TAO/TAO_IDL/be/be_valuetype.cpp
index 9fb566a5fdf..b8fd83d6b6c 100644
--- a/TAO/TAO_IDL/be/be_valuetype.cpp
+++ b/TAO/TAO_IDL/be/be_valuetype.cpp
@@ -418,13 +418,40 @@ be_valuetype::will_have_factory (void)
return (fs == FS_ABSTRACT_FACTORY || fs == FS_CONCRETE_FACTORY);
}
-int
-be_valuetype::gen_helper_header (char*,
- char*)
+bool
+be_valuetype::has_member (void)
{
- TAO_OutStream *os = 0;
+ AST_ValueType *parent = this->pd_inherits_concrete;
+
+ // We're looking for inherited members too.
+ if (parent != 0)
+ {
+ be_valuetype *be_parent =
+ be_valuetype::narrow_from_decl (parent);
+
+ if (be_parent->has_member ())
+ {
+ return true;
+ }
+ }
+
+ for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next())
+ {
+ if (si.item ()->node_type () == AST_Decl::NT_field)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
- os = tao_cg->client_header ();
+int
+be_valuetype::gen_helper_header (char *, char *)
+{
+ TAO_OutStream *os = tao_cg->client_header ();
*os << be_nl << be_nl
<< "// TAO_IDL - Generated from" << be_nl
@@ -445,12 +472,9 @@ be_valuetype::gen_helper_header (char*,
}
int
-be_valuetype::gen_helper_inline (char*,
- char*)
+be_valuetype::gen_helper_inline (char *, char *)
{
- TAO_OutStream *os = 0;
-
- os = tao_cg->client_inline ();
+ TAO_OutStream *os = tao_cg->client_inline ();
// There is a problem, here. Looks like the if defined __ACE_INLINE
// is not getting generated... Actually this is a much bigger
@@ -476,12 +500,9 @@ be_valuetype::gen_helper_inline (char*,
int
-be_valuetype::gen_helper_stubs (char* ,
- char* )
+be_valuetype::gen_helper_stubs (char *, char *)
{
- TAO_OutStream *os = 0;
-
- os = tao_cg->client_stubs ();
+ TAO_OutStream *os = tao_cg->client_stubs ();
*os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp
index f1748719882..d58167597ea 100644
--- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp
@@ -52,16 +52,6 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node)
-1);
}
- AST_Field *field = AST_Field::narrow_from_decl (d);
-
- if (field && field->visibility () == AST_Field::vis_PRIVATE)
- {
- continue;
- // Ignore private fields in this run
- // AST_Attribute derives from AST_Field, so test for
- // vis_PRIVATE is ok (the attribute has it set to vis_NA)
- }
-
be_decl *bd = be_decl::narrow_from_decl (d);
// Set the scope node as "node" in which the code is being
// generated so that elements in the node's scope can use it
@@ -71,63 +61,24 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node)
this->ctx_->node (bd);
this->elem_number_++;
- if (bd == 0 || bd->accept (this) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_visitor_scope::visit_scope - "
- "codegen for scope failed\n"),
- -1);
-
- }
- }
-
- this->elem_number_ = 0;
-
- for (UTL_ScopeActiveIterator sj (node, UTL_Scope::IK_decls);
- !sj.is_done ();
- sj.next())
- {
- AST_Decl *d = sj.item ();
-
- if (!d)
- {
- ACE_ERROR_RETURN ((LM_ERROR,
- "(%N:%l) be_visitor_scope::visit_scope - "
- "bad node in this scope\n"),
- -1);
- }
-
AST_Field *field = AST_Field::narrow_from_decl (d);
-
- if (!field
- || (field && field->visibility () != AST_Field::vis_PRIVATE))
+
+ if (field != 0 && field->visibility () == AST_Field::vis_PRIVATE)
{
- // Only private fields.
- continue;
+ this->begin_private ();
}
-
- ++ n_processed;
-
- if (n_processed == 1)
+ else
{
- this->begin_private ();
+ this->begin_public ();
}
-
- be_decl *bd = be_decl::narrow_from_decl (d);
- // Set the scope node as "node" in which the code is being
- // generated so that elements in the node's scope can use it
- // for code generation.
-
- this->ctx_->scope (node->decl ());
- this->ctx_->node (bd);
- this->elem_number_++;
-
+
if (bd == 0 || bd->accept (this) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,
"(%N:%l) be_visitor_scope::visit_scope - "
- "codegen for scope failed\n"),
+ "codegen for scope failed\n"),
-1);
+
}
}
@@ -817,6 +768,54 @@ be_visitor_valuetype::gen_field_pd (be_field *node)
return 0;
}
+void
+be_visitor_valuetype::gen_obv_init_constructor_args (be_valuetype *node,
+ unsigned long &index)
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+ AST_ValueType *parent = node->inherits_concrete ();
+
+ // Generate for inherited members first.
+ if (parent != 0)
+ {
+ be_valuetype *be_parent =
+ be_valuetype::narrow_from_decl (parent);
+ this->gen_obv_init_constructor_args (be_parent, index);
+ }
+
+ be_visitor_context ctx (*this->ctx_);
+ be_visitor_args_arglist visitor (&ctx);
+
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next())
+ {
+ be_field *f = be_field::narrow_from_decl (si.item ());
+
+ if (f == 0)
+ {
+ continue;
+ }
+
+ *os << (index++ != 0 ? "," : "") << be_nl;
+
+ ACE_CString arg_name ("_tao_init_");
+ arg_name += f->local_name ()->get_string ();
+ Identifier id (arg_name.c_str ());
+ UTL_ScopedName sn (&id, 0);
+ be_type *ft = be_type::narrow_from_decl (f->field_type ());
+ idl_bool seen = ft->seen_in_operation ();
+
+ // This sets ft->seen_in_operation (I_TRUE), so we have to
+ // restore the original value below.
+ be_argument arg (AST_Argument::dir_IN,
+ ft,
+ &sn);
+ ft->seen_in_operation (seen);
+ visitor.visit_argument (&arg);
+ id.destroy ();
+ }
+}
// Generate the _init definition.
int
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp
index 5760338f9b8..8c2900977c6 100644
--- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp
@@ -265,7 +265,7 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node)
// instantiate us.
*os << be_uidt_nl << be_nl << "protected:" << be_idt_nl
<< node->local_name ()
- << " (void);" << be_nl << be_nl;
+ << " (void);" << be_nl;
if (!is_an_amh_exception_holder)
{
@@ -482,7 +482,8 @@ be_visitor_valuetype_ch::begin_public (void)
{
TAO_OutStream *os = this->ctx_->stream ();
- *os << "public:" << be_idt_nl;
+ *os << be_uidt_nl << be_nl << "public:"
+ << be_idt;
}
void
@@ -490,7 +491,8 @@ be_visitor_valuetype_ch::begin_private (void)
{
TAO_OutStream *os = this->ctx_->stream ();
- *os << be_uidt_nl << be_nl << "protected:" << be_idt;
+ *os << be_uidt_nl << be_nl << "protected:"
+ << be_idt;
}
int
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp
index e0d5cb52626..0791251c39b 100644
--- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_ch.cpp
@@ -142,33 +142,10 @@ be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node)
// STEP 2: Generate the body ==
- *os << "{" << be_nl;
-
- this->begin_public ();
-
- // Default constructor and destructor are public if OBV class is concrete
- if (!node->have_operation ())
- {
-
- *os << be_nl;
-
- if (! node->is_nested ())
- {
- *os << "OBV_";
- }
-
- *os << node->local_name () << " (void);";
-
- *os << be_nl << "virtual ~";
-
- if (! node->is_nested ())
- {
- *os << "OBV_";
- }
-
- *os << node->local_name () << " (void);";
- }
+ *os << "{";
+ be_valuetype::FactoryStyle factory_style =
+ node->determine_factory_style ();
// Generate code for the OBV_ class definition.
if (this->visit_valuetype_scope (node) == -1)
@@ -194,27 +171,52 @@ be_visitor_valuetype_obv_ch::visit_valuetype (be_valuetype *node)
if (node->have_operation ())
{
- // Default constructor and destructor are protected if OBV class is abstract
- *os << be_nl << be_uidt_nl << "protected:" << be_idt;
+ this->begin_private ();
+ }
+ else
+ {
+ this->begin_public ();
+ }
+
+ *os << be_nl;
+
+ // Default constructor.
+ if (! node->is_nested ())
+ {
+ *os << "OBV_";
+ }
+ *os << node->local_name () << " (void);";
+
+ // Initializing constructor.
+ if (node->has_member ())
+ {
*os << be_nl;
+
if (! node->is_nested ())
{
*os << "OBV_";
}
+
+ *os << node->local_name () << " (" << be_idt << be_idt;
+
+ unsigned long index = 0;
+ this->gen_obv_init_constructor_args (node, index);
+
+ *os << be_uidt_nl
+ << ");" << be_uidt;
+ }
- *os << node->local_name () << " (void);";
-
- *os << be_nl << "virtual ~";
+ // Virtual destructor.
+ *os << be_nl << "virtual ~";
- if (! node->is_nested ())
- {
- *os << "OBV_";
- }
-
- *os << node->local_name () << " (void);";
+ if (! node->is_nested ())
+ {
+ *os << "OBV_";
}
+ *os << node->local_name () << " (void);";
+
// Map fields to private data.
if (!node->opt_accessor ())
{
@@ -287,14 +289,23 @@ be_visitor_valuetype_obv_ch::visit_field (be_field *node)
void
be_visitor_valuetype_obv_ch::begin_public (void)
{
+ AST_Decl::NodeType nt = this->ctx_->node ()->node_type ();
+
+ // These types are skipped in the OBV class.
+ if (nt == AST_Decl::NT_attr || nt == AST_Decl::NT_op)
+ {
+ return;
+ }
+
TAO_OutStream *os = this->ctx_->stream ();
- *os << "public:" << be_idt;
+ *os << be_uidt_nl << be_nl
+ << "public:" << be_idt;
}
void
be_visitor_valuetype_obv_ch::begin_private (void)
{
TAO_OutStream *os = this->ctx_->stream ();
- *os << be_uidt_nl << be_nl;
- *os << "protected:" << be_idt;
+ *os << be_uidt_nl << be_nl
+ << "protected:" << be_idt;
}
diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp
index 34dd41725df..9e41c78d39f 100644
--- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp
+++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_obv_cs.cpp
@@ -33,7 +33,7 @@ ACE_RCSID (be_visitor_valuetype,
be_visitor_valuetype_obv_cs::be_visitor_valuetype_obv_cs (
be_visitor_context *ctx
)
- : be_visitor_scope (ctx)
+ : be_visitor_valuetype (ctx)
{
}
@@ -57,6 +57,7 @@ be_visitor_valuetype_obv_cs::visit_valuetype (be_valuetype *node)
*os << be_nl << be_nl << "// TAO_IDL - Generated from" << be_nl
<< "// " << __FILE__ << ":" << __LINE__ << be_nl << be_nl;
+ // Default constructor.
*os << node->full_obv_skel_name () << "::";
if (! node->is_nested ())
@@ -66,7 +67,34 @@ be_visitor_valuetype_obv_cs::visit_valuetype (be_valuetype *node)
*os << node->local_name () << " (void)" << be_nl
<< "{}" << be_nl << be_nl;
+
+ // Initializing constructor.
+ if (node->has_member ())
+ {
+ *os << node->full_obv_skel_name () << "::";
+
+ if (! node->is_nested ())
+ {
+ *os << "OBV_";
+ }
+
+ *os << node->local_name () << " (" << be_idt << be_idt;
+
+ unsigned long index = 0;
+ this->gen_obv_init_constructor_args (node, index);
+ *os << be_uidt_nl
+ << ")" << be_nl
+ << ": " << be_idt;
+
+ index = 0;
+ this->gen_obv_init_constructor_init_list (node);
+
+ *os << be_uidt << be_uidt_nl
+ << "{}" << be_nl << be_nl;
+ }
+
+ // Destructor.
*os << node->full_obv_skel_name () << "::~";
if (! node->is_nested ())
@@ -157,3 +185,93 @@ be_visitor_valuetype_obv_cs::visit_field (be_field *node)
return 0;
}
+
+void
+be_visitor_valuetype_obv_cs::gen_obv_init_constructor_init_list (
+ be_valuetype *node
+ )
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+ AST_ValueType *parent = node->inherits_concrete ();
+
+ // Generate for inherited members first.
+ if (parent != 0)
+ {
+ be_valuetype *be_parent = be_valuetype::narrow_from_decl (parent);
+
+ if (be_parent->has_member ())
+ {
+ *os << be_parent->full_obv_skel_name () << " ("
+ << be_idt << be_idt;
+
+ unsigned long p_index = 0;
+ this->gen_obv_init_base_constructor_args (be_parent, p_index);
+
+ *os << be_uidt_nl
+ << ")" << be_uidt;
+
+ // data_members_counts checks only for non-inherited members.
+ if (node->data_members_count () > 0)
+ {
+ *os << "," << be_nl;
+ }
+ }
+ }
+
+ unsigned long index = 0;
+
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next())
+ {
+ AST_Field *f = AST_Field::narrow_from_decl (si.item ());
+
+ if (f == 0)
+ {
+ continue;
+ }
+
+ if (index++ != 0)
+ {
+ *os << "," << be_nl;
+ }
+
+ *os << node->field_pd_prefix () << f->local_name ()
+ << " (_tao_init_" << f->local_name ()
+ << ")";
+ }
+}
+
+void
+be_visitor_valuetype_obv_cs::gen_obv_init_base_constructor_args (
+ be_valuetype *node,
+ unsigned long &index
+ )
+{
+ TAO_OutStream *os = this->ctx_->stream ();
+ AST_ValueType *parent = node->inherits_concrete ();
+
+ // Generate for inherited members first.
+ if (parent != 0)
+ {
+ be_valuetype *be_parent =
+ be_valuetype::narrow_from_decl (parent);
+ this->gen_obv_init_base_constructor_args (be_parent, index);
+ }
+
+ for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls);
+ !si.is_done ();
+ si.next())
+ {
+ be_field *f = be_field::narrow_from_decl (si.item ());
+
+ if (f == 0)
+ {
+ continue;
+ }
+
+ *os << (index++ != 0 ? "," : "") << be_nl
+ << "_tao_init_" << f->local_name ();
+ }
+}
+
diff --git a/TAO/TAO_IDL/be_include/be_valuetype.h b/TAO/TAO_IDL/be_include/be_valuetype.h
index b3c81fa052f..20ddb721b4f 100644
--- a/TAO/TAO_IDL/be_include/be_valuetype.h
+++ b/TAO/TAO_IDL/be_include/be_valuetype.h
@@ -72,7 +72,7 @@ public:
virtual int gen_helper_stubs (char *local_name = 0,
char *full_name = 0);
// Generate the helper functions implementation.
-
+
void gen_var_out_seq_decls (void);
// Generate the declarations used by the template _var, _out
// classes for valuetypes, and by sequence template classes.
@@ -176,7 +176,10 @@ public:
virtual idl_bool will_have_factory (void);
// Use the above enum and methods to determine this after the
// node's scope is visited but before code generation.
-
+
+ bool has_member (void);
+ // Decides whether to generate the initializing contstructor or not.
+
private:
char *full_obv_skel_name_;
diff --git a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype.h b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype.h
index 1789d83b667..a0ccc9cd6fb 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype.h
@@ -97,6 +97,10 @@ public:
virtual int gen_init_impl (be_valuetype *node);
// generate the _init implementation
+ void gen_obv_init_constructor_args (be_valuetype *node,
+ unsigned long &index);
+ // Recursively generate args for the initializing constuctor.
+
protected:
static idl_bool obv_need_ref_counter (be_valuetype *node);
// check is VT needs a RefCounter mix-in in OBV_ class
diff --git a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_obv_cs.h b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_obv_cs.h
index b6a05417462..4c5eca7d56d 100644
--- a/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_obv_cs.h
+++ b/TAO/TAO_IDL/be_include/be_visitor_valuetype/valuetype_obv_cs.h
@@ -24,7 +24,7 @@
#ifndef _BE_VALUETYPE_VALUETYPE_OBV_CS_H_
#define _BE_VALUETYPE_VALUETYPE_OBV_CS_H_
-class be_visitor_valuetype_obv_cs : public be_visitor_scope
+class be_visitor_valuetype_obv_cs : public be_visitor_valuetype
{
//
// = TITLE
@@ -43,8 +43,16 @@ public:
virtual int visit_valuetype (be_valuetype *node);
virtual int visit_eventtype (be_eventtype *node);
-
virtual int visit_field (be_field *node);
+
+private:
+ void gen_obv_init_constructor_init_list (be_valuetype *node);
+ // Generate member assignments for the initializing constructor.
+
+ void gen_obv_init_base_constructor_args (be_valuetype *node,
+ unsigned long &index);
+ // Called by method above to generate base class constructor call.
+
};
#endif /* _BE_VALUETYPE_VALUETYPE_OBV_CS_H_ */
diff --git a/TAO/TAO_IDL/include/ast_attribute.h b/TAO/TAO_IDL/include/ast_attribute.h
index faecd45b815..c1f2998aeaf 100644
--- a/TAO/TAO_IDL/include/ast_attribute.h
+++ b/TAO/TAO_IDL/include/ast_attribute.h
@@ -73,9 +73,6 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
class UTL_ExceptList;
class UTL_NameList;
-// Representation of attribute declaration:
-// An attribute is a field with a readonly property.
-
class TAO_IDL_FE_Export AST_Attribute : public virtual AST_Field
{
public: