diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-03-06 16:21:26 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-03-06 16:21:26 +0000 |
commit | cd3279390f9f4efd579e999a6d217f4b4dc26015 (patch) | |
tree | fef532fe972cd40066e07ede02a4547550403597 | |
parent | 9eccedae87ddc91ba43830df72195616c6bd2b27 (diff) | |
download | ATCD-cd3279390f9f4efd579e999a6d217f4b4dc26015.tar.gz |
ChangeLogTag: Wed Mar 6 10:15:45 2002 Jeff Parsons <parsons@cs.wustl.edu>
233 files changed, 14884 insertions, 13222 deletions
diff --git a/TAO/TAO_IDL/TAO_IDL_FE_DLL.dsp b/TAO/TAO_IDL/TAO_IDL_FE_DLL.dsp index 0db8938c969..07cbddf13d4 100644 --- a/TAO/TAO_IDL/TAO_IDL_FE_DLL.dsp +++ b/TAO/TAO_IDL/TAO_IDL_FE_DLL.dsp @@ -118,6 +118,10 @@ SOURCE=.\ast\ast_check.cpp # End Source File
# Begin Source File
+SOURCE=.\ast\ast_component.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\ast\ast_concrete_type.cpp
# End Source File
# Begin Source File
@@ -354,6 +358,10 @@ SOURCE=.\include\ast_attribute.h # End Source File
# Begin Source File
+SOURCE=.\include\ast_component.h
+# End Source File
+# Begin Source File
+
SOURCE=.\include\ast_concrete_type.h
# End Source File
# Begin Source File
diff --git a/TAO/TAO_IDL/ast/ast_component.cpp b/TAO/TAO_IDL/ast/ast_component.cpp new file mode 100644 index 00000000000..6f76ac0807c --- /dev/null +++ b/TAO/TAO_IDL/ast/ast_component.cpp @@ -0,0 +1,45 @@ +#include "idl.h" +#include "idl_extern.h" + +ACE_RCSID(ast, ast_component, "$Id$") + +// Constructor(s) and destructor. + +AST_Component::AST_Component (void) + : parent_ (0) +{ +} + +AST_Component::AST_Component (UTL_ScopedName *n, + AST_Component *parent, + AST_Interface **supports, + long n_supports, + AST_Interface **supports_flat, + long n_supports_flat) + : AST_Interface (n, + supports, + n_supports, + supports_flat, + n_supports_flat, + I_FALSE, + I_FALSE), + AST_Type (AST_Decl::NT_component, + n), + AST_Decl (AST_Decl::NT_component, + n), + UTL_Scope (AST_Decl::NT_component), + COMMON_Base (I_FALSE, + I_FALSE), + parent_ (parent) +{ +} + +AST_Component::~AST_Component (void) +{ +} + +AST_Component * +AST_Component::parent (void) +{ + return this->parent_; +} diff --git a/TAO/TAO_IDL/ast/ast_constant.cpp b/TAO/TAO_IDL/ast/ast_constant.cpp index b79f18b51f1..a08c833c3a6 100644 --- a/TAO/TAO_IDL/ast/ast_constant.cpp +++ b/TAO/TAO_IDL/ast/ast_constant.cpp @@ -162,11 +162,6 @@ AST_Constant::AST_Constant (AST_Expression::ExprType t, AST_Constant::~AST_Constant (void) { - if (this->pd_constant_value != 0) - { - delete this->pd_constant_value; - this->pd_constant_value = 0; - } } // Redefinition of inherited virtual operations. @@ -187,6 +182,17 @@ AST_Constant::ast_accept (ast_visitor *visitor) return visitor->visit_constant (this); } +void +AST_Constant::destroy (void) +{ + if (this->pd_constant_value != 0) + { + this->pd_constant_value->destroy (); + delete this->pd_constant_value; + this->pd_constant_value = 0; + } +} + // Data accessors. AST_Expression * diff --git a/TAO/TAO_IDL/ast/ast_decl.cpp b/TAO/TAO_IDL/ast/ast_decl.cpp index aac03d7062d..d5fb29f3093 100644 --- a/TAO/TAO_IDL/ast/ast_decl.cpp +++ b/TAO/TAO_IDL/ast/ast_decl.cpp @@ -116,14 +116,14 @@ AST_Decl::AST_Decl (void) pd_node_type (NT_module), pd_line (-1), pd_file_name (0), - pd_name (0), pd_local_name (0), pd_original_local_name (0), pd_added (I_FALSE), full_name_ (0), prefix_ (0), version_ (0), - anonymous_ (I_FALSE) + anonymous_ (I_FALSE), + typeid_set_ (I_FALSE) { } @@ -133,19 +133,21 @@ AST_Decl::AST_Decl (NodeType nt, : repoID_ (0), pd_imported (idl_global->imported ()), pd_in_main_file (idl_global->in_main_file ()), - pd_defined_in (idl_global->scopes ()->depth () > 0 - ? idl_global->scopes ()->top () + pd_defined_in (idl_global->scopes ().depth () > 0 + ? idl_global->scopes ().top () : 0), pd_node_type (nt), pd_line (idl_global->lineno ()), pd_file_name (idl_global->filename ()), pd_name (0), pd_local_name (n == 0 ? 0 : n->last_component ()->copy ()), + pd_original_local_name (0), pd_added (I_FALSE), full_name_ (0), prefix_ (0), version_ (0), - anonymous_ (anonymous) + anonymous_ (anonymous), + typeid_set_ (I_FALSE) { this->compute_full_name (n); @@ -161,10 +163,10 @@ AST_Decl::AST_Decl (NodeType nt, this->prefix_ = ACE::strnew (prefix); } - // Keep the name _cxx_ removed, if any. if (n != 0) { - this->original_local_name (n->last_component ()->copy ()); + // The function body creates its own copy. + this->original_local_name (n->last_component ()); } } @@ -178,6 +180,14 @@ AST_Decl::~AST_Decl (void) void AST_Decl::compute_full_name (UTL_ScopedName *n) { + // This should happen only when we are a non-void predefined type, + // in which case our scoped name has already been created by the + // AST_PredefinedType constructor. + if (n == 0) + { + return; + } + UTL_ScopedName *cn = 0; AST_Decl *d = 0; @@ -185,9 +195,9 @@ AST_Decl::compute_full_name (UTL_ScopedName *n) this->pd_name = 0; // Global scope? - if (defined_in () == 0) + if (this->defined_in () == 0) { - this->pd_name = n; + this->pd_name = (UTL_IdList *) n->copy (); return; } @@ -202,7 +212,7 @@ AST_Decl::compute_full_name (UTL_ScopedName *n) if (cn != 0) { - this->pd_name = (UTL_ScopedName *) cn->copy (); + this->pd_name = (UTL_IdList *) cn->copy (); } if (this->pd_local_name != 0) @@ -224,7 +234,7 @@ AST_Decl::compute_full_name (UTL_ScopedName *n) } } else - { + {/* if (this->pd_name == 0) { ACE_NEW (this->pd_name, @@ -239,6 +249,42 @@ AST_Decl::compute_full_name (UTL_ScopedName *n) 0)); this->pd_name->nconc (conc_name); + }*/ + } +} + +void +AST_Decl::set_prefix_with_typeprefix_r (char *value) +{ + if (this->typeid_set_) + { + return; + } + + delete [] this->repoID_; + this->repoID_ = 0; + this->prefix (value); + this->compute_repoID (); + UTL_Scope *s = DeclAsScope (this); + + if (s != 0) + { + AST_Decl *d = 0; + + for (UTL_ScopeActiveIterator i (s, UTL_Scope::IK_decls); + !i.is_done (); + i.next ()) + { + d = i.item (); + + if (d->typeid_set_) + { + continue; + } + else + { + d->set_prefix_with_typeprefix_r (value); + } } } } @@ -249,7 +295,7 @@ AST_Decl::compute_full_name (UTL_ScopedName *n) void AST_Decl::compute_full_name (void) { - if (this->full_name_ != 0) + if (this->full_name_ != 0) { return; } @@ -260,7 +306,9 @@ AST_Decl::compute_full_name (void) long second = I_FALSE; char *name = 0; - for (UTL_IdListActiveIterator i (this->name ());!i.is_done ();i.next ()) + for (UTL_IdListActiveIterator i (this->name ()); + !i.is_done (); + i.next ()) { if (!first) { @@ -296,7 +344,9 @@ AST_Decl::compute_full_name (void) first = I_TRUE; second = I_FALSE; - for (UTL_IdListActiveIterator j (this->name ());!j.is_done ();j.next ()) + for (UTL_IdListActiveIterator j (this->name ()); + !j.is_done (); + j.next ()) { if (!first) { @@ -325,15 +375,13 @@ AST_Decl::compute_full_name (void) } } } - - return; } // Compute stringified repository ID. void AST_Decl::compute_repoID (void) { - if (this->repoID_ != 0) + if (this->repoID_ != 0) { return; } @@ -358,7 +406,9 @@ AST_Decl::compute_repoID (void) namelen += 4; } - for (UTL_IdListActiveIterator i (this->name ());!i.is_done ();i.next ()) + for (UTL_IdListActiveIterator i (this->name ()); + !i.is_done (); + i.next ()) { if (!first) { @@ -371,7 +421,16 @@ AST_Decl::compute_repoID (void) // Print the identifier. name = i.item ()->get_string (); - namelen += ACE_OS::strlen (name); + size_t item_len = ACE_OS::strlen (name); + + if (ACE_OS::strstr (name, "_cxx_") == name) + { + namelen += (item_len - ACE_OS::strlen ("_cxx_")); + } + else + { + namelen += item_len; + } if (first) { @@ -408,7 +467,9 @@ AST_Decl::compute_repoID (void) first = I_TRUE; second = I_FALSE; - for (UTL_IdListActiveIterator j (this->name ());!j.is_done ();j.next ()) + for (UTL_IdListActiveIterator j (this->name ()); + !j.is_done (); + j.next ()) { if (!first) { @@ -421,8 +482,17 @@ AST_Decl::compute_repoID (void) // Print the identifier. name = j.item ()->get_string (); - ACE_OS::strcat (this->repoID_, - name); + + if (ACE_OS::strstr (name, "_cxx_") == name) + { + ACE_OS::strcat (this->repoID_, + name + ACE_OS::strlen ("_cxx_")); + } + else + { + ACE_OS::strcat (this->repoID_, + name); + } if (first) { @@ -510,17 +580,27 @@ AST_Decl::ast_accept (ast_visitor *visitor) void AST_Decl::destroy (void) { - this->pd_name->destroy (); - delete this->pd_name; - this->pd_name = 0; + // These are not set for the root node. + if (this->pd_name != 0) + { + this->pd_name->destroy (); + delete this->pd_name; + this->pd_name = 0; + } - this->pd_local_name->destroy (); - delete this->pd_local_name; - this->pd_local_name = 0; + if (this->pd_local_name != 0) + { + this->pd_local_name->destroy (); + delete this->pd_local_name; + this->pd_local_name = 0; + } - this->pd_original_local_name->destroy (); - delete this->pd_original_local_name; - this->pd_original_local_name = 0; + if (this->pd_original_local_name != 0) + { + this->pd_original_local_name->destroy (); + delete this->pd_original_local_name; + this->pd_original_local_name = 0; + } delete [] this->full_name_; this->full_name_ = 0; @@ -535,6 +615,8 @@ AST_Decl::destroy (void) this->version_ = 0; } +// Data accessors. + const char * AST_Decl::full_name (void) { @@ -585,7 +667,8 @@ AST_Decl::prefix (void) void AST_Decl::prefix (char *value) { - this->prefix_ = value; + delete [] this->prefix_; + this->prefix_ = ACE::strnew (value); } const char * @@ -627,6 +710,7 @@ AST_Decl::version (char *value) if (this->version_ == 0 && this->repoID_ == 0 || ACE_OS::strcmp (this->version_, value) == 0) { + delete [] this->version_; this->version_ = value; } else @@ -641,7 +725,93 @@ AST_Decl::anonymous (void) const return this->anonymous_; } -// Data accessors. +idl_bool +AST_Decl::typeid_set (void) const +{ + return this->typeid_set_; +} + +void +AST_Decl::typeid_set (idl_bool val) +{ + this->typeid_set_ = val; +} + +void +AST_Decl::set_id_with_typeid (char *value) +{ + // Can't call 'typeid' twice, even with the same value. + if (this->typeid_set ()) + { + idl_global->err ()->error1 (UTL_Error::EIDL_TYPEID_RESET, + this); + } + + // Are we a legal type for 'typeid'? + switch (this->pd_node_type) + { + case AST_Decl::NT_field: + { + AST_Interface *iface = + AST_Interface::narrow_from_scope (this->defined_in ()); + + if (iface == 0 || iface->is_valuetype () == 0) + { + idl_global->err ()->error1 (UTL_Error::EIDL_INVALID_TYPEID, + this); + + return; + } + + break; + } + case AST_Decl::NT_module: + case AST_Decl::NT_interface: + case AST_Decl::NT_const: + case AST_Decl::NT_typedef: + case AST_Decl::NT_except: + case AST_Decl::NT_attr: + case AST_Decl::NT_op: + case AST_Decl::NT_enum: + case AST_Decl::NT_factory: + case AST_Decl::NT_component: + case AST_Decl::NT_home: + case AST_Decl::NT_finder: + case AST_Decl::NT_eventtype: + break; + default: + idl_global->err ()->error1 (UTL_Error::EIDL_INVALID_TYPEID, + this); + + return; + } + + delete [] this->repoID_; + this->repoID_ = 0; + this->repoID (value); + this->typeid_set (I_TRUE); +} + +void +AST_Decl::set_prefix_with_typeprefix (char *value) +{ + // Are we a legal type for 'typeprefix'? This is checked only at + // the top level. + switch (this->pd_node_type) + { + case AST_Decl::NT_module: + case AST_Decl::NT_interface: + case AST_Decl::NT_eventtype: + break; + default: + idl_global->err ()->error1 (UTL_Error::EIDL_INVALID_TYPEPREFIX, + this); + + return; + } + + this->set_prefix_with_typeprefix_r (value); +} idl_bool AST_Decl::imported (void) @@ -803,14 +973,32 @@ AST_Decl::compute_name (const char *prefix, void AST_Decl::set_name (UTL_ScopedName *n) { + if (this->pd_name != 0) + { + this->pd_name->destroy (); + delete this->pd_name; + } + this->pd_name = n; - if (n != NULL) + if (n != 0) { + if (this->pd_local_name != 0) + { + this->pd_local_name->destroy (); + delete this->pd_local_name; + } + this->pd_local_name = n->last_component ()->copy (); // The name without _cxx_ prefix removed, if there was any. - this->original_local_name (n->last_component ()->copy ()); + if (this->pd_original_local_name != 0) + { + this->pd_original_local_name->destroy (); + delete this->pd_original_local_name; + } + + this->original_local_name (n->last_component ()); } } diff --git a/TAO/TAO_IDL/ast/ast_enum.cpp b/TAO/TAO_IDL/ast/ast_enum.cpp index 26024fb0478..8499d75889b 100644 --- a/TAO/TAO_IDL/ast/ast_enum.cpp +++ b/TAO/TAO_IDL/ast/ast_enum.cpp @@ -112,7 +112,7 @@ AST_Enum::member_count (void) UTL_ScopedName * AST_Enum::value_to_name (const unsigned long v) { - AST_EnumVal *item = 0; + AST_EnumVal *item = 0; AST_Decl *d = 0; for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ()) @@ -136,7 +136,9 @@ AST_Enum::lookup_by_value (const AST_Expression *v) AST_EnumVal *item = 0; AST_Decl *d = 0; - for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ()) + for (UTL_ScopeActiveIterator i (this, IK_decls); + !i.is_done (); + i.next ()) { d = i.item (); item = AST_EnumVal::narrow_from_decl (d); @@ -186,7 +188,7 @@ munge_name_for_enumval (UTL_ScopedName *n, UTL_IdList *id = 0; ACE_NEW_RETURN (id, - UTL_IdList (last_component, + UTL_IdList (last_component->copy (), 0), 0); @@ -206,7 +208,9 @@ AST_Enum::compute_member_count (void) // If there are elements in this scope if (this->nmembers () > 0) { - for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ()) + for (UTL_ScopeActiveIterator i (this, IK_decls); + !i.is_done (); + i.next ()) { // Get the next AST decl node. ++this->member_count_; @@ -216,7 +220,7 @@ AST_Enum::compute_member_count (void) return 0; } -// Add an AST_EnumVal node to this scope +// Add an AST_EnumVal node to this scope. AST_EnumVal * AST_Enum::fe_add_enum_val (AST_EnumVal *t) { @@ -231,11 +235,16 @@ AST_Enum::fe_add_enum_val (AST_EnumVal *t) t1 = idl_global->gen ()->create_enum_val (tmp, t->name ()); - t->set_name (munge_name_for_enumval (t->name (), - t->local_name ())); + UTL_ScopedName *sn = + munge_name_for_enumval ((UTL_IdList *) t->name ()->copy (), + t->local_name ()); + + t->set_name (sn); + + sn = munge_name_for_enumval ((UTL_IdList *) t1->name ()->copy (), + t1->local_name ()); - t1->set_name (munge_name_for_enumval (t1->name (), - t1->local_name ())); + t1->set_name (sn); } // Already defined and cannot be redefined? Or already used? @@ -276,7 +285,7 @@ AST_Enum::fe_add_enum_val (AST_EnumVal *t) t->local_name ()); // Add it to enclosing scope. - idl_global->scopes ()->next_to_top ()->fe_add_enum_val (t1); + idl_global->scopes ().next_to_top ()->fe_add_enum_val (t1); return t; } @@ -328,6 +337,8 @@ AST_Enum::ast_accept (ast_visitor *visitor) void AST_Enum::destroy (void) { + this->UTL_Scope::destroy (); + this->AST_Decl::destroy (); } diff --git a/TAO/TAO_IDL/ast/ast_exception.cpp b/TAO/TAO_IDL/ast/ast_exception.cpp index 069d8e33e46..ac259b4ddce 100644 --- a/TAO/TAO_IDL/ast/ast_exception.cpp +++ b/TAO/TAO_IDL/ast/ast_exception.cpp @@ -78,9 +78,9 @@ AST_Exception::AST_Exception (void) { } -AST_Exception::AST_Exception(UTL_ScopedName *n, - idl_bool local, - idl_bool abstract) +AST_Exception::AST_Exception (UTL_ScopedName *n, + idl_bool local, + idl_bool abstract) : AST_Structure (AST_Decl::NT_except, n, local, diff --git a/TAO/TAO_IDL/ast/ast_expression.cpp b/TAO/TAO_IDL/ast/ast_expression.cpp index 6be7806fc4c..93898bfe611 100644 --- a/TAO/TAO_IDL/ast/ast_expression.cpp +++ b/TAO/TAO_IDL/ast/ast_expression.cpp @@ -76,8 +76,8 @@ ACE_RCSID(ast, ast_expression, "$Id$") void AST_Expression::fill_definition_details (void) { - this->pd_defined_in = idl_global->scopes()->depth() > 0 - ? idl_global->scopes()->top() + this->pd_defined_in = idl_global->scopes ().depth () > 0 + ? idl_global->scopes().top () : 0 ; this->pd_line = idl_global->lineno (); this->pd_file_name = idl_global->filename (); @@ -88,10 +88,10 @@ AST_Expression::fill_definition_details (void) // An AST_Expression denoting a symbolic name. AST_Expression::AST_Expression (UTL_ScopedName *nm) : pd_ec (EC_symbol), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (nm) + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (nm) { this->fill_definition_details (); } @@ -99,11 +99,11 @@ AST_Expression::AST_Expression (UTL_ScopedName *nm) // An AST_Expression denoting a type coercion from another AST_Expression. AST_Expression::AST_Expression (AST_Expression *v, ExprType t) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -120,12 +120,12 @@ AST_Expression::AST_Expression (AST_Expression *v, // two other AST_Expressions. AST_Expression::AST_Expression (ExprComb c, AST_Expression *ev1, - AST_Expression *ev2) + AST_Expression *ev2) : pd_ec (c), - pd_ev (0), - pd_v1 (ev1), - pd_v2 (ev2), - pd_n (0) + pd_ev (0), + pd_v1 (ev1), + pd_v2 (ev2), + pd_n (0) { this->fill_definition_details (); } @@ -133,10 +133,10 @@ AST_Expression::AST_Expression (ExprComb c, // An AST_Expression denoting a short integer. AST_Expression::AST_Expression (short sv) : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -150,10 +150,10 @@ AST_Expression::AST_Expression (short sv) // An AST_Expression denoting an unsigned short integer. AST_Expression::AST_Expression (unsigned short usv) : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -167,10 +167,10 @@ AST_Expression::AST_Expression (unsigned short usv) // An AST_Expression denoting a long integer. AST_Expression::AST_Expression (long lv) : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -184,11 +184,11 @@ AST_Expression::AST_Expression (long lv) // An AST_Expression denoting a long integer being used as a boolean. AST_Expression::AST_Expression (long lv, ExprType t) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -202,11 +202,11 @@ AST_Expression::AST_Expression (long lv, // An AST_Expression denoting an unsigned long integer. AST_Expression::AST_Expression (unsigned long ulv) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (NULL) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (NULL) { this->fill_definition_details (); @@ -219,11 +219,11 @@ AST_Expression::AST_Expression (unsigned long ulv) // An AST_Expression denoting a 32-bit floating point number. AST_Expression::AST_Expression (float fv) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -236,11 +236,11 @@ AST_Expression::AST_Expression (float fv) // An AST_Expression denoting a 64-bit floating point number. AST_Expression::AST_Expression (double dv) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (NULL), - pd_n (0) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (NULL), + pd_n (0) { this->fill_definition_details (); @@ -253,11 +253,11 @@ AST_Expression::AST_Expression (double dv) // An AST_Expression denoting a character. AST_Expression::AST_Expression (char cv) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -270,11 +270,11 @@ AST_Expression::AST_Expression (char cv) // An AST_Expression denoting a wide character. AST_Expression::AST_Expression (ACE_OutputCDR::from_wchar wcv) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -287,11 +287,11 @@ AST_Expression::AST_Expression (ACE_OutputCDR::from_wchar wcv) // An AST_Expression denoting an octet (unsigned char). AST_Expression::AST_Expression (unsigned char ov) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (NULL) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (NULL) { this->fill_definition_details (); @@ -304,11 +304,11 @@ AST_Expression::AST_Expression (unsigned char ov) // An AST_Expression denoting a string (char * encapsulated as a String). AST_Expression::AST_Expression (UTL_String *sv) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -321,11 +321,11 @@ AST_Expression::AST_Expression (UTL_String *sv) // An AST_Expression denoting a wide string. AST_Expression::AST_Expression (char *sv) - : pd_ec (EC_none), - pd_ev (0), - pd_v1 (0), - pd_v2 (0), - pd_n (0) + : pd_ec (EC_none), + pd_ev (0), + pd_v1 (0), + pd_v2 (0), + pd_n (0) { this->fill_definition_details (); @@ -1892,9 +1892,9 @@ AST_Expression::eval_symbol (AST_Expression::EvalKind ek) } // Get current scope for lookup. - if (idl_global->scopes ()->depth() > 0) + if (idl_global->scopes ().depth () > 0) { - s = idl_global->scopes ()->top_non_null (); + s = idl_global->scopes ().top_non_null (); } if (s == 0) @@ -2504,6 +2504,13 @@ AST_Expression::ast_accept (ast_visitor *visitor) return visitor->visit_expression (this); } +void +AST_Expression::destroy (void) +{ + delete this->pd_ev; + this->pd_ev = 0; +} + // Data accessors. UTL_Scope * diff --git a/TAO/TAO_IDL/ast/ast_factory.cpp b/TAO/TAO_IDL/ast/ast_factory.cpp index 2d464a1da90..1ebde1a4849 100644 --- a/TAO/TAO_IDL/ast/ast_factory.cpp +++ b/TAO/TAO_IDL/ast/ast_factory.cpp @@ -217,14 +217,14 @@ void AST_Factory::dump (ostream &o) { AST_Decl *d = 0; - UTL_ScopeActiveIterator i (this, - IK_decls); o << "factory "; this->local_name ()->dump (o); o << "("; - while (!i.is_done()) + // Iterator must be explicitly advanced inside the loop. + for (UTL_ScopeActiveIterator i (this, IK_decls); + !i.is_done();) { d = i.item (); d->dump (o); diff --git a/TAO/TAO_IDL/ast/ast_generator.cpp b/TAO/TAO_IDL/ast/ast_generator.cpp index f3cbc233004..666b6845a89 100644 --- a/TAO/TAO_IDL/ast/ast_generator.cpp +++ b/TAO/TAO_IDL/ast/ast_generator.cpp @@ -98,7 +98,7 @@ AST_Module * AST_Generator::create_module (UTL_Scope *s, UTL_ScopedName *n) { - // We create this first so if we find a module with the + // We create this first so if we find a module with the // same name from an included file, we can add its // members to the new module's scope. AST_Module *retval = 0; @@ -669,9 +669,15 @@ AST_Generator::create_sequence (AST_Expression *ms, AST_String * AST_Generator::create_string (AST_Expression *ms) { + Identifier id ("string"); + UTL_ScopedName n (&id, + 0); + AST_String *retval = 0; ACE_NEW_RETURN (retval, - AST_String (ms), + AST_String (AST_Decl::NT_string, + &n, + ms), 0); return retval; @@ -681,9 +687,20 @@ AST_Generator::create_string (AST_Expression *ms) AST_String * AST_Generator::create_wstring (AST_Expression *ms) { + Identifier id (sizeof (ACE_CDR::WChar) == 1 + ? "string" + : "wstring"); + UTL_ScopedName n (&id, + 0); + AST_Decl::NodeType nt = sizeof (ACE_CDR::WChar) == 1 + ? AST_Decl::NT_string + : AST_Decl::NT_wstring; + AST_String *retval = 0; ACE_NEW_RETURN (retval, - AST_String (ms, + AST_String (nt, + &n, + ms, sizeof (ACE_OS::WChar)), 0); diff --git a/TAO/TAO_IDL/ast/ast_interface.cpp b/TAO/TAO_IDL/ast/ast_interface.cpp index 4fade4b5971..106db58a669 100644 --- a/TAO/TAO_IDL/ast/ast_interface.cpp +++ b/TAO/TAO_IDL/ast/ast_interface.cpp @@ -87,14 +87,16 @@ AST_Interface::AST_Interface (void) { } -AST_Interface::AST_Interface(UTL_ScopedName *n, - AST_Interface **ih, - long nih, - AST_Interface **ih_flat, - long nih_flat, - idl_bool local, - idl_bool abstract) - : AST_Decl (AST_Decl::NT_interface, +AST_Interface::AST_Interface (UTL_ScopedName *n, + AST_Interface **ih, + long nih, + AST_Interface **ih_flat, + long nih_flat, + idl_bool local, + idl_bool abstract) + : AST_Type (AST_Decl::NT_interface, + n), + AST_Decl (AST_Decl::NT_interface, n), UTL_Scope (AST_Decl::NT_interface), COMMON_Base (local, @@ -370,7 +372,7 @@ AST_Interface::fe_add_field (AST_Field *t) // Add an AST_Operation node (an operation declaration) to this scope. AST_Operation * -AST_Interface::fe_add_operation(AST_Operation *t) +AST_Interface::fe_add_operation (AST_Operation *t) { AST_Decl *d = 0; @@ -1206,6 +1208,10 @@ AST_Interface::inherited_name_clash (void) void AST_Interface::destroy (void) { + delete [] this->pd_inherits; + this->pd_inherits = 0; + delete [] this->pd_inherits_flat; + this->pd_inherits_flat = 0; } int diff --git a/TAO/TAO_IDL/ast/ast_module.cpp b/TAO/TAO_IDL/ast/ast_module.cpp index 4373900c292..5ac6a424487 100644 --- a/TAO/TAO_IDL/ast/ast_module.cpp +++ b/TAO/TAO_IDL/ast/ast_module.cpp @@ -77,7 +77,7 @@ ACE_RCSID(ast, ast_module, "$Id$") // Constructor(s) and destructor. -AST_Module::AST_Module () +AST_Module::AST_Module (void) { } @@ -802,7 +802,7 @@ AST_Module::be_add_interface (AST_Interface *i, void AST_Module::add_CORBA_members (void) { - UTL_ScopedName *sn = 0; + UTL_ScopedName *sn = 0; Identifier *id = 0; ACE_NEW (id, @@ -895,6 +895,7 @@ AST_Module::look_in_previous (Identifier *e) void AST_Module::destroy (void) { + this->AST_Decl::destroy (); } int diff --git a/TAO/TAO_IDL/ast/ast_native.cpp b/TAO/TAO_IDL/ast/ast_native.cpp index d62ac7a5d38..f454f9eb4c1 100644 --- a/TAO/TAO_IDL/ast/ast_native.cpp +++ b/TAO/TAO_IDL/ast/ast_native.cpp @@ -14,7 +14,7 @@ AST_Native::AST_Native (void) { } -AST_Native::AST_Native(UTL_ScopedName *n) +AST_Native::AST_Native (UTL_ScopedName *n) : AST_Decl (AST_Decl::NT_native, n) { diff --git a/TAO/TAO_IDL/ast/ast_operation.cpp b/TAO/TAO_IDL/ast/ast_operation.cpp index 8d058ee36ee..cea7e982d24 100644 --- a/TAO/TAO_IDL/ast/ast_operation.cpp +++ b/TAO/TAO_IDL/ast/ast_operation.cpp @@ -203,16 +203,12 @@ AST_Operation::compute_argument_attr (void) if (this->nmembers () > 0) { // Instantiate a scope iterator. - UTL_ScopeActiveIterator *si = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls), - -1); - - while (!si->is_done ()) + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { // Get the next AST decl node. - d = si->item (); + d = si.item (); if (d->node_type () == AST_Decl::NT_argument) { @@ -227,11 +223,7 @@ AST_Operation::compute_argument_attr (void) this->has_native_ = 1; } } - - si->next (); } - - delete si; } type = AST_Type::narrow_from_decl (this->return_type ()); diff --git a/TAO/TAO_IDL/ast/ast_predefined_type.cpp b/TAO/TAO_IDL/ast/ast_predefined_type.cpp index 2db404de631..0e8c268662a 100644 --- a/TAO/TAO_IDL/ast/ast_predefined_type.cpp +++ b/TAO/TAO_IDL/ast/ast_predefined_type.cpp @@ -78,17 +78,118 @@ ACE_RCSID(ast, ast_predefined_type, "$Id$") // Constructor(s). AST_PredefinedType::AST_PredefinedType (void) - : pd_pt (PT_long) + : pd_pt (PT_long) { } AST_PredefinedType::AST_PredefinedType (PredefinedType t, UTL_ScopedName *n) - : AST_Decl (AST_Decl::NT_pre_defined, - n, - I_TRUE), - pd_pt (t) + : AST_Decl (AST_Decl::NT_pre_defined, + n, + I_TRUE), + pd_pt (t) { + UTL_ScopedName *new_name = 0; + Identifier *id = 0; + + // Generate a new Scoped Name for us such that we belong to the CORBA + // namespace. + if (t == AST_PredefinedType::PT_void) + { + ACE_NEW (id, + Identifier (n->last_component ()->get_string ())); + + ACE_NEW (new_name, + UTL_ScopedName (id, + 0)); + } + else + { + Identifier *corba_id = 0; + ACE_NEW (corba_id, + Identifier ("CORBA")); + + ACE_NEW (new_name, + UTL_ScopedName (corba_id, + 0)); + + UTL_ScopedName *conc_name = 0; + + switch (this->pt ()) + { + case AST_PredefinedType::PT_long: + ACE_NEW (id, + Identifier ("Long")); + break; + case AST_PredefinedType::PT_ulong: + ACE_NEW (id, + Identifier ("ULong")); + break; + case AST_PredefinedType::PT_short: + ACE_NEW (id, + Identifier ("Short")); + break; + case AST_PredefinedType::PT_ushort: + ACE_NEW (id, + Identifier ("UShort")); + break; + case AST_PredefinedType::PT_float: + ACE_NEW (id, + Identifier ("Float")); + break; + case AST_PredefinedType::PT_double: + ACE_NEW (id, + Identifier ("Double")); + break; + case AST_PredefinedType::PT_char: + ACE_NEW (id, + Identifier ("Char")); + break; + case AST_PredefinedType::PT_octet: + ACE_NEW (id, + Identifier ("Octet")); + break; + case AST_PredefinedType::PT_wchar: + ACE_NEW (id, + Identifier ("WChar")); + break; + case AST_PredefinedType::PT_boolean: + ACE_NEW (id, + Identifier ("Boolean")); + break; + case AST_PredefinedType::PT_longlong: + ACE_NEW (id, + Identifier ("LongLong")); + break; + case AST_PredefinedType::PT_ulonglong: + ACE_NEW (id, + Identifier ("ULongLong")); + break; + case AST_PredefinedType::PT_longdouble: + ACE_NEW (id, + Identifier ("LongDouble")); + break; + case AST_PredefinedType::PT_any: + ACE_NEW (id, + Identifier ("Any")); + break; + case AST_PredefinedType::PT_pseudo: + ACE_NEW (id, + Identifier (n->last_component ()->get_string ())); + break; + default: + ACE_ERROR ((LM_ERROR, + "AST_PredefinedType - bad enum value\n")); + } + + ACE_NEW (conc_name, + UTL_ScopedName (id, + 0)); + + new_name->nconc (conc_name); + } + + this->set_name (new_name); } AST_PredefinedType::~AST_PredefinedType (void) @@ -110,6 +211,12 @@ AST_PredefinedType::ast_accept (ast_visitor *visitor) return visitor->visit_predefined_type (this); } +void +AST_PredefinedType::destroy (void) +{ + this->AST_Type::destroy (); +} + // Data accessors. AST_PredefinedType::PredefinedType diff --git a/TAO/TAO_IDL/ast/ast_root.cpp b/TAO/TAO_IDL/ast/ast_root.cpp index 7146dfb2baf..66353a34507 100644 --- a/TAO/TAO_IDL/ast/ast_root.cpp +++ b/TAO/TAO_IDL/ast/ast_root.cpp @@ -182,6 +182,12 @@ AST_Root::ast_accept (ast_visitor *visitor) return visitor->visit_root (this); } +void +AST_Root::destroy () +{ + this->AST_Decl::destroy (); +} + // Narrowing methods. IMPL_NARROW_METHODS1(AST_Root, AST_Module) IMPL_NARROW_FROM_DECL(AST_Root) diff --git a/TAO/TAO_IDL/ast/ast_string.cpp b/TAO/TAO_IDL/ast/ast_string.cpp index c71af9dc02d..15d52b19187 100644 --- a/TAO/TAO_IDL/ast/ast_string.cpp +++ b/TAO/TAO_IDL/ast/ast_string.cpp @@ -72,7 +72,10 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "idl.h" #include "idl_extern.h" -ACE_RCSID(ast, ast_string, "$Id$") +ACE_RCSID (ast, + ast_string, + "$Id$") + // Constructor(s) and destructor. AST_String::AST_String (void) : pd_max_size (0), @@ -80,28 +83,13 @@ AST_String::AST_String (void) { } -AST_String::AST_String (AST_Expression *ms) - : AST_Decl (AST_Decl::NT_string, - new UTL_ScopedName (new Identifier ("string"), - 0), - I_TRUE), - pd_max_size (ms), - pd_width (sizeof (char)) -{ -} - -AST_String::AST_String (AST_Expression *ms, +AST_String::AST_String (AST_Decl::NodeType nt, + UTL_ScopedName *n, + AST_Expression *ms, long wide) - : AST_Decl - ( - wide == (long) sizeof (char) ? AST_Decl::NT_string : AST_Decl::NT_wstring, - new UTL_ScopedName - ( - new Identifier ((wide == (long) sizeof (char)) ? "string" : "wstring"), - 0 - ), - I_TRUE - ), + : AST_Decl (nt, + n, + I_TRUE), pd_max_size (ms), pd_width (wide) { @@ -115,7 +103,7 @@ AST_String::~AST_String (void) // Dump this AST_String node to the ostream o. void -AST_String::dump(ACE_OSTREAM_TYPE &o) +AST_String::dump (ACE_OSTREAM_TYPE &o) { o << "string <"; this->pd_max_size->dump (o); @@ -128,6 +116,16 @@ AST_String::ast_accept (ast_visitor *visitor) return visitor->visit_string (this); } +void +AST_String::destroy (void) +{ + this->pd_max_size->destroy (); + delete this->pd_max_size; + this->pd_max_size = 0; + + this->AST_Decl::destroy (); +} + // Data accessors. AST_Expression * diff --git a/TAO/TAO_IDL/ast/ast_type.cpp b/TAO/TAO_IDL/ast/ast_type.cpp index 63d6d727f72..2c2deee1fb1 100644 --- a/TAO/TAO_IDL/ast/ast_type.cpp +++ b/TAO/TAO_IDL/ast/ast_type.cpp @@ -139,6 +139,12 @@ AST_Type::ast_accept (ast_visitor *visitor) return visitor->visit_type (this); } +void +AST_Type::destroy (void) +{ + this->AST_Decl::destroy (); +} + // Narrowing. IMPL_NARROW_METHODS1(AST_Type, AST_Decl) IMPL_NARROW_FROM_DECL(AST_Type) diff --git a/TAO/TAO_IDL/ast/ast_typedef.cpp b/TAO/TAO_IDL/ast/ast_typedef.cpp index 67e5601dc97..b3e343b3451 100644 --- a/TAO/TAO_IDL/ast/ast_typedef.cpp +++ b/TAO/TAO_IDL/ast/ast_typedef.cpp @@ -143,6 +143,11 @@ AST_Typedef::ast_accept (ast_visitor *visitor) return visitor->visit_typedef (this); } +void +AST_Typedef::destroy (void) +{ +} + // Data accessors. AST_Type * diff --git a/TAO/TAO_IDL/be/be_codegen.cpp b/TAO/TAO_IDL/be/be_codegen.cpp index ea36133d7ea..e87de1ab83b 100644 --- a/TAO/TAO_IDL/be/be_codegen.cpp +++ b/TAO/TAO_IDL/be/be_codegen.cpp @@ -57,6 +57,11 @@ TAO_CodeGen::~TAO_CodeGen (void) delete this->client_inline_; delete this->server_inline_; delete this->server_template_inline_; +#if !defined (linux) && !defined (__QNX__) + // This causes a seg fault on Linux RH 5.1. Let it leak . . . + delete this->gperf_input_stream_; +#endif /* ! linux */ + delete [] this->gperf_input_filename_; this->curr_os_ = 0; // delete this->visitor_factory_; } @@ -175,11 +180,11 @@ TAO_CodeGen::start_client_header (const char *fname) { // Include Messaging skeleton file. this->gen_standard_include (this->client_header_, - "tao/Messaging.h"); + "tao/Messaging/Messaging.h"); // Including Asynch Invocation file. this->gen_standard_include (this->client_header_, - "tao/Asynch_Invocation.h"); + "tao/Messaging/Twoway_Asynch_Invocation.h"); } // Include the smart proxy base class if smart proxies are enabled. @@ -430,9 +435,9 @@ TAO_CodeGen::start_server_header (const char *fname) { // Include Messaging skeleton file. this->gen_standard_include (this->server_header_, - "tao/PortableServer/MessagingS.h"); + "tao/Messaging/MessagingS.h"); this->gen_standard_include (this->server_header_, - "tao/Asynch_Invocation.h"); + "tao/Messaging/Twoway_Asynch_Invocation.h"); } // We must include all the skeleton headers corresponding to @@ -1166,8 +1171,8 @@ TAO_CodeGen::gperf_input_stream (void) void TAO_CodeGen::gperf_input_filename (char *filename) { - delete [] this->gperf_input_filename_; - this->gperf_input_filename_ = ACE::strnew (filename); + delete [] this->gperf_input_filename_; + this->gperf_input_filename_ = filename; } char * diff --git a/TAO/TAO_IDL/be/be_constant.cpp b/TAO/TAO_IDL/be/be_constant.cpp index 96bf7c9c6ad..7242b87f6fd 100644 --- a/TAO/TAO_IDL/be/be_constant.cpp +++ b/TAO/TAO_IDL/be/be_constant.cpp @@ -19,11 +19,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "idl.h" +#include "idl_extern.h" +#include "be.h" -ACE_RCSID(be, be_constant, "$Id$") +ACE_RCSID (be, + be_constant, + "$Id$") be_constant::be_constant (void) { @@ -93,6 +95,13 @@ be_constant::accept (be_visitor *visitor) return visitor->visit_constant (this); } +void +be_constant::destroy (void) +{ + this->AST_Constant::destroy (); + this->be_decl::destroy (); +} + // Narrowing IMPL_NARROW_METHODS2 (be_constant, AST_Constant, be_decl) IMPL_NARROW_FROM_DECL (be_constant) diff --git a/TAO/TAO_IDL/be/be_decl.cpp b/TAO/TAO_IDL/be/be_decl.cpp index 99411cd454a..03e9f049216 100644 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ b/TAO/TAO_IDL/be/be_decl.cpp @@ -269,8 +269,6 @@ be_decl::compute_flat_name (void) } } - - void be_decl::compute_flat_name (const char *prefix, const char *suffix, @@ -341,6 +339,8 @@ be_decl::destroy (void) delete [] this->flat_name_; this->flat_name_ = 0; } + + this->AST_Decl::destroy (); } idl_bool diff --git a/TAO/TAO_IDL/be/be_enum.cpp b/TAO/TAO_IDL/be/be_enum.cpp index 51b02972995..6a57a21f025 100644 --- a/TAO/TAO_IDL/be/be_enum.cpp +++ b/TAO/TAO_IDL/be/be_enum.cpp @@ -49,8 +49,10 @@ void be_enum::destroy (void) { // Call the destroy methods of our base classes. - be_scope::destroy (); -// be_type::destroy (); + // No need to call be_scope::destroy(). It has no + // allocated members, and AST_Enum::destroy() will + // call UTL_Scope::destroy(). + this->AST_Enum::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_enum_val.cpp b/TAO/TAO_IDL/be/be_enum_val.cpp index 84f0b1b7953..6739a120681 100644 --- a/TAO/TAO_IDL/be/be_enum_val.cpp +++ b/TAO/TAO_IDL/be/be_enum_val.cpp @@ -19,11 +19,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "idl.h" +#include "idl_extern.h" +#include "be.h" -ACE_RCSID(be, be_enum_val, "$Id$") +ACE_RCSID (be, + be_enum_val, + "$Id$") be_enum_val::be_enum_val (void) { @@ -33,7 +35,7 @@ be_enum_val::be_enum_val (unsigned long v, UTL_ScopedName *n) : AST_Constant (AST_Expression::EV_ulong, AST_Decl::NT_enum_val, - new AST_Expression(v), + new AST_Expression (v), n), AST_Decl (AST_Decl::NT_enum_val, n) @@ -46,6 +48,13 @@ be_enum_val::accept (be_visitor *visitor) return visitor->visit_enum_val (this); } +void +be_enum_val::destroy (void) +{ + this->AST_EnumVal::destroy (); + this->be_decl::destroy (); +} + int be_enum_val::compute_size_type (void) { diff --git a/TAO/TAO_IDL/be/be_expression.cpp b/TAO/TAO_IDL/be/be_expression.cpp index 1510eb257cf..8648991eee1 100644 --- a/TAO/TAO_IDL/be/be_expression.cpp +++ b/TAO/TAO_IDL/be/be_expression.cpp @@ -19,11 +19,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "idl.h" +#include "idl_extern.h" +#include "be.h" -ACE_RCSID(be, be_expression, "$Id$") +ACE_RCSID (be, + be_expression, + "$Id$") be_expression::be_expression (UTL_ScopedName *n) : AST_Expression (n) diff --git a/TAO/TAO_IDL/be/be_generator.cpp b/TAO/TAO_IDL/be/be_generator.cpp index 787cfa85bdb..f9937e74ee7 100644 --- a/TAO/TAO_IDL/be/be_generator.cpp +++ b/TAO/TAO_IDL/be/be_generator.cpp @@ -598,9 +598,16 @@ be_generator::create_sequence (AST_Expression *v, AST_String * be_generator::create_string (AST_Expression *v) { + Identifier id ("string"); + UTL_ScopedName n (&id, + 0); + be_string *retval = 0; ACE_NEW_RETURN (retval, - be_string (v), + be_string (AST_Decl::NT_string, + &n, + v, + 1), 0); return retval; @@ -609,9 +616,20 @@ be_generator::create_string (AST_Expression *v) AST_String * be_generator::create_wstring (AST_Expression *v) { + Identifier id (sizeof (ACE_CDR::WChar) == 1 + ? "string" + : "wstring"); + UTL_ScopedName n (&id, + 0); + AST_Decl::NodeType nt = sizeof (ACE_CDR::WChar) == 1 + ? AST_Decl::NT_string + : AST_Decl::NT_wstring; + be_string *retval = 0; ACE_NEW_RETURN (retval, - be_string (v, + be_string (nt, + &n, + v, sizeof (ACE_CDR::WChar)), 0); diff --git a/TAO/TAO_IDL/be/be_global.cpp b/TAO/TAO_IDL/be/be_global.cpp index 5db3572a94c..5f1c4225328 100644 --- a/TAO/TAO_IDL/be/be_global.cpp +++ b/TAO/TAO_IDL/be/be_global.cpp @@ -26,53 +26,79 @@ ACE_RCSID(be, be_global, "$Id$") TAO_IDL_BE_Export BE_GlobalData *be_global = 0; BE_GlobalData::BE_GlobalData (void) - : changing_standard_include_files_ (1), - skel_export_macro_ (0), - skel_export_include_ (0), - stub_export_macro_ (0), - stub_export_include_ (0), - pch_include_ (0), - pre_include_ (0), - post_include_ (0), - client_hdr_ending_ (ACE::strnew ("C.h")), - client_stub_ending_ (ACE::strnew ("C.cpp")), - client_inline_ending_ (ACE::strnew ("C.i")), - server_hdr_ending_ (ACE::strnew ("S.h")), - implementation_hdr_ending_ (ACE::strnew ("I.h")), - implementation_skel_ending_ (ACE::strnew ("I.cpp")), - impl_class_prefix_ (ACE::strnew ("")), - impl_class_suffix_ (ACE::strnew ("_i")), - server_template_hdr_ending_ (ACE::strnew ("S_T.h")), - server_skeleton_ending_ (ACE::strnew ("S.cpp")), - server_template_skeleton_ending_ (ACE::strnew ("S_T.cpp")), - server_inline_ending_ (ACE::strnew ("S.i")), - server_template_inline_ending_ (ACE::strnew ("S_T.i")), - output_dir_ (0), - any_support_ (I_TRUE), - tc_support_ (I_TRUE), - obv_opt_accessor_ (0), - gen_impl_files_ (I_FALSE), - gen_copy_ctor_ (I_FALSE), - gen_assign_op_ (I_FALSE), - gen_thru_poa_collocation_ (I_TRUE), // Default is thru_poa. - gen_direct_collocation_ (I_FALSE), + : changing_standard_include_files_ (1), + skel_export_macro_ (0), + skel_export_include_ (0), + stub_export_macro_ (0), + stub_export_include_ (0), + pch_include_ (0), + pre_include_ (0), + post_include_ (0), + client_hdr_ending_ (ACE::strnew ("C.h")), + client_stub_ending_ (ACE::strnew ("C.cpp")), + client_inline_ending_ (ACE::strnew ("C.i")), + server_hdr_ending_ (ACE::strnew ("S.h")), + implementation_hdr_ending_ (ACE::strnew ("I.h")), + implementation_skel_ending_ (ACE::strnew ("I.cpp")), + impl_class_prefix_ (ACE::strnew ("")), + impl_class_suffix_ (ACE::strnew ("_i")), + server_template_hdr_ending_ (ACE::strnew ("S_T.h")), + server_skeleton_ending_ (ACE::strnew ("S.cpp")), + server_template_skeleton_ending_ (ACE::strnew ("S_T.cpp")), + server_inline_ending_ (ACE::strnew ("S.i")), + server_template_inline_ending_ (ACE::strnew ("S_T.i")), + output_dir_ (0), + any_support_ (I_TRUE), + tc_support_ (I_TRUE), + obv_opt_accessor_ (0), + gen_impl_files_ (I_FALSE), + gen_copy_ctor_ (I_FALSE), + gen_assign_op_ (I_FALSE), + gen_thru_poa_collocation_ (I_TRUE), // Default is thru_poa. + gen_direct_collocation_ (I_FALSE), #ifdef ACE_HAS_EXCEPTIONS - exception_support_ (I_TRUE), + exception_support_ (I_TRUE), #else - exception_support_ (I_FALSE), + exception_support_ (I_FALSE), #endif /* ACE_HAS_EXCEPTIONS */ - use_raw_throw_ (I_FALSE), - opt_tc_ (I_FALSE), - ami_call_back_ (I_FALSE), - gen_amh_classes_ (I_FALSE), - gen_tie_classes_ (I_TRUE), - gen_smart_proxies_ (I_FALSE), - lookup_strategy_ (TAO_PERFECT_HASH) + use_raw_throw_ (I_FALSE), + opt_tc_ (I_FALSE), + ami_call_back_ (I_FALSE), + gen_amh_classes_ (I_FALSE), + gen_tie_classes_ (I_TRUE), + gen_smart_proxies_ (I_FALSE), + lookup_strategy_ (TAO_PERFECT_HASH) { } BE_GlobalData::~BE_GlobalData (void) { + delete this->client_hdr_ending_; + this->client_hdr_ending_ = 0; + delete this->client_stub_ending_; + this->client_stub_ending_ = 0; + delete this->client_inline_ending_; + this->client_inline_ending_ = 0; + delete this->server_hdr_ending_; + this->server_hdr_ending_ = 0; + delete this->implementation_hdr_ending_; + this->implementation_hdr_ending_ = 0; + delete this->implementation_skel_ending_; + this->implementation_skel_ending_ = 0; + delete this->impl_class_prefix_; + this->impl_class_prefix_ = 0; + delete this->impl_class_suffix_; + this->impl_class_suffix_ = 0; + delete this->server_template_hdr_ending_; + this->server_template_hdr_ending_ = 0; + delete this->server_skeleton_ending_; + this->server_skeleton_ending_ = 0; + delete this->server_template_skeleton_ending_; + this->server_template_skeleton_ending_ = 0; + delete this->server_inline_ending_; + this->server_inline_ending_ = 0; + delete this->server_template_inline_ending_; + this->server_template_inline_ending_ = 0; } // To switch between changing or non-changing standard include files diff --git a/TAO/TAO_IDL/be/be_helper.cpp b/TAO/TAO_IDL/be/be_helper.cpp index 8a853af2476..63a9d3bd021 100644 --- a/TAO/TAO_IDL/be/be_helper.cpp +++ b/TAO/TAO_IDL/be/be_helper.cpp @@ -69,7 +69,7 @@ const TAO_UNINDENT be_uidt_nl (1); // Methods of the TAO_OutStream class. TAO_OutStream::TAO_OutStream (void) - : fp_ (NULL), + : fp_ (0), indent_level_ (0) { } @@ -122,7 +122,7 @@ TAO_OutStream::open (const char *fname, } } -// set and get the stream type +// Set and get the stream type. void TAO_OutStream::stream_type (TAO_OutStream::STREAM_TYPE st) { diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 02ec030b50e..ab521d6b5b7 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -1059,8 +1059,7 @@ be_interface::gen_operation_table (const char *flat_name, case BE_GlobalData::TAO_DYNAMIC_HASH: { // Init the outstream appropriately. - TAO_OutStream *os = - this->strategy_->get_out_stream (); + TAO_OutStream *os = this->strategy_->get_out_stream (); // Start from current indentation level. os->indent (); @@ -1068,10 +1067,12 @@ be_interface::gen_operation_table (const char *flat_name, // Start the table generation. *os << "static const TAO_operation_db_entry " << flat_name << "_operations [] = {\n"; + os->incr_indent (0); // Traverse the graph. TAO_IDL_Gen_OpTable_Worker worker (skeleton_class_name); + if (this->traverse_inheritance_graph (worker, os) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -1081,23 +1082,29 @@ be_interface::gen_operation_table (const char *flat_name, // Generate the skeleton for the is_a method. os->indent (); + *os << "{\"_is_a\", &" << skeleton_class_name << "::_is_a_skel},\n"; + this->skel_count_++; os->indent (); + *os << "{\"_non_existent\", &" << skeleton_class_name << "::_non_existent_skel},\n"; + this->skel_count_++; os->indent (); + *os << "{\"_interface\", &" << skeleton_class_name << "::_interface_skel}\n"; + this->skel_count_++; os->decr_indent (); - *os << "};\n" << be_nl; + *os << "};\n" << be_nl; *os << "static const CORBA::Long _tao_" << flat_name << "_optable_size = sizeof (ACE_Hash_Map_Entry<const char *," << " TAO_Skeleton>) * (" << (3 * this->skel_count_) @@ -1130,9 +1137,10 @@ be_interface::gen_operation_table (const char *flat_name, // Temp file name. char *temp_file = 0; ACE_NEW_RETURN (temp_file, - char [ACE_OS::strlen (idl_global->temp_dir ()) + - ACE_OS::strlen (flat_name) + - ACE_OS::strlen (".gperf") + 1], + char [ACE_OS::strlen (idl_global->temp_dir ()) + + ACE_OS::strlen (flat_name) + + ACE_OS::strlen (".gperf") + + 1], -1); ACE_OS::sprintf (temp_file, @@ -1158,8 +1166,7 @@ be_interface::gen_operation_table (const char *flat_name, // interface. // Retrieve the singleton instance to the outstream factory. - TAO_OutStream_Factory *factory = - TAO_OUTSTREAM_FACTORY::instance (); + TAO_OutStream_Factory *factory = TAO_OUTSTREAM_FACTORY::instance (); // Get a new instance for the temp file. TAO_OutStream *os = factory->make_outstream (); @@ -1546,12 +1553,14 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & be_interface **temp; (void) q_iter.next (temp); + if (!ACE_OS::strcmp (parent->full_name (), (*temp)->full_name ())) { // We exist in this queue and cannot be inserted. found = 1; } + if (found) { break; @@ -2292,8 +2301,9 @@ void be_interface::destroy (void) { // Call the destroy methods of our base classes. - be_scope::destroy (); - be_type::destroy (); + this->AST_Interface::destroy (); + this->be_scope::destroy (); + this->be_type::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_interface_strategy.cpp b/TAO/TAO_IDL/be/be_interface_strategy.cpp index 20bbbd231b8..67f01a66dc8 100644 --- a/TAO/TAO_IDL/be/be_interface_strategy.cpp +++ b/TAO/TAO_IDL/be/be_interface_strategy.cpp @@ -43,21 +43,52 @@ be_interface_strategy::be_interface_strategy (be_interface *node, be_interface_strategy::~be_interface_strategy (void) { if (this->local_name_ != 0) - delete [] this->local_name_; + { + delete [] this->local_name_; + this->local_name_ = 0; + } + if (this->full_name_ != 0) - delete [] this->full_name_; + { + delete [] this->full_name_; + this->full_name_ = 0; + } + if (this->flat_name_ != 0) - delete [] this->flat_name_; + { + delete [] this->flat_name_; + this->flat_name_ = 0; + } + if (this->repoID_ != 0) - delete [] this->repoID_; + { + delete [] this->repoID_; + this->repoID_ = 0; + } + if (this->full_skel_name_ != 0) - delete [] this->full_skel_name_; + { + delete [] this->full_skel_name_; + this->full_skel_name_ = 0; + } + if (this->full_coll_name_ != 0) - delete [] this->full_coll_name_; + { + delete [] this->full_coll_name_; + this->full_coll_name_ = 0; + } + if (this->local_coll_name_ != 0) - delete [] this->local_coll_name_; + { + delete [] this->local_coll_name_; + this->local_coll_name_ = 0; + } + if (this->relative_skel_name_ != 0) - delete [] this->relative_skel_name_; + { + delete [] this->relative_skel_name_; + this->relative_skel_name_ = 0; + } } // Interface Type Strategy Base Class @@ -347,8 +378,8 @@ be_interface_ami_handler_strategy::next_state ( // **************************************************************** // AMI Exception Holder Strategy -be_interface_ami_exception_holder_strategy -::be_interface_ami_exception_holder_strategy (be_interface *node) +be_interface_ami_exception_holder_strategy:: +be_interface_ami_exception_holder_strategy (be_interface *node) : be_interface_default_strategy (node, AMI_EXCEPTION_HOLDER) { @@ -514,6 +545,113 @@ be_interface_default_strategy::be_interface_default_strategy ( be_interface_default_strategy::~be_interface_default_strategy (void) { + if (this->base_proxy_impl_name_ != 0) + { + delete this->base_proxy_impl_name_; + this->base_proxy_impl_name_ = 0; + } + + if (this->remote_proxy_impl_name_ != 0) + { + delete this->remote_proxy_impl_name_; + this->remote_proxy_impl_name_ = 0; + } + + if (this->thruPOA_proxy_impl_name_ != 0) + { + delete this->thruPOA_proxy_impl_name_; + this->thruPOA_proxy_impl_name_ = 0; + } + + if (this->direct_proxy_impl_name_ != 0) + { + delete this->direct_proxy_impl_name_; + this->direct_proxy_impl_name_ = 0; + } + + if (this->full_base_proxy_impl_name_ != 0) + { + delete this->full_base_proxy_impl_name_; + this->full_base_proxy_impl_name_ = 0; + } + + if (this->full_remote_proxy_impl_name_ != 0) + { + delete this->full_remote_proxy_impl_name_; + this->full_remote_proxy_impl_name_ = 0; + } + + if (this->full_thruPOA_proxy_impl_name_ != 0) + { + delete this->full_thruPOA_proxy_impl_name_; + this->full_thruPOA_proxy_impl_name_ = 0; + } + + if (this->full_direct_proxy_impl_name_ != 0) + { + delete this->full_direct_proxy_impl_name_; + this->full_direct_proxy_impl_name_ = 0; + } + + if (this->base_proxy_broker_ != 0) + { + delete this->base_proxy_broker_; + this->base_proxy_broker_ = 0; + } + + if (this->remote_proxy_broker_ != 0) + { + delete this->remote_proxy_broker_; + this->remote_proxy_broker_ = 0; + } + + if (this->strategized_proxy_broker_ != 0) + { + delete this->strategized_proxy_broker_; + this->strategized_proxy_broker_ = 0; + } + + if (this->full_base_proxy_broker_name_ != 0) + { + delete this->full_base_proxy_broker_name_; + this->full_base_proxy_broker_name_ = 0; + } + + if (this->full_remote_proxy_broker_name_ != 0) + { + delete this->full_remote_proxy_broker_name_; + this->full_remote_proxy_broker_name_ = 0; + } + + if (this->full_strategized_proxy_broker_name_ != 0) + { + delete this->full_strategized_proxy_broker_name_; + this->full_strategized_proxy_broker_name_ = 0; + } + + if (this->client_scope_ != 0) + { + delete this->client_scope_; + this->client_scope_ = 0; + } + + if (this->flat_client_scope_ != 0) + { + delete this->flat_client_scope_; + this->flat_client_scope_ = 0; + } + + if (this->server_scope_ != 0) + { + delete this->server_scope_; + this->server_scope_ = 0; + } + + if (this->flat_server_scope_ != 0) + { + delete this->flat_server_scope_; + this->flat_server_scope_ = 0; + } } const char * @@ -639,7 +777,9 @@ be_interface_default_strategy::create_with_prefix_suffix ( ACE_OS::strlen (separator) + 1; // The '/0' - ACE_NEW_RETURN (cat_string, char[length], 0); + ACE_NEW_RETURN (cat_string, + char[length], + 0); ACE_OS::strcpy (cat_string, prefix); ACE_OS::strcat (cat_string, str); @@ -653,7 +793,9 @@ const char * be_interface_default_strategy::base_proxy_impl_name (void) { if (this->base_proxy_impl_name_ != 0) - return this->base_proxy_impl_name_; + { + return this->base_proxy_impl_name_; + } this->base_proxy_impl_name_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -668,14 +810,18 @@ const char * be_interface_default_strategy::client_scope (void) { if (this->client_scope_ != 0) - return this->client_scope_; + { + return this->client_scope_; + } const char *full_name = this->full_name (); const char *name = this->local_name (); int offset = ACE_OS::strlen (name); int length = ACE_OS::strlen (full_name) - offset; - this->client_scope_ = new char[length+1]; + ACE_NEW_RETURN (this->client_scope_, + char[length + 1], + 0); ACE_OS::strncpy (this->client_scope_, full_name, length); this->client_scope_[length] = '\0'; @@ -686,14 +832,18 @@ const char * be_interface_default_strategy::flat_client_scope (void) { if (this->flat_client_scope_ != 0) - return this->flat_client_scope_; + { + return this->flat_client_scope_; + } const char *full_name = this->flat_name (); const char *name = this->local_name (); int offset = ACE_OS::strlen (name); int length = ACE_OS::strlen (full_name) - offset; - this->flat_client_scope_ = new char[length+1]; + ACE_NEW_RETURN (this->flat_client_scope_, + char[length + 1], + 0); ACE_OS::strncpy (this->flat_client_scope_, full_name, length); this->flat_client_scope_[length] = '\0'; @@ -706,7 +856,9 @@ const char * be_interface_default_strategy::server_scope (void) { if (this->server_scope_ != 0) - return this->server_scope_; + { + return this->server_scope_; + } const char *full_name = this->node_->full_coll_name (be_interface::DIRECT); @@ -715,7 +867,9 @@ be_interface_default_strategy::server_scope (void) int offset = ACE_OS::strlen (name); int length = ACE_OS::strlen (full_name) - offset; - this->server_scope_ = new char[length+1]; + ACE_NEW_RETURN (this->server_scope_, + char[length + 1], + 0); ACE_OS::strncpy (this->server_scope_, full_name, length); this->server_scope_[length] = '\0'; @@ -727,14 +881,18 @@ const char * be_interface_default_strategy::flat_server_scope (void) { if (this->flat_server_scope_ != 0) - return this->flat_server_scope_; + { + return this->flat_server_scope_; + } const char *full_name = this->flat_name (); const char *name = this->local_name (); int offset = ACE_OS::strlen (name); int length = ACE_OS::strlen (full_name) - offset; - this->flat_client_scope_ = new char[length+1]; + ACE_NEW_RETURN (this->flat_client_scope_, + char[length + 1], + 0); ACE_OS::strncpy (this->flat_server_scope_, full_name, length); this->flat_server_scope_[length] = '\0'; @@ -748,12 +906,17 @@ const char * be_interface_default_strategy::full_base_proxy_impl_name (void) { if (this->full_base_proxy_impl_name_ != 0) - return this->full_base_proxy_impl_name_; + { + return this->full_base_proxy_impl_name_; + } const char *scope = this->client_scope (); const char *base_name = this->base_proxy_impl_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_base_proxy_impl_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_base_proxy_impl_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_base_proxy_impl_name_, scope); ACE_OS::strcat (this->full_base_proxy_impl_name_, base_name); @@ -766,7 +929,9 @@ const char * be_interface_default_strategy::remote_proxy_impl_name (void) { if (this->remote_proxy_impl_name_ != 0) - return this->remote_proxy_impl_name_; + { + return this->remote_proxy_impl_name_; + } this->remote_proxy_impl_name_ = @@ -782,12 +947,17 @@ const char * be_interface_default_strategy::full_remote_proxy_impl_name (void) { if (this->full_remote_proxy_impl_name_ != 0) - return this->full_remote_proxy_impl_name_; + { + return this->full_remote_proxy_impl_name_; + } const char *scope = this->client_scope (); const char *base_name = this->remote_proxy_impl_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_remote_proxy_impl_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_remote_proxy_impl_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_remote_proxy_impl_name_, scope); ACE_OS::strcat (this->full_remote_proxy_impl_name_, base_name); @@ -798,7 +968,9 @@ const char * be_interface_default_strategy::thru_poa_proxy_impl_name (void) { if (this->thruPOA_proxy_impl_name_ != 0) - return this->thruPOA_proxy_impl_name_; + { + return this->thruPOA_proxy_impl_name_; + } this->thruPOA_proxy_impl_name_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -813,12 +985,17 @@ const char * be_interface_default_strategy::full_thru_poa_proxy_impl_name (void) { if (this->full_thruPOA_proxy_impl_name_ != 0) - return this->full_thruPOA_proxy_impl_name_; + { + return this->full_thruPOA_proxy_impl_name_; + } const char *scope = this->server_scope (); const char *base_name = this->thru_poa_proxy_impl_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_thruPOA_proxy_impl_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_thruPOA_proxy_impl_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_thruPOA_proxy_impl_name_, scope); ACE_OS::strcat (this->full_thruPOA_proxy_impl_name_, base_name); @@ -830,7 +1007,9 @@ const char * be_interface_default_strategy::direct_proxy_impl_name (void) { if (this->direct_proxy_impl_name_ != 0) - return this->direct_proxy_impl_name_; + { + return this->direct_proxy_impl_name_; + } this->direct_proxy_impl_name_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -846,13 +1025,18 @@ const char * be_interface_default_strategy::full_direct_proxy_impl_name (void) { if (this->full_direct_proxy_impl_name_ != 0) - return this->full_direct_proxy_impl_name_; + { + return this->full_direct_proxy_impl_name_; + } const char *scope = this->server_scope (); const char *base_name = this->direct_proxy_impl_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_direct_proxy_impl_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_direct_proxy_impl_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_direct_proxy_impl_name_, scope); ACE_OS::strcat (this->full_direct_proxy_impl_name_, base_name); @@ -864,7 +1048,9 @@ const char * be_interface_default_strategy::base_proxy_broker_name (void) { if (this->base_proxy_broker_ != 0) - return this->base_proxy_broker_; + { + return this->base_proxy_broker_; + } this->base_proxy_broker_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -879,12 +1065,17 @@ const char * be_interface_default_strategy::full_base_proxy_broker_name (void) { if (this->full_base_proxy_broker_name_ != 0) - return this->full_base_proxy_broker_name_; + { + return this->full_base_proxy_broker_name_; + } const char *scope = this->client_scope (); const char *base_name = this->base_proxy_broker_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_base_proxy_broker_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_base_proxy_broker_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_base_proxy_broker_name_, scope); ACE_OS::strcat (this->full_base_proxy_broker_name_, base_name); @@ -895,7 +1086,9 @@ const char * be_interface_default_strategy::remote_proxy_broker_name (void) { if (this->remote_proxy_broker_ != 0) - return this->remote_proxy_broker_; + { + return this->remote_proxy_broker_; + } this->remote_proxy_broker_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -911,12 +1104,17 @@ const char * be_interface_default_strategy::full_remote_proxy_broker_name (void) { if (this->full_remote_proxy_broker_name_ != 0) - return this->full_remote_proxy_broker_name_; + { + return this->full_remote_proxy_broker_name_; + } const char *scope = this->client_scope (); const char *base_name = this->remote_proxy_broker_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_remote_proxy_broker_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_remote_proxy_broker_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_remote_proxy_broker_name_, scope); ACE_OS::strcat (this->full_remote_proxy_broker_name_, base_name); @@ -928,7 +1126,9 @@ const char * be_interface_default_strategy::strategized_proxy_broker_name (void) { if (this->strategized_proxy_broker_ != 0) - return this->strategized_proxy_broker_; + { + return this->strategized_proxy_broker_; + } this->strategized_proxy_broker_ = this->create_with_prefix_suffix (this->tag_table_[GC_PREFIX], @@ -943,12 +1143,17 @@ const char * be_interface_default_strategy::full_strategized_proxy_broker_name (void) { if (this->full_strategized_proxy_broker_name_ != 0) - return this->full_strategized_proxy_broker_name_; + { + return this->full_strategized_proxy_broker_name_; + } const char *scope = this->server_scope (); const char *base_name = this->strategized_proxy_broker_name (); int length = ACE_OS::strlen (scope) + ACE_OS::strlen (base_name); - this->full_strategized_proxy_broker_name_ = new char[length+1]; + ACE_NEW_RETURN (this->full_strategized_proxy_broker_name_, + char[length + 1], + 0); + ACE_OS::strcpy (this->full_strategized_proxy_broker_name_, scope); ACE_OS::strcat (this->full_strategized_proxy_broker_name_, base_name); diff --git a/TAO/TAO_IDL/be/be_operation.cpp b/TAO/TAO_IDL/be/be_operation.cpp index bcd210104c9..ed791a03c6c 100644 --- a/TAO/TAO_IDL/be/be_operation.cpp +++ b/TAO/TAO_IDL/be/be_operation.cpp @@ -118,9 +118,13 @@ be_operation::compute_size_type (void) void be_operation::destroy (void) { + delete this->strategy_; + this->strategy_ = 0; + // Call the destroy methods of our base classes. - be_scope::destroy (); - be_decl::destroy (); + this->be_scope::destroy (); + this->be_decl::destroy (); + this->AST_Operation::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_predefined_type.cpp b/TAO/TAO_IDL/be/be_predefined_type.cpp index ddab9500d21..0c9dd051e15 100644 --- a/TAO/TAO_IDL/be/be_predefined_type.cpp +++ b/TAO/TAO_IDL/be/be_predefined_type.cpp @@ -37,103 +37,9 @@ be_predefined_type::be_predefined_type (AST_PredefinedType::PredefinedType t, n, I_TRUE) { - // Generate a new Scoped Name for us such that we belong to the CORBA - // namespace. - if (this->pt () != AST_PredefinedType::PT_void) - { - Identifier *corba_id = 0; - ACE_NEW (corba_id, - Identifier ("CORBA")); - - UTL_ScopedName *new_name = 0; - ACE_NEW (new_name, - UTL_ScopedName (corba_id, - 0)); - - Identifier *id = 0; - UTL_ScopedName *conc_name = 0; - - switch (this->pt ()) - { - case AST_PredefinedType::PT_long: - ACE_NEW (id, - Identifier ("Long")); - break; - case AST_PredefinedType::PT_ulong: - ACE_NEW (id, - Identifier ("ULong")); - break; - case AST_PredefinedType::PT_short: - ACE_NEW (id, - Identifier ("Short")); - break; - case AST_PredefinedType::PT_ushort: - ACE_NEW (id, - Identifier ("UShort")); - break; - case AST_PredefinedType::PT_float: - ACE_NEW (id, - Identifier ("Float")); - break; - case AST_PredefinedType::PT_double: - ACE_NEW (id, - Identifier ("Double")); - break; - case AST_PredefinedType::PT_char: - ACE_NEW (id, - Identifier ("Char")); - break; - case AST_PredefinedType::PT_octet: - ACE_NEW (id, - Identifier ("Octet")); - break; - case AST_PredefinedType::PT_wchar: - ACE_NEW (id, - Identifier ("WChar")); - break; - case AST_PredefinedType::PT_boolean: - ACE_NEW (id, - Identifier ("Boolean")); - break; - case AST_PredefinedType::PT_longlong: - ACE_NEW (id, - Identifier ("LongLong")); - break; - case AST_PredefinedType::PT_ulonglong: - ACE_NEW (id, - Identifier ("ULongLong")); - break; - case AST_PredefinedType::PT_longdouble: - ACE_NEW (id, - Identifier ("LongDouble")); - break; - case AST_PredefinedType::PT_any: - ACE_NEW (id, - Identifier ("Any")); - break; - case AST_PredefinedType::PT_pseudo: - ACE_NEW (id, - Identifier (n->last_component ()->get_string ())); - break; - default: - ACE_NEW (id, - Identifier (this->local_name ()->get_string ())); - } - - ACE_NEW (conc_name, - UTL_ScopedName (id, - 0)); - - new_name->nconc (conc_name); - this->set_name (new_name); - } - // Computes the repoID. this->compute_repoID (); - // Computes the fully scoped name. - AST_Decl::compute_full_name (); - // Computes the fully scoped typecode name. this->compute_tc_name (); @@ -287,6 +193,13 @@ be_predefined_type::accept (be_visitor *visitor) return visitor->visit_predefined_type (this); } +void +be_predefined_type::destroy (void) +{ + this->AST_PredefinedType::destroy (); + this->be_type::destroy (); +} + // Narrowing IMPL_NARROW_METHODS2 (be_predefined_type, AST_PredefinedType, be_type) IMPL_NARROW_FROM_DECL (be_predefined_type) diff --git a/TAO/TAO_IDL/be/be_produce.cpp b/TAO/TAO_IDL/be/be_produce.cpp index ad7b39a558c..877afdb32f7 100644 --- a/TAO/TAO_IDL/be/be_produce.cpp +++ b/TAO/TAO_IDL/be/be_produce.cpp @@ -79,16 +79,12 @@ ACE_RCSID(be, be_produce, "$Id$") TAO_IDL_BE_Export void BE_cleanup (void) { - AST_Decl *d = idl_global->root (); - be_root *root = be_root::narrow_from_decl (d); - - root->destroy (); - delete root; - root = 0; - idl_global->destroy (); delete idl_global; idl_global = 0; + + delete be_global; + be_global = 0; } // Abort this run of the BE. @@ -110,9 +106,6 @@ BE_produce (void) // Root of the AST made up of BE nodes. be_root *root = 0; - // Visitor for root. - be_visitor *visitor = 0; - // Context information for the visitor root. be_visitor_context ctx; @@ -136,158 +129,143 @@ BE_produce (void) { // Make a first pass over the AST and introduce // AMI specific interfaces, methods and valuetypes. - be_visitor_context *local_ctx = 0; - ACE_NEW (local_ctx, - be_visitor_context (ctx)); + be_visitor_ami_pre_proc ami_preproc_visitor (&ctx); - ACE_NEW (visitor, - be_visitor_ami_pre_proc (local_ctx)); - - if (root->accept (visitor) == -1) + if (root->accept (&ami_preproc_visitor) == -1) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_produce - " "client header for Root failed\n")); BE_abort (); } - - delete visitor; } if (be_global->gen_amh_classes () == I_TRUE) { // Make a first pass over the AST and introduce // AMH specific code - be_visitor_context *local_ctx = 0; - ACE_NEW (local_ctx, - be_visitor_context (ctx)); + be_visitor_amh_pre_proc amh_pre_proc_visitor (&ctx); - ACE_NEW (visitor, - be_visitor_amh_pre_proc (local_ctx)); - - if (root->accept (visitor) == -1) + if (root->accept (&amh_pre_proc_visitor) == -1) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_produce - " "client header for Root failed\n")); BE_abort (); } - - delete visitor; } // Code generation involves six steps because of the six files that we // generate. - // (1) Generate client header, - // instantiate a visitor context, and set the codegen state - ctx.state (TAO_CodeGen::TAO_ROOT_CH); - - // Get a root visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the client header - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "client header for Root failed\n")); - BE_abort (); - } - - delete visitor; - - // (2) Generate client inline and - // set the context information. - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_CI); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the client inline file. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "client inline for Root failed\n")); - BE_abort (); - } - - delete visitor; - - - // (3) Generate client stubs. - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_CS); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the client stubs. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "client stubs for Root failed\n")); - BE_abort (); - } - - delete visitor; - - // (4) Generate server header. - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_SH); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the server header file. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "server header for Root failed\n")); - BE_abort (); - } - - delete visitor; - - // (5) Generate server inline. - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_SI); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the server inline file. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "server inline for Root failed\n")); - BE_abort (); - } - - delete visitor; - - // (6) Generate server skeletons - ctx.reset (); - ctx.state (TAO_CodeGen::TAO_ROOT_SS); - - // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); - - // Generate code for the server skeletons. - if (root->accept (visitor) == -1) - { - ACE_ERROR ((LM_ERROR, - "(%N:%l) be_produce - " - "server skeletons for Root failed\n")); - BE_abort (); - } - - delete visitor; + { + // (1) Generate client header, + // instantiate a visitor context, and set the codegen state + ctx.state (TAO_CodeGen::TAO_ROOT_CH); + + // Get a root visitor. + be_visitor_root_ch root_ch_visitor (&ctx); + + // Generate code for the client header + if (root->accept (&root_ch_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "client header for Root failed\n")); + BE_abort (); + } + } + + { + // (2) Generate client inline and + // set the context information. + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_CI); + + // Create a visitor. + be_visitor_root_ci root_ci_visitor (&ctx); + + // Generate code for the client inline file. + if (root->accept (&root_ci_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "client inline for Root failed\n")); + BE_abort (); + } + } + + { + // (3) Generate client stubs. + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_CS); + + // Create a visitor. + be_visitor_root_cs root_cs_visitor (&ctx); + + // Generate code for the client stubs. + if (root->accept (&root_cs_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "client stubs for Root failed\n")); + BE_abort (); + } + } + + { + // (4) Generate server header. + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_SH); + + // Create a visitor. + be_visitor_root_sh root_sh_visitor (&ctx); + + // Generate code for the server header file. + if (root->accept (&root_sh_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "server header for Root failed\n")); + BE_abort (); + } + } + + { + // (5) Generate server inline. + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_SI); + + // Create a visitor. + be_visitor_root_si root_si_visitor (&ctx); + + // Generate code for the server inline file. + if (root->accept (&root_si_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "server inline for Root failed\n")); + BE_abort (); + } + } + + { + // (6) Generate server skeletons + ctx.reset (); + ctx.state (TAO_CodeGen::TAO_ROOT_SS); + + // Create a visitor. + be_visitor_root_ss root_ss_visitor (&ctx); + + // Generate code for the server skeletons. + if (root->accept (&root_ss_visitor) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%N:%l) be_produce - " + "server skeletons for Root failed\n")); + BE_abort (); + } + } // (7) Generated server template header. if (be_global->gen_tie_classes ()) @@ -317,10 +295,10 @@ BE_produce (void) ctx.state (TAO_CodeGen::TAO_ROOT_IH); // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); + be_visitor_root_ih root_ih_visitor (&ctx); // Generate code for the implementation header. - if (root->accept (visitor) == -1) + if (root->accept (&root_ih_visitor) == -1) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_produce - " @@ -328,25 +306,21 @@ BE_produce (void) BE_abort (); } - delete visitor; - // (9) Generate implementation source. ctx.reset (); ctx.state (TAO_CodeGen::TAO_ROOT_IS); // Create a visitor. - visitor = tao_cg->make_visitor (&ctx); + be_visitor_root_is root_is_visitor (&ctx); // Generate code for the implementation source. - if (root->accept (visitor) == -1) + if (root->accept (&root_is_visitor) == -1) { ACE_ERROR ((LM_ERROR, "(%N:%l) be_produce - " "implementation skeletons for Root failed\n")); BE_abort (); } - - delete visitor; } // Clean up. diff --git a/TAO/TAO_IDL/be/be_root.cpp b/TAO/TAO_IDL/be/be_root.cpp index 65385b6255c..581b218bc87 100644 --- a/TAO/TAO_IDL/be/be_root.cpp +++ b/TAO/TAO_IDL/be/be_root.cpp @@ -52,7 +52,7 @@ be_root::fe_add_sequence (AST_Sequence *t) return 0; } - add_to_local_types(t); + add_to_local_types (t); return t; } @@ -88,6 +88,7 @@ be_root::destroy (void) // Call the destroy methods of our base classes. be_scope::destroy (); be_decl::destroy (); + AST_Root::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_scope.cpp b/TAO/TAO_IDL/be/be_scope.cpp index c7fde75337d..a02e4a334a9 100644 --- a/TAO/TAO_IDL/be/be_scope.cpp +++ b/TAO/TAO_IDL/be/be_scope.cpp @@ -71,18 +71,7 @@ be_scope::decl (void) void be_scope::destroy (void) { - for (UTL_ScopeActiveIterator iter (this, IK_decls); - !iter.is_done (); - iter.next ()) - { - AST_Decl *i = iter.item (); - i->destroy (); - delete i; - i = 0; - } - // Still some glitches, but the call should eventually - // be made here. - // UTL_Scope::destroy (); + UTL_Scope::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_string.cpp b/TAO/TAO_IDL/be/be_string.cpp index d2f5dff0608..866ec8197f8 100644 --- a/TAO/TAO_IDL/be/be_string.cpp +++ b/TAO/TAO_IDL/be/be_string.cpp @@ -9,7 +9,7 @@ // be_string.cpp // // = DESCRIPTION -// Extension of class AST_Array that provides additional means for C++ +// Extension of class AST_String that provides additional means for C++ // mapping. // // = AUTHOR @@ -23,7 +23,9 @@ #include "idl_extern.h" #include "be.h" -ACE_RCSID(be, be_string, "$Id$") +ACE_RCSID (be, + be_string, + "$Id$") be_string::be_string (void) { @@ -31,28 +33,16 @@ be_string::be_string (void) this->size_type (be_decl::VARIABLE); } -be_string::be_string (AST_Expression *v) - : AST_String (v), - AST_Decl (AST_Decl::NT_string, - new UTL_ScopedName (new Identifier ("string"), - 0), - I_TRUE) -{ - // Always the case. - this->size_type (be_decl::VARIABLE); -} - -be_string::be_string (AST_Expression *v, - long wide) - : AST_String (v, wide), - AST_Decl (wide == (long) sizeof (char) - ? AST_Decl::NT_string - : AST_Decl::NT_wstring, - wide == (long) sizeof (char) - ? new UTL_ScopedName (new Identifier ("string"), - 0) - : new UTL_ScopedName (new Identifier ("wstring"), - 0), +be_string::be_string (AST_Decl::NodeType nt, + UTL_ScopedName *n, + AST_Expression *v, + long width) + : AST_String (nt, + n, + v, + width), + AST_Decl (nt, + n, I_TRUE) { // Always the case. @@ -90,6 +80,13 @@ be_string::accept (be_visitor *visitor) return visitor->visit_string (this); } +void +be_string::destroy (void) +{ + this->be_type::destroy (); + this->AST_String::destroy (); +} + // Narrowing. IMPL_NARROW_METHODS2 (be_string, AST_String, be_type) IMPL_NARROW_FROM_DECL (be_string) diff --git a/TAO/TAO_IDL/be/be_type.cpp b/TAO/TAO_IDL/be/be_type.cpp index 8e495d578a4..13aed0c8f9d 100644 --- a/TAO/TAO_IDL/be/be_type.cpp +++ b/TAO/TAO_IDL/be/be_type.cpp @@ -522,9 +522,12 @@ be_type::destroy (void) if (this->nested_type_name_ != 0) { - delete this->nested_type_name_; + delete [] this->nested_type_name_; this->nested_type_name_ = 0; } + + this->AST_Type::destroy (); + this->be_decl::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_typedef.cpp b/TAO/TAO_IDL/be/be_typedef.cpp index 85ab37e8eee..a0b2f8d771f 100644 --- a/TAO/TAO_IDL/be/be_typedef.cpp +++ b/TAO/TAO_IDL/be/be_typedef.cpp @@ -105,7 +105,8 @@ be_typedef::base_node_type (void) const void be_typedef::destroy (void) { - // Do nothing + this->AST_Typedef::destroy (); + this->be_type::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_visitor.cpp b/TAO/TAO_IDL/be/be_visitor.cpp index 440c1f9a3b3..e1683ceecb2 100644 --- a/TAO/TAO_IDL/be/be_visitor.cpp +++ b/TAO/TAO_IDL/be/be_visitor.cpp @@ -24,7 +24,7 @@ #include "idl.h" #include "be.h" #include "be_visitor.h" -#include "be_visitor_valuetype.h" + ACE_RCSID(be, be_visitor, "$Id$") be_visitor::be_visitor (void) @@ -180,3 +180,4 @@ int be_visitor::visit_native (be_native *) { return 0; } + diff --git a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp index da536d45417..a4f0fda2ca1 100644 --- a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp +++ b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp @@ -266,7 +266,7 @@ be_visitor_amh_pre_proc::add_exception_reply (be_operation *node, be_interface *response_handler, be_valuetype *exception_holder) { - Identifier *id = 0; + Identifier *id = 0; UTL_ScopedName *sn = 0; ACE_NEW_RETURN (id, @@ -677,7 +677,7 @@ be_visitor_amh_pre_proc::create_exception_holder (be_interface *node) AST_Interface **p_intf = 0; #endif - UTL_ScopedName *excep_holder_name = + UTL_ScopedName *excep_holder_name = node->compute_name ("AMH_", "ExceptionHolder"); be_valuetype *excep_holder = 0; diff --git a/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp b/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp index bc8ee6f9fde..40e284f2af2 100644 --- a/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp +++ b/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp @@ -517,8 +517,8 @@ be_visitor_ami_pre_proc::create_reply_handler (be_interface *node, be_interface (reply_handler_name, // name p_intf, // list of inherited 1, // number of inherited - p_intf, // list of ancestors - 1, // number of ancestors + 0, // list of all ancestors + 0, // number of ancestors 0, // non-local 0), // non-abstract 0); diff --git a/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp b/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp index 06cfa4d0cce..3fa6243b5a0 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/post_upcall_ss.cpp @@ -23,7 +23,9 @@ #include "be.h" #include "be_visitor_argument.h" -ACE_RCSID(be_visitor_argument, post_upcall_ss, "$Id$") +ACE_RCSID (be_visitor_argument, + post_upcall_ss, + "$Id$") // ************************************************************************ // visitor for doing any post-processing after the upcall is made @@ -53,7 +55,7 @@ int be_visitor_args_post_upcall_ss::visit_argument (be_argument *node) if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_compiled_args_post_upcall::" + "be_visitor_args_post_upcall::" "visit_argument - " "Bad argument type\n"), -1); @@ -65,7 +67,7 @@ int be_visitor_args_post_upcall_ss::visit_argument (be_argument *node) if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_compiled_args_post_upcall::" + "be_visitor_args_post_upcall::" "visit_argument - " "cannot accept visitor\n"), -1); @@ -116,7 +118,7 @@ int be_visitor_args_post_upcall_ss::visit_typedef (be_typedef *node) if (node->primitive_base_type ()->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_compiled_args_post_upcall::" + "be_visitor_args_post_upcall::" "visit_typedef - " "accept on primitive type failed\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_argument/pre_invoke_cs.cpp b/TAO/TAO_IDL/be/be_visitor_argument/pre_invoke_cs.cpp index 43c173b574d..e42af34029e 100644 --- a/TAO/TAO_IDL/be/be_visitor_argument/pre_invoke_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_argument/pre_invoke_cs.cpp @@ -23,7 +23,9 @@ #include "be.h" #include "be_visitor_argument.h" -ACE_RCSID(be_visitor_argument, pre_invoke_cs, "$Id$") +ACE_RCSID (be_visitor_argument, + pre_invoke_cs, + "$Id$") // ************************************************************************* diff --git a/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp b/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp index c95b0d52563..709f3716673 100644 --- a/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp +++ b/TAO/TAO_IDL/be/be_visitor_attribute/attribute.cpp @@ -70,17 +70,18 @@ be_visitor_attribute::visit_attribute (be_attribute *node) // first the "get" operation - be_operation *op = new be_operation (node->field_type (), - AST_Operation::OP_noflags, - node->name (), - node->is_local (), - node->is_abstract ()); - op->set_name ((UTL_IdList *) node->name ()->copy ()); - op->set_defined_in (node->defined_in ()); + be_operation get_op (node->field_type (), + AST_Operation::OP_noflags, + node->name (), + node->is_local (), + node->is_abstract ()); + + get_op.set_name ((UTL_IdList *) node->name ()->copy ()); + get_op.set_defined_in (node->defined_in ()); // Get the strategy from the attribute and hand it over // to the operation - delete op->set_strategy (node->get_get_strategy ()); + delete get_op.set_strategy (node->get_get_strategy ()); be_visitor_context ctx (*this->ctx_); @@ -141,7 +142,7 @@ be_visitor_attribute::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CS: ctx.state (TAO_CodeGen::TAO_OPERATION_SMART_PROXY_CS); break; - case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CH: + case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CH: ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_CH); break; case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CS: @@ -170,13 +171,13 @@ be_visitor_attribute::visit_attribute (be_attribute *node) } // Change the state depending on the kind of node strategy - ctx.state (op->next_state (ctx.state ())); + ctx.state (get_op.next_state (ctx.state ())); be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (op->accept (visitor) == -1)) + + if (!visitor || (get_op.accept (visitor) == -1)) { delete visitor; - delete op; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " @@ -187,16 +188,15 @@ be_visitor_attribute::visit_attribute (be_attribute *node) delete visitor; visitor = 0; - if (op->has_extra_code_generation (ctx.state ())) + if (get_op.has_extra_code_generation (ctx.state ())) { // Change the state depending on the kind of node strategy - ctx.state (op->next_state (ctx.state (), 1)); - + ctx.state (get_op.next_state (ctx.state (), 1)); be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (op->accept (visitor) == -1)) + + if (!visitor || (get_op.accept (visitor) == -1)) { delete visitor; - delete op; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " @@ -208,37 +208,46 @@ be_visitor_attribute::visit_attribute (be_attribute *node) visitor = 0; } - delete op; - // Do nothing for readonly attributes. if (node->readonly ()) - return 0; + { + return 0; + } // Create the set method. + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); // the return type is "void" - be_predefined_type *rt = - new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName (new Identifier ("void"), - 0)); + be_predefined_type rt (AST_PredefinedType::PT_void, + sn); // argument type is the same as the attribute type - be_argument *arg = new be_argument (AST_Argument::dir_IN, - node->field_type (), - node->name ()); - arg->set_name ((UTL_IdList *) node->name ()->copy ()); + be_argument arg (AST_Argument::dir_IN, + node->field_type (), + node->name ()); + arg.set_name ((UTL_IdList *) node->name ()->copy ()); // create the operation - op = new be_operation (rt, - AST_Operation::OP_noflags, - node->name (), - node->is_local (), - node->is_abstract ()); - op->set_name ((UTL_IdList *) node->name ()->copy ()); - op->set_defined_in (node->defined_in ()); - op->add_argument_to_scope (arg); + be_operation set_op (&rt, + AST_Operation::OP_noflags, + node->name (), + node->is_local (), + node->is_abstract ()); + set_op.set_name ((UTL_IdList *) node->name ()->copy ()); + set_op.set_defined_in (node->defined_in ()); + set_op.add_argument_to_scope (&arg); // Get the strategy from the attribute and hand it over // to the operation, thereby deleting the old one. - delete op->set_strategy (node->get_set_strategy ()); + delete set_op.set_strategy (node->get_set_strategy ()); ctx = *this->ctx_; // this switch statement eliminates the need for different classes that have @@ -327,49 +336,43 @@ be_visitor_attribute::visit_attribute (be_attribute *node) // Change the state depending on the kind of node strategy - ctx.state (op->next_state (ctx.state ())); - + ctx.state (set_op.next_state (ctx.state ())); visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (op->accept (visitor) == -1)) + + if (!visitor || (set_op.accept (visitor) == -1)) { delete visitor; - delete op; - delete arg; - delete rt; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "codegen for set_attribute failed\n"), -1); } + delete visitor; visitor = 0; - if (op->has_extra_code_generation (ctx.state ())) + if (set_op.has_extra_code_generation (ctx.state ())) { // Change the state depending on the kind of node strategy - ctx.state (op->next_state (ctx.state (), 1)); + ctx.state (set_op.next_state (ctx.state (), 1)); visitor = tao_cg->make_visitor (&ctx); - if (!visitor || !op || (op->accept (visitor) == -1)) + + if (!visitor || (set_op.accept (visitor) == -1)) { delete visitor; - delete op; - delete arg; - delete rt; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "codegen for set_attribute failed\n"), -1); } + delete visitor; visitor = 0; } - delete op; - delete rt; - delete arg; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp b/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp index e6c6bd01342..de697ab6a68 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/enum_ch.cpp @@ -18,11 +18,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_enum.h" +#include "be_visitor_typecode/typecode_decl.h" ACE_RCSID(be_visitor_enum, enum_ch, "$Id$") @@ -79,9 +79,9 @@ be_visitor_enum_ch::visit_enum (be_enum *node) // will be based on the command line options. This is still TO-DO. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_typecode_decl visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_enum_ch::" diff --git a/TAO/TAO_IDL/be/be_visitor_enum/enum_cs.cpp b/TAO/TAO_IDL/be/be_visitor_enum/enum_cs.cpp index e846ec8b439..dd388d32179 100644 --- a/TAO/TAO_IDL/be/be_visitor_enum/enum_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_enum/enum_cs.cpp @@ -18,11 +18,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_enum.h" +#include "be_visitor_typecode/typecode_defn.h" ACE_RCSID(be_visitor_enum, enum_cs, "$Id$") @@ -47,24 +47,22 @@ be_visitor_enum_cs::visit_enum (be_enum *node) { if (!node->cli_stub_gen () && !node->imported () && !node->is_local ()) { - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - be_visitor *visitor; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_typecode_defn visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_enum_cs::" "visit_enum - " - "TypeCode definition failed\n" - ), -1); + "TypeCode definition failed\n"), + -1); } node->cli_stub_gen (I_TRUE); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp index 71f9590bb4b..8cc93857ca1 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception.cpp @@ -18,16 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_exception.h" +#include "be_visitor_field.h" -ACE_RCSID(be_visitor_exception, exception, "$Id$") +ACE_RCSID (be_visitor_exception, + exception, + "$Id$") -// generic struct visitor +// Generic exception visitor. be_visitor_exception::be_visitor_exception (be_visitor_context *ctx) : be_visitor_scope (ctx) { @@ -37,74 +39,88 @@ be_visitor_exception::~be_visitor_exception (void) { } -// visit the Exception node and its scope +// Visit the Exception node and its scope. int be_visitor_exception::visit_exception (be_exception *) { - return -1; // must be overriden + // Must be overriden. + return -1; } int be_visitor_exception::visit_field (be_field *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same + ctx.node (node); + int status = 0; - // this switch is acceptable rather than having derived visitors overriding + // This switch is acceptable rather than having derived visitors overriding // this method and differing only in what state they set switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_EXCEPTION_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CH); + be_visitor_field_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CI); + be_visitor_field_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CS); + be_visitor_field_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); + be_visitor_field_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CI); + be_visitor_field_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); + be_visitor_field_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception::" "visit_field - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception::" "visit_field - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_exception::" - "visit_field - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp index 80347ac7477..ffeb80ca1ad 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_ch.cpp @@ -18,12 +18,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" #include "be.h" #include "be_visitor_exception.h" +#include "be_visitor_typecode/typecode_decl.h" -ACE_RCSID(be_visitor_exception, exception_ch, "$Id$") +ACE_RCSID (be_visitor_exception, + exception_ch, + "$Id$") // ****************************************************** @@ -77,8 +78,7 @@ int be_visitor_exception_ch::visit_exception (be_exception *node) *os << node->local_name () << " &operator= (const " << node->local_name () << " &);\n" << be_nl; - if (!node->is_local ()) - *os << "static void _tao_any_destructor (void*);\n" << be_nl; + *os << "static void _tao_any_destructor (void*);\n" << be_nl; *os << "static " << node->local_name () << " *_downcast (CORBA::Exception *);" << be_nl; @@ -103,44 +103,38 @@ int be_visitor_exception_ch::visit_exception (be_exception *node) { be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_exception_ctor visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception::" "visit_exception - " - "codegen for ctor failed\n"), -1); + "codegen for ctor failed\n"), + -1); } - - delete visitor; } - if (!node->is_local () && be_global->tc_support ()) + if (be_global->tc_support ()) { *os << be_nl <<"virtual CORBA::TypeCode_ptr _type (void) const;"; } *os << be_uidt_nl << "};\n\n"; - if (!node->is_local ()) + if (be_global->tc_support ()) { - // By using a visitor to declare and define the TypeCode, we - // have the added advantage to conditionally not generate - // any code. This will be based on the command line - // options. This is still TO-DO. - be_visitor *visitor = 0; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_typecode_decl visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception_ch::" "visit_exception - " - "TypeCode declaration failed\n" - ), -1); + "TypeCode declaration failed\n"), + -1); } } diff --git a/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp b/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp index ba617486fff..6e9cc86b544 100644 --- a/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_exception/exception_cs.cpp @@ -18,13 +18,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" #include "be.h" - #include "be_visitor_exception.h" +#include "be_visitor_typecode/typecode_defn.h" -ACE_RCSID(be_visitor_exception, exception_cs, "$Id$") +ACE_RCSID (be_visitor_exception, + exception_cs, + "$Id$") // *************************************************************************** @@ -42,11 +42,9 @@ be_visitor_exception_cs::~be_visitor_exception_cs (void) // Visit the Exception_Cs node and its scope. int be_visitor_exception_cs::visit_exception (be_exception *node) { - TAO_OutStream *os = 0; - if (!node->cli_stub_gen () && !node->imported ()) { - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); os->indent (); @@ -87,18 +85,16 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); - be_visitor *visitor = 0; if (node->nmembers () > 0) { *os << be_idt; // Assign each individual member. - visitor = tao_cg->make_visitor (&ctx); + be_visitor_exception_ctor_assign visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception_cs::" "visit_exception -" @@ -106,8 +102,8 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) -1); } - delete visitor; *os << be_uidt; + os->decr_indent (); } @@ -125,11 +121,10 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) // Assign each individual member. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_ASSIGN_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_exception_ctor_assign visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception_cs::" "visit_exception -" @@ -137,22 +132,19 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) -1); } - delete visitor; os->indent (); + *os << "return *this;" << be_uidt_nl << "}" << be_nl << be_nl; - if (!node->is_local ()) - { - *os << "void " - << node->name () - << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl - << "{" << be_idt_nl - << node->local_name () << " *tmp = ACE_static_cast (" - << node->local_name () << "*, _tao_void_pointer);" << be_nl - << "delete tmp;" << be_uidt_nl - << "}" << be_nl << be_nl; - } + *os << "void " + << node->name () + << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl + << "{" << be_idt_nl + << node->local_name () << " *tmp = ACE_static_cast (" + << node->local_name () << "*, _tao_void_pointer);" << be_nl + << "delete tmp;" << be_uidt_nl + << "}" << be_nl << be_nl; *os << node->name () << " *" << be_nl; *os << node->name () << "::_downcast (CORBA::Exception *exc)" << be_nl; @@ -291,9 +283,9 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) // Generate the signature. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_EXCEPTION_CTOR_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_exception_ctor ec_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&ec_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception::" @@ -302,8 +294,6 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) -1); } - delete visitor; - *os << " : CORBA_UserException " << "(\"" << node->repoID () << "\")" << be_uidt_nl; *os << "{\n"; @@ -315,13 +305,12 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) // Indicate that the special ctor is being generated. ctx.exception (1); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_exception_ctor_assign eca_visitor (&ctx); *os << be_idt; - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&eca_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception_cs::" "visit_exception -" @@ -329,23 +318,19 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) -1); } - delete visitor; os->decr_indent (); + *os << "}\n\n"; } - if (!node->is_local ()) + if (be_global->tc_support ()) { - // By using a visitor to declare and define the TypeCode, we - // have the added advantage to conditionally not generate - // any code. This will be based on the command line - // options. This is still TO-DO. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_typecode_defn visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_exception_cs::" @@ -355,7 +340,7 @@ int be_visitor_exception_cs::visit_exception (be_exception *node) } } - if (!node->is_local () && be_global->tc_support ()) + if (be_global->tc_support ()) { *os << "\n// TAO extension - the virtual _type method." << be_nl; *os << "CORBA::TypeCode_ptr " << node->name () diff --git a/TAO/TAO_IDL/be/be_visitor_factory.cpp b/TAO/TAO_IDL/be/be_visitor_factory.cpp index 20b88782b2a..1f6b4da4c00 100644 --- a/TAO/TAO_IDL/be/be_visitor_factory.cpp +++ b/TAO/TAO_IDL/be/be_visitor_factory.cpp @@ -19,11 +19,10 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "idl.h" +#include "idl_extern.h" +#include "be.h" -// individual visitors included only here #include "be_visitor_factory.h" #include "be_visitor_argument.h" @@ -83,7 +82,7 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) // create a new context so that ownership issues are not confused. This newly // created context is a copy of what was sent by the caller. The newly // created visitor will own this new copy. - be_visitor_context *new_ctx = new be_visitor_context (*ctx); + be_visitor_context *new_ctx = ctx; switch (st) { case TAO_CodeGen::TAO_ROOT_CH: @@ -484,14 +483,19 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_ATTRIBUTE_IH: case TAO_CodeGen::TAO_ATTRIBUTE_SS: case TAO_CodeGen::TAO_ATTRIBUTE_IS: + case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SH: case TAO_CodeGen::TAO_ATTRIBUTE_TIE_SI: + case TAO_CodeGen::TAO_ATTRIBUTE_THRU_POA_COLLOCATED_SH: case TAO_CodeGen::TAO_ATTRIBUTE_THRU_POA_COLLOCATED_SS: + case TAO_CodeGen::TAO_ATTRIBUTE_DIRECT_COLLOCATED_SH: case TAO_CodeGen::TAO_ATTRIBUTE_DIRECT_COLLOCATED_SS: + case TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CH: case TAO_CodeGen::TAO_ATTRIBUTE_SMART_PROXY_CS: + case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CH: case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_CS: case TAO_CodeGen::TAO_ATTRIBUTE_INTERCEPTORS_SH: @@ -544,7 +548,6 @@ TAO_Common_Visitor_Factory::make_visitor (be_visitor_context *ctx) return new be_visitor_array_cdr_op_cs (new_ctx); default: // an error - delete new_ctx; return 0; } return 0; @@ -569,7 +572,7 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) // create a new context so that ownership issues are not confused. This newly // created context is a copy of what was sent by the caller. The newly // created visitor will own this new copy. - be_visitor_context *new_ctx = new be_visitor_context (*ctx); + be_visitor_context *new_ctx = ctx; switch (st) { @@ -657,9 +660,6 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_OPERATION_RETVAL_ASSIGN_SS: return new be_visitor_operation_rettype_assign_ss (new_ctx); - case TAO_CodeGen::TAO_OPERATION_INVOKE_ARG_LIST: - return new be_visitor_operation_inv_arglist (new_ctx); - case TAO_CodeGen::TAO_OPERATION_ARGLIST_CH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_SH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_IH: @@ -698,7 +698,7 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: case TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS: - return new be_compiled_visitor_operation_argument_marshal (new_ctx); + return new be_visitor_operation_argument_marshal (new_ctx); case TAO_CodeGen::TAO_OPERATION_TIE_SH: return new be_visitor_operation_tie_sh (new_ctx); @@ -707,7 +707,7 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) return new be_visitor_operation_tie_si (new_ctx); case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS: - return new be_compiled_visitor_operation_argument_invoke (new_ctx); + return new be_visitor_operation_argument_invoke (new_ctx); case TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH: case TAO_CodeGen::TAO_ARGUMENT_ARGLIST_SH: @@ -759,13 +759,13 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) return new be_visitor_operation_ami_handler_reply_stub_operation_ch (new_ctx); case TAO_CodeGen::TAO_AMI_HANDLER_REPLY_STUB_OPERATION_CS: - return new be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs (new_ctx); + return new be_visitor_operation_ami_handler_reply_stub_operation_cs (new_ctx); case TAO_CodeGen::TAO_AMI_SENDC_OPERATION_CH: return new be_visitor_operation_ami_ch (new_ctx); case TAO_CodeGen::TAO_AMI_SENDC_OPERATION_CS: - return new be_compiled_visitor_operation_ami_cs (new_ctx); + return new be_visitor_operation_ami_cs (new_ctx); case TAO_CodeGen::TAO_AMI_EXCEPTION_HOLDER_RAISE_OPERATION_CS: return new be_visitor_operation_ami_exception_holder_operation_cs (new_ctx); @@ -790,7 +790,6 @@ TAO_Compiled_Visitor_Factory::make_visitor (be_visitor_context *ctx) default: // cannot handle it; delegate it to the common visitor factory - delete new_ctx; return TAO_COMMON_VISITOR_FACTORY::instance ()->make_visitor (ctx); } } diff --git a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ch.cpp index 35f083cec82..80be47544f2 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ch.cpp @@ -18,127 +18,116 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_field.h" +#include "be_visitor_array/cdr_op_ch.h" +#include "be_visitor_enum/cdr_op_ch.h" +#include "be_visitor_sequence/cdr_op_ch.h" +#include "be_visitor_structure/structure.h" +#include "be_visitor_structure/cdr_op_ch.h" +#include "be_visitor_union/union.h" +#include "be_visitor_union/cdr_op_ch.h" ACE_RCSID(be_visitor_field, cdr_op_ch, "$Id$") // ********************************************** -// visitor for field in the client header file +// Visitor for field in the client header file. // ********************************************** -// constructor +// Constructor. be_visitor_field_cdr_op_ch::be_visitor_field_cdr_op_ch (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor +// Destructor. be_visitor_field_cdr_op_ch::~be_visitor_field_cdr_op_ch (void) { } -// visit the field node +// Visit the field node. int be_visitor_field_cdr_op_ch::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field can be. -// visit array type int be_visitor_field_cdr_op_ch::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined. - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. + // This is the case for anonymous arrays. - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the struct declaration + // First generate the array declaration. ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit enum type int be_visitor_field_cdr_op_ch::visit_enum (be_enum *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined + if (!this->ctx_->alias () // not a typedef. && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the enum declaration + // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" @@ -146,38 +135,28 @@ be_visitor_field_cdr_op_ch::visit_enum (be_enum *node) "codegen failed\n" ), -1); } - delete visitor; } return 0; } -// visit sequence type int be_visitor_field_cdr_op_ch::visit_sequence (be_sequence *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined. if (!this->ctx_->alias () // not a typedef && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the sequence declaration + // First generate the sequence declaration. ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" @@ -185,13 +164,11 @@ be_visitor_field_cdr_op_ch::visit_sequence (be_sequence *node) "codegen failed\n" ), -1); } - delete visitor; } return 0; } -// visit structure type int be_visitor_field_cdr_op_ch::visit_structure (be_structure *node) { @@ -208,16 +185,9 @@ be_visitor_field_cdr_op_ch::visit_structure (be_structure *node) // first generate the struct declaration ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" @@ -225,23 +195,22 @@ be_visitor_field_cdr_op_ch::visit_structure (be_structure *node) "codegen failed\n" ), -1); } - delete visitor; } return 0; } -// visit typedefed type int be_visitor_field_cdr_op_ch::visit_typedef (be_typedef *node) { - // save the node for use in code generation and + // Save the node for use in code generation and // indicate that the field of the field node - // is a typedefed quantity + // is a typedefed quantity. this->ctx_->alias (node); - // make a decision based on the primitive base type + // 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, @@ -250,6 +219,7 @@ be_visitor_field_cdr_op_ch::visit_typedef (be_typedef *node) "Bad primitive type\n" ), -1); } + this->ctx_->alias (0); return 0; } @@ -258,28 +228,20 @@ be_visitor_field_cdr_op_ch::visit_typedef (be_typedef *node) int be_visitor_field_cdr_op_ch::visit_union (be_union *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined. if (!this->ctx_->alias () // not a typedef && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the enum declaration + // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ch::" @@ -287,7 +249,6 @@ be_visitor_field_cdr_op_ch::visit_union (be_union *node) "codegen failed\n" ), -1); } - delete visitor; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp index 6761af03dca..1c661538b90 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_ci.cpp @@ -22,8 +22,15 @@ #include "idl_extern.h" #include "be.h" #include "be_visitor_field.h" +#include "be_visitor_array/cdr_op_ci.h" +#include "be_visitor_enum/cdr_op_ci.h" +#include "be_visitor_sequence/cdr_op_ci.h" +#include "be_visitor_structure/cdr_op_ci.h" +#include "be_visitor_union/cdr_op_ci.h" -ACE_RCSID(be_visitor_field, cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_field, + cdr_op_ci, + "$Id$") // ********************************************** @@ -171,18 +178,9 @@ be_visitor_field_cdr_op_ci::visit_array (be_array *node) // First generate the declaration. ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_array_cdr_op_ci visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_array - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -190,8 +188,6 @@ be_visitor_field_cdr_op_ci::visit_array (be_array *node) "codegen failed\n"), -1); } - - delete visitor; } return 0; @@ -251,18 +247,9 @@ be_visitor_field_cdr_op_ci::visit_enum (be_enum *node) // Generate the typcode for enums. ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_enum - " - "Bad visitor\n"), - -1); - } + be_visitor_enum_cdr_op_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -270,8 +257,6 @@ be_visitor_field_cdr_op_ci::visit_enum (be_enum *node) "codegen failed\n"), -1); } - - delete visitor; } return 0; @@ -520,17 +505,9 @@ be_visitor_field_cdr_op_ci::visit_sequence (be_sequence *node) // Generate the inline code for structs. ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_sequence - " - "Bad visitor\n"), - -1); - } + be_visitor_sequence_cdr_op_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -538,8 +515,6 @@ be_visitor_field_cdr_op_ci::visit_sequence (be_sequence *node) "codegen failed\n"), -1); } - - delete visitor; } return 0; @@ -643,18 +618,9 @@ be_visitor_field_cdr_op_ci::visit_structure (be_structure *node) // Generate the inline code for structs. ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_struct - " - "Bad visitor\n"), - -1); - } + be_visitor_structure_cdr_op_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -662,8 +628,6 @@ be_visitor_field_cdr_op_ci::visit_structure (be_structure *node) "codegen failed\n"), -1); } - - delete visitor; } return 0; @@ -748,18 +712,9 @@ be_visitor_field_cdr_op_ci::visit_union (be_union *node) // Generate the inline code for union. ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_union_cdr_op_ci visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_union - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_ci::" @@ -767,8 +722,6 @@ be_visitor_field_cdr_op_ci::visit_union (be_union *node) "codegen failed\n"), -1); } - - delete visitor; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp index 93f25b43b70..d0b4c202d7c 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/cdr_op_cs.cpp @@ -18,86 +18,75 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_field.h" +#include "be_visitor_array/cdr_op_cs.h" +#include "be_visitor_sequence/cdr_op_cs.h" +#include "be_visitor_structure/cdr_op_cs.h" +#include "be_visitor_union/cdr_op_cs.h" -ACE_RCSID(be_visitor_field, cdr_op_cs, "$Id$") +ACE_RCSID (be_visitor_field, + cdr_op_cs, + "$Id$") // ********************************************** // visitor for field in the client stubs file // ********************************************** -// constructor -be_visitor_field_cdr_op_cs::be_visitor_field_cdr_op_cs (be_visitor_context *ctx) +be_visitor_field_cdr_op_cs::be_visitor_field_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// destructor be_visitor_field_cdr_op_cs::~be_visitor_field_cdr_op_cs (void) { } -// visit the field node int be_visitor_field_cdr_op_cs::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } + return 0; } -// visit array int be_visitor_field_cdr_op_cs::visit_array (be_array *node) { - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. Generate the <<, >> operators - // for the type defined by the anonymous array - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - - // set the node to be the node being visited. The scope - // is still the same ctx.node (node); - - // first generate the declaration ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" @@ -105,46 +94,14 @@ be_visitor_field_cdr_op_cs::visit_array (be_array *node) "codegen failed\n" ), -1); } - delete visitor; } + return 0; } -// visit enum type int be_visitor_field_cdr_op_cs::visit_enum (be_enum *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the typcode for enums - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_ci::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } return 0; } @@ -154,135 +111,87 @@ be_visitor_field_cdr_op_cs::visit_sequence (be_sequence *node) if (node->node_type () != AST_Decl::NT_typedef && node->is_child (this->ctx_->scope ())) { - // Anonymous sequence - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - - // set the node to be the node being visited. The scope is - // still the same be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // generate the code for sequences ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit structure type int be_visitor_field_cdr_op_cs::visit_structure (be_structure *node) { if (node->node_type () != AST_Decl::NT_typedef && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - // set the node to be the node being visited. The scope is - // still the same ctx.node (node); - - // generate the inline code for structs ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_field_cdr_op_cs::visit_typedef (be_typedef *node) { - // save the typedef node for use in code generation as we visit the - // base type this->ctx_->alias (node); - - // the node to be visited in the base primitve type that gets - // typedefed be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_field_cdr_op_cs::visit_union (be_union *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for union + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cdr_op_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cdr_op_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp index 0e67616f8a2..b78a2221f4a 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/field_ch.cpp @@ -18,39 +18,39 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_field.h" +#include "be_visitor_array.h" +#include "be_visitor_enum/enum_ch.h" +#include "be_visitor_sequence/sequence_ch.h" +#include "be_visitor_structure.h" +#include "be_visitor_union.h" -ACE_RCSID(be_visitor_field, field_ch, "$Id$") +ACE_RCSID (be_visitor_field, + field_ch, + "$Id$") // ********************************************** -// visitor for field in the client header file +// Visitor for field in the client header file. // ********************************************** -// Constructor. be_visitor_field_ch::be_visitor_field_ch (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// Destructor. be_visitor_field_ch::~be_visitor_field_ch (void) { } -// Visit the field node. int be_visitor_field_ch::visit_field (be_field *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // First generate the type information. - bt = be_type::narrow_from_decl (node->field_type ()); + be_type *bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) { @@ -78,9 +78,8 @@ be_visitor_field_ch::visit_field (be_field *node) return 0; } -// =Visit operations on all possible data types that a field can be. +// Visit operations on all possible data types that a field can be. -// Visit array type. int be_visitor_field_ch::visit_array (be_array *node) { @@ -110,18 +109,9 @@ be_visitor_field_ch::visit_array (be_array *node) // First generate the array declaration ctx.state (TAO_CodeGen::TAO_ARRAY_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_array_ch visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_array - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -130,8 +120,6 @@ be_visitor_field_ch::visit_array (be_array *node) -1); } - delete visitor; - // Having defined all array type and its supporting operations, now // generate the actual variable that is a field of the structure. *os << "_" << bt->local_name (); @@ -154,7 +142,6 @@ be_visitor_field_ch::visit_array (be_array *node) return 0; } -// Visit enum type. int be_visitor_field_ch::visit_enum (be_enum *node) { @@ -181,18 +168,9 @@ be_visitor_field_ch::visit_enum (be_enum *node) // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_enum_ch visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_enum - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -200,8 +178,6 @@ be_visitor_field_ch::visit_enum (be_enum *node) "codegen failed\n"), -1); } - - delete visitor; } // Now use this enum as a "type" for the subsequent declarator. @@ -219,7 +195,6 @@ be_visitor_field_ch::visit_enum (be_enum *node) return 0; } -// Visit interface type. int be_visitor_field_ch::visit_interface (be_interface *node) { @@ -250,7 +225,6 @@ be_visitor_field_ch::visit_interface (be_interface *node) return 0; } -// Visit interface forward type. int be_visitor_field_ch::visit_interface_fwd (be_interface_fwd *node) { @@ -281,7 +255,6 @@ be_visitor_field_ch::visit_interface_fwd (be_interface_fwd *node) return 0; } -// Visit valuetype type. int be_visitor_field_ch::visit_valuetype (be_valuetype *node) { @@ -312,7 +285,6 @@ be_visitor_field_ch::visit_valuetype (be_valuetype *node) return 0; } -// Visit valuetype forward type. int be_visitor_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) { @@ -343,7 +315,6 @@ be_visitor_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) return 0; } -// Visit predefined type. int be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) { @@ -359,7 +330,6 @@ be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined. if (node->pt () == AST_PredefinedType::PT_pseudo) { // Check if we are dealing with a CORBA::Object, @@ -398,7 +368,6 @@ be_visitor_field_ch::visit_predefined_type (be_predefined_type *node) return 0; } -// Visit sequence type. int be_visitor_field_ch::visit_sequence (be_sequence *node) { @@ -414,29 +383,17 @@ be_visitor_field_ch::visit_sequence (be_sequence *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); // First generate the sequence declaration. ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_sequence - " - "Bad visitor\n"), - -1); - } + be_visitor_sequence_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -445,8 +402,6 @@ be_visitor_field_ch::visit_sequence (be_sequence *node) -1); } - delete visitor; - // If we are being reused by valutype, this would get generated // in the private section of the OBV_xx class, so we must // generate the typedef for that case elsewhere. @@ -483,15 +438,11 @@ be_visitor_field_ch::visit_sequence (be_sequence *node) return 0; } -// Visit string type. int be_visitor_field_ch::visit_string (be_string *node) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // Set the right type. if (node->width () == (long) sizeof (char)) { *os << "TAO_String_Manager"; @@ -504,7 +455,6 @@ be_visitor_field_ch::visit_string (be_string *node) return 0; } -// Visit structure type. int be_visitor_field_ch::visit_structure (be_structure *node) { @@ -520,29 +470,16 @@ be_visitor_field_ch::visit_structure (be_structure *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined. if (!this->ctx_->alias () // not a typedef && node->is_child (this->ctx_->scope ())) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - // First generate the struct declaration. ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_struct - " - "Bad visitor\n"), - -1); - } + be_visitor_structure_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -550,8 +487,6 @@ be_visitor_field_ch::visit_structure (be_structure *node) "codegen failed\n"), -1); } - - delete visitor; } // ACE_NESTED_CLASS macro generated by nested_type_name @@ -607,29 +542,16 @@ be_visitor_field_ch::visit_union (be_union *node) bt = node; } - // If not a typedef and we are defined in the use scope, we must be defined. - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - // First generate the union declaration. ctx.state (TAO_CodeGen::TAO_UNION_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ch::" - "visit_union - " - "Bad visitor\n"), - -1); - } + be_visitor_union_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" @@ -637,8 +559,6 @@ be_visitor_field_ch::visit_union (be_union *node) "codegen failed\n"), -1); } - - delete visitor; } // ACE_NESTED_CLASS macro generated by nested_type_name diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp index 57d2daa7690..a05860634cf 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/field_ci.cpp @@ -18,238 +18,171 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_field.h" +#include "be_visitor_array/array_ci.h" +#include "be_visitor_sequence/sequence_ci.h" +#include "be_visitor_structure/structure_ci.h" +#include "be_visitor_union/union_ci.h" -ACE_RCSID(be_visitor_field, field_ci, "$Id$") - +ACE_RCSID (be_visitor_field, + field_ci, + "$Id$") -// ********************************************** -// visitor for field in the client inline file. -// -// Generate inline code for types that are defined -// inside the structure -// ********************************************** -// constructor be_visitor_field_ci::be_visitor_field_ci (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor be_visitor_field_ci::~be_visitor_field_ci (void) { } -// visit the field node int be_visitor_field_ci::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); - // first generate the type information + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } + return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field can be -// visit array int be_visitor_field_ci::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the struct declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ci::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit sequence int be_visitor_field_ci::visit_sequence (be_sequence *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // anonymous sequence - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit structure type int be_visitor_field_ci::visit_structure (be_structure *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ci::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_field_ci::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type - - // the node to be visited in the base primitve type that gets typedefed + this->ctx_->alias (node); be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_field_ci::visit_union (be_union *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the inline code for union + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_ci::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ci::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_field/field_cs.cpp b/TAO/TAO_IDL/be/be_visitor_field/field_cs.cpp index 756c8aa123b..da377a69e0a 100644 --- a/TAO/TAO_IDL/be/be_visitor_field/field_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_field/field_cs.cpp @@ -18,268 +18,197 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_field.h" +#include "be_visitor_array/array_cs.h" +#include "be_visitor_enum/enum_cs.h" +#include "be_visitor_sequence/sequence_cs.h" +#include "be_visitor_structure/structure_cs.h" +#include "be_visitor_union/union_cs.h" -ACE_RCSID(be_visitor_field, field_cs, "$Id$") +ACE_RCSID (be_visitor_field, + field_cs, + "$Id$") // ********************************************** -// visitor for field in the client stubs file +// Visitor for field in the client stubs file. // ********************************************** -// constructor be_visitor_field_cs::be_visitor_field_cs (be_visitor_context *ctx) : be_visitor_decl (ctx) { } -// destructor be_visitor_field_cs::~be_visitor_field_cs (void) { } -// visit the field node int be_visitor_field_cs::visit_field (be_field *node) { - // first generate the type information be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } + return 0; } -// visit array int be_visitor_field_cs::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be - // defined - - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the struct declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit enum type int be_visitor_field_cs::visit_enum (be_enum *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the typcode for enums + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ENUM_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } int be_visitor_field_cs::visit_sequence (be_sequence *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit structure type int be_visitor_field_cs::visit_structure (be_structure *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_field_cs::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type - - // the node to be visited in the base primitve type that gets typedefed + this->ctx_->alias (node); be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_field_cs::visit_union (be_union *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for union + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_field_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp index 8b7aef7aa1e..152c05578c5 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface.cpp @@ -18,20 +18,28 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" - -ACE_RCSID(be_visitor_interface, interface, "$Id$") +#include "be_visitor_attribute.h" +#include "be_visitor_constant.h" +#include "be_visitor_enum.h" +#include "be_visitor_exception.h" +#include "be_visitor_structure.h" +#include "be_visitor_typedef.h" +#include "be_visitor_union.h" + +ACE_RCSID (be_visitor_interface, + interface, + "$Id$") // ****************************************************** // Generic Interface visitor // ****************************************************** be_visitor_interface::be_visitor_interface (be_visitor_context *ctx) - : be_visitor_scope (ctx) + : be_visitor_scope (ctx) { } @@ -39,7 +47,7 @@ be_visitor_interface::~be_visitor_interface (void) { } -// this method must be overridden by the derived interface visitors +// This method must be overridden by the derived interface visitors. int be_visitor_interface::visit_interface (be_interface *) { @@ -55,27 +63,23 @@ be_visitor_interface::is_amh_rh_node (be_interface *node) // and the name starts with AMH if (ACE_OS::strncmp (node->local_name (), "AMH", 3) == 0) { - // then it is an AMH node + // then it is an AMH node. return 1; } } return 0; } -// =all common visit methods for interface visitor +// All common visit methods for interface visitor. -// visit an attribute int be_visitor_interface::visit_attribute (be_attribute *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same + ctx.node (node); - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: @@ -132,19 +136,14 @@ be_visitor_interface::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_INTERFACE_TIE_SI: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_TIE_SI); break; - - case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_BASE_PROXY_IMPL_CH); break; - - case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH: case TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH: case TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_PROXY_IMPL_XH); break; - case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS: ctx.state (TAO_CodeGen::TAO_ATTRIBUTE_REMOTE_PROXY_IMPL_CS); break; @@ -168,7 +167,6 @@ be_visitor_interface::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_SH: case TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_SS: case TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CS: - case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH: case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CS: case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_SH: @@ -179,8 +177,6 @@ be_visitor_interface::visit_attribute (be_attribute *node) case TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CS: case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SH: case TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SS: - - case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: @@ -194,55 +190,51 @@ be_visitor_interface::visit_attribute (be_attribute *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_attribute - " - "Bad context state\n: " ), + "Bad context state\n: "), -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_attribute - " - "NUL visitor\n" - ), -1); - } + // Same visitor for all the above cases where an action is taken. + be_visitor_attribute visitor (&ctx); - // let the node accept this visitor - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_attribute - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - delete visitor; + return 0; } -// visit a constant int be_visitor_interface::visit_constant (be_constant *node) { - // instantiate a visitor context with a copy of our context. This info + // Instantiate a visitor context with a copy of our context. This info // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); + be_visitor_constant_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); + be_visitor_constant_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: @@ -266,7 +258,6 @@ be_visitor_interface::visit_constant (be_constant *node) case TAO_CodeGen::TAO_INTERFACE_SS: case TAO_CodeGen::TAO_INTERFACE_TIE_SH: case TAO_CodeGen::TAO_INTERFACE_TIE_SI: - case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH: case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CS: case TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_SH: @@ -292,78 +283,85 @@ be_visitor_interface::visit_constant (be_constant *node) case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return 0; // nothing to be done + return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_constant - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_constant - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -//visit an enum int be_visitor_interface::visit_enum (be_enum *node) { - // instantiate a visitor context with a copy of our context. This info + // Instantiate a visitor context with a copy of our context. This info // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: case TAO_CodeGen::TAO_INTERFACE_CI: case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: @@ -420,26 +418,15 @@ be_visitor_interface::visit_enum (be_enum *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_enum - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } @@ -447,41 +434,70 @@ be_visitor_interface::visit_enum (be_enum *node) int be_visitor_interface::visit_exception (be_exception *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); + be_visitor_exception_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); + be_visitor_exception_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); + be_visitor_exception_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); + be_visitor_exception_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); + be_visitor_exception_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); + be_visitor_exception_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); + be_visitor_exception_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); + be_visitor_exception_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: case TAO_CodeGen::TAO_INTERFACE_IS: @@ -525,7 +541,7 @@ be_visitor_interface::visit_exception (be_exception *node) case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return 0; // nothing to be done + return 0; // nothing to be done default: { @@ -537,26 +553,15 @@ be_visitor_interface::visit_exception (be_exception *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_exception - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_exception - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } @@ -565,14 +570,10 @@ int be_visitor_interface::visit_operation (be_operation *node) { - // instantiate a visitor context with a copy of our context. This info + // Instantiate a visitor context with a copy of our context. This info // will be modified ased on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); switch (this->ctx_->state ()) { @@ -677,30 +678,31 @@ be_visitor_interface::visit_operation (be_operation *node) } } - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state ())); // grab the appropriate visitor be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_operation - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // visit the node using this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_operation - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; @@ -709,29 +711,30 @@ be_visitor_interface::visit_operation (be_operation *node) // the node. if (node->has_extra_code_generation (ctx.state ())) { - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state (), 1)); - // grab the appropriate visitor + // Grab the appropriate visitor. visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_operation - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // visit the node using this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_operation - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } @@ -739,45 +742,73 @@ be_visitor_interface::visit_operation (be_operation *node) return 0; } -// Visit an structure. int be_visitor_interface::visit_structure (be_structure *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: case TAO_CodeGen::TAO_INTERFACE_IS: @@ -827,73 +858,90 @@ be_visitor_interface::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_structure - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_structure - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_structure - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit a union int be_visitor_interface::visit_union (be_union *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: case TAO_CodeGen::TAO_INTERFACE_IS: @@ -937,79 +985,96 @@ be_visitor_interface::visit_union (be_union *node) case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return 0; // nothing to be done + return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_union - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_union - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_union - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit a typedef int be_visitor_interface::visit_typedef (be_typedef *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_INTERFACE_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); + be_visitor_typedef_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); + be_visitor_typedef_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); + be_visitor_typedef_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); + be_visitor_typedef_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); + be_visitor_typedef_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); + be_visitor_typedef_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); + be_visitor_typedef_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); + be_visitor_typedef_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_INTERFACE_SH: case TAO_CodeGen::TAO_INTERFACE_IH: case TAO_CodeGen::TAO_INTERFACE_IS: @@ -1053,37 +1118,26 @@ be_visitor_interface::visit_typedef (be_typedef *node) case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SH: case TAO_CodeGen::TAO_INTERFACE_AMH_RH_SS: - return 0; // nothing to be done + return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_typedef - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_typedef - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp index 1bc260d140d..d1011060a97 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ch.cpp @@ -18,11 +18,11 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" +#include "be_visitor_typecode/typecode_decl.h" ACE_RCSID(be_visitor_interface, interface_ch, "$Id$") @@ -297,11 +297,10 @@ be_visitor_interface_ch::visit_interface (be_interface *node) // Interceptor related classes. ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_interceptors_ch interceptor_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&interceptor_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -309,9 +308,6 @@ be_visitor_interface_ch::visit_interface (be_interface *node) -1); } - delete visitor; - visitor = 0; - ctx = *this->ctx_; *os << be_uidt_nl; @@ -322,11 +318,10 @@ be_visitor_interface_ch::visit_interface (be_interface *node) { // Smart Proxy related classes. ctx.state (TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_smart_proxy_ch sp_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&sp_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -334,21 +329,13 @@ be_visitor_interface_ch::visit_interface (be_interface *node) -1); } - delete visitor; - visitor = 0; - } - - if (!node->is_local ()) - { // Proxy Implementation Declaration. - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_PROXY_IMPLS_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_proxy_impls_ch spi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&spi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -356,39 +343,29 @@ be_visitor_interface_ch::visit_interface (be_interface *node) -1); } - delete visitor; - } - - if (!node->is_local ()) - { // Proxy Broker Declaration. - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_PROXY_BROKERS_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_proxy_brokers_ch pb_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&pb_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " "codegen for Proxy Broker classes failed\n"), -1); } - - delete visitor; } os->gen_endif (); - if (!node->is_local ()) + if (be_global->tc_support ()) { - visitor = 0; ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_typecode_decl td_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&td_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_ch::" diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp index 57786ac89e7..a93def0789f 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_cs.cpp @@ -18,13 +18,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" +#include "be_visitor_typecode/typecode_defn.h" -ACE_RCSID(be_visitor_interface, interface_cs, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_cs, + "$Id$") // ************************************************************ @@ -62,6 +64,9 @@ be_visitor_interface_cs::visit_interface (be_interface *node) TAO_OutStream *os = this->ctx_->stream (); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // Initialize the static narrrowing helper variable. *os << "int " << node->full_name () << "::_tao_class_id = 0;" << be_nl << be_nl; @@ -141,7 +146,6 @@ be_visitor_interface_cs::visit_interface (be_interface *node) -1); } - be_visitor *visitor = 0; be_visitor_context ctx; // Interceptor classes. The interceptors helper classes must be @@ -149,14 +153,12 @@ be_visitor_interface_cs::visit_interface (be_interface *node) // the implementation of said operations. ctx = (*this->ctx_); - visitor = 0; ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_interceptors_cs ii_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&ii_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "visit_interface - " @@ -164,18 +166,14 @@ be_visitor_interface_cs::visit_interface (be_interface *node) -1); } - delete visitor; - visitor = 0; - if (!node->is_local ()) { ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_remote_proxy_impl_cs irpi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&irpi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "visit_interface - " @@ -183,24 +181,18 @@ be_visitor_interface_cs::visit_interface (be_interface *node) -1); } - delete visitor; - - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_remote_proxy_broker_cs irpb_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&irpb_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "visit_interface - " "codegen for Base Proxy Broker class failed\n"), -1); } - - delete visitor; } // Generate the destructor and default constructor. @@ -534,9 +526,9 @@ be_visitor_interface_cs::visit_interface (be_interface *node) be_visitor *visitor = 0; ctx.state (TAO_CodeGen::TAO_INTERFACE_SMART_PROXY_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_smart_proxy_cs isp_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&isp_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" @@ -544,18 +536,15 @@ be_visitor_interface_cs::visit_interface (be_interface *node) "codegen for smart proxy classes failed\n"), -1); } + } - delete visitor; - visitor = 0; - - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO + if (be_global->tc_support ()) + { ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_typecode_defn tc_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&tc_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_cs::" @@ -563,8 +552,6 @@ be_visitor_interface_cs::visit_interface (be_interface *node) "TypeCode definition failed\n"), -1); } - - delete visitor; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp index d1b29aa441b..7b82220171b 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ih.cpp @@ -16,16 +16,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" -ACE_RCSID(be_visitor_interface, interface_ih, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_ih, + "$Id$") // ************************************************************ -// Interface visitor for implementation header +// Interface visitor for implementation header. // ************************************************************ be_visitor_interface_ih::be_visitor_interface_ih (be_visitor_context *ctx) @@ -40,30 +41,34 @@ be_visitor_interface_ih::~be_visitor_interface_ih (void) int be_visitor_interface_ih::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream - static char namebuf [NAMEBUFSIZE]; // holds the class name + TAO_OutStream *os = this->ctx_->stream (); + static char namebuf [NAMEBUFSIZE]; if (node->impl_hdr_gen () || node->imported ()) - return 0; - - ACE_OS::memset (namebuf, '\0', NAMEBUFSIZE); + { + return 0; + } - os = this->ctx_->stream (); + ACE_OS::memset (namebuf, + '\0', + NAMEBUFSIZE); - // generate the skeleton class name + // Generate the skeleton class name. - os->indent (); // start with whatever indentation level we are at + os->indent (); ACE_OS::sprintf (namebuf, "%s", node->flat_name ()); *os << "//Class " << be_global->impl_class_prefix () << namebuf << be_global->impl_class_suffix () << be_nl; - // now generate the class definition + + // Now generate the class definition. *os << "class " << be_global->stub_export_macro () << " " << be_global->impl_class_prefix () << namebuf << be_global->impl_class_suffix () << " : "; - //inherit from the base skeleton file + + // Inherit from the base skeleton file. *os <<"public virtual "<< node->full_skel_name (); *os << be_nl @@ -97,7 +102,7 @@ be_visitor_interface_ih::visit_interface (be_interface *node) << be_global->impl_class_suffix () << " (void);" << be_nl << be_uidt_nl; - // generate code for elements in the scope (e.g., operations) + // Generate code for elements in the scope (e.g., operations). if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -107,31 +112,15 @@ be_visitor_interface_ih::visit_interface (be_interface *node) -1); } - /* - if (node->n_inherits () > 0) - { - // this interface inherits from other interfaces - be_interface *intf; // inherited interface - - for (i = 0; i < node->n_inherits (); i++) - { - intf = be_interface::narrow_from_decl (node->inherits ()[i]); - // generate code for elements in the scope (e.g., operations) - if (this->visit_scope (intf) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ih::" - "visit_interface - " - "codegen for scope failed\n"), - -1); - } - } - } - */ + // Generate the code for the members of the derived classes. + int status = + node->traverse_inheritance_graph ( + be_visitor_interface_ih::method_helper, + os + ); - //Generate the code for the members of the derived classes - if (node->traverse_inheritance_graph (be_visitor_interface_ih::method_helper, os) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh_ss::" @@ -146,11 +135,11 @@ be_visitor_interface_ih::visit_interface (be_interface *node) } -//Helper method to generate members within the scope of the base classes +// Helper method to generate members within the scope of the base classes. int be_visitor_interface_ih::method_helper (be_interface *derived, - be_interface *node, - TAO_OutStream *os) + be_interface *node, + TAO_OutStream *os) { if (strcmp (derived->flat_name (), node->flat_name ()) != 0) @@ -159,16 +148,15 @@ be_visitor_interface_ih::method_helper (be_interface *derived, ctx.state (TAO_CodeGen::TAO_INTERFACE_IH); ctx.interface (derived); ctx.stream (os); + be_visitor_interface_ih visitor (&ctx); - be_visitor* visitor = tao_cg->make_visitor (&ctx); - if (visitor == 0 || visitor->visit_scope (node) == -1) + if (visitor.visit_scope (node) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_is::" "method_helper\n"), -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_is.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_is.cpp index 243e6bb1e61..fdf98c91504 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_is.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_is.cpp @@ -16,18 +16,19 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" // ************************************************************ -// Interface visitor for implementation skeletons +// Interface visitor for implementation skeletons. // ************************************************************ -ACE_RCSID(be_visitor_interface, interface_is, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_is, + "$Id$") be_visitor_interface_is::be_visitor_interface_is (be_visitor_context *ctx) : be_visitor_interface (ctx) @@ -44,22 +45,20 @@ be_visitor_interface_is::visit_interface (be_interface *node) this->ctx_->interface (node); - TAO_OutStream *os; // output stream + TAO_OutStream *os = this->ctx_->stream (); if (node->impl_skel_gen () || node->imported ()) - return 0; - - os = this->ctx_->stream (); - - - // generate the skeleton class name + { + return 0; + } - os->indent (); // start with whatever indentation level we are at + // Generate the skeleton class name. + os->indent (); - // constructor *os << "// Implementation skeleton constructor" << be_nl; - // find if we are at the top scope or inside some module + + // Find if we are at the top scope or inside some module. *os << be_global->impl_class_prefix () << node->flat_name () << be_global->impl_class_suffix () <<"::" << be_global->impl_class_prefix () << node->flat_name () @@ -69,7 +68,6 @@ be_visitor_interface_is::visit_interface (be_interface *node) *os << "{" << be_nl << "}" << be_nl << be_uidt_nl; - // destructor os->indent (); *os << "// Implementation skeleton destructor" << be_nl; @@ -82,7 +80,7 @@ be_visitor_interface_is::visit_interface (be_interface *node) *os << "{" <<be_nl; *os << "}" << be_nl <<be_uidt_nl; - if (be_global->gen_copy_ctor () ) + if (be_global->gen_copy_ctor ()) { *os << "//Implementation Skeleton Copy Constructor" << be_nl; @@ -93,11 +91,12 @@ be_visitor_interface_is::visit_interface (be_interface *node) << be_global->impl_class_prefix () << node->flat_name () << be_global->impl_class_suffix () << "& t)"<< be_idt_nl; - if(node->n_inherits () >0) + if (node->n_inherits () > 0) { - node->gen_copy_ctors(os); + node->gen_copy_ctors (os); *os << ", TAO_ServantBase (t)" << be_nl; } + *os << "{" << be_nl << "}" << be_nl << be_uidt_nl; } @@ -117,7 +116,7 @@ be_visitor_interface_is::visit_interface (be_interface *node) << "}" << be_nl << be_uidt_nl; } - // generate code for elements in the scope (e.g., operations) + // Generate code for elements in the scope (e.g., operations). if (this->visit_scope (node) == -1) { @@ -127,27 +126,14 @@ be_visitor_interface_is::visit_interface (be_interface *node) "codegen for scope failed\n"), -1); } - /* - if (node->n_inherits () > 0) - { - // this interface inherits from other interfaces - be_interface *intf; // inherited interface - - for (int i = 0; i < node->n_inherits (); i++) - { - intf = be_interface::narrow_from_decl (node->inherits ()[i]); - // generate code for elements in the scope (e.g., operations) - if (this->visit_scope (intf) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_ih::" - "visit_interface - " - "codegen for scope failed\n"), - -1); - } - } - */ - if (node->traverse_inheritance_graph (be_visitor_interface_is::method_helper, os) == -1) + + int status = + node->traverse_inheritance_graph ( + be_visitor_interface_is::method_helper, + os + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh_ss::" @@ -156,34 +142,35 @@ be_visitor_interface_is::visit_interface (be_interface *node) -1); } - return 0; } -//Helper method to generate the members in the scope of the base classes +// Helper method to generate the members in the scope of the base classes. int be_visitor_interface_is::method_helper (be_interface *derived, - be_interface *node, - TAO_OutStream *os) + be_interface *node, + TAO_OutStream *os) { - if (strcmp (derived->flat_name (), node->flat_name ()) != 0) + if (ACE_OS::strcmp (derived->flat_name (), node->flat_name ()) != 0) { be_visitor_context ctx; ctx.state (TAO_CodeGen::TAO_INTERFACE_IS); ctx.interface (derived); ctx.stream (os); + be_visitor_interface_is visitor (&ctx); + + if (visitor.visit_scope (node) == -1) - be_visitor* visitor = tao_cg->make_visitor (&ctx); - if (visitor == 0 || visitor->visit_scope (node) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_is::" - "method_helper\n"), -1); + "method_helper\n"), + -1); } - delete visitor; + } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp index bbb32209225..b54806bcef5 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_sh.cpp @@ -18,17 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" -ACE_RCSID(be_visitor_interface, interface_sh, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_sh, + "$Id$") // ************************************************************ -// Interface visitor for server header +// Interface visitor for server header. // ************************************************************ be_visitor_interface_sh::be_visitor_interface_sh (be_visitor_context *ctx) @@ -44,29 +45,35 @@ int be_visitor_interface_sh::visit_interface (be_interface *node) { if (node->srv_hdr_gen () || node->imported ()) - return 0; + { + return 0; + } // If this node is a AMH-RH node, then generate code for it if (node->is_local ()) { if (this->is_amh_rh_node (node)) { - // Create amh_rh_visitors + // Create amh_rh_visitors. be_visitor_amh_rh_interface_sh amh_rh_intf (this->ctx_); amh_rh_intf.visit_interface (node); } - return 0; + + return 0; } if (this->generate_amh_classes (node) == -1) - return -1; - - TAO_OutStream *os = this->ctx_->stream (); // output stream - - ACE_CString class_name; // holds the class name + { + return -1; + } + TAO_OutStream *os = this->ctx_->stream (); + ACE_CString class_name; os->indent (); + *os << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // We shall have a POA_ prefix only if we are at the topmost level. if (!node->is_nested ()) { @@ -204,7 +211,13 @@ be_visitor_interface_sh::visit_interface (be_interface *node) // Generate skeletons for operations of our base classes. These // skeletons just cast the pointer to the appropriate type // before invoking the call. - if (node->traverse_inheritance_graph (be_interface::gen_skel_helper, os) == -1) + int status = + node->traverse_inheritance_graph ( + be_interface::gen_skel_helper, + os + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_sh::" @@ -216,14 +229,12 @@ be_visitor_interface_sh::visit_interface (be_interface *node) // Generate the embedded RequestInfo classes per operation. // This is to be used by interceptors. be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = 0; // Interceptor related classes. ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_interceptors_sh ii_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&ii_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -231,29 +242,27 @@ be_visitor_interface_sh::visit_interface (be_interface *node) -1); } - delete visitor; - visitor = 0; - *os << be_uidt_nl << "};\n\n"; - if (be_global->gen_thru_poa_collocation () || - be_global->gen_direct_collocation ()) + if (be_global->gen_thru_poa_collocation () + || be_global->gen_direct_collocation ()) { ctx = *this->ctx_; // Generate strategized proxy broker. ctx.state (TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SH); - visitor = tao_cg->make_visitor (&ctx); - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" - "visit_interface - " - "codegen for thru_poa_collocated class failed\n"), - -1); - } - - delete visitor; + be_visitor_interface_strategized_proxy_broker_sh ispb_visitor (&ctx); + + if (node->accept (&ispb_visitor) == -1) + { + ACE_ERROR_RETURN (( + LM_ERROR, + "be_visitor_interface_sh::" + "visit_interface - " + "codegen for thru_poa_collocated class failed\n" + ), + -1 + ); + } } ctx = *this->ctx_; @@ -261,44 +270,39 @@ be_visitor_interface_sh::visit_interface (be_interface *node) // Generate the collocated class. if (be_global->gen_thru_poa_collocation ()) { - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_thru_poa_proxy_impl_sh itppi_visitor (&ctx); - if (visitor == 0 || node->accept (visitor) == -1) + if (node->accept (&itppi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_sh::" "visit_interface - " "codegen for thru_poa_collocated class failed\n"), -1); } - - delete visitor; } ctx = *this->ctx_; if (be_global->gen_direct_collocation ()) { - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_direct_proxy_impl_sh idpi_visitor (&ctx); - if (visitor == 0 || node->accept (visitor) == -1) + if (node->accept (&idpi_visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_interface_sh::" - "visit_interface - " - "codegen for thru_poa_collocated class failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "be_visitor_interface_sh::" + "visit_interface - " + "codegen for thru_poa_collocated class failed\n" + ), + -1 + ); } - - delete visitor; } *os << "\n"; @@ -325,5 +329,6 @@ be_visitor_interface_sh::generate_amh_classes (be_interface *node) be_visitor_amh_interface_sh amh_intf (this->ctx_); return amh_intf.visit_interface (node); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_si.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_si.cpp index 7ac5571926c..000c39ce2ce 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_si.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_si.cpp @@ -18,13 +18,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" -ACE_RCSID(be_visitor_interface, interface_si, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_si, + "$Id$") // ************************************************************************ @@ -43,16 +44,19 @@ be_visitor_interface_si::~be_visitor_interface_si (void) int be_visitor_interface_si::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream - if (node->srv_inline_gen () || node->imported () || node->is_local ()) - return 0; + { + return 0; + } + + TAO_OutStream *os = this->ctx_->stream (); - os = this->ctx_->stream (); + // Determine if we are in some form of a multiple inheritance. + int status = + node->traverse_inheritance_graph (be_interface::in_mult_inheritance_helper, + 0); - // determine if we are in some form of a multiple inheritance - if (node->traverse_inheritance_graph - (be_interface::in_mult_inheritance_helper, 0) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_si::visit_interface " @@ -62,9 +66,10 @@ be_visitor_interface_si::visit_interface (be_interface *node) // Generate skeletons for operations of our base classes. These skeletons // just cast the pointer to the appropriate type before invoking the - // call. Hence we generate these in the inline file - if (node->traverse_inheritance_graph (be_interface::gen_skel_helper, os) - == -1) + // call. Hence we generate these in the inline file. + status = node->traverse_inheritance_graph (be_interface::gen_skel_helper, + os); + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface_si::" @@ -74,15 +79,14 @@ be_visitor_interface_si::visit_interface (be_interface *node) if (be_global->gen_tie_classes ()) { - // generate the TIE class + // Generate the TIE class. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SI); ctx.stream (tao_cg->server_template_inline ()); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_tie_si visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_sh::" "visit_interface - " diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp index 8686a4bf0ac..f1ae6c99cea 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp @@ -18,18 +18,19 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" #include "ace/SString.h" -ACE_RCSID(be_visitor_interface, interface_ss, "$Id$") +ACE_RCSID (be_visitor_interface, + interface_ss, + "$Id$") // ************************************************************ -// Interface visitor for server skeletons +// Interface visitor for server skeletons. // ************************************************************ be_visitor_interface_ss::be_visitor_interface_ss (be_visitor_context *ctx) @@ -53,7 +54,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) { if (this->is_amh_rh_node (node)) { - // Create amh_rh_visitors + // Create amh_rh_visitors. be_visitor_amh_rh_interface_ss amh_rh_ss_intf (this->ctx_); amh_rh_ss_intf.visit_interface (node); } @@ -62,20 +63,24 @@ be_visitor_interface_ss::visit_interface (be_interface *node) } if (this->generate_amh_classes (node) == -1) - return -1; + { + return -1; + } - // Generate the normal skeleton as usual + // Generate the normal skeleton as usual. TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start with whatever indentation level we are at + os->indent (); ACE_CString full_skel_name_holder = this->generate_full_skel_name (node); + const char *full_skel_name = full_skel_name_holder.c_str (); ACE_CString flat_name_holder = this->generate_flat_name (node); + const char *flat_name = flat_name_holder.c_str (); if (node->gen_operation_table (flat_name, full_skel_name) == -1) @@ -103,6 +108,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) // pre-compute the prefix that must be added to the local name in // each case. const char *local_name_prefix = ""; + if (!node->is_nested ()) { local_name_prefix = "POA_"; @@ -110,6 +116,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) ACE_CString node_local_name_holder = this->generate_local_name (node); + const char *node_local_name = node_local_name_holder.c_str (); *os << full_skel_name << "::" @@ -149,7 +156,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) *os << "{" << be_nl; *os << "}\n\n"; - // generate code for elements in the scope (e.g., operations) + // Generate code for elements in the scope (e.g., operations). if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -228,9 +235,14 @@ be_visitor_interface_ss::visit_interface (be_interface *node) << be_idt_nl; if (be_global->use_raw_throw ()) - *os << "throw CORBA::MARSHAL ();" << be_uidt << be_uidt_nl; + { + *os << "throw CORBA::MARSHAL ();" << be_uidt << be_uidt_nl; + } else - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt << be_uidt_nl; + { + *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt << be_uidt_nl; + } + *os << "}\n\n"; // Generate code for the _interface skeleton. @@ -283,6 +295,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) // Generate code for the _is_a override. os->indent (); + *os << "CORBA::Boolean " << full_skel_name << "::_is_a (" << be_idt << be_idt_nl << "const char* value" << be_nl @@ -302,6 +315,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) } os->indent (); + *os << "(!ACE_OS::strcmp ((char *)value, base_id)))" << be_idt_nl << "return 1;" << be_uidt_nl << "else" << be_idt_nl @@ -339,7 +353,7 @@ be_visitor_interface_ss::visit_interface (be_interface *node) *os << "return \"" << node->repoID () << "\";" << be_uidt_nl; *os << "}" << be_nl << be_nl; - // Print out dispatch method + // Print out dispatch method. this->dispatch_method (node); *os << be_nl; @@ -357,7 +371,7 @@ be_visitor_interface_ss::this_method (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - // the _this () operation + // the _this () operation. *os << node->full_name () << "*" << be_nl << node->full_skel_name () << "::_this (ACE_ENV_SINGLE_ARG_DECL)" << be_nl @@ -393,7 +407,6 @@ be_visitor_interface_ss::dispatch_method (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - // now the dispatch method *os << "void " << node->full_skel_name () << "::_dispatch (" << be_idt << be_idt_nl << "TAO_ServerRequest &req," << be_nl @@ -417,6 +430,7 @@ be_visitor_interface_ss::generate_amh_classes (be_interface *node) be_visitor_amh_interface_ss amh_intf (this->ctx_); return amh_intf.visit_interface (node); } + return 0; } @@ -425,15 +439,14 @@ be_visitor_interface_ss::generate_proxy_classes (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - // Strategized Proxy Broker Implementation + // Strategized Proxy Broker Implementation. be_visitor_context ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_INTERCEPTORS_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_interceptors_ss ii_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&ii_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "generate_proxy_classes - " @@ -441,19 +454,15 @@ be_visitor_interface_ss::generate_proxy_classes (be_interface *node) -1); } - delete visitor; - visitor = 0; - if (be_global->gen_thru_poa_collocation () || be_global->gen_direct_collocation ()) { ctx = (*this->ctx_); ctx.state (TAO_CodeGen::TAO_INTERFACE_STRATEGIZED_PROXY_BROKER_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_strategized_proxy_broker_ss ispb_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&ispb_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "generate_proxy_classes - " @@ -461,8 +470,6 @@ be_visitor_interface_ss::generate_proxy_classes (be_interface *node) -1); } - delete visitor; - // Proxy Broker Factory Function. *os << be_nl << node->full_base_proxy_broker_name () << " *" << be_nl @@ -513,42 +520,34 @@ be_visitor_interface_ss::generate_proxy_classes (be_interface *node) // Proxy Impl Implementations. if (be_global->gen_thru_poa_collocation ()) { - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_THRU_POA_PROXY_IMPL_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_thru_poa_proxy_impl_ss itppi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&itppi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "generate_proxy_classes - " "codegen for Base Proxy Broker class failed\n"), -1); } - - delete visitor; } if (be_global->gen_direct_collocation ()) { - visitor = 0; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_DIRECT_PROXY_IMPL_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_direct_proxy_impl_ss idpi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&idpi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_cs::" "generate_proxy_classes - " "codegen for Base Proxy Broker class failed\n"), -1); } - - delete visitor; } os->decr_indent (0); diff --git a/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp index 357e932f3af..db1c6aaa9ac 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/proxy_brokers_ch.cpp @@ -1,19 +1,28 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" -ACE_RCSID (be_visitor_interface, proxy_brokers_ch, "$Id$") +ACE_RCSID (be_visitor_interface, + proxy_brokers_ch, + "$Id$") - be_visitor_interface_proxy_brokers_ch::be_visitor_interface_proxy_brokers_ch (be_visitor_context *ctx) - : be_visitor_interface (ctx) +be_visitor_interface_proxy_brokers_ch::be_visitor_interface_proxy_brokers_ch ( + be_visitor_context *ctx + ) + : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_proxy_brokers_ch::~be_visitor_interface_proxy_brokers_ch (void) +be_visitor_interface_proxy_brokers_ch::~be_visitor_interface_proxy_brokers_ch ( + void + ) { // No-Op. } @@ -35,11 +44,10 @@ be_visitor_interface_proxy_brokers_ch::visit_interface (be_interface *node) be_visitor *visitor = 0; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_BROKER_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_base_proxy_broker_ch bpb_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&bpb_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -47,15 +55,12 @@ be_visitor_interface_proxy_brokers_ch::visit_interface (be_interface *node) -1); } - delete visitor; - ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_BROKER_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_remote_proxy_broker_ch rpb_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&rpb_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -63,7 +68,5 @@ be_visitor_interface_proxy_brokers_ch::visit_interface (be_interface *node) -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp b/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp index cca6a5e8a65..6229e7c04dc 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/proxy_impls_ch.cpp @@ -1,19 +1,28 @@ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +// +// $Id$ +// +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" -ACE_RCSID (be_visitor_interface, base_proxy_broker_impl_ch, "$Id$") +ACE_RCSID (be_visitor_interface, + base_proxy_broker_impl_ch, + "$Id$") -be_visitor_interface_proxy_impls_ch::be_visitor_interface_proxy_impls_ch (be_visitor_context *ctx) +be_visitor_interface_proxy_impls_ch::be_visitor_interface_proxy_impls_ch ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { // No-Op. } -be_visitor_interface_proxy_impls_ch::~be_visitor_interface_proxy_impls_ch (void) +be_visitor_interface_proxy_impls_ch::~be_visitor_interface_proxy_impls_ch ( + void + ) { // No-Op. } @@ -34,11 +43,10 @@ be_visitor_interface_proxy_impls_ch::visit_interface (be_interface *node) be_visitor *visitor = 0; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_INTERFACE_BASE_PROXY_IMPL_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_base_proxy_impl_ch bpi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&bpi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -46,15 +54,12 @@ be_visitor_interface_proxy_impls_ch::visit_interface (be_interface *node) -1); } - delete visitor; - ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_INTERFACE_REMOTE_PROXY_IMPL_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_remote_proxy_impl_ch rpi_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&rpi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_ch::" "visit_interface - " @@ -62,7 +67,5 @@ be_visitor_interface_proxy_impls_ch::visit_interface (be_interface *node) -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/tie_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/tie_sh.cpp index d8ecbb5d5a6..b7270105156 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/tie_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/tie_sh.cpp @@ -19,20 +19,23 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" -ACE_RCSID(be_visitor_interface, tie_sh, "$Id$") +ACE_RCSID (be_visitor_interface, + tie_sh, + "$Id$") // ************************************************************ -// Interface visitor for server header +// Interface visitor for server header. // ************************************************************ -be_visitor_interface_tie_sh::be_visitor_interface_tie_sh (be_visitor_context *ctx) +be_visitor_interface_tie_sh::be_visitor_interface_tie_sh ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -88,6 +91,9 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node) // Now generate the class definition. os->indent (); + *os << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl << be_nl; + *os << "// TIE class: Refer to CORBA v2.2, Section 20.34.4" << be_nl; *os << "template <class T>" << be_nl; *os << "class " << be_global->skel_export_macro () @@ -121,10 +127,13 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node) << "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl << ");" << be_uidt << "\n"; - if (node->traverse_inheritance_graph ( - be_visitor_interface_tie_sh::method_helper, - os - ) == -1) + int status = + node->traverse_inheritance_graph ( + be_visitor_interface_tie_sh::method_helper, + os + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh_ss::" @@ -134,6 +143,7 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node) } os->decr_indent (1); + *os << "private:" << be_idt_nl << "T *ptr_;" << be_nl << "PortableServer::POA_var poa_;" << be_nl @@ -148,23 +158,21 @@ be_visitor_interface_tie_sh::visit_interface (be_interface *node) int be_visitor_interface_tie_sh::method_helper (be_interface *, - be_interface *node, - TAO_OutStream *os) + be_interface *node, + TAO_OutStream *os) { be_visitor_context ctx; ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SH); - ctx.stream (os); - be_visitor* visitor = tao_cg->make_visitor (&ctx); + be_visitor_interface_tie_sh visitor (&ctx); - if (visitor == 0 || visitor->visit_scope (node) == -1) + if (visitor.visit_scope (node) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh::" - "method_helper\n"), -1); + "method_helper\n"), + -1); } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp b/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp index 7a42da46f21..9b8ae77ca5e 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/tie_si.cpp @@ -19,20 +19,23 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_interface.h" -ACE_RCSID(be_visitor_interface, tie_si, "$Id$") +ACE_RCSID (be_visitor_interface, + tie_si, + "$Id$") // ************************************************************************ // Interface visitor for server inline // ************************************************************************ -be_visitor_interface_tie_si::be_visitor_interface_tie_si (be_visitor_context *ctx) +be_visitor_interface_tie_si::be_visitor_interface_tie_si ( + be_visitor_context *ctx + ) : be_visitor_interface (ctx) { } @@ -44,37 +47,52 @@ be_visitor_interface_tie_si::~be_visitor_interface_tie_si (void) int be_visitor_interface_tie_si::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream - static char fulltiename [NAMEBUFSIZE]; // holds the class name - static char localtiename [NAMEBUFSIZE]; // holds the tie name - static char localskelname [NAMEBUFSIZE]; // holds the local skeleton name + TAO_OutStream *os; + static char fulltiename [NAMEBUFSIZE]; + static char localtiename [NAMEBUFSIZE]; + static char localskelname [NAMEBUFSIZE]; if (node->srv_inline_gen () || node->imported ()) - return 0; + { + return 0; + } - ACE_OS::memset (fulltiename, '\0', NAMEBUFSIZE); - ACE_OS::memset (localtiename, '\0', NAMEBUFSIZE); - ACE_OS::memset (localskelname, '\0', NAMEBUFSIZE); + ACE_OS::memset (fulltiename, + '\0', + NAMEBUFSIZE); + ACE_OS::memset (localtiename, + '\0', + NAMEBUFSIZE); + ACE_OS::memset (localskelname, + '\0', + NAMEBUFSIZE); os = this->ctx_->stream (); - // generate the skeleton class name which will be used to determine the TIE - // class name + // Generate the skeleton class name which will be used to determine the TIE + // class name. + + // We are outermost. + ACE_OS::sprintf (fulltiename, + "%s_tie", + node->full_skel_name ()); - // we are outermost - ACE_OS::sprintf (fulltiename, "%s_tie", node->full_skel_name ()); if (!node->is_nested ()) { - ACE_OS::sprintf (localskelname, "POA_%s", + ACE_OS::sprintf (localskelname, + "POA_%s", node->local_name ()); - ACE_OS::sprintf (localtiename, "POA_%s_tie", + ACE_OS::sprintf (localtiename, + "POA_%s_tie", node->local_name ()); } else { - ACE_OS::sprintf (localskelname, "%s", + ACE_OS::sprintf (localskelname, + "%s", node->local_name ()); - ACE_OS::sprintf (localtiename, "%s_tie", + ACE_OS::sprintf (localtiename, + "%s_tie", node->local_name ()); } @@ -83,7 +101,10 @@ be_visitor_interface_tie_si::visit_interface (be_interface *node) *os << "#if defined (ACE_HAS_USING_KEYWORD)\n\n"; } - os->indent (); // start with whatever indentation level we are at + os->indent (); + + *os << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl << be_nl; *os << "template <class T> ACE_INLINE" << be_nl << fulltiename << "<T>::" << localtiename << " (T &t)" << be_nl @@ -170,7 +191,13 @@ be_visitor_interface_tie_si::visit_interface (be_interface *node) << "::_default_POA (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "}\n\n"; - if (node->traverse_inheritance_graph (be_visitor_interface_tie_si::method_helper, os) == -1) + int status = + node->traverse_inheritance_graph ( + be_visitor_interface_tie_si::method_helper, + os + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh_ss::" @@ -196,15 +223,16 @@ be_visitor_interface_tie_si::method_helper (be_interface *derived, ctx.state (TAO_CodeGen::TAO_INTERFACE_TIE_SI); ctx.interface (derived); ctx.stream (os); + be_visitor_interface_tie_si visitor (&ctx); + + if (visitor.visit_scope (node) == -1) - be_visitor* visitor = tao_cg->make_visitor (&ctx); - if (visitor == 0 || visitor->visit_scope (node) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "be_visitor_interface_tie_sh::" - "method_helper\n"), -1); + "method_helper\n"), + -1); } - delete visitor; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_module/module.cpp b/TAO/TAO_IDL/be/be_visitor_module/module.cpp index d57c95b1ace..4290e432108 100644 --- a/TAO/TAO_IDL/be/be_visitor_module/module.cpp +++ b/TAO/TAO_IDL/be/be_visitor_module/module.cpp @@ -18,13 +18,22 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_module.h" +#include "be_visitor_constant.h" +#include "be_visitor_enum.h" +#include "be_visitor_exception.h" +#include "be_visitor_interface_fwd.h" +#include "be_visitor_structure.h" +#include "be_visitor_typedef.h" +#include "be_visitor_union.h" +#include "be_visitor_valuetype_fwd.h" -ACE_RCSID(be_visitor_module, module, "$Id$") +ACE_RCSID (be_visitor_module, + module, + "$Id$") // ****************************************************** @@ -40,7 +49,6 @@ be_visitor_module::~be_visitor_module (void) { } -// visit the Module node and its scope int be_visitor_module::visit_module (be_module *node) { if (node->nmembers () == 0) @@ -49,7 +57,6 @@ int be_visitor_module::visit_module (be_module *node) node); } - // all we have to do is to visit the scope if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -60,30 +67,33 @@ int be_visitor_module::visit_module (be_module *node) return 0; } -// =all common visit methods for module visitor +// All common visit methods for module visitor. -// visit a constant int be_visitor_module::visit_constant (be_constant *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); + be_visitor_constant_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); + be_visitor_constant_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: @@ -101,70 +111,77 @@ be_visitor_module::visit_constant (be_constant *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_constant - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_constant - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -//visit an enum int be_visitor_module::visit_enum (be_enum *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; case TAO_CodeGen::TAO_MODULE_CI: case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_IH: @@ -177,73 +194,90 @@ be_visitor_module::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_enum - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_enum - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an exception int be_visitor_module::visit_exception (be_exception *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); + be_visitor_exception_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); + be_visitor_exception_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); + be_visitor_exception_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); + be_visitor_exception_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); + be_visitor_exception_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); + be_visitor_exception_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); + be_visitor_exception_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); + be_visitor_exception_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_IH: case TAO_CodeGen::TAO_MODULE_SI: @@ -260,30 +294,18 @@ be_visitor_module::visit_exception (be_exception *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_exception - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_exception - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an interface int be_visitor_module::visit_interface (be_interface *node) { @@ -351,24 +373,25 @@ be_visitor_module::visit_interface (be_interface *node) ctx.state (node->next_state (ctx.state ())); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; @@ -377,28 +400,29 @@ be_visitor_module::visit_interface (be_interface *node) // the node. if (node->has_extra_code_generation (ctx.state ())) { - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state (), 1)); visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } @@ -406,39 +430,53 @@ be_visitor_module::visit_interface (be_interface *node) return 0; } -// visit an interface_fwd int be_visitor_module::visit_interface_fwd (be_interface_fwd *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); + be_visitor_interface_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); + be_visitor_interface_fwd_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); + be_visitor_interface_fwd_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_ANY_OP_CH); + be_visitor_interface_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CH); + be_visitor_interface_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: case TAO_CodeGen::TAO_MODULE_CS: case TAO_CodeGen::TAO_MODULE_SH: @@ -452,46 +490,30 @@ be_visitor_module::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface_fwd - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_interface_fwd - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_interface_fwd - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an valuetype int be_visitor_module::visit_valuetype (be_valuetype *node) { - // instantiate a visitor context with a copy of our context. This info + // Instantiate a visitor context with a copy of our context. This info // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); switch (this->ctx_->state ()) { @@ -524,67 +546,69 @@ be_visitor_module::visit_valuetype (be_valuetype *node) case TAO_CodeGen::TAO_MODULE_SI: case TAO_CodeGen::TAO_MODULE_SS: case TAO_CodeGen::TAO_MODULE_IS: - return 0; // nothing to do, resp. not yet impl. + return 0; // nothing to do. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state ())); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor + // Let the node accept this visitor. if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; - // Do addtional "extra" code generation if necessary + // Do addtional "extra" code generation if necessary. if (node->has_extra_code_generation (ctx.state ())) { - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state (), 1)); - visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor + // Let the node accept this visitor. if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } @@ -592,33 +616,45 @@ be_visitor_module::visit_valuetype (be_valuetype *node) return 0; } -// visit a valuetype_fwd int be_visitor_module::visit_valuetype_fwd (be_valuetype_fwd *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CH); + be_visitor_valuetype_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CI); + be_visitor_valuetype_fwd_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CH); + be_visitor_valuetype_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CI); + be_visitor_valuetype_fwd_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: @@ -634,73 +670,90 @@ be_visitor_module::visit_valuetype_fwd (be_valuetype_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype_fwd - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_valuetype_fwd - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_valuetype_fwd - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an structure int be_visitor_module::visit_structure (be_structure *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_IH: case TAO_CodeGen::TAO_MODULE_SI: @@ -712,73 +765,90 @@ be_visitor_module::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_structure - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_structure - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_structure - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an union int be_visitor_module::visit_union (be_union *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_IH: case TAO_CodeGen::TAO_MODULE_SI: @@ -790,73 +860,90 @@ be_visitor_module::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_union - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_union - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_union - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit a typedef int be_visitor_module::visit_typedef (be_typedef *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_MODULE_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); + be_visitor_typedef_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); + be_visitor_typedef_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); + be_visitor_typedef_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); + be_visitor_typedef_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); + be_visitor_typedef_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); + be_visitor_typedef_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); + be_visitor_typedef_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); + be_visitor_typedef_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_MODULE_SH: case TAO_CodeGen::TAO_MODULE_SI: case TAO_CodeGen::TAO_MODULE_SS: @@ -868,30 +955,19 @@ be_visitor_module::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_typedef - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_module::" "visit_typedef - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_module::" - "visit_typedef - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation.cpp index ef9ba2b885c..5f5e9121204 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation.cpp @@ -71,7 +71,6 @@ #include "be_visitor_operation/interceptors_result.cpp" #include "be_visitor_operation/base_proxy_impl_ch.cpp" #include "be_visitor_operation/proxy_impl_xh.cpp" -#include "be_visitor_operation/inv_arglist.cpp" #include "be_visitor_operation/remote_proxy_impl_cs.cpp" #include "be_visitor_operation/thru_poa_proxy_impl_ss.cpp" #include "be_visitor_operation/direct_proxy_impl_ss.cpp" @@ -82,4 +81,6 @@ #include "be_visitor_operation/amh_rh_ss.cpp" #include "be_visitor_operation/amh_rh_sh.cpp" -ACE_RCSID(be, be_visitor_operation, "$Id$") +ACE_RCSID (be, + be_visitor_operation, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp index 12cfa035143..c5799ed4af7 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_sh.cpp @@ -19,13 +19,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "ast_decl.h" +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, operation_amh_rh_sh, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_amh_rh_sh, + "$Id$") // ****************************************************** @@ -33,7 +34,9 @@ ACE_RCSID(be_visitor_operation, operation_amh_rh_sh, "$Id$") // in skeleton header. // ****************************************************** -be_visitor_amh_rh_operation_sh::be_visitor_amh_rh_operation_sh (be_visitor_context *ctx) +be_visitor_amh_rh_operation_sh::be_visitor_amh_rh_operation_sh ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -92,29 +95,17 @@ be_visitor_amh_rh_operation_sh::visit_operation (be_operation *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_arglist visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_amh_rh_sh::" "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_amh_rh_sh::" - "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - *os << ";" << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp index 6cd31367597..fcd04df16b8 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_rh_ss.cpp @@ -212,7 +212,7 @@ be_visitor_amh_rh_operation_ss::marshal_params (be_operation *node) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - be_compiled_visitor_operation_argument_invoke visitor (&ctx); + be_visitor_operation_argument_invoke visitor (&ctx); if (node->accept (&visitor) == -1) { diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp index f0e40e41975..3bd283bfd2d 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp @@ -111,7 +111,7 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) if (marshal_visitor.visit_argument (argument) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "visit_operation - " "codegen for demarshal failed\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp index aef71be2e41..31bf0e1d809 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_ch.cpp @@ -19,20 +19,23 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, operation_ami_ch, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_ami_ch, + "$Id$") // ****************************************************** // Visitor for generating AMI stub for "operation" in client header. // ****************************************************** -be_visitor_operation_ami_ch::be_visitor_operation_ami_ch (be_visitor_context *ctx) +be_visitor_operation_ami_ch::be_visitor_operation_ami_ch ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -86,30 +89,16 @@ be_visitor_operation_ami_ch::visit_operation (be_operation *node) // parameter listing. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_arglist visitor (&ctx); - if (!visitor) + if (node->arguments ()->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ami_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->arguments ()->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ami_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - -// *os << be_nl; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp index a8577a4ac25..d4d7a4ff3aa 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_cs.cpp @@ -20,20 +20,23 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, operation_ami_cs, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_ami_cs, + "$Id$") // ************************************************************ // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_ami_cs::be_visitor_operation_ami_cs (be_visitor_context *ctx) +be_visitor_operation_ami_cs::be_visitor_operation_ami_cs ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -49,8 +52,12 @@ be_visitor_operation_ami_cs::post_process (be_decl *bd) { // all we do here is to insert a comma and a newline TAO_OutStream *os = this->ctx_->stream (); + if (!this->last_node (bd)) - *os << ",\n"; + { + *os << ",\n"; + } + return 0; } @@ -59,16 +66,15 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) { // No sendc method for oneway operations. if (node->flags () == AST_Operation::OP_oneway) - return 0; - - TAO_OutStream *os; // output stream - be_visitor_context ctx; // visitor context - be_visitor *visitor; // visitor + { + return 0; + } - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + be_visitor_context ctx; + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - os->indent (); // start with the current indentation level + os->indent (); // Generate the return type mapping. Return type is simply void. *os << "void" << be_nl; @@ -78,25 +84,32 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) // Grab the scope name. be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); + if (parent == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ami_cs::" - "visit_operation - " - "scope name is nil\n"), - -1); + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "visit_operation - " + "scope name is nil\n"), + -1); + } // Generate the scope::operation name. *os << parent->full_name () << "::sendc_"; - // check if we are an attribute node in disguise + // Check if we are an attribute node in disguise. if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "set_"; + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + *os << "set_"; + } else - *os << "get_"; + { + *os << "get_"; + } } *os << node->local_name ()->get_string (); @@ -105,18 +118,16 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if ((!visitor) || (node->arguments ()->accept (visitor) == -1)) + be_visitor_operation_arglist oa_visitor (&ctx); + + if (node->arguments ()->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ami_cs::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - visitor = 0; // Generate the actual code for the stub. However, if any of the argument // types is "native", we flag a MARSHAL exception. @@ -127,11 +138,11 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) be_type *bt = be_type::narrow_from_decl (node->arguments ()->return_type ()); - // generate any pre stub info if and only if none of our parameters is of the - // native type + // Generate any pre stub info if and only if none of our parameters is of the + // native type. if (!node->has_native ()) { - // native type does not exist. + // Native type does not exist. // Generate any "pre" stub information such as tables or declarations // This is a template method and the actual work will be done by the @@ -148,9 +159,11 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) if (node->has_native ()) // native exists => no stub { - if (this->gen_raise_exception (bt, - "CORBA::MARSHAL", - "") == -1) + int status = this->gen_raise_exception (bt, + "CORBA::MARSHAL", + ""); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ami_cs::" @@ -167,7 +180,7 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) << "TAO_Stub *istub = this->_stubobj ();" << be_nl << "if (istub == 0)" << be_idt_nl; - // if the stub object was bad, then we raise a system exception + // If the stub object was bad, then we raise a system exception. if (this->gen_raise_exception (bt, "CORBA::INV_OBJREF", "") == -1) { @@ -201,16 +214,16 @@ be_visitor_operation_ami_cs::visit_operation (be_operation *node) return 0; } +// This method is used to generate the ParamData table entry. int be_visitor_operation_ami_cs::visit_argument (be_argument *node) { - // this method is used to generate the ParamData table entry - TAO_OutStream *os = this->ctx_->stream (); be_type *bt; // argument type - // retrieve the type for this argument + // Retrieve the type for this argument. bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -222,6 +235,7 @@ be_visitor_operation_ami_cs::visit_argument (be_argument *node) os->indent (); *os << "{" << bt->tc_name () << ", "; + switch (node->direction ()) { case AST_Argument::dir_IN: @@ -234,64 +248,15 @@ be_visitor_operation_ami_cs::visit_argument (be_argument *node) *os << "PARAM_OUT, "; break; } - *os << "0}"; - - return 0; -} - -// ************************************************************ -// Operation visitor for interpretive client stubs -// ************************************************************ - -be_interpretive_visitor_operation_ami_cs:: -be_interpretive_visitor_operation_ami_cs (be_visitor_context *ctx) - : be_visitor_operation_ami_cs (ctx) -{ -} - -be_interpretive_visitor_operation_ami_cs::~be_interpretive_visitor_operation_ami_cs (void) -{ -} - -// concrete implementation of the template methods -int -be_interpretive_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, - be_type *bt) -{ - ACE_UNUSED_ARG (node); - ACE_UNUSED_ARG (bt); - return 0; -} + *os << "0}"; -int -be_interpretive_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node, - be_type *bt) -{ - ACE_UNUSED_ARG (node); - ACE_UNUSED_ARG (bt); return 0; } -// ************************************************************ -// Operation visitor for compiled client stubs -// ************************************************************ - -be_compiled_visitor_operation_ami_cs:: -be_compiled_visitor_operation_ami_cs (be_visitor_context *ctx) - : be_visitor_operation_ami_cs (ctx) -{ -} - -be_compiled_visitor_operation_ami_cs::~be_compiled_visitor_operation_ami_cs (void) -{ -} - -// concrete implementation of the template methods - int -be_compiled_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, - be_type *bt) +be_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, + be_type *bt) { // Nothing to be done here, we do not through any exceptions, // besides system exceptions, so we do not need an user exception table. @@ -302,11 +267,10 @@ be_compiled_visitor_operation_ami_cs::gen_pre_stub_info (be_operation *node, } int -be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node, - be_type *bt) +be_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node, + be_type *bt) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; be_visitor_context ctx; os->indent (); @@ -321,20 +285,24 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node default: *os << "TAO_GIOP_Twoway_Asynch_Invocation _tao_call "; } + *os << "(" << be_idt << be_idt_nl << "istub," << be_nl; - *os << "\""; size_t ext = 0; if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "_set_"; + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + *os << "_set_"; + } else - *os << "_get_"; + { + *os << "_get_"; + } ext += 5; } @@ -369,11 +337,15 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "set_"; + // Now check if we are a "get" or "set" operation + if (node->nmembers () == 1) + { + *os << "set_"; + } else - *os << "get_"; + { + *os << "get_"; + } } *os << node->local_name () << "_reply_stub," << be_nl; @@ -429,34 +401,43 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->marshaling ()->accept (visitor) == -1)) + be_visitor_operation_argument_invoke visitor (&ctx); + + if (node->marshaling ()->accept (&visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_cs::" - "gen_marshal_and_invoke - " - "codegen for return var in do_static_call failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_ami_cs::" + "gen_marshal_and_invoke - " + "codegen for return var in do_static_call failed\n" + ), + -1 + ); } + *os << be_uidt << be_uidt_nl << "))" << be_nl; // If marshaling fails, raise exception. - if (this->gen_raise_exception (bt, "CORBA::MARSHAL", - "") == -1) + int status = this->gen_raise_exception (bt, + "CORBA::MARSHAL", + ""); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "(%N:%l) be_visitor_operation_ami_cs::" "gen_marshal_and invoke - " "codegen for return var failed\n"), -1); } + *os << be_uidt; } *os << be_nl - << "int _invoke_status = _tao_call.invoke (ACE_ENV_SINGLE_ARG_PARAMETER);"; + << "int _invoke_status =" << be_idt_nl + << "_tao_call.invoke (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt; *os << be_uidt_nl; @@ -464,7 +445,7 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node if (this->gen_check_exception (bt) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "(%N:%l) be_visitor_operation_ami_cs::" "gen_marshal_and_invoke - " "codegen for checking exception failed\n"), -1); @@ -479,12 +460,15 @@ be_compiled_visitor_operation_ami_cs::gen_marshal_and_invoke (be_operation *node << "if (_invoke_status != TAO_INVOKE_OK)" << be_nl << "{" << be_idt_nl; - if (this->gen_raise_exception (bt, - "CORBA::UNKNOWN", - "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES") == -1) + int status = + this->gen_raise_exception (bt, + "CORBA::UNKNOWN", + "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES"); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_cs::" + "(%N:%l) be_visitor_operation_ami_cs::" "gen_marshal_and invoke - " "codegen for return var failed\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_cs.cpp index 1220c388552..71597734ad0 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_handler_reply_stub_operation_cs.cpp @@ -18,77 +18,92 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, ami_handler_reply_stub_operation_cs, "$Id$") +ACE_RCSID (be_visitor_operation, + ami_handler_reply_stub_operation_cs, + "$Id$") // ************************************************************ -// Operation visitor for client stubs +// Operation visitor for client stubs. // ************************************************************ -be_visitor_operation_ami_handler_reply_stub_operation_cs::be_visitor_operation_ami_handler_reply_stub_operation_cs (be_visitor_context *ctx) +be_visitor_operation_ami_handler_reply_stub_operation_cs:: +be_visitor_operation_ami_handler_reply_stub_operation_cs (be_visitor_context *ctx) : be_visitor_operation (ctx) { } -be_visitor_operation_ami_handler_reply_stub_operation_cs::~be_visitor_operation_ami_handler_reply_stub_operation_cs (void) +be_visitor_operation_ami_handler_reply_stub_operation_cs:: +~be_visitor_operation_ami_handler_reply_stub_operation_cs (void) { } -// processing to be done after every element in the scope is processed +// Processing to be done after every element in the scope is processed int be_visitor_operation_ami_handler_reply_stub_operation_cs::post_process (be_decl *bd) { - // all we do here is to insert a comma and a newline + // All we do here is to insert a comma and a newline. TAO_OutStream *os = this->ctx_->stream (); + if (!this->last_node (bd)) - *os << ",\n"; + { + *os << ",\n"; + } + return 0; } int -be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation (be_operation *node) +be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - be_type *bt; // type node - be_visitor_context ctx; // visitor context - be_visitor *visitor = 0; // visitor + be_type *bt; + be_visitor_context ctx; - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - // Init the return type variable. + // Initialize the return type variable. bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_ami_handler_reply_stub_operation_cs::" - "visit_operation - " - "Bad return type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_ami_handler_reply_stub_operation_cs::" + "visit_operation - " + "Bad return type\n" + ), + -1 + ); } // Start with the current indentation level. os->indent (); - // Generate the return type. Return type is simply void. *os << be_nl << "void" << be_nl; // Get the scope name. - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + if (!parent) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" - "visit_operation - " - "node information not sufficient :-<\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" + "visit_operation - " + "node information not sufficient :-<\n" + ), + -1 + ); } // Genereate scope name. @@ -96,15 +111,21 @@ be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation (be_op // Generate the operation name. *os << "::"; + // Check if we are an attribute node in disguise if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "_set_"; + // Now check if we are a "get" or "set" operation + if (node->nmembers () == 1) + { + *os << "_set_"; + } else - *os << "_get_"; + { + *os << "_get_"; + } } + *os << node->local_name () << "_reply_stub (" << be_idt_nl; // Generate the argument list. @@ -160,18 +181,16 @@ be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation (be_op // declare variables for arguments ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument oad_visitor (&ctx); + + if (node->accept (&oad_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) ami_handler_reply_stub_operation_cs::" "visit_operation - " "codegen for return var decl failed\n"), -1); } - delete visitor; - visitor = 0; // Demarshal parameters if (this->gen_marshal_and_invoke (node, bt) == -1) @@ -272,23 +291,28 @@ be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_operation (be_op return 0; } +// This method is used to generate the ParamData table entry. int -be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_argument (be_argument *node) +be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_argument ( + be_argument *node + ) { - // this method is used to generate the ParamData table entry - TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; // argument type + be_type *bt; - // retrieve the type for this argument + // Retrieve the type for this argument. bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" - "visit_argument - " - "Bad argument type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" + "visit_argument - " + "Bad argument type\n" + ), + -1 + ); } os->indent (); @@ -310,27 +334,12 @@ be_visitor_operation_ami_handler_reply_stub_operation_cs::visit_argument (be_arg return 0; } -// ************************************************************ -// Operation visitor for compiled client skeletons of the AMI reply handler -// ************************************************************ - -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs (be_visitor_context *ctx) - : be_visitor_operation_ami_handler_reply_stub_operation_cs (ctx) -{ -} - -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::~be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs (void) -{ -} - -// concrete implementation of the template methods - int -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::gen_pre_stub_info (be_operation *node, - be_type *bt) +be_visitor_operation_ami_handler_reply_stub_operation_cs::gen_pre_stub_info ( + be_operation *node, + be_type * + ) { - ACE_UNUSED_ARG (bt); // Check if this operation raises any exceptions. In that case, we must // generate a list of exception typecodes. This is not valid for // attributes @@ -338,37 +347,38 @@ be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::gen_pre_stub_ { be_visitor_context ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_exceptlist_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) " - "be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::" - "gen_pre_stub_info - " - "Exceptionlist generation error\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) " + "be_visitor_operation_ami_handler_reply_stub_operation_cs::" + "gen_pre_stub_info - " + "Exceptionlist generation error\n" + ), + -1 + ); } - delete visitor; } return 0; } int -be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: - gen_marshal_and_invoke (be_operation *node, - be_type *bt) +be_visitor_operation_ami_handler_reply_stub_operation_cs::gen_marshal_and_invoke ( + be_operation *node, + be_type * + ) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor = 0; be_visitor_context ctx; - ACE_UNUSED_ARG (bt); - os->indent (); *os << "// Demarshall all the arguments." << be_nl; + if (this->has_param_type (node, AST_Argument::dir_IN)) { *os << "if (!(\n" << be_idt << be_idt << be_idt; @@ -377,24 +387,28 @@ be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS); ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument_marshal visitor (&ctx); + + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs::" + "(%N:%l) be_visitor_operation_ami_handler_reply_stub_operation_cs::" "gen_marshal_params - " "codegen for args failed\n"), -1); } - delete visitor; *os << be_uidt << be_uidt_nl << " ))" << be_nl; + if (be_global->use_raw_throw ()) - *os << "throw CORBA::MARSHAL ();" << be_uidt_nl << be_nl; + { + *os << "throw CORBA::MARSHAL ();" << be_uidt_nl << be_nl; + } else - *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl << be_nl; + { + *os << "ACE_THROW (CORBA::MARSHAL ());" << be_uidt_nl << be_nl; + } } @@ -402,14 +416,18 @@ be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: *os << "// Invoke the call back method." << be_nl << "_tao_reply_handler_object->"; - // check if we are an attribute node in disguise + // Check if we are an attribute node in disguise. if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "set_"; + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + *os << "set_"; + } else - *os << "get_"; + { + *os << "get_"; + } } *os << node->local_name () << " (" << be_idt << be_idt_nl; @@ -417,24 +435,18 @@ be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS); - // generate the argument list containing the inout and inout arguments - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument oau_visitor (&ctx); + + if (node->accept (&oau_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) ami_handler_reply_stub_operation_cs::" "visit_operation - " "codegen for making upcall failed\n"), -1); } - delete visitor; - visitor = 0; - -// os->indent (); *os << be_uidt_nl << ");" << be_uidt_nl; - *os << "ACE_CHECK;" << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp index 79fe13e262c..85fbb834eaf 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/argument.cpp @@ -18,23 +18,24 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, argument, "$Id$") +ACE_RCSID (be_visitor_operation, + argument, + "$Id$") // ************************************************************ -// generic operation visitor to handle the pre/post -// do_static_call/upcall stuff with arguments +// Generic operation visitor to handle the pre/post +// do_static_call/upcall stuff with arguments. // ************************************************************ -be_visitor_operation_argument:: -be_visitor_operation_argument (be_visitor_context - *ctx) +be_visitor_operation_argument::be_visitor_operation_argument ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -48,8 +49,7 @@ be_visitor_operation_argument::post_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); - - // if we are not the last parameter, we insert a comma. This is only + // If we are not the last parameter, we insert a comma. This is only // applicable for the upcalls or the call to (de)marshal that we use in the // interpreted marshaling. switch (this->ctx_->state ()) @@ -62,10 +62,12 @@ be_visitor_operation_argument::post_process (be_decl *bd) { *os << "," << be_nl; } + break; default: break; } + return 0; } @@ -74,7 +76,7 @@ be_visitor_operation_argument::visit_operation (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - // all we do is hand over code generation to our scope + // All we do is hand over code generation to our scope. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -84,22 +86,27 @@ be_visitor_operation_argument::visit_operation (be_operation *node) -1); } - // if we are supporting the alternate mapping, we must pass the - // ACE_ENV_ARG_PARAMETER as the last parameter + // If we are supporting the alternate mapping, we must pass the + // ACE_ENV_ARG_PARAMETER as the last parameter. if (!be_global->exception_support ()) { switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS: - // applicable only to these cases where the actual upcall is made + // Applicable only to these cases where the actual upcall is made. // Use ACE_ENV_SINGLE_ARG_DECL or ACE_ENV_ARG_DECL depending on // whether the operation node has parameters. if (node->argument_count () > 0) - *os << " ACE_ENV_ARG_PARAMETER"; + { + *os << " ACE_ENV_ARG_PARAMETER"; + } else - *os << "ACE_ENV_SINGLE_ARG_PARAMETER"; + { + *os << "ACE_ENV_SINGLE_ARG_PARAMETER"; + } + break; default: break; @@ -112,7 +119,7 @@ be_visitor_operation_argument::visit_operation (be_operation *node) int be_visitor_operation_argument::visit_argument (be_argument *node) { - // get the visitor that will dump the argument's mapping in the operation + // Get the visitor that will dump the argument's mapping in the operation // signature. be_visitor_context ctx (*this->ctx_); @@ -121,6 +128,7 @@ be_visitor_operation_argument::visit_argument (be_argument *node) // inside the scope of the interface node. In such cases, we would like to // generate the appropriate relative scoped names. be_operation *op = this->ctx_->be_scope_as_operation (); + if (!op) { ACE_ERROR_RETURN ((LM_ERROR, @@ -132,7 +140,7 @@ be_visitor_operation_argument::visit_argument (be_argument *node) // We need the interface node in which this operation was defined. However, // if this operation node was an attribute node in disguise, we get this - // information from the context + // information from the context. be_interface *intf; intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) @@ -146,34 +154,68 @@ be_visitor_operation_argument::visit_argument (be_argument *node) "Bad interface\n"), -1); } - ctx.scope (intf); // set new scope + + ctx.scope (intf); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_PRE_INVOKE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_PRE_INVOKE_CS); + be_visitor_args_pre_invoke_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INVOKE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INVOKE_CS); + be_visitor_args_invoke_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_POST_INVOKE_CS); + be_visitor_args_post_invoke_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_VARDECL_SS); + be_visitor_args_vardecl_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_DEMARSHAL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_DEMARSHAL_SS); + be_visitor_args_marshal_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_MARSHAL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_MARSHAL_SS); + be_visitor_args_marshal_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_COLLOCATED_UPCALL_SS); + be_visitor_args_upcall_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); + be_visitor_args_upcall_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -184,26 +226,15 @@ be_visitor_operation_argument::visit_argument (be_argument *node) } } - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_argument::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_argument::" "visit_argument - " "codegen for argument failed\n"), -1); } - delete visitor; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument_invoke.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument_invoke.cpp index cb4d38bb115..40b4c35b9c4 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument_invoke.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/argument_invoke.cpp @@ -33,21 +33,23 @@ ACE_RCSID(be_visitor_operation, argument_invoke, "$Id$") // operation visitor to handle the passing of arguments to the CDR operators // ************************************************************ -be_compiled_visitor_operation_argument_invoke:: -be_compiled_visitor_operation_argument_invoke (be_visitor_context - *ctx) +be_visitor_operation_argument_invoke::be_visitor_operation_argument_invoke ( + be_visitor_context + *ctx + ) : be_visitor_operation_argument (ctx), - last_arg_printed_ (be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) + last_arg_printed_ (be_visitor_operation_argument_invoke::TAO_ARG_NONE) { } -be_compiled_visitor_operation_argument_invoke:: -~be_compiled_visitor_operation_argument_invoke (void) +be_visitor_operation_argument_invoke::~be_visitor_operation_argument_invoke ( + void + ) { } int -be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) +be_visitor_operation_argument_invoke::pre_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); @@ -57,7 +59,7 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad argument node\n"), -1); @@ -69,7 +71,7 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) + be_visitor_operation_argument_invoke::TAO_ARG_NONE) *os << " &&\n"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) @@ -81,13 +83,13 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) + be_visitor_operation_argument_invoke::TAO_ARG_NONE) *os << " &&\n"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) + be_visitor_operation_argument_invoke::TAO_ARG_NONE) *os << " &&\n"; } break; @@ -99,7 +101,7 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_invoke::TAO_ARG_NONE) + be_visitor_operation_argument_invoke::TAO_ARG_NONE) *os << " &&\n"; } break; @@ -109,7 +111,7 @@ be_compiled_visitor_operation_argument_invoke::pre_process (be_decl *bd) } int -be_compiled_visitor_operation_argument_invoke::post_process (be_decl *bd) +be_visitor_operation_argument_invoke::post_process (be_decl *bd) { be_argument *arg = be_argument::narrow_from_decl (bd); @@ -117,7 +119,7 @@ be_compiled_visitor_operation_argument_invoke::post_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad argument node\n"), -1); @@ -130,12 +132,12 @@ be_compiled_visitor_operation_argument_invoke::post_process (be_decl *bd) case AST_Argument::dir_IN: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_invoke::TAO_ARG_IN; + be_visitor_operation_argument_invoke::TAO_ARG_IN; break; case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_invoke::TAO_ARG_INOUT; + be_visitor_operation_argument_invoke::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // these arguments don't get printed for the << operator on the stub @@ -151,19 +153,19 @@ be_compiled_visitor_operation_argument_invoke::post_process (be_decl *bd) case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_invoke::TAO_ARG_INOUT; + be_visitor_operation_argument_invoke::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_invoke::TAO_ARG_OUT; + be_visitor_operation_argument_invoke::TAO_ARG_OUT; break; } break; default: ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad sub state\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp b/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp index 756964eacbd..4c3e9ae195c 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/argument_marshal.cpp @@ -33,21 +33,23 @@ ACE_RCSID(be_visitor_operation, argument_marshal, "$Id$") // operation visitor to handle the passing of arguments to the CDR operators // ************************************************************ -be_compiled_visitor_operation_argument_marshal:: -be_compiled_visitor_operation_argument_marshal (be_visitor_context - *ctx) +be_visitor_operation_argument_marshal::be_visitor_operation_argument_marshal ( + be_visitor_context + *ctx + ) : be_visitor_operation_argument (ctx), - last_arg_printed_ (be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + last_arg_printed_ (be_visitor_operation_argument_marshal::TAO_ARG_NONE) { } -be_compiled_visitor_operation_argument_marshal:: -~be_compiled_visitor_operation_argument_marshal (void) +be_visitor_operation_argument_marshal::~be_visitor_operation_argument_marshal ( + void + ) { } int -be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) +be_visitor_operation_argument_marshal::pre_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); @@ -57,7 +59,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_marshal" + "be_visitor_operation_argument_marshal" "::post_process - " "Bad argument node\n"), -1); @@ -68,7 +70,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) @@ -80,13 +82,13 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_INPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } break; @@ -98,7 +100,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) else if (this->ctx_->sub_state () == TAO_CodeGen::TAO_CDR_OUTPUT) { if (this->last_arg_printed_ != - be_compiled_visitor_operation_argument_marshal::TAO_ARG_NONE) + be_visitor_operation_argument_marshal::TAO_ARG_NONE) *os << " &&\n"; } break; @@ -108,7 +110,7 @@ be_compiled_visitor_operation_argument_marshal::pre_process (be_decl *bd) } int -be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) +be_visitor_operation_argument_marshal::post_process (be_decl *bd) { be_argument *arg = be_argument::narrow_from_decl (bd); @@ -116,7 +118,7 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_marshal" + "be_visitor_operation_argument_marshal" "::post_process - " "Bad argument node\n"), -1); @@ -129,12 +131,12 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) case AST_Argument::dir_IN: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_IN; + be_visitor_operation_argument_marshal::TAO_ARG_IN; break; case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_INOUT; + be_visitor_operation_argument_marshal::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // these arguments don't get printed for the << operator on the stub @@ -150,19 +152,19 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) case AST_Argument::dir_INOUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_INOUT; + be_visitor_operation_argument_marshal::TAO_ARG_INOUT; break; case AST_Argument::dir_OUT: // only these arguments get printed this->last_arg_printed_ = - be_compiled_visitor_operation_argument_marshal::TAO_ARG_OUT; + be_visitor_operation_argument_marshal::TAO_ARG_OUT; break; } break; default: ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_marshal" + "be_visitor_operation_argument_marshal" "::post_process - " "Bad sub state\n"), -1); @@ -172,19 +174,19 @@ be_compiled_visitor_operation_argument_marshal::post_process (be_decl *bd) // **************************************************************** -be_visitor_compiled_args_decl::be_visitor_compiled_args_decl (be_visitor_context *ctx) +be_visitor_args_decl::be_visitor_args_decl (be_visitor_context *ctx) : be_visitor_scope (ctx) { } int -be_visitor_compiled_args_decl::visit_operation (be_operation *node) +be_visitor_args_decl::visit_operation (be_operation *node) { return this->visit_scope (node); } int -be_visitor_compiled_args_decl::visit_argument (be_argument *node) +be_visitor_args_decl::visit_argument (be_argument *node) { this->ctx_->node (node); // save the argument node @@ -196,7 +198,7 @@ be_visitor_compiled_args_decl::visit_argument (be_argument *node) // visit array int -be_visitor_compiled_args_decl::visit_array (be_array *node) +be_visitor_args_decl::visit_array (be_array *node) { TAO_OutStream *os = this->ctx_->stream (); @@ -205,7 +207,7 @@ be_visitor_compiled_args_decl::visit_array (be_array *node) if (f == 0) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_compiled_args_decl::" + "(%N:%l) be_visitor_args_decl::" "visit_array - " "cannot retrieve argument node\n" ), -1); @@ -255,7 +257,7 @@ be_visitor_compiled_args_decl::visit_array (be_array *node) // visit typedef type int -be_visitor_compiled_args_decl::visit_typedef (be_typedef *node) +be_visitor_args_decl::visit_typedef (be_typedef *node) { this->ctx_->alias (node); @@ -264,7 +266,7 @@ be_visitor_compiled_args_decl::visit_typedef (be_typedef *node) if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_compiled_args_decl::" + "(%N:%l) be_visitor_args_decl::" "visit_typedef - " "Bad primitive type\n" ), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp index 5cf6a728d1b..bc13f93457b 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/base_proxy_impl_ch.cpp @@ -1,15 +1,17 @@ // $Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, x_proxy_impl_xh, "$Id$") +ACE_RCSID (be_visitor_operation, + x_proxy_impl_xh, + "$Id$") -be_visitor_operation_base_proxy_impl_ch::be_visitor_operation_base_proxy_impl_ch (be_visitor_context *ctx) +be_visitor_operation_base_proxy_impl_ch:: +be_visitor_operation_base_proxy_impl_ch (be_visitor_context *ctx) : be_visitor_scope (ctx) { } @@ -20,19 +22,13 @@ be_visitor_operation_base_proxy_impl_ch::~be_visitor_operation_base_proxy_impl_c int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node - -// os->indent (); // start with the current indentation level + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - // every operation is declared virtual in the client code *os << "virtual "; - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { @@ -43,23 +39,12 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " @@ -67,8 +52,6 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node -1); } - delete visitor; - // STEP 2: generate the operation name *os << " " << node->local_name (); @@ -76,20 +59,10 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_BASE_PROXY_IMPL_CH); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oabpi_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oabpi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " @@ -97,7 +70,5 @@ int be_visitor_operation_base_proxy_impl_ch::visit_operation (be_operation *node -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/direct_collocated_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/direct_collocated_sh.cpp index 19c9b14417e..191a54fd26c 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/direct_collocated_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/direct_collocated_sh.cpp @@ -18,46 +18,46 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, direct_collocated_sh, "$Id$") +ACE_RCSID (be_visitor_operation, + direct_collocated_sh, + "$Id$") // ************************************************************************* -// be_visitor_operation_direct_collocated_sh -- // This visitor generates code for the direct_collocated operation signature in a -// server header file +// server header file. // ************************************************************************* -be_visitor_operation_direct_collocated_sh::be_visitor_operation_direct_collocated_sh -(be_visitor_context *ctx) +be_visitor_operation_direct_collocated_sh:: +be_visitor_operation_direct_collocated_sh (be_visitor_context *ctx) : be_visitor_scope (ctx) { } -be_visitor_operation_direct_collocated_sh::~be_visitor_operation_direct_collocated_sh (void) +be_visitor_operation_direct_collocated_sh:: +~be_visitor_operation_direct_collocated_sh (void) { } -int be_visitor_operation_direct_collocated_sh::visit_operation (be_operation *node) +int be_visitor_operation_direct_collocated_sh::visit_operation ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - os->indent (); // start with the current indentation level + os->indent (); - // every operation is declared virtual in the client code *os << "virtual "; - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -67,58 +67,36 @@ int be_visitor_operation_direct_collocated_sh::visit_operation (be_operation *no -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; - // STEP 2: generate the operation name + // STEP 2: generate the operation name. *os << " " << node->local_name (); - // STEP 3: generate the argument list with the appropriate mapping. For these - // we grab a visitor that generates the parameter listing + // STEP 3: generate the argument list with the appropriate mapping. For + // these, we grab a visitor that generates the parameter listing. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oac_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oac_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/direct_collocated_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/direct_collocated_ss.cpp index a253d39b1e7..5324bc7090c 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/direct_collocated_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/direct_collocated_ss.cpp @@ -21,37 +21,39 @@ #include "idl.h" #include "idl_extern.h" #include "be.h" - #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, direct_collocated_ss, "$Id$") +ACE_RCSID (be_visitor_operation, + direct_collocated_ss, + "$Id$") // ************************************************************************* -// be_visitor_operation_direct_collocated_ss -- // This visitor generates code for the direct_collocated operation signature in a -// server skeletons file +// server skeletons file. // ************************************************************************* -be_visitor_operation_direct_collocated_ss::be_visitor_operation_direct_collocated_ss -(be_visitor_context *ctx) - : be_visitor_scope (ctx) +be_visitor_operation_direct_collocated_ss:: +be_visitor_operation_direct_collocated_ss(be_visitor_context *ctx) + : be_visitor_operation (ctx) { } -be_visitor_operation_direct_collocated_ss::~be_visitor_operation_direct_collocated_ss (void) +be_visitor_operation_direct_collocated_ss:: +~be_visitor_operation_direct_collocated_ss (void) { } -int be_visitor_operation_direct_collocated_ss::visit_operation (be_operation *node) +int be_visitor_operation_direct_collocated_ss::visit_operation ( + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); // We need the interface node in which this operation was defined. However, // if this operation node was an attribute node in disguise, we get this - // information from the context - be_interface *intf; - intf = this->ctx_->attribute () + // information from the context. + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (node->defined_in ()); @@ -64,8 +66,9 @@ int be_visitor_operation_direct_collocated_ss::visit_operation (be_operation *no -1); } - // retrieve the operation return type + // Retrieve the operation return type. be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -78,27 +81,16 @@ int be_visitor_operation_direct_collocated_ss::visit_operation (be_operation *no // STEP 2: generate the return type mapping (same as in the header file) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_direct_collocated_ss::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_direct_collocated_ss::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; *os << " " << intf->full_coll_name (be_interface::DIRECT) << "::" << node->local_name () << " "; @@ -107,26 +99,16 @@ int be_visitor_operation_direct_collocated_ss::visit_operation (be_operation *no // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_cs::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oao_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oao_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt << "\n"; @@ -138,8 +120,11 @@ int be_visitor_operation_direct_collocated_ss::visit_operation (be_operation *no } *os << "this->servant_"; + if (this->gen_invoke (ctx, node) == -1) - return -1; + { + return -1; + } *os << be_uidt_nl << "}\n\n"; @@ -147,8 +132,10 @@ int be_visitor_operation_direct_collocated_ss::visit_operation (be_operation *no return 0; } -int be_visitor_operation_direct_collocated_ss::gen_invoke (be_visitor_context &ctx, - be_operation *node) +int be_visitor_operation_direct_collocated_ss::gen_invoke ( + be_visitor_context &ctx, + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -157,10 +144,10 @@ int be_visitor_operation_direct_collocated_ss::gen_invoke (be_visitor_context &c ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument ocau_visitor (&ctx); + + if (node->accept (&ocau_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_direct_collocated_ss::" "gen_invoke - " @@ -168,21 +155,9 @@ int be_visitor_operation_direct_collocated_ss::gen_invoke (be_visitor_context &c -1); } - // end the upcall *os << be_uidt_nl << ");\n" << be_uidt; + return 0; } -int -be_visitor_operation_direct_collocated_ss::void_return_type (be_type *bt) -{ - // is the operation return type void? - - if (bt->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (bt)->pt () - == AST_PredefinedType::PT_void)) - return 1; - else - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/direct_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/direct_proxy_impl_ss.cpp index 9b24f4fa611..ab5c8bd8b99 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/direct_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/direct_proxy_impl_ss.cpp @@ -3,32 +3,34 @@ #include "idl.h" #include "idl_extern.h" #include "be.h" - #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, direct_proxy_impl_ss, "$Id$") +ACE_RCSID (be_visitor_operation, + direct_proxy_impl_ss, + "$Id$") -be_visitor_operation_direct_proxy_impl_ss::be_visitor_operation_direct_proxy_impl_ss -(be_visitor_context *ctx) - : be_visitor_scope (ctx) +be_visitor_operation_direct_proxy_impl_ss:: +be_visitor_operation_direct_proxy_impl_ss (be_visitor_context *ctx) + : be_visitor_operation (ctx) { } -be_visitor_operation_direct_proxy_impl_ss::~be_visitor_operation_direct_proxy_impl_ss (void) +be_visitor_operation_direct_proxy_impl_ss:: +~be_visitor_operation_direct_proxy_impl_ss (void) { } - int -be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) +be_visitor_operation_direct_proxy_impl_ss::visit_operation ( + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); // We need the interface node in which this operation was defined. However, // if this operation node was an attribute node in disguise, we get this - // information from the context - be_interface *intf; - intf = this->ctx_->attribute () + // information from the context. + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (node->defined_in ()); @@ -41,8 +43,8 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) -1); } - // retrieve the operation return type be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -51,31 +53,21 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) "Bad return type\n"), -1); } + os->indent (); // STEP 2: generate the return type mapping (same as in the header file) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_direct_collocated_ss::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_direct_collocated_ss::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; *os << " " << intf->full_direct_proxy_impl_name () << "::" << node->local_name () << " "; @@ -84,26 +76,16 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_cs::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oapi_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oapi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt << "\n"; @@ -122,8 +104,11 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) << "\"" << intf->repoID () << "\"" << ")" << be_uidt_nl // idt = 2 << ")"; + if (this->gen_invoke (ctx, node) == -1) - return -1; + { + return -1; + } *os << be_uidt_nl << "}" << be_nl << be_nl; @@ -134,8 +119,10 @@ be_visitor_operation_direct_proxy_impl_ss::visit_operation (be_operation *node) int -be_visitor_operation_direct_proxy_impl_ss::gen_invoke (be_visitor_context &ctx, - be_operation *node) +be_visitor_operation_direct_proxy_impl_ss::gen_invoke ( + be_visitor_context &ctx, + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -144,10 +131,10 @@ be_visitor_operation_direct_proxy_impl_ss::gen_invoke (be_visitor_context &ctx, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument visitor (&ctx); + + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_direct_collocated_ss::" "gen_invoke - " @@ -155,21 +142,9 @@ be_visitor_operation_direct_proxy_impl_ss::gen_invoke (be_visitor_context &ctx, -1); } - // end the upcall *os << be_uidt_nl << ");" << be_uidt << be_uidt << be_uidt_nl; + return 0; } -int -be_visitor_operation_direct_proxy_impl_ss::void_return_type (be_type *bt) -{ - // is the operation return type void? - - if (bt->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (bt)->pt () - == AST_PredefinedType::PT_void)) - return 1; - else - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_arglist.cpp index 27499952058..8070b6abaa9 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_arglist.cpp @@ -18,19 +18,20 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, interceptors_arglist, "$Id$") +ACE_RCSID (be_visitor_operation, + interceptors_arglist, + "$Id$") // ************************************************************ -// operation visitor to generate the argument list. +// Operation visitor to generate the argument list. // We have separated code generation for this from the 4 main -// visitors to avoid code duplication and tight coupling +// visitors to avoid code duplication and tight coupling. // ************************************************************ be_visitor_operation_interceptors_arglist:: @@ -39,16 +40,18 @@ be_visitor_operation_interceptors_arglist (be_visitor_context *ctx) { } -be_visitor_operation_interceptors_arglist::~be_visitor_operation_interceptors_arglist (void) +be_visitor_operation_interceptors_arglist:: +~be_visitor_operation_interceptors_arglist (void) { } int -be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) +be_visitor_operation_interceptors_arglist::visit_operation ( + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); - // all we do is hand over code generation to our scope if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -58,7 +61,6 @@ be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) -1); } - // generate the ACE_ENV_ARG_PARAMETER for the alternative mapping if (!be_global->exception_support ()) { switch (this->ctx_->state ()) @@ -68,7 +70,6 @@ be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_CS: case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST: case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_SS: - // case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_RESULT: break; case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS: case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SS: @@ -79,7 +80,7 @@ be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CS: case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SS: { - // last argument - is always CORBA::Environment + // Last argument - is always CORBA::Environment. *os << " ACE_ENV_ARG_DECL_NOT_USED"; break; } @@ -88,7 +89,7 @@ be_visitor_operation_interceptors_arglist::visit_operation (be_operation *node) { // @@ Do it for all cases i.e arg count > = 0 - // last argument - is always CORBA::Environment + // Last argument - is always CORBA::Environment. *os << " ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl; break; } @@ -116,14 +117,16 @@ be_visitor_operation_interceptors_arglist::pre_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad argument node\n"), -1); } if (arg->direction () == AST_Argument::dir_OUT) - return 0; + { + return 0; + } switch (this->ctx_->state ()) { @@ -191,8 +194,7 @@ be_visitor_operation_interceptors_arglist::visit_argument (be_argument *node) // We need the interface node in which this operation was defined. However, // if this operation node was an attribute node in disguise, we get this // information from the context. - be_interface *intf; - intf = this->ctx_->attribute () + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (op->defined_in ()); @@ -205,43 +207,70 @@ be_visitor_operation_interceptors_arglist::visit_argument (be_argument *node) -1); } - ctx.scope (intf); // set new scope + ctx.scope (intf); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); - break; - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CH); - break; case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); - break; + case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SH: + case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SS: + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); + be_visitor_args_request_info_arglist visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CH: + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CH); + be_visitor_args_request_info_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_CS); + be_visitor_args_request_info_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CS); + be_visitor_args_request_info_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_PARAMLIST); - break; - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_PARAMLIST); + be_visitor_args_paramlist visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SH); - break; - case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_INFO_ARGLIST_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SH); + be_visitor_args_request_info_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_INTERCEPTORS_ARGLIST_SS); + be_visitor_args_request_info_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_UPCALL_SS); + be_visitor_args_upcall_ss visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -252,21 +281,8 @@ be_visitor_operation_interceptors_arglist::visit_argument (be_argument *node) } } - // Grab a visitor. - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interceptors_arglist::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interceptors_arglist::" "visit_argument - " @@ -274,7 +290,6 @@ be_visitor_operation_interceptors_arglist::visit_argument (be_argument *node) -1); } - delete visitor; return 0; } @@ -288,14 +303,16 @@ be_visitor_operation_interceptors_arglist::post_process (be_decl *bd) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_argument_invoke" + "be_visitor_operation_argument_invoke" "::post_process - " "Bad argument node\n"), -1); } if (arg->direction () != AST_Argument::dir_OUT) - return 0; + { + return 0; + } switch (this->ctx_->state ()) { @@ -328,5 +345,6 @@ be_visitor_operation_interceptors_arglist::post_process (be_decl *bd) } } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp index 122e9f3784c..a83becaa1ab 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_cs.cpp @@ -29,7 +29,7 @@ ACE_RCSID (be_visitor_operation, // ****************************************************** -// primary visitor for "operation" in client header +// Primary visitor for "operation" in client header // ****************************************************** be_visitor_operation_interceptors_cs::be_visitor_operation_interceptors_cs ( @@ -51,24 +51,28 @@ be_visitor_operation_interceptors_cs::visit_operation (be_operation *node) TAO_OutStream *os = this->ctx_->stream (); if (this->generate_class_declaration (os, node) == -1) - return -1; + { + return -1; + } if (this->generate_class_definition (os, node) == -1) - return -1; + { + return -1; + } return 0; } int -be_visitor_operation_interceptors_cs:: - generate_class_declaration (TAO_OutStream *os, - be_operation *node) +be_visitor_operation_interceptors_cs::generate_class_declaration ( + TAO_OutStream *os, + be_operation *node + ) { be_type *bt = 0; be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - // Save the node + // Save the node. this->ctx_->node (node); // Generate the ClientRequestInfo object per operation to @@ -153,29 +157,17 @@ be_visitor_operation_interceptors_cs:: // we grab a visitor that generates the parameter listing. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oia_visitor (&ctx); - if (!visitor) + if (node->accept (&oia_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_interceptors_cs::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_interceptors_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - if (be_global->exception_support ()) { *os << be_uidt; @@ -219,11 +211,10 @@ be_visitor_operation_interceptors_cs:: *os << be_nl << "void result ("; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_info_rettype oiir_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&oiir_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -235,7 +226,6 @@ be_visitor_operation_interceptors_cs:: } *os << be_uidt_nl << "private:" << be_idt_nl; - *os << "TAO_ClientRequestInfo_" << node->flat_name (); // We need the interface node in which this operation was defined. However, @@ -341,29 +331,17 @@ be_visitor_operation_interceptors_cs:: // we grab a visitor that generates the parameter listing and // modify it to generate reference members. ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oiia_visitor (&ctx); - if (!visitor) + if (node->accept (&oiia_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_interceptors_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_interceptors_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - // Generate the result data member. // Generate the return type. bt = be_type::narrow_from_decl (node->return_type ()); @@ -383,11 +361,10 @@ be_visitor_operation_interceptors_cs:: { ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_info_rettype toiir_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&toiir_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -408,16 +385,16 @@ be_visitor_operation_interceptors_cs:: } int -be_visitor_operation_interceptors_cs:: - generate_class_definition (TAO_OutStream *os, - be_operation *node) +be_visitor_operation_interceptors_cs::generate_class_definition ( + TAO_OutStream *os, + be_operation *node + ) { // Start with the current indentation level. os->indent (); be_type *bt = 0; be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = tao_cg->make_visitor (&ctx); // Save the node. this->ctx_->node (node); @@ -496,11 +473,10 @@ be_visitor_operation_interceptors_cs:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist toiia_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&toiia_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -508,7 +484,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; os->indent (); *os << be_uidt_nl << ")" << be_uidt_nl; @@ -519,11 +494,10 @@ be_visitor_operation_interceptors_cs:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oiai_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oiai_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -531,8 +505,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; - os->decr_indent (); *os << be_nl << "{}\n\n"; @@ -582,20 +554,21 @@ be_visitor_operation_interceptors_cs:: { *os << "// Generate the argument list on demand." << be_nl << "Dynamic::ParameterList *parameter_list =" << be_idt_nl - << "TAO_RequestInfo_Util::make_parameter_list (ACE_ENV_SINGLE_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_parameter_list " + << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl; size_t parameter_count = this->count_non_out_parameters (node); - if (node->argument_count () == 0 || - parameter_count == 0 || + if (node->argument_count () == 0 + || parameter_count == 0 // Now make sure that we have some in and inout // parameters. Otherwise, there is nothing to be put into // the Dyanmic::Paramlist. - (!(this->has_param_type (node, AST_Argument::dir_IN)) && - !(this->has_param_type (node, AST_Argument::dir_INOUT)))) + || (!(this->has_param_type (node, AST_Argument::dir_IN)) + && !(this->has_param_type (node, AST_Argument::dir_INOUT)))) { *os << "return parameter_list;" << be_uidt_nl; } @@ -621,11 +594,10 @@ be_visitor_operation_interceptors_cs:: // decide this. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oip_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oip_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -633,8 +605,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; - *os << be_nl << "return safe_parameter_list._retn ();"; } @@ -701,7 +671,8 @@ be_visitor_operation_interceptors_cs:: { *os << "// Generate the exception list on demand." << be_nl << "Dynamic::ExceptionList *exception_list =" << be_idt_nl - << "TAO_RequestInfo_Util::make_exception_list (ACE_ENV_SINGLE_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_exception_list " + << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl; @@ -718,11 +689,10 @@ be_visitor_operation_interceptors_cs:: // We change our scope to be able to generate the exceptionlist. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_exceptlist oie_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oie_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -730,8 +700,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; - *os << be_nl << "return safe_exception_list._retn ();"; } @@ -805,7 +773,8 @@ be_visitor_operation_interceptors_cs:: // Return an Any with tk_void TypeCode. *os << "CORBA::Boolean tk_void_any = 1;" << be_nl << "CORBA::Any *result_any =" << be_idt_nl - << "TAO_RequestInfo_Util::make_any (tk_void_any ACE_ENV_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_any " + << "(tk_void_any ACE_ENV_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl @@ -815,7 +784,8 @@ be_visitor_operation_interceptors_cs:: { *os << "CORBA::Boolean tk_void_any = 0;" << be_nl << "CORBA::Any *result_any =" << be_idt_nl - << "TAO_RequestInfo_Util::make_any (tk_void_any ACE_ENV_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_any " + << "(tk_void_any ACE_ENV_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl @@ -825,11 +795,10 @@ be_visitor_operation_interceptors_cs:: // Generate the insertion of result into Any. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_RESULT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_result oir_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&oir_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -837,8 +806,6 @@ be_visitor_operation_interceptors_cs:: -1); } - delete visitor; - *os << "return safe_result_any._retn ();"; } } @@ -867,7 +834,7 @@ be_visitor_operation_interceptors_cs:: if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interceptors_ch::" + "(%N:%l) be_visitor_interceptors_ch::" "visit_operation - " "Bad return type\n"), -1); @@ -882,11 +849,11 @@ be_visitor_operation_interceptors_cs:: *os << "TAO_ClientRequestInfo_"<< node->flat_name (); - // We need the interface node in which this operation was defined. However, - // if this operation node was an attribute node in disguise, we get this - // information from the context and add a "_get"/"_set" to the flat - // name to get around the problem of overloaded methods which are - // generated for attributes. + // We need the interface node in which this operation was defined. + // However, if this operation node was an attribute node in disguise, + // we get this information from the context and add a "_get"/"_set" + // to the flat name to get around the problem of overloaded methods + // which are generated for attributes. if (this->ctx_->attribute ()) { bt = be_type::narrow_from_decl (node->return_type ()); @@ -917,11 +884,10 @@ be_visitor_operation_interceptors_cs:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype or_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -930,6 +896,7 @@ be_visitor_operation_interceptors_cs:: } os->indent (); + *os << " result)" << be_uidt << be_uidt << be_uidt_nl << "{" << be_idt_nl << "// update the result " << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ss.cpp index d651e62e77f..06dffe1deca 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_ss.cpp @@ -51,22 +51,26 @@ be_visitor_operation_interceptors_ss::visit_operation (be_operation *node) TAO_OutStream *os = this->ctx_->stream (); if (this->generate_class_declaration (os, node) == -1) - return -1; + { + return -1; + } if (this->generate_class_definition (os, node) == -1) - return -1; + { + return -1; + } return 0; } int -be_visitor_operation_interceptors_ss:: - generate_class_declaration (TAO_OutStream *os, - be_operation *node) +be_visitor_operation_interceptors_ss::generate_class_declaration ( + TAO_OutStream *os, + be_operation *node + ) { be_type *bt = 0; be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = tao_cg->make_visitor (&ctx); // save the node. this->ctx_->node (node); @@ -129,7 +133,7 @@ be_visitor_operation_interceptors_ss:: -1); } - // grab the right visitor to generate the return type if its not + // Grab the right visitor to generate the return type if its not // void it means it is not the accessor. if (!this->void_return_type (bt)) { @@ -141,7 +145,6 @@ be_visitor_operation_interceptors_ss:: } } - *os << " (" << be_idt_nl << "TAO_ServerRequest &_tao_server_request," << be_nl; @@ -170,33 +173,25 @@ be_visitor_operation_interceptors_ss:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oia_visitor (&ctx); - if (!visitor) + if (node->accept (&oia_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_interceptors_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_interceptors_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - *os << ");\n\n"; os->indent (); - // Here I still need to generate the other methods + private args + + *os << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl; + + // Here I still need to generate the other methods + private args. *os << "virtual Dynamic::ParameterList * arguments (" << be_idt << be_idt_nl << "ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl @@ -252,11 +247,10 @@ be_visitor_operation_interceptors_ss:: *os << "void result ("; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype or_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -268,7 +262,6 @@ be_visitor_operation_interceptors_ss:: } *os << be_uidt_nl << "private:" << be_idt_nl; - *os << "TAO_ServerRequestInfo_" << node->flat_name (); // We need the interface node in which this operation was defined. However, @@ -376,38 +369,24 @@ be_visitor_operation_interceptors_ss:: // Get the right object implementation. *os << intf->full_skel_name () << " *_tao_impl;" << be_nl; - // Need to generate the args as reference memebers... + // Need to generate the args as reference memebers. // generate the member list with the appropriate mapping. For these // we grab a visitor that generates the parameter listing and // modify it to generate reference members. - ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oiia_visitor (&ctx); - if (!visitor) + if (node->accept (&oiia_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_interceptors_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_interceptors_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - // Generate the result data member. // Generate the return type. - bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) @@ -425,11 +404,10 @@ be_visitor_operation_interceptors_ss:: { ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_SH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype tor_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&tor_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -446,13 +424,13 @@ be_visitor_operation_interceptors_ss:: } int -be_visitor_operation_interceptors_ss:: - generate_class_definition (TAO_OutStream *os, - be_operation *node) +be_visitor_operation_interceptors_ss::generate_class_definition ( + TAO_OutStream *os, + be_operation *node + ) { be_type *bt = 0; be_visitor_context ctx (*this->ctx_); - be_visitor *visitor = tao_cg->make_visitor (&ctx); // Save the node. this->ctx_->node (node); @@ -557,11 +535,10 @@ be_visitor_operation_interceptors_ss:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARGLIST_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oia_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oia_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -569,8 +546,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - *os << be_uidt_nl << ")" << be_nl; // Generate the member list and set each member but before that, @@ -581,11 +556,10 @@ be_visitor_operation_interceptors_ss:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_ARG_INFO_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oiai_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oiai_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_args_info_ss::" "visit_argument- " @@ -593,8 +567,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - os->decr_indent (); *os << be_nl << "{}\n\n"; @@ -640,19 +612,21 @@ be_visitor_operation_interceptors_ss:: << "{" << be_idt_nl << "// Generate the argument list on demand." << be_nl << "Dynamic::ParameterList *parameter_list =" << be_idt_nl - << "TAO_RequestInfo_Util::make_parameter_list (ACE_ENV_SINGLE_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_parameter_list " + << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl; size_t parameter_count = this->count_non_out_parameters (node); - if (node->argument_count () == 0 || - parameter_count == 0 || + + if (node->argument_count () == 0 + || parameter_count == 0 // Now make sure that we have some in and inout // parameters. Otherwise, there is nothing to be put into // the Dynamic::Parameterlist. - (!(this->has_param_type (node, AST_Argument::dir_IN)) && - !(this->has_param_type (node, AST_Argument::dir_INOUT)))) + || (!(this->has_param_type (node, AST_Argument::dir_IN)) + &&!(this->has_param_type (node, AST_Argument::dir_INOUT)))) { *os << "return parameter_list;" << be_uidt_nl; } @@ -678,11 +652,10 @@ be_visitor_operation_interceptors_ss:: // decide this. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_PARAMLIST); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oip_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oip_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -690,8 +663,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - *os << be_nl << "return safe_parameter_list._retn ();" << be_uidt_nl; } @@ -745,7 +716,8 @@ be_visitor_operation_interceptors_ss:: { *os << "// Generate the exception list on demand." << be_nl << "Dynamic::ExceptionList *exception_list =" << be_idt_nl - << "TAO_RequestInfo_Util::make_exception_list (ACE_ENV_SINGLE_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_exception_list " + << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl; @@ -762,11 +734,10 @@ be_visitor_operation_interceptors_ss:: // We change our scope to be able to generate the exceptionlist. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_exceptlist oie_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oie_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -774,8 +745,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - *os << be_nl << "return safe_exception_list._retn ();"; } @@ -849,7 +818,8 @@ be_visitor_operation_interceptors_ss:: // Return an Any with tk_void TypeCode. *os << "CORBA::Boolean tk_void_any = 1;" << be_nl << "CORBA::Any *result_any =" << be_idt_nl - << "TAO_RequestInfo_Util::make_any (tk_void_any ACE_ENV_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_any " + << "(tk_void_any ACE_ENV_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl @@ -859,7 +829,8 @@ be_visitor_operation_interceptors_ss:: { *os << "CORBA::Boolean tk_void_any = 0;" << be_nl << "CORBA::Any *result_any =" << be_idt_nl - << "TAO_RequestInfo_Util::make_any (tk_void_any ACE_ENV_ARG_PARAMETER);" + << "TAO_RequestInfo_Util::make_any " + << "(tk_void_any ACE_ENV_ARG_PARAMETER);" << be_uidt_nl << "ACE_CHECK_RETURN (0);" << be_nl << be_nl @@ -869,11 +840,10 @@ be_visitor_operation_interceptors_ss:: // Generate the insertion of result into Any. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_RESULT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_result oir_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&oir_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -881,8 +851,6 @@ be_visitor_operation_interceptors_ss:: -1); } - delete visitor; - *os << be_nl << "return safe_result_any._retn ();"; } @@ -1029,7 +997,7 @@ be_visitor_operation_interceptors_ss:: if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interceptors_ch::" + "(%N:%l) be_visitor_interceptors_ch::" "visit_operation - " "Bad return type\n"), -1); @@ -1052,11 +1020,10 @@ be_visitor_operation_interceptors_ss:: ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype or_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " diff --git a/TAO/TAO_IDL/be/be_visitor_operation/inv_arglist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/inv_arglist.cpp deleted file mode 100644 index 0e7b149472d..00000000000 --- a/TAO/TAO_IDL/be/be_visitor_operation/inv_arglist.cpp +++ /dev/null @@ -1,103 +0,0 @@ -// $Id$ - -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - -#include "be_visitor_operation.h" - -ACE_RCSID(be_visitor_operation, inv_arglist, "$Id$") - - -be_visitor_operation_inv_arglist:: -be_visitor_operation_inv_arglist (be_visitor_context *ctx) - : be_visitor_operation (ctx) -{ -} - -be_visitor_operation_inv_arglist::~be_visitor_operation_inv_arglist (void) -{ -} - -int -be_visitor_operation_inv_arglist::visit_operation (be_operation *node) -{ - // all we do is hand over code generation to our scope - if (this->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_inv_arglist::" - "visit_operation - " - "codegen for scope failed\n"), - -1); - } - - return 0; -} - -int -be_visitor_operation_inv_arglist::visit_argument (be_argument *node) -{ - // get the visitor that will dump the argument's mapping in the operation - // signature. - be_visitor_context ctx (*this->ctx_); - - // first grab the interface definition inside which this operation is - // defined. We need this since argument types may very well be declared - // inside the scope of the interface node. In such cases, we would like to - // generate the appropriate relative scoped names. - be_operation *op = this->ctx_->be_scope_as_operation (); - if (!op) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_inv_arglist::" - "visit_argument - " - "Bad operation\n"), - -1); - } - - // We need the interface node in which this operation was defined. However, - // if this operation node was an attribute node in disguise, we get this - // information from the context - be_interface *intf; - intf = this->ctx_->attribute () - ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) - : be_interface::narrow_from_scope (op->defined_in ()); - - if (!intf) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_inv_arglist::" - "visit_argument - " - "Bad interface\n"), - -1); - } - ctx.scope (intf); // set new scope - - ctx.state (TAO_CodeGen::TAO_ARGUMENT_INVOKE_ARG_LIST); - - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_inv_arglist::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_inv_arglist::" - "visit_argument - " - "codegen for inv_arglist failed\n"), - -1); - } - delete visitor; - return 0; -} - - diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp index 08ef81d3e6a..6d9393db5bb 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ch.cpp @@ -18,17 +18,18 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, operation_ch, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_ch, + "$Id$") // ****************************************************** -// primary visitor for "operation" in client header +// Primary visitor for "operation" in client header. // ****************************************************** be_visitor_operation_ch::be_visitor_operation_ch (be_visitor_context *ctx) @@ -44,7 +45,6 @@ int be_visitor_operation_ch::visit_operation (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; this->ctx_->node (node); @@ -52,7 +52,7 @@ be_visitor_operation_ch::visit_operation (be_operation *node) *os << "virtual "; // STEP I: generate the return type. - bt = be_type::narrow_from_decl (node->return_type ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { @@ -66,20 +66,10 @@ be_visitor_operation_ch::visit_operation (be_operation *node) // Grab the right visitor to generate the return type. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype or_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ch::" "visit_operation - " @@ -87,8 +77,6 @@ be_visitor_operation_ch::visit_operation (be_operation *node) -1); } - delete visitor; - // STEP 2: generate the operation name. *os << " " << node->local_name (); @@ -96,28 +84,16 @@ be_visitor_operation_ch::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_arglist oa_visitor (&ctx); - if (!visitor) + if (node->accept (&oa_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp index 716787d0da4..4bd6682e582 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ih.cpp @@ -16,16 +16,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, operation_ih, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_ih, + "$Id$") // ************************************************************ -// Operation visitor for implementation header +// Operation visitor for implementation header. // ************************************************************ be_visitor_operation_ih::be_visitor_operation_ih (be_visitor_context *ctx) @@ -40,17 +41,14 @@ be_visitor_operation_ih::~be_visitor_operation_ih (void) int be_visitor_operation_ih::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); // save the node // every operation is declared virtual in the client code *os << "virtual "; // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { @@ -64,20 +62,10 @@ be_visitor_operation_ih::visit_operation (be_operation *node) // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ih::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ih::" "visit_operation - " @@ -85,8 +73,6 @@ be_visitor_operation_ih::visit_operation (be_operation *node) -1); } - delete visitor; - // STEP 2: generate the operation name *os << " " << node->local_name (); @@ -94,20 +80,10 @@ be_visitor_operation_ih::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_IH); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ih::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ih::" "visit_operation - " @@ -115,8 +91,6 @@ be_visitor_operation_ih::visit_operation (be_operation *node) -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp index fab89122083..74afad31713 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_is.cpp @@ -16,14 +16,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" -#include "ace/SString.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" +#include "ace/SString.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, operation_is, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_is, + "$Id$") // ************************************************************ // Operation visitor for implementation skeleton @@ -41,25 +42,16 @@ be_visitor_operation_is::~be_visitor_operation_is (void) int be_visitor_operation_is::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - //cout<<"Within visit_operation "<<endl; - os = this->ctx_->stream (); - be_interface *intf = - this->ctx_->interface (); - - + TAO_OutStream *os = this->ctx_->stream (); + be_interface *intf = this->ctx_->interface (); this->ctx_->node (node); // save the node os->indent (); // start with the current indentation level - - - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -69,40 +61,27 @@ be_visitor_operation_is::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_is::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_is::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; const char *classname = 0; if (intf) { - //If derived class + // If derived class/ classname = intf->flat_name (); } - else { ACE_CString str(node->flat_name ()); @@ -112,7 +91,7 @@ be_visitor_operation_is::visit_operation (be_operation *node) int fnmlength = ACE_OS::strlen (node->flat_name ()); fnmlength--; - classname = str.substr (0,(fnmlength-lnmlength) ).rep (); + classname = str.substr (0, (fnmlength-lnmlength)).rep (); } // STEP 2: generate the operation name @@ -123,69 +102,24 @@ be_visitor_operation_is::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_IS); - visitor = tao_cg->make_visitor (&ctx); - + be_visitor_operation_arglist oa_visitor (&ctx); - if (!visitor) + if (node->accept (&oa_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_is::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_is::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - //generate the excetions thrown by the operation - // this->gen_throw_spec (node); + // Generate the exceptions thrown by the operation + // this->gen_throw_spec (node); *os <<be_idt_nl << "{"<<be_idt_nl; *os << "//Add your implementation here"<<be_uidt_nl; - - //Code to generate teh return statement in the operations..... - //Can be uncommented when required - - /* - ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_IS); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_is::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } - - - if (bt->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_is::" - "visit_operation - " - "codegen for return type failed\n"), - -1); - } - delete visitor; - */ - *os << "}" << be_nl << be_uidt_nl; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_sh.cpp index 096fc8a6633..2d93a16b1c5 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_sh.cpp @@ -18,13 +18,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, operation_sh, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_sh, + "$Id$") // ************************************************************ @@ -43,19 +44,16 @@ be_visitor_operation_sh::~be_visitor_operation_sh (void) int be_visitor_operation_sh::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - os->indent (); // start with the current indentation level + os->indent (); - // every operation is declared virtual in the client code *os << "virtual "; - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -65,30 +63,18 @@ be_visitor_operation_sh::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; // STEP 2: generate the operation name *os << " " << node->local_name (); @@ -97,42 +83,38 @@ be_visitor_operation_sh::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_SH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - // generate the corresponding static skeleton method for this operation only + // Generate the corresponding static skeleton method for this operation only // if there was no "native" type. if (!node->has_native ()) { os->indent (); *os << "static void "; - // check if we are an attribute node in disguise + + // Check if we are an attribute node in disguise. if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - *os << "_set_"; + // Now check if we are a "get" or "set" operation + if (node->nmembers () == 1) + { + *os << "_set_"; + } else - *os << "_get_"; + { + *os << "_get_"; + } } + *os << node->local_name () << "_skel (" << be_idt << be_idt_nl << "TAO_ServerRequest &_tao_req," << be_nl diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp index af39de154e1..a0f71048bda 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp @@ -18,10 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" #include "be_visitor_argument.h" @@ -42,7 +41,7 @@ be_visitor_operation_ss::be_visitor_operation_ss (be_visitor_context *ctx) be_visitor_operation_ss::~be_visitor_operation_ss (void) { - delete[] this->operation_name_; + delete [] this->operation_name_; } // Processing to be done after every element in the scope is processed. @@ -91,8 +90,7 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // We need the interface node in which this operation was defined. However, // if this operation node was an attribute node in disguise, we get this // information from the context - be_interface *intf; - intf = this->ctx_->attribute () + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (node->defined_in ()); @@ -130,8 +128,8 @@ be_visitor_operation_ss::visit_operation (be_operation *node) << "ACE_ENV_ARG_DECL" << be_uidt_nl << ")" << be_uidt_nl; - // Generate the actual code for the skeleton. However, if any of the argument - // types is "native", we do not generate any skeleton + // Generate the actual code for the skeleton. However, if any of the + // argument types is "native", we do not generate any skeleton // last argument - is always CORBA::Environment. *os << "{\n" << be_idt; @@ -154,12 +152,7 @@ be_visitor_operation_ss::visit_operation (be_operation *node) << "_tao_object_reference" << be_uidt_nl << ");" << be_uidt << be_uidt_nl; - // Declare a return type variable. - be_visitor_context ctx = *this->ctx_; - ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // Do we have any arguments in the operation that needs marshalling. + // Do we have any arguments in the operation that needs marshalling? int flag = node->count_arguments_with_direction (AST_Argument::dir_INOUT | AST_Argument::dir_OUT); @@ -172,9 +165,13 @@ be_visitor_operation_ss::visit_operation (be_operation *node) *os << "_tao_server_request.argument_flag (0);" << be_nl; } - if (!visitor || (bt->accept (visitor) == -1)) + // Declare a return type variable. + be_visitor_context ctx = *this->ctx_; + ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_SS); + be_visitor_operation_rettype_vardecl_ss ord_visitor (&ctx); + + if (bt->accept (&ord_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -185,11 +182,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // Declare variables for arguments. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DECL_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument oad_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oad_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -263,11 +259,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // RequestInfo object. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist oiia_visitor (&ctx); - if ((!visitor) || (node->accept (visitor) == -1)) + if (node->accept (&oiia_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -275,7 +270,6 @@ be_visitor_operation_ss::visit_operation (be_operation *node) -1); } - delete visitor; *os << be_uidt_nl << ");" << be_uidt_nl << be_nl; *os << "ACE_TRY" << be_idt_nl @@ -303,11 +297,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // Make the upcall and assign to the return val. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_ASSIGN_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype_assign_ss ora_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + if (bt->accept (&ora_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -320,11 +313,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) << "_tao_impl->" << node->local_name () << " (" << be_idt << be_idt_nl; ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_UPCALL_SS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument oau_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oau_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " @@ -375,11 +367,10 @@ be_visitor_operation_ss::visit_operation (be_operation *node) // Generate the return type mapping (same as in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if ((!visitor) || (bt->accept (visitor) == -1)) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -387,8 +378,6 @@ be_visitor_operation_ss::visit_operation (be_operation *node) -1); } - delete visitor; - if (bt->size_type () == be_decl::VARIABLE || bt->base_node_type () == AST_Decl::NT_array) { @@ -477,10 +466,9 @@ be_visitor_operation_ss::visit_argument (be_argument *node) // This method is used to generate the ParamData table entry. TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; // argument type // Retrieve the type for this argument. - bt = be_type::narrow_from_decl (node->field_type ()); + be_type *bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) { @@ -533,7 +521,6 @@ be_visitor_operation_ss::gen_demarshal_params (be_operation *node, be_type *) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; be_visitor_context ctx; // Now make sure that we have some in and inout parameters. Otherwise, there @@ -550,13 +537,12 @@ be_visitor_operation_ss::gen_demarshal_params (be_operation *node, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_DEMARSHAL_SS); ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument_marshal oad_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oad_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_demarshal_params - " "codegen for demarshal failed\n"), -1); @@ -565,12 +551,14 @@ be_visitor_operation_ss::gen_demarshal_params (be_operation *node, *os << be_uidt_nl << "))\n" << be_idt; // If marshaling fails, raise exception. - if (this->gen_raise_exception (0, - "CORBA::MARSHAL", - "") == -1) + int status = this->gen_raise_exception (0, + "CORBA::MARSHAL", + ""); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_and invoke - " "codegen for return var failed\n"), -1); @@ -588,7 +576,6 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, be_type *bt) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; be_visitor_context ctx; // Setup parameters for marshaling and marshal them into the @@ -601,9 +588,9 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, // We still need the following check because we maybe 2way and yet have no // parameters and a void return type. - if (this->void_return_type (bt) && - !this->has_param_type (node, AST_Argument::dir_INOUT) && - !this->has_param_type (node, AST_Argument::dir_OUT)) + if (this->void_return_type (bt) + && !this->has_param_type (node, AST_Argument::dir_INOUT) + && !this->has_param_type (node, AST_Argument::dir_OUT)) { return 0; } @@ -613,17 +600,12 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, { ctx = *this->ctx_; - be_visitor_context *new_ctx = 0; - ACE_NEW_RETURN (new_ctx, - be_visitor_context (ctx), - 0); - - be_visitor_operation_rettype_post_upcall_ss visitor (new_ctx); + be_visitor_operation_rettype_post_upcall_ss visitor (&ctx); if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_params - " "codegen for return var [post upcall] failed\n"), -1); @@ -632,12 +614,12 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, // Generate any temporary variables to demarshal the arguments. ctx = *this->ctx_; - be_visitor_args_post_upcall_ss vis1 (new be_visitor_context (ctx)); + be_visitor_args_post_upcall_ss vis1 (&ctx); if (node->accept (&vis1) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_pre_stub_info - " "codegen for pre args failed\n"), -1); @@ -653,21 +635,20 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_MARSHAL_SS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype_marshal_ss orm_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&orm_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_params - " "codegen for return var failed\n"), -1); } } - if (this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) + if (this->has_param_type (node, AST_Argument::dir_INOUT) + || this->has_param_type (node, AST_Argument::dir_OUT)) { if (!this->void_return_type (bt)) @@ -680,13 +661,12 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_MARSHAL_SS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument_marshal oam_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&oam_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_params - " "codegen for args failed\n"), -1); @@ -694,13 +674,16 @@ be_visitor_operation_ss::gen_marshal_params (be_operation *node, } *os << be_uidt_nl << "))\n"; - // if marshaling fails, raise exception - if (this->gen_raise_exception (0, - "CORBA::MARSHAL", - "") == -1) + + // If marshaling fails, raise exception. + int status = this->gen_raise_exception (0, + "CORBA::MARSHAL", + ""); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_ss::" + "(%N:%l) be_visitor_operation_ss::" "gen_marshal_params - " "codegen for raising exception failed\n"), -1); diff --git a/TAO/TAO_IDL/be/be_visitor_operation/proxy_impl_xh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/proxy_impl_xh.cpp index d7e00029d36..93f29885bb4 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/proxy_impl_xh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/proxy_impl_xh.cpp @@ -1,15 +1,18 @@ // $Id$ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, proxy_impl_xh, "$Id$") +ACE_RCSID (be_visitor_operation, + proxy_impl_xh, + "$Id$") -be_visitor_operation_proxy_impl_xh::be_visitor_operation_proxy_impl_xh (be_visitor_context *ctx) +be_visitor_operation_proxy_impl_xh::be_visitor_operation_proxy_impl_xh ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -20,17 +23,14 @@ be_visitor_operation_proxy_impl_xh::~be_visitor_operation_proxy_impl_xh (void) int be_visitor_operation_proxy_impl_xh::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - // every operation is declared virtual in the client code *os << "virtual "; - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -40,30 +40,18 @@ int be_visitor_operation_proxy_impl_xh::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; // STEP 2: generate the operation name *os << " " << node->local_name (); @@ -72,26 +60,16 @@ int be_visitor_operation_proxy_impl_xh::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oapi_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oapi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp index 9e0cefca478..0d81e8e24ff 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp @@ -3,7 +3,6 @@ #include "idl.h" #include "idl_extern.h" #include "be.h" - #include "be_visitor_operation.h" ACE_RCSID (be_visitor_operation, @@ -15,46 +14,55 @@ ACE_RCSID (be_visitor_operation, // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_remote_proxy_impl_cs::be_visitor_operation_remote_proxy_impl_cs (be_visitor_context *ctx) +be_visitor_operation_remote_proxy_impl_cs:: +be_visitor_operation_remote_proxy_impl_cs (be_visitor_context *ctx) : be_visitor_operation (ctx), operation_name_ (0) { } -be_visitor_operation_remote_proxy_impl_cs::~be_visitor_operation_remote_proxy_impl_cs (void) +be_visitor_operation_remote_proxy_impl_cs:: +~be_visitor_operation_remote_proxy_impl_cs (void) { - delete[] operation_name_; + delete [] operation_name_; } -// processing to be done after every element in the scope is processed +// Processing to be done after every element in the scope is processed. int be_visitor_operation_remote_proxy_impl_cs::post_process (be_decl *bd) { - // all we do here is to insert a comma and a newline + // All we do here is to insert a comma and a newline. TAO_OutStream *os = this->ctx_->stream (); + if (!this->last_node (bd)) - *os << ",\n"; + { + *os << ",\n"; + } + return 0; } int -be_visitor_operation_remote_proxy_impl_cs::visit_operation (be_operation *node) +be_visitor_operation_remote_proxy_impl_cs::visit_operation ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - be_type *bt; // type node - be_visitor_context ctx; // visitor context - be_visitor *visitor; // visitor + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; + be_visitor_context ctx; - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + this->ctx_->node (node); if (node->is_local ()) - return 0; + { + return 0; + } - os->indent (); // start with the current indentation level + os->indent (); - // retrieve the operation return type + // Retrieve the operation return type. bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -67,56 +75,47 @@ be_visitor_operation_remote_proxy_impl_cs::visit_operation (be_operation *node) // Generate the return type mapping (same as in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype ort_visitor (&ctx); - if ((!visitor) || (bt->accept (visitor) == -1)) + if (bt->accept (&ort_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; // Generate the operation name be_decl* scope = be_scope::narrow_from_scope (node->defined_in ())->decl (); be_interface *interface = be_interface::narrow_from_decl (scope); - *os <<" " << interface->full_remote_proxy_impl_name () << "::" << node->local_name (); + + *os <<" " << interface->full_remote_proxy_impl_name () + << "::" << node->local_name (); // Generate the argument list with the appropriate mapping (same as - // in the header file) + // in the header file). ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XS); - visitor = tao_cg->make_visitor (&ctx); - if ((!visitor) || (node->accept (visitor) == -1)) + be_visitor_operation_arglist arglist_visitor (&ctx); + + if (node->accept (&arglist_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; // Generate the actual code for the stub. However, if any of the argument // types is "native", we flag a MARSHAL exception. // last argument - is always ACE_ENV_ARG_PARAMETER *os << "{" << be_idt_nl; - -/* This shall go away as soon as we drop the include_env switch - (2001-10-29 oliver.kellogg@t-online.de) =======*/ - // Deal with differences between IDL mapping for true C++ exceptions and - // alternate mapping. Since our code uses the ACE_TRY_ENV variable in a - // number of places, for the true exception case, we will have to explicitly - // declare the ACE_TRY_ENV variable. *os << this->gen_environment_var () << "\n"; -//============================================================================ - // Generate any pre stub info if and only if none of our parameters is of the - // native type. + // Generate any pre stub info if and only if none of our parameters is of + // the native type. if (!node->has_native ()) { // native type does not exist. @@ -126,21 +125,24 @@ be_visitor_operation_remote_proxy_impl_cs::visit_operation (be_operation *node) // derived class if (this->gen_pre_stub_info (node) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "gen_pre_stub_info failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "gen_pre_stub_info failed\n" + ), + -1 + ); } } // Declare return type. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + be_visitor_operation_rettype_vardecl_cs rd_visitor (&ctx); + + if (bt->accept (&rd_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" "visit_operation - " @@ -154,11 +156,14 @@ be_visitor_operation_remote_proxy_impl_cs::visit_operation (be_operation *node) "CORBA::MARSHAL", "") == -1) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for return var failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for return var failed\n" + ), + -1 + ); } } else @@ -166,68 +171,77 @@ be_visitor_operation_remote_proxy_impl_cs::visit_operation (be_operation *node) // Generate code that retrieves the underlying stub object and then // invokes do_static_call on it. *os << be_nl - << "TAO_Stub *istub = _collocated_tao_target_->_stubobj ();" << be_nl - << "if (istub == 0)" << be_idt_nl; + << "TAO_Stub *istub = _collocated_tao_target_->_stubobj ();" + << be_nl << "if (istub == 0)" << be_idt_nl; - // if the stub object was bad, then we raise a system exception - if (this->gen_raise_exception (bt, - "CORBA::INTERNAL", - "") == -1) + // If the stub object was bad, then we raise a system exception. + if (this->gen_raise_exception (bt, "CORBA::INTERNAL", "") == -1) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for checking exception failed\n"), - -1); - + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for checking exception failed\n" + ), + -1 + ); } + *os << be_uidt_nl << "\n"; - // do any pre marshal and invoke processing with return type. This + // Do any pre marshal and invoke processing with return type. This // includes allocating memory, initialization. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_PRE_INVOKE_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + be_visitor_operation_rettype_pre_invoke_cs rpi_visitor (&ctx); + + if (bt->accept (&rpi_visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for retval pre invoke failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for retval pre invoke failed\n" + ), + -1 + ); } - // do any pre marshal and invoke stuff with arguments + // Do any pre marshal and invoke stuff with arguments. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_PRE_INVOKE_CS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument api_visitor (&ctx); + + if (node->accept (&api_visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for argument pre invoke failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for argument pre invoke failed\n" + ), + -1 + ); } - // generate the code for marshaling in the parameters and transmitting - // them + // Generate the code for marshaling in the parameters and transmitting + // them. if (this->gen_marshal_and_invoke (node, bt) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for marshal and invoke failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for marshal and invoke failed\n" + ), + -1 + ); } if (!this->void_return_type (bt)) { - // now generate the normal successful return statement - // os->indent (); + // Now generate the normal successful return statement. if (bt->size_type () == be_decl::VARIABLE || bt->base_node_type () == AST_Decl::NT_array) { @@ -245,19 +259,17 @@ be_visitor_operation_remote_proxy_impl_cs::visit_operation (be_operation *node) return 0; } - - - int be_visitor_operation_remote_proxy_impl_cs::visit_argument (be_argument *node) { - // this method is used to generate the ParamData table entry + // This method is used to generate the ParamData table entry. TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; // argument type + be_type *bt; - // retrieve the type for this argument + // Retrieve the type for this argument. bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -269,6 +281,7 @@ be_visitor_operation_remote_proxy_impl_cs::visit_argument (be_argument *node) os->indent (); *os << "{" << bt->tc_name () << ", "; + switch (node->direction ()) { case AST_Argument::dir_IN: @@ -287,22 +300,25 @@ be_visitor_operation_remote_proxy_impl_cs::visit_argument (be_argument *node) } int -be_visitor_operation_remote_proxy_impl_cs::gen_pre_stub_info (be_operation *node) +be_visitor_operation_remote_proxy_impl_cs::gen_pre_stub_info ( + be_operation *node + ) { // Check if this operation raises any exceptions. In that case, we must // generate a list of exception typecodes. This is not valid for - // attributes + // attributes. if (!this->ctx_->attribute ()) { be_visitor_context ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_EXCEPTLIST_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_exceptlist_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) " - "be_compiled_visitor_operation_cs::" + "be_visitor_operation_cs::" "gen_pre_stub_info - " "Exceptionlist generation error\n"), -1); @@ -314,16 +330,16 @@ be_visitor_operation_remote_proxy_impl_cs::gen_pre_stub_info (be_operation *node int be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( - be_operation *node, - be_type *bt) + be_operation *node, + be_type *bt + ) { TAO_OutStream *os = this->ctx_->stream (); - be_visitor *visitor; be_visitor_context ctx; os->indent (); - // create the GIOP_Invocation and grab the outgoing CDR stream + // Create the GIOP_Invocation and grab the outgoing CDR stream. switch (node->flags ()) { case AST_Operation::OP_oneway: @@ -400,9 +416,13 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( // Grab the right visitor to generate the return type if its not // void it means it is not the accessor. if (!this->void_return_type (bt)) - *os << "_get"; + { + *os << "_get"; + } else - *os << "_set"; + { + *os << "_set"; + } } *os << " _tao_ri (" << be_idt_nl @@ -413,11 +433,10 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( // to the RequestInfo object. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_CS); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_interceptors_arglist iia_visitor (&ctx); - if ((!visitor) || (node->accept (visitor) == -1)) + if (node->accept (&iia_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" "visit_operation - " @@ -425,8 +444,6 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( -1); } - delete visitor; - *os << be_uidt_nl << ");" << be_nl; if (this->gen_check_exception (bt) == -1) @@ -494,7 +511,8 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( *os << be_nl << "_tao_call.start (ACE_ENV_SINGLE_ARG_PARAMETER);" << be_nl; - // check if there is an exception + + // Check if there is an exception. if (this->gen_check_interceptor_exception (bt) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -509,8 +527,8 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( << "ACE_static_cast (CORBA::Octet, _tao_response_flag)" << be_nl << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl << ");" << be_uidt_nl; - // check if there is an exception + // Check if there is an exception. if (this->gen_check_interceptor_exception (bt) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -534,27 +552,27 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); ctx.sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument_invoke oai_visitor (&ctx); + + if (node->accept (&oai_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and_invoke - " - "codegen for return var in do_static_call failed\n"), + "codegen for return var in " + "do_static_call failed\n"), -1); } + *os << be_uidt_nl << "))" << be_nl; // If marshaling fails, raise exception. - if (this->gen_raise_interceptor_exception (bt, - "CORBA::MARSHAL", - "") + if (this->gen_raise_interceptor_exception (bt, "CORBA::MARSHAL", "") == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and invoke - " "codegen for return var failed\n"), -1); @@ -563,9 +581,12 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( *os << be_uidt_nl; } else - *os << be_nl; + { + *os << be_nl; + } *os << "_invoke_status =" << be_idt_nl; + if (node->flags () == AST_Operation::OP_oneway) { // Oneway operation. @@ -587,11 +608,12 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( } *os << be_uidt_nl; + // Check if there is an exception. if (this->gen_check_interceptor_exception (bt) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and_invoke - " "codegen for checking exception failed\n"), -1); @@ -602,13 +624,16 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( << "{" << be_idt_nl; // Unlisted user exception received by client. - if (this->gen_raise_interceptor_exception ( - bt, - "CORBA::UNKNOWN", - "TAO_OMG_VMCID | 1, CORBA::COMPLETED_YES") == -1) + int status = this->gen_raise_interceptor_exception ( + bt, + "CORBA::UNKNOWN", + "TAO_OMG_VMCID | 1, CORBA::COMPLETED_YES" + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and invoke - " "codegen for return var failed\n"), -1); @@ -638,33 +663,33 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( // If we reach here, we are ready to proceed. // the code below this is for twoway operations only. - if (!this->void_return_type (bt) || - this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) + if (!this->void_return_type (bt) + || this->has_param_type (node, AST_Argument::dir_INOUT) + || this->has_param_type (node, AST_Argument::dir_OUT)) { // Do any post_invoke stuff that might be necessary. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_POST_INVOKE_CS); ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument oapi_visitor (&ctx); + + if (node->accept (&oapi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and_invoke - " "codegen for args in post do_static_call\n"), -1); } - // Generate any temporary variables to demarshal the arguments - ctx = *this->ctx_; - be_visitor_compiled_args_decl vis1 (new be_visitor_context (ctx)); + // Generate any temporary variables to demarshal the arguments. + be_visitor_args_decl vis1 (&ctx); + if (node->accept (&vis1) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_pre_stub_info - " "codegen for pre args failed\n"), -1); @@ -672,61 +697,61 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( if (!this->void_return_type (bt)) { - // Generate any temporary variables to demarshal the return value - ctx = *this->ctx_; - be_visitor_context *new_ctx = - new be_visitor_context (ctx); - be_visitor_operation_rettype_post_invoke_cs vis2 (new_ctx); + // Generate any temporary variables to demarshal the return value. + be_visitor_operation_rettype_post_invoke_cs vis2 (&ctx); + if (bt->accept (&vis2) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_pre_stub_info - " "codegen rettype [post invoke] failed\n"), -1); } } - // check if there was a user exception, else demarshal the + // Check if there was a user exception, else demarshal the // return val (if any) and parameters (if any) that came with - // the response message + // the response message. *os << "TAO_InputCDR &_tao_in = _tao_call.inp_stream ();" << be_nl << "if (!(" << be_idt << be_idt_nl; if (!this->void_return_type (bt)) { - // demarshal the return val + // Demarshal the return value. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_INVOKE_CS); ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_rettype_marshal_ss ori_visitor (&ctx); + + if (node->accept (&ori_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and_invoke - " "codegen for return var failed\n"), -1); } } - if (this->has_param_type (node, AST_Argument::dir_INOUT) || - this->has_param_type (node, AST_Argument::dir_OUT)) + if (this->has_param_type (node, AST_Argument::dir_INOUT) + || this->has_param_type (node, AST_Argument::dir_OUT)) { if (!this->void_return_type (bt)) - *os << " &&" << be_nl; + { + *os << " &&" << be_nl; + } - // demarshal each out and inout argument + // Demarshal each out and inout argument. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARG_INVOKE_CS); ctx.sub_state (TAO_CodeGen::TAO_CDR_INPUT); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument_invoke oai_visitor (&ctx); + + if (node->accept (&oai_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and_invoke - " "codegen for return var failed\n"), -1); @@ -736,13 +761,18 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( *os << be_nl << "))" << be_uidt_nl << "{" << be_idt_nl; - // if marshaling fails, raise exception - if (this->gen_raise_interceptor_exception - (bt, "CORBA::MARSHAL", - "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES") == -1) + + // If marshaling fails, raise exception. + int status = this->gen_raise_interceptor_exception ( + bt, + "CORBA::MARSHAL", + "TAO_DEFAULT_MINOR_CODE, CORBA::COMPLETED_YES" + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and invoke - " "codegen for return var failed\n"), -1); @@ -771,17 +801,19 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( // Generate the return type mapping (same as in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if ((!visitor) || (bt->accept (visitor) == -1)) + be_visitor_operation_rettype oro_visitor (&ctx); + + if (bt->accept (&oro_visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" - "visit_operation - " - "codegen for return type failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_remote_proxy_impl_cs::" + "visit_operation - " + "codegen for return type failed\n" + ), + -1 + ); } - delete visitor; if (bt->size_type () == be_decl::VARIABLE || bt->base_node_type () == AST_Decl::NT_array) @@ -863,9 +895,13 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( << be_idt_nl; if (be_global->use_raw_throw ()) - *os << "throw;" << be_uidt << be_uidt_nl; + { + *os << "throw;" << be_uidt << be_uidt_nl; + } else - *os << "ACE_RE_THROW;" << be_uidt << be_uidt_nl; + { + *os << "ACE_RE_THROW;" << be_uidt << be_uidt_nl; + } *os << "}" << be_uidt_nl << "ACE_ENDTRY;" << be_nl; @@ -873,7 +909,7 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( if (this->gen_check_exception (bt) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and_invoke - " "codegen for checking exception failed\n"), -1); @@ -892,7 +928,7 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( if (this->gen_check_exception (bt) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_compiled_visitor_operation_cs::" + "(%N:%l) be_visitor_operation_cs::" "gen_marshal_and_invoke - " "codegen for checking exception failed\n"), -1); @@ -913,9 +949,11 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( } int -be_visitor_operation_remote_proxy_impl_cs::gen_raise_interceptor_exception (be_type *bt, - const char *excep, - const char *completion_status) +be_visitor_operation_remote_proxy_impl_cs::gen_raise_interceptor_exception ( + be_type *bt, + const char *excep, + const char *completion_status + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -956,14 +994,20 @@ be_visitor_operation_remote_proxy_impl_cs::gen_raise_interceptor_exception (be_t } const char* -be_visitor_operation_remote_proxy_impl_cs::compute_operation_name (be_operation *node) +be_visitor_operation_remote_proxy_impl_cs::compute_operation_name ( + be_operation *node + ) { if (this->operation_name_ == 0) { - size_t len = 3; // length for two double quotes - // and the null termination char. + // Length for two double quotes and the null termination char. + size_t len = 3; + if (this->ctx_->attribute ()) - len += 5; // "Added length for "_set_" or "_get_". + { + // "Added length for "_set_" or "_get_". + len += 5; + } len += ACE_OS::strlen (node->original_local_name ()->get_string ()); @@ -972,17 +1016,24 @@ be_visitor_operation_remote_proxy_impl_cs::compute_operation_name (be_operation 0); ACE_OS::strcpy (this->operation_name_, "\""); + if (this->ctx_->attribute ()) { - // now check if we are a "get" or "set" operation - if (node->nmembers () == 1) // set - ACE_OS::strcat (this->operation_name_, "_set_"); + // Now check if we are a "get" or "set" operation. + if (node->nmembers () == 1) + { + ACE_OS::strcat (this->operation_name_, "_set_"); + } else - ACE_OS::strcat (this->operation_name_, "_get_"); + { + ACE_OS::strcat (this->operation_name_, "_get_"); + } } + ACE_OS::strcat (this->operation_name_, node->original_local_name ()->get_string ()); ACE_OS::strcat (this->operation_name_, "\""); } + return this->operation_name_; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_ss.cpp index 74034b7c6ab..fb8da6e0eb2 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/rettype_vardecl_ss.cpp @@ -104,7 +104,7 @@ visit_interface_fwd (be_interface_fwd *node) return 0; } -// like be_compiled_visitor_operation_rettype_vardecl_ss +// Like be_visitor_operation_rettype_vardecl_ss. int be_visitor_operation_rettype_vardecl_ss::visit_valuetype (be_valuetype *node) { diff --git a/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_ch.cpp b/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_ch.cpp index 67166a5d8fc..7818851434d 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_ch.cpp @@ -18,25 +18,30 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, operation_smart_proxy_ch, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_smart_proxy_ch, + "$Id$") // ****************************************************** -// primary visitor for "operation" in client header +// Primary visitor for "operation" in client header. // ****************************************************** -be_visitor_operation_smart_proxy_ch::be_visitor_operation_smart_proxy_ch (be_visitor_context *ctx) +be_visitor_operation_smart_proxy_ch::be_visitor_operation_smart_proxy_ch ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } -be_visitor_operation_smart_proxy_ch::~be_visitor_operation_smart_proxy_ch (void) +be_visitor_operation_smart_proxy_ch::~be_visitor_operation_smart_proxy_ch ( + void + ) { } @@ -46,19 +51,15 @@ be_visitor_operation_smart_proxy_ch::visit_operation (be_operation *node) if (be_global->gen_smart_proxies ()) { + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); + os->indent (); - TAO_OutStream *os; // output stream - be_type *bt; // type node - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node - os->indent (); // start with the current indentation level - - // every operation is declared virtual in the client code *os << "virtual "; - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -68,58 +69,36 @@ be_visitor_operation_smart_proxy_ch::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_smart_proxy_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype or_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_smart_proxy_ch::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; - // STEP 2: generate the operation name + // STEP 2: generate the operation name. *os << " " << node->local_name (); // STEP 3: generate the argument list with the appropriate mapping. For these // we grab a visitor that generates the parameter listing ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_smart_proxy_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_smart_proxy_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; } else { @@ -127,5 +106,4 @@ be_visitor_operation_smart_proxy_ch::visit_operation (be_operation *node) } return 0; - } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_cs.cpp index 715d774c75b..7f3e0bc24d6 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/smart_proxy_cs.cpp @@ -18,26 +18,30 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, operation_smart_proxy_cs, "$Id$") +ACE_RCSID (be_visitor_operation, + operation_smart_proxy_cs, + "$Id$") // ************************************************************ // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_smart_proxy_cs::be_visitor_operation_smart_proxy_cs -(be_visitor_context *ctx) - : be_visitor_scope (ctx) +be_visitor_operation_smart_proxy_cs::be_visitor_operation_smart_proxy_cs ( + be_visitor_context *ctx + ) + : be_visitor_operation (ctx) { } -be_visitor_operation_smart_proxy_cs::~be_visitor_operation_smart_proxy_cs (void) +be_visitor_operation_smart_proxy_cs::~be_visitor_operation_smart_proxy_cs ( + void + ) { } @@ -49,9 +53,8 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) // We need the interface node in which this operation was defined. However, // if this operation node was an attribute node in disguise, we get this - // information from the context - be_interface *intf; - intf = this->ctx_->attribute () + // information from the context. + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (node->defined_in ()); @@ -64,8 +67,8 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) -1); } - // retrieve the operation return type be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -75,30 +78,19 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) -1); } - // STEP 2: generate the return type mapping (same as in the header file) + // STEP 2: generate the return type mapping (same as in the header file). be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_smart_proxy_cs::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_smart_proxy_cs::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; // Its necessary to take care of the nested case. The smart proxy classes // are in the same scope as the proxy (i.e. interface) but here the @@ -121,26 +113,16 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ss::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oao_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oao_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt << "\n"; @@ -167,11 +149,10 @@ int be_visitor_operation_smart_proxy_cs::visit_operation (be_operation *node) } return 0; - } int be_visitor_operation_smart_proxy_cs::gen_invoke (be_visitor_context &ctx, - be_operation *node) + be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); @@ -180,10 +161,10 @@ int be_visitor_operation_smart_proxy_cs::gen_invoke (be_visitor_context &ctx, ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument visitor (&ctx); + + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_smart_proxy_cs::" "gen_invoke - " @@ -191,21 +172,9 @@ int be_visitor_operation_smart_proxy_cs::gen_invoke (be_visitor_context &ctx, -1); } - // end the upcall *os << be_uidt_nl << ");\n" << be_uidt; + return 0; } -int -be_visitor_operation_smart_proxy_cs::void_return_type (be_type *bt) -{ - // is the operation return type void? - - if (bt->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (bt)->pt () - == AST_PredefinedType::PT_void)) - return 1; - else - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_sh.cpp index c098696d347..c279b788c7b 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_sh.cpp @@ -18,46 +18,46 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, thru_poa_collocated_sh, "$Id$") +ACE_RCSID (be_visitor_operation, + thru_poa_collocated_sh, + "$Id$") // ************************************************************************* -// be_visitor_operation_thru_poa_collocated_sh -- // This visitor generates code for the thru_poa_collocated operation signature in a -// server header file +// server header file. // ************************************************************************* -be_visitor_operation_thru_poa_collocated_sh::be_visitor_operation_thru_poa_collocated_sh -(be_visitor_context *ctx) +be_visitor_operation_thru_poa_collocated_sh:: +be_visitor_operation_thru_poa_collocated_sh (be_visitor_context *ctx) : be_visitor_scope (ctx) { } -be_visitor_operation_thru_poa_collocated_sh::~be_visitor_operation_thru_poa_collocated_sh (void) +be_visitor_operation_thru_poa_collocated_sh:: +~be_visitor_operation_thru_poa_collocated_sh (void) { } -int be_visitor_operation_thru_poa_collocated_sh::visit_operation (be_operation *node) +int be_visitor_operation_thru_poa_collocated_sh::visit_operation ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - os->indent (); // start with the current indentation level + os->indent (); - // every operation is declared virtual in the client code *os << "virtual "; - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -67,58 +67,36 @@ int be_visitor_operation_thru_poa_collocated_sh::visit_operation (be_operation * -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; - // STEP 2: generate the operation name + // STEP 2: generate the operation name. *os << " " << node->local_name (); // STEP 3: generate the argument list with the appropriate mapping. For these - // we grab a visitor that generates the parameter listing + // we grab a visitor that generates the parameter listing. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oac_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oac_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_ss.cpp index 45a3a6b8d77..b4b064c52f6 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_collocated_ss.cpp @@ -18,115 +18,98 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, thru_poa_collocated_ss, "$Id$") +ACE_RCSID (be_visitor_operation, + thru_poa_collocated_ss, + "$Id$") // ************************************************************************* -// be_visitor_operation_thru_poa_collocated_ss -- // This visitor generates code for the thru_poa_collocated operation signature in a -// server skeletons file +// server skeletons file. // ************************************************************************* -be_visitor_operation_thru_poa_collocated_ss::be_visitor_operation_thru_poa_collocated_ss -(be_visitor_context *ctx) +be_visitor_operation_thru_poa_collocated_ss:: +be_visitor_operation_thru_poa_collocated_ss (be_visitor_context *ctx) : be_visitor_operation (ctx) { } -be_visitor_operation_thru_poa_collocated_ss::~be_visitor_operation_thru_poa_collocated_ss (void) +be_visitor_operation_thru_poa_collocated_ss:: +~be_visitor_operation_thru_poa_collocated_ss (void) { } -int be_visitor_operation_thru_poa_collocated_ss::visit_operation (be_operation *node) +int be_visitor_operation_thru_poa_collocated_ss::visit_operation ( + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); // We need the interface node in which this operation was defined. However, // if this operation node was an attribute node in disguise, we get this - // information from the context - be_interface *intf; - intf = this->ctx_->attribute () + // information from the context. + be_interface *intf = this->ctx_->attribute () ? be_interface::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_interface::narrow_from_scope (node->defined_in ()); if (!intf) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "(%N:%l) be_visitor_operation_" + "thru_poa_collocated_ss::" "visit_operation - " "bad interface scope\n"), -1); } - // retrieve the operation return type be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "(%N:%l) be_visitor_operation_" + "thru_poa_collocated_ss::" "visit_operation - " "Bad return type\n"), -1); } - // STEP 2: generate the return type mapping (same as in the header file) + // STEP 2: generate the return type mapping (same as in the header file). be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if (!visitor) + if (bt->accept (&oro_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); - } - - if (bt->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; *os << " " << intf->full_coll_name (be_interface::THRU_POA) << "::"; *os << node->local_name (); // STEP 4: generate the argument list with the appropriate mapping (same as - // in the header file) + // in the header file). ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ss::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oao_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oao_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt_nl << "TAO_Object_Adapter::Servant_Upcall servant_upcall (" @@ -139,21 +122,29 @@ int be_visitor_operation_thru_poa_collocated_ss::visit_operation (be_operation * << "this->_object_key ()," << be_nl << "\"" << node->original_local_name () << "\"," << be_nl << "forward_to.out ()"; + if (!be_global->exception_support ()) - *os << " ACE_ENV_ARG_PARAMETER);\n" << be_uidt_nl << be_uidt; + { + *os << " ACE_ENV_ARG_PARAMETER);\n" << be_uidt_nl << be_uidt; + } else - *os << be_uidt_nl << ");\n" << be_uidt; + { + *os << be_uidt_nl << ");\n" << be_uidt; + } // check if there is an exception if (!be_global->exception_support ()) - if (this->gen_check_exception (0) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "codegen for checking exception failed\n"), - -1); - } + { + if (this->gen_check_exception (0) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_operation_" + "thru_poa_collocated_ss::" + "visit_operation - " + "codegen for checking exception failed\n"), + -1); + } + } os->indent (); @@ -170,7 +161,9 @@ int be_visitor_operation_thru_poa_collocated_ss::visit_operation (be_operation * << ")" << be_uidt; if (this->gen_invoke (ctx, node) == -1) - return -1; + { + return -1; + } if (this->void_return_type (bt)) { @@ -194,11 +187,10 @@ int be_visitor_operation_thru_poa_collocated_ss::gen_invoke ( ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" "gen_invoke - " @@ -206,22 +198,9 @@ int be_visitor_operation_thru_poa_collocated_ss::gen_invoke ( -1); } - // End the upcall *os << be_uidt_nl << ");\n"; return 0; } -int -be_visitor_operation_thru_poa_collocated_ss::void_return_type (be_type *bt) -{ - // is the operation return type void? - - if (bt->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (bt)->pt () - == AST_PredefinedType::PT_void)) - return 1; - else - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_proxy_impl_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_proxy_impl_ss.cpp index 84fdaac5823..4f7e5c3eba1 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_proxy_impl_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/thru_poa_proxy_impl_ss.cpp @@ -3,29 +3,34 @@ #include "idl.h" #include "idl_extern.h" #include "be.h" - #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, be_visitor_operation_thru_poa_proxy_impl_ss, "$Id$") +ACE_RCSID (be_visitor_operation, + be_visitor_operation_thru_poa_proxy_impl_ss, + "$Id$") // ************************************************************ // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_thru_poa_proxy_impl_ss::be_visitor_operation_thru_poa_proxy_impl_ss (be_visitor_context *ctx) +be_visitor_operation_thru_poa_proxy_impl_ss:: +be_visitor_operation_thru_poa_proxy_impl_ss (be_visitor_context *ctx) : be_visitor_operation (ctx) { } -be_visitor_operation_thru_poa_proxy_impl_ss::~be_visitor_operation_thru_poa_proxy_impl_ss (void) +be_visitor_operation_thru_poa_proxy_impl_ss:: +~be_visitor_operation_thru_poa_proxy_impl_ss (void) { //No-Op. } int -be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node) +be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation ( + be_operation *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -39,48 +44,47 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node if (!intf) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "bad interface scope\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "bad interface scope\n" + ), + -1 + ); } // retrieve the operation return type be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "Bad return type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "Bad return type\n" + ), + -1 + ); } // STEP 2: generate the return type mapping (same as in the header file) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_rettype oro_visitor (&ctx); - if (!visitor) + if (bt->accept (&oro_visitor) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); - } - - if (bt->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "codegen for return type failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "codegen for return type failed\n" + ), + -1 + ); } - delete visitor; *os << " " << intf->full_thru_poa_proxy_impl_name () << "::"; *os << node->local_name (); @@ -89,26 +93,16 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_ss::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oapi_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oapi_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt << be_nl; @@ -117,15 +111,18 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node // Declare a return type ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_DECL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (bt->accept (visitor) == -1)) + be_visitor_operation_rettype_vardecl_ss ord_visitor (&ctx); + + if (bt->accept (&ord_visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "codegen for return var decl failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "codegen for return var decl failed\n" + ), + -1 + ); } if (!this->void_return_type (bt)) @@ -139,7 +136,8 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node *os <<"TAO_Object_Adapter::Servant_Upcall servant_upcall (" << be_idt << be_idt_nl - << "_collocated_tao_target_->_stubobj ()->servant_orb_var ()->orb_core ()" + << "_collocated_tao_target_->_stubobj ()" + << "->servant_orb_var ()->orb_core ()" << be_uidt_nl << ");" << be_uidt_nl << "CORBA::Object_var forward_to;" << be_nl @@ -147,22 +145,30 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node << "_collocated_tao_target_->_object_key ()," << be_nl << "\"" << node->original_local_name () << "\"," << be_nl << "forward_to.out ()"; + if (!be_global->exception_support ()) - *os << be_nl - << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl - << ");" << be_nl << be_uidt; + { + *os << be_nl + << "ACE_ENV_ARG_PARAMETER" << be_uidt_nl + << ");" << be_nl << be_uidt; + } else - *os << be_uidt_nl << ");" << be_uidt_nl; + { + *os << be_uidt_nl << ");" << be_uidt_nl; + } - // check if there is an exception + // Check if there is an exception. if (!be_global->exception_support ()) if (this->gen_check_exception (bt) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "visit_operation - " - "codegen for checking exception failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "visit_operation - " + "codegen for checking exception failed\n" + ), + -1 + ); } os->indent (); @@ -180,7 +186,9 @@ be_visitor_operation_thru_poa_proxy_impl_ss::visit_operation (be_operation *node << ")" << be_uidt; if (this->gen_invoke (ctx, node) == -1) - return -1; + { + return -1; + } if (this->void_return_type (bt)) { @@ -208,23 +216,25 @@ be_visitor_operation_thru_poa_proxy_impl_ss::gen_invoke ( ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_argument visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" - "gen_invoke - " - "codegen for making upcall failed\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_thru_poa_collocated_ss::" + "gen_invoke - " + "codegen for making upcall failed\n" + ), + -1 + ); } // End the upcall *os << be_uidt_nl << ");"; - // retrieve the operation return type + // Retrieve the operation return type. be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (this->void_return_type (bt)) @@ -239,15 +249,3 @@ be_visitor_operation_thru_poa_proxy_impl_ss::gen_invoke ( return 0; } -int -be_visitor_operation_thru_poa_proxy_impl_ss::void_return_type (be_type *bt) -{ - // is the operation return type void? - - if (bt->node_type () == AST_Decl::NT_pre_defined - && (be_predefined_type::narrow_from_decl (bt)->pt () - == AST_PredefinedType::PT_void)) - return 1; - else - return 0; -} diff --git a/TAO/TAO_IDL/be/be_visitor_operation/tie_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/tie_sh.cpp index 08c28a0d6ee..a583e5e5701 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/tie_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/tie_sh.cpp @@ -19,20 +19,23 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, tie_sh, "$Id$") +ACE_RCSID (be_visitor_operation, + tie_sh, + "$Id$") // ************************************************************ -// Operation visitor for server header for TIE class operations +// Operation visitor for server header for TIE class operations. // ************************************************************ -be_visitor_operation_tie_sh::be_visitor_operation_tie_sh (be_visitor_context *ctx) +be_visitor_operation_tie_sh::be_visitor_operation_tie_sh ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -44,16 +47,14 @@ be_visitor_operation_tie_sh::~be_visitor_operation_tie_sh (void) int be_visitor_operation_tie_sh::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node representing the return type + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node + os->indent (); - os->indent (); // start with the current indentation level + // STEP I: generate the return type. + be_type *bt = be_type::narrow_from_decl (node->return_type ()); - // STEP I: generate the return type - bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -63,32 +64,20 @@ be_visitor_operation_tie_sh::visit_operation (be_operation *node) -1); } - // grab the right visitor to generate the return type be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_tie_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_tie_sh::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; - // STEP 2: generate the operation name + // STEP 2: generate the operation name. *os << " " << node->local_name (); // STEP 3: generate the argument list with the appropriate mapping. For these @@ -97,25 +86,16 @@ be_visitor_operation_tie_sh::visit_operation (be_operation *node) // we use the _CH state here because the _SH state produces pure virtual // methods. ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_tie_sh::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist oa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_tie_sh::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/tie_si.cpp b/TAO/TAO_IDL/be/be_visitor_operation/tie_si.cpp index 2a53fe4a408..b5a7ff5eb3b 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/tie_si.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/tie_si.cpp @@ -18,21 +18,22 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_operation.h" -ACE_RCSID(be_visitor_operation, tie_si, "$Id$") - +ACE_RCSID (be_visitor_operation, + tie_si, + "$Id$") // ************************************************************ -// Operation visitor for server inline for TIE class operations +// Operation visitor for server inline for TIE class operations. // ************************************************************ -be_visitor_operation_tie_si::be_visitor_operation_tie_si -(be_visitor_context *ctx) +be_visitor_operation_tie_si::be_visitor_operation_tie_si ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -45,8 +46,7 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - be_interface *intf = - this->ctx_->interface (); + be_interface *intf = this->ctx_->interface (); if (!intf) { @@ -57,8 +57,9 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) -1); } - // retrieve the operation return type + // Retrieve the operation return type. be_type *bt = be_type::narrow_from_decl (node->return_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -71,30 +72,19 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) os->indent (); *os << "template <class T> ACE_INLINE\n"; - // generate the return type mapping (same as in the header file) + // Generate the return type mapping (same as in the header file). be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_tie_si::" - "visit_operation - " - "Bad visitor for return type\n"), - -1); - } + be_visitor_operation_rettype oro_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&oro_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_tie_si::" "visit_operation - " "codegen for return type failed\n"), -1); } - delete visitor; *os << " " << intf->full_skel_name () << "_tie<T>::" << node->local_name () << " "; @@ -103,31 +93,22 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) // in the header file) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_operation_cs::" - "visit_operation - " - "Bad visitor for argument list\n"), - -1); - } + be_visitor_operation_arglist oao_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&oao_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; *os << "{" << be_idt_nl; - if (bt->node_type () != AST_Decl::NT_pre_defined - || be_predefined_type::narrow_from_decl (bt)->pt () != AST_PredefinedType::PT_void) + be_predefined_type *pdt = be_predefined_type::narrow_from_decl (bt); + + if (pdt == 0 || pdt->pt () != AST_PredefinedType::PT_void) { *os << "return "; } @@ -136,17 +117,17 @@ int be_visitor_operation_tie_si::visit_operation (be_operation *node) ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OPERATION_COLLOCATED_ARG_UPCALL_SS); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_operation_argument ocau_visitor (&ctx); + + if (node->accept (&ocau_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ss::" "visit_operation - " "codegen for making upcall failed\n"), -1); } - // end the upcall + *os << be_uidt_nl; *os << ");" << be_uidt_nl; *os << "}\n\n"; diff --git a/TAO/TAO_IDL/be/be_visitor_root/root.cpp b/TAO/TAO_IDL/be/be_visitor_root/root.cpp index 2bea93a0734..f4db20744e8 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root.cpp @@ -18,13 +18,24 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_root.h" - -ACE_RCSID(be_visitor_root, root, "$Id$") +#include "be_visitor_valuetype/obv_module.h" +#include "be_visitor_constant.h" +#include "be_visitor_enum.h" +#include "be_visitor_exception.h" +#include "be_visitor_interface_fwd.h" +#include "be_visitor_module.h" +#include "be_visitor_structure.h" +#include "be_visitor_typedef.h" +#include "be_visitor_union.h" +#include "be_visitor_valuetype_fwd.h" + +ACE_RCSID (be_visitor_root, + root, + "$Id$") // Generic Root visitor @@ -37,31 +48,31 @@ be_visitor_root::~be_visitor_root (void) { } -// this method must be overridden by the derived root visitors +// This method must be overridden by the derived root visitors. int be_visitor_root::init (void) { return -1; } -// visit the Root node and its scope int be_visitor_root::visit_root (be_root *node) { - // open the appropriate output file based on what state we are in. The + // Open the appropriate output file based on what state we are in. The // overridden "init" method of derived classes will do the job. if (this->init () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::init - " - "failed to initialize context\n"), -1); + "failed to initialize context\n"), + -1); } - // all we have to do is to visit the scope and generate code if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::visit_root - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } // If we are generating the client header file, this is the place to @@ -80,6 +91,8 @@ int be_visitor_root::visit_root (be_root *node) { *os << "// Proxy Broker Factory function pointer declarations." << be_nl << be_nl; + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; } for (index = 0; index < size; ++index) @@ -98,6 +111,12 @@ int be_visitor_root::visit_root (be_root *node) size = be_global->non_defined_interfaces.size (); + if (size > 0) + { + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + } + for (index = 0; index < size; ++index) { be_global->non_defined_interfaces.dequeue_head (ifwd); @@ -140,70 +159,86 @@ int be_visitor_root::visit_root (be_root *node) } } - be_visitor *visitor; be_visitor_context ctx (*this->ctx_); - // make one more pass over the entire tree and generate the OBV_ namespaces - // and OBV_ classes + // Make one more pass over the entire tree and generate the OBV_ namespaces + // and OBV_ classes. idl_bool obv = 0; + int status = 0; + switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - obv = 1; - ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CH); - break; + { + obv = 1; + ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CH); + be_visitor_obv_module visitor (&ctx); + status = visitor.visit_scope (node); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - obv = 1; - ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CI); - break; + { + obv = 1; + ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CI); + be_visitor_obv_module visitor (&ctx); + status = visitor.visit_scope (node); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - obv = 1; - ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CS); - break; + { + obv = 1; + ctx.state (TAO_CodeGen::TAO_MODULE_OBV_CS); + be_visitor_obv_module visitor (&ctx); + status = visitor.visit_scope (node); + break; + } default: - break; + break; } - if (obv) - { - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "NUL visitor\n" - ), -1); - } - if (visitor->visit_scope (node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "failed to generate OBV_ things\n" - ), -1); - } - delete visitor; + if (obv == 1 && status == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root::" + "visit_root - " + "failed to generate OBV_ things\n"), + -1); } // The next thing we need to do is make one more pass thru the entire tree // and generate code for all the <<= and >>= operators for all the // user-defined types. - // - // XXXASG - this part of the code may be conditionally generated because at - // times it is not necessary to have these operators at all. TO-DO. ctx = *this->ctx_; + status = 0; + switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CH); + + if (be_global->any_support ()) + { + be_visitor_root_any_op visitor (&ctx); + status = node->accept (&visitor); + } + + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_ANY_OP_CS); + + if (be_global->any_support ()) + { + be_visitor_root_any_op visitor (&ctx); + status = node->accept (&visitor); + } + break; + } case TAO_CodeGen::TAO_ROOT_IH: (void) tao_cg->end_implementation_header ( be_global->be_get_implementation_hdr_fname (0) @@ -213,7 +248,6 @@ int be_visitor_root::visit_root (be_root *node) (void) tao_cg->end_server_header (); return 0; case TAO_CodeGen::TAO_ROOT_CI: - break; case TAO_CodeGen::TAO_ROOT_IS: break; case TAO_CodeGen::TAO_ROOT_SI: @@ -243,56 +277,48 @@ int be_visitor_root::visit_root (be_root *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - // *ASG* - this is a tempoaray hack soln so that our CDR operators get - // generated in the *.i file rather than the *.cpp file - if (this->ctx_->state () != TAO_CodeGen::TAO_ROOT_CI - && this->ctx_->state () != TAO_CodeGen::TAO_ROOT_IH - && this->ctx_->state () != TAO_CodeGen::TAO_ROOT_IS) + if (status == -1) { - visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "NUL visitor\n" - ), -1); - } - - // generate the << and >> operators for all the user-defined - // data types in the outermost scope - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "failed to generate Any operators\n" - ), -1); - } - delete visitor; + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root::" + "visit_root - " + "failed to generate Any operators\n"), + -1); } - // make one more pass over the entire tree and generate the CDR << and >> - // operators for compiled marshaling. Again, this code can be conditionally - // generated if compiled marshaling is desired. + + // Make one more pass over the entire tree and generate the CDR operators. ctx = *this->ctx_; + status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CH); + be_visitor_root_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CI); + be_visitor_root_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ROOT_CDR_OP_CS); + be_visitor_root_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_IH: case TAO_CodeGen::TAO_ROOT_SI: @@ -305,32 +331,21 @@ int be_visitor_root::visit_root (be_root *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } - } visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_root - " - "NUL visitor\n" - ), -1); - } - - // generate the << and >> operators for all the user-defined data types in - // the outermost scope - if (node->accept (visitor) == -1) + } + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_root - " - "failed to generate CDR operators\n" - ), -1); + "failed to generate CDR operators\n"), + -1); } - delete visitor; - // generate any final code such as #endifs + // Generate any final code such as #endifs. switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: @@ -342,29 +357,33 @@ int be_visitor_root::visit_root (be_root *node) return 0; } -// =all common visit methods for root visitor +// All common visit methods for root visitor. -// visit a constant int be_visitor_root::visit_constant (be_constant *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); + be_visitor_constant_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); + be_visitor_constant_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: @@ -382,70 +401,77 @@ be_visitor_root::visit_constant (be_constant *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_constant - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_constant - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -//visit an enum int be_visitor_root::visit_enum (be_enum *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; case TAO_CodeGen::TAO_ROOT_CI: case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: @@ -458,73 +484,90 @@ be_visitor_root::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_enum - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_enum - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an exception int be_visitor_root::visit_exception (be_exception *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); + be_visitor_exception_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); + be_visitor_exception_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); + be_visitor_exception_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); + be_visitor_exception_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); + be_visitor_exception_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); + be_visitor_exception_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); + be_visitor_exception_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); + be_visitor_exception_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: case TAO_CodeGen::TAO_ROOT_SS: @@ -536,31 +579,20 @@ be_visitor_root::visit_exception (be_exception *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_exception - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_exception - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_exception - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } @@ -568,14 +600,10 @@ be_visitor_root::visit_exception (be_exception *node) int be_visitor_root::visit_interface (be_interface *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); switch (this->ctx_->state ()) { @@ -623,8 +651,8 @@ be_visitor_root::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } @@ -632,24 +660,25 @@ be_visitor_root::visit_interface (be_interface *node) ctx.state (node->next_state (ctx.state ())); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; @@ -662,24 +691,25 @@ be_visitor_root::visit_interface (be_interface *node) ctx.state (node->next_state (ctx.state (), 1)); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } @@ -687,39 +717,53 @@ be_visitor_root::visit_interface (be_interface *node) return 0; } -// visit an interface_fwd int be_visitor_root::visit_interface_fwd (be_interface_fwd *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CH); + be_visitor_interface_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CI); + be_visitor_interface_fwd_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CS); - break; - case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CI); + be_visitor_interface_fwd_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_ANY_OP_CH); + be_visitor_interface_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: + { + ctx.state (TAO_CodeGen::TAO_INTERFACE_FWD_CDR_OP_CH); + be_visitor_interface_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: case TAO_CodeGen::TAO_ROOT_CS: case TAO_CodeGen::TAO_ROOT_SH: @@ -733,46 +777,30 @@ be_visitor_root::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface_fwd - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_interface_fwd - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_interface_fwd - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit a valuetype int be_visitor_root::visit_valuetype (be_valuetype *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); switch (this->ctx_->state ()) { @@ -806,100 +834,115 @@ be_visitor_root::visit_valuetype (be_valuetype *node) case TAO_CodeGen::TAO_ROOT_SS: case TAO_CodeGen::TAO_ROOT_IS: case TAO_CodeGen::TAO_ROOT_TIE_SH: - return 0; // nothing to do, resp. not yet impl. + return 0; // nothing to do. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_valuetype - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state ())); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_valuetype - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_valuetype - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; - // Do addtional "extra" code generation if necessary + // Do addtional "extra" code generation if necessary. if (node->has_extra_code_generation (ctx.state ())) { - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state (), 1)); visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_valuetype - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_valuetype - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } + return 0; } -// visit an valuetype_fwd int be_visitor_root::visit_valuetype_fwd (be_valuetype_fwd *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CH); + be_visitor_valuetype_fwd_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CI); + be_visitor_valuetype_fwd_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CH); + be_visitor_valuetype_fwd_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_VALUETYPE_FWD_CDR_OP_CI); + be_visitor_valuetype_fwd_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: @@ -943,323 +986,411 @@ be_visitor_root::visit_valuetype_fwd (be_valuetype_fwd *node) return 0; } -// visit a module int be_visitor_root::visit_module (be_module *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_MODULE_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CH); + be_visitor_module_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_MODULE_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CI); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_MODULE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CS); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: - ctx.state (TAO_CodeGen::TAO_MODULE_SH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_SH); + be_visitor_module_sh visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SI: - ctx.state (TAO_CodeGen::TAO_MODULE_SI); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_SI); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SS: - ctx.state (TAO_CodeGen::TAO_MODULE_SS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_SS); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_IS: - ctx.state (TAO_CodeGen::TAO_MODULE_IS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_IS); + be_visitor_module visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_IH: - ctx.state (TAO_CodeGen::TAO_MODULE_IH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_IH); + be_visitor_module_ih visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CH); + be_visitor_module_any_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_ANY_OP_CS); + be_visitor_module_any_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CH); + be_visitor_module_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CI); + be_visitor_module_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_MODULE_CDR_OP_CS); + be_visitor_module_cdr_op visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_module - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_module - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_module - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an structure int be_visitor_root::visit_structure (be_structure *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: case TAO_CodeGen::TAO_ROOT_SS: - case TAO_CodeGen::TAO_ROOT_IS: - case TAO_CodeGen::TAO_ROOT_IH: + case TAO_CodeGen::TAO_ROOT_IS: + case TAO_CodeGen::TAO_ROOT_IH: return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_structure - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_structure - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_structure - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an union int be_visitor_root::visit_union (be_union *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: case TAO_CodeGen::TAO_ROOT_SS: - case TAO_CodeGen::TAO_ROOT_IS: - case TAO_CodeGen::TAO_ROOT_IH: + case TAO_CodeGen::TAO_ROOT_IS: + case TAO_CodeGen::TAO_ROOT_IH: return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_union - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_union - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_union - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an typedef int be_visitor_root::visit_typedef (be_typedef *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_ROOT_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); + be_visitor_typedef_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); + be_visitor_typedef_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); + be_visitor_typedef_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); + be_visitor_typedef_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); + be_visitor_typedef_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); + be_visitor_typedef_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); + be_visitor_typedef_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); + be_visitor_typedef_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_ROOT_SH: case TAO_CodeGen::TAO_ROOT_SI: case TAO_CodeGen::TAO_ROOT_SS: - case TAO_CodeGen::TAO_ROOT_IS: - case TAO_CodeGen::TAO_ROOT_IH: + case TAO_CodeGen::TAO_ROOT_IS: + case TAO_CodeGen::TAO_ROOT_IH: return 0; // nothing to be done default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_typedef - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_root::" "visit_typedef - " - "NUL visitor\n" - ), -1); + "failed to accept visitor"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root::" - "visit_typedef - " - "failed to accept visitor" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence.cpp b/TAO/TAO_IDL/be/be_visitor_sequence.cpp index 8bb155d0cd5..e147b3f6f1e 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence.cpp @@ -52,4 +52,6 @@ #include "be_visitor_sequence/gen_bounded_str_sequence_cs.cpp" #include "be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp" -ACE_RCSID(be, be_visitor_sequence, "$Id$") +ACE_RCSID (be, + be_visitor_sequence, + "$Id$") diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp index 3258ee8ddc0..4dd714d544d 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/cdr_op_cs.cpp @@ -22,18 +22,20 @@ #include "idl.h" #include "idl_extern.h" #include "be.h" - #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, cdr_op_cs, "$Id$") +ACE_RCSID (be_visitor_sequence, + cdr_op_cs, + "$Id$") // *************************************************************************** // Sequence visitor for generating CDR operator declarations in the client -// stubs file +// stubs file. // *************************************************************************** -be_visitor_sequence_cdr_op_cs::be_visitor_sequence_cdr_op_cs -(be_visitor_context *ctx) +be_visitor_sequence_cdr_op_cs::be_visitor_sequence_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -47,7 +49,7 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) { if (this->ctx_->alias ()) { - // we are here because the base type of the sequence node is + // We are here because the base type of the sequence node is // itself a sequence i.e., this is a case of sequence of // typedef'd sequence. For the case of sequence of // anonymous sequence, see comment below. @@ -55,15 +57,18 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) } else { - if (node->cli_stub_cdr_op_gen () || - node->imported () || - node->is_local ()) - return 0; + if (node->cli_stub_cdr_op_gen () + || node->imported () + || node->is_local ()) + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); be_type *bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -78,9 +83,13 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS) - == -1) + int status = + this->gen_anonymous_base_type ( + bt, + TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS + ); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_array_cdr_op_cs::" @@ -90,9 +99,9 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) } } - // generate the CDR << and >> operator defns + // Generate the CDR << and >> operator defns. - // save the sequence node for further use + // Save the sequence node for further use. this->ctx_->node (node); // If we're an anonymous sequence, we must protect against @@ -104,7 +113,7 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) << "#define _TAO_CDR_OP_" << node->flat_name () << "_CPP_\n\n"; } - // set the sub state as generating code for the output operator + // Set the sub state as generating code for the output operator. this->ctx_->sub_state (TAO_CodeGen::TAO_CDR_OUTPUT); *os << "CORBA::Boolean operator<< (" << be_idt << be_idt_nl << "TAO_OutputCDR &strm," << be_nl @@ -113,10 +122,10 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) << ")" << be_uidt_nl << "{" << be_idt_nl; - // first encode the sequence length + // First encode the sequence length. *os << "if (strm << _tao_sequence.length ())" << be_nl << "{" << be_idt_nl; - // now encode the sequence elements + // Now encode the sequence elements. *os << "// encode all elements" << be_nl; if (bt->node_type () == AST_Decl::NT_sequence) @@ -139,7 +148,7 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) << "return 0; // error" << be_uidt_nl << "}\n\n"; - // set the sub state as generating code for the input operator + // Set the sub state as generating code for the input operator. os->indent (); this->ctx_->sub_state(TAO_CodeGen::TAO_CDR_INPUT); *os << "CORBA::Boolean operator>> (" << be_idt << be_idt_nl @@ -147,16 +156,16 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) << node->name () << " &_tao_sequence" << be_uidt_nl << ")" << be_uidt_nl << "{" << be_idt_nl; - // first retrieve the length and adjust the sequence length accordingly + // First retrieve the length and adjust the sequence length accordingly. *os << "CORBA::ULong _tao_seq_len;" << be_nl; *os << "if (strm >> _tao_seq_len)" << be_nl << "{" << be_idt_nl; - // now check if the length does not exceed the maximum. We do this only + // Now check if the length does not exceed the maximum. We do this only // for bounded sequences AST_Expression *expr = node->max_size (); - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) + + if (expr == 0 || (expr != 0 && expr->ev () == 0)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -169,8 +178,8 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) { if (expr->ev ()->u.ulval > 0) { - // we are dealing with a bounded sequence. Check if we are within - // bounds + // We are dealing with a bounded sequence. Check if we are within + // bounds. *os << "if (_tao_seq_len <= _tao_sequence.maximum ())" << be_nl << "{" << be_idt_nl; } @@ -220,9 +229,10 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) if (expr->ev ()->u.ulval > 0) { - // we are dealing with a bounded sequence. + // We are dealing with a bounded sequence. *os << "}" << be_uidt_nl; } + *os << "}" << be_nl << "return 0; // error" << be_uidt_nl << "}\n\n"; @@ -236,11 +246,10 @@ be_visitor_sequence_cdr_op_cs::visit_sequence (be_sequence *node) node->cli_stub_cdr_op_gen (1); } + return 0; } -// handle all the base types - int be_visitor_sequence_cdr_op_cs::visit_array (be_array *node) { @@ -278,7 +287,9 @@ be_visitor_sequence_cdr_op_cs::visit_valuetype_fwd (be_valuetype_fwd *node) } int -be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) +be_visitor_sequence_cdr_op_cs::visit_predefined_type ( + be_predefined_type *node + ) { TAO_OutStream *os = this->ctx_->stream (); @@ -286,27 +297,23 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) { case AST_PredefinedType::PT_pseudo: case AST_PredefinedType::PT_any: - // let the helper handle this return this->visit_node (node); case AST_PredefinedType::PT_void: - // error ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" "visit_predefined_type - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); default: - // all other primitive types. Handle them as shown below break; }; - // we get here if the "type" of individual elements of the sequence is a + // We get here if the "type" of individual elements of the sequence is a // primitive type. In this case, we treat the sequence as a single // dimensional sequence (even of it was multi-dimensional), and pass // the total length of the sequence as a cross product of the - // dimensions + // dimensions. - // grab the sequence node be_sequence *sequence = this->ctx_->be_node_as_sequence (); if (!sequence) @@ -318,12 +325,13 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) -1); } - // handle octet sequences using the optimizations provided by the TAO ORB - // Core. If these optimizations are not available, then use the normal form + // Handle octet sequences using the optimizations provided by the TAO ORB + // Core. If these optimizations are not available, then use the normal form. if (node->pt () == AST_PredefinedType::PT_octet && sequence->unbounded ()) { *os << "\n#if (TAO_NO_COPY_OCTET_SEQUENCES == 1)" << be_nl; + switch (this->ctx_->sub_state ()) { case TAO_CodeGen::TAO_CDR_INPUT: @@ -374,12 +382,14 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) "bad sub state\n"), -1); } + *os << "\n#else /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */" << be_nl; } *os << "return strm."; - // based on our substate, we may be reading from a stream or writing into a - // stream + + // Based on our substate, we may be reading from a stream or writing into a + // stream/ switch (this->ctx_->sub_state ()) { case TAO_CodeGen::TAO_CDR_INPUT: @@ -396,7 +406,7 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) -1); } - // determine what kind of sequence are we reading/writing + // Determine what kind of sequence are we reading/writing. switch (node->pt ()) { case AST_PredefinedType::PT_long: @@ -447,7 +457,7 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) -1); } - // handle special case to avoid compiler errors + // Handle special case to avoid compiler errors. switch (node->pt ()) { case AST_PredefinedType::PT_char: @@ -476,7 +486,10 @@ be_visitor_sequence_cdr_op_cs::visit_predefined_type (be_predefined_type *node) *os << "_tao_sequence.length ());" << be_uidt_nl; if (node->pt () == AST_PredefinedType::PT_octet && sequence->unbounded ()) - *os << "\n#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */" << be_nl; + { + *os << "\n#endif /* TAO_NO_COPY_OCTET_SEQUENCES == 0 */" << be_nl; + } + return 0; } @@ -501,35 +514,28 @@ be_visitor_sequence_cdr_op_cs::visit_union (be_union *node) int be_visitor_sequence_cdr_op_cs::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type - - // the node to be visited in the base primitve type that gets typedefed + this->ctx_->alias (node); be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// helper int be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) { TAO_OutStream *os = this->ctx_->stream (); be_sequence *node = this->ctx_->be_node_as_sequence (); - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!node) { ACE_ERROR_RETURN ((LM_ERROR, @@ -539,7 +545,11 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) -1); } - // initialize a boolean variable + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); + be_visitor_sequence_base visitor (&ctx); + + // Initialize a boolean variable. *os << "CORBA::Boolean _tao_marshal_flag = 1;" << be_nl; // we get here if the "type" of individual elements of the sequence is not a @@ -547,8 +557,8 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) // encode/decode element by element AST_Expression *expr = node->max_size (); - // dimension value - if ((expr == NULL) || ((expr != NULL) && (expr->ev () == NULL))) + + if (expr == 0 || (expr != 0 && expr->ev () == 0)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -556,6 +566,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) "bad sequence dimension\n"), -1); } + if (expr->ev ()->et == AST_Expression::EV_ulong) { *os << "for (CORBA::ULong i = 0; i < _tao_sequence.length ()" @@ -572,7 +583,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) -1); } - // if the type was a string, an obj ref, or a pseudo-obj, we are dealing with + // If the type was a string, an obj ref, or a pseudo-obj, we are dealing with // a manager type and hence we must use the appropriate in () and out () // methods. // @@ -583,7 +594,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) switch (bt->node_type ()) { case AST_Decl::NT_array: - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -594,7 +605,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_forany tmp ("; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -606,7 +617,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_alloc ());" << be_nl; *os << "_tao_marshal_flag = (strm >> tmp);" << be_nl; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -617,7 +628,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_copy (_tao_sequence[i], tmp.in ());" << be_nl; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -641,9 +652,10 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) "bad string node\n"), -1); } + if (str->max_size ()->ev ()->u.ulval == 0) { - // unbounded + // Unbounded. *os << "_tao_marshal_flag = (strm >> _tao_sequence[i].out ());" << be_uidt_nl; } @@ -669,9 +681,10 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) break; case AST_Decl::NT_pre_defined: { - // we need to separately handle this case of pseudo objects because - // they have a _var type + // We need to separately handle this case of pseudo objects because + // they have a _var type. be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); + if (!pt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -702,7 +715,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) switch (bt->node_type ()) { case AST_Decl::NT_array: - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -713,7 +726,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << "_var tmp_var (" << be_idt << be_idt_nl; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -742,7 +755,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << ")" << be_uidt << be_uidt_nl; *os << ");" << be_uidt_nl; - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cdr_op_cs::" @@ -763,6 +776,7 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) case AST_Decl::NT_pre_defined: { be_predefined_type *pt = be_predefined_type::narrow_from_decl (bt); + if (!pt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -800,6 +814,5 @@ be_visitor_sequence_cdr_op_cs::visit_node (be_type *bt) *os << be_nl; *os << "return _tao_marshal_flag;" << be_uidt_nl; - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp index 460cb93d1bc..5bfbd0b57ff 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ch.cpp @@ -20,22 +20,19 @@ // // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_bounded_obj_sequence_ch, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_bounded_obj_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -63,7 +60,7 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); // !! Branching in either compile time template instantiation // or manual template instantiation. @@ -78,20 +75,20 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) << "// = Initialization and termination methods." << be_nl << be_nl; - // default constructor + // Default constructor. *os << class_name << " (void);" << be_nl; - // constructor + // Constructor. *os << class_name << " (" << be_idt << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<"* *value," << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl << ");" << be_uidt_nl; - // constructor + // Constructor. *os << class_name << " (" << be_idt << be_idt_nl << "const " << class_name << " &rhs" << be_uidt_nl << ");" << be_uidt_nl; @@ -101,10 +98,10 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) << "const " << class_name << " &rhs" << be_uidt_nl << ");" << be_uidt_nl; - // destructor + // Destructor. *os << "virtual ~" << class_name << " (void);" << be_nl << be_nl; - // Accessors + // Accessors. *os << "// = Accessors." << be_nl; be_predefined_type *prim = be_predefined_type::narrow_from_decl (pt); @@ -133,9 +130,13 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) } if (is_valuetype) - *os << "TAO_Valuetype_Manager<"; + { + *os << "TAO_Valuetype_Manager<"; + } else - *os << "TAO_Object_Manager<"; + { + *os << "TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -148,14 +149,14 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) // allocbuf *os << "static "; - bt->accept (visitor); + bt->accept (&visitor); *os << " **allocbuf (CORBA::ULong length);" << be_nl; // freebuf *os << "static void freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **buffer);" << be_nl << be_nl; @@ -169,13 +170,13 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) *os << "virtual void _deallocate_buffer (void);" << be_nl; // get_buffer - bt->accept(visitor); + bt->accept (&visitor); *os << "* *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << "* *get_buffer (void) const;" << be_nl; @@ -189,20 +190,19 @@ be_visitor_sequence_ch::gen_bounded_obj_sequence (be_sequence *node) { // Pseudo objects do not require these methods. *os << "virtual void _downcast (" << be_idt << be_idt_nl - << "void* target," << be_nl - << "CORBA_Object *src" << be_nl - << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl - << ");" << be_uidt_nl; - + << "void* target," << be_nl + << "CORBA_Object *src" << be_nl + << "ACE_ENV_ARG_DECL_WITH_DEFAULTS" << be_uidt_nl + << ");" << be_uidt_nl; *os << "virtual CORBA_Object* _upcast (void *src) const;"; } + *os << be_uidt_nl << "};" << be_nl; os->gen_endif (); - // generate #endif for AHETI + // Generate #endif for AHETI. os->gen_endif_AHETI (); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp index 23c63bc255d..feb90e31a0a 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_ci.cpp @@ -19,21 +19,18 @@ // Modifications by Aniruddha Gokhale // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_bounded_obj_sequence_ci, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_bounded_obj_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -105,14 +102,15 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // Branching in either compile time template instantiation // or manual template instatiation. os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // First generate the static methods since they are used by others. Since @@ -120,7 +118,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // some compilers give lots of warnings. // allocbuf - *os << "ACE_INLINE "; bt->accept (visitor); + *os << "ACE_INLINE "; bt->accept (&visitor); *os << " **" << be_nl; *os << full_class_name << "::allocbuf (CORBA::ULong /* length */) " << "// Allocate storage for a sequence.." << be_nl @@ -129,7 +127,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // The accept is here the first time used and if an // error occurs, it will occur here. Later no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -142,7 +140,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << be_nl << "ACE_NEW_RETURN (buf, "; - bt->accept (visitor); + bt->accept (&visitor); *os << "*[" << node->max_size () << "], 0);" << be_nl << be_nl @@ -152,17 +150,21 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "buf[i] = "; int is_valuetype = 0; - { - be_interface *bf = be_interface::narrow_from_decl (pt); - if (bf != 0) + be_interface *bf = be_interface::narrow_from_decl (pt); + + if (bf != 0) + { is_valuetype = bf->is_valuetype (); - else - { - be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); - if (bff != 0) + } + else + { + be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); + + if (bff != 0) + { is_valuetype = bff->is_valuetype (); - } - } + } + } if (is_valuetype) { @@ -170,7 +172,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) } else if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -188,7 +190,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) *os << "ACE_INLINE void" << be_nl << full_class_name << "::freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **buffer)" << be_nl << "{" << be_idt_nl @@ -206,14 +208,14 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) } else if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ())" << be_idt_nl << "{" << be_idt_nl << "CORBA::release (buffer[i]);" << be_nl << "buffer[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();" << be_uidt_nl; } @@ -247,7 +249,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << full_class_name << "::" << class_name << " (CORBA::ULong length," << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<"* *value," << be_nl << "CORBA::Boolean release)" << be_uidt_nl @@ -268,15 +270,15 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "if (rhs.buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **tmp1 = allocbuf (" << node->max_size () << ");" << be_nl; - bt->accept(visitor); + bt->accept(&visitor); *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "** ACE_CAST_CONST, rhs.buffer_);" << be_nl << "for (CORBA::ULong i = 0; i < rhs.length_; i++)" << be_idt_nl @@ -291,16 +293,17 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) else { *os << "tmp1[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (tmp2[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (tmp2[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; + } } *os << be_uidt_nl @@ -326,11 +329,11 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "if (this->release_ && this->buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl << be_nl @@ -348,7 +351,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -369,19 +372,19 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "TAO_Bounded_Base_Sequence::operator= (rhs);" << be_nl << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **tmp1 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, rhs.buffer_);" << be_nl << "for (CORBA::ULong i=0; i < rhs.length_; ++i)" << be_idt_nl @@ -396,16 +399,17 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) else { *os << "tmp1[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (tmp2[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (tmp2[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; + } } *os << be_uidt_nl @@ -430,9 +434,13 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) else { if (is_valuetype) - *os << "TAO_Valuetype_Manager<"; + { + *os << "TAO_Valuetype_Manager<"; + } else - *os << "ACE_INLINE TAO_Object_Manager<"; + { + *os << "ACE_INLINE TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -442,11 +450,11 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "ACE_ASSERT (index < this->maximum_);" << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **const tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, this->buffer_);" << be_nl; @@ -457,9 +465,13 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) else { if (is_valuetype) + { *os << "return TAO_Valuetype_Manager<"; + } else - *os << "return TAO_Object_Manager<"; + { + *os << "return TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -471,14 +483,14 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // get_buffer *os << "ACE_INLINE "; - bt->accept(visitor); + bt->accept (&visitor); *os << " **" << be_nl; *os << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os << " **result = 0;" << be_nl << "if (orphan == 0)" << be_nl @@ -495,7 +507,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "result = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_uidt_nl << "}" << be_uidt_nl @@ -509,7 +521,7 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) << "result = ACE_reinterpret_cast("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**,this->buffer_);" << be_nl << "this->maximum_ = 0;" << be_nl << "this->length_ = 0;" << be_nl @@ -524,14 +536,14 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // get_buffer. *os << "ACE_INLINE const "; - bt->accept (visitor); + bt->accept (&visitor); *os << "* *" << be_nl << full_class_name << "::get_buffer (void) const" << be_nl << "{" << be_idt_nl << "return ACE_reinterpret_cast(const "; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, this->buffer_);" << be_uidt_nl << "}" << be_nl @@ -542,6 +554,5 @@ be_visitor_sequence_ci::gen_bounded_obj_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp index f144dd55c62..bf51424b76a 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_obj_sequence_cs.cpp @@ -19,21 +19,18 @@ // Modifications by Aniruddha Gokhale // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_bounded_obj_sequence_cs, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_bounded_obj_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -81,17 +78,21 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) } int is_valuetype = 0; - { - be_interface *bf = be_interface::narrow_from_decl (pt); - if (bf != 0) + be_interface *bf = be_interface::narrow_from_decl (pt); + + if (bf != 0) + { is_valuetype = bf->is_valuetype (); - else - { - be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); - if (bff != 0) + } + else + { + be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); + + if (bff != 0) + { is_valuetype = bff->is_valuetype (); - } - } + } + } const char * class_name = node->instance_name (); @@ -118,14 +119,15 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // Branching in either compile time template instantiation // or manual template instatiation. os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // First generate the static methods since they are used by others. Since @@ -154,11 +156,11 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl << "return;" << be_uidt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_nl @@ -181,11 +183,11 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl << be_nl @@ -203,7 +205,7 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -234,18 +236,18 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) << ")" << be_uidt_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os << " **tmp = ACE_static_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, target);" << be_nl << "*tmp = "; if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_narrow (src ACE_ENV_ARG_PARAMETER);"; } @@ -257,30 +259,30 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) *os << be_nl << "ACE_CHECK;" << be_uidt_nl - << "}\n" << be_nl; + << "}\n" << be_nl; *os << "CORBA_Object*" << be_nl << full_class_name << "::_upcast (void *src) const" << be_nl - << "{" << be_idt_nl; + << "{" << be_idt_nl; if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << " **tmp = ACE_static_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, src);" << be_nl << "return *tmp;"; } else { - *os << "return tao_" << pt->flat_name () << "_upcast (src);"; + *os << "return tao_" << pt->flat_name () << "_upcast (src);"; } *os << be_uidt_nl - << "}" << be_nl; + << "}" << be_nl; } os->gen_endif (); @@ -288,6 +290,5 @@ be_visitor_sequence_cs::gen_bounded_obj_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp index ee01027a5ff..6e6a167697d 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ch.cpp @@ -18,24 +18,20 @@ // // ============================================================================ -//#include "idl.h" -//#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_bounded_sequence_ch, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_bounded_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -48,9 +44,11 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CH) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CH); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -62,15 +60,16 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) const char * class_name = node->instance_name (); - be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // !! branching in either compile time template instantiation // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); *os << "class TAO_EXPORT_MACRO " << class_name << be_idt_nl @@ -86,7 +85,7 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) *os << class_name << " (" << be_idt << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" *data," << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl @@ -109,32 +108,33 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) // operator[] *os << "// = Accessors." << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" &operator[] (CORBA::ULong i);" << be_nl; // operator[] *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << " &operator[] (CORBA::ULong i) const;" << be_nl << be_nl; // Static Operations *os << "// = Static operations." << be_nl << "static "; - bt->accept (visitor); + bt->accept (&visitor); *os << " *allocbuf (CORBA::ULong);" << be_nl; // free_buf *os << "static void freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " *buffer);" << be_nl << be_nl; // Implement the TAO_Base_Sequence methods (see Sequence.h) - *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" + << be_nl; // allocate_buffer *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; @@ -143,13 +143,13 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) *os << "virtual void _deallocate_buffer (void);" << be_nl; // get_buffer - bt->accept (visitor); + bt->accept (&visitor); *os << " *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << " *get_buffer (void) const;" << be_nl; @@ -158,7 +158,7 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) << "CORBA::ULong max," << be_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" *data," << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl @@ -171,6 +171,5 @@ be_visitor_sequence_ch::gen_bounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp index 0a239629207..14b3ac8479f 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_ci.cpp @@ -98,14 +98,15 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; // !! Branching in either compile time template instantiation // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // First generate the static methods since they are used by others. Since @@ -120,7 +121,7 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // The accept is used the first time here, and if an // error occurs, it will occur here. Later, no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence::" @@ -133,10 +134,14 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << full_class_name << "::allocbuf (CORBA::ULong) " << "// Allocate storage for the sequence." << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *retval = 0;" << be_nl << "ACE_NEW_RETURN (retval, "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "[" << node->max_size () << "], 0);" << be_nl << "return retval;" << be_uidt_nl << "}" << be_nl @@ -145,7 +150,9 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // free_buf. *os << "ACE_INLINE void " << be_nl << full_class_name << "::freebuf ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *buffer) // Free the sequence." << be_nl << "{" << be_idt_nl << "delete [] buffer;" << be_uidt_nl @@ -164,12 +171,16 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // Constructor. *os << "ACE_INLINE" << be_nl; - *os << full_class_name << "::" << class_name << " (CORBA::ULong length," << be_idt_nl; - bt->accept (visitor); + *os << full_class_name << "::" << class_name + << " (CORBA::ULong length," << be_idt_nl; + + bt->accept (&visitor); + *os <<" *data," << be_nl << "CORBA::Boolean release)" << be_uidt_nl << "// Constructor using the data and memory management flag." << be_nl - << " : TAO_Bounded_Base_Sequence (" << node->max_size () << ", length, data, release)" << be_nl + << " : TAO_Bounded_Base_Sequence (" << node->max_size () + << ", length, data, release)" << be_nl << "{" << be_nl << "}" << be_nl << be_nl; @@ -183,20 +194,26 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "{" << be_idt_nl << "if (rhs.buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp1 = " << class_name << "::allocbuf (" << node->max_size () << ");" << be_nl << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" * const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); *os << "_var::copy (tmp1[i], tmp2[i]);" << be_uidt_nl; } else @@ -216,7 +233,8 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // operator=. *os << "ACE_INLINE " << full_class_name << " &" << be_nl - << full_class_name << "::operator= (const " << class_name << " &rhs)" << be_nl + << full_class_name << "::operator= (const " + << class_name << " &rhs)" << be_nl << "// Assignment operator. " << be_nl << "{" << be_idt_nl << "if (this == &rhs)" << be_idt_nl @@ -226,24 +244,33 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "{" << be_nl << "}" << be_nl << "else" << be_idt_nl - << "this->buffer_ = " << class_name << "::allocbuf (rhs.maximum_);" << be_uidt_nl + << "this->buffer_ = " << class_name + << "::allocbuf (rhs.maximum_);" << be_uidt_nl << be_nl <<"TAO_Bounded_Base_Sequence::operator= (rhs);" << be_nl << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<"* tmp1 = ACE_reinterpret_cast ("; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " *, this->buffer_);" << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<"* const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); *os << "_var::copy (tmp1[i], tmp2[i]);" << be_uidt_nl; } else @@ -259,28 +286,40 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // Accessors. *os << "// = Accessors." << be_nl; *os << "ACE_INLINE "; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " &" << be_nl; - *os << full_class_name << "::operator[] (CORBA::ULong i)// operator []" << be_nl + *os << full_class_name << "::operator[] (CORBA::ULong i)" << be_nl << "{" << be_idt_nl << "ACE_ASSERT (i < this->maximum_);" << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << "return tmp[i];" << be_uidt_nl << "}" << be_nl; - *os << "ACE_INLINE const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " &" << be_nl - << full_class_name << "::operator[] (CORBA::ULong i) const// operator []" << be_nl + << full_class_name << "::operator[] (CORBA::ULong i) const" + << be_nl << "{" << be_idt_nl << "ACE_ASSERT (i < this->maximum_);" << be_nl << "const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* tmp = ACE_reinterpret_cast (const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* ACE_CAST_CONST,this->buffer_);" << be_nl << "return tmp[i];" << be_uidt_nl << "}" << be_nl @@ -288,11 +327,15 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // get_buffer. *os << "ACE_INLINE "; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " *" << be_nl << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " *result = 0;" << be_nl << "if (orphan == 0)" << be_nl << "{" << be_idt_nl @@ -306,7 +349,9 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "else" << be_nl << "{" << be_idt_nl << "result = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*, this->buffer_);" << be_uidt_nl << "}" << be_uidt_nl << "}" << be_nl @@ -317,7 +362,9 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "// We set the state back to default and relinquish" << be_nl << "// ownership." << be_nl << "result = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << "this->maximum_ = 0;" << be_nl << "this->length_ = 0;" << be_nl @@ -331,12 +378,16 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // get_buffer. *os << "ACE_INLINE const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *" << be_nl << full_class_name << "::get_buffer (void) const" << be_nl << "{" << be_idt_nl << "return ACE_reinterpret_cast(const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, this->buffer_);" << be_uidt_nl << "}" << be_nl << be_nl; @@ -345,7 +396,9 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) *os << "ACE_INLINE void " << be_nl << full_class_name << "::replace (CORBA::ULong max," << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *data," << be_nl << "CORBA::Boolean release)" << be_uidt_nl << "{" << be_idt_nl @@ -353,9 +406,13 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) << "this->length_ = length;" << be_nl << "if (this->buffer_ && this->release_ == 1)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<"* tmp = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* ACE_CAST_CONST, this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_uidt_nl << "}" << be_nl @@ -368,6 +425,5 @@ be_visitor_sequence_ci::gen_bounded_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp index 8bb053c1a9e..11075b2288b 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_sequence_cs.cpp @@ -21,18 +21,17 @@ #include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_bounded_sequence_cs, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_bounded_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -45,9 +44,11 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CS) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CS); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" @@ -57,55 +58,48 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) } } -// May not need variable 'pt' at all -#if 0 - // generate the class name - be_type *pt; // base types - - if (bt->node_type () == AST_Decl::NT_typedef) - { - // get the primitive base type of this typedef node - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } - else - pt = bt; -#endif /* 0 */ - const char * class_name = node->instance_name (); - static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); + + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer *os << "void " << be_nl - << full_class_name << "::_allocate_buffer (CORBA::ULong /* length */)" << be_nl - << "// allocate a buffer of the requested length. The buffer is allocated for the" << be_nl + << full_class_name << "::_allocate_buffer (CORBA::ULong /* length */)" + << be_nl + << "// allocate a buffer of the requested length. " + << "The buffer is allocated for the" << be_nl << "// right type" << be_nl << "{" << be_idt_nl << "this->buffer_ = " << class_name << "::allocbuf (" @@ -120,9 +114,13 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) << "{" << be_idt_nl << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl << "return;" << be_uidt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *, this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_nl << "this->buffer_ = 0;" << be_uidt_nl @@ -130,7 +128,8 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) << be_nl; // destructor - *os << full_class_name << "::~" << class_name << " (void) // Dtor." << be_nl + *os << full_class_name << "::~" << class_name + << " (void) // Dtor." << be_nl << "{" << be_idt_nl << "this->_deallocate_buffer ();" << be_uidt_nl << "}" << be_nl @@ -141,6 +140,5 @@ be_visitor_sequence_cs::gen_bounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp index 89fc707468b..5ac6e43cda1 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ch.cpp @@ -20,68 +20,24 @@ // ============================================================================ #include "be.h" - #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_bounded_str_sequence_ch, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_bounded_str_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_bounded_str_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // Generate the class name. - be_type *pt; - - if (bt->node_type () == AST_Decl::NT_typedef) - { - // Get the primitive base type of this typedef node. - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } - else - { - pt = bt; - } - - const char * class_name = node->instance_name (); - - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); + const char *class_name = node->instance_name (); - os->gen_ifdef_macro (class_name); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // The accept is used here the first time and if an - // error occurs, it will occur here. Later no check - // for errors will be done. - if (pt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } + os->gen_ifdef_AHETI(); + os->gen_ifdef_macro (class_name); *os << "class TAO_EXPORT_MACRO " << class_name << be_idt_nl << ": public TAO_Bounded_Base_Sequence" << be_uidt_nl @@ -156,7 +112,5 @@ be_visitor_sequence_ch::gen_bounded_str_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp index 4837f699946..910464abd10 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_ci.cpp @@ -20,59 +20,47 @@ // // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_bounded_str_sequence_ci, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_bounded_str_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_bounded_str_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "Bad element type\n"), -1); - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // first generate the static methods since they are used by others. Since @@ -241,7 +229,5 @@ be_visitor_sequence_ci::gen_bounded_str_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp index dee7d1881bd..e3fbd3a32a6 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_str_sequence_cs.cpp @@ -20,59 +20,46 @@ // // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_bounded_str_sequence_cs, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_bounded_str_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_bounded_str_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "Bad element type\n"), -1); - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer @@ -126,7 +113,5 @@ be_visitor_sequence_cs::gen_bounded_str_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp index 75654b7c89c..f9347776058 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ch.cpp @@ -18,69 +18,25 @@ // // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" +ACE_RCSID (be_visitor_sequence, + gen_bounded_wstr_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_bounded_wstr_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "Bad element type\n"), -1); - } - - // Generate the class name. - be_type *pt; - - if (bt->node_type () == AST_Decl::NT_typedef) - { - // Get the primitive base type of this typedef node. - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } - else - { - pt = bt; - } - const char * class_name = node->instance_name (); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); - // the accept is here the first time used and if an - // error occurs, it will occur here. Later no check - // for errors will be done. - if (pt->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "base type visit failed\n"), - -1); - } *os << "class TAO_EXPORT_MACRO " << class_name << be_idt_nl << ": public TAO_Bounded_Base_Sequence" << be_uidt_nl @@ -155,7 +111,5 @@ be_visitor_sequence_ch::gen_bounded_wstr_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ci.cpp index 164e72ff3c3..a8d0e7de912 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_ci.cpp @@ -18,60 +18,49 @@ // // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" +ACE_RCSID (be_visitor_sequence, + gen_bounded_wstr_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_bounded_wstr_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "visit_sequence - " - "Bad element type\n"), -1); - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); - // first generate the static methods since they are used by others. Since + // First generate the static methods since they are used by others. Since // they are inlined, their definition needs to come before their use else // some compilers (e.g., g++) produce lots of warnings. @@ -251,7 +240,5 @@ be_visitor_sequence_ci::gen_bounded_wstr_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp index d6c0170bdb2..c629ce046c5 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_bounded_wstr_sequence_cs.cpp @@ -18,28 +18,17 @@ // // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" +ACE_RCSID (be_visitor_sequence, + gen_bounded_wstr_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_bounded_wstr_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); - if (!bt) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "Bad element type\n"), -1); - } - const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; @@ -47,28 +36,26 @@ be_visitor_sequence_cs::gen_bounded_wstr_sequence (be_sequence *node) if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // get the visitor for the type of the sequence - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - // !! branching in either compile time template instantiation - // or manual template instatiation os->gen_ifdef_AHETI(); - os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer @@ -123,7 +110,5 @@ be_visitor_sequence_cs::gen_bounded_wstr_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp index d7b421b58d7..1c688940ce3 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ch.cpp @@ -21,22 +21,19 @@ // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_unbounded_obj_sequence_ch, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_unbounded_obj_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -46,8 +43,7 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) "Bad element type\n"), -1); } - // Generate the class name. - be_type *pt; + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) { @@ -60,16 +56,17 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) pt = bt; } - const char * class_name = node->instance_name (); + // Generate the class name. + const char *class_name = node->instance_name (); be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! Branching in either compile time template instantiation - // or manual template instatiation. - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); *os << "class TAO_EXPORT_MACRO " << class_name << be_idt_nl @@ -89,7 +86,7 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) << "CORBA::ULong maximum," << be_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<"* *value," << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl @@ -127,19 +124,29 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) else { be_interface *bf = be_interface::narrow_from_decl (pt); + if (bf != 0) - is_valuetype = bf->is_valuetype (); + { + is_valuetype = bf->is_valuetype (); + } else { be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); + if (bff != 0) - is_valuetype = bff->is_valuetype (); + { + is_valuetype = bff->is_valuetype (); + } } if (is_valuetype) - *os << "TAO_Valuetype_Manager<"; + { + *os << "TAO_Valuetype_Manager<"; + } else - *os << "TAO_Object_Manager<"; + { + *os << "TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -152,14 +159,14 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) // allocbuf *os << "static "; - bt->accept (visitor); + bt->accept (&visitor); *os << " **allocbuf (CORBA::ULong nelems);" << be_nl; // freebuf *os << "static void freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **buffer);" << be_nl << be_nl; @@ -173,14 +180,14 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) *os << "virtual void _deallocate_buffer (void);" << be_nl; // get_buffer - bt->accept (visitor); + bt->accept (&visitor); *os << "* *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << "* *get_buffer (void) const;" << be_nl; @@ -209,6 +216,5 @@ be_visitor_sequence_ch::gen_unbounded_obj_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp index ca6c891e885..eac4ac2698d 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_ci.cpp @@ -19,11 +19,12 @@ // Modifications by Aniruddha Gokhale // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_unbounded_obj_sequence_ci, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_unbounded_obj_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) @@ -104,14 +105,13 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !Branching in either compile time template instantiation - // or manual template instatiation. - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // allocbuf. @@ -120,7 +120,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) // The accept is here the first time used and if an // error occurs, it will occur here. Later no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -133,13 +133,13 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << full_class_name << "::allocbuf (CORBA::ULong nelems)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **buf = 0;" << be_nl << be_nl << "ACE_NEW_RETURN (buf, " ; - bt->accept (visitor); + bt->accept (&visitor); *os << "*[nelems], 0);" << be_nl << be_nl @@ -150,13 +150,19 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) int is_valuetype = 0; { be_interface *bf = be_interface::narrow_from_decl (pt); + if (bf != 0) - is_valuetype = bf->is_valuetype (); + { + is_valuetype = bf->is_valuetype (); + } else { be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); + if (bff != 0) - is_valuetype = bff->is_valuetype (); + { + is_valuetype = bff->is_valuetype (); + } } } @@ -166,7 +172,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) } else if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -184,7 +190,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) *os << "ACE_INLINE void " << be_nl << full_class_name << "::freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **buffer)" << be_nl << "{" << be_idt_nl @@ -217,7 +223,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << " (CORBA::ULong maximum," << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<"* *value," << be_nl << "CORBA::Boolean release)" << be_uidt_nl @@ -236,16 +242,16 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "if (rhs.buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **tmp1 = " << class_name << "::allocbuf (this->maximum_);" << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl @@ -261,16 +267,17 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) else { *os << "tmp1[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (tmp2[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (tmp2[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; + } } *os << be_uidt_nl @@ -295,11 +302,11 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "if (this->release_)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl << be_nl @@ -317,7 +324,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -344,19 +351,19 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "TAO_Unbounded_Base_Sequence::operator= (rhs);" << be_nl << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp1 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " **, this->buffer_);" << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" ** const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl @@ -372,17 +379,19 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) else { *os << "tmp1[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (tmp2[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (tmp2[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (tmp2[i]);"; + } } + *os << be_uidt_nl << "}" << be_uidt_nl << be_nl << "return *this;" << be_uidt_nl @@ -403,9 +412,13 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) else { if (is_valuetype) - *os << "ACE_INLINE TAO_Valuetype_Manager<"; + { + *os << "ACE_INLINE TAO_Valuetype_Manager<"; + } else - *os << "ACE_INLINE TAO_Object_Manager<"; + { + *os << "ACE_INLINE TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -416,11 +429,11 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "ACE_ASSERT (index < this->maximum_);" << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" ** const tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, this->buffer_);" << be_nl; @@ -431,9 +444,13 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) else { if (is_valuetype) - *os << "return TAO_Valuetype_Manager<"; + { + *os << "return TAO_Valuetype_Manager<"; + } else - *os << "return TAO_Object_Manager<"; + { + *os << "return TAO_Object_Manager<"; + } } *os << bt->name () << "," @@ -445,13 +462,13 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) // get_buffer *os << "ACE_INLINE "; - bt->accept(visitor); + bt->accept (&visitor); *os << "* *" << be_nl << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os << " **result = 0;" << be_nl << "if (orphan == 0)" << be_nl @@ -468,7 +485,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "{" << be_idt_nl << "result = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_uidt_nl << "}" << be_uidt_nl @@ -481,7 +498,7 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) << "// ownership." << be_nl << "result = ACE_reinterpret_cast("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**,this->buffer_);" << be_nl << "this->maximum_ = 0;" << be_nl @@ -498,14 +515,14 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) *os << "ACE_INLINE "; *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << "* *" << be_nl << full_class_name << "::get_buffer (void) const" << be_nl << "{" << be_idt_nl << "return ACE_reinterpret_cast(const "; - bt->accept (visitor); + bt->accept (&visitor); *os << " ** ACE_CAST_CONST, this->buffer_);" << be_uidt_nl << "}" << be_nl @@ -516,6 +533,5 @@ be_visitor_sequence_ci::gen_unbounded_obj_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp index b9e9880dbdd..25e0acfef31 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_obj_sequence_cs.cpp @@ -19,21 +19,18 @@ // Modifications by Aniruddha Gokhale // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_unbounded_obj_sequence_cs, "$Id$") +ACE_RCSID (be_visitor_sequence, + gen_unbounded_obj_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -57,8 +54,7 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) pt = bt; } - const char *name = - be_decl::narrow_from_decl (pt)->full_name (); + const char *name = be_decl::narrow_from_decl (pt)->full_name (); idl_bool bt_is_defined; @@ -82,13 +78,19 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) int is_valuetype = 0; { be_interface *bf = be_interface::narrow_from_decl (pt); + if (bf != 0) - is_valuetype = bf->is_valuetype (); + { + is_valuetype = bf->is_valuetype (); + } else { be_interface_fwd *bff = be_interface_fwd::narrow_from_decl (pt); + if (bff != 0) - is_valuetype = bff->is_valuetype (); + { + is_valuetype = bff->is_valuetype (); + } } } @@ -117,14 +119,13 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // Branching in either compile time template instantiation - // or manual template instatiation. - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer. @@ -135,7 +136,7 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = 0;" << be_nl << "tmp = " << class_name << "::allocbuf (length);" << be_nl @@ -143,11 +144,11 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << "if (this->buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" **old = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl @@ -164,16 +165,17 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) else { *os << "tmp[i] = "; - if (bt_is_defined) - { - bt->accept (visitor); - *os << "::_duplicate (old[i]);"; - } - else - { - *os << "tao_" << pt->flat_name () << "_duplicate (old[i]);"; - } + if (bt_is_defined) + { + bt->accept (&visitor); + + *os << "::_duplicate (old[i]);"; + } + else + { + *os << "tao_" << pt->flat_name () << "_duplicate (old[i]);"; + } } *os << be_uidt_nl @@ -199,11 +201,11 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl << "return;" << be_uidt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl @@ -220,7 +222,7 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -251,11 +253,11 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << "::_shrink_buffer (CORBA::ULong nl, CORBA::ULong ol)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" **tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, this->buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = nl; i < ol; ++i)" << be_idt_nl @@ -272,7 +274,7 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) *os << "CORBA::release (tmp[i]);" << be_nl << "tmp[i] = "; - bt->accept (visitor); + bt->accept (&visitor); *os << "::_nil ();"; } @@ -304,18 +306,18 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) << ")" << be_uidt_nl << "{" << be_idt_nl; - bt->accept (visitor); + bt->accept (&visitor); *os << " **tmp = ACE_static_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, target);" << be_nl << "*tmp = "; if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << "::_narrow (src ACE_ENV_ARG_PARAMETER);"; } @@ -331,26 +333,26 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) *os << "CORBA_Object*" << be_nl << full_class_name << "::_upcast (void *src) const" << be_nl - << "{" << be_idt_nl; + << "{" << be_idt_nl; if (bt_is_defined) { - bt->accept (visitor); + bt->accept (&visitor); *os << " **tmp = ACE_static_cast ("; - bt->accept (visitor); + bt->accept (&visitor); *os << "**, src);" << be_nl << "return *tmp;"; } else { - *os << "return tao_" << pt->flat_name () << "_upcast (src);"; + *os << "return tao_" << pt->flat_name () << "_upcast (src);"; } *os << be_uidt_nl - << "}" << be_nl; + << "}" << be_nl; } os->gen_endif (); @@ -358,6 +360,5 @@ be_visitor_sequence_cs::gen_unbounded_obj_sequence (be_sequence *node) // Generate #endif for AHETI. os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp index 7a1810b92f9..3227a4b9ae4 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ch.cpp @@ -18,22 +18,18 @@ // // ============================================================================ -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_unbounded_sequence_ch, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_unbounded_sequence_ch, + "$Id$") int be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -47,9 +43,11 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CH) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CH); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -61,15 +59,15 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) const char * class_name = node->instance_name (); - // get the visitor for the type of the sequence + // Get the visitor for the type of the sequence. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI (); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI (); os->gen_ifdef_macro (class_name); *os << "class TAO_EXPORT_MACRO " @@ -92,7 +90,7 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // The accept is used here the first time and if an // error occurs, it will occur here. Later no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -121,14 +119,14 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // Accessors *os << "// = Accessors." << be_nl; - bt->accept (visitor); + bt->accept (&visitor); *os <<" &operator[] (CORBA::ULong i);" << be_nl; // operator[] *os << "const "; - bt->accept (visitor); + bt->accept (&visitor); *os << " &operator[] (CORBA::ULong i) const;" << be_nl << be_nl; @@ -136,18 +134,19 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) *os << "// = Static operations." << be_nl << "static "; - bt->accept (visitor); + bt->accept (&visitor); *os << " *allocbuf (CORBA::ULong size);" << be_nl; *os << "static void freebuf ("; - bt->accept (visitor); + bt->accept (&visitor); *os << " *buffer);" << be_nl << be_nl; // Implement the TAO_Base_Sequence methods (see Sequence.h) - *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl; + *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" + << be_nl; // allocate_buffer *os << "virtual void _allocate_buffer (CORBA::ULong length);" << be_nl; @@ -155,12 +154,15 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // deallocate_buffer *os << "virtual void _deallocate_buffer (void);" << be_nl; - bt->accept(visitor); + bt->accept (&visitor); + *os << " *get_buffer (CORBA::Boolean orphan = 0);" << be_nl; // get_buffer *os << "const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *get_buffer (void) const;" << be_nl; // replace @@ -168,7 +170,7 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) << "CORBA::ULong max," << be_nl << "CORBA::ULong length," << be_nl; - bt->accept(visitor); + bt->accept (&visitor); *os <<" *data," << be_nl << "CORBA::Boolean release" << be_uidt_nl @@ -181,6 +183,5 @@ be_visitor_sequence_ch::gen_unbounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp index efde5904e65..f6a6d32e63a 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_ci.cpp @@ -18,39 +18,37 @@ // // ============================================================================ -//#include "idl.h" -//#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_unbounded_sequence_ci, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_unbounded_sequence_ci, + "$Id$") int be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" "visit_sequence - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } // If we contain an anonymous sequence, // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CI) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CI); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -60,12 +58,12 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) } } - // generate the class name - be_type *pt; // base types + // Generate the class name + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) { - // get the primitive base type of this typedef node + // Get the primitive base type of this typedef node. be_typedef *t = be_typedef::narrow_from_decl (bt); pt = t->primitive_base_type (); } @@ -80,27 +78,31 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } - // get the visitor for the type of the sequence + // Get the visitor for the type of the sequence. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // Static operations @@ -110,7 +112,7 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // the accept is here the first time used and if an // error occurs, it will occur here. Later no check // for errors will be done. - if (bt->accept (visitor) == -1) + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -118,14 +120,19 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) "base type visit failed\n"), -1); } + *os << " *" << be_nl << full_class_name << "::allocbuf (CORBA::ULong size)" << be_nl << "// Allocate storage for the sequence." << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *retval = 0;" << be_nl << "ACE_NEW_RETURN (retval, "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "[size], 0);" << be_nl << "return retval;" << be_uidt_nl << "}" << be_nl @@ -133,7 +140,9 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) *os << "ACE_INLINE void " << full_class_name << "::freebuf ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *buffer)" << be_nl << "// Free the sequence." << be_nl << "{" << be_idt_nl @@ -143,7 +152,8 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // constructor *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (void) // Default constructor." << be_nl + << full_class_name << "::" << class_name + << " (void) // Default constructor." << be_nl << "{" << be_nl << "}" << be_nl << be_nl; @@ -161,12 +171,16 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // constructor *os << "ACE_INLINE" << be_nl - << full_class_name << "::" << class_name << " (CORBA::ULong maximum," << be_idt_nl + << full_class_name << "::" << class_name + << " (CORBA::ULong maximum," << be_idt_nl << "CORBA::ULong length," << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *data," << be_nl << "CORBA::Boolean release)" << be_uidt_nl - << ": TAO_Unbounded_Base_Sequence (maximum, length, data, release)" << be_nl + << ": TAO_Unbounded_Base_Sequence (maximum, length, data, release)" + << be_nl << "{" << be_nl << "}" << be_nl << be_nl; @@ -180,18 +194,24 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "{" << be_idt_nl << "if (rhs.buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp1 = " << class_name << "::allocbuf (this->maximum_);" << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " * const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); *os << "_var::copy (tmp1[i], tmp2[i]);" << be_uidt_nl; } else @@ -222,9 +242,13 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "if (this->maximum_ < rhs.maximum_)" << be_nl << "{" << be_idt_nl << "// free the old buffer" << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *, this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_nl << "this->buffer_ = " << class_name @@ -237,20 +261,28 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << be_nl << "TAO_Unbounded_Base_Sequence::operator= (rhs);" << be_nl << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" *tmp1 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *, this->buffer_);" << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" * const tmp2 = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, rhs.buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); *os << "_var::copy (tmp1[i], tmp2[i]);" << be_uidt_nl; } else @@ -266,15 +298,21 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // Accessors *os << "// = Accessors." << be_nl; *os << "ACE_INLINE "; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" &" << be_nl << full_class_name << "::operator[] (CORBA::ULong i)" << be_nl << "// operator []" << be_nl << "{" << be_idt_nl << "ACE_ASSERT (i < this->maximum_);" << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<"* tmp = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << "return tmp[i];" << be_uidt_nl << "}" << be_nl @@ -282,15 +320,21 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // operator[] *os << "ACE_INLINE const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " &" << be_nl << full_class_name << "::operator[] (CORBA::ULong i) const" << be_nl << "// operator []" << be_nl << "{" << be_idt_nl << "ACE_ASSERT (i < this->maximum_);" << be_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" * const tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* ACE_CAST_CONST, this->buffer_);" << be_nl << "return tmp[i];" << be_uidt_nl << "}" << be_nl @@ -300,11 +344,15 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) *os << "// Implement the TAO_Base_Sequence methods (see Sequence.h)" << be_nl << be_nl; *os << "ACE_INLINE "; - bt->accept(visitor); + + bt->accept (&visitor); + *os << " *" << be_nl << full_class_name << "::get_buffer (CORBA::Boolean orphan)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *result = 0;" << be_nl << "if (orphan == 0)" << be_nl << "{" << be_idt_nl @@ -318,7 +366,9 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "else" << be_nl << "{" << be_idt_nl << "result = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*, this->buffer_);" << be_uidt_nl << "}" << be_uidt_nl << "}" << be_nl @@ -329,7 +379,9 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "// We set the state back to default and relinquish" << be_nl << "// ownership." << be_nl << "result = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << "this->maximum_ = 0;" << be_nl << "this->length_ = 0;" << be_nl @@ -343,12 +395,16 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // get_buffer *os << "ACE_INLINE const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *" << be_nl << full_class_name << "::get_buffer (void) const" << be_nl << "{" << be_idt_nl << "return ACE_reinterpret_cast(const "; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " * ACE_CAST_CONST, this->buffer_);" << be_uidt_nl << "}" << be_nl << be_nl; @@ -357,7 +413,9 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) *os << "ACE_INLINE void" << be_nl << full_class_name << "::replace (CORBA::ULong max," << be_nl << "CORBA::ULong length," << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *data," << be_nl << "CORBA::Boolean release)" << be_nl << "{" << be_idt_nl @@ -365,9 +423,13 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) << "this->length_ = length;" << be_nl << "if (this->buffer_ && this->release_ == 1)" << be_nl << "{" << be_idt_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "*,this->buffer_);" << be_nl << class_name << "::freebuf (tmp);" << be_uidt_nl << "}" << be_nl @@ -380,6 +442,5 @@ be_visitor_sequence_ci::gen_unbounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp index 4fe9def4d30..c8828556951 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/gen_unbounded_sequence_cs.cpp @@ -18,24 +18,19 @@ // // ============================================================================ -//#include "idl.h" -//#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, gen_unbounded_sequence_cs, "$Id$") - +ACE_RCSID (be_visitor_sequence, + gen_unbounded_sequence_cs, + "$Id$") int be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -48,9 +43,11 @@ be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) // generate code for that sequence here. if (bt->node_type () == AST_Decl::NT_sequence) { - if (this->gen_anonymous_base_type (bt, - TAO_CodeGen::TAO_SEQUENCE_CS) - == -1) + int status = + this->gen_anonymous_base_type (bt, + TAO_CodeGen::TAO_SEQUENCE_CS); + + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" @@ -60,69 +57,83 @@ be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) } } - // generate the class name - be_type *pt; // base types + // Generate the class name. + be_type *pt; if (bt->node_type () == AST_Decl::NT_typedef) - { - // get the primitive base type of this typedef node - be_typedef *t = be_typedef::narrow_from_decl (bt); - pt = t->primitive_base_type (); - } + { + // Get the primitive base type of this typedef node. + be_typedef *t = be_typedef::narrow_from_decl (bt); + pt = t->primitive_base_type (); + } else - pt = bt; - + { + pt = bt; + } const char * class_name = node->instance_name (); static char full_class_name [NAMEBUFSIZE]; - ACE_OS::memset (full_class_name, '\0', NAMEBUFSIZE); + ACE_OS::memset (full_class_name, + '\0', + NAMEBUFSIZE); if (node->is_nested ()) { - ACE_OS::sprintf (full_class_name, "%s::%s", - be_scope::narrow_from_scope (node->defined_in ())->decl ()->full_name (), + be_decl *tmp = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + + ACE_OS::sprintf (full_class_name, + "%s::%s", + tmp->full_name (), class_name); } else { - ACE_OS::sprintf (full_class_name, "%s", + ACE_OS::sprintf (full_class_name, + "%s", class_name); } - // get the visitor for the type of the sequence + // Get the visitor for the type of the sequence. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_base visitor (&ctx); - // !! branching in either compile time template instantiation - // or manual template instatiation - os->gen_ifdef_AHETI(); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); os->gen_ifdef_macro (class_name); - os->indent (); // allocate_buffer *os << "void" << be_nl << full_class_name << "::_allocate_buffer (CORBA::ULong length)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os << "* tmp = 0;" << be_nl << "tmp = " << class_name << "::allocbuf (length);" << be_nl << be_nl << "if (this->buffer_ != 0)" << be_nl << "{" << be_idt_nl; - bt->accept (visitor); + + bt->accept (&visitor); + *os <<" *old = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *,this->buffer_);" << be_nl << be_nl << "for (CORBA::ULong i = 0; i < this->length_; ++i)" << be_idt_nl; if (pt->node_type () == AST_Decl::NT_array) { - bt->accept (visitor); + bt->accept (&visitor); + *os << "_var::copy (tmp[i], old[i]);" << be_uidt_nl; } else @@ -145,9 +156,13 @@ be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) << "if (this->buffer_ == 0 || this->release_ == 0)" << be_idt_nl << "return;" << be_uidt_nl << be_nl; - bt->accept(visitor); + + bt->accept (&visitor); + *os <<" *tmp = ACE_reinterpret_cast ("; - bt->accept (visitor); + + bt->accept (&visitor); + *os << " *,this->buffer_);" << be_nl << be_nl << class_name << "::freebuf (tmp);" << be_nl @@ -167,6 +182,5 @@ be_visitor_sequence_cs::gen_unbounded_sequence (be_sequence *node) // generate #endif for AHETI os->gen_endif_AHETI(); - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp index c5c3cdb1cde..12fb8b09564 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ch.cpp @@ -21,10 +21,11 @@ #include "idl.h" #include "idl_extern.h" #include "be.h" - #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, sequence_ch, "$Id$") +ACE_RCSID (be_visitor_sequence, + sequence_ch, + "$Id$") // Root visitor for client header. @@ -41,23 +42,20 @@ int be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt = 0; - - // Retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (bt == 0) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // !! Branching in either compile time template instantiation - // or manual template instatiation. os->gen_ifdef_AHETI (); // This is the instantiation branch. @@ -150,15 +148,12 @@ be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) break; } - be_visitor_context *ctx = 0; - ACE_NEW_RETURN (ctx, - be_visitor_context (*this->ctx_), - 0); + be_visitor_context ctx (*this->ctx_); - be_visitor_sequence_base_template_args visitor (ctx, + be_visitor_sequence_base_template_args visitor (&ctx, node); - ctx->state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); + ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CH); if (bt->accept (&visitor) == -1) { @@ -188,7 +183,7 @@ be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) *os << ", "; // So the call to nested_type_name will have "_var" suffix. - ctx->sub_state (TAO_CodeGen::TAO_ARRAY_SEQ_CH_TEMPLATE_VAR); + ctx.sub_state (TAO_CodeGen::TAO_ARRAY_SEQ_CH_TEMPLATE_VAR); if (bt->accept (&visitor) == -1) { @@ -199,7 +194,7 @@ be_visitor_sequence_ch::gen_base_sequence_class (be_sequence *node) -1); } - ctx->sub_state (TAO_CodeGen::TAO_SUB_STATE_UNKNOWN); + ctx.sub_state (TAO_CodeGen::TAO_SUB_STATE_UNKNOWN); } if (node->unbounded ()) @@ -228,7 +223,8 @@ be_visitor_sequence_ch::instantiate_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "gen_instantiate_template_name - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } // Generate the appropriate sequence type. @@ -342,7 +338,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "codegen. for the primitive type sequence\n"), -1); + "codegen. for the primitive type sequence\n"), + -1); } // End of instantiation. @@ -415,18 +412,9 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) // Generate the base type for the buffer. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_buffer_type bt_visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "visit_sequence - " - "Bad visitor\n"), - -1); - } - - if (bt->accept (visitor) == -1) + if (bt->accept (&bt_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" @@ -435,8 +423,6 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) -1); } - delete visitor; - *os << " *buffer, " << be_nl << "CORBA::Boolean release = 0" << be_uidt_nl << ");" << be_uidt_nl; @@ -507,7 +493,8 @@ int be_visitor_sequence_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } os->gen_endif (); @@ -538,7 +525,6 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); char namebuf [NAMEBUFSIZE]; - be_type *bt = 0; ACE_OS::memset (namebuf, '\0', @@ -555,7 +541,7 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) << be_nl << be_nl; // Retrieve base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { @@ -635,17 +621,9 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) // Overloaded [] operators. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_elemtype sr_visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_var_defn - " - "Bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_sequence::" @@ -690,7 +668,7 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) { *os << "const "; - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_sequence::" @@ -702,8 +680,6 @@ be_visitor_sequence_ch::gen_var_defn (be_sequence *node) *os << " operator[] (CORBA::ULong index) const;" << be_nl; } - delete visitor; - *os << be_nl; *os << "// in, inout, out, _retn " << be_nl; @@ -734,7 +710,6 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); char namebuf [NAMEBUFSIZE]; - be_type *bt = 0; ACE_OS::memset (namebuf, '\0', @@ -744,7 +719,7 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) node->local_name ()->get_string ()); // Retrieve base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); if (bt == 0) { @@ -794,17 +769,9 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) // required be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_elemtype sr_visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ch::" - "gen_out_defn - " - "Bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_sequence::" @@ -813,16 +780,12 @@ be_visitor_sequence_ch::gen_out_defn (be_sequence *node) -1); } - delete visitor; - *os << " operator[] (CORBA::ULong index);" << be_uidt_nl << be_nl; *os << "private:" << be_idt_nl; - *os << node->local_name () << " *&ptr_;" << be_nl; *os << "// Assignment from T_var not allowed." << be_nl; *os << "void operator= (const " << node->local_name () << "_var &);" << be_uidt_nl; - *os << "};" << be_nl << be_nl; return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ci.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ci.cpp index 8b902e3326c..b1f113a6c4e 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_ci.cpp @@ -21,14 +21,15 @@ #include "idl.h" #include "idl_extern.h" #include "be.h" - #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, sequence_ci, "$Id$") +ACE_RCSID (be_visitor_sequence, + sequence_ci, + "$Id$") // *********************************************************** -// sequence visitor for inline generation +// Sequence visitor for inline generation. // *********************************************************** @@ -76,7 +77,8 @@ be_visitor_sequence_ci::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" "visit_sequence - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } if (this->gen_out_impl (node) == -1) @@ -84,7 +86,8 @@ be_visitor_sequence_ci::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" "visit_sequence - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } // Generate the endif macro for the sequence type. @@ -106,7 +109,8 @@ be_visitor_sequence_ci::instantiate_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "gen_instantiate_template_name - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } // Generate the appropriate sequence type. @@ -219,12 +223,16 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" "visit_sequence - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } // Generate the var implementation in the inline file. os->indent (); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// *************************************************************" << be_nl; *os << "// Inline operations for class " << fname << be_nl; @@ -234,11 +242,11 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) // Default constuctor. *os << "ACE_INLINE" << be_nl << fname << "::" << lname - << " (void) // default constructor" << be_nl + << " (void)" << be_nl << " " << ": ptr_ (0)" << be_nl << "{}" << be_nl << be_nl; - // Constuctorr from a _ptr. + // Constuctor from a _ptr. *os << "ACE_INLINE" << be_nl; *os << fname << "::" << lname << " (" << node->local_name () << " *p)" << be_nl; @@ -248,7 +256,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) // Copy constructor. *os << "ACE_INLINE" << be_nl; *os << fname << "::" << lname << " (const ::" << fname - << " &p) // copy constructor" << be_nl; + << " &p)" << be_nl; *os << "{" << be_idt_nl; *os << "if (p.ptr_)" << be_idt_nl; *os << "ACE_NEW (this->ptr_, ::" << node->name () @@ -272,7 +280,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) // Destructor. *os << "ACE_INLINE" << be_nl; - *os << fname << "::~" << lname << " (void) // destructor" << be_nl; + *os << fname << "::~" << lname << " (void)" << be_nl; *os << "{" << be_idt_nl; *os << "delete this->ptr_;" << be_uidt_nl; *os << "}" << be_nl << be_nl; @@ -388,17 +396,9 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "gen_var_impl - " - "Bad visitor\n"), -1); - } + be_visitor_sequence_elemtype sr_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -448,7 +448,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) // Const. *os << "ACE_INLINE const "; - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -463,7 +463,7 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) *os << "return ACE_const_cast (const "; - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -477,8 +477,6 @@ be_visitor_sequence_ci::gen_var_impl (be_sequence *node) *os << "}" << be_nl << be_nl; } - delete visitor; - // in, inout, out, and _retn. *os << "ACE_INLINE const ::" << node->name () << " &" << be_nl; *os << fname << "::in (void) const" << be_nl; @@ -527,11 +525,21 @@ be_visitor_sequence_ci::gen_out_impl (be_sequence *node) char lname [NAMEBUFSIZE]; - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_out", node->full_name ()); + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); + + ACE_OS::sprintf (fname, + "%s_out", + node->full_name ()); + + ACE_OS::memset (lname, + '\0', + NAMEBUFSIZE); - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_out", node->local_name ()->get_string ()); + ACE_OS::sprintf (lname, + "%s_out", + node->local_name ()->get_string ()); // Retrieve base type. be_type *bt = be_type::narrow_from_decl (node->base_type ()); @@ -548,6 +556,9 @@ be_visitor_sequence_ci::gen_out_impl (be_sequence *node) os->indent (); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// *************************************************************" << be_nl; *os << "// Inline operations for class " << fname << be_nl; @@ -629,17 +640,9 @@ be_visitor_sequence_ci::gen_out_impl (be_sequence *node) be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQELEM_RETTYPE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_elemtype sr_visitor (&ctx); - if (visitor == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_ci::" - "gen_out_impl - " - "Bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) + if (bt->accept (&sr_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ci::" @@ -648,8 +651,6 @@ be_visitor_sequence_ci::gen_out_impl (be_sequence *node) -1); } - delete visitor; - *os << be_nl; *os << fname << "::operator[] (CORBA::ULong index)" << be_nl; *os << "{" << be_idt_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp index e02b632b837..fb10bec42ae 100644 --- a/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_sequence/sequence_cs.cpp @@ -18,13 +18,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_sequence.h" -ACE_RCSID(be_visitor_sequence, sequence_cs, "$Id$") +ACE_RCSID (be_visitor_sequence, + sequence_cs, + "$Id$") // ************************************************************ @@ -40,35 +41,32 @@ be_visitor_sequence_cs::~be_visitor_sequence_cs (void) { } -// XXXASG - this method is same as that in the _ch visitor. So we need some -// abstraction for this - int be_visitor_sequence_cs::gen_base_sequence_class (be_sequence *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - - // retrieve the base type since we may need to do some code - // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" "gen_base_sequence_class - " - "Bad element type\n"), -1); + "Bad element type\n"), + -1); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + os->gen_ifdef_AHETI(); - // this is the instantiation branch + // This is the instantiation branch. *os << node->instance_name (); os->gen_else_AHETI(); - // generate the appropriate sequence type + // Generate the appropriate sequence type. switch (node->managed_type ()) { case be_sequence::MNG_OBJREF: @@ -119,12 +117,10 @@ be_visitor_sequence_cs::gen_base_sequence_class (be_sequence *node) break; } - be_visitor_context *ctx; - ACE_NEW_RETURN (ctx, - be_visitor_context (*this->ctx_), - 0); - be_visitor_sequence_base_template_args visitor (ctx,node); - ctx->state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); + be_visitor_context ctx (*this->ctx_); + be_visitor_sequence_base_template_args visitor (&ctx, + node); + ctx.state (TAO_CodeGen::TAO_SEQUENCE_BASE_CS); if (bt->accept (&visitor) == -1) { @@ -135,7 +131,7 @@ be_visitor_sequence_cs::gen_base_sequence_class (be_sequence *node) -1); } - // find out if the sequence is of a managed type and if it is bounded or not + // Find out if the sequence is of a managed type and if it is bounded or not. if (node->managed_type () == be_sequence::MNG_STRING || node->managed_type () == be_sequence::MNG_WSTRING) { @@ -181,33 +177,31 @@ be_visitor_sequence_cs::gen_base_sequence_class (be_sequence *node) int be_visitor_sequence_cs::visit_sequence (be_sequence *node) { - // generate the constructors - be_type *bt; // type node TAO_OutStream *os = this->ctx_->stream (); if (node->cli_stub_gen () || node->imported ()) - return 0; - - // instantiation + { + return 0; + } if (this->instantiate_sequence (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_ch::" "visit_sequence - " - "codegen. for the primitive type sequence\n"), -1); + "codegen. for the primitive type sequence\n"), + -1); } - // end of instantiation - - // generate the ifdefined macro for the sequence type + // Generate the ifdefined macro for the sequence type. os->gen_ifdef_macro (node->flat_name ()); os->indent (); // start with the current indentation level - // retrieve the base type since we may need to do some code + // Retrieve the base type since we may need to do some code // generation for the base type. - bt = be_type::narrow_from_decl (node->base_type ()); + be_type *bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -216,6 +210,9 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) "Bad element type\n"), -1); } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// *************************************************************" << be_nl << "// " << node->name () << be_nl @@ -249,24 +246,19 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) // constructor with the buffer *os << node->name () << "::" << node->local_name () << " ("; + if (node->unbounded ()) { *os << "CORBA::ULong max, "; // unbounded seq takes this extra parameter } + *os << "CORBA::ULong length, "; // generate the base type for the buffer be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_SEQUENCE_BUFFER_TYPE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_sequence_cs::" - "visit_sequence - " - "Bad visitor\n"), -1); - } + be_visitor_sequence_buffer_type bt_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&bt_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" @@ -274,48 +266,56 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) "base type visit failed\n"), -1); } - delete visitor; + *os << " *buffer, CORBA::Boolean release)" << be_nl << " : "; - // pass it to the base constructor + + // Pass it to the base constructor. if (this->gen_base_sequence_class (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" "visit_sequence - " - "codegen for base sequence class\n"), -1); + "codegen for base sequence class\n"), + -1); } + *os << " ("; + if (node->unbounded ()) { *os << "max, "; } + *os << "length, buffer, release)" << be_nl << "{}" << be_nl; - // copy constructor + // Copy constructor. *os << node->name () << "::" << node->local_name () << " (const " << node->local_name () << " &seq) // copy ctor" << be_nl << " : "; - // pass it to the base constructor + + // Pass it to the base constructor. if (this->gen_base_sequence_class (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_sequence_cs::" "visit_sequence - " - "codegen for base sequence class\n"), -1); + "codegen for base sequence class\n"), + -1); } + *os << " (seq)" << be_nl << "{}" << be_nl; - // destructor + // Destructor. *os << node->name () << "::~" << node->local_name () << " (void) // dtor" << be_nl << "{}" << be_nl - << "void " - << node->name () << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl + << node->name () << "::_tao_any_destructor (void *_tao_void_pointer)" + << be_nl << "{" << be_idt_nl << node->local_name () << " *tmp = ACE_static_cast (" << node->local_name () << "*, _tao_void_pointer);" << be_nl @@ -331,9 +331,8 @@ int be_visitor_sequence_cs::visit_sequence (be_sequence *node) int be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) { - be_type *bt; + be_type *bt = be_type::narrow_from_decl (node->base_type ()); - bt = be_type::narrow_from_decl (node->base_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -342,35 +341,43 @@ be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) "Bad element type\n"), -1); } - // generate the appropriate sequence type + // Generate the appropriate sequence type. switch (node->managed_type ()) { case be_sequence::MNG_PSEUDO: case be_sequence::MNG_OBJREF: case be_sequence::MNG_VALUE: if (node->unbounded ()) - this->gen_unbounded_obj_sequence (node); + { + this->gen_unbounded_obj_sequence (node); + } else - this->gen_bounded_obj_sequence (node); + { + this->gen_bounded_obj_sequence (node); + } + break; - case be_sequence::MNG_STRING: // sequence of strings + case be_sequence::MNG_STRING: if (!node->unbounded ()) - this->gen_bounded_str_sequence (node); - // else - // inheriting from the right class is enough + { + this->gen_bounded_str_sequence (node); + } + break; - case be_sequence::MNG_WSTRING: // sequence of strings + case be_sequence::MNG_WSTRING: if (!node->unbounded ()) - this->gen_bounded_wstr_sequence (node); - // else - // inheriting from the right class is enough + { + this->gen_bounded_wstr_sequence (node); + } + break; - default: // not a managed type + default: if (node->unbounded ()) { // TAO provides extensions for octet sequences, first find out - // if the base type is an octet (or an alias for octet) + // if the base type is an octet (or an alias for octet). be_predefined_type *predef = 0; + if (bt->base_node_type () == AST_Type::NT_pre_defined) { be_typedef* alias = @@ -389,6 +396,7 @@ be_visitor_sequence_cs::instantiate_sequence (be_sequence *node) ); } } + if (predef != 0) { if (predef->pt() != AST_PredefinedType::PT_octet) diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp index 518345c6d28..532392cf184 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure.cpp @@ -18,16 +18,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_structure.h" +#include "be_visitor_field.h" -ACE_RCSID(be_visitor_structure, structure, "$Id$") +ACE_RCSID (be_visitor_structure, + structure, + "$Id$") -// generic struct visitor be_visitor_structure::be_visitor_structure (be_visitor_context *ctx) : be_visitor_scope (ctx) { @@ -37,74 +36,83 @@ be_visitor_structure::~be_visitor_structure (void) { } -// visit the Structure node and its scope int be_visitor_structure::visit_structure (be_structure *) { - return -1; // must be overriden + return -1; // Must be overriden. } int be_visitor_structure::visit_field (be_field *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_STRUCT_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CH); + be_visitor_field_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CI); + be_visitor_field_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CS); + be_visitor_field_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CH); + be_visitor_field_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CI); + be_visitor_field_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_STRUCT_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_FIELD_CDR_OP_CS); + be_visitor_field_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure::" "visit_field - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure::" "visit_field - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure::" - "visit_field - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp index 5f85d0f3954..253488143cf 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure_ch.cpp @@ -18,13 +18,13 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_structure.h" +#include "be_visitor_typecode/typecode_decl.h" -ACE_RCSID(be_visitor_structure, structure_ch, "$Id$") +ACE_RCSID (be_visitor_structure, + structure_ch, + "$Id$") // ****************************************************** @@ -111,20 +111,18 @@ int be_visitor_structure_ch::visit_structure (be_structure *node) << node->local_name () << "_out;" << be_nl << be_nl; } - if (!node->is_local ()) + if (be_global->tc_support ()) { - be_visitor *visitor; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_typecode_decl visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure_ch::" "visit_structure - " - "TypeCode declaration failed\n" - ), + "TypeCode declaration failed\n"), -1); } } diff --git a/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp b/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp index de509e4ae97..73c0855247c 100644 --- a/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_structure/structure_cs.cpp @@ -18,18 +18,19 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_structure.h" +#include "be_visitor_typecode/typecode_defn.h" -ACE_RCSID(be_visitor_structure, structure_cs, "$Id$") +ACE_RCSID (be_visitor_structure, + structure_cs, + "$Id$") // *************************************************************************** -// for client stubs +// For client stubs. // *************************************************************************** + be_visitor_structure_cs::be_visitor_structure_cs (be_visitor_context *ctx) : be_visitor_structure (ctx) { @@ -39,51 +40,53 @@ be_visitor_structure_cs::~be_visitor_structure_cs (void) { } -// visit the structure node and its scope int be_visitor_structure_cs::visit_structure (be_structure *node) { if (!node->cli_stub_gen () && !node->imported () && !node->is_local ()) { - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - be_visitor *visitor; - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (be_global->tc_support ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure_cs::" - "visit_structure - " - "TypeCode definition failed\n" - ), -1); + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); + ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); + be_visitor_typecode_defn visitor (&ctx); + + if (visitor.visit_structure (node) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_structure_cs::" + "visit_structure - " + "TypeCode definition failed\n"), + -1); + } } TAO_OutStream *os = this->ctx_->stream (); os->indent (); - if (!node->is_local ()) - *os << "void " - << node->name () - << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl - << "{" << be_idt_nl - << node->local_name () << " *tmp = ACE_static_cast (" - << node->local_name () << "*, _tao_void_pointer);" << be_nl - << "delete tmp;" << be_uidt_nl - << "}\n\n"; - // do any code generation required for the scope members - // all we have to do is to visit the scope + *os << "void " + << node->name () + << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl + << "{" << be_idt_nl + << node->local_name () << " *tmp = ACE_static_cast (" + << node->local_name () << "*, _tao_void_pointer);" << be_nl + << "delete tmp;" << be_uidt_nl + << "}\n\n"; + + // Do any code generation required for the scope members + // all we have to do is to visit the scope. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_structure_cs::" "visit_structure - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } + node->cli_stub_gen (I_TRUE); } return 0; + } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp index 26c232861b3..ef18630ad24 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/typedef.cpp @@ -18,17 +18,21 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_typedef.h" +#include "be_visitor_array.h" +#include "be_visitor_enum.h" +#include "be_visitor_sequence.h" +#include "be_visitor_structure.h" +#include "be_visitor_union.h" -ACE_RCSID(be_visitor_typedef, typedef, "$Id$") +ACE_RCSID (be_visitor_typedef, + typedef, + "$Id$") // ****************************************************** -// Generic Typedef visitor +// Generic typedef visitor. // ****************************************************** be_visitor_typedef::be_visitor_typedef (be_visitor_context *ctx) @@ -40,123 +44,156 @@ be_visitor_typedef::~be_visitor_typedef (void) { } -// visit the Typedef node and its scope int be_visitor_typedef::visit_typedef (be_typedef *) { - return -1; // must be overridden + return -1; // Must be overridden. } -// =all common visit methods for typedef visitor +// All common visit methods for typedef visitor. -// visit a array int be_visitor_typedef::visit_array (be_array *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_ARRAY_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CH); + be_visitor_array_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_ARRAY_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CI); + be_visitor_array_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_ARRAY_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CS); + be_visitor_array_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CH); + be_visitor_array_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_ANY_OP_CS); + be_visitor_array_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); + be_visitor_array_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CI); + be_visitor_array_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CS); + be_visitor_array_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_array - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_array - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_array - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -//visit an enum int be_visitor_typedef::visit_enum (be_enum *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; case TAO_CodeGen::TAO_TYPEDEF_CI: return 0; // nothing to be done default: @@ -164,137 +201,150 @@ be_visitor_typedef::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_enum - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_enum - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_enum - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an predefined type int be_visitor_typedef::visit_predefined_type (be_predefined_type *) { return 0; } -// visit an sequence int be_visitor_typedef::visit_sequence (be_sequence *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); + be_visitor_sequence_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); + be_visitor_sequence_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); + be_visitor_sequence_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CH); + be_visitor_sequence_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_ANY_OP_CS); + be_visitor_sequence_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); + be_visitor_sequence_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CI); + be_visitor_sequence_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS); + be_visitor_sequence_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_sequence - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_sequence - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_sequence - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an structure int be_visitor_typedef::visit_string (be_string *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: @@ -306,31 +356,20 @@ be_visitor_typedef::visit_string (be_string *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_string - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_string - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_string - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } @@ -338,142 +377,177 @@ be_visitor_typedef::visit_string (be_string *node) int be_visitor_typedef::visit_structure (be_structure *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_structure - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_structure - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_structure - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } -// visit an union int be_visitor_typedef::visit_union (be_union *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_TYPEDEF_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_union - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef::" "visit_union - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typedef::" - "visit_union - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp index 76c9f997b42..a53e9fba5b9 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_ch.cpp @@ -18,13 +18,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_typedef.h" +#include "be_visitor_typecode/typecode_decl.h" -ACE_RCSID(be_visitor_typedef, typedef_ch, "$Id$") +ACE_RCSID(be_visitor_typedef, + typedef_ch, + "$Id$") // ****************************************************** @@ -83,8 +85,7 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad primitive base type\n" - ), + "bad primitive base type\n"), -1); } @@ -94,8 +95,7 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), + "failed to accept visitor\n"), -1); } @@ -115,9 +115,8 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad base type\n" - ), - -1); + "bad base type\n"), + -1); } // accept on this base type, but generate code for the typedef node. @@ -126,28 +125,23 @@ be_visitor_typedef_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), - -1); + "failed to accept visitor\n"), + -1); } // Generate the typecode decl for this typedef node. - // @@ NW: !bt->is_local () is a hack. There should be a way to - // propagate bt's info up to typedef. - if (!node->imported () && !node->is_local () && !bt->is_local ()) + if (!node->imported () && be_global->tc_support ()) { - be_visitor *visitor; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_typecode_decl visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "TypeCode declaration failed\n" - ), + "TypeCode declaration failed\n"), -1); } } diff --git a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_cs.cpp b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_cs.cpp index df7fa65c2a6..1b049984fa8 100644 --- a/TAO/TAO_IDL/be/be_visitor_typedef/typedef_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typedef/typedef_cs.cpp @@ -18,13 +18,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_typedef.h" +#include "be_visitor_typecode/typecode_defn.h" -ACE_RCSID(be_visitor_typedef, typedef_cs, "$Id$") +ACE_RCSID (be_visitor_typedef, + typedef_cs, + "$Id$") // ****************************************************** @@ -68,82 +70,82 @@ be_visitor_typedef_cs::visit_typedef (be_typedef *node) if (this->ctx_->tdef ()) { - // the fact that we are here indicates that we were generating code for a + // The fact that we are here indicates that we were generating code for a // typedef node whose base type also happens to be another typedef-ed - // (i.e. an alias) node for another (possibly alias) node + // (i.e. an alias) node for another (possibly alias) node. this->ctx_->alias (node); // save this alias - // grab the most primitive base type in the chain to avoid recusrsively - // going thru this visit method + // Grab the most primitive base type in the chain to avoid recusrsively + // going thru this visit method. bt = node->primitive_base_type (); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad primitive base type\n" - ), -1); + "bad primitive base type\n"), + -1); } - // accept on this base type + // Accept on this base type. if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + this->ctx_->alias (0); } else { - // the context has not stored any "tdef" node. So we must be in here for - // the first time - this->ctx_->tdef (node); // save the typedef node + // The context has not stored any "tdef" node. So we must be in here for + // the first time. + this->ctx_->tdef (node); - // grab the immediate base type node + // Grab the immediate base type node. bt = be_type::narrow_from_decl (node->base_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "bad base type\n" - ), -1); + "bad base type\n"), + -1); } - // accept on this base type + + // Accept on this base type. if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_ch::" "visit_typedef - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // @@ NW: !bt->is_local () is a hack. There should be a way to - // propagate bt's info up to typedef. - if (!node->imported () && !node->is_local () && !bt->is_local ()) + if (!node->imported () && be_global->tc_support ()) { - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - be_visitor *visitor; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + be_visitor_typecode_defn visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typedef_cs::" "visit_typedef - " - "TypeCode definition failed\n" - ), -1); + "TypeCode definition failed\n"), + -1); } } + this->ctx_->tdef (0); } diff --git a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp index 8995f570b1e..0d363f8164b 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/discriminant_ch.cpp @@ -18,17 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union.h" +#include "be_visitor_enum/enum_ch.h" -ACE_RCSID(be_visitor_union, discriminant_ch, "$Id$") +ACE_RCSID (be_visitor_union, + discriminant_ch, + "$Id$") // ************************************************************************* -// be_visitor_discriminant_ch - visitor for discriminant in client header file +// Visitor for discriminant in client header file. // ************************************************************************* be_visitor_union_discriminant_ch::be_visitor_union_discriminant_ch @@ -71,27 +71,16 @@ be_visitor_union_discriminant_ch::visit_enum (be_enum *node) // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_discriminant_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } + be_visitor_enum_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_discriminant_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - - delete visitor; } // The set method. @@ -143,8 +132,8 @@ be_visitor_union_discriminant_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_discriminant_ch::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); diff --git a/TAO/TAO_IDL/be/be_visitor_union/discriminant_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/discriminant_cs.cpp index 79f75f66a28..3b067c12b9c 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/discriminant_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/discriminant_cs.cpp @@ -18,21 +18,22 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union.h" +#include "be_visitor_enum/enum_cs.h" -ACE_RCSID(be_visitor_union, discriminant_cs, "$Id$") +ACE_RCSID (be_visitor_union, + discriminant_cs, + "$Id$") // ************************************************************************* -// be_visitor_discriminant_cs - visitor for discriminant in client stubs +// Visitor for discriminant in client stubs. // ************************************************************************* -be_visitor_union_discriminant_cs::be_visitor_union_discriminant_cs -(be_visitor_context *ctx) +be_visitor_union_discriminant_cs::be_visitor_union_discriminant_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -48,41 +49,33 @@ be_visitor_union_discriminant_cs::visit_enum (be_enum *node) this->ctx_->be_node_as_union (); // get the enclosing union backend be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) bt = this->ctx_->alias (); else bt = node; - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); // generate the typecode for the enum ctx.state (TAO_CodeGen::TAO_ENUM_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_discriminant_cs::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_discriminant_cs::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union/union.cpp b/TAO/TAO_IDL/be/be_visitor_union/union.cpp index 2b04aff5d46..e06edf10dda 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union.cpp @@ -18,16 +18,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union.h" +#include "be_visitor_union_branch.h" -ACE_RCSID(be_visitor_union, union, "$Id$") +ACE_RCSID (be_visitor_union, + union, + "$Id$") -// generic struct visitor be_visitor_union::be_visitor_union (be_visitor_context *ctx) : be_visitor_scope (ctx) { @@ -37,86 +36,111 @@ be_visitor_union::~be_visitor_union (void) { } -// visit the Union node and its scope int be_visitor_union::visit_union (be_union *) { - return -1; // must be overriden + return -1; // Must be overriden. } int be_visitor_union::visit_union_branch (be_union_branch *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Instantiate a visitor context with a copy of our context. This info + // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + ctx.node (node); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_UNION_PUBLIC_CH: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CH); + be_visitor_union_branch_public_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PRIVATE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); + be_visitor_union_branch_private_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PUBLIC_CI: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CI); + be_visitor_union_branch_public_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PUBLIC_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_CS); + be_visitor_union_branch_public_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); + be_visitor_union_branch_public_assign_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS); + be_visitor_union_branch_public_reset_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_PUBLIC_ACCESS_CS: - ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_ACCESS_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_PUBLIC_ACCESS_CS); + be_visitor_union_branch_public_access_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CH); + be_visitor_union_branch_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CI); + be_visitor_union_branch_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_UNION_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_BRANCH_CDR_OP_CS); + be_visitor_union_branch_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union::" "visit_union_branch - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union::" "visit_union_branch - " - "NUL visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } - // let the node accept this visitor - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union::" - "visit_union_branch - " - "failed to accept visitor\n" - ), -1); - } - delete visitor; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp index 5475cc456fc..c840cdc11e6 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_ch.cpp @@ -18,17 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union.h" +#include "be_visitor_typecode/typecode_decl.h" -ACE_RCSID(be_visitor_union, union_ch, "$Id$") +ACE_RCSID (be_visitor_union, + union_ch, + "$Id$") // ****************************************************** -// for client header +// For client header. // ****************************************************** be_visitor_union_ch::be_visitor_union_ch (be_visitor_context *ctx) @@ -40,12 +40,8 @@ be_visitor_union_ch::~be_visitor_union_ch (void) { } -// Visit the Union node and its scope. int be_visitor_union_ch::visit_union (be_union *node) { - TAO_OutStream *os; - be_type *bt; - // Instantiate a visitor context with a copy of our context. This info // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); @@ -53,7 +49,7 @@ int be_visitor_union_ch::visit_union (be_union *node) if (!node->cli_hdr_gen () && !node->imported ()) { - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); // Generate the ifdefined macro for the union type. os->gen_ifdef_macro (node->flat_name ()); @@ -73,51 +69,40 @@ int be_visitor_union_ch::visit_union (be_union *node) // Generate destructor. << "~" << node->local_name () << " (void);" << be_nl; - if (!node->is_local ()) - { - *os << "static void _tao_any_destructor (void*);" - << be_nl << be_nl; - } + *os << "static void _tao_any_destructor (void*);" + << be_nl << be_nl; // Generate assignment operator. *os << node->local_name () << " &operator= (const " << node->local_name () << " &);" << be_nl << be_nl; // Retrieve the disriminant type. - bt = be_type::narrow_from_decl (node->disc_type ()); + be_type *bt = be_type::narrow_from_decl (node->disc_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ch::" "visit_union - " - "bad disciminant type\n"), -1); + "bad disciminant type\n"), + -1); } // The discriminant type may have to be defined here if it was an enum // declaration inside of the union statement. ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_union_discriminant_ch ud_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ch::" - "visit_union - " - "bad visitor\n"), -1); - } - - if (bt->accept (visitor) == -1) + if (bt->accept (&ud_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ch::" " visit_union - " - "codegen for discriminant failed\n"), -1); + "codegen for discriminant failed\n"), + -1); } - delete visitor; - // Generate the _var_type typedef // but we must protect against certain versions of g++. *os << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" @@ -168,6 +153,7 @@ int be_visitor_union_ch::visit_union (be_union *node) // The members are inside of a union. *os << "union" << be_nl; *os << "{" << be_idt_nl; + this->ctx_->state (TAO_CodeGen::TAO_UNION_PRIVATE_CH); if (this->visit_scope (node) == -1) @@ -175,7 +161,8 @@ int be_visitor_union_ch::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ch::" "visit_union - " - "codegen for private members of union\n"), -1); + "codegen for private members of union\n"), + -1); } *os << be_uidt_nl; @@ -188,19 +175,19 @@ int be_visitor_union_ch::visit_union (be_union *node) *os << "// Frees any allocated storage." << be_nl << be_nl; *os << "}; //" << node->name () << be_nl << be_nl; - if (!node->is_local ()) + if (be_global->tc_support ()) { ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); + be_visitor_typecode_decl tc_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&tc_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ch::" "visit_union - " - "TypeCode declaration failed\n" - ), -1); + "TypeCode declaration failed\n"), + -1); } } diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_ci.cpp index 8edc9fa72a0..c545f646a65 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_ci.cpp @@ -18,17 +18,16 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union.h" -ACE_RCSID(be_visitor_union, union_ci, "$Id$") +ACE_RCSID (be_visitor_union, + union_ci, + "$Id$") // ****************************************************** -// for client inline +// For client inline. // ****************************************************** be_visitor_union_ci::be_visitor_union_ci (be_visitor_context *ctx) @@ -40,21 +39,14 @@ be_visitor_union_ci::~be_visitor_union_ci (void) { } -// visit the Union node and its scope int be_visitor_union_ci::visit_union (be_union *node) { - TAO_OutStream *os; // output stream - be_type *bt; // type node - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - + ctx.node (node); if (!node->cli_inline_gen () && !node->imported ()) { - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); *os << "// *************************************************************" << be_nl; @@ -64,70 +56,75 @@ int be_visitor_union_ci::visit_union (be_union *node) // the discriminant type may have to be defined here if it was an enum // declaration inside of the union statement. - bt = be_type::narrow_from_decl (node->disc_type ()); + be_type *bt = be_type::narrow_from_decl (node->disc_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit_union - " - "bad discriminant type\n"), -1); + "bad discriminant type\n"), + -1); } - ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CI); // set current code - // gen state - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_ci::" - "visit_union - " - "bad visitor\n"), -1); - } - // generate code for the discriminant - if (bt->accept (visitor) == -1) + ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CI); + + be_visitor_union_discriminant_ci visitor (&ctx); + + if (bt->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit union - " - "codegen for discrminant failed\n"), -1); + "codegen for discrminant failed\n"), + -1); } - // now generate the implementation of the access methods for the - // union. For this set our state + // Now generate the implementation of the access methods for the + // union. For this set our state. this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_CI); + if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit_union - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - // generate the ifdefined macro for the array type + // Generate the ifdefined macro for the array type. os->gen_ifdef_macro (node->flat_name (), "_var"); + if (node->gen_var_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit_union - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } + os->gen_endif (); - // generate the ifdefined macro for the array type then generate the _out - // impl + // Generate the ifdefined macro for the array type then generate the + // _out impl os->gen_ifdef_macro (node->flat_name (), "_out"); + if (node->size_type () == be_decl::VARIABLE && node->gen_out_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_ci::" "visit_union - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } + os->gen_endif (); node->cli_inline_gen (I_TRUE); } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ch.cpp index d066471016b..73ba240073d 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ch.cpp @@ -19,276 +19,212 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union_branch.h" +#include "be_visitor_array.h" +#include "be_visitor_enum.h" +#include "be_visitor_sequence.h" +#include "be_visitor_structure.h" +#include "be_visitor_union.h" -ACE_RCSID(be_visitor_union_branch, cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_union_branch, + cdr_op_ch, + "$Id$") // ********************************************** -// visitor for union_branch in the client header file +// Visitor for union_branch in the client header file. // ********************************************** -// constructor -be_visitor_union_branch_cdr_op_ch::be_visitor_union_branch_cdr_op_ch (be_visitor_context *ctx) +be_visitor_union_branch_cdr_op_ch::be_visitor_union_branch_cdr_op_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// destructor be_visitor_union_branch_cdr_op_ch::~be_visitor_union_branch_cdr_op_ch (void) { } -// visit the union_branch node int be_visitor_union_branch_cdr_op_ch::visit_union_branch (be_union_branch *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_union_branch - " - "Bad union_branch type\n" - ), -1); + "Bad union_branch type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); + "codegen for union_branch type failed\n"), + -1); } return 0; } -// =visit operations on all possible data types that a union_branch can be +// Visit operations on all possible data types that a union_branch can be. -// visit array type int be_visitor_union_branch_cdr_op_ch::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined. - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. + // This is the case for anonymous arrays. - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the struct declaration ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit enum type int be_visitor_union_branch_cdr_op_ch::visit_enum (be_enum *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the enum declaration ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit sequence type int be_visitor_union_branch_cdr_op_ch::visit_sequence (be_sequence *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the sequence declaration ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit structure type int be_visitor_union_branch_cdr_op_ch::visit_structure (be_structure *node) { - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the struct declaration ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit typedefed type int be_visitor_union_branch_cdr_op_ch::visit_typedef (be_typedef *node) { - // save the node for use in code generation and - // indicate that the union_branch of the union_branch node - // is a typedefed quantity 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_union_branch_cdr_op_ch::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } + this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_union_branch_cdr_op_ch::visit_union (be_union *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same + ctx.node (node); - // first generate the enum declaration ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp index 37bbb15f6a4..2b1563db5df 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_cs.cpp @@ -18,132 +18,86 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union_branch.h" -ACE_RCSID(be_visitor_union_branch, cdr_op_cs, "$Id$") +ACE_RCSID (be_visitor_union_branch, + cdr_op_cs, + "$Id$") // ********************************************** -// visitor for union_branch in the client stubs file +// Visitor for union_branch in the client stubs file. // ********************************************** -// constructor -be_visitor_union_branch_cdr_op_cs::be_visitor_union_branch_cdr_op_cs (be_visitor_context *ctx) +be_visitor_union_branch_cdr_op_cs::be_visitor_union_branch_cdr_op_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// destructor be_visitor_union_branch_cdr_op_cs::~be_visitor_union_branch_cdr_op_cs (void) { } -// visit the union_branch node int be_visitor_union_branch_cdr_op_cs::visit_union_branch (be_union_branch *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_union_branch - " - "Bad union_branch type\n" - ), -1); + "Bad union_branch type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); + "codegen for union_branch type failed\n"), + -1); } + return 0; } -// visit array int be_visitor_union_branch_cdr_op_cs::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined - + // If not a typedef and we are defined in the use scope, we must be defined. if (!this->ctx_->alias () // not a typedef && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // This is the case for anonymous arrays. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit enum type int be_visitor_union_branch_cdr_op_cs::visit_enum (be_enum *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure - { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting - be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the typcode for enums - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_enum - " - "codegen failed\n" - ), -1); - } - delete visitor; - } return 0; } @@ -152,134 +106,91 @@ be_visitor_union_branch_cdr_op_cs::visit_sequence (be_sequence *node) { if (node->node_type () != AST_Decl::NT_typedef && node->is_child (this->ctx_->scope ())) - // not a typedef AND - // node is defined inside the structure { // Anonymous sequence - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit structure type int be_visitor_union_branch_cdr_op_cs::visit_structure (be_structure *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_union_branch_cdr_op_cs::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type + this->ctx_->alias (node); - // the node to be visited in the base primitve type that gets typedefed + // The node to be visited in the base primitve type that gets typedefed. be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_union_branch_cdr_op_cs::visit_union (be_union *node) { - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for union + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp index 4d184a3099d..c6d5d820e2e 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ch.cpp @@ -18,32 +18,34 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union_branch.h" +#include "be_visitor_array.h" +#include "be_visitor_enum.h" +#include "be_visitor_sequence.h" +#include "be_visitor_structure.h" +#include "be_visitor_union.h" -ACE_RCSID(be_visitor_union_branch, public_ch, "$Id$") +ACE_RCSID (be_visitor_union_branch, + public_ch, + "$Id$") // ********************************************** -// visitor for union_branch in the client header file +// Visitor for union_branch in the client header file. // ********************************************** -// Constructor. -be_visitor_union_branch_public_ch::be_visitor_union_branch_public_ch -(be_visitor_context *ctx) +be_visitor_union_branch_public_ch::be_visitor_union_branch_public_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// Destructor. be_visitor_union_branch_public_ch::~be_visitor_union_branch_public_ch (void) { } -// Visit the union_branch node. int be_visitor_union_branch_public_ch::visit_union_branch (be_union_branch *node) { @@ -66,8 +68,7 @@ be_visitor_union_branch_public_ch::visit_union_branch (be_union_branch *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), + "codegen for union_branch type failed\n"), -1); } @@ -76,7 +77,6 @@ be_visitor_union_branch_public_ch::visit_union_branch (be_union_branch *node) // Visit operations on all possible data types that a union_branch can be. -// Visit array type. int be_visitor_union_branch_public_ch::visit_array (be_array *node) { @@ -99,8 +99,7 @@ be_visitor_union_branch_public_ch::visit_array (be_array *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_array - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -112,26 +111,12 @@ be_visitor_union_branch_public_ch::visit_array (be_array *node) { // This is the case of an anonymous array inside a union. - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // First generate the array declaration. ctx.state (TAO_CodeGen::TAO_ARRAY_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_array - " - "Bad visitor\n" - ), - -1); - } + be_visitor_array_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" @@ -141,8 +126,6 @@ be_visitor_union_branch_public_ch::visit_array (be_array *node) -1); } - delete visitor; - // Now use this array as a "type" for the subsequent declarator // the set method. *os << "void " << ub->local_name () << " (" @@ -166,7 +149,6 @@ be_visitor_union_branch_public_ch::visit_array (be_array *node) return 0; } -// Visit enum type. int be_visitor_union_branch_public_ch::visit_enum (be_enum *node) { @@ -189,47 +171,29 @@ be_visitor_union_branch_public_ch::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_enum - " - "bad context information\n" - ), + "bad context information\n"), -1); } TAO_OutStream *os = this->ctx_->stream (); // Not a typedef and bt is defined inside the union. - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_enum_ch visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_enum - " - "Bad visitor\n" - ), + "codegen failed\n"), -1); } - - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_enum - " - "codegen failed\n" - ), - -1); - } - - delete visitor; } // Now use this enum as a "type" for the subsequent declarator @@ -244,7 +208,6 @@ be_visitor_union_branch_public_ch::visit_enum (be_enum *node) return 0; } -// Visit interface type. int be_visitor_union_branch_public_ch::visit_interface (be_interface *node) { @@ -267,8 +230,7 @@ be_visitor_union_branch_public_ch::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_interface - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -281,10 +243,10 @@ be_visitor_union_branch_public_ch::visit_interface (be_interface *node) // Get method. *os << bt->nested_type_name (bu, "_ptr") << " " << ub->local_name () << " (void) const;" << be_nl << be_nl; + return 0; } -// Visit interface forward type. int be_visitor_union_branch_public_ch::visit_interface_fwd (be_interface_fwd *node) { @@ -307,8 +269,7 @@ be_visitor_union_branch_public_ch::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_interface_fwd - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -325,7 +286,6 @@ be_visitor_union_branch_public_ch::visit_interface_fwd (be_interface_fwd *node) return 0; } -// Visit valuetype type. int be_visitor_union_branch_public_ch::visit_valuetype (be_valuetype *node) { @@ -348,8 +308,7 @@ be_visitor_union_branch_public_ch::visit_valuetype (be_valuetype *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_valuetype - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -366,7 +325,6 @@ be_visitor_union_branch_public_ch::visit_valuetype (be_valuetype *node) return 0; } -// Visit valuetype forward type. int be_visitor_union_branch_public_ch::visit_valuetype_fwd (be_valuetype_fwd *node) { @@ -389,8 +347,7 @@ be_visitor_union_branch_public_ch::visit_valuetype_fwd (be_valuetype_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_valuetype_fwd - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -407,7 +364,6 @@ be_visitor_union_branch_public_ch::visit_valuetype_fwd (be_valuetype_fwd *node) return 0; } -// Visit predefined type. int be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *node) { @@ -430,8 +386,7 @@ be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *no ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_predefined_type - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -465,7 +420,6 @@ be_visitor_union_branch_public_ch::visit_predefined_type (be_predefined_type *no return 0; } -// visit sequence type int be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) { @@ -488,8 +442,7 @@ be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_sequence - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -499,37 +452,20 @@ be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // First generate the sequence declaration. ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_sequence_ch visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_sequence - " - "Bad visitor\n" - ), - -1); - } - - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_sequence - " - "codegen failed\n" - ), + "codegen failed\n"), -1); } - delete visitor; - // Generate the anonymous sequence member typedef // but we must protect against certain versions of g++. // This provides a consistent name to use instead of the @@ -553,7 +489,6 @@ be_visitor_union_branch_public_ch::visit_sequence (be_sequence *node) return 0; } -// Visit string type. int be_visitor_union_branch_public_ch::visit_string (be_string *node) { @@ -565,8 +500,7 @@ be_visitor_union_branch_public_ch::visit_string (be_string *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_string - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -597,7 +531,6 @@ be_visitor_union_branch_public_ch::visit_string (be_string *node) return 0; } -// Visit structure type. int be_visitor_union_branch_public_ch::visit_structure (be_structure *node) { @@ -620,8 +553,7 @@ be_visitor_union_branch_public_ch::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_structure - " - "bad context information\n" - ), + "bad context information\n"), -1); } @@ -631,37 +563,19 @@ be_visitor_union_branch_public_ch::visit_structure (be_structure *node) if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // First generate the sequence declaration. + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_structure - " - "Bad visitor\n" - ), - -1); - } + be_visitor_structure_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_structure - " - "codegen failed\n" - ), + "codegen failed\n"), -1); } - - delete visitor; } *os << "void " << ub->local_name () << " (const " @@ -675,7 +589,6 @@ be_visitor_union_branch_public_ch::visit_structure (be_structure *node) return 0; } -// Visit typedefed type. int be_visitor_union_branch_public_ch::visit_typedef (be_typedef *node) { @@ -689,8 +602,7 @@ be_visitor_union_branch_public_ch::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_spec_ch::" "visit_typedef - " - "Bad primitive type\n" - ), + "Bad primitive type\n"), -1); } @@ -698,7 +610,6 @@ be_visitor_union_branch_public_ch::visit_typedef (be_typedef *node) return 0; } -// Visit union type. int be_visitor_union_branch_public_ch::visit_union (be_union *node) { @@ -732,36 +643,19 @@ be_visitor_union_branch_public_ch::visit_union (be_union *node) if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // First generate the union declaration. ctx.state (TAO_CodeGen::TAO_UNION_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_union_ch visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ch::" "visit_union - " - "Bad visitor\n" - ), + "codegen failed\n"), -1); } - - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ch::" - "visit_union - " - "codegen failed\n" - ), - -1); - } - - delete visitor; } *os << "void " << ub->local_name () << " (const " diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp index 593c57366b6..58bad7041af 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_ci.cpp @@ -18,17 +18,16 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union_branch.h" -ACE_RCSID(be_visitor_union_branch, public_ci, "$Id$") +ACE_RCSID (be_visitor_union_branch, + public_ci, + "$Id$") // ***************************************************** -// visitor for union_branch in the client inline file +// Visitor for union_branch in the client inline file. // ***************************************************** // constructor @@ -55,33 +54,31 @@ be_visitor_union_branch_public_ci::visit_union_branch (be_union_branch *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cs::" "visit_union_branch - " - "Bad union_branch type\n" - ), -1); + "Bad union_branch type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cs::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); + "codegen for union_branch type failed\n"), + -1); } return 0; } -// =visit operations on all possible data types that a union_branch can be +// Visit operations on all possible data types that a union_branch can be. int be_visitor_union_branch_public_ci::visit_array (be_array *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -99,45 +96,35 @@ be_visitor_union_branch_public_ci::visit_array (be_array *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_enum - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); - // If bt is not a typedef and is defined inside the union + // If bt is not a typedef and is defined inside the union. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { // Instantiate a visitor context with a copy of our context. This info // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); + // Set the node to be the node being visited. Scope is still the same. ctx.node (node); // First generate the inline operations for this anonymous array type. ctx.state (TAO_CodeGen::TAO_ARRAY_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_array_ci visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_array - " - "Bad visitor\n" - ), -1); + "codegen failed\n"), + -1); } - - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_array - " - "codegen failed\n" - ), -1); - } - - delete visitor; } // For anonymous arrays, the type name has a _ prepended. We compute the @@ -181,38 +168,46 @@ be_visitor_union_branch_public_ci::visit_array (be_array *node) // Set method. os->indent (); - *os << "// accessor to set the member" << be_nl + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << fname - << " val)// set" << be_nl + << " val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } // Default label. else { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } *os << ";" << be_nl - << "// set the value" << be_nl + << "// Set the value." << be_nl << "this->u_." << ub->local_name () << "_ = " << fname << "_dup (val);" << be_uidt_nl << "}" << be_nl << be_nl; // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << fname << "_slice *" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl @@ -225,13 +220,11 @@ be_visitor_union_branch_public_ci::visit_array (be_array *node) int be_visitor_union_branch_public_ci::visit_enum (be_enum *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // heck if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) { bt = this->ctx_->alias (); @@ -246,45 +239,53 @@ be_visitor_union_branch_public_ci::visit_enum (be_enum *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_enum - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); // Set method. os->indent (); - *os << "// accessor to set the member" << be_nl + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << bt->name () - << " val)// set" << be_nl + << " val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } // Default label. else { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } *os << ";" << be_nl - << "// set the value" << be_nl + << "// Set the value." << be_nl << "this->u_." << ub->local_name () << "_ = val;" << be_uidt_nl << "}" << be_nl << be_nl; // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << bt->name () << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl @@ -297,10 +298,8 @@ be_visitor_union_branch_public_ci::visit_enum (be_enum *node) int be_visitor_union_branch_public_ci::visit_interface (be_interface *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -318,35 +317,43 @@ be_visitor_union_branch_public_ci::visit_interface (be_interface *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); // Set method. os->indent (); - *os << "// accessor to set the member" << be_nl + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl + << "_ptr val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } // Default label. else { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -373,7 +380,7 @@ be_visitor_union_branch_public_ci::visit_interface (be_interface *node) << "}" << be_nl << be_nl; // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << bt->name () << "_ptr " << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl @@ -386,10 +393,8 @@ be_visitor_union_branch_public_ci::visit_interface (be_interface *node) int be_visitor_union_branch_public_ci::visit_interface_fwd (be_interface_fwd *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -407,35 +412,43 @@ be_visitor_union_branch_public_ci::visit_interface_fwd (be_interface_fwd *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); // Set method. os->indent (); - *os << "// accessor to set the member" << be_nl + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl + << "_ptr val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } // Default label. else { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -462,7 +475,7 @@ be_visitor_union_branch_public_ci::visit_interface_fwd (be_interface_fwd *node) << "}" << be_nl << be_nl; // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << bt->name () << "_ptr " << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl @@ -477,10 +490,8 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( be_predefined_type *node ) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -498,15 +509,19 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); // Set method. os->indent (); - *os << "// accessor to set the member" << be_nl + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (" << bt->name (); @@ -517,22 +532,26 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( *os << " val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -569,7 +588,7 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( break; default: - *os << "// set the value" << be_nl + *os << "// Set the value." << be_nl << "this->u_." << ub->local_name () << "_ = val;" << be_uidt_nl; } @@ -580,7 +599,7 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( { case AST_PredefinedType::PT_pseudo: // Get method. - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << "ACE_INLINE " << bt->name () << "_ptr" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl @@ -637,10 +656,8 @@ be_visitor_union_branch_public_ci::visit_predefined_type ( int be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -658,69 +675,66 @@ be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_sequence - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); - // If bt is not a typedef and is defined inside the union + // If bt is not a typedef and is defined inside the union. if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { // Instantiate a visitor context with a copy of our context. This info // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); + // Set the node to be the node being visited. Scope is still the same. ctx.node (node); // First generate inline operations for this anonymous sequence type. ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } + be_visitor_sequence_ci visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - - delete visitor; } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // (1) Set from a const. - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (const " << bt->name () << " &val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -732,7 +746,7 @@ be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) << "}" << be_nl << be_nl; // Readonly get method. - *os << "// readonly get method " << be_nl + *os << "// Readonly get method." << be_nl << "ACE_INLINE const " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl @@ -740,7 +754,7 @@ be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) << "}" << be_nl << be_nl; // Read/write get method. - *os << "// read/write get method " << be_nl + *os << "// Read/write get method." << be_nl << "ACE_INLINE " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl @@ -753,18 +767,16 @@ be_visitor_union_branch_public_ci::visit_sequence (be_sequence *node) int be_visitor_union_branch_public_ci::visit_string (be_string *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); // get union branch - be_union *bu = - this->ctx_->be_scope_as_union (); // get the enclosing union backend + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_string - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); @@ -773,7 +785,11 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) // (1) Set method from char* or wchar*. os->indent (); - *os << "// accessor to set the member" << be_nl + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl; if (node->width () == (long) sizeof (char)) @@ -788,22 +804,26 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) *os << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -813,7 +833,7 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) << "}" << be_nl << be_nl; // (2) Set method from const char * or const wchar *. - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name (); @@ -826,27 +846,31 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) *os << " (const CORBA::WChar *val)" << be_nl << "{" << be_idt_nl; } - *os << "// set the discriminant val" << be_nl + *os << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } *os << ";" << be_nl - << "// set the value" << be_nl + << "// Set the value." << be_nl << "this->u_." << ub->local_name () << "_ = "; if (node->width () == (long) sizeof (char)) @@ -861,7 +885,7 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) } // (3) Set from const String_var& or WString_var& - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name (); @@ -875,27 +899,31 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) } *os << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } *os << ";" << be_nl - << "// set the value" << be_nl; + << "// Set the value." << be_nl; if (node->width () == (long) sizeof (char)) { @@ -933,10 +961,8 @@ be_visitor_union_branch_public_ci::visit_string (be_string *node) int be_visitor_union_branch_public_ci::visit_structure (be_structure *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -954,8 +980,8 @@ be_visitor_union_branch_public_ci::visit_structure (be_structure *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_structure - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); @@ -967,56 +993,53 @@ be_visitor_union_branch_public_ci::visit_structure (be_structure *node) // Instantiate a visitor context with a copy of our context. This info // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); + // Set the node to be the node being visited. Scope is still the same. ctx.node (node); // First generate the struct declaration ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_structure_ci visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_structure - " - "Bad visitor\n" - ), -1); + "codegen failed\n"), + -1); } - - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_structure - " - "codegen failed\n" - ), -1); - } - - delete visitor; } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // (1) Set from a const. - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (const " << bt->name () << " &val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -1038,7 +1061,7 @@ be_visitor_union_branch_public_ci::visit_structure (be_structure *node) *os << "}" << be_nl << be_nl; // Readonly get method. - *os << "// readonly get method " << be_nl + *os << "// Readonly get method." << be_nl << "ACE_INLINE const " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl; @@ -1056,7 +1079,7 @@ be_visitor_union_branch_public_ci::visit_structure (be_structure *node) *os << "}" << be_nl << be_nl; // Read/write get method. - *os << "// read/write get method " << be_nl + *os << "// Read/write get method." << be_nl << "ACE_INLINE " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl; @@ -1090,8 +1113,8 @@ be_visitor_union_branch_public_ci::visit_typedef (be_typedef *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); @@ -1101,10 +1124,8 @@ be_visitor_union_branch_public_ci::visit_typedef (be_typedef *node) int be_visitor_union_branch_public_ci::visit_union (be_union *node) { - be_union_branch *ub = - this->ctx_->be_node_as_union_branch (); - be_union *bu = - this->ctx_->be_scope_as_union (); + be_union_branch *ub = this->ctx_->be_node_as_union_branch (); + be_union *bu = this->ctx_->be_scope_as_union (); be_type *bt; // Check if we are visiting this node via a visit to a typedef node. @@ -1122,8 +1143,8 @@ be_visitor_union_branch_public_ci::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_union - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } TAO_OutStream *os = this->ctx_->stream (); @@ -1135,56 +1156,53 @@ be_visitor_union_branch_public_ci::visit_union (be_union *node) // Instantiate a visitor context with a copy of our context. This info // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); + // Set the node to be the node being visited. Scope is still the same. ctx.node (node); // First generate the union declaration. ctx.state (TAO_CodeGen::TAO_UNION_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_union_ci visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_union - " - "Bad visitor\n" - ), -1); + "codegen failed\n"), + -1); } - - if (node->accept (visitor) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_ci::" - "visit_union - " - "codegen failed\n" - ), -1); - } - - delete visitor; } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // (1) Set from a const. - *os << "// accessor to set the member" << be_nl + *os << "// Accessor to set the member." << be_nl << "ACE_INLINE void" << be_nl << bu->name () << "::" << ub->local_name () << " (const " << bt->name () << " &val)" << be_nl << "{" << be_idt_nl - << "// set the discriminant val" << be_nl + << "// Set the discriminant value." << be_nl << "this->_reset ("; if (ub->label ()->label_kind () == AST_UnionLabel::UL_label) { ub->gen_label_value (os); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_label_value (os); } else // We have an explicit default case. { ub->gen_default_label_value (os, bu); + *os << ", 0);" << be_nl << "this->disc_ = "; + ub->gen_default_label_value (os, bu); } @@ -1196,7 +1214,7 @@ be_visitor_union_branch_public_ci::visit_union (be_union *node) << "}" << be_nl << be_nl; // Readonly get method. - *os << "// readonly get method " << be_nl + *os << "// Readonly get method." << be_nl << "ACE_INLINE const " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl @@ -1204,7 +1222,7 @@ be_visitor_union_branch_public_ci::visit_union (be_union *node) << "}" << be_nl << be_nl; // Read/write get method. - *os << "// read/write get method " << be_nl + *os << "// Read/write get method." << be_nl << "ACE_INLINE " << bt->name () << " &" << be_nl << bu->name () << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl diff --git a/TAO/TAO_IDL/be/be_visitor_union_branch/public_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/public_cs.cpp index 5d8424c9b92..8f2b1f9a377 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/public_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/public_cs.cpp @@ -18,244 +18,174 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_union_branch.h" -ACE_RCSID(be_visitor_union_branch, public_cs, "$Id$") +ACE_RCSID (be_visitor_union_branch, + public_cs, + "$Id$") // ********************************************** -// visitor for union_branch in the client stubs file +// Visitor for union_branch in the client stubs file. // ********************************************** -// constructor -be_visitor_union_branch_public_cs::be_visitor_union_branch_public_cs (be_visitor_context *ctx) +be_visitor_union_branch_public_cs::be_visitor_union_branch_public_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// destructor be_visitor_union_branch_public_cs::~be_visitor_union_branch_public_cs (void) { } -// visit the union_branch node int be_visitor_union_branch_public_cs::visit_union_branch (be_union_branch *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_union_branch - " - "Bad union_branch type\n" - ), -1); + "Bad union_branch type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_union_branch - " - "codegen for union_branch type failed\n" - ), -1); + "codegen for union_branch type failed\n"), + -1); } + return 0; } -// visit array type int be_visitor_union_branch_public_cs::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be - // defined - - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be + // defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // anonymous array case - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Anonymous array case. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous array type + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit enum type int be_visitor_union_branch_public_cs::visit_enum (be_enum *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the typcode for enums + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ENUM_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; + return 0; } -// visit sequence type int be_visitor_union_branch_public_cs::visit_sequence (be_sequence *node) { - // if not a typedef and we are defined in the use scope, we must be - // defined + // If not a typedef and we are defined in the use scope, we must be + // defined. - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // anonymous array case - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Anonymous sequence case. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous sequence type + ctx.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit string type int be_visitor_union_branch_public_cs::visit_string (be_string *) { return 0; } -// visit structure type int be_visitor_union_branch_public_cs::visit_structure (be_structure *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; + return 0; } -// visit union type int be_visitor_union_branch_public_cs::visit_union (be_union *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for union + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_public_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp index 129104f1a06..ab1945a19a6 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_ch.cpp @@ -18,33 +18,36 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_valuetype.h" -ACE_RCSID(be_visitor_valuetype, ami_exception_holder_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype, + ami_exception_holder_ch, + "$Id$") // ****************************************************** -// Interface visitor for client header +// Interface visitor for client header. // ****************************************************** -be_visitor_valuetype_ami_exception_holder_ch::be_visitor_valuetype_ami_exception_holder_ch (be_visitor_context *ctx) +be_visitor_valuetype_ami_exception_holder_ch:: +be_visitor_valuetype_ami_exception_holder_ch (be_visitor_context *ctx) : be_visitor_valuetype (ctx) { } -be_visitor_valuetype_ami_exception_holder_ch::~be_visitor_valuetype_ami_exception_holder_ch (void) +be_visitor_valuetype_ami_exception_holder_ch:: +~be_visitor_valuetype_ami_exception_holder_ch (void) { } int -be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype (be_valuetype *node) +be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype ( + be_valuetype *node + ) { TAO_OutStream *os = this->ctx_->stream (); - // Generate the implemenation of the Messaging aware ORB + // Generate the implemenation of the Messaging aware ORB. *os << be_nl << "class _tao_" << node->local_name () << be_idt_nl << ": public "; @@ -58,17 +61,15 @@ be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype (be_valuetype *nod << " public virtual OBV_Messaging::ExceptionHolder," << be_nl << " public virtual CORBA::DefaultValueRefCountBase" << be_uidt_nl << "{" << be_nl; - *os << "public:" << be_idt_nl; - *os << "_tao_" << node->local_name () << " ();" << be_nl << be_nl; - *os << "~_tao_" << node->local_name () << " ();" << be_nl << be_nl; if (this->visit_valuetype_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ami_exception_holder_cs::" + "(%N:%l) be_visitor_valuetype_ami_" + "exception_holder_cs::" "visit_valuetype - " "codegen for scope failed\n"), -1); @@ -76,36 +77,28 @@ be_visitor_valuetype_ami_exception_holder_ch::visit_valuetype (be_valuetype *nod *os << be_uidt_nl << "};" << be_nl << be_nl; + return 0; } int -be_visitor_valuetype_ami_exception_holder_ch::visit_operation (be_operation *node) +be_visitor_valuetype_ami_exception_holder_ch::visit_operation ( + be_operation *node + ) { be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_IH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ami_exception_holder_ch::" - "visit_operation - " - "Bad visitor to argument list\n"), - -1); - } + be_visitor_operation_ih visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ami_exception_holder_ch::" + "(%N:%l) be_visitor_valuetype_" + "ami_exception_holder_ch::" "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_cs.cpp index 8d22f9cdae1..8b78cb56557 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/ami_exception_holder_cs.cpp @@ -18,10 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_valuetype.h" ACE_RCSID(be_visitor_valuetype, ami_exception_holder_cs, "$Id$") @@ -43,31 +42,34 @@ be_visitor_valuetype_ami_exception_holder_cs::~be_visitor_valuetype_ami_exceptio int be_visitor_valuetype_ami_exception_holder_cs::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - if (node->is_nested () && - node->defined_in ()->scope_node_type () == AST_Decl::NT_module) - *os << "OBV_"; + if (node->is_nested () + && node->defined_in ()->scope_node_type () == AST_Decl::NT_module) + { + *os << "OBV_"; + } *os << node->compute_name ("_tao_", "") << "::" << node->compute_local_name ("_tao_", "") << " () { }" << be_nl << be_nl; - if (node->is_nested () && - node->defined_in ()->scope_node_type () == AST_Decl::NT_module) - *os << "OBV_"; + if (node->is_nested () + && node->defined_in ()->scope_node_type () == AST_Decl::NT_module) + { + *os << "OBV_"; + } *os << node->compute_name ("_tao_", "") << "::~" << node->compute_local_name ("_tao_", "") << " () { }" << be_nl << be_nl; - // generate code for the elements of the interface + // Generate code for the elements of the interface if (this->visit_valuetype_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ami_exception_holder_cs::" "visit_valuetype - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } return 0; @@ -79,28 +81,16 @@ be_visitor_valuetype_ami_exception_holder_cs::visit_operation (be_operation *nod { be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_AMI_EXCEPTION_HOLDER_RAISE_OPERATION_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_operation_ami_exception_holder_operation_cs visitor (&ctx); - if (!visitor) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ami_exception_holder_ch::" "visit_operation - " - "Bad visitor to argument list\n"), - -1); - } - - if (node->accept (visitor) == -1) - { - delete visitor; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ami_exception_holder_ch::" - "visit_operation - " "codegen for argument list failed\n"), -1); } - delete visitor; - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp index b53c4daf8be..f48eba2001e 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/arglist.cpp @@ -20,23 +20,24 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_operation.h" +#include "be_visitor_argument.h" -ACE_RCSID(be_visitor_valuetype, arglist, "$Id$") +ACE_RCSID (be_visitor_valuetype, + arglist, + "$Id$") // ************************************************************ -// operation visitor to generate the argument list. +// Operation visitor to generate the argument list. // We have separated code generation for this from the 4 main -// visitors to avoid code duplication and tight coupling +// visitors to avoid code duplication and tight coupling. // ************************************************************ -be_visitor_obv_operation_arglist::be_visitor_obv_operation_arglist (be_visitor_context - *ctx) +be_visitor_obv_operation_arglist::be_visitor_obv_operation_arglist ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -67,8 +68,9 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) { // Use ACE_ENV_SINGLE_ARG_DECL or ACE_ENV_ARG_DECL depending on // whether the operation node has parameters. - const char *env_decl = (node->argument_count () > 0 ? - " ACE_ENV_ARG_DECL" : "ACE_ENV_SINGLE_ARG_DECL"); + const char *env_decl = (node->argument_count () > 0 + ? " ACE_ENV_ARG_DECL" + : "ACE_ENV_SINGLE_ARG_DECL"); switch (this->ctx_->state ()) { @@ -95,8 +97,11 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) be_visitor_context ctx = *this->ctx_; be_visitor_operation operation_visitor (&ctx); + if (operation_visitor.gen_throw_spec (node) == -1) - return -1; + { + return -1; + } switch (this->ctx_->state ()) { @@ -122,17 +127,14 @@ be_visitor_obv_operation_arglist::visit_operation (be_operation *node) int be_visitor_obv_operation_arglist::visit_argument (be_argument *node) { - // TAO_OutStream *os = this->ctx_->stream (); - - // get the visitor that will dump the argument's mapping in the operation - // signature. be_visitor_context ctx (*this->ctx_); - // first grab the interface definition inside which this operation is + // First grab the interface definition inside which this operation is // defined. We need this since argument types may very well be declared // inside the scope of the interface node. In such cases, we would like to // generate the appropriate relative scoped names. be_operation *op = this->ctx_->be_scope_as_operation (); + if (!op) { ACE_ERROR_RETURN ((LM_ERROR, @@ -144,10 +146,9 @@ be_visitor_obv_operation_arglist::visit_argument (be_argument *node) // We need the interface node in which this operation was defined. However, // if this operation node was an attribute node in disguise, we get this - // information from the context + // information from the context. // %! use AST_Interface - be_valuetype *intf; - intf = this->ctx_->attribute () + be_valuetype *intf = this->ctx_->attribute () ? be_valuetype::narrow_from_scope (this->ctx_->attribute ()->defined_in ()) : be_valuetype::narrow_from_scope (op->defined_in ()); @@ -159,14 +160,13 @@ be_visitor_obv_operation_arglist::visit_argument (be_argument *node) "Bad interface\n"), -1); } - ctx.scope (intf); // set new scope - // snipped from - // be_visitor_args_arglist::visit_argument (be_argument *node) + ctx.scope (intf); ctx.node (node); // save the argument node - // retrieve the type + // Retrieve the type. be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -176,24 +176,27 @@ be_visitor_obv_operation_arglist::visit_argument (be_argument *node) -1); } - // os->indent (); // start with current indentation level - - // Different types have different mappings when used as in/out or - // inout parameters. Let this visitor deal with the type - - // end of be_visitor_args_arglist::visit_argument () + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); + be_visitor_args_arglist visitor (&ctx); + status = bt->accept (&visitor); + break; + } case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_OTHERS: case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_SH: case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IH: case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IS: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_OTHERS); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_OTHERS); + be_visitor_args_arglist visitor (&ctx); + status = bt->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -204,26 +207,15 @@ be_visitor_obv_operation_arglist::visit_argument (be_argument *node) } } - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_arglist::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - if (bt->accept (visitor) == -1) + if (status == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_arglist::" "visit_argument - " "codegen for argument failed\n"), -1); } - delete visitor; + return 0; } @@ -233,21 +225,26 @@ be_visitor_obv_operation_arglist::post_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); - switch (this->ctx_->state ()) + switch (this->ctx_->state ()) + { + case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: + case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_OTHERS: + case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_SH: + case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IH: + case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IS: + if (!this->last_node (bd)) { - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_OTHERS: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_SH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IH: - case TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_IS: - if (!this->last_node (bd)) - *os << ", "; // "\n"; - else - *os << ""; // "\n"; - break; - default: - break; + *os << ", "; + } + else + { + *os << ""; } + + break; + default: + break; + } return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ch.cpp index 494b8378eb1..3fde72dda7f 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ch.cpp @@ -18,277 +18,211 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_field.h" +#include "be_visitor_array.h" +#include "be_visitor_enum.h" +#include "be_visitor_structure.h" +#include "be_visitor_sequence.h" +#include "be_visitor_union.h" -ACE_RCSID(be_visitor_valuetype, field_cdr_op_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype, + field_cdr_op_ch, + "$Id$") // ********************************************** -// visitor for field in the client header file +// Visitor for field in the client header file. // ********************************************** -// constructor -be_visitor_valuetype_field_cdr_ch::be_visitor_valuetype_field_cdr_ch (be_visitor_context *ctx) +be_visitor_valuetype_field_cdr_ch::be_visitor_valuetype_field_cdr_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx), - pre_ (""), post_ ("") + pre_ (""), + post_ ("") { } -// destructor be_visitor_valuetype_field_cdr_ch::~be_visitor_valuetype_field_cdr_ch (void) { } -// visit the field node int be_visitor_valuetype_field_cdr_ch::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field can be -// visit array type int be_visitor_valuetype_field_cdr_ch::visit_array (be_array *node) { - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // This is the case for anonymous arrays. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the struct declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit enum type int be_visitor_valuetype_field_cdr_ch::visit_enum (be_enum *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit sequence type int be_visitor_valuetype_field_cdr_ch::visit_sequence (be_sequence *node) { - // if not a typedef and we are defined in the use scope, we must be defined + // If not a typedef and we are defined in the use scope, we must be defined. if (!this->ctx_->alias () // not a typedef && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the sequence declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit structure type int be_visitor_valuetype_field_cdr_ch::visit_structure (be_structure *node) { - // if not a typedef and we are defined in the use scope, we must be defined - - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the struct declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; } -// visit typedefed type int be_visitor_valuetype_field_cdr_ch::visit_typedef (be_typedef *node) { - // save the node for use in code generation and + // Save the node for use in code generation and // indicate that the field of the field node - // is a typedefed quantity + // is a typedefed quantity. this->ctx_->alias (node); - // make a decision based on the primitive base type + // 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_valuetype_field_cdr_ch::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } + this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_valuetype_field_cdr_ch::visit_union (be_union *node) { - // if not a typedef and we are defined in the use scope, we must be defined - if (!this->ctx_->alias () // not a typedef + // If not a typedef and we are defined in the use scope, we must be defined. + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ch::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_ch visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ch::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ci.cpp index bb9549c5b1c..2689a58661a 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cdr_ci.cpp @@ -19,109 +19,116 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_field.h" -ACE_RCSID(be_visitor_valuetype, field_cdr_op_ci, "$Id$") +ACE_RCSID (be_visitor_valuetype, + field_cdr_op_ci, + "$Id$") // ********************************************** -// visitor for field in the client stubs file +// Visitor for field in the client inline file. // ********************************************** -// constructor -be_visitor_valuetype_field_cdr_ci::be_visitor_valuetype_field_cdr_ci (be_visitor_context *ctx) +be_visitor_valuetype_field_cdr_ci::be_visitor_valuetype_field_cdr_ci ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx), - pre_ (""), post_ ("") + pre_ (""), + post_ ("") { } -// destructor be_visitor_valuetype_field_cdr_ci::~be_visitor_valuetype_field_cdr_ci (void) { } -// visit the field node int be_visitor_valuetype_field_cdr_ci::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } + return 0; } -// visit array int be_visitor_valuetype_field_cdr_ci::visit_array (be_array *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // for anonymous arrays, the type name has a _ prepended. We compute + // For anonymous arrays, the type name has a _ prepended. We compute // the full_name with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and + char fname [NAMEBUFSIZE]; + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); - // save the node's local name and full name in a buffer for quick - // use later on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // for anonymous arrays ... - // we have to generate a name for us that has an underscore + // For anonymous arrays ... + // We have to generate a name for us that has an underscore // prepended to our local name. This needs to be inserted after - // the parents's name + // the parents's name. if (node->is_nested ()) { be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->full_name (), + ACE_OS::sprintf (fname, + "%s::_%s", + parent->full_name (), node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->full_name ()); + ACE_OS::sprintf (fname, + "_%s", + node->full_name ()); } } else { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->full_name ()); + // Typedefed node. + ACE_OS::sprintf (fname, + "%s", + node->full_name ()); } - // check what is the code generation substate. Are we generating + // Check what is the code generation substate. Are we generating // code for the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -134,74 +141,58 @@ be_visitor_valuetype_field_cdr_ci::visit_array (be_array *node) << "_tao_" << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } - // if not a typedef and we are defined in the use scope, we must be defined - + // If not a typedef and we are defined in the use scope, we must be defined. if (!this->ctx_->alias () // not a typedef && node->is_child (this->ctx_->scope ())) { - // this is the case for anonymous arrays. Generate the <<, >> operators - // for the type defined by the anonymous array - - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // This is the case for anonymous arrays. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit enum type int be_visitor_valuetype_field_cdr_ci::visit_enum (be_enum *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generation substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -212,70 +203,56 @@ be_visitor_valuetype_field_cdr_ci::visit_enum (be_enum *node) *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_enum - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // generate the typcode for enums + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit interface type int be_visitor_valuetype_field_cdr_ci::visit_interface (be_interface *) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_interface - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generations substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -286,39 +263,39 @@ be_visitor_valuetype_field_cdr_ci::visit_interface (be_interface *) *os << "(strm << " << pre_ << f->local_name () << post_ << ".in ())"; break; case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an interface cannit be declared inside a - // structure + // Nothing to be done because an interface cannit be declared inside a + // structure. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_interface - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } + return 0; } -// visit interface forward type int be_visitor_valuetype_field_cdr_ci::visit_interface_fwd (be_interface_fwd *) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_interface_fwd - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generations substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -329,39 +306,39 @@ be_visitor_valuetype_field_cdr_ci::visit_interface_fwd (be_interface_fwd *) *os << "(strm << " << pre_ << f->local_name () << post_ << ").in ()"; break; case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an interface cannit be declared inside a - // structure + // Nothing to be done because an interface cannit be declared inside a + // structure. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_interface_fwd - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } + return 0; } -// visit valuetype type int be_visitor_valuetype_field_cdr_ci::visit_valuetype (be_valuetype *) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_valuetype - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generations substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -372,39 +349,39 @@ be_visitor_valuetype_field_cdr_ci::visit_valuetype (be_valuetype *) *os << "(strm << " << pre_ << f->local_name () << post_ << ".in ())"; break; case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an valuetype cannit be declared inside a - // structure + // Nothing to be done because a valuetype cannit be declared inside a + // structure. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_valuetype - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } + return 0; } -// visit valuetype forward type int be_visitor_valuetype_field_cdr_ci::visit_valuetype_fwd (be_valuetype_fwd *) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_valuetype_fwd - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generations substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -415,91 +392,114 @@ be_visitor_valuetype_field_cdr_ci::visit_valuetype_fwd (be_valuetype_fwd *) *os << "(strm << " << pre_ << f->local_name () << post_ << ").in ()"; break; case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done because an valuetype cannot be declared inside a - // structure + // Nothing to be done because a valuetype cannot be declared inside a + // structure. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_valuetype_fwd - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } + return 0; } -// visit predefined type int be_visitor_valuetype_field_cdr_ci::visit_predefined_type (be_predefined_type *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_predefined_type - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generations substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { case TAO_CodeGen::TAO_CDR_INPUT: - // is a psuedo obj if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "(strm >> " << pre_ << f->local_name () << post_ - << ".out ())"; + { + *os << "(strm >> " << pre_ << f->local_name () << post_ + << ".out ())"; + } else if (node->pt () == AST_PredefinedType::PT_char) - *os << "(strm >> CORBA::Any::to_char (" << pre_ - << f->local_name () << post_ << "))"; + { + *os << "(strm >> CORBA::Any::to_char (" << pre_ + << f->local_name () << post_ << "))"; + } else if (node->pt () == AST_PredefinedType::PT_wchar) - *os << "(strm >> CORBA::Any::to_wchar (" << pre_ - << f->local_name () << post_ << "))"; + { + *os << "(strm >> CORBA::Any::to_wchar (" << pre_ + << f->local_name () << post_ << "))"; + } else if (node->pt () == AST_PredefinedType::PT_octet) - *os << "(strm >> CORBA::Any::to_octet (" << pre_ - << f->local_name () << post_ << "))"; + { + *os << "(strm >> CORBA::Any::to_octet (" << pre_ + << f->local_name () << post_ << "))"; + } else if (node->pt () == AST_PredefinedType::PT_boolean) - *os << "(strm >> CORBA::Any::to_boolean (" << pre_ - << f->local_name () << post_ << "))"; + { + *os << "(strm >> CORBA::Any::to_boolean (" << pre_ + << f->local_name () << post_ << "))"; + } else - *os << "(strm >> " << pre_ << f->local_name () << post_ << ")"; + { + *os << "(strm >> " << pre_ << f->local_name () << post_ << ")"; + } break; case TAO_CodeGen::TAO_CDR_OUTPUT: - // is a psuedo obj if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "(strm << " << pre_ << f->local_name () << post_ << ".in ())"; + { + *os << "(strm << " << pre_ << f->local_name () + << post_ << ".in ())"; + } else if (node->pt () == AST_PredefinedType::PT_char) - *os << "(strm << CORBA::Any::from_char (" << pre_ - << f->local_name () << post_ << "))"; + { + *os << "(strm << CORBA::Any::from_char (" << pre_ + << f->local_name () << post_ << "))"; + } else if (node->pt () == AST_PredefinedType::PT_wchar) - *os << "(strm << CORBA::Any::from_wchar (" << pre_ - << f->local_name () << post_ << "))"; + { + *os << "(strm << CORBA::Any::from_wchar (" << pre_ + << f->local_name () << post_ << "))"; + } else if (node->pt () == AST_PredefinedType::PT_octet) - *os << "(strm << CORBA::Any::from_octet (" << pre_ - << f->local_name () << post_ << "))"; + { + *os << "(strm << CORBA::Any::from_octet (" << pre_ + << f->local_name () << post_ << "))"; + } else if (node->pt () == AST_PredefinedType::PT_boolean) - *os << "(strm << CORBA::Any::from_boolean (" << pre_ - << f->local_name () << post_ << "))"; + { + *os << "(strm << CORBA::Any::from_boolean (" << pre_ + << f->local_name () << post_ << "))"; + } else - *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; + { + *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; + } break; case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done + // Nothing to be done. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } return 0; @@ -508,21 +508,21 @@ be_visitor_valuetype_field_cdr_ci::visit_predefined_type (be_predefined_type *no int be_visitor_valuetype_field_cdr_ci::visit_sequence (be_sequence *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_sequence - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n" ), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generations substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -533,72 +533,59 @@ be_visitor_valuetype_field_cdr_ci::visit_sequence (be_sequence *node) *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_sequence - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } if (node->node_type () != AST_Decl::NT_typedef && node->is_child (this->ctx_->scope ())) - // not a typedef AND - // node is defined inside the structure + // Not a typedef AND + // node is defined inside the valuetype. { - // Anonymous sequence - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting + // Anonymous sequence. be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. - // The scope is still the same - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit string type int be_visitor_valuetype_field_cdr_ci::visit_string (be_string *) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_string - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generations substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -609,39 +596,38 @@ be_visitor_valuetype_field_cdr_ci::visit_string (be_string *) *os << "(strm << " << pre_ << f->local_name () << post_ << ".in ())"; break; case TAO_CodeGen::TAO_CDR_SCOPE: - // nothing to be done + // Nothing to be done. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_array - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } return 0; } -// visit structure type int be_visitor_valuetype_field_cdr_ci::visit_structure (be_structure *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_structure - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generations substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -652,92 +638,77 @@ be_visitor_valuetype_field_cdr_ci::visit_structure (be_structure *node) *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_structure - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for structs + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_valuetype_field_cdr_ci::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type + this->ctx_->alias (node); - // the node to be visited in the base primitve type that gets typedefed + // The node to be visited in the base primitve type that gets typedefed. be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_public_ci::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_valuetype_field_cdr_ci::visit_union (be_union *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_union - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // check what is the code generations substate. Are we generating code for + // Check what is the code generations substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -748,56 +719,44 @@ be_visitor_valuetype_field_cdr_ci::visit_union (be_union *node) *os << "(strm << " << pre_ << f->local_name () << post_ << ")"; return 0; case TAO_CodeGen::TAO_CDR_SCOPE: - // proceed further + // Proceed further. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_union - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } - if (node->node_type () != AST_Decl::NT_typedef // not a typedef - && node->is_child (this->ctx_->scope ())) // node is defined inside the - // structure + if (node->node_type () != AST_Decl::NT_typedef + && node->is_child (this->ctx_->scope ())) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same - - // generate the inline code for union + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cdr_ci::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_ci::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } // **************************************************************** -be_visitor_valuetype_field_cdr_decl:: - be_visitor_valuetype_field_cdr_decl (be_visitor_context *ctx) +be_visitor_valuetype_field_cdr_decl::be_visitor_valuetype_field_cdr_decl ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -814,89 +773,101 @@ int be_visitor_valuetype_field_cdr_decl::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_decl::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } // @@ Shouldn't this be saved in the visitor and not the context?! - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_decl::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } + return 0; } -// visit array int be_visitor_valuetype_field_cdr_decl::visit_array (be_array *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the field node + // Retrieve the field node. be_field *f = this->ctx_->be_node_as_field (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_decl::" "visit_array - " - "cannot retrieve field node\n" - ), -1); + "cannot retrieve field node\n"), + -1); } - // retrieve the valuetype scope in which the code is generated + // Retrieve the valuetype scope in which the code is generated. be_decl *sc = this->ctx_->scope (); be_valuetype *vt = be_valuetype::narrow_from_decl (sc); + if (!vt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_decl::" "visit_array - " - "cannot retrieve valuetype node\n" - ), -1); + "cannot retrieve valuetype node\n"), + -1); } - // for anonymous arrays, the type name has a _ prepended. We compute + // For anonymous arrays, the type name has a _ prepended. We compute // the full_name with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and + char fname [NAMEBUFSIZE]; + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (!this->ctx_->alias () // not a typedef + if (!this->ctx_->alias () && node->is_child (this->ctx_->scope ())) { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope + // For anonymous arrays ... + // We have to generate a name for us that has an underscope // prepended to our local name. This needs to be inserted after - // the parents's name + // the parent's name. if (node->is_nested ()) { - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->full_name (), + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + ACE_OS::sprintf (fname, + "%s::_%s", + parent->full_name (), node->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", node->full_name ()); + ACE_OS::sprintf (fname, + "_%s", + node->full_name ()); } } else { - // typedefed node - ACE_OS::sprintf (fname, "%s", node->full_name ()); + // Typedefed node. + ACE_OS::sprintf (fname, + "%s", + node->full_name ()); } - // check what is the code generation substate. Are we generating code for + // Check what is the code generation substate. Are we generating code for // the in/out operators for our parent or for us? switch (this->ctx_->sub_state ()) { @@ -914,32 +885,29 @@ be_visitor_valuetype_field_cdr_decl::visit_array (be_array *node) return 0; case TAO_CodeGen::TAO_CDR_SCOPE: default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cdr_decl::" - "visit_array - " - "bad sub state\n" - ), -1); + "visit_array - "), + -1); } + ACE_NOTREACHED (return 0); } -// visit typedef type int be_visitor_valuetype_field_cdr_decl::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type - - // the node to be visited in the base primitve type that gets typedefed + this->ctx_->alias (node); be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_cdr_op_field_decl::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp index 0cd37403575..157429b1133 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ch.cpp @@ -20,27 +20,30 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" #include "be.h" +#include "be_visitor_array.h" +#include "be_visitor_enum.h" +#include "be_visitor_sequence.h" +#include "be_visitor_structure.h" +#include "be_visitor_union.h" -ACE_RCSID(be_visitor_valuetype, field_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype, + field_ch, + "$Id$") -// Constructor. -be_visitor_valuetype_field_ch::be_visitor_valuetype_field_ch - (be_visitor_context *ctx) +be_visitor_valuetype_field_ch::be_visitor_valuetype_field_ch ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { - setenclosings ("",";"); + setenclosings ("", ";"); } -// Destructor. be_visitor_valuetype_field_ch::~be_visitor_valuetype_field_ch (void) { } -// Visit the field node. int be_visitor_valuetype_field_ch::visit_field (be_field *node) { @@ -69,9 +72,8 @@ be_visitor_valuetype_field_ch::visit_field (be_field *node) return 0; } -// =Visit operations on all possible data types (valuetype state member). +// Visit operations on all possible data types (valuetype state member). -// visit array type int be_visitor_valuetype_field_ch::visit_array (be_array *node) { @@ -100,30 +102,16 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) TAO_OutStream *os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { // This is the case of an anonymous array inside a union. - - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // First generate the array declaration. ctx.state (TAO_CodeGen::TAO_ARRAY_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_array - " - "Bad visitor\n"), - -1); - } + be_visitor_array_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -132,7 +120,6 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) -1); } - delete visitor; // Now use this array as a "type" for the subsequent declarator // the set method. *os << pre_op () << "void " << ub->local_name () << " (" @@ -166,7 +153,6 @@ be_visitor_valuetype_field_ch::visit_array (be_array *node) return 0; } -// Visit enum type. int be_visitor_valuetype_field_ch::visit_enum (be_enum *node) { @@ -195,28 +181,15 @@ be_visitor_valuetype_field_ch::visit_enum (be_enum *node) TAO_OutStream *os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // First generate the enum declaration. ctx.state (TAO_CodeGen::TAO_ENUM_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_enum_ch visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_enum - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -224,8 +197,6 @@ be_visitor_valuetype_field_ch::visit_enum (be_enum *node) "codegen failed\n"), -1); } - - delete visitor; } // Now use this enum as a "type" for the subsequent declarator @@ -241,7 +212,6 @@ be_visitor_valuetype_field_ch::visit_enum (be_enum *node) return 0; } -// Visit interface type. int be_visitor_valuetype_field_ch::visit_interface (be_interface *node) { @@ -283,7 +253,6 @@ be_visitor_valuetype_field_ch::visit_interface (be_interface *node) return 0; } -// Visit interface forward type. int be_visitor_valuetype_field_ch::visit_interface_fwd (be_interface_fwd *node) { @@ -325,7 +294,6 @@ be_visitor_valuetype_field_ch::visit_interface_fwd (be_interface_fwd *node) return 0; } -// Visit valuetype type. int be_visitor_valuetype_field_ch::visit_valuetype (be_valuetype *node) { @@ -367,7 +335,6 @@ be_visitor_valuetype_field_ch::visit_valuetype (be_valuetype *node) return 0; } -// Visit valuetype forward type. int be_visitor_valuetype_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) { @@ -409,7 +376,6 @@ be_visitor_valuetype_field_ch::visit_valuetype_fwd (be_valuetype_fwd *node) return 0; } -// Visit predefined type. int be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) { @@ -441,11 +407,11 @@ be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) switch (node->pt ()) { case AST_PredefinedType::PT_pseudo: - // set method. + // Set method. *os << pre_op () << "void " << ub->local_name () << " (" << bt->name () << "_ptr)" << post_op () << " // set" << be_nl; - // Get method. + // Get method. *os << pre_op () << bt->name () << "_ptr " << ub->local_name () << " (void) const" << post_op () << " // get method" @@ -479,10 +445,10 @@ be_visitor_valuetype_field_ch::visit_predefined_type (be_predefined_type *node) << " (void) const" << post_op () << " // get method" << be_nl << be_nl; } + return 0; } -// Visit sequence type. int be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) { @@ -515,25 +481,12 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // First generate the sequence declaration. ctx.state (TAO_CodeGen::TAO_SEQUENCE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_sequence - " - "Bad visitor\n"), - -1); - } + be_visitor_sequence_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -542,8 +495,6 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) -1); } - delete visitor; - // Generate the anonymous sequence member typedef // but we must protect against certain versions of g++. // This provides a consistent name to use instead of the @@ -554,6 +505,7 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) << "typedef " << bt->nested_type_name (bu) << " _" << ub->local_name () << "_seq;" << be_uidt_nl; *os << "#endif /* ! __GNUC__ || ACE_HAS_GNUG_PRE_2_8 */\n" << be_nl; + os->incr_indent (); } @@ -575,7 +527,6 @@ be_visitor_valuetype_field_ch::visit_sequence (be_sequence *node) return 0; } -// Visit string type. int be_visitor_valuetype_field_ch::visit_string (be_string *node) { @@ -630,7 +581,6 @@ be_visitor_valuetype_field_ch::visit_string (be_string *node) return 0; } -// Visit structure type. int be_visitor_valuetype_field_ch::visit_structure (be_structure *node) { @@ -663,25 +613,12 @@ be_visitor_valuetype_field_ch::visit_structure (be_structure *node) if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // First generate the sequence declaration. ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_structure_ch visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_structure - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -689,8 +626,6 @@ be_visitor_valuetype_field_ch::visit_structure (be_structure *node) "codegen failed\n"), -1); } - - delete visitor; } // Set method. @@ -709,7 +644,6 @@ be_visitor_valuetype_field_ch::visit_structure (be_structure *node) return 0; } -// Visit typedefed type. int be_visitor_valuetype_field_ch::visit_typedef (be_typedef *node) { @@ -731,7 +665,6 @@ be_visitor_valuetype_field_ch::visit_typedef (be_typedef *node) return 0; } -// Visit union type. int be_visitor_valuetype_field_ch::visit_union (be_union *node) { @@ -764,25 +697,12 @@ be_visitor_valuetype_field_ch::visit_union (be_union *node) if (bt->node_type () != AST_Decl::NT_typedef && bt->is_child (bu)) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); - // First generate the sequence declaration. - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ch::" - "visit_union - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ch::" @@ -790,8 +710,6 @@ be_visitor_valuetype_field_ch::visit_union (be_union *node) "codegen failed\n"), -1); } - - delete visitor; } // Set method. @@ -812,7 +730,8 @@ be_visitor_valuetype_field_ch::visit_union (be_union *node) } void -be_visitor_valuetype_field_ch::setenclosings (const char *pre, const char *post) +be_visitor_valuetype_field_ch::setenclosings (const char *pre, + const char *post) { pre_op_ = pre; post_op_ = post; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ci.cpp index 25e78d69a86..a4ff2e23c85 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_ci.cpp @@ -20,112 +20,99 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_valuetype.h" -ACE_RCSID(be_visitor_valuetype, field_ci, "$Id$") +ACE_RCSID (be_visitor_valuetype, + field_ci, + "$Id$") -// constructor -be_visitor_valuetype_field_ci:: -be_visitor_valuetype_field_ci (be_visitor_context *ctx) +be_visitor_valuetype_field_ci::be_visitor_valuetype_field_ci ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx), in_obv_space_ (0) { setenclosings (""); } -// destructor -be_visitor_valuetype_field_ci:: -~be_visitor_valuetype_field_ci (void) +be_visitor_valuetype_field_ci::~be_visitor_valuetype_field_ci (void) { } -// visit the field node int -be_visitor_valuetype_field_ci:: -visit_field (be_field *node) +be_visitor_valuetype_field_ci::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } + return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field can be. int be_visitor_valuetype_field_ci::visit_array (be_array *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_array - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the valuetype + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous array type + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ci::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; @@ -170,56 +157,45 @@ be_visitor_valuetype_field_ci::visit_predefined_type (be_predefined_type *) int be_visitor_valuetype_field_ci::visit_sequence (be_sequence *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_sequence - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous sequence type + ctx.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; @@ -234,56 +210,45 @@ be_visitor_valuetype_field_ci::visit_string (be_string *) int be_visitor_valuetype_field_ci::visit_structure (be_structure *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_structure - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ci::" - "visit_structure - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_structure - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; @@ -298,56 +263,45 @@ be_visitor_valuetype_field_ci::visit_typedef (be_typedef *) int be_visitor_valuetype_field_ci::visit_union (be_union *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_union - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_ci::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_ci visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_ci::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } return 0; @@ -356,22 +310,26 @@ be_visitor_valuetype_field_ci::visit_union (be_union *node) void be_visitor_valuetype_field_ci::setenclosings (const char *pre) { - pre_op_ = pre; + this->pre_op_ = pre; } const char* be_visitor_valuetype_field_ci::pre_op () { - return pre_op_; + return this->pre_op_; } -// retrieve the fully scoped skeleton name +// Retrieve the fully scoped skeleton name. void be_visitor_valuetype_field_ci::op_name (be_valuetype *node, TAO_OutStream *os) { if (this->in_obv_space_) - *os << node->full_obv_skel_name (); + { + *os << node->full_obv_skel_name (); + } else - *os << node->name (); + { + *os << node->name (); + } } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp index 3a80831f824..d24c3ea34eb 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/field_cs.cpp @@ -21,683 +21,811 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_valuetype.h" -ACE_RCSID(be_visitor_valuetype, field_cs, "$Id$") +ACE_RCSID (be_visitor_valuetype, + field_cs, + "$Id$") -// constructor -be_visitor_valuetype_field_cs:: -be_visitor_valuetype_field_cs (be_visitor_context *ctx) +be_visitor_valuetype_field_cs::be_visitor_valuetype_field_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx), in_obv_space_ (0) { setenclosings (""); } -// destructor -be_visitor_valuetype_field_cs:: -~be_visitor_valuetype_field_cs (void) +be_visitor_valuetype_field_cs::~be_visitor_valuetype_field_cs (void) { } -// visit the field node int -be_visitor_valuetype_field_cs:: -visit_field (be_field *node) +be_visitor_valuetype_field_cs::visit_field (be_field *node) { be_type *bt = be_type::narrow_from_decl (node->field_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - this->ctx_->node (node); // save the node + this->ctx_->node (node); + if (bt->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_cs::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } + return 0; } -// =visit operations on all possible data types that a field can be +// Visit operations on all possible data types that a field can be int be_visitor_valuetype_field_cs::visit_array (be_array *node) { - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_array - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the valuetype + + TAO_OutStream *os = this->ctx_->stream (); + + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous array type + ctx.node (node); ctx.state (TAO_CodeGen::TAO_ARRAY_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } - // for anonymous arrays, the type name has a _ prepended. We compute the + // For anonymous arrays, the type name has a _ prepended. We compute the // full_name with or without the underscore and use it later on. - char fname [NAMEBUFSIZE]; // to hold the full and + char fname [NAMEBUFSIZE]; + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); - // save the node's local name and full name in a buffer for quick use later - // on - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // for anonymous arrays ... - // we have to generate a name for us that has an underscope prepended to - // our local name. This needs to be inserted after the parents's name - + // For anonymous arrays ... + // We have to generate a name for us that has an underscope prepended to + // our local name. This needs to be inserted after the parent's name. if (bt->is_nested ()) { be_decl *parent = be_scope::narrow_from_scope (bt->defined_in ())->decl (); - ACE_OS::sprintf (fname, "%s::_%s", parent->full_name (), + ACE_OS::sprintf (fname, + "%s::_%s", + parent->full_name (), bt->local_name ()->get_string ()); } else { - ACE_OS::sprintf (fname, "_%s", bt->full_name ()); + ACE_OS::sprintf (fname, + "_%s", + bt->full_name ()); } } else { - // typedefed node - ACE_OS::sprintf (fname, "%s", bt->full_name ()); + // Typedefed node. + ACE_OS::sprintf (fname, + "%s", + bt->full_name ()); } - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); *os << "::" << ub->local_name () << " (" << fname - << " val)// set" << be_nl - << "{" << be_idt_nl; + os->indent (); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// Accessor to set the member." << be_nl + << this->pre_op () << "void" << be_nl; + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " (" << fname + << " val)" << be_nl + << "{" << be_idt_nl; *os << fname << "_copy (" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ", val);" << be_uidt_nl; - *os << "}" << be_nl; - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << "const " << fname << "_slice *" << be_nl; - this->op_name(bu,os); + *os << "// Retrieve the member." << be_nl + << this->pre_op () << "const " << fname << "_slice *" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl; *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << ";" << be_uidt_nl + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}\n" << be_nl; - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << fname << "_slice *" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (void)" << be_nl + *os << "// Retrieve the member." << be_nl + << this->pre_op () << fname << "_slice *" << be_nl; + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl; - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << ";" << be_uidt_nl; + *os << "return this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl; *os << "}\n\n"; + return 0; } int be_visitor_valuetype_field_cs::visit_enum (be_enum *node) { - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_enum - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (" << bt->name () - << " val)// set" << be_nl + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " (" << bt->name () + << " val)/" << be_nl << "{\n"; + os->incr_indent (); + *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = val;\n"; + os->decr_indent (); + *os << "}" << be_nl; - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " () const" + *os << "// Retrieve the member." << be_nl + << this->pre_op () << bt->name () << be_nl; + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " () const" << be_nl << "{\n"; + os->incr_indent (); + *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix() << ub->local_name () + << bu->field_pd_postfix () << ";\n"; + os->decr_indent (); + *os << "}\n\n"; + return 0; } int be_visitor_valuetype_field_cs::visit_interface (be_interface *node) { - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl + << this->pre_op () << "void" << be_nl; + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " (" << bt->name () + << "_ptr val)" << be_nl << "{\n"; + os->incr_indent (); + *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = " << bt->name () << "::_duplicate (val);" << be_uidt_nl; *os << "}" << be_nl; - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << "_ptr " << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " () const" + *os << "// Retrieve the member." << be_nl + << this->pre_op () << bt->name () << "_ptr " << be_nl; + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " () const" << be_nl << "{\n"; + os->incr_indent (); + *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ".ptr ();\n"; + os->decr_indent (); + *os << "}\n\n"; + return 0; } int be_visitor_valuetype_field_cs::visit_interface_fwd (be_interface_fwd *node) { - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (" << bt->name () - << "_ptr val)// set" << be_nl + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl + << this->pre_op () << "void" << be_nl; + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " (" << bt->name () + << "_ptr val)" << be_nl << "{\n"; + os->incr_indent (); + *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = " << bt->name () << "::_duplicate (val);" << be_uidt_nl; *os << "}" << be_nl; - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << "_ptr " << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " () const" + *os << "// Retrieve the member" << be_nl + << this->pre_op () << bt->name () << "_ptr " << be_nl; + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " () const" << be_nl << "{\n"; + os->incr_indent (); + *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ".ptr ();\n"; + os->decr_indent (); + *os << "}\n\n"; + return 0; } int be_visitor_valuetype_field_cs::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " (" << bt->name () + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl + << this->pre_op () << "void" << be_nl; + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " (" << bt->name () << "* val)// set" << be_nl << "{\n"; + os->incr_indent (); + *os << "CORBA::add_ref (val);" << be_nl << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = val;" << be_uidt_nl; *os << "}" << be_nl; - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << "* " << be_nl; - this->op_name(bu,os); - *os << "::" << ub->local_name () << " () const" + *os << "// Retrieve the member" << be_nl + << this->pre_op () << bt->name () << "* " << be_nl; + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " () const" << be_nl << "{\n"; + os->incr_indent (); + *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ".ptr ();\n"; + os->decr_indent (); + *os << "}\n\n"; + return 0; } int be_visitor_valuetype_field_cs::visit_valuetype_fwd (be_valuetype_fwd *node) { - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_interface - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl << this->pre_op () << "void" << be_nl; - this->op_name (bu, os); - *os << "::" << ub->local_name () << " (" << bt->name () - << "* val)// set" << be_nl + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " (" << bt->name () + << "* val)" << be_nl << "{\n"; + os->incr_indent (); + *os << "CORBA::add_ref (val);" << be_nl << "this->" - << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = val;" << be_uidt_nl; *os << "}" << be_nl; - // get method - *os << "// retrieve the member" << be_nl + *os << "// Retrieve the member." << be_nl << this->pre_op () << bt->name () << "* " << be_nl; - this->op_name (bu, os); - *os << "::" << ub->local_name () << " () const" + + this->op_name (bu, + os); + + *os << "::" << ub->local_name () << " () const" << be_nl << "{\n"; + os->incr_indent (); + *os << "return this->" - << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix + () << ".ptr ();\n"; + os->decr_indent (); + *os << "}\n\n"; + return 0; } int be_visitor_valuetype_field_cs::visit_predefined_type (be_predefined_type *node) { - TAO_OutStream *os; // output stream - - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_predef... - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); - // set method - os->indent (); // start from current indentation - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); + TAO_OutStream *os = this->ctx_->stream (); + + os->indent (); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member." << be_nl + << this->pre_op () << "void" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (" << bt->name (); + if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "_ptr"; - *os << " val) // set" << be_nl + { + *os << "_ptr"; + } + + *os << " val)" << be_nl << "{" << be_idt_nl; - switch (node->pt ()) - { - case AST_PredefinedType::PT_pseudo: - *os << "this->" << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << " = " - << bt->name () << "::_duplicate (val);" << be_uidt_nl; - break; - - case AST_PredefinedType::PT_any: - *os << "ACE_NEW (" << be_idt << be_idt_nl - << "this->" << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << "," << be_nl - << bt->name () << " (val)" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl; - break; - - case AST_PredefinedType::PT_void: - break; - - default: - *os << "// set the value" << be_nl - << "this->" << bu->field_pd_prefix () << ub->local_name () - << bu->field_pd_postfix () - << " = val;" << be_uidt_nl; - } + switch (node->pt ()) + { + case AST_PredefinedType::PT_pseudo: + *os << "this->" << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = " + << bt->name () << "::_duplicate (val);" << be_uidt_nl; + break; + + case AST_PredefinedType::PT_any: + *os << "ACE_NEW (" << be_idt << be_idt_nl + << "this->" << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << "," << be_nl + << bt->name () << " (val)" << be_uidt_nl + << ");" << be_uidt << be_uidt_nl; + break; + + case AST_PredefinedType::PT_void: + break; + + default: + *os << "// Set the value." << be_nl + << "this->" << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () + << " = val;" << be_uidt_nl; + } + *os << "}" << be_nl; switch (node->pt ()) - { + { case AST_PredefinedType::PT_pseudo: - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << "_ptr" << be_nl; - this->op_name(bu,os); + *os << "// Retrieve the member" << be_nl + << this->pre_op () << bt->name () << "_ptr" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}\n\n"; break; case AST_PredefinedType::PT_any: - // get method with read-only access - *os << "// retrieve the member" << be_nl - << this->pre_op() << "const " << bt->name () << be_nl; - this->op_name(bu,os); + *os << "// Retrieve the member." << be_nl + << this->pre_op () << "const " << bt->name () << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}" << be_nl; - // get method with read/write access - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << be_nl; - this->op_name(bu,os); + *os << "// Retrieve the member" << be_nl + << this->pre_op () << bt->name () << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}\n\n"; break; case AST_PredefinedType::PT_void: break; default: - // get method - *os << "// retrieve the member" << be_nl - << this->pre_op() << bt->name () << be_nl; - this->op_name(bu,os); + *os << "// Retrieve the member" << be_nl + << this->pre_op () << bt->name () << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}\n\n"; - } + } + return 0; } int be_visitor_valuetype_field_cs::visit_sequence (be_sequence *node) { - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_sequence - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); + + TAO_OutStream *os = this->ctx_->stream (); if (bt->node_type () != AST_Decl::NT_typedef // not a typedef && bt->is_child (bu)) // bt is defined inside the union { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the inline operations for this anonymous sequence type + ctx.node (node); ctx.state (TAO_CodeGen::TAO_SEQUENCE_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + // (1) set from a const - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); + *os << "// Accessor to set the member." << be_nl + << this->pre_op () << "void" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (const " << bt->name () << " &val)" << be_nl << "{" << be_idt_nl; *os << "this->" - << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = val;" << be_uidt_nl; - *os << "}" << be_nl << be_nl; - // readonly get method - *os << "// readonly get method " << be_nl - << this->pre_op() << "const " << bt->name () << " &" << be_nl; - this->op_name(bu,os); + *os << "// Readonly get method." << be_nl + << this->pre_op () << "const " << bt->name () << " &" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl - << "return this->" // %! *this (seq_var, not seq member) - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << "return this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}" << be_nl << be_nl; - // read/write get method - *os << "// read/write get method " << be_nl - << this->pre_op() << bt->name () << " &" << be_nl; - this->op_name(bu,os); + *os << "// Read/write get method." << be_nl + << this->pre_op () << bt->name () << " &" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix() << ";" << be_uidt_nl << "}\n\n"; @@ -707,27 +835,31 @@ be_visitor_valuetype_field_cs::visit_sequence (be_sequence *node) int be_visitor_valuetype_field_cs::visit_string (be_string *node) { - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_string - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } + TAO_OutStream *os = this->ctx_->stream (); - // three methods to set the string value + // Three methods to set the string value. + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // (1) Set method from char* or wchar*. + os->indent (); - // (1) set method from char* or wchar* - os->indent (); // start from current indentation *os << "// accessor to set the member" << be_nl << this->pre_op () << "void" << be_nl; + this->op_name (bu, os); @@ -742,16 +874,17 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << be_nl << "{" << be_idt_nl; - - *os << "// set the value" << be_nl - << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val;" << be_uidt_nl + *os << "// set the value" << be_nl + << "this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () + << " = val;" << be_uidt_nl << "}" << be_nl; - // (2) set method from const char * or const wchar* - *os << "// accessor to set the member" << be_nl + // (2) Set method from const char * or const wchar*. + *os << "// Accessor to set the member." << be_nl << this->pre_op () << "void" << be_nl; + this->op_name (bu, os); *os << "::" << ub->local_name (); @@ -766,11 +899,13 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) } *os << "{\n"; + os->incr_indent (); - *os << "// set the value" << be_nl + *os << "// Set the value." << be_nl << "this->" - << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = "; if (node->width () == (long) sizeof (char)) @@ -784,11 +919,13 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << "}" << be_nl; - // (3) set from const String_var& - *os << "// accessor to set the member" << be_nl + // (3) Set from const String_var&. + *os << "// Accessor to set the member." << be_nl << this->pre_op () << "void" << be_nl; + this->op_name (bu, os); + *os << "::" << ub->local_name (); if (node->width () == (long) sizeof (char)) @@ -802,7 +939,6 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << "{" << be_idt_nl; *os << ";" << be_nl; - *os << "// set the value" << be_nl; if (node->width () == (long) sizeof (char)) @@ -816,13 +952,12 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) *os << "_var = val;" << be_nl << "this->" - << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << " = " << ub->local_name () << "_var._retn ();" << be_uidt_nl; - *os << "}" << be_nl; - // get method if (node->width () == (long) sizeof (char)) { *os << this->pre_op () << "const char *" << be_nl; @@ -834,139 +969,112 @@ be_visitor_valuetype_field_cs::visit_string (be_string *node) this->op_name (bu, os); + *os << "::" << ub->local_name () << " (void) const // get method" << be_nl << "{" << be_idt_nl << "return this->" - << bu->field_pd_prefix () << ub->local_name () << bu->field_pd_postfix () + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}\n\n"; + return 0; } int be_visitor_valuetype_field_cs::visit_structure (be_structure *node) { - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_structure - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + TAO_OutStream *os = this->ctx_->stream (); + + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_structure - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_structure - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } - // (1) set from a const - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + // (1) Set from a const. + *os << "// Accessor to set the member." << be_nl + << this->pre_op () << "void" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (const " << bt->name () << " &val)" << be_nl << "{" << be_idt_nl; - if (0) // %! (bt->size_type () == be_type::VARIABLE) - { cerr <<"!t VARIABLE struct in field_cs\n"; - *os << "delete this->" - << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() - << ";" << be_nl; + *os << "this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () + << " = val;" << be_uidt_nl; - *os << "ACE_NEW (" << be_idt << be_idt_nl - << "this->" << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << "," << be_nl - << bt->name () << " (val)" << be_uidt_nl - << ");" << be_uidt << be_uidt_nl; + *os << "}" << be_nl; -// This was replaced by the above output statement, but this doesn't work -// *os << "this->" -// << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() -// << " = new " -// << bt->name () << " (val);" << be_uidt_nl; - } - else - { - *os << "this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << " = val;" << be_uidt_nl; - } + *os << "// Readonly get method." << be_nl + << this->pre_op () << "const " << bt->name () << " &" << be_nl; - *os << "}" << be_nl; + this->op_name (bu, + os); - // readonly get method - *os << "// readonly get method " << be_nl - << this->pre_op() << "const " << bt->name () << " &" << be_nl; - this->op_name(bu,os); *os << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl; - if (0) // %! (bt->size_type () == be_type::VARIABLE) - *os << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl; - else - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl; + *os << "return this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () + << ";" << be_uidt_nl; *os << "}" << be_nl; - // read/write get method - *os << "// read/write get method " << be_nl - << this->pre_op() << bt->name () << " &" << be_nl; - this->op_name(bu,os); + *os << "// Read/write get method." << be_nl + << this->pre_op () << bt->name () << " &" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl; - if (0) // %! (bt->size_type () == be_type::VARIABLE) - *os << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl; - else - *os << "return this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() - << ";" << be_uidt_nl; + *os << "return this->" + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () + << ";" << be_uidt_nl; *os << "}\n\n"; return 0; @@ -975,18 +1083,16 @@ be_visitor_valuetype_field_cs::visit_structure (be_structure *node) int be_visitor_valuetype_field_cs::visit_typedef (be_typedef *node) { - this->ctx_->alias (node); // save the typedef node for use in code generation - // as we visit the base type - - // the node to be visited in the base primitve type that gets typedefed + this->ctx_->alias (node); be_type *bt = node->primitive_base_type (); + if (!bt || (bt->accept (this) == -1)) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_typedef - " - "Bad primitive type\n" - ), -1); + "Bad primitive type\n"), + -1); } this->ctx_->alias (0); @@ -996,102 +1102,93 @@ be_visitor_valuetype_field_cs::visit_typedef (be_typedef *node) int be_visitor_valuetype_field_cs::visit_union (be_union *node) { - cerr << "!u be_visitor_valuetype_field_cs::visit_union unimp.\n"; - TAO_OutStream *os; // output stream - be_decl *ub = - this->ctx_->node (); // get field node - be_valuetype *bu = - be_valuetype::narrow_from_decl (this->ctx_->scope ()); + be_decl *ub = this->ctx_->node (); + be_valuetype *bu = be_valuetype::narrow_from_decl (this->ctx_->scope ()); be_type *bt; - // check if we are visiting this node via a visit to a typedef node + // Check if we are visiting this node via a visit to a typedef node. if (this->ctx_->alias ()) - bt = this->ctx_->alias (); + { + bt = this->ctx_->alias (); + } else - bt = node; + { + bt = node; + } if (!ub || !bu) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_union - " - "bad context information\n" - ), -1); + "bad context information\n"), + -1); } - os = this->ctx_->stream (); - if (bt->node_type () != AST_Decl::NT_typedef // not a typedef - && bt->is_child (bu)) // bt is defined inside the union + TAO_OutStream *os = this->ctx_->stream (); + + if (bt->node_type () != AST_Decl::NT_typedef + && bt->is_child (bu)) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope - // is still the same - - // first generate the enum declaration + ctx.node (node); ctx.state (TAO_CodeGen::TAO_UNION_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_field_cs::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cs visitor (&ctx); + + if (node->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_field_cs::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } - // (1) set from a const - *os << "// accessor to set the member" << be_nl - << this->pre_op() << "void" << be_nl; - this->op_name(bu,os); + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + + *os << "// Accessor to set the member" << be_nl + << this->pre_op () << "void" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (const " << bt->name () << " &val)" << be_nl << "{" << be_idt_nl; - *os << "ACE_NEW (" << be_idt << be_idt_nl - << "this->" << bu->field_pd_prefix() << ub->local_name () - << bu->field_pd_postfix() << "_var," << be_nl + << "this->" << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << "_var," << be_nl << bt->name () << " (val)" << be_uidt_nl << ");" << be_uidt << be_uidt_nl; + *os << "}" << be_nl; -// This was replaced by the above output statement, but this doesn't work -// *os << "this->" -// << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() -// << "_var = new " << bt->name () -// << " (val);" << be_uidt_nl; + *os << "// Readonly get method." << be_nl + << this->pre_op () << "const " << bt->name () << " &" << be_nl; - *os << "}" << be_nl; + this->op_name (bu, + os); - // readonly get method - *os << "// readonly get method " << be_nl - << this->pre_op() << "const " << bt->name () << " &" << be_nl; - this->op_name(bu,os); *os << "::" << ub->local_name () << " (void) const" << be_nl << "{" << be_idt_nl << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}" << be_nl; - // read/write get method - *os << "// read/write get method " << be_nl - << this->pre_op() << bt->name () << " &" << be_nl; - this->op_name(bu,os); + *os << "// Read/write get method." << be_nl + << this->pre_op () << bt->name () << " &" << be_nl; + + this->op_name (bu, + os); + *os << "::" << ub->local_name () << " (void)" << be_nl << "{" << be_idt_nl << "return *this->" - << bu->field_pd_prefix() << ub->local_name () << bu->field_pd_postfix() + << bu->field_pd_prefix () << ub->local_name () + << bu->field_pd_postfix () << ";" << be_uidt_nl << "}\n\n"; @@ -1101,22 +1198,26 @@ be_visitor_valuetype_field_cs::visit_union (be_union *node) void be_visitor_valuetype_field_cs::setenclosings (const char *pre) { - pre_op_ = pre; + this->pre_op_ = pre; } const char* be_visitor_valuetype_field_cs::pre_op () { - return pre_op_; + return this->pre_op_; } -// retrieve the fully scoped skeleton name +// Retrieve the fully scoped skeleton name. void be_visitor_valuetype_field_cs::op_name (be_valuetype *node, TAO_OutStream *os) { if (this->in_obv_space_) - *os << node->full_obv_skel_name (); + { + *os << node->full_obv_skel_name (); + } else - *os << node->name (); + { + *os << node->name (); + } } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp index e53d67fa7d2..63caf813a69 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/obv_module.cpp @@ -20,15 +20,15 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "be.h" -ACE_RCSID(be_visitor_obv_module, obv_module, "$Id$") +ACE_RCSID (be_visitor_obv_module, + obv_module, + "$Id$") // ************************************************************ -// Module visitor for server header +// OBV module visitor for server header. // ************************************************************ be_visitor_obv_module::be_visitor_obv_module (be_visitor_context *ctx) @@ -40,19 +40,10 @@ be_visitor_obv_module::~be_visitor_obv_module (void) { } - - -// This states are processed: -// TAO_MODULE_OBV_CH -// TAO_MODULE_OBV_CI -// TAO_MODULE_OBV_CH - - int be_visitor_obv_module::visit_module (be_module *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); if (node->has_nested_valuetype ()) { @@ -60,25 +51,30 @@ be_visitor_obv_module::visit_module (be_module *node) { os->indent (); - *os << "TAO_NAMESPACE "; // << idl_global->skel_export_macro () + *os << "TAO_NAMESPACE "; if (!node->is_nested ()) - // we are outermost module, so prepend + { + // We are outermost module, so prepend. *os << " OBV_" << node->local_name () << be_nl; + } else - // we are inside another module + { + // We are inside another module. *os << " " << node->local_name () << be_nl; + } *os << "{" << be_nl << be_idt; - } // client header + } if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_obv_module::" "visit_module - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } if (this->ctx_->state () == TAO_CodeGen::TAO_MODULE_OBV_CH) @@ -87,6 +83,7 @@ be_visitor_obv_module::visit_module (be_module *node) *os << "}\nTAO_NAMESPACE_CLOSE\n\n"; } } + return 0; } @@ -94,11 +91,8 @@ be_visitor_obv_module::visit_module (be_module *node) int be_visitor_obv_module::visit_valuetype (be_valuetype *node) { - // instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); - ctx.node (node); // set the node to be the node being visited. The scope is - // still the same + ctx.node (node); switch (this->ctx_->state ()) { @@ -117,60 +111,63 @@ be_visitor_obv_module::visit_valuetype (be_valuetype *node) "(%N:%l) be_visitor_obv_module::" "visit_valuetype - " "Bad context state\n" - ), -1); + ), + -1); } } - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state ())); be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_obv_module::" "visit_valuetype - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_obv_module::" "visit_valuetype - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; - // Do addtional "extra" code generation if necessary + // Do addtional "extra" code generation if necessary. if (node->has_extra_code_generation (ctx.state ())) { - // Change the state depending on the kind of node strategy + // Change the state depending on the kind of node strategy. ctx.state (node->next_state (ctx.state (), 1)); visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_obv_module::" "visit_valuetype - " - "NUL visitor\n" - ), -1); + "NUL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_obv_module::" "visit_valuetype - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; visitor = 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp index 5239193cffd..7be03891886 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp @@ -21,8 +21,16 @@ #include "be_visitor_valuetype.h" #include "be_visitor_field.h" +#include "be_visitor_constant.h" +#include "be_visitor_enum.h" +#include "be_visitor_exception.h" +#include "be_visitor_structure.h" +#include "be_visitor_typedef.h" +#include "be_visitor_union.h" -ACE_RCSID(be_visitor_valuetype, valuetype, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype, + "$Id$") be_visitor_valuetype::be_visitor_valuetype (be_visitor_context *ctx) : be_visitor_scope (ctx) @@ -44,7 +52,6 @@ int be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) { int n_processed = 0; - this->elem_number_ = 0; for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); @@ -63,21 +70,20 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) AST_Field *field = AST_Field::narrow_from_decl (d); - if (field && field->visibility() == AST_Field::vis_PRIVATE) + if (field && field->visibility () == AST_Field::vis_PRIVATE) { - continue; // ignore private fields in this run + 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 + // 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 + // for code generation. this->ctx_->scope (node->decl ()); - - // set the node to be visited this->ctx_->node (bd); this->elem_number_++; @@ -89,7 +95,7 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) -1); } - } // end of for loop + } this->elem_number_ = 0; @@ -129,8 +135,6 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) // for code generation. this->ctx_->scope (node->decl ()); - - // Set the node to be visited. this->ctx_->node (bd); this->elem_number_++; @@ -167,21 +171,16 @@ be_visitor_valuetype::visit_attribute (be_attribute *node) this->ctx_->node (node); this->ctx_->attribute (node); - be_operation *op = 0; - ACE_NEW_RETURN (op, - be_operation (node->field_type (), - AST_Operation::OP_noflags, - node->name (), - 0, - 0), - -1); + be_operation op (node->field_type (), + AST_Operation::OP_noflags, + node->name (), + 0, + 0); - op->set_name ((UTL_IdList *) node->name ()->copy ()); + op.set_name ((UTL_IdList *) node->name ()->copy ()); - if (!op || this->visit_operation (op) == -1) + if (this->visit_operation (&op) == -1) { - delete op; - op = 0; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " @@ -189,66 +188,39 @@ be_visitor_valuetype::visit_attribute (be_attribute *node) -1); } - delete op; - op = 0; - if (node->readonly ()) { // Nothing else to do. return 0; } - // The set method. - // The return type is "void". - - Identifier *id = 0; - UTL_ScopedName *sn = 0; + Identifier id ("void"); - ACE_NEW_RETURN (id, - Identifier ("void"), - -1); + UTL_ScopedName sn (&id, + 0); - ACE_NEW_RETURN (sn, - UTL_ScopedName (id, - 0), - -1); - - be_predefined_type *rt = 0; - ACE_NEW_RETURN (rt, - be_predefined_type (AST_PredefinedType::PT_void, - sn), - -1); + be_predefined_type rt (AST_PredefinedType::PT_void, + &sn); // Argument type is the same as the attribute type. - be_argument *arg = 0; - ACE_NEW_RETURN (arg, - be_argument (AST_Argument::dir_IN, - node->field_type (), - node->name ()), - -1); + be_argument arg (AST_Argument::dir_IN, + node->field_type (), + node->name ()); - arg->set_name ((UTL_IdList *) node->name ()->copy ()); + arg.set_name ((UTL_IdList *) node->name ()->copy ()); // Create the operation. - ACE_NEW_RETURN (op, - be_operation (rt, - AST_Operation::OP_noflags, - node->name (), - 0, - 0), - -1); - - op->set_name ((UTL_IdList *) node->name ()->copy ()); - op->add_argument_to_scope (arg); - - if (!op || this->visit_operation (op) == -1) + be_operation op2 (&rt, + AST_Operation::OP_noflags, + node->name (), + 0, + 0); + + op.set_name ((UTL_IdList *) node->name ()->copy ()); + op.add_argument_to_scope (&arg); + + if (this->visit_operation (&op2) == -1) { - delete op; - op = 0; - delete arg; - arg = 0; - delete rt; - rt = 0; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " @@ -256,12 +228,6 @@ be_visitor_valuetype::visit_attribute (be_attribute *node) -1); } - delete op; - op = 0; - delete rt; - rt = 0; - delete arg; - arg = 0; return 0; } @@ -269,22 +235,26 @@ be_visitor_valuetype::visit_attribute (be_attribute *node) int be_visitor_valuetype::visit_constant (be_constant *node) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CH); + be_visitor_constant_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_CONSTANT_CS); + be_visitor_constant_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -310,18 +280,7 @@ be_visitor_valuetype::visit_constant (be_constant *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_constant - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" @@ -330,44 +289,61 @@ be_visitor_valuetype::visit_constant (be_constant *node) -1); } - delete visitor; return 0; } int be_visitor_valuetype::visit_enum (be_enum *node) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CH); + be_visitor_enum_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CS); + be_visitor_enum_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CH); + be_visitor_enum_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_ANY_OP_CS); + be_visitor_enum_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); - break; - case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CH); + be_visitor_enum_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_ENUM_CDR_OP_CI); + be_visitor_enum_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } + case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -388,18 +364,7 @@ be_visitor_valuetype::visit_enum (be_enum *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_enum - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" @@ -408,7 +373,6 @@ be_visitor_valuetype::visit_enum (be_enum *node) -1); } - delete visitor; return 0; } @@ -423,41 +387,68 @@ be_visitor_valuetype::visit_operation (be_operation *) int be_visitor_valuetype::visit_exception (be_exception *node) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CH); + be_visitor_exception_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CI); + be_visitor_exception_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CS); + be_visitor_exception_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CH); + be_visitor_exception_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_ANY_OP_CS); + be_visitor_exception_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CH); + be_visitor_exception_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CI); + be_visitor_exception_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); - break; - + { + ctx.state (TAO_CodeGen::TAO_EXCEPTION_CDR_OP_CS); + be_visitor_exception_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_SH: case TAO_CodeGen::TAO_VALUETYPE_IH: case TAO_CodeGen::TAO_VALUETYPE_SI: @@ -485,18 +476,7 @@ be_visitor_valuetype::visit_exception (be_exception *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_interface::" - "visit_exception - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" @@ -505,47 +485,74 @@ be_visitor_valuetype::visit_exception (be_exception *node) -1); } - delete visitor; return 0; } int be_visitor_valuetype::visit_structure (be_structure *node) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CH); + be_visitor_structure_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CI); + be_visitor_structure_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CS); + be_visitor_structure_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CH); + be_visitor_structure_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_ANY_OP_CS); + be_visitor_structure_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CH); + be_visitor_structure_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CI); + be_visitor_structure_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_STRUCT_CDR_OP_CS); + be_visitor_structure_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -565,18 +572,7 @@ be_visitor_valuetype::visit_structure (be_structure *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_structure - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" @@ -585,47 +581,74 @@ be_visitor_valuetype::visit_structure (be_structure *node) -1); } - delete visitor; return 0; } int be_visitor_valuetype::visit_union (be_union *node) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CH); + be_visitor_union_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CI); + be_visitor_union_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CS); + be_visitor_union_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CH); + be_visitor_union_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_ANY_OP_CS); + be_visitor_union_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CH); + be_visitor_union_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CI); + be_visitor_union_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_UNION_CDR_OP_CS); + be_visitor_union_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -645,18 +668,7 @@ be_visitor_valuetype::visit_union (be_union *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_union - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" @@ -665,47 +677,74 @@ be_visitor_valuetype::visit_union (be_union *node) -1); } - delete visitor; return 0; } int be_visitor_valuetype::visit_typedef (be_typedef *node) { - // Instantiate a visitor context with a copy of our context. This info - // will be modified based on what type of node we are visiting. be_visitor_context ctx (*this->ctx_); ctx.node (node); - - // This switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set. + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CH); + be_visitor_typedef_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CI); + be_visitor_typedef_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CS); + be_visitor_typedef_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CH); + be_visitor_typedef_any_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_ANY_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_ANY_OP_CS); + be_visitor_typedef_any_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CH: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CH); + be_visitor_typedef_cdr_op_ch visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CI: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CI); + be_visitor_typedef_cdr_op_ci visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_CDR_OP_CS: - ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); - break; + { + ctx.state (TAO_CodeGen::TAO_TYPEDEF_CDR_OP_CS); + be_visitor_typedef_cdr_op_cs visitor (&ctx); + status = node->accept (&visitor); + break; + } case TAO_CodeGen::TAO_VALUETYPE_OBV_CH: case TAO_CodeGen::TAO_VALUETYPE_OBV_CI: case TAO_CodeGen::TAO_VALUETYPE_OBV_CS: @@ -725,18 +764,7 @@ be_visitor_valuetype::visit_typedef (be_typedef *node) } } - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype::" - "visit_typedef - " - "NULL visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" @@ -745,7 +773,6 @@ be_visitor_valuetype::visit_typedef (be_typedef *node) -1); } - delete visitor; return 0; } @@ -762,7 +789,6 @@ int be_visitor_valuetype::gen_pd (be_valuetype *node) { int n_processed = 0; - this->elem_number_ = 0; for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); @@ -784,14 +810,15 @@ be_visitor_valuetype::gen_pd (be_valuetype *node) { continue; } + ++n_processed; + // 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 ()); - // set the node to be visited + // Set the node to be visited. this->ctx_->node (field); this->elem_number_++; @@ -812,13 +839,10 @@ int be_visitor_valuetype::gen_field_pd (be_field *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; - be_valuetype *vt; - os = this->ctx_->stream (); // First generate the type information. - bt = be_type::narrow_from_decl (node->field_type ()); - vt = be_valuetype::narrow_from_scope (node->defined_in ()); + be_type *bt = be_type::narrow_from_decl (node->field_type ()); + be_valuetype *vt = be_valuetype::narrow_from_scope (node->defined_in ()); if (!bt || !vt) { @@ -852,6 +876,7 @@ be_visitor_valuetype::gen_field_pd (be_field *node) *os << " " << vt->field_pd_prefix () << node->local_name () << vt->field_pd_postfix() << ";" << be_nl; + return 0; } @@ -974,11 +999,11 @@ be_visitor_valuetype::determine_factory_style (be_valuetype* node) } // end of for loop } // end of if - if(!have_operation && !have_factory) + if (!have_operation && !have_factory) { factory_style = FS_CONCRETE_FACTORY; } - else if(have_operation && !have_factory) + else if (have_operation && !have_factory) { factory_style = FS_NO_FACTORY; } @@ -1031,24 +1056,24 @@ be_visitor_valuetype::have_operation(be_valuetype* node) AST_Decl::NodeType node_type = d->node_type(); - if(node_type == AST_Decl::NT_op) + if (node_type == AST_Decl::NT_op) { have_operation = 1; continue; } - if(node_type == AST_Decl::NT_attr) + if (node_type == AST_Decl::NT_attr) { have_operation = 1; continue; } - if(node_type == AST_Decl::NT_factory) + if (node_type == AST_Decl::NT_factory) { continue; } - if(node_type == AST_Decl::NT_field) + if (node_type == AST_Decl::NT_field) { continue; } @@ -1101,20 +1126,17 @@ be_visitor_valuetype::obv_need_ref_counter (be_valuetype* node) } // Now go thru our base VTs and see if one has already. - - int i; // loop index - - for (i = 0; i < node->n_inherits (); ++i) + for (int i = 0; i < node->n_inherits (); ++i) { AST_Interface *inherited = AST_Interface::narrow_from_decl (node->inherits ()[i]); - if (!inherited || !inherited->is_valuetype()) + if (!inherited || !inherited->is_valuetype ()) { continue; } - be_valuetype *vt = be_valuetype::narrow_from_decl(node->inherits ()[i]); + be_valuetype *vt = be_valuetype::narrow_from_decl (node->inherits ()[i]); if (vt != 0) { @@ -1123,7 +1145,7 @@ be_visitor_valuetype::obv_need_ref_counter (be_valuetype* node) return 0; } } - } // end of for loop + } return 1; } @@ -1144,15 +1166,12 @@ be_visitor_valuetype::obv_have_ref_counter (be_valuetype* node) } // Now go thru our base VTs. - - int i; // loop index - - for (i = 0; i < node->n_inherits (); ++i) + for (int i = 0; i < node->n_inherits (); ++i) { AST_Interface *inherited = AST_Interface::narrow_from_decl (node->inherits ()[i]); - if (!inherited || !inherited->is_valuetype()) + if (!inherited || !inherited->is_valuetype ()) { continue; } @@ -1166,7 +1185,7 @@ be_visitor_valuetype::obv_have_ref_counter (be_valuetype* node) return 1; } } - } // end of for loop + } return 0; } 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 7890fd7ac59..43021787f23 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ch.cpp @@ -20,13 +20,14 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_valuetype.h" +#include "be_visitor_typecode/typecode_decl.h" +#include "be_visitor_operation/rettype.h" -ACE_RCSID(be_visitor_valuetype, valuetype_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype_ch, + "$Id$") // ****************************************************** @@ -49,6 +50,9 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) if (!node->cli_hdr_gen () && !node->imported ()) { + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; + *os << "// Valuetype class" << be_nl; // == STEP 1: Generate the class name and class names we inherit == @@ -79,18 +83,20 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) os->gen_endif (); // Generate the ifdef macro for the _out class. - os->gen_ifdef_macro (node->flat_name (), "_out"); + os->gen_ifdef_macro (node->flat_name (), + "_out"); - // Generate the _out declaration + // Generate the _out declaration. if (node->gen_out_defn () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_valuetype - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } - // generate the endif macro. + // Generate the endif macro. os->gen_endif (); } @@ -110,13 +116,14 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) // (ordinary (not abstract) interfaces ignored). *os << be_idt_nl <<": "; + int i; // loop index int n_inherits_valuetypes = 0; idl_bool valuebase_inherited = 0; if (node->n_inherits () > 0) { - for (i = 0; i < node->n_inherits (); i++) + for (i = 0; i < node->n_inherits (); ++i) { // %! move is_nested() and nested_type_name() to // AST_Interface, then type AST_Interface can be used @@ -191,16 +198,16 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) *os << "{" << be_nl << "public:" << be_idt_nl - // Generate the _ptr_type and _var_type typedef - // but we must protect against certain versions of g++ + // Generate the _ptr_type and _var_type typedef + // but we must protect against certain versions of g++ << "\n#if !defined(__GNUC__) || !defined (ACE_HAS_GNUG_PRE_2_8)" << be_nl << "typedef " << node->local_name () << "* _ptr_type;" << be_nl << "typedef " << node->local_name () << "_var _var_type;\n" << "#endif /* ! __GNUC__ || g++ >= 2.8 */" << be_nl << be_nl - // Generate the static _downcast operation. - // (see OMG 20.17.{4,5}). + // Generate the static _downcast operation. + // (see OMG 20.17.{4,5}). << "static " << node->local_name () << "* " << "_downcast (CORBA::ValueBase* );" << be_nl << "// The address of static _downcast is implicit used as type id\n" @@ -250,8 +257,8 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << "_tao_marshal_v (TAO_OutputCDR &);" << be_nl; *os << "virtual CORBA::Boolean " << "_tao_unmarshal_v (TAO_InputCDR &);" << be_nl; - // %! optimize _downcast away: extra parameter with type info - // set (void *) in CDR Stream with the right derived pointer. + // %! optimize _downcast away: extra parameter with type info + // set (void *) in CDR Stream with the right derived pointer. } @@ -265,7 +272,7 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << "void operator= (const " << node->local_name () << " &);" << be_nl; - // Map fields to private data (if optimizing). + // Map fields to private data (if optimizing). if (node->opt_accessor ()) { *os << be_uidt_nl << "protected:" << be_idt_nl; @@ -275,6 +282,7 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) << "_tao_unmarshal_state (TAO_InputCDR &);" << be_uidt_nl << be_nl; *os << "private:" << be_idt_nl; + this->gen_pd (node); } else // Need a way to access the state of derived OBV_ classes. @@ -292,51 +300,40 @@ be_visitor_valuetype_ch::visit_valuetype (be_valuetype *node) } *os << be_uidt_nl << "};" << be_nl; + os->gen_endif (); // Generate the _init -related declarations. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_valuetype_init_ch visitor (&ctx); - if (!visitor) + if (visitor.visit_valuetype (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_valuetype - " - "NULL visitor.\n" - ), -1); + "failed to generate _init construct.\n"), + -1); } - if (visitor->visit_valuetype(node) == -1) + // Step last: generate typecode declaration. + if (be_global->tc_support ()) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "failed to generate _init construct.\n" - ), -1); - } + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); + be_visitor_typecode_decl visitor (&ctx); - delete visitor; - - // Step last: generate typecode declaration - { - be_visitor *visitor; - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_TYPECODE_DECL); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_structure - " - "TypeCode declaration failed\n" - ), - -1); - } - } + if (node->accept (&visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_ch::" + "visit_structure - " + "TypeCode declaration failed\n"), + -1); + } + } node->cli_hdr_gen (I_TRUE); @@ -348,7 +345,6 @@ int be_visitor_valuetype_ch::visit_operation (be_operation *node) { TAO_OutStream *os = this->ctx_->stream (); - be_type *bt; this->ctx_->node (node); // save the node @@ -356,7 +352,7 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) *os << "virtual "; // STEP I: Generate the return type. - bt = be_type::narrow_from_decl (node->return_type ()); + be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) { @@ -370,20 +366,10 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) // Grab the right visitor to generate the return type. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETTYPE_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ch::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_rettype or_visitor (&ctx); - if (bt->accept (visitor) == -1) + if (bt->accept (&or_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_operation - " @@ -391,8 +377,6 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) -1); } - delete visitor; - // STEP 2: Generate the operation name. *os << " " << node->local_name (); @@ -400,20 +384,10 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) // we grab a visitor that generates the parameter listing. ctx = *this->ctx_; ctx.state (TAO_CodeGen::TAO_OBV_OPERATION_ARGLIST_CH); - visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_ch::" - "visit_operation - " - "Bad visitor to argument list\n"), - -1); - } + be_visitor_obv_operation_arglist ooa_visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&ooa_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_ch::" "visit_operation - " @@ -421,8 +395,6 @@ be_visitor_valuetype_ch::visit_operation (be_operation *node) -1); } - delete visitor; - return 0; } @@ -438,36 +410,25 @@ be_visitor_valuetype_ch::visit_field (be_field *node) be_visitor_context* ctx = new be_visitor_context (*this->ctx_); ctx->state (TAO_CodeGen::TAO_FIELD_OBV_CH); - be_visitor_valuetype_field_ch *visitor = - new be_visitor_valuetype_field_ch (ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_obv_ch::" - "visit_field - bad visitor\n"), - -1); - } + be_visitor_valuetype_field_ch visitor (ctx); if (vt->opt_accessor ()) { - visitor->setenclosings ("",";"); + visitor.setenclosings ("",";"); } else { - visitor->setenclosings ("virtual "," = 0;"); + visitor.setenclosings ("virtual "," = 0;"); } - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_obv_ch::" - "visit_field - codegen failed\n"), + "visit_field - codegen failed\n"), -1); } - delete visitor; return 0; } @@ -476,6 +437,7 @@ void be_visitor_valuetype_ch::begin_public (void) { TAO_OutStream *os = this->ctx_->stream (); + *os << "public:" << be_idt_nl; } @@ -483,5 +445,6 @@ void be_visitor_valuetype_ch::begin_private (void) { TAO_OutStream *os = this->ctx_->stream (); + *os << be_uidt_nl << "protected:" << be_idt_nl; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp index 6fa624a44fe..98c5d6eba6b 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_ci.cpp @@ -19,17 +19,16 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_valuetype.h" -ACE_RCSID(be_visitor_valuetype, valuetype_ci, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype_ci, + "$Id$") // ************************************************** -// Valuetype visitor for client inline +// Valuetype visitor for client inline. // ************************************************** be_visitor_valuetype_ci::be_visitor_valuetype_ci (be_visitor_context *ctx) : be_visitor_valuetype (ctx), @@ -44,21 +43,23 @@ be_visitor_valuetype_ci::~be_visitor_valuetype_ci (void) int be_visitor_valuetype_ci::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os; // output stream - if (node->cli_inline_gen () || node->imported ()) - return 0; + { + return 0; + } - //@@ What is that? - // need to access it in visit_field () if (node->opt_accessor ()) - this->opt_accessor_ = 1; + { + this->opt_accessor_ = 1; + } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start from the current indentation level + os->indent (); + + *os << be_nl << "// TAO_IDL - Generated from " + << __FILE__ << ":" << __LINE__ << be_nl << be_nl; - // generate the constructors and destructor *os << "ACE_INLINE" << be_nl; *os << node->name () << "::" << node->local_name () << " () // default constructor" << be_nl; @@ -75,40 +76,29 @@ be_visitor_valuetype_ci::visit_valuetype (be_valuetype *node) << "return \"" << node->repoID () << "\";" << be_uidt_nl << "}\n\n"; - // generate inline methods for elements of our scope if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ci::" "visit_valuetype - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - // Generate the _init -related code. + // Generate the _init-related code. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_valuetype_init_ci visitor (&ctx); - if (!visitor) + if (visitor.visit_valuetype (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ci::" "visit_valuetype - " - "NULL visitor.\n" - ), -1); + "failed to generate _init construct.\n"), + -1); } - if (visitor->visit_valuetype(node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ci::" - "visit_valuetype - " - "failed to generate _init construct.\n" - ), -1); - } - - delete visitor; - return 0; } @@ -118,22 +108,19 @@ be_visitor_valuetype_ci::visit_field (be_field *node) { if (opt_accessor_) { - be_visitor_context *ctx = new be_visitor_context (*this->ctx_); - be_visitor_valuetype_field_cs *visitor = - new be_visitor_valuetype_field_cs (ctx); - visitor->in_obv_space_ = 0; - visitor->setenclosings ("ACE_INLINE "); + be_visitor_context ctx (*this->ctx_); + be_visitor_valuetype_field_cs visitor (&ctx); + visitor.in_obv_space_ = 0; + visitor.setenclosings ("ACE_INLINE "); - if (visitor->visit_field (node) == -1) + if (visitor.visit_field (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ci::" "visit_field - " - "visit_field failed\n" - ), -1); + "visit_field failed\n"), + -1); } - - delete visitor; } 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 fa658ecdffb..70161628737 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_cs.cpp @@ -19,17 +19,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_valuetype.h" +#include "be_visitor_typecode/typecode_defn.h" -ACE_RCSID(be_visitor_valuetype, valuetype_cs, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype_cs, + "$Id$") // ************************************************************ -// Valuetype visitor for client stubs +// Valuetype visitor for client stubs. // ************************************************************ be_visitor_valuetype_cs::be_visitor_valuetype_cs (be_visitor_context *ctx) @@ -44,43 +44,40 @@ be_visitor_valuetype_cs::~be_visitor_valuetype_cs (void) int be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) { - TAO_OutStream *os; // output stream - if (node->cli_stub_gen () || node->imported ()) { return 0; } - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - { - be_visitor *visitor; - be_visitor_context ctx (*this->ctx_); - ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); - ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); - visitor = tao_cg->make_visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_cs::" - "visit_valuetype - " - "TypeCode definition failed\n" - ), -1); - } - } + if (be_global->tc_support ()) + { + be_visitor_context ctx (*this->ctx_); + ctx.state (TAO_CodeGen::TAO_TYPECODE_DEFN); + ctx.sub_state (TAO_CodeGen::TAO_TC_DEFN_TYPECODE); + be_visitor_typecode_defn tc_visitor (&ctx); + + if (node->accept (&tc_visitor) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_cs::" + "visit_valuetype - " + "TypeCode definition failed\n"), + -1); + } + } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - os->indent (); // start with whatever indentation level we are at + os->indent (); - // Generate methods for _var class + // Generate methods for _var class. if (node->gen_var_impl () == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_cs::" "visit_valuetype - " - "codegen for _var failed\n"), -1); + "codegen for _var failed\n"), + -1); } // Generate methods for _out class @@ -89,7 +86,8 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_cs::" "visit_valuetype - " - "codegen for _out failed\n"), -1); + "codegen for _out failed\n"), + -1); } @@ -121,7 +119,7 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) int n_inherits_downcastable = 0; - for (int i = 0; i < node->n_inherits (); i++) + for (int i = 0; i < node->n_inherits (); ++i) { AST_Interface *inherited = AST_Interface::narrow_from_decl (node->inherits ()[i]); @@ -129,14 +127,21 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) if (inherited->is_valuetype()) { ++n_inherits_downcastable; + *os << "if (rval == 0)" << be_idt_nl << "rval = "; - if (inherited->defined_in ()->scope_node_type () == AST_Decl::NT_module) + AST_Decl::NodeType nt = + inherited->defined_in ()->scope_node_type (); + + if (nt == AST_Decl::NT_module) { - be_decl *scope = be_scope::narrow_from_scope (inherited->defined_in ())->decl (); + be_scope *scope = + be_scope::narrow_from_scope (inherited->defined_in ()); + be_decl *scope_decl = scope->decl (); + *os << "ACE_NESTED_CLASS (" - << scope->name() << "," + << scope_decl->name () << "," << inherited->local_name () << ")"; } else @@ -151,7 +156,6 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) *os << "return rval;" << be_uidt_nl << "}\n\n"; - // Ugly TAO any support routine *os << "void" << be_nl << node->name () << "::_tao_any_destructor (void *_tao_void_pointer)" << be_nl @@ -165,15 +169,18 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) // Nothing to marshal if abstract valuetype. if (!node->is_abstract_valuetype ()) { - // The virtual _tao_marshal_v method + // The virtual _tao_marshal_v method. *os << "CORBA::Boolean " << node->name () - << "::_tao_marshal_v (TAO_OutputCDR & strm)" + << "::_tao_marshal_v (TAO_OutputCDR & strm)" << be_nl - << "{" << be_idt_nl - << "return "; + << "{" << be_idt_nl + << "return "; + if (node->opt_accessor ()) { - be_decl *scope = be_scope::narrow_from_scope (node->defined_in ())->decl (); + be_decl *scope = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + *os << "ACE_NESTED_CLASS (" << scope->name () << "," << node->local_name () << ")" @@ -187,15 +194,18 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) *os << "}\n" << be_nl; - // The virtual _tao_unmarshal_v method + // The virtual _tao_unmarshal_v method. *os << "CORBA::Boolean " << node->name () - << "::_tao_unmarshal_v (TAO_InputCDR & strm)" + << "::_tao_unmarshal_v (TAO_InputCDR & strm)" << be_nl - << "{" << be_idt_nl - << "return "; + << "{" << be_idt_nl + << "return "; + if (node->opt_accessor ()) { - be_decl *scope = be_scope::narrow_from_scope (node->defined_in ())->decl (); + be_decl *scope = + be_scope::narrow_from_scope (node->defined_in ())->decl (); + *os << "ACE_NESTED_CLASS (" << scope->name () << "," << node->local_name () << ")" @@ -210,89 +220,69 @@ be_visitor_valuetype_cs::visit_valuetype (be_valuetype *node) *os << "}\n" << be_nl; } - // The static T::_tao_unmarshal method ---------------------------- + // The static T::_tao_unmarshal method *os << "CORBA::Boolean " << node->name() - << "::_tao_unmarshal (TAO_InputCDR &strm, " - << node->local_name () <<" *&new_object)" << be_nl - << "{" << be_idt_nl - << "CORBA::Boolean retval = 1;" << be_nl - << "CORBA::ValueBase *base; // %! should be a _var" - << be_nl - << "CORBA::ValueFactory_ptr factory; // %! should be a _var" - << be_nl - - << "if (!CORBA::ValueBase::_tao_unmarshal_pre (strm, factory, base," << be_idt_nl - << " " << node->local_name () + << "::_tao_unmarshal (TAO_InputCDR &strm, " + << node->local_name () <<" *&new_object)" << be_nl + << "{" << be_idt_nl + << "CORBA::Boolean retval = 1;" << be_nl + << "CORBA::ValueBase *base; // %! should be a _var" + << be_nl + << "CORBA::ValueFactory_ptr factory; // %! should be a _var" + << be_nl + << "if (!CORBA::ValueBase::_tao_unmarshal_pre (strm, factory, base," + << be_idt_nl + << " " << node->local_name () << "::_tao_obv_static_repository_id ()) )" << be_nl - << "{" << be_idt_nl - << "return 0;" << be_uidt_nl - << "}" << be_uidt_nl - << "if (factory != 0)" << be_idt_nl - << "{" << be_idt_nl - - << "base = factory->create_for_unmarshal ();" << be_nl - << "factory->_remove_ref ();" << be_nl - << "if (base == 0) return 0; // %! except.?" << be_nl - << "//%! ACE_DEBUG ((LM_DEBUG, \"" << node->name() - << "::_tao_unmarshal %s\\n\", " - << "base->_tao_obv_repository_id () ));" << be_nl - << "retval = base->_tao_unmarshal_v (strm);" << be_nl - << "//%! ACE_DEBUG ((LM_DEBUG, \"" << node->name() - << "::_tao_unmarshal retval unmarshal_v is %d\\n\", " - << "retval));" << be_nl - << "if (!retval) return 0;" - - << be_uidt_nl << "}" << be_uidt_nl - << "// Now base must be null or point to the unmarshaled object." - << be_nl - << "// Align the pointer to the right subobject." << be_nl - << "new_object = " << node->local_name () << "::_downcast (base);" << be_nl - << "// %! unmarshal_post" << be_nl - << "return 1;" << be_uidt_nl - << "}\n" << be_nl; - - // The static T::_tao_unmarshal method ------------------------ end - - // generate code for the elements of the valuetype + << "{" << be_idt_nl + << "return 0;" << be_uidt_nl + << "}" << be_uidt_nl + << "if (factory != 0)" << be_idt_nl + << "{" << be_idt_nl + << "base = factory->create_for_unmarshal ();" << be_nl + << "factory->_remove_ref ();" << be_nl + << "if (base == 0) return 0; // %! except.?" << be_nl + << "//%! ACE_DEBUG ((LM_DEBUG, \"" << node->name() + << "::_tao_unmarshal %s\\n\", " + << "base->_tao_obv_repository_id () ));" << be_nl + << "retval = base->_tao_unmarshal_v (strm);" << be_nl + << "//%! ACE_DEBUG ((LM_DEBUG, \"" << node->name() + << "::_tao_unmarshal retval unmarshal_v is %d\\n\", " + << "retval));" << be_nl + << "if (!retval) return 0;" + << be_uidt_nl << "}" << be_uidt_nl + << "// Now base must be null or point to the unmarshaled object." + << be_nl + << "// Align the pointer to the right subobject." << be_nl + << "new_object = " << node->local_name () << "::_downcast (base);" << be_nl + << "// %! unmarshal_post" << be_nl + << "return 1;" << be_uidt_nl + << "}\n" << be_nl; + + // Generate code for the elements of the valuetype. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_cs::" "visit_valuetype - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - // Generate the _init -related code. + // Generate the _init-related code. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_CS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); + be_visitor_valuetype_init_cs vi_visitor (&ctx); - if (!visitor) + if (vi_visitor.visit_valuetype (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_ch::" "visit_valuetype - " - "NULL visitor.\n" - ), -1); + "failed to generate _init construct.\n"), + -1); } - if (visitor->visit_valuetype(node) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_ch::" - "visit_valuetype - " - "failed to generate _init construct.\n" - ), -1); - } - - delete visitor; - - - // by using a visitor to declare and define the TypeCode, we have the - // added advantage to conditionally not generate any code. This will be - // based on the command line options. This is still TO-DO - // (see interface code how to do this. not yet impl.) - return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp index 5b621ca3272..c31295d6c78 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_arglist_ch.cpp @@ -19,23 +19,24 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_valuetype.h" -ACE_RCSID(be_visitor_valuetype_init, arglist_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype_init, + arglist_ch, + "$Id$") -be_visitor_valuetype_init_arglist_ch:: -be_visitor_valuetype_init_arglist_ch (be_visitor_context *ctx) +be_visitor_valuetype_init_arglist_ch::be_visitor_valuetype_init_arglist_ch ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } -be_visitor_valuetype_init_arglist_ch:: -~be_visitor_valuetype_init_arglist_ch (void) +be_visitor_valuetype_init_arglist_ch::~be_visitor_valuetype_init_arglist_ch ( + void + ) { } @@ -43,10 +44,11 @@ int be_visitor_valuetype_init_arglist_ch::visit_factory (be_factory *node) { TAO_OutStream& os = *(this->ctx_->stream ()); - os << " (" << be_idt // idt = 1 - << be_idt_nl; // idt = 2 - // all we do is hand over code generation to our scope + os << " (" << be_idt + << be_idt_nl; + + // All we do is hand over code generation to our scope. if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -56,8 +58,8 @@ be_visitor_valuetype_init_arglist_ch::visit_factory (be_factory *node) -1); } - os << be_uidt_nl // idt = 1 - << ")" << be_uidt; // idt = 0 + os << be_uidt_nl + << ")" << be_uidt; return 0; } @@ -65,15 +67,20 @@ be_visitor_valuetype_init_arglist_ch::visit_factory (be_factory *node) int be_visitor_valuetype_init_arglist_ch::visit_argument (be_argument *node) { - // get the visitor that will dump the argument's mapping in the operation + // Get the visitor that will dump the argument's mapping in the operation // signature. be_visitor_context ctx (*this->ctx_); + int status = 0; switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_VALUETYPE_INIT_ARGLIST_CH: - ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); - break; + { + ctx.state (TAO_CodeGen::TAO_ARGUMENT_ARGLIST_CH); + be_visitor_args_arglist visitor (&ctx); + status = node->accept (&visitor); + break; + } default: { ACE_ERROR_RETURN ((LM_ERROR, @@ -84,20 +91,8 @@ be_visitor_valuetype_init_arglist_ch::visit_argument (be_argument *node) } } - // grab a visitor - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_valuetype_init_arglist_ch::" - "visit_argument - " - "Bad visitor\n"), - -1); - } - - if (node->accept (visitor) == -1) + if (status == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_init_arglist_ch::" "visit_argument - " @@ -105,7 +100,6 @@ be_visitor_valuetype_init_arglist_ch::visit_argument (be_argument *node) -1); } - delete visitor; return 0; } @@ -114,7 +108,7 @@ be_visitor_valuetype_init_arglist_ch::post_process (be_decl *bd) { TAO_OutStream *os = this->ctx_->stream (); - // if we are not the last node in the list of arguments, generate a comma. + // If we are not the last node in the list of arguments, generate a comma. if (!this->last_node (bd)) { *os << "," << be_nl; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp index ffa84c7497c..ccfd431ff39 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype_init_ch.cpp @@ -20,13 +20,12 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "be.h" #include "be_visitor_valuetype.h" -ACE_RCSID(be_visitor_valuetype, valuetype_init_ch, "$Id$") +ACE_RCSID (be_visitor_valuetype, + valuetype_init_ch, + "$Id$") be_visitor_valuetype_init_ch::be_visitor_valuetype_init_ch ( be_visitor_context *ctx @@ -61,9 +60,10 @@ be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) FactoryStyle factory_style = determine_factory_style (node); - if(factory_style == FS_NO_FACTORY) // nothing to do + if (factory_style == FS_NO_FACTORY) { - return 0; // bail out + // Nothing to do. + return 0; } TAO_OutStream& os = *(this->ctx_->stream ()); @@ -72,22 +72,22 @@ be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) os.gen_ifdef_macro (node->flat_name (), "_init"); - //@@ If I'm generating concrete class I need a RefCounter + //@@ If I'm generating concrete class I need a RefCounter. os << "class " << be_global->stub_export_macro () << " " << node->local_name () << "_init : public virtual CORBA_ValueFactoryBase" << be_nl; - // generate the body + // Generate the body. os << "{" << be_nl << "public:" << be_idt_nl; - if(factory_style == FS_CONCRETE_FACTORY) + if (factory_style == FS_CONCRETE_FACTORY) { - // public ctor + // Public constructor. os << node->local_name () << "_init ();" << be_nl; } - // virtual public dtor + // Virtual destructor. os << "virtual ~" << node->local_name () << "_init ();" << be_nl; @@ -105,11 +105,11 @@ be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) os << be_nl; - // generate _downcast method + // Generate _downcast method. os << "static " << node->local_name () << "_init* " << "_downcast (CORBA_ValueFactoryBase* );" << be_nl; - if(factory_style == FS_CONCRETE_FACTORY) + if (factory_style == FS_CONCRETE_FACTORY) { //@@ Boris: create_for_unmarshal is still public... // generate create_for_unmarshal @@ -121,21 +121,18 @@ be_visitor_valuetype_init_ch::visit_valuetype (be_valuetype *node) os << be_nl; - // propriate extensions + // Proprietary extensions. os << "// TAO-specific extensions" << be_uidt_nl << "public:" << be_idt_nl; - os << "virtual const char* tao_repository_id (void);\n"; - if(factory_style == FS_ABSTRACT_FACTORY) + if (factory_style == FS_ABSTRACT_FACTORY) { - // protected ctor + // Protected constructor. os << be_uidt_nl << "protected:" << be_idt_nl; - os << node->local_name () << "_init ();"; - } os << be_uidt_nl << "};" << be_nl; @@ -166,20 +163,10 @@ be_visitor_valuetype_init_ch::visit_factory (be_factory *node) // we grab a visitor that generates the parameter listing. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_VALUETYPE_INIT_ARGLIST_CH); - be_visitor* visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "be_visitor_valuetype_init_ch::" - "visit_factory - " - "Bad visitor to argument list\n"), - -1); - } + be_visitor_valuetype_init_arglist_ch visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_init_arglist__ch::" "visit_operation - " @@ -187,9 +174,7 @@ be_visitor_valuetype_init_ch::visit_factory (be_factory *node) -1); } - delete visitor; - - // make pure virtual + // Make pure virtual. os << " = 0;" << be_nl; return 0; diff --git a/TAO/TAO_IDL/be_include/be_codegen.h b/TAO/TAO_IDL/be_include/be_codegen.h index 45ace5551cc..bab081e1aa8 100644 --- a/TAO/TAO_IDL/be_include/be_codegen.h +++ b/TAO/TAO_IDL/be_include/be_codegen.h @@ -320,11 +320,6 @@ public: TAO_OPERATION_RETTYPE_IS, // return type in client header op TAO_OPERATION_RETTYPE_OTHERS, // ... in other cases - TAO_OPERATION_INVOKE_ARG_LIST, // Generate the signature needed to invoke - // the operation given. The signature generated - // consists of the name of the arguments, without - // any type - TAO_OPERATION_ARGLIST_CH, // parameter list in op signature // ... for client header TAO_OPERATION_ARGLIST_SH, // ... for server header @@ -340,9 +335,6 @@ public: TAO_OPERATION_INTERCEPTORS_INFO_ARGLIST_SS, // arglist for request info obj instantiation TAO_OPERATION_INTERCEPTORS_ARGLIST_SS, // private member list list for request info // ... for server source - // TAO_OPERATION_ARGLIST_PROXY_IMPL_CH, // Proxy impl arg list generation - // in client header - TAO_OPERATION_ARGLIST_PROXY_IMPL_XH, // Proxy impl arg list generation // in client/server header TAO_OPERATION_ARGLIST_PROXY_IMPL_XS, diff --git a/TAO/TAO_IDL/be_include/be_constant.h b/TAO/TAO_IDL/be_include/be_constant.h index 64486bc999c..a9007d9dc5f 100644 --- a/TAO/TAO_IDL/be_include/be_constant.h +++ b/TAO/TAO_IDL/be_include/be_constant.h @@ -47,6 +47,9 @@ public: // Visiting. virtual int accept (be_visitor *visitor); + //Cleanup. + virtual void destroy (void); + // Narrowing. DEF_NARROW_METHODS2 (be_constant, AST_Constant, be_decl); DEF_NARROW_FROM_DECL (be_constant); diff --git a/TAO/TAO_IDL/be_include/be_decl.h b/TAO/TAO_IDL/be_include/be_decl.h index a5c5191097c..e6063fc8a63 100644 --- a/TAO/TAO_IDL/be_include/be_decl.h +++ b/TAO/TAO_IDL/be_include/be_decl.h @@ -94,6 +94,9 @@ public: void has_constructor (idl_bool value); // Mutator for protected member. + virtual void destroy (void); + // Cleanup function. + // Boolean methods to test if code was already generated. idl_bool cli_hdr_gen (void); idl_bool cli_stub_gen (void); @@ -137,9 +140,6 @@ protected: virtual void compute_flat_name (void); // Compute the flattened fully scoped name. - virtual void destroy (void); - // Cleanup function. - // Variables that indicate if the code generation for that node is already // been done. This way we avoid regenerating same code. idl_bool cli_hdr_gen_; diff --git a/TAO/TAO_IDL/be_include/be_enum_val.h b/TAO/TAO_IDL/be_include/be_enum_val.h index 36040c96752..2019ee39258 100644 --- a/TAO/TAO_IDL/be_include/be_enum_val.h +++ b/TAO/TAO_IDL/be_include/be_enum_val.h @@ -42,6 +42,9 @@ public: // Visiting virtual int accept (be_visitor *visitor); + //Cleanup. + virtual void destroy (void); + // Narrowing DEF_NARROW_METHODS2 (be_enum_val, AST_EnumVal, be_decl); DEF_NARROW_FROM_DECL (be_enum_val); diff --git a/TAO/TAO_IDL/be_include/be_helper.h b/TAO/TAO_IDL/be_include/be_helper.h index cb0a911e2f9..206c01581ee 100644 --- a/TAO/TAO_IDL/be_include/be_helper.h +++ b/TAO/TAO_IDL/be_include/be_helper.h @@ -205,7 +205,6 @@ protected: int indent_level_; // indentation level - }; #endif // if !defined diff --git a/TAO/TAO_IDL/be_include/be_interface_strategy.h b/TAO/TAO_IDL/be_include/be_interface_strategy.h index 07484fdfa4a..22c96876104 100644 --- a/TAO/TAO_IDL/be_include/be_interface_strategy.h +++ b/TAO/TAO_IDL/be_include/be_interface_strategy.h @@ -172,7 +172,6 @@ public: // e.g. the reply handler to the actual node. protected: - char *local_name_; char *full_name_; @@ -197,12 +196,8 @@ protected: Strategy_Kind strategy_type_; // The type of strategy - - }; - - class be_interface_default_strategy : public be_interface_strategy { diff --git a/TAO/TAO_IDL/be_include/be_predefined_type.h b/TAO/TAO_IDL/be_include/be_predefined_type.h index 0860729e6f2..220fa110df8 100644 --- a/TAO/TAO_IDL/be_include/be_predefined_type.h +++ b/TAO/TAO_IDL/be_include/be_predefined_type.h @@ -42,6 +42,9 @@ public: // Visiting. virtual int accept (be_visitor* visitor); + // Cleanup. + virtual void destroy (void); + // Narrowing. DEF_NARROW_METHODS2 (be_predefined_type, AST_PredefinedType, be_type); DEF_NARROW_FROM_DECL (be_predefined_type); diff --git a/TAO/TAO_IDL/be_include/be_string.h b/TAO/TAO_IDL/be_include/be_string.h index 236cb1bc64c..b13c4218ded 100644 --- a/TAO/TAO_IDL/be_include/be_string.h +++ b/TAO/TAO_IDL/be_include/be_string.h @@ -35,16 +35,18 @@ public: be_string (void); // Default constructor. - be_string (AST_Expression *v); - // Constructor. - - be_string (AST_Expression *v, - long wide); + be_string (AST_Decl::NodeType nt, + UTL_ScopedName *n, + AST_Expression *v, + long width); // Constructor. // Visiting. virtual int accept (be_visitor *visitor); + // Cleanup. + virtual void destroy (void); + // Narrowing. DEF_NARROW_METHODS2 (be_string, AST_String, be_type); DEF_NARROW_FROM_DECL (be_string); diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation.h b/TAO/TAO_IDL/be_include/be_visitor_operation.h index e5f48ddb6ff..94329dd2031 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation.h @@ -69,7 +69,6 @@ #include "be_visitor_operation/interceptors_result.h" #include "be_visitor_operation/base_proxy_impl_ch.h" #include "be_visitor_operation/proxy_impl_xh.h" -#include "be_visitor_operation/inv_arglist.h" #include "be_visitor_operation/remote_proxy_impl_cs.h" #include "be_visitor_operation/thru_poa_proxy_impl_ss.h" #include "be_visitor_operation/direct_proxy_impl_ss.h" diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_cs.h b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_cs.h index dd581cf58f0..982b5cb9a0d 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_cs.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_cs.h @@ -49,10 +49,12 @@ public: // visit argument to generate ParamData entries // = template methods - virtual int gen_pre_stub_info (be_operation *, be_type *) = 0; + virtual int gen_pre_stub_info (be_operation *node, + be_type *bt); // generate any info before the actual code for the stub is generated - virtual int gen_marshal_and_invoke (be_operation *, be_type *) = 0; + virtual int gen_marshal_and_invoke (be_operation *node, + be_type *bt); // generate code that marshals the arguments and transmits them // =helper @@ -60,57 +62,4 @@ public: // stuff to output after every member of the scope is handled }; -// specialized visitors - -class be_interpretive_visitor_operation_ami_cs : public be_visitor_operation_ami_cs -{ - // - // = TITLE - // be_interpretive_visitor_operation_ami_cs - // - // = DESCRIPTION - // This is a concrete visitor to generate the client stubs for operation - // using interpretive marshaling. - // - // -public: - be_interpretive_visitor_operation_ami_cs (be_visitor_context *); - // ctor - - ~be_interpretive_visitor_operation_ami_cs (void); - // dtor - - virtual int gen_pre_stub_info (be_operation *, be_type *); - // generate any info before the actual code for the stub is generated - - virtual int gen_marshal_and_invoke (be_operation *, be_type *); - // generate code that marshals the arguments and transmits them - -}; - -class be_compiled_visitor_operation_ami_cs : public be_visitor_operation_ami_cs -{ - // - // = TITLE - // be_compiled_visitor_operation_ami_cs - // - // = DESCRIPTION - // This is a concrete visitor to generate the client stubs for operation - // using compiled marshaling. - // - // -public: - be_compiled_visitor_operation_ami_cs (be_visitor_context *); - // ctor - - ~be_compiled_visitor_operation_ami_cs (void); - // dtor - - virtual int gen_pre_stub_info (be_operation *, be_type *); - // generate any info before the actual code for the stub is generated - - virtual int gen_marshal_and_invoke (be_operation *, be_type *); - // generate code that marshals the arguments and transmits them -}; - #endif /* _BE_VISITOR_OPERATION_AMI_CS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_reply_stub_operation_cs.h b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_reply_stub_operation_cs.h index e692c382502..7b38c0e57d7 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_reply_stub_operation_cs.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/ami_handler_reply_stub_operation_cs.h @@ -51,10 +51,12 @@ public: // visit argument to generate ParamData entries // = template methods - virtual int gen_pre_stub_info (be_operation *, be_type *) = 0; + virtual int gen_pre_stub_info (be_operation *node, + be_type *bt); // generate any info before the actual code for the stub is generated - virtual int gen_marshal_and_invoke (be_operation *, be_type *) = 0; + virtual int gen_marshal_and_invoke (be_operation *node, + be_type *bt); // generate code that marshals the arguments and transmits them // =helper @@ -62,59 +64,4 @@ public: // stuff to output after every member of the scope is handled }; -// specialized visitors - -class be_interpretive_visitor_operation_ami_handler_reply_stub_operation_cs : public be_visitor_operation_ami_handler_reply_stub_operation_cs -{ - // - // = TITLE - // be_interpretive_visitor_operation_ami_skeleton_operation_cs - // - // = DESCRIPTION - // This is a concrete visitor to generate the client skeletons - // for AMI reply handlers of IDL operations using interpretive marshaling. - // - // -public: - be_interpretive_visitor_operation_ami_handler_reply_stub_operation_cs (be_visitor_context *); - // ctor - - ~be_interpretive_visitor_operation_ami_handler_reply_stub_operation_cs (void); - // dtor - - virtual int gen_pre_stub_info (be_operation *, be_type *); - // generate any info before the actual code for the stub is generated - - virtual int gen_marshal_and_invoke (be_operation *, be_type *); - // generate code that marshals the arguments and transmits them - -}; - -class be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs : public be_visitor_operation_ami_handler_reply_stub_operation_cs -{ - // - // = TITLE - // be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs - // - // = DESCRIPTION - // This is a concrete visitor to generate the client skeletons - // for AMI reply handlers of IDL operations using compiled marshaling. - // - // -public: - be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs (be_visitor_context *); - // ctor - - ~be_compiled_visitor_operation_ami_handler_reply_stub_operation_cs (void); - // dtor - - virtual int gen_pre_stub_info (be_operation *, be_type *); - // generate any info before the actual code for the stub is generated - - virtual int gen_marshal_and_invoke (be_operation *, be_type *); - // generate code that marshals the arguments and transmits them - -}; - - #endif /* _BE_VISITOR_OPERATION_OPERATION_AMI_HANDLER_REPLY_STUB_OPERATION_CS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/argument_invoke.h b/TAO/TAO_IDL/be_include/be_visitor_operation/argument_invoke.h index 06e47f6b16a..47ed79ccfaa 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/argument_invoke.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/argument_invoke.h @@ -27,7 +27,7 @@ // generic operation visitor for docall, upcall, pre/post // ************************************************************ -class be_compiled_visitor_operation_argument_invoke +class be_visitor_operation_argument_invoke : public be_visitor_operation_argument { // @@ -39,10 +39,10 @@ class be_compiled_visitor_operation_argument_invoke // return type // public: - be_compiled_visitor_operation_argument_invoke (be_visitor_context *ctx); + be_visitor_operation_argument_invoke (be_visitor_context *ctx); // constructor - ~be_compiled_visitor_operation_argument_invoke (void); + ~be_visitor_operation_argument_invoke (void); // destructor virtual int pre_process (be_decl *bd); diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/argument_marshal.h b/TAO/TAO_IDL/be_include/be_visitor_operation/argument_marshal.h index 2a4802db351..183b1baa7b3 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/argument_marshal.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/argument_marshal.h @@ -27,7 +27,7 @@ // generic operation visitor for docall, upcall, pre/post // ************************************************************ -class be_compiled_visitor_operation_argument_marshal +class be_visitor_operation_argument_marshal : public be_visitor_operation_argument { // @@ -39,10 +39,10 @@ class be_compiled_visitor_operation_argument_marshal // return type // public: - be_compiled_visitor_operation_argument_marshal (be_visitor_context *ctx); + be_visitor_operation_argument_marshal (be_visitor_context *ctx); // constructor - ~be_compiled_visitor_operation_argument_marshal (void); + ~be_visitor_operation_argument_marshal (void); // destructor virtual int pre_process (be_decl *bd); @@ -65,7 +65,7 @@ private: // **************************************************************** -class be_visitor_compiled_args_decl : public be_visitor_scope +class be_visitor_args_decl : public be_visitor_scope { // // = TITLE @@ -76,7 +76,7 @@ class be_visitor_compiled_args_decl : public be_visitor_scope // compiled marshaling stubs. // public: - be_visitor_compiled_args_decl (be_visitor_context *ctx); + be_visitor_args_decl (be_visitor_context *ctx); // constructor int visit_array (be_array *node); diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/direct_collocated_ss.h b/TAO/TAO_IDL/be_include/be_visitor_operation/direct_collocated_ss.h index c6ebe06940f..fce4fc184ee 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/direct_collocated_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/direct_collocated_ss.h @@ -26,7 +26,7 @@ // Operation visitor for server skeletons for the direct collocated class // ***************************************************************** -class be_visitor_operation_direct_collocated_ss : public be_visitor_scope +class be_visitor_operation_direct_collocated_ss : public be_visitor_operation { // // = TITLE @@ -49,9 +49,6 @@ public: virtual int gen_invoke (be_visitor_context &ctx, be_operation *node); // A helper method to generate operation invocation code. - - virtual int void_return_type (be_type *bt); - // is my return type void? }; #endif /* _BE_VISITOR_OPERATION_DIRECT_COLLOCATED_SS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/direct_proxy_impl_ss.h b/TAO/TAO_IDL/be_include/be_visitor_operation/direct_proxy_impl_ss.h index 3d8003ed5ee..3bbb72d9107 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/direct_proxy_impl_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/direct_proxy_impl_ss.h @@ -20,7 +20,7 @@ #ifndef _BE_VISITOR_OPERATION_DIRECT_PROXY_IMPL_SS_H_ #define _BE_VISITOR_OPERATION_DIRECT_PROXY_IMPL_SS_H_ -class be_visitor_operation_direct_proxy_impl_ss : public be_visitor_scope +class be_visitor_operation_direct_proxy_impl_ss : public be_visitor_operation { // // = TITLE @@ -43,9 +43,6 @@ public: virtual int gen_invoke (be_visitor_context &ctx, be_operation *node); // A helper method to generate operation invocation code. - - virtual int void_return_type (be_type *bt); - // is my return type void? }; #endif /* _BE_VISITOR_OPERATION_DIRECT_PROXY_IMPL_SS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/inv_arglist.h b/TAO/TAO_IDL/be_include/be_visitor_operation/inv_arglist.h deleted file mode 100644 index 3b1cb7d4db3..00000000000 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/inv_arglist.h +++ /dev/null @@ -1,55 +0,0 @@ -// $Id$ -// -// ============================================================================ -// -// = LIBRARY -// TAO IDL -// -// = FILENAME -// inv_arglist.h -// -// = DESCRIPTION -// Visitor for generating signature needed to invoke a given -// operation. -// -// = AUTHOR -// Angelo Corsaro -// -// ============================================================================ - -#ifndef _BE_VISITOR_OPERATION_INV_ARGLIST_H_ -#define _BE_VISITOR_OPERATION_INV_ARGLIST_H_ - -// ****************************************************************************** -// Operation visitor for argument list - generates parameters in the signature -// ****************************************************************************** - -class be_visitor_operation_inv_arglist : public be_visitor_operation -{ - // - // = TITLE - // be_visitor_operaion_inv_arglist - // - // = DESCRIPTION - // This visitor generates the argument list needed to - // invoke a given operation. No parentesys are generated - // to give the caller code the abity to stick in other - // parameter that might be needed. - // - // -public: - be_visitor_operation_inv_arglist (be_visitor_context *ctx); - // constructor - - ~be_visitor_operation_inv_arglist (void); - // destructor - - virtual int visit_operation (be_operation *node); - // visit the operation - - virtual int visit_argument (be_argument *node); - // visit each argument - -}; - -#endif /* _BE_VISITOR_OPERATION_INV_ARGLIST_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/smart_proxy_cs.h b/TAO/TAO_IDL/be_include/be_visitor_operation/smart_proxy_cs.h index 5e63484c0c8..8bbba1ab4ee 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/smart_proxy_cs.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/smart_proxy_cs.h @@ -23,7 +23,7 @@ // Operation visitor for client stubs // ************************************************************ -class be_visitor_operation_smart_proxy_cs : public be_visitor_scope +class be_visitor_operation_smart_proxy_cs : public be_visitor_operation { // // = TITLE @@ -45,9 +45,6 @@ public: virtual int gen_invoke (be_visitor_context &ctx, be_operation *node); // A helper method to generate operation invocation code. - - virtual int void_return_type (be_type *bt); - // is my return type void? }; #endif /* _BE_VISITOR_OPERATION_OPERATION_SMART_PROXY_CS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/thru_poa_collocated_ss.h b/TAO/TAO_IDL/be_include/be_visitor_operation/thru_poa_collocated_ss.h index 2c63169caea..268cbc37340 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/thru_poa_collocated_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/thru_poa_collocated_ss.h @@ -49,9 +49,6 @@ public: virtual int gen_invoke (be_visitor_context &ctx, be_operation *node); // A helper method to generate operation invocation code. - - virtual int void_return_type (be_type *bt); - // is my return type void? }; #endif /* _BE_VISITOR_OPERATION_THRU_POA_COLLOCATED_SS_H_ */ diff --git a/TAO/TAO_IDL/be_include/be_visitor_operation/thru_poa_proxy_impl_ss.h b/TAO/TAO_IDL/be_include/be_visitor_operation/thru_poa_proxy_impl_ss.h index 3c15fd5762a..f4db4ecf488 100644 --- a/TAO/TAO_IDL/be_include/be_visitor_operation/thru_poa_proxy_impl_ss.h +++ b/TAO/TAO_IDL/be_include/be_visitor_operation/thru_poa_proxy_impl_ss.h @@ -48,9 +48,6 @@ public: virtual int gen_invoke (be_visitor_context &ctx, be_operation *node); // A helper method to generate operation invocation code. - - virtual int void_return_type (be_type *bt); - // is my return type void? }; #endif /* _BE_VISITOR_OPERATION_THRU_POA_PROXY_IMPL_OPERATION_THRU_POA_PROXY_IMPL_SS_H_ */ diff --git a/TAO/TAO_IDL/driver/drv_args.cpp b/TAO/TAO_IDL/driver/drv_args.cpp index 1181db11cb9..1ac164fe6a7 100644 --- a/TAO/TAO_IDL/driver/drv_args.cpp +++ b/TAO/TAO_IDL/driver/drv_args.cpp @@ -241,19 +241,18 @@ DRV_usage (void) )); ACE_DEBUG (( LM_DEBUG, - ACE_TEXT (" -Ge [0|1]\t\t\tDisable/Enable generation of") - ACE_TEXT (" CORBA::Environment arguments (disabled by default") - ACE_TEXT (" if ACE_HAS_EXCEPTIONS)\n") + ACE_TEXT (" -GC \t\tGenerate the code for using AMI Call back model\n") )); ACE_DEBUG (( LM_DEBUG, - ACE_TEXT (" -Gt\t\t\tenable optimized TypeCode support") - ACE_TEXT (" (unopt by default)\n") + ACE_TEXT (" -Gd \t\tGenerate the code for direct collocation. Default") + ACE_TEXT ("is thru-POA collocation\n") )); ACE_DEBUG (( LM_DEBUG, - ACE_TEXT (" -Gv\t\t\tenable OBV (Valuetype) support") - ACE_TEXT (" (disabled by default)\n") + ACE_TEXT (" -Ge [0|1]\t\t\tDisable/Enable generation of") + ACE_TEXT (" CORBA::Environment arguments (disabled by default") + ACE_TEXT (" if ACE_HAS_EXCEPTIONS)\n") )); ACE_DEBUG (( LM_DEBUG, @@ -281,7 +280,13 @@ DRV_usage (void) )); ACE_DEBUG (( LM_DEBUG, - ACE_TEXT (" -GC \t\tGenerate the code for using AMI Call back model\n") + ACE_TEXT (" -Gm \t\tEnable support for CORBA components\n") + ACE_TEXT (" (default)\n") + )); + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT (" -Gp \t\tGenerate the code for thru-POA collocation") + ACE_TEXT (" (default)\n") )); ACE_DEBUG (( LM_DEBUG, @@ -289,6 +294,16 @@ DRV_usage (void) )); ACE_DEBUG (( LM_DEBUG, + ACE_TEXT (" -Gt\t\t\tenable optimized TypeCode support") + ACE_TEXT (" (unopt by default)\n") + )); + ACE_DEBUG (( + LM_DEBUG, + ACE_TEXT (" -Gv\t\t\tenable OBV (Valuetype) support") + ACE_TEXT (" (disabled by default)\n") + )); + ACE_DEBUG (( + LM_DEBUG, ACE_TEXT (" -hc\t\t\tClient's header file name ending.") ACE_TEXT (" Default is C.h\n") )); @@ -1060,6 +1075,11 @@ DRV_parse_args (long ac, char **av) // enable OBV (Valuetype) support idl_global->obv_support (1); } + else if (av[i][2] == 'm') + { + // enable CORBA component support + idl_global->component_support (1); + } else if (av[i][2] == 'I') { int options = ACE_OS::strlen(av[i]) - 3; diff --git a/TAO/TAO_IDL/driver/drv_init.cpp b/TAO/TAO_IDL/driver/drv_init.cpp index f0ad80e2d84..0fd784b8605 100644 --- a/TAO/TAO_IDL/driver/drv_init.cpp +++ b/TAO/TAO_IDL/driver/drv_init.cpp @@ -83,7 +83,6 @@ DRV_init (void) IDL_GlobalData); // Initialize some of its data. - idl_global->set_scopes (0); idl_global->set_root (0); idl_global->set_gen (0); idl_global->set_err (FE_new_UTL_Error ()); diff --git a/TAO/TAO_IDL/driver/drv_preproc.cpp b/TAO/TAO_IDL/driver/drv_preproc.cpp index 885e82956ca..5793dfedcd4 100644 --- a/TAO/TAO_IDL/driver/drv_preproc.cpp +++ b/TAO/TAO_IDL/driver/drv_preproc.cpp @@ -100,9 +100,9 @@ DRV_cpp_putarg (const char *str) ACE_ERROR ((LM_ERROR, "%s%s %d %s\n", idl_global->prog_name (), - ACE_TEXT (": More than"), + ": More than", max_argcount, - ACE_TEXT ("arguments to preprocessor"))); + "arguments to preprocessor")); ACE_OS::exit (99); } @@ -162,10 +162,10 @@ DRV_cpp_init (void) { ACE_ERROR ((LM_ERROR, "%s%s%s%s", - ACE_TEXT ("Warning: The environment variable ") - ACE_TEXT ("CPP_LOCATION has been deprecated.\n") - ACE_TEXT (" Please use TAO_IDL_PREPROCESSOR ") - ACE_TEXT ("instead.\n"))); + "Warning: The environment variable " + "CPP_LOCATION has been deprecated.\n" + " Please use TAO_IDL_PREPROCESSOR " + "instead.\n")); cpp_loc = cpp_path; } @@ -209,11 +209,11 @@ DRV_cpp_init (void) { ACE_ERROR ((LM_ERROR, "%s%s%s%s%s", - ACE_TEXT ("Warning: The environment variable "), - ACE_TEXT ("TAO_IDL_DEFAULT_CPP_FLAGS has been "), - ACE_TEXT ("deprecated.\n"), - ACE_TEXT (" Please use "), - ACE_TEXT ("TAO_IDL_PREPROCESSOR_ARGS instead.\n"))); + "Warning: The environment variable ", + "TAO_IDL_DEFAULT_CPP_FLAGS has been ", + "deprecated.\n", + " Please use ", + "TAO_IDL_PREPROCESSOR_ARGS instead.\n")); cpp_args = args2; } @@ -261,10 +261,10 @@ DRV_cpp_init (void) ACE_ERROR (( LM_ERROR, "%s%s%s%s", - ACE_TEXT ("Note: The environment variables "), - ACE_TEXT ("TAO_ROOT and ACE_ROOT are not defined.\n"), - ACE_TEXT (" TAO_IDL may not be able to "), - ACE_TEXT ("locate orb.idl\n") + "Note: The environment variables ", + "TAO_ROOT and ACE_ROOT are not defined.\n", + " TAO_IDL may not be able to ", + "locate orb.idl\n" )); ACE_OS::strcat (option, "."); @@ -346,9 +346,9 @@ DRV_copy_input (FILE *fin, ACE_ERROR ((LM_ERROR, "%s%s%s%s", idl_global->prog_name (), - ACE_TEXT (": cannot open temp file "), + ": cannot open temp file ", fn, - ACE_TEXT (" for writing\n"))); + " for writing\n")); ACE_OS::exit (99); } @@ -358,7 +358,7 @@ DRV_copy_input (FILE *fin, ACE_ERROR ((LM_ERROR, "%s%s", idl_global->prog_name (), - ACE_TEXT (": cannot open input file\n"))); + ": cannot open input file\n")); ACE_OS::exit (99); } @@ -544,9 +544,9 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, "%s%s%s%s", idl_global->prog_name (), - ACE_TEXT (": cannot open temp file "), + ": cannot open temp file ", tmp_file, - ACE_TEXT (" for writing\n"))); + " for writing\n")); return; } @@ -559,9 +559,9 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, "%s%s%s%s", idl_global->prog_name (), - ACE_TEXT (": spawn of "), + ": spawn of ", arglist[0], - ACE_TEXT (" failed\n"))); + " failed\n")); return; } @@ -574,9 +574,9 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, "%s%s%s%s", idl_global->prog_name (), - ACE_TEXT (": cannot close temp file"), + ": cannot close temp file", tmp_file, - ACE_TEXT (" on parent\n"))); + " on parent\n")); return; } @@ -592,7 +592,7 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, "%s%s", idl_global->prog_name (), - ACE_TEXT (": wait for child process failed\n"))); + ": wait for child process failed\n")); return; } @@ -607,9 +607,9 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, "%s%s%s%s", idl_global->prog_name (), - ACE_TEXT (": preprocessor "), + ": preprocessor ", arglist[0], - ACE_TEXT (" returned with an error\n"))); + " returned with an error\n")); ACE_OS::exit (1); } @@ -622,9 +622,9 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, "%s%s%s%s", idl_global->prog_name (), - ACE_TEXT (": preprocessor "), + ": preprocessor ", arglist[0], - ACE_TEXT (" appears to have been interrupted\n"))); + " appears to have been interrupted\n")); ACE_OS::exit (1); } @@ -639,7 +639,7 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, "%s%s %s\n", idl_global->prog_name (), - ACE_TEXT (": Could not open cpp output file"), + ": Could not open cpp output file", tmp_file)); ACE_OS::exit (99); @@ -693,7 +693,7 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, "%s%s %s\n", idl_global->prog_name (), - ACE_TEXT (": Could not remove cpp input file"), + ": Could not remove cpp input file", tmp_ifile)); ACE_OS::exit (99); @@ -705,7 +705,7 @@ DRV_pre_proc (const char *myfile) ACE_ERROR ((LM_ERROR, "%s%s %s\n", idl_global->prog_name (), - ACE_TEXT (": Could not remove cpp output file"), + ": Could not remove cpp output file", tmp_file)); ACE_OS::exit (99); diff --git a/TAO/TAO_IDL/fe/fe_declarator.cpp b/TAO/TAO_IDL/fe/fe_declarator.cpp index 39ada9380b8..0b44087b598 100644 --- a/TAO/TAO_IDL/fe/fe_declarator.cpp +++ b/TAO/TAO_IDL/fe/fe_declarator.cpp @@ -76,9 +76,9 @@ FE_Declarator::FE_Declarator (UTL_ScopedName *n, DeclaratorType dt, AST_Decl *cp) : pd_complex_part (cp), - pd_name (n), pd_decl_type (dt) { + this->pd_name = n; } // Public operations. @@ -137,6 +137,14 @@ FE_Declarator::compose (AST_Decl *d) return 0; } +void +FE_Declarator::destroy (void) +{ + this->pd_name->destroy (); + delete this->pd_name; + this->pd_name = 0; +} + // Data accessors. AST_Decl * diff --git a/TAO/TAO_IDL/fe/fe_extern.cpp b/TAO/TAO_IDL/fe/fe_extern.cpp index 872b8a434e2..072afc7e7e0 100644 --- a/TAO/TAO_IDL/fe/fe_extern.cpp +++ b/TAO/TAO_IDL/fe/fe_extern.cpp @@ -128,13 +128,3 @@ FE_new_UTL_Indenter (void) return retval; } -UTL_String * -FE_new_UTL_String (char *str) -{ - UTL_String *retval = 0; - ACE_NEW_RETURN (retval, - UTL_String (str), - 0); - - return retval; -} diff --git a/TAO/TAO_IDL/fe/fe_init.cpp b/TAO/TAO_IDL/fe/fe_init.cpp index 18381123889..3f5178adad3 100644 --- a/TAO/TAO_IDL/fe/fe_init.cpp +++ b/TAO/TAO_IDL/fe/fe_init.cpp @@ -79,9 +79,9 @@ trademarks or registered trademarks of Sun Microsystems, Inc. * stack as the outermost scope. */ -#include "idl.h" -#include "idl_extern.h" -#include "fe_private.h" +#include "idl.h" +#include "idl_extern.h" +#include "fe_private.h" ACE_RCSID(fe, fe_init, "$Id$") @@ -107,350 +107,423 @@ create_scoped_name (const char *s) void fe_populate_global_scope (AST_Module *m) { + // No need to created a scoped name for the basic types, the + // AST_PredefinedType constructor will do that. + AST_PredefinedType *pdt = 0; pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_long, - create_scoped_name ("long") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_ulong, - create_scoped_name ("unsigned long") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_longlong, - create_scoped_name ("long long") + 0 ); m->fe_add_predefined_type(pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_ulonglong, - create_scoped_name ("unsigned long long") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_short, - create_scoped_name ("short") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_ushort, - create_scoped_name ("unsigned short") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_float, - create_scoped_name ("float") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_double, - create_scoped_name("double") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_longdouble, - create_scoped_name ("long double") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_char, - create_scoped_name ("char") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_wchar, - create_scoped_name ("wchar") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_octet, - create_scoped_name ("octet") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_any, - create_scoped_name ("any") + 0 ); m->fe_add_predefined_type (pdt); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_boolean, - create_scoped_name ("boolean") + 0 ); m->fe_add_predefined_type (pdt); + Identifier void_id ("void"); + UTL_ScopedName void_name (&void_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_void, - create_scoped_name ("void") + &void_name ); m->fe_add_predefined_type (pdt); + Identifier Object_id ("Object"); + UTL_ScopedName Object_name (&Object_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name("Object") + &Object_name ); m->fe_add_predefined_type (pdt); - // Add these to make all keywords protected even in different spellings +// Add these to make all keywords protected even in different spellings + Identifier attribute_id ("attribute"); + UTL_ScopedName attribute_name (&attribute_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("attribute") + &attribute_name ); m->fe_add_predefined_type (pdt); + Identifier case_id ("case"); + UTL_ScopedName case_name (&case_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("case") + &case_name ); m->fe_add_predefined_type (pdt); + Identifier const_id ("const"); + UTL_ScopedName const_name (&const_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("const") + &const_name ); m->fe_add_predefined_type (pdt); + Identifier context_id ("context"); + UTL_ScopedName context_name (&context_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("context") + &context_name ); m->fe_add_predefined_type (pdt); + Identifier default_id ("default"); + UTL_ScopedName default_name (&default_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("default") + &default_name ); m->fe_add_predefined_type (pdt); + Identifier enum_id ("enum"); + UTL_ScopedName enum_name (&enum_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("enum") + &enum_name ); m->fe_add_predefined_type (pdt); + Identifier exception_id ("exception"); + UTL_ScopedName exception_name (&exception_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("exception") + &exception_name ); m->fe_add_predefined_type (pdt); + Identifier in_id ("in"); + UTL_ScopedName in_name (&in_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("in") + &in_name ); m->fe_add_predefined_type (pdt); + Identifier out_id ("out"); + UTL_ScopedName out_name (&out_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("out") + &out_name ); m->fe_add_predefined_type (pdt); + Identifier inout_id ("inout"); + UTL_ScopedName inout_name (&inout_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("inout") + &inout_name ); m->fe_add_predefined_type (pdt); + Identifier interface_id ("interface"); + UTL_ScopedName interface_name (&interface_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("interface") + &interface_name ); m->fe_add_predefined_type (pdt); + Identifier module_id ("module"); + UTL_ScopedName module_name (&module_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("module") + &module_name ); m->fe_add_predefined_type (pdt); + Identifier oneway_id ("oneway"); + UTL_ScopedName oneway_name (&oneway_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("oneway") + &oneway_name ); m->fe_add_predefined_type (pdt); + Identifier raises_id ("raises"); + UTL_ScopedName raises_name (&raises_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("raises") + &raises_name ); m->fe_add_predefined_type (pdt); + Identifier readonly_id ("readonly"); + UTL_ScopedName readonly_name (&readonly_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("readonly") + &readonly_name ); m->fe_add_predefined_type (pdt); + Identifier sequence_id ("sequence"); + UTL_ScopedName sequence_name (&sequence_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("sequence") + &sequence_name ); m->fe_add_predefined_type (pdt); + Identifier string_id ("string"); + UTL_ScopedName string_name (&string_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("string") + &string_name ); m->fe_add_predefined_type (pdt); + Identifier wstring_id ("wstring"); + UTL_ScopedName wstring_name (&wstring_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("wstring") + &wstring_name ); m->fe_add_predefined_type (pdt); + Identifier struct_id ("struct"); + UTL_ScopedName struct_name (&struct_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("struct") + &struct_name ); m->fe_add_predefined_type (pdt); + Identifier switch_id ("switch"); + UTL_ScopedName switch_name (&switch_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("switch") + &switch_name ); m->fe_add_predefined_type (pdt); + Identifier typedef_id ("typedef"); + UTL_ScopedName typedef_name (&typedef_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("typedef") + &typedef_name ); m->fe_add_predefined_type (pdt); + Identifier union_id ("union"); + UTL_ScopedName union_name (&union_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("union") + &union_name ); m->fe_add_predefined_type (pdt); + Identifier unsigned_id ("unsigned"); + UTL_ScopedName unsigned_name (&unsigned_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("unsigned") + &unsigned_name ); m->fe_add_predefined_type (pdt); + Identifier TRUE_id ("TRUE"); + UTL_ScopedName TRUE_name (&TRUE_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("TRUE") + &TRUE_name ); m->fe_add_predefined_type (pdt); + Identifier FALSE_id ("FALSE"); + UTL_ScopedName FALSE_name (&FALSE_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("FALSE") + &FALSE_name ); m->fe_add_predefined_type (pdt); + Identifier abstract_id ("abstract"); + UTL_ScopedName abstract_name (&abstract_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("abstract") + &abstract_name ); m->fe_add_predefined_type (pdt); + Identifier custom_id ("custom"); + UTL_ScopedName custom_name (&custom_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("custom") + &custom_name ); m->fe_add_predefined_type (pdt); + Identifier private_id ("private"); + UTL_ScopedName private_name (&private_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("private") + &private_name ); m->fe_add_predefined_type (pdt); + Identifier public_id ("public"); + UTL_ScopedName public_name (&public_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("public") + &public_name ); m->fe_add_predefined_type (pdt); + Identifier supports_id ("supports"); + UTL_ScopedName supports_name (&supports_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("supports") + &supports_name ); m->fe_add_predefined_type (pdt); + Identifier truncatable_id ("truncatable"); + UTL_ScopedName truncatable_name (&truncatable_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("truncatable") + &truncatable_name ); m->fe_add_predefined_type (pdt); + Identifier valuetype_id ("valuetype"); + UTL_ScopedName valuetype_name (&valuetype_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("valuetype") + &valuetype_name ); m->fe_add_predefined_type (pdt); + Identifier ValueBase_id ("ValueBase"); + UTL_ScopedName ValueBase_name (&ValueBase_id, 0); pdt = idl_global->gen ()->create_predefined_type ( AST_PredefinedType::PT_pseudo, - create_scoped_name ("ValueBase") + &ValueBase_name ); m->fe_add_predefined_type (pdt); } @@ -468,33 +541,46 @@ fe_populate_idl_keywords (void) "BOOLEAN", "CASE", "CHAR", + "COMPONENT", "CONST", + "CONSUMES", "CONTEXT", "CUSTOM", "DEFAULT", "DOUBLE", + "EMITS", "EXCEPTION", "ENUM", + "EVENTTYPE", "FACTORY", "FALSE", + "FINDER", "FIXED", "FLOAT", + "GETRAISES", + "HOME", + "IMPORT", "IN", "INOUT", "INTERFACE", "LOCAL", "LONG", "MODULE", + "MULTIPLE", "NATIVE", "OBJECT", "OCTET", "ONEWAY", "OUT", + "PRIMARYKEY", "PRIVATE", + "PROVIDES", "PUBLIC", + "PUBLISHES", "RAISES", "READONLY", "SEQUENCE", + "SETRAISES", "SHORT", "STRING", "STRUCT", @@ -503,8 +589,11 @@ fe_populate_idl_keywords (void) "TRUE", "TRUNCATABLE", "TYPEDEF", + "TYPEID", + "TYPEPREFIX", "UNION", "UNSIGNED", + "USES", "VALUEBASE", "VALUETYPE", "VOID", @@ -528,26 +617,9 @@ fe_populate_idl_keywords (void) } } -// Initialization stage 1: create global scopes stack. -void -FE_init_stage1 (void) -{ - idl_global->set_scopes (new UTL_ScopeStack ()); - - if (idl_global->scopes () == NULL) - { - ACE_ERROR (( - LM_ERROR, - ACE_TEXT ("IDL: FE init failed to create scope stack, exiting\n") - )); - - ACE_OS::exit (99); - } -} - -// Initialization stage 2: create global scope and populate it. +// FE initialization: create global scope and populate it. void -FE_init_stage2 (void) +FE_init (void) { AST_Root *r; @@ -563,7 +635,9 @@ FE_init_stage2 (void) } // Create a global root for the AST. Note that the AST root has no name. - r = idl_global->gen ()->create_root (create_scoped_name ("")); + Identifier root_id (""); + UTL_ScopedName root_name (&root_id, 0); + r = idl_global->gen ()->create_root (&root_name); idl_global->set_root (r); if (r == 0) @@ -577,7 +651,7 @@ FE_init_stage2 (void) } // Push it on the stack - idl_global->scopes ()->push (idl_global->root ()); + idl_global->scopes ().push (idl_global->root ()); // Populate it with nodes for predefined types. fe_populate_global_scope (idl_global->root ()); diff --git a/TAO/TAO_IDL/fe/fe_interface_header.cpp b/TAO/TAO_IDL/fe/fe_interface_header.cpp index 527e673f11b..3e5f360466a 100644 --- a/TAO/TAO_IDL/fe/fe_interface_header.cpp +++ b/TAO/TAO_IDL/fe/fe_interface_header.cpp @@ -80,7 +80,11 @@ FE_InterfaceHeader::FE_InterfaceHeader (UTL_ScopedName *n, UTL_NameList *nl, UTL_NameList *supports, idl_bool compile_now) - : pd_interface_name (n) + : pd_interface_name (n), + pd_inherits (0), + pd_n_inherits (0), + pd_inherits_flat (0), + pd_n_inherits_flat (0) { if (compile_now) { @@ -231,7 +235,7 @@ void FE_InterfaceHeader::compile_one_inheritance (AST_Interface *i) { // Check for badly formed interface. - if (i == NULL) + if (i == 0) { return; } @@ -291,21 +295,21 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, // Loop twice if nl and supports are nonempty. for (int loops = 0; loops < 2; ++loops) { - if (nl != NULL) + if (nl != 0) { for (UTL_NamelistActiveIterator l (nl); !l.is_done (); l.next ()) { item = l.item (); // Check that scope stack is valid. - if (idl_global->scopes ()->top () == 0) + if (idl_global->scopes ().top () == 0) { idl_global->err ()->lookup_error (item); return; } // Look it up. - UTL_Scope *s = idl_global->scopes ()->top (); + UTL_Scope *s = idl_global->scopes ().top (); d = s->lookup_by_name (item, I_TRUE); @@ -397,25 +401,32 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, // OK, install in interface header. // First the flat list (all ancestors). - this->pd_inherits_flat = new AST_Interface *[iused_flat]; - - for (j = 0; j < iused_flat; j++) + if (iused_flat > 0) { - this->pd_inherits_flat[j] = iseen_flat[j]; - } + ACE_NEW (this->pd_inherits_flat, + AST_Interface *[iused_flat]);; - this->pd_n_inherits_flat = iused_flat; + for (j = 0; j < iused_flat; j++) + { + this->pd_inherits_flat[j] = iseen_flat[j]; + } - // Then the list of immediate ancestors. - ACE_NEW (this->pd_inherits, - AST_Interface *[iused]); + this->pd_n_inherits_flat = iused_flat; + } - for (k = 0; k < iused; k++) + // Then the list of immediate ancestors. + if (iused > 0) { - this->pd_inherits[k] = iseen[k]; - } + ACE_NEW (this->pd_inherits, + AST_Interface *[iused]); + + for (k = 0; k < iused; k++) + { + this->pd_inherits[k] = iseen[k]; + } - this->pd_n_inherits = iused; + this->pd_n_inherits = iused; + } } // check_ methods called from compile_inheritance() diff --git a/TAO/TAO_IDL/fe/fe_private.cpp b/TAO/TAO_IDL/fe/fe_private.cpp index fa1bd77277a..41c9d1664e0 100644 --- a/TAO/TAO_IDL/fe/fe_private.cpp +++ b/TAO/TAO_IDL/fe/fe_private.cpp @@ -71,7 +71,6 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "idl.h" #include "idl_extern.h" - #include "fe_private.h" ACE_RCSID(fe, fe_private, "$Id$") diff --git a/TAO/TAO_IDL/fe/fe_tmplinst.cpp b/TAO/TAO_IDL/fe/fe_tmplinst.cpp index 0db97489744..f9440f2bd45 100644 --- a/TAO/TAO_IDL/fe/fe_tmplinst.cpp +++ b/TAO/TAO_IDL/fe/fe_tmplinst.cpp @@ -6,6 +6,7 @@ class AST_Decl; class AST_Field; +class Identifier; #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) @@ -26,6 +27,10 @@ template class ACE_Node<AST_Field *>; template class ACE_Unbounded_Queue<AST_Field *>; template class ACE_Unbounded_Queue_Iterator<AST_Field *>; +template class ACE_Node<Identifier *>; +template class ACE_Unbounded_Queue<Identifier *>; +template class ACE_UnboundedQueue_Iterator<Identifier *>; + template class ACE_Unbounded_Stack<char *>; template class ACE_Unbounded_Stack_Iterator<char *>; diff --git a/TAO/TAO_IDL/fe/idl.ll b/TAO/TAO_IDL/fe/idl.ll index 4a155c6b5ad..66828674bc9 100644 --- a/TAO/TAO_IDL/fe/idl.ll +++ b/TAO/TAO_IDL/fe/idl.ll @@ -117,6 +117,19 @@ static int scan_obv_token (int token) return IDENTIFIER; } +static int scan_ccm_token (int token) +{ + if (idl_global->component_support ()) + { + return token; + } + else + { + yylval.strval = ACE_OS::strdup (ace_yytext); + return IDENTIFIER; + } +} + %} /* SO we don't choke on files that use \r\n */ @@ -167,6 +180,23 @@ public return scan_obv_token (IDL_PUBLIC); supports return scan_obv_token (IDL_SUPPORTS); truncatable return scan_obv_token (IDL_TRUNCATABLE); valuetype return scan_obv_token (IDL_VALUETYPE); +component return scan_ccm_token (IDL_COMPONENT); +consumes return scan_ccm_token (IDL_CONSUMES); +emits return scan_ccm_token (IDL_EMITS); +eventtype return scan_ccm_token (IDL_EVENTTYPE); +finder return scan_ccm_token (IDL_FINDER); +getraises return scan_ccm_token (IDL_GETRAISES); +home return scan_ccm_token (IDL_HOME); +import return scan_ccm_token (IDL_IMPORT); +multiple return scan_ccm_token (IDL_MULTIPLE); +primarykey return scan_ccm_token (IDL_PRIMARYKEY); +provides return scan_ccm_token (IDL_PROVIDES); +publishes return scan_ccm_token (IDL_PUBLISHES); +setraises return scan_ccm_token (IDL_SETRAISES); +typeid return scan_ccm_token (IDL_TYPEID); +typeprefix return scan_ccm_token (IDL_TYPEPREFIX); +uses return scan_ccm_token (IDL_USES); +manages return scan_ccm_token (IDL_MANAGES); TRUE return IDL_TRUETOK; FALSE return IDL_FALSETOK; @@ -468,7 +498,9 @@ idl_parse_line_and_file (char *buf) // This call also manages the #pragma prefix. idl_global->store_include_file_name (nm); } - else if (is_main_filename && idl_global->pragma_prefixes ().size () > 1) + else if (is_main_filename + && idl_global->pragma_prefixes ().size () > 1 + && idl_global->scopes ().depth () == 1) { // If we're here, we have come to the end of an included file, so we // pop its prefix. @@ -533,12 +565,12 @@ idl_store_pragma (char *buf) if (new_prefix != 0) { - unsigned long depth = idl_global->scopes ()->depth (); + unsigned long depth = idl_global->scopes ().depth (); // At global scope, we always replace the prefix. For all // other scopes, we replace only if there is a prefix already // associated with that scope, otherwise we add the prefix. - if (depth == 1 || idl_global->scopes ()->top ()->has_prefix ()) + if (depth == 1 || idl_global->scopes ().top ()->has_prefix ()) { char *trash = 0; idl_global->pragma_prefixes ().pop (trash); @@ -547,7 +579,7 @@ idl_store_pragma (char *buf) if (depth > 1) { - idl_global->scopes ()->top ()->has_prefix (1); + idl_global->scopes ().top ()->has_prefix (1); } idl_global->pragma_prefixes ().push (new_prefix); @@ -917,7 +949,7 @@ idl_find_node (char *s) if (node != 0) { - d = idl_global->scopes ()->top_non_null ()->lookup_by_name (node, + d = idl_global->scopes ().top_non_null ()->lookup_by_name (node, I_TRUE); } diff --git a/TAO/TAO_IDL/fe/idl.yy b/TAO/TAO_IDL/fe/idl.yy index 73604a87d16..2cb6a667f83 100644 --- a/TAO/TAO_IDL/fe/idl.yy +++ b/TAO/TAO_IDL/fe/idl.yy @@ -169,7 +169,7 @@ extern int yyleng; %token IDL_CONTEXT %token IDL_NATIVE %token IDL_LOCAL - /* OBV tokens see OMG ptc/98-10-04 3.2.4 */ + /* OBV tokens */ %token IDL_ABSTRACT %token IDL_CUSTOM %token IDL_FACTORY @@ -178,6 +178,24 @@ extern int yyleng; %token IDL_SUPPORTS %token IDL_TRUNCATABLE %token IDL_VALUETYPE + /* Component tokens */ +%token IDL_COMPONENT +%token IDL_CONSUMES +%token IDL_EMITS +%token IDL_EVENTTYPE +%token IDL_FINDER +%token IDL_GETRAISES +%token IDL_HOME +%token IDL_IMPORT +%token IDL_MULTIPLE +%token IDL_PRIMARYKEY +%token IDL_PROVIDES +%token IDL_PUBLISHES +%token IDL_SETRAISES +%token IDL_TYPEID +%token IDL_TYPEPREFIX +%token IDL_USES +%token IDL_MANAGES %token <ival> IDL_INTEGER_LITERAL %token <uival> IDL_UINTEGER_LITERAL @@ -259,58 +277,92 @@ definitions definition : type_dcl { +// definition : type_dcl idl_global->set_parse_state (IDL_GlobalData::PS_TypeDeclSeen); } ';' { idl_global->set_parse_state (IDL_GlobalData::PS_NoState); +// ';' + } + | typeid_dcl + { +// | typeid_dcl + idl_global->set_parse_state (IDL_GlobalData::PS_TypeIdDeclSeen); + } + ';' + { +// ';' + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); + } + | typeprefix_dcl + { +// | typeprefix_dcl + idl_global->set_parse_state (IDL_GlobalData::PS_TypePrefixDeclSeen); + } + ';' + { +// ';' + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | const_dcl { +// | const_dcl idl_global->set_parse_state (IDL_GlobalData::PS_ConstDeclSeen); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | exception { +// | exception idl_global->set_parse_state (IDL_GlobalData::PS_ExceptDeclSeen); } ';' { - idl_global->set_parse_state (IDL_GlobalData::PS_NoState); +// ';' + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | interface_def { +// | interface_def idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceDeclSeen); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | module { +// | module idl_global->set_parse_state (IDL_GlobalData::PS_ModuleDeclSeen); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | value_def { +// | value_def idl_global->set_parse_state (IDL_GlobalData::PS_ValuetypeDeclSeen); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | error { +// | error idl_global->err()->syntax_error (idl_global->parse_state()); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); yyerrok; } @@ -318,43 +370,51 @@ definition module : IDL_MODULE { +// module : IDL_MODULE idl_global->set_parse_state (IDL_GlobalData::PS_ModuleSeen); } IDENTIFIER { - UTL_ScopedName *n = - new UTL_ScopedName(new Identifier ($3), 0); +// IDENTIFIER + Identifier id ($3); + UTL_ScopedName n (&id, + 0); AST_Module *m = 0; - UTL_Scope *s = idl_global->scopes ()->top_non_null (); + UTL_Scope *s = idl_global->scopes ().top_non_null (); idl_global->set_parse_state (IDL_GlobalData::PS_ModuleIDSeen); /* * Make a new module and add it to the enclosing scope */ - if (s != 0) { - m = idl_global->gen ()->create_module (s, n); - (void) s->fe_add_module (m); - } + if (s != 0) + { + m = idl_global->gen ()->create_module (s, + &n); + (void) s->fe_add_module (m); + } /* * Push it on the stack */ - idl_global->scopes ()->push (m); + idl_global->scopes ().push (m); } '{' { +// '{' idl_global->set_parse_state (IDL_GlobalData::PS_ModuleSqSeen); } definitions { +// definitions idl_global->set_parse_state (IDL_GlobalData::PS_ModuleBodySeen); } '}' { +// '}' idl_global->set_parse_state (IDL_GlobalData::PS_ModuleQsSeen); /* * Finished with this module - pop it from the scope stack */ - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } ; @@ -366,58 +426,71 @@ interface_def interface : interface_header { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// interface : interface_header + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Interface *i = 0; /* * Make a new interface node and add it to its enclosing scope */ - if (s != 0 && $1 != 0) { - i = idl_global->gen ()->create_interface ( - $1->interface_name (), - $1->inherits (), - $1->n_inherits (), - $1->inherits_flat (), - $1->n_inherits_flat (), - $1->is_local (), - $1->is_abstract () - ); - AST_Interface::fwd_redefinition_helper (i, s); - /* - * Add the interface to its definition scope - */ - (void) s->fe_add_interface (i); - } + if (s != 0 && $1 != 0) + { + i = + idl_global->gen ()->create_interface ( + $1->interface_name (), + $1->inherits (), + $1->n_inherits (), + $1->inherits_flat (), + $1->n_inherits_flat (), + $1->is_local (), + $1->is_abstract () + ); + AST_Interface::fwd_redefinition_helper (i, + s); + /* + * Add the interface to its definition scope + */ + (void) s->fe_add_interface (i); + } /* * Push it on the scope stack */ - idl_global->scopes ()->push (i); + idl_global->scopes ().push (i); + // This FE_InterfaceHeader class isn't destroyed with the AST. + $1->interface_name ()->destroy (); + delete $1; + $1 = 0; } '{' { +// '{' idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSqSeen); } exports { +// exports idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceBodySeen); } '}' { +// '}' idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceQsSeen); /* * Done with this interface - pop it off the scopes stack */ - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } ; interface_decl: IDL_INTERFACE { +// interface_decl : IDL_INTERFACE idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSeen); } id { +// id idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceIDSeen); $$ = $3; } @@ -426,6 +499,7 @@ interface_decl: interface_header : interface_decl inheritance_spec { +// interface_header : interface_decl inheritance_spec idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen); /* * Create an AST representation of the information in the header @@ -433,11 +507,17 @@ interface_header : * list of all interfaces which this interface inherits from, * recursively */ - $$ = new FE_InterfaceHeader (new UTL_ScopedName ($1, 0), $2); + UTL_ScopedName n ($1, + 0); + ACE_NEW_RETURN ($$, + FE_InterfaceHeader (&n, + $2), + 1); } | IDL_LOCAL interface_decl inheritance_spec { +// | IDL_LOCAL interface_decl inheritance_spec idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen); /* * Create an AST representation of the information in the header @@ -445,11 +525,17 @@ interface_header : * list of all interfaces which this interface inherits from, * recursively */ - $$ = new FE_Local_InterfaceHeader (new UTL_ScopedName($2, 0), $3); + UTL_ScopedName n ($2, + 0); + ACE_NEW_RETURN ($$, + FE_InterfaceHeader (&n, + $3), + 1); } | IDL_ABSTRACT interface_decl inheritance_spec { +// | IDL_ABSTRACT interface_decl inheritance_spec ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error in %s line %d\n"), idl_global->filename ()->get_string (), @@ -463,14 +549,17 @@ interface_header : inheritance_spec : ':' { +// inheritance_spec : ':' idl_global->set_parse_state (IDL_GlobalData::PS_InheritColonSeen); } at_least_one_scoped_name { +// at_least_one_scoped_name $$ = $3; } | /* EMPTY */ { +// | /* EMPTY */ $$ = 0; } ; @@ -485,6 +574,7 @@ value_def valuetype : IDL_CUSTOM value_concrete_decl { +// valuetype : IDL_CUSTOM value_concrete_decl ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error in %s line %d\n"), idl_global->filename ()->get_string (), @@ -499,42 +589,51 @@ valuetype value_concrete_decl : value_header { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// value_concrete_decl : value_header + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Interface *i = 0; - if (s != 0 && $1 != 0) { - i = idl_global->gen ()->create_valuetype ($1->interface_name (), - $1->inherits (), - $1->n_inherits ()); - AST_Interface::fwd_redefinition_helper (i, s); - /* - * Add the valuetype to its definition scope - */ - (void) s->fe_add_interface (i); - } + if (s != 0 && $1 != 0) + { + i = + idl_global->gen ()->create_valuetype ( + $1->interface_name (), + $1->inherits (), + $1->n_inherits () + ); + AST_Interface::fwd_redefinition_helper (i, + s); + /* + * Add the valuetype to its definition scope + */ + (void) s->fe_add_interface (i); + } /* * Push it on the scope stack */ - idl_global->scopes ()->push (i); + idl_global->scopes ().push (i); } '{' { +// '{' idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSqSeen); } value_elements { +// value_elements idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceBodySeen); } '}' { +// '}' idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceQsSeen); /* * Done with this interface - pop it off the scopes stack */ - UTL_Scope* s = idl_global->scopes ()->top (); + UTL_Scope* s = idl_global->scopes ().top (); AST_Interface* m = AST_Interface::narrow_from_scope (s); m->inherited_name_clash (); - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } ; @@ -542,48 +641,60 @@ value_abs_decl : IDL_ABSTRACT value_header { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// value_abs_decl : IDL_ABSTRACT value_header + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Interface *i = 0; - if (s != 0 && $2 != 0) { + if (s != 0 && $2 != 0) + { + if ($2->n_concrete() > 0) + { + idl_global->err ()->abstract_inheritance_error ( + $2->interface_name () + ); + } - if ($2->n_concrete() > 0) { - idl_global->err ()->abstract_inheritance_error ($2->interface_name ()); + i = + idl_global->gen ()->create_valuetype ( + $2->interface_name (), + $2->inherits (), + $2->n_inherits () + ); + i->set_abstract_valuetype (); + AST_Interface::fwd_redefinition_helper (i, + s); + /* + * Add the valuetype to its definition scope + */ + (void) s->fe_add_interface (i); } - i = idl_global->gen()->create_valuetype ($2->interface_name (), - $2->inherits (), - $2->n_inherits ()); - i->set_abstract_valuetype (); - AST_Interface::fwd_redefinition_helper (i, s); - /* - * Add the valuetype to its definition scope - */ - (void) s->fe_add_interface (i); - } /* - * Push it on the scope stack + * Push it on the scope stack. */ - idl_global->scopes ()->push (i); + idl_global->scopes ().push (i); } '{' { +// '{' idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSqSeen); } exports { +// exports idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceBodySeen); } '}' { +// '}' idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceQsSeen); /* * Done with this interface - pop it off the scopes stack */ - UTL_Scope* s = idl_global->scopes ()->top (); + UTL_Scope* s = idl_global->scopes ().top (); AST_Interface* m = AST_Interface::narrow_from_scope (s); m->inherited_name_clash (); - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } ; @@ -594,58 +705,79 @@ value_header : inheritance_spec supports_spec { - $$ = new FE_obv_header (new UTL_ScopedName ($1, 0), $3, $4); +// value_header : value_decl opt_truncatable inheritance_spec supports_spec + UTL_ScopedName *sn = 0; + ACE_NEW_RETURN (sn, + UTL_ScopedName ($1, + 0), + 1); + ACE_NEW_RETURN ($$, + FE_obv_header (sn, + $3, + $4), + 1); } ; value_decl : IDL_VALUETYPE { +// value_decl : IDL_VALUETYPE idl_global->set_parse_state (IDL_GlobalData::PS_ValuetypeSeen); } id { - idl_global->set_parse_state (IDL_GlobalData::PS_ValuetypeIDSeen); - $$ = $3; +// id + idl_global->set_parse_state (IDL_GlobalData::PS_ValuetypeIDSeen); + $$ = $3; } ; opt_truncatable : - IDL_TRUNCATABLE - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("warning in %s line %d\n"), - idl_global->filename ()->get_string (), - idl_global->lineno ())); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("truncatable modifier not supported ") - ACE_TEXT ("and is ignored\n"))); - $$ = I_FALSE; - } + IDL_TRUNCATABLE + { +// opt_truncatable : IDL_TRUNCATABLE + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("warning in %s line %d\n"), + idl_global->filename ()->get_string (), + idl_global->lineno ())); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("truncatable modifier not supported ") + ACE_TEXT ("and is ignored\n"))); + $$ = I_FALSE; + } | /* EMPTY */ { +// | /* EMPTY */ $$ = I_FALSE; } ; supports_spec : - IDL_SUPPORTS - scoped_name - { - $$ = new UTL_NameList ($2, 0); - } - | /* empty */ - { - $$ = 0; - } + IDL_SUPPORTS + scoped_name + { +// supports_spec : IDL_SUPPORTS scoped_name + ACE_NEW_RETURN ($$, + UTL_NameList ($2, + 0), + 1); + } + | /* EMPTY */ + { +// | /* EMPTY */ + $$ = 0; + } ; value_forward_decl : IDL_ABSTRACT value_decl { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName ($2, 0); +// value_forward_decl : IDL_ABSTRACT value_decl + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n ($2, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -653,17 +785,20 @@ value_forward_decl : * Create a node representing a forward declaration of an * valuetype. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen()->create_valuetype_fwd (n); - f->set_abstract_valuetype (); - (void) s->fe_add_interface_fwd (f); + if (s != 0) + { + f = idl_global->gen()->create_valuetype_fwd (&n); + f->set_abstract_valuetype (); + (void) s->fe_add_interface_fwd (f); } } - | + | value_decl { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName ($1, 0); +// | value_decl + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n ($1, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -671,10 +806,11 @@ value_forward_decl : * Create a node representing a forward declaration of an * valuetype. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen ()->create_valuetype_fwd (n); - (void) s->fe_add_interface_fwd (f); - } + if (s != 0) + { + f = idl_global->gen ()->create_valuetype_fwd (&n); + (void) s->fe_add_interface_fwd (f); + } } ; @@ -682,6 +818,7 @@ value_forward_decl : value_box_decl : value_decl type_spec /* in this order %!?*/ { +// value_box_decl : value_decl type_spec ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error in %s line %d\n"), idl_global->filename ()->get_string (), @@ -706,17 +843,18 @@ value_element state_member : IDL_PUBLIC - { - /* is $0 to member_i */ - $<vival>$ = AST_Field::vis_PUBLIC; - } - member_i + { +// state_member : IDL_PUBLIC + /* is $0 to member_i */ + $<vival>$ = AST_Field::vis_PUBLIC; + } + member_i | IDL_PRIVATE - { - /* is $0 to member_i */ - $<vival>$ = AST_Field::vis_PRIVATE; - } - member_i + { + /* is $0 to member_i */ + $<vival>$ = AST_Field::vis_PRIVATE; + } + member_i ; exports @@ -727,50 +865,82 @@ exports export : type_dcl { +// export : type_dcl idl_global->set_parse_state (IDL_GlobalData::PS_TypeDeclSeen); } ';' { +// ';' + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); + } + | typeid_dcl + { +// | typeid_dcl + idl_global->set_parse_state (IDL_GlobalData::PS_TypeIdDeclSeen); + } + ';' + { +// ';' + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); + } + | typeprefix_dcl + { +// | typeprefix_dcl + idl_global->set_parse_state (IDL_GlobalData::PS_TypePrefixDeclSeen); + } + ';' + { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | const_dcl { +// | const_dcl idl_global->set_parse_state (IDL_GlobalData::PS_ConstDeclSeen); } ';' { +// ';' idl_global->set_parse_state(IDL_GlobalData::PS_NoState); } | exception { +// | exception idl_global->set_parse_state (IDL_GlobalData::PS_ExceptDeclSeen); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | attribute { +// | attribute idl_global->set_parse_state (IDL_GlobalData::PS_AttrDeclSeen); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | operation { +// | operation idl_global->set_parse_state (IDL_GlobalData::PS_OpDeclSeen); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } | error { +// | error idl_global->err()->syntax_error (idl_global->parse_state()); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); yyerrok; } @@ -779,7 +949,11 @@ export at_least_one_scoped_name : scoped_name scoped_names { - $$ = new UTL_NameList ($1, $2); +//at_least_one_scoped_name : scoped_name scoped_names + ACE_NEW_RETURN ($$, + UTL_NameList ($1, + $2), + 1); } ; @@ -787,21 +961,35 @@ scoped_names : scoped_names ',' { +// scoped_names : scoped_names ',' idl_global->set_parse_state (IDL_GlobalData::PS_SNListCommaSeen); } scoped_name { +// scoped_name idl_global->set_parse_state (IDL_GlobalData::PS_ScopedNameSeen); if ($1 == 0) - $$ = new UTL_NameList ($4, 0); - else { - $1->nconc (new UTL_NameList ($4, 0)); - $$ = $1; - } + { + ACE_NEW_RETURN ($$, + UTL_NameList ($4, + 0), + 1); + } + else + { + UTL_NameList *nl = 0; + ACE_NEW_RETURN (nl, + UTL_NameList ($4, + 0), + 1); + $1->nconc (nl); + $$ = $1; + } } | /* EMPTY */ { +// | /* EMPTY */ $$ = 0; } ; @@ -809,46 +997,76 @@ scoped_names scoped_name : id { +// scoped_name : id idl_global->set_parse_state (IDL_GlobalData::PS_SN_IDSeen); - $$ = new UTL_IdList($1, 0); + ACE_NEW_RETURN ($$, + UTL_IdList ($1, + 0), + 1); } | IDL_SCOPE_DELIMITOR { +// | IDL_SCOPE_DELIMITOR idl_global->set_parse_state (IDL_GlobalData::PS_ScopeDelimSeen); } id { +// id idl_global->set_parse_state (IDL_GlobalData::PS_SN_IDSeen); - $$ = new UTL_IdList (new Identifier ($1), - new UTL_IdList ($3, 0)); + Identifier *id = 0; + ACE_NEW_RETURN (id, + Identifier ($1), + 1); + UTL_IdList *sn = 0; + ACE_NEW_RETURN (sn, + UTL_IdList ($3, + 0), + 1); + ACE_NEW_RETURN ($$, + UTL_IdList (id, + sn), + 1); } | scoped_name IDL_SCOPE_DELIMITOR { +// | scoped_name IDL_SCOPE_DELIMITOR idl_global->set_parse_state (IDL_GlobalData::PS_ScopeDelimSeen); } id { +// id idl_global->set_parse_state (IDL_GlobalData::PS_SN_IDSeen); - $1->nconc (new UTL_IdList ($4, 0)); + UTL_IdList *sn = 0; + ACE_NEW_RETURN (sn, + UTL_IdList ($4, + 0), + 1); + $1->nconc (sn); $$ = $1; } ; id: IDENTIFIER { - $$ = new Identifier ($1); +// id: IDENTIFIER + ACE_NEW_RETURN ($$, + Identifier ($1), + 1); + ACE_OS::free ($1); } ; forward : interface_decl { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName($1, 0); +// forward : interface_decl + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n ($1, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -856,16 +1074,21 @@ forward : * Create a node representing a forward declaration of an * interface. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen ()->create_interface_fwd (n, 0, 0); - (void) s->fe_add_interface_fwd (f); - } + if (s != 0) + { + f = idl_global->gen ()->create_interface_fwd (&n, + 0, + 0); + (void) s->fe_add_interface_fwd (f); + } } | IDL_LOCAL interface_decl { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName ($2, 0); +// | IDL_LOCAL interface_decl + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n ($2, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -873,16 +1096,21 @@ forward : * Create a node representing a forward declaration of an * interface. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen ()->create_interface_fwd (n, 1, 0); - (void) s->fe_add_interface_fwd (f); - } + if (s != 0) + { + f = idl_global->gen ()->create_interface_fwd (&n, + 1, + 0); + (void) s->fe_add_interface_fwd (f); + } } | IDL_ABSTRACT interface_decl { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName ($2, 0); +// | IDL_ABSTRACT interface_decl + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n ($2, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -890,50 +1118,76 @@ forward : * Create a node representing a forward declaration of an * interface. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen ()->create_interface_fwd (n, 0, 1); - (void) s->fe_add_interface_fwd (f); - } + if (s != 0) + { + f = idl_global->gen ()->create_interface_fwd (&n, + 0, + 1); + (void) s->fe_add_interface_fwd (f); + } } ; const_dcl : IDL_CONST { +// const_dcl : IDL_CONST idl_global->set_parse_state (IDL_GlobalData::PS_ConstSeen); } const_type { +// const_type idl_global->set_parse_state (IDL_GlobalData::PS_ConstTypeSeen); } id { +// id idl_global->set_parse_state (IDL_GlobalData::PS_ConstIDSeen); } '=' { +// '=' idl_global->set_parse_state (IDL_GlobalData::PS_ConstAssignSeen); } expression { - UTL_ScopedName *n = new UTL_ScopedName ($5, 0); - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// expression + UTL_ScopedName n ($5, + 0); + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Constant *c = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ConstExprSeen); /* * Create a node representing a constant declaration. Store - * it in the enclosing scope + * it in the enclosing scope. */ - if ($9 != 0 && s != 0) { - if ($9->coerce ($3) == 0) - idl_global->err ()->coercion_error ($9, $3); - else { - c = - idl_global->gen ()->create_constant ($3, $9, n); - (void) s->fe_add_constant (c); + if ($9 != 0 && s != 0) + { + AST_Expression::AST_ExprValue *result = + $9->coerce ($3); + + if (result == 0) + { + idl_global->err ()->coercion_error ($9, + $3); + } + else + { + c = + idl_global->gen ()->create_constant ( + $3, + $9, + &n + ); + (void) s->fe_add_constant (c); + delete result; + } + + $5->destroy (); + delete $5; + $5 = 0; } - } } ; @@ -946,16 +1200,25 @@ const_type | fixed_type | string_type_spec { +// const_type +// : integer_type +// | char_type +// | octet_type +// | boolean_type +// | floating_pt_type +// | fixed_type +// | string_type_spec $$ = AST_Expression::EV_string; } | wstring_type_spec { +// | wstring_type_spec $$ = AST_Expression::EV_wstring; } | scoped_name { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - AST_Decl *d = 0; +// | scoped_name + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_PredefinedType *c = 0; AST_Typedef *t = 0; @@ -963,33 +1226,61 @@ const_type * If the constant's type is a scoped name, it must resolve * to a scalar constant type */ - if (s != 0 && (d = s->lookup_by_name ($1, I_TRUE)) != 0) { - /* - * Look through typedefs - */ - while (d->node_type () == AST_Decl::NT_typedef) { - t = AST_Typedef::narrow_from_decl (d); - if (t == 0) - break; - d = t->base_type (); - } - if (d == 0) - $$ = AST_Expression::EV_any; - else if (d->node_type () == AST_Decl::NT_pre_defined) { - c = AST_PredefinedType::narrow_from_decl (d); - if (c != 0) { - $$ = idl_global->PredefinedTypeToExprType (c->pt ()); - } else { - $$ = AST_Expression::EV_any; - } - } else if (d->node_type () == AST_Decl::NT_string) { - $$ = AST_Expression::EV_string; - } else if (d->node_type () == AST_Decl::NT_wstring) { - $$ = AST_Expression::EV_wstring; - } else + AST_Decl *d = + s->lookup_by_name ($1, + I_TRUE); + + if (s != 0 && d != 0) + { + /* + * Look through typedefs. + */ + while (d->node_type () == AST_Decl::NT_typedef) + { + t = AST_Typedef::narrow_from_decl (d); + + if (t == 0) + { + break; + } + + d = t->base_type (); + } + + if (d == 0) + { + $$ = AST_Expression::EV_any; + } + else if (d->node_type () == AST_Decl::NT_pre_defined) + { + c = AST_PredefinedType::narrow_from_decl (d); + + if (c != 0) + { + $$ = idl_global->PredefinedTypeToExprType (c->pt ()); + } + else + { + $$ = AST_Expression::EV_any; + } + } + else if (d->node_type () == AST_Decl::NT_string) + { + $$ = AST_Expression::EV_string; + } + else if (d->node_type () == AST_Decl::NT_wstring) + { + $$ = AST_Expression::EV_wstring; + } + else + { + $$ = AST_Expression::EV_any; + } + } + else + { $$ = AST_Expression::EV_any; - } else - $$ = AST_Expression::EV_any; + } } ; @@ -1000,9 +1291,14 @@ const_expr : or_expr ; or_expr : xor_expr | or_expr '|' xor_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_or, - $1, - $3); +// or_expr : xor_expr +// | or_expr '|' xor_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_or, + $1, + $3 + ); } ; @@ -1010,9 +1306,14 @@ xor_expr : and_expr | xor_expr '^' and_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_xor, - $1, - $3); +// xor_expr : and_expr +// | xor_expr '^' and_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_xor, + $1, + $3 + ); } ; @@ -1020,9 +1321,13 @@ and_expr : shift_expr | and_expr '&' shift_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_and, - $1, - $3); +// and_expr : shift_expr | and_expr '&' shift_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_and, + $1, + $3 + ); } ; @@ -1030,15 +1335,23 @@ shift_expr : add_expr | shift_expr IDL_LEFT_SHIFT add_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_left, - $1, - $3); +// shift_expr : add_expr | shift_expr IDL_LEFT_SHIFT add_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_left, + $1, + $3 + ); } | shift_expr IDL_RIGHT_SHIFT add_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_right, - $1, - $3); +// | shift_expr IDL_RIGHT_SHIFT add_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_right, + $1, + $3 + ); } ; @@ -1046,15 +1359,23 @@ add_expr : mult_expr | add_expr '+' mult_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_add, - $1, - $3); +// add_expr : mult_expr | add_expr '+' mult_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_add, + $1, + $3 + ); } | add_expr '-' mult_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_minus, - $1, - $3); +// | add_expr '-' mult_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_minus, + $1, + $3 + ); } ; @@ -1062,21 +1383,33 @@ mult_expr : unary_expr | mult_expr '*' unary_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_mul, - $1, - $3); +// mult_expr : unary_expr | mult_expr '*' unary_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_mul, + $1, + $3 + ); } | mult_expr '/' unary_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_div, - $1, - $3); +// | mult_expr '/' unary_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_div, + $1, + $3 + ); } | mult_expr '%' unary_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_mod, - $1, - $3); +// | mult_expr '%' unary_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_mod, + $1, + $3 + ); } ; @@ -1084,34 +1417,46 @@ unary_expr : primary_expr | '+' primary_expr { - $$ = idl_global->gen ()->create_expr (AST_Expression::EC_u_plus, - $2, - 0); +// unary_expr : primary_expr | '+' primary_expr + $$ = + idl_global->gen ()->create_expr ( + AST_Expression::EC_u_plus, + $2, + 0 + ); } | '-' primary_expr { - $$ = idl_global->gen()->create_expr (AST_Expression::EC_u_minus, - $2, - 0); +// | '-' primary_expr + $$ = + idl_global->gen()->create_expr ( + AST_Expression::EC_u_minus, + $2, + 0 + ); } | '~' primary_expr { - $$ = idl_global->gen()->create_expr (AST_Expression::EC_bit_neg, - $2, - 0); +// | '~' primary_expr + $$ = + idl_global->gen()->create_expr ( + AST_Expression::EC_bit_neg, + $2, + 0 + ); } ; primary_expr : scoped_name { +// primary_expr : scoped_name /* * An expression which is a scoped name is not resolved now, * but only when it is evaluated (such as when it is assigned * as a constant value). */ - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = s->lookup_by_name ($1, 1); @@ -1136,6 +1481,8 @@ primary_expr | literal | '(' const_expr ')' { +// | literal +// | '(' const_expr ')' $$ = $2; } ; @@ -1143,40 +1490,49 @@ primary_expr literal : IDL_INTEGER_LITERAL { +// literal : IDL_INTEGER_LITERAL $$ = idl_global->gen ()->create_expr ($1); } | IDL_UINTEGER_LITERAL { +// | IDL_UINTEGER_LITERAL $$ = idl_global->gen ()->create_expr ($1); } | IDL_STRING_LITERAL { +// | IDL_STRING_LITERAL $$ = idl_global->gen ()->create_expr ($1); } | IDL_WSTRING_LITERAL { +// | IDL_WSTRING_LITERAL $$ = idl_global->gen ()->create_expr ($1); } | IDL_CHARACTER_LITERAL { +// | IDL_CHARACTER_LITERAL $$ = idl_global->gen ()->create_expr ($1); } | IDL_WCHAR_LITERAL { +// | IDL_WCHAR_LITERAL ACE_OutputCDR::from_wchar wc ($1); $$ = idl_global->gen ()->create_expr (wc); } | IDL_FLOATING_PT_LITERAL { +// | IDL_FLOATING_PT_LITERAL $$ = idl_global->gen ()->create_expr ($1); } | IDL_TRUETOK { +// | IDL_TRUETOK $$ = idl_global->gen ()->create_expr ((idl_bool) I_TRUE, AST_Expression::EV_bool); } | IDL_FALSETOK { +// | IDL_FALSETOK $$ = idl_global->gen ()->create_expr ((idl_bool) I_FALSE, AST_Expression::EV_bool); } @@ -1185,10 +1541,9 @@ literal positive_int_expr : const_expr { +// positive_int_expr : const_expr int good_expression = 1; - $1->evaluate (AST_Expression::EK_positive_int); - AST_Expression::AST_ExprValue *ev = $1->ev (); /* @@ -1251,16 +1606,34 @@ positive_int_expr : type_dcl : IDL_TYPEDEF - { - idl_global->set_parse_state (IDL_GlobalData::PS_TypedefSeen); - } - type_declarator {$$ = 0;} - | struct_type { $$ = 0;} - | union_type { $$ = 0;} - | enum_type { $$ = 0;} + { +// type_dcl : IDL_TYPEDEF + idl_global->set_parse_state (IDL_GlobalData::PS_TypedefSeen); + } + type_declarator + { +// type_declarator + $$ = 0; + } + | struct_type + { +// | struct_type + $$ = 0; + } + | union_type + { +// | union_type + $$ = 0; + } + | enum_type + { +// | enum_type + $$ = 0; + } | IDL_NATIVE simple_declarator { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// | IDL_NATIVE simple_declarator + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Native *node = 0; idl_global->set_parse_state (IDL_GlobalData::PS_NativeSeen); @@ -1268,24 +1641,30 @@ type_dcl * Create a node representing a Native and add it to its * enclosing scope */ - if (s != 0) { - node = idl_global->gen ()->create_native ($2->name ()); - /* - * Add it to its defining scope - */ - (void) s->fe_add_native (node); - } + if (s != 0) + { + node = + idl_global->gen ()->create_native ( + $2->name () + ); + /* + * Add it to its defining scope + */ + (void) s->fe_add_native (node); + } } ; type_declarator : type_spec { +// type_declarator : type_spec idl_global->set_parse_state (IDL_GlobalData::PS_TypeSpecSeen); } at_least_one_declarator { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// at_least_one_declarator + UTL_Scope *s = idl_global->scopes ().top_non_null (); FE_Declarator *d = 0; AST_Typedef *t = 0; @@ -1294,21 +1673,38 @@ type_declarator : * Create a list of type renamings. Add them to the * enclosing scope */ - if (s != 0 && $1 != 0 && $3 != 0) { - for (UTL_DecllistActiveIterator l ($3); !l.is_done (); l.next ()) { - d = l.item (); - if (d == 0) - continue; - AST_Type * tp = d->compose ($1); - if (tp == 0) - continue; - t = idl_global->gen ()->create_typedef (tp, - d->name (), - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_typedef (t); + if (s != 0 && $1 != 0 && $3 != 0) + { + for (UTL_DecllistActiveIterator l ($3); + !l.is_done (); + l.next ()) + { + d = l.item (); + + if (d == 0) + { + continue; + } + + AST_Type * tp = d->compose ($1); + + if (tp == 0) + { + continue; + } + + t = idl_global->gen ()->create_typedef (tp, + d->name (), + s->is_local (), + s->is_abstract ()); + (void) s->fe_add_typedef (t); + } + + // This FE_Declarator class isn't destroyed with the AST. + $3->destroy (); + delete $3; + $3 = 0; } - } } ; @@ -1320,18 +1716,31 @@ type_spec simple_type_spec : base_type_spec { - $$ = idl_global->scopes ()->bottom ()->lookup_primitive_type ($1); +// simple_type_spec : base_type_spec + $$ = + idl_global->scopes ().bottom ()->lookup_primitive_type ( + $1 + ); } | template_type_spec | scoped_name { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// | template_type_spec +// | scoped_name + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = 0; if (s != 0) - d = s->lookup_by_name ($1, I_TRUE); + { + d = s->lookup_by_name ($1, + I_TRUE); + } + if (d == 0) - idl_global->err ()->lookup_error ($1); + { + idl_global->err ()->lookup_error ($1); + } + $$ = d; } ; @@ -1361,7 +1770,11 @@ constructed_type_spec at_least_one_declarator : declarator declarators { - $$ = new UTL_DeclList ($1, $2); +// at_least_one_declarator : declarator declarators + ACE_NEW_RETURN ($$, + UTL_DeclList ($1, + $2), + 1); } ; @@ -1369,21 +1782,35 @@ declarators : declarators ',' { +// declarators : declarators ',' idl_global->set_parse_state (IDL_GlobalData::PS_DeclsCommaSeen); } declarator { +// declarator idl_global->set_parse_state (IDL_GlobalData::PS_DeclsDeclSeen); if ($1 == 0) - $$ = new UTL_DeclList ($4, 0); - else { - $1->nconc (new UTL_DeclList ($4, 0)); - $$ = $1; - } + { + ACE_NEW_RETURN ($$, + UTL_DeclList ($4, + 0), + 1); + } + else + { + UTL_DeclList *dl = 0; + ACE_NEW_RETURN (dl, + UTL_DeclList ($4, + 0), + 1); + $1->nconc (dl); + $$ = $1; + } } | /* EMPTY */ { +// | /* EMPTY */ $$ = 0; } ; @@ -1396,7 +1823,11 @@ declarator at_least_one_simple_declarator : simple_declarator simple_declarators { - $$ = new UTL_DeclList ($1, $2); +// at_least_one_simple_declarator : simple_declarator simple_declarators + ACE_NEW_RETURN ($$, + UTL_DeclList ($1, + $2), + 1); } ; @@ -1404,21 +1835,35 @@ simple_declarators : simple_declarators ',' { +// simple_declarators : simple_declarators ',' idl_global->set_parse_state (IDL_GlobalData::PS_DeclsCommaSeen); } simple_declarator { +// simple_declarator idl_global->set_parse_state (IDL_GlobalData::PS_DeclsDeclSeen); if ($1 == 0) - $$ = new UTL_DeclList ($4, 0); - else { - $1->nconc (new UTL_DeclList ($4, 0)); - $$ = $1; - } + { + ACE_NEW_RETURN ($$, + UTL_DeclList ($4, + 0), + 1); + } + else + { + UTL_DeclList *dl = 0; + ACE_NEW_RETURN (dl, + UTL_DeclList ($4, + 0), + 1); + $1->nconc (dl); + $$ = $1; + } } | /* EMPTY */ { +// | /* EMPTY */ $$ = 0; } ; @@ -1426,18 +1871,34 @@ simple_declarators simple_declarator : id { - $$ = new FE_Declarator (new UTL_ScopedName ($1, 0), - FE_Declarator::FD_simple, 0); +// simple_declarator : id + UTL_ScopedName *sn = 0; + ACE_NEW_RETURN (sn, + UTL_ScopedName ($1, + 0), + 1); + ACE_NEW_RETURN ($$, + FE_Declarator (sn, + FE_Declarator::FD_simple, + 0), + 1); } ; complex_declarator : array_declarator { - $$ = new FE_Declarator (new UTL_ScopedName ($1->local_name (), - 0), - FE_Declarator::FD_complex, - $1); +// complex_declarator : array_declarator + UTL_ScopedName *sn = 0; + ACE_NEW_RETURN (sn, + UTL_ScopedName ($1->local_name (), + 0), + 1); + ACE_NEW_RETURN ($$, + FE_Declarator (sn, + FE_Declarator::FD_complex, + $1), + 1); } ; @@ -1449,14 +1910,17 @@ integer_type signed_int : IDL_LONG { +// signed_int : IDL_LONG $$ = AST_Expression::EV_long; } | IDL_LONG IDL_LONG { +// | IDL_LONG IDL_LONG $$ = AST_Expression::EV_longlong; } | IDL_SHORT { +// | IDL_SHORT $$ = AST_Expression::EV_short; } ; @@ -1464,14 +1928,17 @@ signed_int unsigned_int : IDL_UNSIGNED IDL_LONG { +// unsigned_int : IDL_UNSIGNED IDL_LONG $$ = AST_Expression::EV_ulong; } | IDL_UNSIGNED IDL_LONG IDL_LONG { +// | IDL_UNSIGNED IDL_LONG IDL_LONG $$ = AST_Expression::EV_ulonglong; } | IDL_UNSIGNED IDL_SHORT { +// | IDL_UNSIGNED IDL_SHORT $$ = AST_Expression::EV_ushort; } ; @@ -1479,14 +1946,17 @@ unsigned_int floating_pt_type : IDL_DOUBLE { +// floating_pt_type : IDL_DOUBLE $$ = AST_Expression::EV_double; } | IDL_FLOAT { +// | IDL_FLOAT $$ = AST_Expression::EV_float; } | IDL_LONG IDL_DOUBLE { +// | IDL_LONG IDL_DOUBLE $$ = AST_Expression::EV_longdouble; } ; @@ -1494,6 +1964,7 @@ floating_pt_type fixed_type : IDL_FIXED { +// fixed_type : IDL_FIXED ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error in %s line %d\n"), idl_global->filename ()->get_string (), @@ -1507,10 +1978,12 @@ fixed_type char_type : IDL_CHAR { +// char_type : IDL_CHAR $$ = AST_Expression::EV_char; } | IDL_WCHAR { +// | IDL_WCHAR $$ = AST_Expression::EV_wchar; } ; @@ -1518,6 +1991,7 @@ char_type octet_type : IDL_OCTET { +// octet_type : IDL_OCTET $$ = AST_Expression::EV_octet; } ; @@ -1525,6 +1999,7 @@ octet_type boolean_type : IDL_BOOLEAN { +// boolean_type : IDL_BOOLEAN $$ = AST_Expression::EV_bool; } ; @@ -1532,6 +2007,7 @@ boolean_type any_type : IDL_ANY { +// any_type : IDL_ANY $$ = AST_Expression::EV_any; } ; @@ -1539,12 +2015,15 @@ any_type struct_type : IDL_STRUCT { +// struct_type : IDL_STRUCT idl_global->set_parse_state (IDL_GlobalData::PS_StructSeen); } id { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName ($3, 0); +// id + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n ($3, + 0); AST_Structure *d = 0; idl_global->set_parse_state (IDL_GlobalData::PS_StructIDSeen); @@ -1552,16 +2031,20 @@ struct_type : * Create a node representing a struct declaration. Add it * to the enclosing scope */ - if (s != 0) { - d = idl_global->gen ()->create_structure (n, - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_structure (d); - } + if (s != 0) + { + d = + idl_global->gen ()->create_structure ( + &n, + s->is_local (), + s->is_abstract () + ); + (void) s->fe_add_structure (d); + } /* * Push the scope of the struct on the scopes stack */ - idl_global->scopes ()->push (d); + idl_global->scopes ().push (d); } '{' { @@ -1569,6 +2052,7 @@ struct_type : } at_least_one_member { +// at_least_one_member idl_global->set_parse_state (IDL_GlobalData::PS_StructBodySeen); } '}' @@ -1578,9 +2062,9 @@ struct_type : * Done with this struct. Pop its scope off the scopes stack */ $$ = AST_Structure::narrow_from_scope ( - idl_global->scopes ()->top_non_null () + idl_global->scopes ().top_non_null () ); - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } ; @@ -1593,24 +2077,28 @@ members member : { +// member : /* is $0 to member_i */ $<vival>$ = AST_Field::vis_NA; } member_i ; -member_i: +member_i : type_spec { +// member_i : type_spec idl_global->set_parse_state (IDL_GlobalData::PS_MemberTypeSeen); } at_least_one_declarator { +// at_least_one_declarator idl_global->set_parse_state (IDL_GlobalData::PS_MemberDeclsSeen); } ';' { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// ';' + UTL_Scope *s = idl_global->scopes ().top_non_null (); FE_Declarator *d = 0; AST_Field *f = 0; @@ -1618,35 +2106,57 @@ member_i: /* * Check for illegal recursive use of type */ - if ($1 != 0 && AST_illegal_recursive_type ($1)) - idl_global->err ()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE, - $1); + if ($1 != 0 + && AST_illegal_recursive_type ($1)) + { + idl_global->err ()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE, + $1); + } /* * Create a node representing a struct or exception member * Add it to the enclosing scope */ - else if (s != 0 && $1 != 0 && $3 != 0) { - for (UTL_DecllistActiveIterator l ($3); !(l.is_done ()); l.next ()) { - d = l.item (); - if (d == 0) - continue; - AST_Type *tp = d->compose ($1); - if (tp == 0) - continue; - /* $0 denotes Visibility, must be on yacc reduction stack */ - f = idl_global->gen ()->create_field (tp, - d->name (), - $<vival>0); - (void) s->fe_add_field (f); - } + else if (s != 0 + && $1 != 0 + && $3 != 0) + { + for (UTL_DecllistActiveIterator l ($3); + !l.is_done (); + l.next ()) + { + d = l.item (); + + if (d == 0) + { + continue; + } + + AST_Type *tp = d->compose ($1); + + if (tp == 0) + { + continue; + } + + /* $0 denotes Visibility, must be on yacc reduction stack */ + f = + idl_global->gen ()->create_field ( + tp, + d->name (), + $<vival>0 + ); + (void) s->fe_add_field (f); + } } } | error { +// | error idl_global->err()->syntax_error (idl_global->parse_state ()); } ';' { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); yyerrok; } @@ -1655,72 +2165,93 @@ member_i: union_type : IDL_UNION { +// union_type : IDL_UNION idl_global->set_parse_state (IDL_GlobalData::PS_UnionSeen); } id { +// id idl_global->set_parse_state (IDL_GlobalData::PS_UnionIDSeen); } IDL_SWITCH { +// IDL_SWITCH idl_global->set_parse_state (IDL_GlobalData::PS_SwitchSeen); } '(' { +// '(' idl_global->set_parse_state (IDL_GlobalData::PS_SwitchOpenParSeen); } switch_type_spec { +// switch_type_spec idl_global->set_parse_state (IDL_GlobalData::PS_SwitchTypeSeen); } ')' { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName ($3, 0); +// ')' + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n ($3, + 0); AST_Union *u = 0; idl_global->set_parse_state (IDL_GlobalData::PS_SwitchCloseParSeen); + /* * Create a node representing a union. Add it to its enclosing * scope */ - if ($9 != 0 && s != 0) { - AST_ConcreteType *tp = AST_ConcreteType::narrow_from_decl ($9); - if (tp == 0) { - idl_global->err ()->not_a_type ($9); - } else { - u = idl_global->gen ()->create_union (tp, - n, - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_union (u); + if ($9 != 0 + && s != 0) + { + AST_ConcreteType *tp = + AST_ConcreteType::narrow_from_decl ($9); + + if (tp == 0) + { + idl_global->err ()->not_a_type ($9); + } + else + { + u = idl_global->gen ()->create_union (tp, + &n, + s->is_local (), + s->is_abstract ()); + } + + (void) s->fe_add_union (u); } - } + /* * Push the scope of the union on the scopes stack */ - idl_global->scopes()->push (u); + idl_global->scopes ().push (u); } '{' { +// '{' idl_global->set_parse_state (IDL_GlobalData::PS_UnionSqSeen); } at_least_one_case_branch { +// at_least_one_case_branch idl_global->set_parse_state (IDL_GlobalData::PS_UnionBodySeen); } '}' { +// '}' idl_global->set_parse_state (IDL_GlobalData::PS_UnionQsSeen); /* * Done with this union. Pop its scope from the scopes stack */ $$ = AST_Union::narrow_from_scope ( - idl_global->scopes ()->top_non_null () + idl_global->scopes ().top_non_null () ); + if ($$ != 0) { - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } } ; @@ -1728,36 +2259,45 @@ union_type : switch_type_spec : integer_type { - $$ = idl_global->scopes ()->bottom ()->lookup_primitive_type ($1); +// switch_type_spec : integer_type + $$ = idl_global->scopes ().bottom ()->lookup_primitive_type ($1); } | char_type { +// | char_type /* wchars are not allowed */ if ($1 == AST_Expression::EV_wchar) { idl_global->err ()->error0 (UTL_Error::EIDL_DISC_TYPE); } - $$ = idl_global->scopes ()->bottom ()->lookup_primitive_type ($1); + $$ = + idl_global->scopes ().bottom ()->lookup_primitive_type ( + $1 + ); } | octet_type { +// | octet_type /* octets are not allowed */ idl_global->err ()->error0 (UTL_Error::EIDL_DISC_TYPE); - $$ = idl_global->scopes ()->bottom ()->lookup_primitive_type ($1); + $$ = idl_global->scopes ().bottom ()->lookup_primitive_type ($1); } | boolean_type { - $$ = idl_global->scopes ()->bottom ()->lookup_primitive_type ($1); +// | boolean_type + $$ = idl_global->scopes ().bottom ()->lookup_primitive_type ($1); } | enum_type | scoped_name { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// | enum_type +// | scoped_name + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = 0; AST_PredefinedType *p = 0; AST_Typedef *t = 0; - long found = I_FALSE; + idl_bool found = I_FALSE; /* * The discriminator is a scoped name. Try to resolve to @@ -1765,61 +2305,84 @@ switch_type_spec : * typedef's to arrive at the base type at the end of the * chain */ - if (s != 0 && (d = s->lookup_by_name ($1, I_TRUE)) != 0) { - while (!found) { - switch (d->node_type ()) { - case AST_Decl::NT_enum: - $$ = d; - found = I_TRUE; - break; - case AST_Decl::NT_pre_defined: - p = AST_PredefinedType::narrow_from_decl (d); - if (p != 0) { - switch (p->pt ()) { - case AST_PredefinedType::PT_long: - case AST_PredefinedType::PT_ulong: - case AST_PredefinedType::PT_longlong: - case AST_PredefinedType::PT_ulonglong: - case AST_PredefinedType::PT_short: - case AST_PredefinedType::PT_ushort: - case AST_PredefinedType::PT_char: - case AST_PredefinedType::PT_boolean: - $$ = p; - found = I_TRUE; - break; - case AST_PredefinedType::PT_wchar: - case AST_PredefinedType::PT_octet: - /* octets and wchars are not allowed */ - idl_global->err ()->error0 (UTL_Error::EIDL_DISC_TYPE); - $$ = 0; - found = I_TRUE; - break; - default: - $$ = 0; - found = I_TRUE; - break; - } - } else + d = s->lookup_by_name ($1, + I_TRUE); + + if (s != 0 && d != 0) + { + while (!found) { - $$ = 0; - found = I_TRUE; + switch (d->node_type ()) + { + case AST_Decl::NT_enum: + $$ = d; + found = I_TRUE; + break; + case AST_Decl::NT_pre_defined: + p = AST_PredefinedType::narrow_from_decl (d); + + if (p != 0) + { + switch (p->pt ()) + { + case AST_PredefinedType::PT_long: + case AST_PredefinedType::PT_ulong: + case AST_PredefinedType::PT_longlong: + case AST_PredefinedType::PT_ulonglong: + case AST_PredefinedType::PT_short: + case AST_PredefinedType::PT_ushort: + case AST_PredefinedType::PT_char: + case AST_PredefinedType::PT_boolean: + $$ = p; + found = I_TRUE; + break; + case AST_PredefinedType::PT_wchar: + case AST_PredefinedType::PT_octet: + /* octets and wchars are not allowed */ + idl_global->err ()->error0 ( + UTL_Error::EIDL_DISC_TYPE + ); + $$ = 0; + found = I_TRUE; + break; + default: + $$ = 0; + found = I_TRUE; + break; + } + } + else + { + $$ = 0; + found = I_TRUE; + } + + break; + case AST_Decl::NT_typedef: + t = AST_Typedef::narrow_from_decl (d); + + if (t != 0) + { + d = t->base_type (); + } + + break; + default: + $$ = 0; + found = I_TRUE; + break; + } } - break; - case AST_Decl::NT_typedef: - t = AST_Typedef::narrow_from_decl (d); - if (t != 0) d = t->base_type (); - break; - default: - $$ = 0; - found = I_TRUE; - break; - } + } + else + { + $$ = 0; } - } else - $$ = 0; if ($$ == 0) - idl_global->err ()->lookup_error ($1); + { + idl_global->err ()->lookup_error ($1); + } } ; @@ -1833,37 +2396,48 @@ case_branches case_branch : at_least_one_case_label { +// case_branch : at_least_one_case_label idl_global->set_parse_state (IDL_GlobalData::PS_UnionLabelSeen); } element_spec { +// element_spec idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemSeen); } ';' { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// ';' + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_UnionBranch *b = 0; AST_Field *f = $3; idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemCompleted); + /* * Create several nodes representing branches of a union. * Add them to the enclosing scope (the union scope) */ - if (s != 0 && $1 != 0 && $3 != 0) { - b = idl_global->gen ()->create_union_branch ($1, - f->field_type (), - f->name ()); + if (s != 0 + && $1 != 0 + && $3 != 0) + { + b = + idl_global->gen ()->create_union_branch ( + $1, + f->field_type (), + f->name () + ); (void) s->fe_add_union_branch (b); - } + } } | error { +// | error idl_global->err()->syntax_error (idl_global->parse_state()); } ';' - { +// ';' idl_global->set_parse_state (IDL_GlobalData::PS_NoState); yyerrok; } @@ -1872,6 +2446,7 @@ case_branch : at_least_one_case_label : case_label case_labels { +// at_least_one_case_label : case_label case_labels $$ = new UTL_LabelList ($1, $2); } ; @@ -1879,15 +2454,28 @@ at_least_one_case_label : case_labels : case_labels case_label { +// case_labels : case_labels case_label if ($1 == 0) - $$ = new UTL_LabelList ($2, 0); - else { - $1->nconc(new UTL_LabelList ($2, 0)); - $$ = $1; - } + { + ACE_NEW_RETURN ($$, + UTL_LabelList ($2, + 0), + 1); + } + else + { + UTL_LabelList *ll = 0; + ACE_NEW_RETURN (ll, + UTL_LabelList ($2, + 0), + 1); + $1->nconc (ll); + $$ = $1; + } } | /* EMPTY */ { +// | /* EMPTY */ $$ = 0; } ; @@ -1895,10 +2483,12 @@ case_labels case_label : IDL_DEFAULT { +// case_label : IDL_DEFAULT idl_global->set_parse_state (IDL_GlobalData::PS_DefaultSeen); } ':' { +// ':' idl_global->set_parse_state (IDL_GlobalData::PS_LabelColonSeen); $$ = idl_global->gen ()->create_union_label ( @@ -1908,6 +2498,7 @@ case_label } | IDL_CASE { +// | IDL_CASE idl_global->set_parse_state (IDL_GlobalData::PS_CaseSeen); } const_expr @@ -1916,6 +2507,7 @@ case_label } ':' { +// const_expr idl_global->set_parse_state (IDL_GlobalData::PS_LabelColonSeen); $$ = idl_global->gen()->create_union_label ( @@ -1928,50 +2520,71 @@ case_label element_spec : type_spec { +// element_spec : type_spec idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemTypeSeen); } declarator { +// declarator idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemDeclSeen); + /* * Check for illegal recursive use of type */ - if ($1 != 0 && AST_illegal_recursive_type ($1)) - idl_global->err()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE, $1); + if ($1 != 0 + && AST_illegal_recursive_type ($1)) + { + idl_global->err()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE, + $1); + } /* * Create a field in a union branch */ else if ($1 == 0 || $3 == 0) - $$ = 0; - else { - AST_Type *tp = $3->compose ($1); - if (tp == 0) + { $$ = 0; - else - $$ = idl_global->gen ()->create_field (tp, - $3->name()); - } + } + else + { + AST_Type *tp = $3->compose ($1); + + if (tp == 0) + { + $$ = 0; + } + else + { + $$ = idl_global->gen ()->create_field ( + tp, + $3->name () + ); + } + } } ; enum_type : IDL_ENUM { +// enum_type : IDL_ENUM idl_global->set_parse_state (IDL_GlobalData::PS_EnumSeen); } id { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName($3, 0); +// id + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n ($3, + 0); AST_Enum *e = 0; idl_global->set_parse_state (IDL_GlobalData::PS_EnumIDSeen); + /* * Create a node representing an enum and add it to its * enclosing scope */ if (s != 0) { - e = idl_global->gen ()->create_enum (n, + e = idl_global->gen ()->create_enum (&n, s->is_local (), s->is_abstract ()); /* @@ -1982,30 +2595,36 @@ enum_type : /* * Push the enum scope on the scopes stack */ - idl_global->scopes ()->push (e); + idl_global->scopes ().push (e); } '{' { +// '{' idl_global->set_parse_state (IDL_GlobalData::PS_EnumSqSeen); } at_least_one_enumerator { +// at_least_one_enumerator idl_global->set_parse_state (IDL_GlobalData::PS_EnumBodySeen); } '}' { +// '}' idl_global->set_parse_state (IDL_GlobalData::PS_EnumQsSeen); /* * Done with this enum. Pop its scope from the scopes stack */ - if (idl_global->scopes ()->top () == 0) - $$ = 0; - else { - $$ = AST_Enum::narrow_from_scope ( - idl_global->scopes ()->top_non_null () - ); - idl_global->scopes ()->pop (); - } + if (idl_global->scopes ().top () == 0) + { + $$ = 0; + } + else + { + $$ = AST_Enum::narrow_from_scope ( + idl_global->scopes ().top_non_null () + ); + idl_global->scopes ().pop (); + } } ; @@ -2015,6 +2634,7 @@ enumerators : enumerators ',' { +// enumerators : enumerators ',' idl_global->set_parse_state (IDL_GlobalData::PS_EnumCommaSeen); } enumerator @@ -2024,9 +2644,11 @@ enumerators enumerator : IDENTIFIER { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = - new UTL_ScopedName (new Identifier ($1), 0); +// enumerator : IDENTIFIER + UTL_Scope *s = idl_global->scopes ().top_non_null (); + Identifier id ($1); + UTL_ScopedName n (&id, + 0); AST_EnumVal *e = 0; AST_Enum *c = 0; @@ -2034,13 +2656,21 @@ enumerator : * Create a node representing one enumerator in an enum * Add it to the enclosing scope (the enum scope) */ - if (s != 0 && s->scope_node_type () == AST_Decl::NT_enum) { - c = AST_Enum::narrow_from_scope (s); - if (c != 0) - e = idl_global->gen ()->create_enum_val (c->next_enum_val (), - n); - (void) s->fe_add_enum_val (e); - } + if (s != 0 + && s->scope_node_type () == AST_Decl::NT_enum) + { + c = AST_Enum::narrow_from_scope (s); + + if (c != 0) + { + e = idl_global->gen ()->create_enum_val ( + c->next_enum_val (), + &n + ); + } + + (void) s->fe_add_enum_val (e); + } } ; @@ -2048,88 +2678,125 @@ sequence_type_spec : seq_head ',' { +// sequence_type_spec : seq_head ',' idl_global->set_parse_state (IDL_GlobalData::PS_SequenceCommaSeen); } positive_int_expr { +// positive_int_expr idl_global->set_parse_state (IDL_GlobalData::PS_SequenceExprSeen); } '>' { +// '>' idl_global->set_parse_state (IDL_GlobalData::PS_SequenceQsSeen); + /* - * Remove sequence marker from scopes stack + * Remove sequence marker from scopes stack. */ - if (idl_global->scopes ()->top() == 0) - idl_global->scopes ()->pop (); - UTL_Scope *s = idl_global->scopes ()->top_non_null (); + if (idl_global->scopes ().top() == 0) + { + idl_global->scopes ().pop (); + } + + UTL_Scope *s = idl_global->scopes ().top_non_null (); + /* * Create a node representing a sequence */ - if ($4 == 0 || $4->coerce(AST_Expression::EV_ulong) == 0) { - idl_global->err ()->coercion_error ($4, AST_Expression::EV_ulong); - $$ = 0; - } else if ($1 == 0) { - $$ = 0; - } else { - AST_Type *tp = AST_Type::narrow_from_decl ($1); - if (tp == 0) - ; // Error will be caught in FE_Declarator. - else { - $$ = idl_global->gen ()->create_sequence ($4, - tp, - s->is_local (), - s->is_abstract ()); + if ($4 == 0 || $4->coerce (AST_Expression::EV_ulong) == 0) + { + idl_global->err ()->coercion_error ($4, + AST_Expression::EV_ulong); + $$ = 0; + } + else if ($1 == 0) + { + $$ = 0; + } + else + { + AST_Type *tp = AST_Type::narrow_from_decl ($1); + + if (tp == 0) + { + ; // Error will be caught in FE_Declarator. + } + else + { + $$ = + idl_global->gen ()->create_sequence ( + $4, + tp, + s->is_local (), + s->is_abstract () + ); + } } - } } | seq_head '>' { +// | seq_head '>' idl_global->set_parse_state (IDL_GlobalData::PS_SequenceQsSeen); + /* - * Remove sequence marker from scopes stack + * Remove sequence marker from scopes stack. */ - if (idl_global->scopes ()->top () == 0) - idl_global->scopes ()->pop (); - UTL_Scope *s = idl_global->scopes ()->top_non_null (); + if (idl_global->scopes ().top () == 0) + { + idl_global->scopes ().pop (); + } + + UTL_Scope *s = idl_global->scopes ().top_non_null (); + /* * Create a node representing a sequence */ if ($1 == 0) - $$ = 0; - else { - AST_Type *tp = AST_Type::narrow_from_decl ($1); - if (tp == 0) - ; // Error will be caught in FE_Declarator. - else { - $$ = - idl_global->gen ()->create_sequence ( - idl_global->gen ()->create_expr ((unsigned long) 0), - tp, - s->is_local (), - s->is_abstract () - ); + { + $$ = 0; + } + else + { + AST_Type *tp = AST_Type::narrow_from_decl ($1); + + if (tp == 0) + { + ; // Error will be caught in FE_Declarator. + } + else + { + $$ = + idl_global->gen ()->create_sequence ( + idl_global->gen ()->create_expr ((unsigned long) 0), + tp, + s->is_local (), + s->is_abstract () + ); + } } - } } ; -seq_head: +seq_head : IDL_SEQUENCE { +// seq_head : IDL_SEQUENCE idl_global->set_parse_state (IDL_GlobalData::PS_SequenceSeen); /* * Push a sequence marker on scopes stack */ - idl_global->scopes ()->push (0); + idl_global->scopes ().push (0); } '<' { +// '<' idl_global->set_parse_state (IDL_GlobalData::PS_SequenceSqSeen); } simple_type_spec { +// simple_type_spec idl_global->set_parse_state (IDL_GlobalData::PS_SequenceTypeSeen); $$ = $5; } @@ -2139,53 +2806,68 @@ string_type_spec : string_head '<' { +// string_type_spec : string_head '<' idl_global->set_parse_state (IDL_GlobalData::PS_StringSqSeen); } positive_int_expr { +// positive_int_expr idl_global->set_parse_state (IDL_GlobalData::PS_StringExprSeen); } '>' { +// '>' idl_global->set_parse_state (IDL_GlobalData::PS_StringQsSeen); + /* - * Create a node representing a string + * Create a node representing a string. */ - if ($4 == 0 || $4->coerce (AST_Expression::EV_ulong) == 0) { - idl_global->err ()->coercion_error ($4, AST_Expression::EV_ulong); - $$ = 0; - } else { - $$ = idl_global->gen ()->create_string ($4); - /* - * Add this AST_String to the types defined in the global scope - */ - (void) idl_global->root ()->fe_add_string ( - AST_String::narrow_from_decl ($$) - ); - } + if ($4 == 0 + || $4->coerce (AST_Expression::EV_ulong) == 0) + { + idl_global->err ()->coercion_error ($4, + AST_Expression::EV_ulong); + $$ = 0; + } + else + { + $$ = idl_global->gen ()->create_string ($4); + /* + * Add this AST_String to the types defined in the global scope. + */ + (void) idl_global->root ()->fe_add_string ( + AST_String::narrow_from_decl ( + $$ + ) + ); + } } | string_head { +// | string_head idl_global->set_parse_state (IDL_GlobalData::PS_StringCompleted); /* - * Create a node representing a string + * Create a node representing a string. */ $$ = idl_global->gen ()->create_string ( idl_global->gen ()->create_expr ((unsigned long) 0) ); /* - * Add this AST_String to the types defined in the global scope + * Add this AST_String to the types defined in the global scope. */ (void) idl_global->root ()->fe_add_string ( - AST_String::narrow_from_decl ($$) + AST_String::narrow_from_decl ( + $$ + ) ); } ; -string_head: +string_head : IDL_STRING { +// string_head : IDL_STRING idl_global->set_parse_state (IDL_GlobalData::PS_StringSeen); } ; @@ -2194,36 +2876,46 @@ wstring_type_spec : wstring_head '<' { +// wstring_type_spec : wstring_head '<' idl_global->set_parse_state (IDL_GlobalData::PS_StringSqSeen); } positive_int_expr { +// positive_int_expr idl_global->set_parse_state (IDL_GlobalData::PS_StringExprSeen); } '>' { +// '>' idl_global->set_parse_state (IDL_GlobalData::PS_StringQsSeen); + /* - * Create a node representing a string + * Create a node representing a string. */ - if ($4 == 0 || $4->coerce(AST_Expression::EV_ulong) == 0) { - idl_global->err ()->coercion_error ($4, AST_Expression::EV_ulong); - $$ = 0; - } else { - $$ = idl_global->gen ()->create_wstring ($4); - /* - * Add this AST_String to the types defined in the global scope - */ - (void) idl_global->root ()->fe_add_string ( - AST_String::narrow_from_decl ($$) - ); - } + if ($4 == 0 + || $4->coerce (AST_Expression::EV_ulong) == 0) + { + idl_global->err ()->coercion_error ($4, + AST_Expression::EV_ulong); + $$ = 0; + } + else + { + $$ = idl_global->gen ()->create_wstring ($4); + /* + * Add this AST_String to the types defined in the global scope + */ + (void) idl_global->root ()->fe_add_string ( + AST_String::narrow_from_decl ($$) + ); + } } | wstring_head { +// | wstring_head idl_global->set_parse_state (IDL_GlobalData::PS_StringCompleted); /* - * Create a node representing a string + * Create a node representing a wstring. */ $$ = idl_global->gen ()->create_wstring ( @@ -2238,9 +2930,10 @@ wstring_type_spec } ; -wstring_head: +wstring_head : IDL_WSTRING { +// wstring_head : IDL_WSTRING idl_global->set_parse_state (IDL_GlobalData::PS_StringSeen); } ; @@ -2248,44 +2941,69 @@ wstring_head: array_declarator : id { +// array_declarator : id idl_global->set_parse_state (IDL_GlobalData::PS_ArrayIDSeen); } at_least_one_array_dim { +// at_least_one_array_dim idl_global->set_parse_state (IDL_GlobalData::PS_ArrayCompleted); + /* - * Create a node representing an array + * Create a node representing an array. */ - if ($3 != 0) { - $$ = idl_global->gen ()->create_array (new UTL_ScopedName ($1, - 0), - $3->length (), - $3, - 0, - 0); - } + if ($3 != 0) + { + UTL_ScopedName sn ($1, + 0); + $$ = + idl_global->gen ()->create_array ( + &sn, + $3->length (), + $3, + 0, + 0 + ); + } } ; at_least_one_array_dim : array_dim array_dims { - $$ = new UTL_ExprList ($1, $2); +// at_least_one_array_dim : array_dim array_dims + ACE_NEW_RETURN ($$, + UTL_ExprList ($1, + $2), + 1); } ; array_dims : array_dims array_dim { +// array_dims : array_dims array_dim if ($1 == 0) - $$ = new UTL_ExprList ($2, 0); - else { - $1->nconc (new UTL_ExprList ($2, 0)); - $$ = $1; - } + { + ACE_NEW_RETURN ($$, + UTL_ExprList ($2, + 0), + 1); + } + else + { + UTL_ExprList *el = 0; + ACE_NEW_RETURN (el, + UTL_ExprList ($2, + 0), + 1); + $1->nconc (el); + $$ = $1; + } } | /* EMPTY */ { +// | /* EMPTY */ $$ = 0; } ; @@ -2293,78 +3011,111 @@ array_dims array_dim : '[' { +// array_dim : '[' idl_global->set_parse_state (IDL_GlobalData::PS_DimSqSeen); } positive_int_expr { +// positive_int_expr idl_global->set_parse_state (IDL_GlobalData::PS_DimExprSeen); } ']' { +// ']' idl_global->set_parse_state (IDL_GlobalData::PS_DimQsSeen); + /* * Array dimensions are expressions which must be coerced to - * positive integers + * positive integers. */ - if ($3 == 0 || $3->coerce (AST_Expression::EV_ulong) == 0) { - idl_global->err ()->coercion_error ($3, AST_Expression::EV_ulong); - $$ = 0; - } else - $$ = $3; + if ($3 == 0 + || $3->coerce (AST_Expression::EV_ulong) == 0) + { + idl_global->err ()->coercion_error ($3, + AST_Expression::EV_ulong); + $$ = 0; + } + else + { + $$ = $3; + } } ; -attribute: +attribute : opt_readonly IDL_ATTRIBUTE { +// attribute : opt_readonly IDL_ATTRIBUTE idl_global->set_parse_state (IDL_GlobalData::PS_AttrSeen); } param_type_spec { +// param_type_spec idl_global->set_parse_state (IDL_GlobalData::PS_AttrTypeSeen); } at_least_one_simple_declarator { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// at_least_one_simple_declarator + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Attribute *a = 0; FE_Declarator *d = 0; idl_global->set_parse_state (IDL_GlobalData::PS_AttrCompleted); + /* * Create nodes representing attributes and add them to the - * enclosing scope + * enclosing scope. */ - if (s != 0 && $4 != 0 && $6 != 0) { - for (UTL_DecllistActiveIterator l ($6); !l.is_done (); l.next ()) { - d = l.item (); - if (d == 0) - continue; - AST_Type *tp = d->compose ($4); - if (tp == 0) - continue; - a = idl_global->gen ()->create_attribute ($1, - tp, - (UTL_IdList *) d->name()->copy (), - s->is_local (), - s->is_abstract ()); - /* - * Add one attribute to the enclosing scope - */ - (void) s->fe_add_attribute (a); + if (s != 0 + && $4 != 0 + && $6 != 0) + { + for (UTL_DecllistActiveIterator l ($6); + !l.is_done (); + l.next ()) + { + d = l.item (); + + if (d == 0) + { + continue; + } + + AST_Type *tp = d->compose ($4); + + if (tp == 0) + { + continue; + } + + a = + idl_global->gen ()->create_attribute ( + $1, + tp, + (UTL_IdList *) d->name ()->copy (), + s->is_local (), + s->is_abstract () + ); + /* + * Add one attribute to the enclosing scope. + */ + (void) s->fe_add_attribute (a); + } } - } } ; opt_readonly : IDL_READONLY { +// opt_readonly : IDL_READONLY idl_global->set_parse_state (IDL_GlobalData::PS_AttrROSeen); $$ = I_TRUE; } | /* EMPTY */ { +// | /* EMPTY */ $$ = I_FALSE; } ; @@ -2372,45 +3123,54 @@ opt_readonly exception : IDL_EXCEPTION { +// exception : IDL_EXCEPTION idl_global->set_parse_state (IDL_GlobalData::PS_ExceptSeen); } id { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName ($3, 0); +// id + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n ($3, + 0); AST_Exception *e = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ExceptIDSeen); + /* * Create a node representing an exception and add it to - * the enclosing scope + * the enclosing scope. */ - if (s != 0) { - e = idl_global->gen ()->create_exception (n, - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_exception (e); - } + if (s != 0) + { + e = idl_global->gen ()->create_exception (&n, + s->is_local (), + s->is_abstract ()); + (void) s->fe_add_exception (e); + } + /* - * Push the exception scope on the scope stack + * Push the exception scope on the scope stack. */ - idl_global->scopes()->push (e); + idl_global->scopes ().push (e); } '{' { +// '{' idl_global->set_parse_state (IDL_GlobalData::PS_ExceptSqSeen); } members { +// members idl_global->set_parse_state (IDL_GlobalData::PS_ExceptBodySeen); } '}' { +// '}' idl_global->set_parse_state (IDL_GlobalData::PS_ExceptQsSeen); /* - * Done with this exception. Pop its scope from the scope stack + * Done with this exception. Pop its scope from the scope stack. */ - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } ; @@ -2418,85 +3178,114 @@ operation : opt_op_attribute op_type_spec { +// operation : opt_op_attribute op_type_spec idl_global->set_parse_state (IDL_GlobalData::PS_OpTypeSeen); } IDENTIFIER { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = - new UTL_ScopedName (new Identifier ($4), 0); +// IDENTIFIER + UTL_Scope *s = idl_global->scopes ().top_non_null (); + Identifier id ($4); + UTL_ScopedName n (&id, 0); AST_Operation *o = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen); + /* * Create a node representing an operation on an interface * and add it to its enclosing scope */ - if (s != 0 && $2 != 0) { - AST_Type *tp = AST_Type::narrow_from_decl ($2); - if (tp == 0) { - idl_global->err ()->not_a_type ($2); - } else if (tp->node_type () == AST_Decl::NT_except) { - idl_global->err ()->not_a_type ($2); - } else { - o = idl_global->gen ()->create_operation (tp, - $1, - n, - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_operation (o); + if (s != 0 && $2 != 0) + { + AST_Type *tp = AST_Type::narrow_from_decl ($2); + + if (tp == 0) + { + idl_global->err ()->not_a_type ($2); + } + else if (tp->node_type () == AST_Decl::NT_except) + { + idl_global->err ()->not_a_type ($2); + } + else + { + o = + idl_global->gen ()->create_operation (tp, + $1, + &n, + s->is_local (), + s->is_abstract ()); + (void) s->fe_add_operation (o); + } } - } + + ACE_OS::free ($4); + $4 = 0; + /* * Push the operation scope onto the scopes stack */ - idl_global->scopes()->push (o); + idl_global->scopes ().push (o); } parameter_list { +// parameter_list idl_global->set_parse_state (IDL_GlobalData::PS_OpParsCompleted); } opt_raises { +// opt_raises idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted); } opt_context { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// opt_context + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Operation *o = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpCompleted); + /* - * Add exceptions and context to the operation + * Add exceptions and context to the operation. */ - if (s != 0 && s->scope_node_type() == AST_Decl::NT_op) { + if (s != 0 && s->scope_node_type () == AST_Decl::NT_op) + { o = AST_Operation::narrow_from_scope (s); if ($8 != 0 && o != 0) - (void) o->fe_add_exceptions ($8); + { + (void) o->fe_add_exceptions ($8); + } + if ($10 != 0) - (void) o->fe_add_context ($10); - } + { + (void) o->fe_add_context ($10); + } + } + /* - * Done with this operation. Pop its scope from the scopes stack + * Done with this operation. Pop its scope from the scopes stack. */ - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } ; opt_op_attribute : IDL_ONEWAY { +// opt_op_attribute : IDL_ONEWAY idl_global->set_parse_state (IDL_GlobalData::PS_OpAttrSeen); $$ = AST_Operation::OP_oneway; } | IDL_IDEMPOTENT { +// | IDL_IDEMPOTENT idl_global->set_parse_state (IDL_GlobalData::PS_OpAttrSeen); $$ = AST_Operation::OP_idempotent; } | /* EMPTY */ { +// | /* EMPTY */ $$ = AST_Operation::OP_noflags; } ; @@ -2505,8 +3294,9 @@ op_type_spec : param_type_spec | IDL_VOID { +// op_type_spec : param_type_spec | IDL_VOID $$ = - idl_global->scopes ()->bottom ()->lookup_primitive_type ( + idl_global->scopes ().bottom ()->lookup_primitive_type ( AST_Expression::EV_void ); } @@ -2515,25 +3305,29 @@ op_type_spec init_decl : IDL_FACTORY { +// init_decl : IDL_FACTORY //@@ PS_FactorySeen? idl_global->set_parse_state (IDL_GlobalData::PS_OpTypeSeen); } IDENTIFIER { +// IDENTIFIER + UTL_Scope *s = idl_global->scopes ().top_non_null (); - UTL_Scope *s = idl_global->scopes ()->top_non_null (); if (s->is_abstract ()) - { - //@@ Fire error - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("error in %s line %d:\n") - ACE_TEXT ("Abstract valuetype can't have a ") - ACE_TEXT ("factory construct.\n"), - idl_global->filename ()->get_string (), - idl_global->lineno ())); - } - UTL_ScopedName *n = - new UTL_ScopedName (new Identifier ($3), 0); + { + //@@ Fire error + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("error in %s line %d:\n") + ACE_TEXT ("Abstract valuetype can't have a ") + ACE_TEXT ("factory construct.\n"), + idl_global->filename ()->get_string (), + idl_global->lineno ())); + } + + Identifier id ($3); + UTL_ScopedName n (&id, + 0); AST_Factory *factory = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen); @@ -2543,40 +3337,46 @@ init_decl * and add it to its enclosing scope */ if (s != 0) - { - factory = idl_global->gen ()->create_factory (n); - (void) s->fe_add_factory (factory); - } + { + factory = idl_global->gen ()->create_factory (&n); + (void) s->fe_add_factory (factory); + } + /* - * Push the operation scope onto the scopes stack + * Push the operation scope onto the scopes stack. */ - idl_global->scopes ()->push (factory); + idl_global->scopes ().push (factory); } init_parameter_list { - // TODO: replace parameter_list with rule that accepts only IN args +// init_parameter_list + /* TODO: replace parameter_list with rule that accepts only IN args */ idl_global->set_parse_state (IDL_GlobalData::PS_OpParsCompleted); - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } ; init_parameter_list : '(' { +// init_parameter_list : '(' idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen); } ')' { +// ')' idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen); } | '(' { +// | '(' idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen); } at_least_one_in_parameter ')' { +// at_least_one_in_parameter ')' idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen); } ; @@ -2587,6 +3387,7 @@ in_parameters : in_parameters ',' { +// in_parameters : in_parameters ',' idl_global->set_parse_state (IDL_GlobalData::PS_OpParCommaSeen); } in_parameter @@ -2596,56 +3397,66 @@ in_parameters in_parameter : IDL_IN { +// in_parameter : IDL_IN idl_global->set_parse_state (IDL_GlobalData::PS_OpParDirSeen); } param_type_spec { +// param_type_spec idl_global->set_parse_state (IDL_GlobalData::PS_OpParTypeSeen); } declarator { - - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// declarator + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Argument *a = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpParDeclSeen); + /* * Create a node representing an argument to an operation - * Add it to the enclosing scope (the operation scope) + * Add it to the enclosing scope (the operation scope). */ - if ($3 != 0 && $5 != 0 && s != 0) - { - AST_Type *tp = $5->compose ($3); - if (tp != 0) + if ($3 != 0 + && $5 != 0 && + s != 0) { - a = idl_global->gen ()->create_argument ( - AST_Argument::dir_IN, - tp, - (UTL_IdList *) $5->name ()->copy () - ); + AST_Type *tp = $5->compose ($3); - (void) s->fe_add_argument (a); + if (tp != 0) + { + a = idl_global->gen ()->create_argument ( + AST_Argument::dir_IN, + tp, + (UTL_IdList *) $5->name ()->copy () + ); + + (void) s->fe_add_argument (a); + } } - } } ; parameter_list : '(' { +// parameter_list : '(' idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen); } ')' { +// ')' idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen); } | '(' { +// | '(' idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen); } at_least_one_parameter ')' { +// at_least_one_parameter ')' idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen); } ; @@ -2656,6 +3467,7 @@ parameters : parameters ',' { +// parameters : parameters ',' idl_global->set_parse_state (IDL_GlobalData::PS_OpParCommaSeen); } parameter @@ -2665,65 +3477,85 @@ parameters parameter : direction { +// parameter : direction idl_global->set_parse_state (IDL_GlobalData::PS_OpParDirSeen); } param_type_spec { +// param_type_spec idl_global->set_parse_state (IDL_GlobalData::PS_OpParTypeSeen); } declarator { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// declarator + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Argument *a = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpParDeclSeen); + /* * Create a node representing an argument to an operation * Add it to the enclosing scope (the operation scope) */ - if ($3 != 0 && $5 != 0 && s != 0) { - AST_Type *tp = $5->compose ($3); - if (tp != 0) { - if (!s->is_local () && tp->is_local ()) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("error in %s line %d\n"), - idl_global->filename ()->get_string (), - idl_global->lineno ())); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Cannot use a local type as an ") - ACE_TEXT ("argument of a remote operation\n"))); - } - else + if ($3 != 0 + && $5 != 0 + && s != 0) + { + AST_Type *tp = $5->compose ($3); + + if (tp != 0) { - a = idl_global->gen ()->create_argument ( - $1, - tp, - (UTL_IdList *) $5->name ()->copy () - ); - (void) s->fe_add_argument (a); + if (!s->is_local () && tp->is_local ()) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("error in %s line %d\n"), + idl_global->filename ()->get_string (), + idl_global->lineno ())); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Cannot use a local type as an ") + ACE_TEXT ("argument of a remote operation\n"))); + } + else + { + a = idl_global->gen ()->create_argument ( + $1, + tp, + (UTL_IdList *) $5->name ()->copy () + ); + (void) s->fe_add_argument (a); + } } } - } } ; param_type_spec : base_type_spec { - $$ = idl_global->scopes ()->bottom ()->lookup_primitive_type ($1); +// param_type_spec : base_type_spec + $$ = idl_global->scopes ().bottom ()->lookup_primitive_type ($1); } | string_type_spec | wstring_type_spec | scoped_name { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +// | string_type_spec +// | wstring_type_spec +// | scoped_name + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = 0; if (s != 0) - d = s->lookup_by_name ($1, I_TRUE); + { + d = s->lookup_by_name ($1, + I_TRUE); + } + if (d == 0) - idl_global->err ()->lookup_error ($1); + { + idl_global->err ()->lookup_error ($1); + } + $$ = d; } ; @@ -2731,14 +3563,17 @@ param_type_spec direction : IDL_IN { +// direction : IDL_IN $$ = AST_Argument::dir_IN; } | IDL_OUT { +// | IDL_OUT $$ = AST_Argument::dir_OUT; } | IDL_INOUT { +// | IDL_INOUT $$ = AST_Argument::dir_INOUT; } ; @@ -2746,41 +3581,49 @@ direction opt_raises : IDL_RAISES { +// opt_raises : IDL_RAISES idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseSeen); } '(' { +// '(' idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseSqSeen); } at_least_one_scoped_name ')' { +// at_least_one_scoped_name ')' idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseQsSeen); $$ = $5; } | /* EMPTY */ { $$ = 0; +// | /* EMPTY */ } ; opt_context : IDL_CONTEXT { +// opt_context : IDL_CONTEXT idl_global->set_parse_state (IDL_GlobalData::PS_OpContextSeen); } '(' { idl_global->set_parse_state (IDL_GlobalData::PS_OpContextSqSeen); +// '(' } at_least_one_string_literal ')' { +// at_least_one_string_literal ')' idl_global->set_parse_state (IDL_GlobalData::PS_OpContextQsSeen); $$ = $5; } | /* EMPTY */ { +// | /* EMPTY */ $$ = 0; } ; @@ -2788,7 +3631,11 @@ opt_context at_least_one_string_literal : IDL_STRING_LITERAL string_literals { - $$ = new UTL_StrList ($1, $2); +// at_least_one_string_literal : IDL_STRING_LITERAL string_literals + ACE_NEW_RETURN ($$, + UTL_StrList ($1, + $2), + 1); } ; @@ -2796,23 +3643,79 @@ string_literals : string_literals ',' { +// string_literals : string_literals ',' idl_global->set_parse_state (IDL_GlobalData::PS_OpContextCommaSeen); } IDL_STRING_LITERAL { +// IDL_STRING_LITERAL if ($1 == 0) - $$ = new UTL_StrList ($4, 0); - else { - $1->nconc (new UTL_StrList ($4, 0)); - $$ = $1; - } + { + ACE_NEW_RETURN ($$, + UTL_StrList ($4, + 0), + 1); + } + else + { + UTL_StrList *sl = 0; + ACE_NEW_RETURN (sl, + UTL_StrList ($4, + 0), + 1); + $1->nconc (sl); + $$ = $1; + } } | /* EMPTY */ { +// | /* EMPTY */ $$ = 0; } ; +typeid_dcl + : IDL_TYPEID scoped_name IDL_STRING_LITERAL + { +// typeid_dcl : IDL_TYPEID scoped_name IDL_STRING_LITERAL + UTL_Scope *s = idl_global->scopes ().top_non_null (); + AST_Decl *d = s->lookup_by_name ($2, + I_TRUE); + + if (d == 0) + { + idl_global->err ()->lookup_error ($2); + } + else + { + d->set_id_with_typeid ( + $3->get_string () + ); + } + } + ; + +typeprefix_dcl + : IDL_TYPEPREFIX scoped_name IDL_STRING_LITERAL + { +// typeprefix_dcl : IDL_TYPEPREFIX scoped_name IDL_STRING_LITERAL + UTL_Scope *s = idl_global->scopes ().top_non_null (); + AST_Decl *d = s->lookup_by_name ($2, + I_TRUE); + + if (d == 0) + { + idl_global->err ()->lookup_error ($2); + } + else + { + d->set_prefix_with_typeprefix ( + $3->get_string () + ); + } + } + ; + %% /* programs */ diff --git a/TAO/TAO_IDL/fe/lex.yy.cpp b/TAO/TAO_IDL/fe/lex.yy.cpp index 5fbc23d512a..d6c3b11233f 100644 --- a/TAO/TAO_IDL/fe/lex.yy.cpp +++ b/TAO/TAO_IDL/fe/lex.yy.cpp @@ -28,15 +28,15 @@ /* The "const" storage-class-modifier is valid. */ #define TAO_YY_USE_CONST -#else /* ! __cplusplus */ +#else /* ! __cplusplus */ #if __STDC__ #define TAO_YY_USE_PROTOS #define TAO_YY_USE_CONST -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ #ifdef __TURBOC__ #pragma warn -rch @@ -105,10 +105,10 @@ extern FILE *tao_yyin, *tao_yyout; * int a single C statement (which needs a semi-colon terminator). This * avoids problems with code like: * - * if ( condition_holds ) - * tao_yyless( 5 ); - * else - * do_something_else(); + * if ( condition_holds ) + * tao_yyless( 5 ); + * else + * do_something_else(); * * Prior to using the do-while the compiler would get upset at the * "else" because it interpreted the "if" statement as being all @@ -118,15 +118,15 @@ extern FILE *tao_yyin, *tao_yyout; /* Return all but the first 'n' matched characters back to the input stream. */ #define tao_yyless(n) \ - do \ - { \ - /* Undo effects of setting up tao_yytext. */ \ - *tao_yy_cp = tao_yy_hold_char; \ - TAO_YY_RESTORE_TAO_YY_MORE_OFFSET \ - tao_yy_c_buf_p = tao_yy_cp = tao_yy_bp + n - TAO_YY_MORE_ADJ; \ - TAO_YY_DO_BEFORE_ACTION; /* set up tao_yytext again */ \ - } \ - while ( 0 ) + do \ + { \ + /* Undo effects of setting up tao_yytext. */ \ + *tao_yy_cp = tao_yy_hold_char; \ + TAO_YY_RESTORE_TAO_YY_MORE_OFFSET \ + tao_yy_c_buf_p = tao_yy_cp = tao_yy_bp + n - TAO_YY_MORE_ADJ; \ + TAO_YY_DO_BEFORE_ACTION; /* set up tao_yytext again */ \ + } \ + while ( 0 ) #define unput(c) tao_yyunput( c, tao_yytext_ptr ) @@ -138,61 +138,61 @@ typedef unsigned int tao_yy_size_t; struct tao_yy_buffer_state - { - FILE *tao_yy_input_file; - - char *tao_yy_ch_buf; /* input buffer */ - char *tao_yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - tao_yy_size_t tao_yy_buf_size; - - /* Number of characters read into tao_yy_ch_buf, not including EOB - * characters. - */ - int tao_yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int tao_yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int tao_yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int tao_yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int tao_yy_fill_buffer; - - int tao_yy_buffer_status; + { + FILE *tao_yy_input_file; + + char *tao_yy_ch_buf; /* input buffer */ + char *tao_yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + tao_yy_size_t tao_yy_buf_size; + + /* Number of characters read into tao_yy_ch_buf, not including EOB + * characters. + */ + int tao_yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int tao_yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int tao_yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int tao_yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int tao_yy_fill_buffer; + + int tao_yy_buffer_status; #define TAO_YY_BUFFER_NEW 0 #define TAO_YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as TAO_YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via tao_yyrestart()), so that the user can continue scanning by - * just pointing tao_yyin at a new input file. - */ + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as TAO_YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via tao_yyrestart()), so that the user can continue scanning by + * just pointing tao_yyin at a new input file. + */ #define TAO_YY_BUFFER_EOF_PENDING 2 - }; + }; static TAO_YY_BUFFER_STATE tao_yy_current_buffer = 0; @@ -206,15 +206,15 @@ static TAO_YY_BUFFER_STATE tao_yy_current_buffer = 0; /* tao_yy_hold_char holds the character lost when tao_yytext is formed. */ static char tao_yy_hold_char; -static int tao_yy_n_chars; /* number of characters read into tao_yy_ch_buf */ +static int tao_yy_n_chars; /* number of characters read into tao_yy_ch_buf */ int tao_yyleng; /* Points to current character in buffer. */ static char *tao_yy_c_buf_p = (char *) 0; -static int tao_yy_init = 1; /* whether we need to initialize */ -static int tao_yy_start = 0; /* start state number */ +static int tao_yy_init = 1; /* whether we need to initialize */ +static int tao_yy_start = 0; /* start state number */ /* Flag which is used to allow tao_yywrap()'s to do buffer switches * instead of setting up a fresh tao_yyin. A bit of a hack ... @@ -242,18 +242,18 @@ static void tao_yy_flex_free TAO_YY_PROTO(( void * )); #define tao_yy_new_buffer tao_yy_create_buffer #define tao_yy_set_interactive(is_interactive) \ - { \ - if ( ! tao_yy_current_buffer ) \ - tao_yy_current_buffer = tao_yy_create_buffer( tao_yyin, TAO_YY_BUF_SIZE ); \ - tao_yy_current_buffer->tao_yy_is_interactive = is_interactive; \ - } + { \ + if ( ! tao_yy_current_buffer ) \ + tao_yy_current_buffer = tao_yy_create_buffer( tao_yyin, TAO_YY_BUF_SIZE ); \ + tao_yy_current_buffer->tao_yy_is_interactive = is_interactive; \ + } #define tao_yy_set_bol(at_bol) \ - { \ - if ( ! tao_yy_current_buffer ) \ - tao_yy_current_buffer = tao_yy_create_buffer( tao_yyin, TAO_YY_BUF_SIZE ); \ - tao_yy_current_buffer->tao_yy_at_bol = at_bol; \ - } + { \ + if ( ! tao_yy_current_buffer ) \ + tao_yy_current_buffer = tao_yy_create_buffer( tao_yyin, TAO_YY_BUF_SIZE ); \ + tao_yy_current_buffer->tao_yy_at_bol = at_bol; \ + } #define TAO_YY_AT_BOL() (tao_yy_current_buffer->tao_yy_at_bol) @@ -272,68 +272,78 @@ static void tao_yy_fatal_error TAO_YY_PROTO(( tao_yyconst char msg[] )); * corresponding action - sets up tao_yytext. */ #define TAO_YY_DO_BEFORE_ACTION \ - tao_yytext_ptr = tao_yy_bp; \ - tao_yyleng = (int) (tao_yy_cp - tao_yy_bp); \ - tao_yy_hold_char = *tao_yy_cp; \ - *tao_yy_cp = '\0'; \ - if ( tao_yyleng >= TAO_YYLMAX ) \ - TAO_YY_FATAL_ERROR( "token too large, exceeds TAO_YYLMAX" ); \ - tao_yy_flex_strncpy( tao_yytext, tao_yytext_ptr, tao_yyleng + 1 ); \ - tao_yy_c_buf_p = tao_yy_cp; - -#define TAO_YY_NUM_RULES 86 -#define TAO_YY_END_OF_BUFFER 87 -static tao_yyconst short int tao_yy_accept[445] = + tao_yytext_ptr = tao_yy_bp; \ + tao_yyleng = (int) (tao_yy_cp - tao_yy_bp); \ + tao_yy_hold_char = *tao_yy_cp; \ + *tao_yy_cp = '\0'; \ + if ( tao_yyleng >= TAO_YYLMAX ) \ + TAO_YY_FATAL_ERROR( "token too large, exceeds TAO_YYLMAX" ); \ + tao_yy_flex_strncpy( tao_yytext, tao_yytext_ptr, tao_yyleng + 1 ); \ + tao_yy_c_buf_p = tao_yy_cp; + +#define TAO_YY_NUM_RULES 103 +#define TAO_YY_END_OF_BUFFER 104 +static tao_yyconst short int tao_yy_accept[538] = { 0, - 83, 83, 87, 85, 83, 84, 84, 85, 85, 85, - 85, 85, 58, 54, 85, 85, 85, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 85, - 84, 83, 0, 59, 0, 0, 0, 0, 57, 53, - 51, 82, 0, 51, 58, 0, 0, 0, 54, 49, - 47, 48, 50, 50, 0, 0, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 44, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - - 50, 50, 50, 50, 50, 0, 77, 0, 0, 0, - 0, 0, 0, 0, 0, 61, 0, 61, 0, 0, - 57, 0, 53, 0, 51, 0, 81, 81, 51, 0, - 52, 56, 50, 0, 60, 0, 0, 0, 50, 50, - 1, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 45, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 0, 0, 0, 0, 0, 0, 0, 64, 62, 0, - 0, 55, 0, 51, 52, 50, 0, 65, 0, 41, - - 50, 50, 50, 19, 26, 50, 50, 50, 50, 50, - 12, 50, 50, 50, 50, 50, 50, 50, 23, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 50, 50, 50, 50, 50, 50, 50, 50, 30, 50, - 50, 0, 0, 0, 0, 0, 0, 0, 78, 0, - 0, 0, 0, 0, 0, 62, 0, 63, 0, 42, - 0, 0, 50, 50, 50, 9, 50, 50, 50, 50, - 50, 50, 17, 21, 43, 50, 32, 50, 50, 29, - 50, 50, 50, 50, 50, 50, 24, 50, 50, 50, - 50, 50, 50, 16, 50, 50, 27, 50, 73, 0, - + 100, 100, 104, 102, 100, 101, 101, 102, 102, 102, + 102, 102, 75, 71, 102, 102, 102, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 102, 101, 100, 0, 76, 0, 0, 0, 0, + 74, 70, 68, 99, 0, 68, 75, 0, 0, 0, + 71, 66, 64, 65, 67, 67, 0, 0, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 61, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 0, 94, 0, 0, 0, + 0, 0, 0, 0, 0, 78, 0, 78, 0, 0, + 74, 0, 70, 0, 68, 0, 98, 98, 68, 0, + 69, 73, 67, 0, 77, 0, 0, 0, 67, 67, + 1, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 62, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + + 67, 67, 0, 0, 0, 0, 0, 0, 0, 81, + 79, 0, 0, 72, 0, 68, 69, 67, 0, 82, + 0, 58, 67, 67, 67, 19, 26, 67, 67, 67, + 67, 67, 67, 67, 12, 67, 67, 67, 67, 67, + 67, 67, 47, 67, 67, 67, 67, 23, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, + 67, 56, 67, 30, 67, 67, 0, 0, 0, 0, + 0, 0, 0, 95, 0, 0, 0, 0, 0, 0, + 79, 0, 80, 0, 59, 0, 0, 67, 67, 67, + + 67, 9, 67, 67, 67, 67, 67, 43, 67, 67, + 67, 67, 17, 21, 67, 67, 60, 67, 32, 67, + 67, 67, 67, 29, 67, 67, 67, 67, 67, 67, + 67, 67, 67, 24, 67, 67, 67, 67, 67, 67, + 67, 67, 16, 67, 67, 27, 67, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 66, 0, 50, 50, 50, 50, 34, 50, 22, - 50, 50, 50, 2, 31, 46, 50, 37, 3, 50, - 50, 13, 11, 50, 18, 50, 50, 50, 50, 50, - 0, 71, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 50, 50, 28, 7, - 20, 50, 35, 50, 36, 50, 50, 50, 50, 10, - 50, 50, 14, 0, 0, 69, 69, 0, 0, 75, - 0, 0, 74, 0, 0, 0, 0, 0, 0, 0, - 33, 50, 50, 50, 4, 15, 38, 50, 25, 50, - - 0, 79, 79, 0, 0, 0, 0, 72, 0, 0, - 0, 0, 0, 0, 0, 5, 6, 8, 50, 40, - 0, 67, 67, 0, 0, 70, 70, 0, 0, 0, - 0, 50, 0, 80, 80, 0, 0, 0, 39, 76, - 0, 68, 68, 0 + 83, 0, 67, 67, 67, 67, 67, 67, 34, 67, + 22, 67, 67, 67, 45, 67, 48, 67, 67, 2, + 67, 31, 63, 67, 67, 67, 37, 67, 3, 67, + 67, 67, 13, 11, 67, 18, 67, 67, 54, 67, + + 67, 67, 67, 0, 88, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, + 67, 28, 67, 67, 7, 20, 67, 67, 35, 67, + 67, 57, 67, 67, 36, 67, 67, 67, 67, 67, + 67, 67, 10, 67, 67, 67, 14, 0, 0, 86, + 86, 0, 0, 92, 0, 0, 91, 0, 0, 0, + 0, 0, 0, 0, 33, 67, 67, 42, 67, 67, + 67, 67, 49, 67, 51, 67, 4, 15, 67, 38, + 67, 67, 25, 67, 0, 96, 96, 0, 0, 0, + 0, 89, 0, 0, 0, 0, 0, 0, 0, 5, + + 41, 44, 6, 46, 8, 67, 52, 53, 67, 67, + 40, 0, 84, 84, 0, 0, 87, 87, 0, 0, + 0, 0, 50, 67, 55, 0, 97, 97, 0, 0, + 0, 39, 93, 0, 85, 85, 0 } ; static tao_yyconst int tao_yy_ec[256] = @@ -349,9 +359,9 @@ static tao_yyconst int tao_yy_ec[256] = 26, 28, 29, 30, 31, 26, 26, 32, 26, 26, 1, 33, 1, 1, 26, 1, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 26, 26, 43, 44, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 26, 1, 1, 1, 1, 1, 1, 1, 1, + 38, 39, 40, 41, 42, 26, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 26, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -368,348 +378,390 @@ static tao_yyconst int tao_yy_ec[256] = 1, 1, 1, 1, 1 } ; -static tao_yyconst int tao_yy_meta[57] = +static tao_yyconst int tao_yy_meta[58] = { 0, 1, 1, 2, 1, 1, 3, 1, 4, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1, 1, 1, 3, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 3, 7, 7, 5, 5, 5, 7, 6, - 6, 6, 6, 6, 8, 6, 6, 6, 8, 6, - 8, 6, 8, 6, 8, 6 + 6, 6, 6, 6, 6, 8, 6, 6, 6, 8, + 6, 8, 6, 8, 6, 8, 6 } ; -static tao_yyconst short int tao_yy_base[472] = +static tao_yyconst short int tao_yy_base[565] = { 0, - 0, 50, 922, 923, 56, 923, 923, 53, 888, 48, - 51, 59, 61, 66, 903, 901, 898, 0, 895, 81, - 888, 49, 869, 57, 50, 24, 63, 869, 867, 866, - 877, 56, 58, 36, 73, 46, 865, 83, 76, 128, - 888, 113, 107, 923, 0, 900, 131, 105, 136, 141, - 178, 923, 133, 162, 173, 184, 199, 0, 211, 923, - 923, 923, 0, 880, 128, 873, 874, 854, 847, 851, - 855, 850, 865, 853, 847, 857, 843, 842, 857, 856, - 836, 844, 77, 102, 852, 837, 836, 848, 834, 842, - 848, 840, 847, 832, 833, 829, 830, 834, 823, 827, - - 116, 830, 830, 830, 819, 826, 923, 116, 215, 826, - 830, 824, 816, 845, 129, 923, 855, 854, 224, 853, - 228, 0, 239, 246, 923, 169, 923, 180, 0, 166, - 253, 0, 831, 200, 923, 807, 850, 196, 833, 805, - 0, 806, 811, 815, 803, 195, 800, 816, 814, 804, - 809, 795, 807, 810, 791, 804, 807, 800, 787, 796, - 799, 782, 0, 782, 791, 783, 795, 779, 781, 182, - 782, 777, 782, 788, 779, 782, 771, 785, 787, 771, - 813, 812, 774, 778, 770, 780, 295, 923, 923, 250, - 805, 0, 256, 279, 923, 788, 0, 923, 0, 0, - - 762, 768, 771, 0, 0, 757, 769, 760, 753, 761, - 0, 756, 756, 764, 749, 748, 749, 754, 0, 753, - 742, 743, 759, 758, 749, 752, 743, 750, 736, 741, - 749, 738, 747, 746, 744, 735, 739, 740, 0, 728, - 734, 769, 270, 736, 728, 734, 731, 727, 923, 241, - 298, 727, 731, 725, 717, 923, 757, 923, 756, 0, - 337, 755, 728, 726, 726, 0, 704, 714, 714, 718, - 704, 705, 0, 0, 0, 714, 0, 657, 645, 0, - 615, 616, 628, 611, 604, 601, 0, 597, 575, 561, - 565, 571, 554, 0, 536, 528, 0, 533, 923, 325, - - 274, 525, 342, 531, 568, 567, 529, 533, 525, 535, - 363, 923, 560, 530, 505, 510, 502, 0, 500, 0, - 490, 473, 485, 0, 0, 0, 473, 0, 0, 467, - 468, 0, 0, 442, 0, 429, 417, 416, 397, 404, - 389, 923, 404, 284, 280, 412, 427, 390, 410, 328, - 377, 366, 352, 349, 435, 376, 331, 329, 0, 0, - 0, 323, 0, 332, 0, 311, 317, 304, 316, 0, - 311, 298, 0, 431, 286, 923, 360, 362, 434, 923, - 330, 281, 923, 461, 315, 284, 476, 281, 275, 307, - 0, 221, 205, 203, 0, 0, 0, 202, 0, 190, - - 392, 923, 458, 206, 464, 480, 484, 923, 492, 499, - 319, 507, 512, 407, 173, 0, 0, 0, 152, 0, - 512, 923, 521, 531, 527, 923, 533, 535, 163, 158, - 321, 103, 537, 923, 540, 77, 546, 556, 0, 923, - 559, 923, 561, 923, 582, 590, 594, 600, 608, 616, - 620, 627, 635, 640, 643, 650, 655, 658, 661, 665, - 672, 677, 684, 689, 696, 704, 712, 720, 728, 736, - 744 + 0, 51, 1014, 1015, 57, 1015, 1015, 54, 980, 49, + 52, 60, 62, 67, 995, 993, 990, 0, 987, 82, + 980, 49, 960, 51, 33, 57, 55, 968, 958, 61, + 957, 62, 969, 74, 64, 74, 78, 71, 24, 88, + 87, 137, 981, 124, 126, 1015, 0, 993, 135, 130, + 148, 154, 191, 1015, 133, 141, 159, 184, 179, 0, + 209, 1015, 1015, 1015, 0, 973, 128, 966, 967, 946, + 939, 943, 947, 942, 958, 79, 940, 951, 936, 946, + 934, 948, 949, 948, 131, 936, 930, 936, 932, 162, + 165, 933, 941, 933, 924, 923, 936, 921, 170, 937, + + 929, 936, 161, 922, 918, 919, 924, 912, 916, 177, + 925, 918, 919, 919, 907, 914, 1015, 159, 234, 915, + 919, 913, 904, 934, 220, 1015, 944, 943, 226, 942, + 230, 0, 245, 256, 1015, 259, 1015, 261, 0, 259, + 262, 0, 920, 225, 1015, 895, 939, 174, 922, 893, + 0, 894, 899, 904, 891, 892, 96, 887, 904, 902, + 884, 890, 888, 895, 880, 894, 892, 895, 878, 889, + 879, 872, 886, 889, 882, 887, 867, 867, 876, 879, + 861, 0, 198, 861, 870, 862, 875, 858, 860, 859, + 237, 860, 855, 860, 867, 857, 861, 851, 848, 863, + + 865, 848, 891, 890, 851, 856, 847, 858, 305, 1015, + 1015, 277, 883, 0, 279, 288, 1015, 866, 0, 1015, + 0, 0, 839, 846, 849, 0, 0, 839, 244, 847, + 837, 830, 838, 830, 0, 828, 831, 831, 839, 839, + 823, 840, 0, 823, 820, 821, 826, 0, 829, 824, + 825, 812, 813, 830, 829, 828, 819, 818, 821, 811, + 819, 822, 803, 808, 817, 805, 815, 814, 263, 803, + 808, 0, 809, 0, 796, 803, 838, 313, 805, 796, + 803, 800, 795, 1015, 278, 325, 796, 800, 794, 785, + 1015, 826, 1015, 825, 0, 348, 824, 797, 795, 795, + + 782, 0, 782, 770, 780, 780, 785, 0, 770, 769, + 770, 769, 0, 0, 776, 765, 0, 777, 0, 777, + 776, 765, 774, 0, 754, 760, 757, 771, 200, 756, + 760, 759, 762, 0, 763, 750, 751, 759, 765, 760, + 760, 746, 0, 749, 742, 0, 747, 1015, 353, 331, + 740, 374, 746, 784, 783, 687, 681, 661, 669, 377, + 1015, 692, 661, 632, 636, 635, 624, 594, 0, 590, + 0, 584, 586, 560, 0, 564, 0, 580, 562, 0, + 567, 0, 0, 552, 570, 569, 0, 565, 0, 561, + 568, 552, 0, 0, 550, 0, 544, 551, 0, 550, + + 548, 527, 542, 403, 1015, 418, 321, 333, 426, 441, + 541, 555, 356, 516, 504, 510, 500, 449, 530, 476, + 474, 0, 468, 462, 0, 0, 456, 450, 0, 457, + 446, 0, 432, 426, 0, 416, 420, 397, 414, 400, + 386, 396, 0, 390, 389, 377, 0, 445, 406, 1015, + 432, 447, 473, 1015, 398, 343, 1015, 487, 373, 351, + 491, 351, 317, 372, 0, 328, 313, 0, 314, 305, + 292, 299, 0, 293, 0, 263, 0, 0, 261, 0, + 264, 256, 0, 250, 477, 1015, 496, 280, 506, 508, + 516, 1015, 520, 512, 392, 537, 541, 544, 247, 0, + + 0, 0, 0, 0, 0, 199, 0, 0, 188, 164, + 0, 541, 1015, 560, 562, 564, 1015, 566, 568, 196, + 182, 393, 0, 146, 0, 570, 1015, 576, 87, 589, + 591, 0, 1015, 595, 1015, 597, 1015, 618, 626, 630, + 636, 644, 652, 656, 663, 671, 676, 679, 686, 691, + 694, 697, 701, 708, 713, 720, 725, 732, 740, 748, + 756, 764, 772, 780 } ; -static tao_yyconst short int tao_yy_def[472] = +static tao_yyconst short int tao_yy_def[565] = { 0, - 444, 1, 444, 444, 444, 444, 444, 445, 446, 444, - 444, 444, 444, 444, 444, 444, 444, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 444, - 444, 444, 445, 444, 448, 444, 449, 444, 444, 444, - 444, 444, 450, 51, 444, 444, 444, 451, 444, 444, - 444, 444, 447, 447, 452, 453, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - - 447, 447, 447, 447, 447, 40, 444, 40, 444, 444, - 444, 444, 444, 444, 445, 444, 444, 444, 444, 454, - 444, 455, 444, 444, 444, 450, 444, 450, 54, 444, - 444, 451, 447, 452, 444, 444, 444, 444, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 456, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 457, 455, 444, 444, 444, 447, 458, 444, 459, 447, - - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 456, 444, 444, 444, 444, 444, 187, 444, 187, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 447, - 452, 460, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 444, 444, - - 444, 444, 444, 444, 461, 444, 444, 444, 444, 444, - 261, 444, 462, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 444, 444, 444, 463, 444, 444, 444, 444, 461, 444, - 444, 444, 444, 444, 261, 464, 447, 447, 447, 447, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - 447, 447, 447, 444, 463, 444, 463, 465, 444, 444, - 466, 444, 444, 444, 444, 444, 444, 444, 452, 444, - 447, 447, 447, 447, 447, 447, 447, 447, 447, 447, - - 465, 444, 465, 466, 444, 467, 444, 444, 444, 468, - 444, 444, 444, 444, 444, 447, 447, 447, 447, 447, - 467, 444, 467, 444, 468, 444, 468, 469, 470, 444, - 444, 447, 469, 444, 469, 470, 444, 471, 447, 444, - 471, 444, 471, 0, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444 + 537, 1, 537, 537, 537, 537, 537, 538, 539, 537, + 537, 537, 537, 537, 537, 537, 537, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 537, 537, 537, 538, 537, 541, 537, 542, 537, + 537, 537, 537, 537, 543, 53, 537, 537, 537, 544, + 537, 537, 537, 537, 540, 540, 545, 546, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 42, 537, 42, 537, 537, + 537, 537, 537, 537, 538, 537, 537, 537, 537, 547, + 537, 548, 537, 537, 537, 543, 537, 543, 56, 537, + 537, 544, 540, 545, 537, 537, 537, 537, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + + 540, 540, 549, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 550, 548, 537, 537, 537, 540, 551, 537, + 552, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 549, 537, 537, 537, + 537, 537, 209, 537, 209, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 540, 545, 553, 540, 540, 540, + + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 537, 537, 537, + 537, 537, 537, 554, 537, 537, 537, 537, 537, 296, + 537, 555, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + + 540, 540, 540, 537, 537, 537, 556, 537, 537, 537, + 537, 554, 537, 537, 537, 537, 537, 296, 557, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 537, 556, 537, + 556, 558, 537, 537, 559, 537, 537, 537, 537, 537, + 537, 537, 545, 537, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 540, 540, 540, 558, 537, 558, 559, 537, 560, + 537, 537, 537, 561, 537, 537, 537, 537, 537, 540, + + 540, 540, 540, 540, 540, 540, 540, 540, 540, 540, + 540, 560, 537, 560, 537, 561, 537, 561, 562, 563, + 537, 537, 540, 540, 540, 562, 537, 562, 563, 537, + 564, 540, 537, 564, 537, 564, 0, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537 } ; -static tao_yyconst short int tao_yy_nxt[980] = +static tao_yyconst short int tao_yy_nxt[1073] = { 0, 4, 5, 6, 7, 5, 8, 4, 9, 4, 4, 10, 11, 12, 13, 14, 14, 15, 16, 4, 17, 7, 18, 18, 18, 19, 18, 20, 18, 18, 21, - 18, 18, 4, 22, 23, 24, 25, 26, 27, 18, - 18, 28, 29, 30, 31, 32, 33, 18, 34, 35, - 36, 37, 38, 39, 18, 18, 40, 42, 44, 48, - 42, 49, 50, 50, 51, 51, 51, 52, 78, 92, - 41, 53, 54, 93, 55, 55, 56, 54, 79, 59, - 59, 59, 437, 68, 57, 45, 65, 76, 66, 57, - 72, 87, 58, 69, 99, 77, 80, 73, 57, 70, - - 88, 100, 74, 57, 81, 82, 90, 89, 75, 91, - 94, 104, 44, 95, 42, 58, 102, 42, 51, 51, - 51, 181, 155, 96, 97, 105, 98, 156, 103, 106, - 107, 107, 108, 135, 44, 127, 128, 157, 118, 45, - 439, 109, 109, 109, 119, 119, 158, 54, 107, 121, - 121, 56, 54, 128, 123, 123, 123, 175, 444, 57, - 136, 45, 120, 429, 57, 176, 110, 122, 437, 111, - 112, 127, 128, 57, 113, 129, 129, 129, 57, 131, - 131, 131, 127, 128, 54, 120, 55, 55, 56, 128, - 122, 51, 51, 51, 432, 54, 57, 56, 56, 56, - - 128, 124, 125, 198, 125, 135, 431, 57, 130, 130, - 57, 405, 131, 131, 131, 124, 125, 107, 107, 182, - 125, 57, 54, 230, 59, 59, 59, 420, 109, 109, - 109, 189, 136, 231, 57, 107, 419, 190, 190, 54, - 418, 121, 121, 56, 206, 207, 305, 199, 57, 417, - 54, 57, 123, 123, 123, 193, 193, 256, 416, 194, - 194, 194, 57, 257, 257, 57, 131, 131, 131, 194, - 194, 194, 299, 299, 300, 344, 57, 195, 344, 195, - 135, 378, 406, 444, 378, 406, 376, 377, 376, 377, - 299, 195, 194, 194, 194, 195, 248, 249, 249, 250, - - 249, 249, 306, 125, 377, 125, 377, 136, 251, 251, - 251, 251, 251, 251, 312, 249, 410, 125, 249, 410, - 428, 125, 438, 428, 415, 438, 341, 342, 342, 341, - 383, 383, 384, 252, 411, 405, 253, 254, 343, 343, - 343, 255, 135, 346, 400, 342, 346, 399, 383, 398, - 311, 311, 311, 397, 396, 347, 347, 347, 311, 311, - 311, 311, 376, 377, 402, 403, 395, 394, 393, 136, - 311, 311, 311, 311, 311, 311, 355, 355, 355, 392, - 377, 391, 403, 312, 355, 355, 355, 355, 388, 387, - 341, 342, 342, 341, 402, 403, 355, 355, 355, 355, - - 355, 355, 374, 374, 374, 341, 342, 342, 341, 342, - 386, 430, 403, 346, 385, 350, 346, 343, 343, 343, - 414, 414, 414, 382, 342, 347, 347, 347, 379, 380, - 380, 379, 381, 342, 342, 379, 380, 380, 379, 381, - 347, 347, 347, 373, 374, 374, 374, 380, 389, 389, - 389, 342, 372, 371, 380, 370, 389, 389, 389, 389, - 402, 403, 407, 408, 408, 407, 380, 380, 389, 389, - 389, 389, 389, 389, 409, 409, 409, 412, 403, 369, - 413, 408, 422, 423, 380, 407, 408, 408, 407, 414, - 414, 414, 368, 407, 408, 408, 407, 424, 424, 424, - - 423, 426, 427, 367, 408, 409, 409, 409, 412, 366, - 365, 413, 408, 412, 422, 423, 413, 429, 364, 427, - 414, 414, 414, 422, 423, 414, 414, 414, 363, 426, - 427, 362, 423, 408, 408, 426, 427, 434, 435, 434, - 435, 423, 434, 435, 424, 424, 424, 427, 440, 440, - 361, 408, 360, 427, 359, 435, 358, 435, 442, 443, - 435, 442, 443, 442, 443, 357, 440, 312, 354, 353, - 352, 351, 305, 350, 348, 345, 443, 340, 339, 443, - 338, 443, 43, 43, 43, 43, 43, 43, 43, 43, - 46, 337, 46, 46, 46, 46, 46, 46, 63, 63, - - 63, 63, 115, 115, 336, 335, 115, 115, 117, 334, - 117, 117, 117, 117, 117, 117, 126, 126, 126, 126, - 126, 126, 126, 126, 132, 333, 132, 134, 134, 134, - 134, 134, 134, 134, 134, 137, 332, 137, 137, 137, - 137, 137, 137, 191, 191, 331, 191, 192, 330, 192, - 242, 242, 242, 242, 242, 242, 242, 242, 259, 259, - 329, 259, 261, 328, 261, 262, 327, 262, 313, 313, - 326, 313, 349, 349, 349, 349, 349, 349, 349, 349, - 356, 356, 325, 356, 375, 375, 375, 375, 375, 375, - 375, 375, 390, 390, 324, 390, 401, 401, 401, 401, - - 401, 401, 401, 401, 404, 404, 404, 404, 404, 404, - 404, 404, 421, 421, 421, 421, 421, 421, 421, 421, - 425, 425, 425, 425, 425, 425, 425, 425, 433, 433, - 433, 433, 433, 433, 433, 433, 436, 436, 436, 436, - 436, 436, 436, 436, 441, 441, 441, 441, 441, 441, - 441, 441, 323, 322, 321, 320, 319, 318, 317, 316, - 315, 314, 312, 258, 256, 310, 309, 308, 307, 444, - 304, 303, 302, 301, 243, 298, 297, 296, 295, 294, - 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, - 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, - - 273, 272, 271, 270, 269, 268, 267, 266, 265, 264, - 263, 260, 258, 247, 246, 245, 244, 181, 243, 241, - 240, 239, 238, 237, 236, 235, 234, 233, 232, 229, - 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, - 218, 217, 216, 215, 214, 213, 212, 211, 210, 209, - 208, 205, 204, 203, 202, 201, 200, 198, 197, 196, - 188, 188, 188, 187, 186, 185, 184, 183, 444, 180, - 179, 178, 177, 174, 173, 172, 171, 170, 169, 168, - 167, 166, 165, 164, 163, 162, 161, 160, 159, 154, - 153, 152, 151, 150, 149, 148, 147, 146, 145, 144, - - 143, 142, 141, 140, 139, 138, 133, 116, 114, 101, - 86, 85, 84, 83, 71, 67, 64, 62, 61, 60, - 47, 444, 3, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444 + 18, 18, 4, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 18, 31, 32, 33, 34, 35, 18, 36, + 37, 38, 39, 40, 41, 18, 18, 42, 44, 46, + 50, 44, 51, 52, 52, 53, 53, 53, 54, 110, + 78, 43, 55, 56, 111, 57, 57, 58, 56, 79, + 61, 61, 61, 70, 74, 59, 47, 67, 84, 68, + 59, 75, 530, 60, 71, 92, 85, 76, 86, 59, + + 72, 80, 81, 77, 59, 89, 90, 101, 93, 96, + 82, 102, 83, 99, 94, 103, 100, 60, 104, 97, + 108, 112, 114, 156, 157, 44, 98, 109, 44, 105, + 106, 46, 107, 145, 113, 137, 138, 115, 116, 117, + 117, 118, 128, 53, 53, 53, 229, 230, 129, 129, + 119, 119, 119, 138, 139, 139, 139, 117, 47, 56, + 146, 131, 131, 58, 203, 56, 130, 133, 133, 133, + 56, 59, 57, 57, 58, 120, 166, 59, 121, 132, + 122, 220, 59, 532, 123, 59, 167, 520, 140, 140, + 130, 59, 141, 141, 141, 56, 59, 58, 58, 58, + + 174, 530, 537, 132, 53, 53, 53, 59, 172, 188, + 175, 183, 189, 173, 134, 135, 184, 135, 196, 525, + 56, 59, 61, 61, 61, 46, 221, 197, 134, 135, + 145, 524, 59, 211, 135, 387, 117, 117, 204, 212, + 212, 56, 255, 131, 131, 58, 59, 119, 119, 119, + 388, 256, 47, 59, 117, 523, 56, 146, 133, 133, + 133, 137, 138, 137, 138, 215, 215, 59, 59, 216, + 216, 216, 141, 141, 141, 141, 141, 141, 264, 138, + 522, 138, 59, 354, 291, 489, 217, 511, 217, 265, + 292, 292, 216, 216, 216, 302, 303, 510, 509, 340, + + 217, 216, 216, 216, 341, 217, 283, 284, 284, 285, + 342, 508, 135, 507, 135, 348, 348, 349, 286, 286, + 286, 537, 145, 450, 451, 284, 135, 284, 284, 355, + 506, 135, 407, 348, 452, 407, 505, 452, 286, 286, + 286, 451, 504, 287, 490, 284, 288, 490, 289, 146, + 503, 502, 290, 145, 404, 405, 405, 404, 457, 457, + 458, 360, 360, 360, 501, 500, 406, 406, 406, 360, + 360, 360, 360, 405, 494, 409, 457, 494, 409, 361, + 146, 360, 360, 360, 360, 360, 360, 410, 410, 410, + 418, 418, 418, 519, 531, 499, 519, 531, 418, 418, + + 418, 418, 495, 489, 404, 405, 405, 404, 450, 451, + 418, 418, 418, 418, 418, 418, 448, 448, 448, 404, + 405, 405, 404, 405, 484, 483, 451, 409, 482, 481, + 409, 406, 406, 406, 450, 451, 480, 479, 405, 410, + 410, 410, 453, 454, 454, 453, 455, 405, 405, 486, + 487, 478, 451, 477, 410, 410, 410, 476, 448, 448, + 448, 454, 463, 463, 463, 405, 475, 487, 474, 473, + 463, 463, 463, 463, 453, 454, 454, 453, 455, 486, + 487, 472, 463, 463, 463, 463, 463, 463, 491, 492, + 492, 491, 496, 454, 471, 497, 470, 487, 486, 487, + + 493, 493, 493, 469, 498, 498, 498, 492, 454, 454, + 513, 514, 468, 467, 517, 518, 487, 491, 492, 492, + 491, 491, 492, 492, 491, 466, 454, 465, 514, 515, + 515, 515, 518, 493, 493, 493, 492, 361, 496, 462, + 492, 497, 496, 513, 514, 497, 520, 461, 521, 460, + 498, 498, 498, 459, 498, 498, 498, 498, 498, 498, + 413, 514, 513, 514, 492, 492, 517, 518, 517, 518, + 527, 528, 527, 528, 456, 515, 515, 515, 527, 528, + 514, 447, 492, 446, 518, 445, 518, 444, 528, 443, + 528, 533, 533, 535, 536, 442, 528, 535, 536, 535, + + 536, 441, 440, 439, 438, 437, 436, 435, 434, 533, + 433, 536, 432, 431, 430, 536, 429, 536, 45, 45, + 45, 45, 45, 45, 45, 45, 48, 428, 48, 48, + 48, 48, 48, 48, 65, 65, 65, 65, 125, 125, + 427, 426, 125, 125, 127, 425, 127, 127, 127, 127, + 127, 127, 136, 136, 136, 136, 136, 136, 136, 136, + 142, 424, 142, 144, 144, 144, 144, 144, 144, 144, + 144, 147, 423, 147, 147, 147, 147, 147, 147, 213, + 213, 422, 213, 214, 421, 214, 277, 277, 277, 277, + 277, 277, 277, 277, 294, 294, 420, 294, 296, 361, + + 296, 297, 417, 297, 362, 362, 416, 362, 412, 412, + 412, 412, 412, 412, 412, 412, 419, 419, 415, 419, + 449, 449, 449, 449, 449, 449, 449, 449, 464, 464, + 414, 464, 485, 485, 485, 485, 485, 485, 485, 485, + 488, 488, 488, 488, 488, 488, 488, 488, 512, 512, + 512, 512, 512, 512, 512, 512, 516, 516, 516, 516, + 516, 516, 516, 516, 526, 526, 526, 526, 526, 526, + 526, 526, 529, 529, 529, 529, 529, 529, 529, 529, + 534, 534, 534, 534, 534, 534, 534, 534, 354, 413, + 411, 408, 403, 402, 401, 400, 399, 398, 397, 396, + + 395, 394, 393, 392, 391, 390, 389, 386, 385, 384, + 383, 382, 381, 380, 379, 378, 377, 376, 375, 374, + 373, 372, 371, 370, 369, 368, 367, 366, 365, 364, + 363, 361, 293, 291, 359, 358, 357, 356, 537, 353, + 352, 351, 350, 278, 347, 346, 345, 344, 343, 339, + 338, 337, 336, 335, 334, 333, 332, 331, 330, 329, + 328, 327, 326, 325, 324, 323, 322, 321, 320, 319, + 318, 317, 316, 315, 314, 313, 312, 311, 310, 309, + 308, 307, 306, 305, 304, 301, 300, 299, 298, 295, + 293, 282, 281, 280, 279, 203, 278, 276, 275, 274, + + 273, 272, 271, 270, 269, 268, 267, 266, 263, 262, + 261, 260, 259, 258, 257, 254, 253, 252, 251, 250, + 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, + 239, 238, 237, 236, 235, 234, 233, 232, 231, 228, + 227, 226, 225, 224, 223, 222, 220, 219, 218, 210, + 210, 210, 209, 208, 207, 206, 205, 537, 202, 201, + 200, 199, 198, 195, 194, 193, 192, 191, 190, 187, + 186, 185, 182, 181, 180, 179, 178, 177, 176, 171, + 170, 169, 168, 165, 164, 163, 162, 161, 160, 159, + 158, 155, 154, 153, 152, 151, 150, 149, 148, 143, + + 126, 124, 95, 91, 88, 87, 73, 69, 66, 64, + 63, 62, 49, 537, 3, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537 } ; -static tao_yyconst short int tao_yy_chk[980] = +static tao_yyconst short int tao_yy_chk[1073] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 2, 5, 8, 10, - 5, 10, 10, 10, 11, 11, 11, 12, 26, 34, - 2, 12, 13, 34, 13, 13, 13, 14, 26, 14, - 14, 14, 436, 22, 13, 8, 20, 25, 20, 14, - 24, 32, 13, 22, 36, 25, 27, 24, 13, 22, - - 32, 36, 24, 14, 27, 27, 33, 32, 24, 33, - 35, 39, 43, 35, 42, 13, 38, 42, 48, 48, - 48, 108, 83, 35, 35, 39, 35, 83, 38, 40, - 40, 40, 40, 65, 115, 53, 53, 84, 47, 43, - 432, 40, 40, 40, 47, 47, 84, 49, 40, 49, - 49, 49, 50, 53, 50, 50, 50, 101, 108, 49, - 65, 115, 47, 430, 50, 101, 40, 49, 429, 40, - 40, 126, 126, 49, 40, 54, 54, 54, 50, 130, - 130, 130, 128, 128, 55, 47, 55, 55, 55, 126, - 49, 51, 51, 51, 419, 56, 55, 56, 56, 56, - - 128, 51, 51, 138, 51, 134, 415, 56, 57, 57, - 55, 404, 57, 57, 57, 51, 51, 109, 109, 109, - 51, 56, 59, 170, 59, 59, 59, 400, 109, 109, - 109, 119, 134, 170, 59, 109, 398, 119, 119, 121, - 394, 121, 121, 121, 146, 146, 250, 138, 59, 393, - 123, 121, 123, 123, 123, 124, 124, 190, 392, 124, - 124, 124, 123, 190, 190, 121, 131, 131, 131, 193, - 193, 193, 243, 243, 243, 301, 123, 131, 301, 131, - 389, 345, 382, 250, 345, 382, 344, 344, 375, 375, - 243, 131, 194, 194, 194, 131, 187, 187, 187, 187, - - 251, 251, 251, 194, 344, 194, 375, 389, 187, 187, - 187, 251, 251, 251, 390, 187, 385, 194, 251, 385, - 411, 194, 431, 411, 388, 431, 300, 300, 300, 300, - 350, 350, 350, 187, 386, 381, 187, 187, 300, 300, - 300, 187, 261, 303, 372, 300, 303, 371, 350, 369, - 261, 261, 261, 368, 367, 303, 303, 303, 261, 261, - 261, 261, 377, 377, 378, 378, 366, 364, 362, 261, - 261, 261, 261, 261, 261, 261, 311, 311, 311, 358, - 377, 357, 378, 356, 311, 311, 311, 311, 354, 353, - 341, 341, 341, 341, 401, 401, 311, 311, 311, 311, - - 311, 311, 341, 341, 341, 343, 343, 343, 343, 341, - 352, 414, 401, 346, 351, 349, 346, 343, 343, 343, - 414, 414, 414, 348, 343, 346, 346, 346, 347, 347, - 347, 347, 347, 374, 374, 379, 379, 379, 379, 379, - 347, 347, 347, 340, 374, 374, 374, 347, 355, 355, - 355, 374, 339, 338, 379, 337, 355, 355, 355, 355, - 403, 403, 384, 384, 384, 384, 405, 405, 355, 355, - 355, 355, 355, 355, 384, 384, 384, 387, 403, 336, - 387, 384, 406, 406, 405, 407, 407, 407, 407, 387, - 387, 387, 334, 409, 409, 409, 409, 407, 407, 407, - - 406, 410, 410, 331, 407, 409, 409, 409, 412, 330, - 327, 412, 409, 413, 421, 421, 413, 413, 323, 410, - 412, 412, 412, 423, 423, 413, 413, 413, 322, 425, - 425, 321, 421, 424, 424, 427, 427, 428, 428, 433, - 433, 423, 435, 435, 424, 424, 424, 425, 437, 437, - 319, 424, 317, 427, 316, 428, 315, 433, 438, 438, - 435, 441, 441, 443, 443, 314, 437, 313, 310, 309, - 308, 307, 306, 305, 304, 302, 438, 298, 296, 441, - 295, 443, 445, 445, 445, 445, 445, 445, 445, 445, - 446, 293, 446, 446, 446, 446, 446, 446, 447, 447, - - 447, 447, 448, 448, 292, 291, 448, 448, 449, 290, - 449, 449, 449, 449, 449, 449, 450, 450, 450, 450, - 450, 450, 450, 450, 451, 289, 451, 452, 452, 452, - 452, 452, 452, 452, 452, 453, 288, 453, 453, 453, - 453, 453, 453, 454, 454, 286, 454, 455, 285, 455, - 456, 456, 456, 456, 456, 456, 456, 456, 457, 457, - 284, 457, 458, 283, 458, 459, 282, 459, 460, 460, - 281, 460, 461, 461, 461, 461, 461, 461, 461, 461, - 462, 462, 279, 462, 463, 463, 463, 463, 463, 463, - 463, 463, 464, 464, 278, 464, 465, 465, 465, 465, - - 465, 465, 465, 465, 466, 466, 466, 466, 466, 466, - 466, 466, 467, 467, 467, 467, 467, 467, 467, 467, - 468, 468, 468, 468, 468, 468, 468, 468, 469, 469, - 469, 469, 469, 469, 469, 469, 470, 470, 470, 470, - 470, 470, 470, 470, 471, 471, 471, 471, 471, 471, - 471, 471, 276, 272, 271, 270, 269, 268, 267, 265, - 264, 263, 262, 259, 257, 255, 254, 253, 252, 248, - 247, 246, 245, 244, 242, 241, 240, 238, 237, 236, - 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, - 225, 224, 223, 222, 221, 220, 218, 217, 216, 215, - - 214, 213, 212, 210, 209, 208, 207, 206, 203, 202, - 201, 196, 191, 186, 185, 184, 183, 182, 181, 180, - 179, 178, 177, 176, 175, 174, 173, 172, 171, 169, - 168, 167, 166, 165, 164, 162, 161, 160, 159, 158, - 157, 156, 155, 154, 153, 152, 151, 150, 149, 148, - 147, 145, 144, 143, 142, 140, 139, 137, 136, 133, - 120, 118, 117, 114, 113, 112, 111, 110, 106, 105, - 104, 103, 102, 100, 99, 98, 97, 96, 95, 94, - 93, 92, 91, 90, 89, 88, 87, 86, 85, 82, - 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, - - 71, 70, 69, 68, 67, 66, 64, 46, 41, 37, - 31, 30, 29, 28, 23, 21, 19, 17, 16, 15, - 9, 3, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444, 444, - 444, 444, 444, 444, 444, 444, 444, 444, 444 + 1, 1, 1, 1, 1, 1, 1, 2, 5, 8, + 10, 5, 10, 10, 10, 11, 11, 11, 12, 39, + 25, 2, 12, 13, 39, 13, 13, 13, 14, 25, + 14, 14, 14, 22, 24, 13, 8, 20, 27, 20, + 14, 24, 529, 13, 22, 32, 27, 24, 27, 13, + + 22, 26, 26, 24, 14, 30, 30, 36, 32, 34, + 26, 36, 26, 35, 32, 37, 35, 13, 37, 34, + 38, 40, 41, 76, 76, 44, 34, 38, 44, 37, + 37, 45, 37, 67, 40, 55, 55, 41, 42, 42, + 42, 42, 49, 50, 50, 50, 157, 157, 49, 49, + 42, 42, 42, 55, 56, 56, 56, 42, 45, 51, + 67, 51, 51, 51, 118, 52, 49, 52, 52, 52, + 57, 51, 57, 57, 57, 42, 85, 52, 42, 51, + 42, 148, 57, 524, 42, 51, 85, 521, 59, 59, + 49, 52, 59, 59, 59, 58, 57, 58, 58, 58, + + 91, 520, 118, 51, 53, 53, 53, 58, 90, 103, + 91, 99, 103, 90, 53, 53, 99, 53, 110, 510, + 61, 58, 61, 61, 61, 125, 148, 110, 53, 53, + 144, 509, 61, 129, 53, 329, 119, 119, 119, 129, + 129, 131, 183, 131, 131, 131, 61, 119, 119, 119, + 329, 183, 125, 131, 119, 506, 133, 144, 133, 133, + 133, 136, 136, 138, 138, 134, 134, 131, 133, 134, + 134, 134, 140, 140, 140, 141, 141, 141, 191, 136, + 499, 138, 133, 285, 212, 488, 141, 484, 141, 191, + 212, 212, 215, 215, 215, 229, 229, 482, 481, 269, + + 141, 216, 216, 216, 269, 141, 209, 209, 209, 209, + 269, 479, 216, 476, 216, 278, 278, 278, 209, 209, + 209, 285, 463, 407, 407, 209, 216, 286, 286, 286, + 474, 216, 350, 278, 408, 350, 472, 408, 286, 286, + 286, 407, 471, 209, 456, 286, 209, 456, 209, 463, + 470, 469, 209, 296, 349, 349, 349, 349, 413, 413, + 413, 296, 296, 296, 467, 466, 349, 349, 349, 296, + 296, 296, 296, 349, 459, 352, 413, 459, 352, 464, + 296, 296, 296, 296, 296, 296, 296, 352, 352, 352, + 360, 360, 360, 495, 522, 462, 495, 522, 360, 360, + + 360, 360, 460, 455, 404, 404, 404, 404, 449, 449, + 360, 360, 360, 360, 360, 360, 404, 404, 404, 406, + 406, 406, 406, 404, 446, 445, 449, 409, 444, 442, + 409, 406, 406, 406, 451, 451, 441, 440, 406, 409, + 409, 409, 410, 410, 410, 410, 410, 448, 448, 452, + 452, 439, 451, 438, 410, 410, 410, 437, 448, 448, + 448, 410, 418, 418, 418, 448, 436, 452, 434, 433, + 418, 418, 418, 418, 453, 453, 453, 453, 453, 485, + 485, 431, 418, 418, 418, 418, 418, 418, 458, 458, + 458, 458, 461, 453, 430, 461, 428, 485, 487, 487, + + 458, 458, 458, 427, 461, 461, 461, 458, 489, 489, + 490, 490, 424, 423, 494, 494, 487, 491, 491, 491, + 491, 493, 493, 493, 493, 421, 489, 420, 490, 491, + 491, 491, 494, 493, 493, 493, 491, 419, 496, 417, + 493, 496, 497, 512, 512, 497, 497, 416, 498, 415, + 496, 496, 496, 414, 497, 497, 497, 498, 498, 498, + 412, 512, 514, 514, 515, 515, 516, 516, 518, 518, + 519, 519, 526, 526, 411, 515, 515, 515, 528, 528, + 514, 403, 515, 402, 516, 401, 518, 400, 519, 398, + 526, 530, 530, 531, 531, 397, 528, 534, 534, 536, + + 536, 395, 392, 391, 390, 388, 386, 385, 384, 530, + 381, 531, 379, 378, 376, 534, 374, 536, 538, 538, + 538, 538, 538, 538, 538, 538, 539, 373, 539, 539, + 539, 539, 539, 539, 540, 540, 540, 540, 541, 541, + 372, 370, 541, 541, 542, 368, 542, 542, 542, 542, + 542, 542, 543, 543, 543, 543, 543, 543, 543, 543, + 544, 367, 544, 545, 545, 545, 545, 545, 545, 545, + 545, 546, 366, 546, 546, 546, 546, 546, 546, 547, + 547, 365, 547, 548, 364, 548, 549, 549, 549, 549, + 549, 549, 549, 549, 550, 550, 363, 550, 551, 362, + + 551, 552, 359, 552, 553, 553, 358, 553, 554, 554, + 554, 554, 554, 554, 554, 554, 555, 555, 357, 555, + 556, 556, 556, 556, 556, 556, 556, 556, 557, 557, + 356, 557, 558, 558, 558, 558, 558, 558, 558, 558, + 559, 559, 559, 559, 559, 559, 559, 559, 560, 560, + 560, 560, 560, 560, 560, 560, 561, 561, 561, 561, + 561, 561, 561, 561, 562, 562, 562, 562, 562, 562, + 562, 562, 563, 563, 563, 563, 563, 563, 563, 563, + 564, 564, 564, 564, 564, 564, 564, 564, 355, 354, + 353, 351, 347, 345, 344, 342, 341, 340, 339, 338, + + 337, 336, 335, 333, 332, 331, 330, 328, 327, 326, + 325, 323, 322, 321, 320, 318, 316, 315, 312, 311, + 310, 309, 307, 306, 305, 304, 303, 301, 300, 299, + 298, 297, 294, 292, 290, 289, 288, 287, 283, 282, + 281, 280, 279, 277, 276, 275, 273, 271, 270, 268, + 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, + 257, 256, 255, 254, 253, 252, 251, 250, 249, 247, + 246, 245, 244, 242, 241, 240, 239, 238, 237, 236, + 234, 233, 232, 231, 230, 228, 225, 224, 223, 218, + 213, 208, 207, 206, 205, 204, 203, 202, 201, 200, + + 199, 198, 197, 196, 195, 194, 193, 192, 190, 189, + 188, 187, 186, 185, 184, 181, 180, 179, 178, 177, + 176, 175, 174, 173, 172, 171, 170, 169, 168, 167, + 166, 165, 164, 163, 162, 161, 160, 159, 158, 156, + 155, 154, 153, 152, 150, 149, 147, 146, 143, 130, + 128, 127, 124, 123, 122, 121, 120, 116, 115, 114, + 113, 112, 111, 109, 108, 107, 106, 105, 104, 102, + 101, 100, 98, 97, 96, 95, 94, 93, 92, 89, + 88, 87, 86, 84, 83, 82, 81, 80, 79, 78, + 77, 75, 74, 73, 72, 71, 70, 69, 68, 66, + + 48, 43, 33, 31, 29, 28, 23, 21, 19, 17, + 16, 15, 9, 3, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537, 537, 537, 537, 537, 537, 537, 537, 537, + 537, 537 } ; static tao_yy_state_type tao_yy_last_accepting_state; @@ -729,7 +781,7 @@ static char *tao_yy_last_accepting_cpos; char tao_yytext[TAO_YYLMAX]; char *tao_yytext_ptr; #define INITIAL 0 -/* $Id: idl.ll,v 1.56 2001/09/23 19:16:59 parsons Exp $ +/* $Id: idl.ll,v 1.60 2002/01/31 19:27:19 parsons Exp $ COPYRIGHT @@ -847,6 +899,19 @@ static int scan_obv_token (int token) return IDENTIFIER; } +static int scan_ccm_token (int token) +{ + if (idl_global->component_support ()) + { + return token; + } + else + { + tao_yylval.strval = ACE_OS::strdup (ace_tao_yytext); + return IDENTIFIER; + } +} + /* SO we don't choke on files that use \r\n */ #define TAO_YY_NEVER_INTERACTIVE 1 @@ -935,21 +1000,21 @@ TAO_YY_MALLOC_DECL */ #ifndef TAO_YY_INPUT #define TAO_YY_INPUT(buf,result,max_size) \ - if ( tao_yy_current_buffer->tao_yy_is_interactive ) \ - { \ - int c = '*', n; \ - for ( n = 0; n < max_size && \ - (c = getc( tao_yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( tao_yyin ) ) \ - TAO_YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else if ( ((result = fread( buf, 1, max_size, tao_yyin )) == 0) \ - && ferror( tao_yyin ) ) \ - TAO_YY_FATAL_ERROR( "input in flex scanner failed" ); + if ( tao_yy_current_buffer->tao_yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( tao_yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( tao_yyin ) ) \ + TAO_YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, tao_yyin )) == 0) \ + && ferror( tao_yyin ) ) \ + TAO_YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "tao_yyterminate();" - @@ -990,303 +1055,371 @@ TAO_YY_MALLOC_DECL #endif #define TAO_YY_RULE_SETUP \ - if ( tao_yyleng > 0 ) \ - tao_yy_current_buffer->tao_yy_at_bol = \ - (tao_yytext[tao_yyleng - 1] == '\n'); \ - TAO_YY_USER_ACTION + if ( tao_yyleng > 0 ) \ + tao_yy_current_buffer->tao_yy_at_bol = \ + (tao_yytext[tao_yyleng - 1] == '\n'); \ + TAO_YY_USER_ACTION TAO_YY_DECL - { - register tao_yy_state_type tao_yy_current_state; - register char *tao_yy_cp = 0, *tao_yy_bp = 0; - register int tao_yy_act; + { + register tao_yy_state_type tao_yy_current_state; + register char *tao_yy_cp = 0, *tao_yy_bp = 0; + register int tao_yy_act; - if ( tao_yy_init ) - { - tao_yy_init = 0; + if ( tao_yy_init ) + { + tao_yy_init = 0; #ifdef TAO_YY_USER_INIT - TAO_YY_USER_INIT; + TAO_YY_USER_INIT; #endif - if ( ! tao_yy_start ) - tao_yy_start = 1; /* first start state */ + if ( ! tao_yy_start ) + tao_yy_start = 1; /* first start state */ - if ( ! tao_yyin ) - tao_yyin = stdin; + if ( ! tao_yyin ) + tao_yyin = stdin; - if ( ! tao_yyout ) - tao_yyout = stdout; + if ( ! tao_yyout ) + tao_yyout = stdout; - if ( ! tao_yy_current_buffer ) - tao_yy_current_buffer = - tao_yy_create_buffer( tao_yyin, TAO_YY_BUF_SIZE ); + if ( ! tao_yy_current_buffer ) + tao_yy_current_buffer = + tao_yy_create_buffer( tao_yyin, TAO_YY_BUF_SIZE ); - tao_yy_load_buffer_state(); - } + tao_yy_load_buffer_state(); + } - while ( 1 ) /* loops until end-of-file is reached */ - { - tao_yy_cp = tao_yy_c_buf_p; + while ( 1 ) /* loops until end-of-file is reached */ + { + tao_yy_cp = tao_yy_c_buf_p; - /* Support of tao_yytext. */ - *tao_yy_cp = tao_yy_hold_char; + /* Support of tao_yytext. */ + *tao_yy_cp = tao_yy_hold_char; - /* tao_yy_bp points to the position in tao_yy_ch_buf of the start of - * the current run. - */ - tao_yy_bp = tao_yy_cp; + /* tao_yy_bp points to the position in tao_yy_ch_buf of the start of + * the current run. + */ + tao_yy_bp = tao_yy_cp; - tao_yy_current_state = tao_yy_start; - tao_yy_current_state += TAO_YY_AT_BOL(); + tao_yy_current_state = tao_yy_start; + tao_yy_current_state += TAO_YY_AT_BOL(); tao_yy_match: - do - { - register TAO_YY_CHAR tao_yy_c = tao_yy_ec[TAO_YY_SC_TO_UI(*tao_yy_cp)]; - if ( tao_yy_accept[tao_yy_current_state] ) - { - tao_yy_last_accepting_state = tao_yy_current_state; - tao_yy_last_accepting_cpos = tao_yy_cp; - } - while ( tao_yy_chk[tao_yy_base[tao_yy_current_state] + tao_yy_c] != tao_yy_current_state ) - { - tao_yy_current_state = (int) tao_yy_def[tao_yy_current_state]; - if ( tao_yy_current_state >= 445 ) - tao_yy_c = tao_yy_meta[(unsigned int) tao_yy_c]; - } - tao_yy_current_state = tao_yy_nxt[tao_yy_base[tao_yy_current_state] + (unsigned int) tao_yy_c]; - ++tao_yy_cp; - } - while ( tao_yy_base[tao_yy_current_state] != 923 ); + do + { + register TAO_YY_CHAR tao_yy_c = tao_yy_ec[TAO_YY_SC_TO_UI(*tao_yy_cp)]; + if ( tao_yy_accept[tao_yy_current_state] ) + { + tao_yy_last_accepting_state = tao_yy_current_state; + tao_yy_last_accepting_cpos = tao_yy_cp; + } + while ( tao_yy_chk[tao_yy_base[tao_yy_current_state] + tao_yy_c] != tao_yy_current_state ) + { + tao_yy_current_state = (int) tao_yy_def[tao_yy_current_state]; + if ( tao_yy_current_state >= 538 ) + tao_yy_c = tao_yy_meta[(unsigned int) tao_yy_c]; + } + tao_yy_current_state = tao_yy_nxt[tao_yy_base[tao_yy_current_state] + (unsigned int) tao_yy_c]; + ++tao_yy_cp; + } + while ( tao_yy_base[tao_yy_current_state] != 1015 ); tao_yy_find_action: - tao_yy_act = tao_yy_accept[tao_yy_current_state]; - if ( tao_yy_act == 0 ) - { /* have to back up */ - tao_yy_cp = tao_yy_last_accepting_cpos; - tao_yy_current_state = tao_yy_last_accepting_state; - tao_yy_act = tao_yy_accept[tao_yy_current_state]; - } + tao_yy_act = tao_yy_accept[tao_yy_current_state]; + if ( tao_yy_act == 0 ) + { /* have to back up */ + tao_yy_cp = tao_yy_last_accepting_cpos; + tao_yy_current_state = tao_yy_last_accepting_state; + tao_yy_act = tao_yy_accept[tao_yy_current_state]; + } - TAO_YY_DO_BEFORE_ACTION; + TAO_YY_DO_BEFORE_ACTION; -do_action: /* This label is used only to access EOF actions. */ +do_action: /* This label is used only to access EOF actions. */ - switch ( tao_yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of TAO_YY_DO_BEFORE_ACTION */ - *tao_yy_cp = tao_yy_hold_char; - tao_yy_cp = tao_yy_last_accepting_cpos; - tao_yy_current_state = tao_yy_last_accepting_state; - goto tao_yy_find_action; + switch ( tao_yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of TAO_YY_DO_BEFORE_ACTION */ + *tao_yy_cp = tao_yy_hold_char; + tao_yy_cp = tao_yy_last_accepting_cpos; + tao_yy_current_state = tao_yy_last_accepting_state; + goto tao_yy_find_action; case 1: TAO_YY_RULE_SETUP return IDL_ANY; - TAO_YY_BREAK + TAO_YY_BREAK case 2: TAO_YY_RULE_SETUP return IDL_MODULE; - TAO_YY_BREAK + TAO_YY_BREAK case 3: TAO_YY_RULE_SETUP return IDL_RAISES; - TAO_YY_BREAK + TAO_YY_BREAK case 4: TAO_YY_RULE_SETUP return IDL_READONLY; - TAO_YY_BREAK + TAO_YY_BREAK case 5: TAO_YY_RULE_SETUP return IDL_ATTRIBUTE; - TAO_YY_BREAK + TAO_YY_BREAK case 6: TAO_YY_RULE_SETUP return IDL_EXCEPTION; - TAO_YY_BREAK + TAO_YY_BREAK case 7: TAO_YY_RULE_SETUP return IDL_CONTEXT; - TAO_YY_BREAK + TAO_YY_BREAK case 8: TAO_YY_RULE_SETUP return IDL_INTERFACE; - TAO_YY_BREAK + TAO_YY_BREAK case 9: TAO_YY_RULE_SETUP return IDL_CONST; - TAO_YY_BREAK + TAO_YY_BREAK case 10: TAO_YY_RULE_SETUP return IDL_TYPEDEF; - TAO_YY_BREAK + TAO_YY_BREAK case 11: TAO_YY_RULE_SETUP return IDL_STRUCT; - TAO_YY_BREAK + TAO_YY_BREAK case 12: TAO_YY_RULE_SETUP return IDL_ENUM; - TAO_YY_BREAK + TAO_YY_BREAK case 13: TAO_YY_RULE_SETUP return IDL_STRING; - TAO_YY_BREAK + TAO_YY_BREAK case 14: TAO_YY_RULE_SETUP return IDL_WSTRING; - TAO_YY_BREAK + TAO_YY_BREAK case 15: TAO_YY_RULE_SETUP return IDL_SEQUENCE; - TAO_YY_BREAK + TAO_YY_BREAK case 16: TAO_YY_RULE_SETUP return IDL_UNION; - TAO_YY_BREAK + TAO_YY_BREAK case 17: TAO_YY_RULE_SETUP return IDL_FIXED; - TAO_YY_BREAK + TAO_YY_BREAK case 18: TAO_YY_RULE_SETUP return IDL_SWITCH; - TAO_YY_BREAK + TAO_YY_BREAK case 19: TAO_YY_RULE_SETUP return IDL_CASE; - TAO_YY_BREAK + TAO_YY_BREAK case 20: TAO_YY_RULE_SETUP return IDL_DEFAULT; - TAO_YY_BREAK + TAO_YY_BREAK case 21: TAO_YY_RULE_SETUP return IDL_FLOAT; - TAO_YY_BREAK + TAO_YY_BREAK case 22: TAO_YY_RULE_SETUP return IDL_DOUBLE; - TAO_YY_BREAK + TAO_YY_BREAK case 23: TAO_YY_RULE_SETUP return IDL_LONG; - TAO_YY_BREAK + TAO_YY_BREAK case 24: TAO_YY_RULE_SETUP return IDL_SHORT; - TAO_YY_BREAK + TAO_YY_BREAK case 25: TAO_YY_RULE_SETUP return IDL_UNSIGNED; - TAO_YY_BREAK + TAO_YY_BREAK case 26: TAO_YY_RULE_SETUP return IDL_CHAR; - TAO_YY_BREAK + TAO_YY_BREAK case 27: TAO_YY_RULE_SETUP return IDL_WCHAR; - TAO_YY_BREAK + TAO_YY_BREAK case 28: TAO_YY_RULE_SETUP return IDL_BOOLEAN; - TAO_YY_BREAK + TAO_YY_BREAK case 29: TAO_YY_RULE_SETUP return IDL_OCTET; - TAO_YY_BREAK + TAO_YY_BREAK case 30: TAO_YY_RULE_SETUP return IDL_VOID; - TAO_YY_BREAK + TAO_YY_BREAK case 31: TAO_YY_RULE_SETUP return IDL_NATIVE; - TAO_YY_BREAK + TAO_YY_BREAK case 32: TAO_YY_RULE_SETUP return IDL_LOCAL; - TAO_YY_BREAK + TAO_YY_BREAK case 33: TAO_YY_RULE_SETUP return scan_obv_token (IDL_ABSTRACT); - TAO_YY_BREAK + TAO_YY_BREAK case 34: TAO_YY_RULE_SETUP return scan_obv_token (IDL_CUSTOM); - TAO_YY_BREAK + TAO_YY_BREAK case 35: TAO_YY_RULE_SETUP return scan_obv_token (IDL_FACTORY); - TAO_YY_BREAK + TAO_YY_BREAK case 36: TAO_YY_RULE_SETUP return scan_obv_token (IDL_PRIVATE); - TAO_YY_BREAK + TAO_YY_BREAK case 37: TAO_YY_RULE_SETUP return scan_obv_token (IDL_PUBLIC); - TAO_YY_BREAK + TAO_YY_BREAK case 38: TAO_YY_RULE_SETUP return scan_obv_token (IDL_SUPPORTS); - TAO_YY_BREAK + TAO_YY_BREAK case 39: TAO_YY_RULE_SETUP return scan_obv_token (IDL_TRUNCATABLE); - TAO_YY_BREAK + TAO_YY_BREAK case 40: TAO_YY_RULE_SETUP return scan_obv_token (IDL_VALUETYPE); - TAO_YY_BREAK + TAO_YY_BREAK case 41: TAO_YY_RULE_SETUP -return IDL_TRUETOK; - TAO_YY_BREAK +return scan_ccm_token (IDL_COMPONENT); + TAO_YY_BREAK case 42: TAO_YY_RULE_SETUP -return IDL_FALSETOK; - TAO_YY_BREAK +return scan_ccm_token (IDL_CONSUMES); + TAO_YY_BREAK case 43: TAO_YY_RULE_SETUP -return IDL_INOUT; - TAO_YY_BREAK +return scan_ccm_token (IDL_EMITS); + TAO_YY_BREAK case 44: TAO_YY_RULE_SETUP -return IDL_IN; - TAO_YY_BREAK +return scan_ccm_token (IDL_EVENTTYPE); + TAO_YY_BREAK case 45: TAO_YY_RULE_SETUP -return IDL_OUT; - TAO_YY_BREAK +return scan_ccm_token (IDL_FINDER); + TAO_YY_BREAK case 46: TAO_YY_RULE_SETUP -return IDL_ONEWAY; - TAO_YY_BREAK +return scan_ccm_token (IDL_GETRAISES); + TAO_YY_BREAK case 47: TAO_YY_RULE_SETUP -return IDL_LEFT_SHIFT; - TAO_YY_BREAK +return scan_ccm_token (IDL_HOME); + TAO_YY_BREAK case 48: TAO_YY_RULE_SETUP -return IDL_RIGHT_SHIFT; - TAO_YY_BREAK +return scan_ccm_token (IDL_IMPORT); + TAO_YY_BREAK case 49: TAO_YY_RULE_SETUP -{ - tao_yylval.strval = (char *) "::"; - return IDL_SCOPE_DELIMITOR; - } - TAO_YY_BREAK +return scan_ccm_token (IDL_MULTIPLE); + TAO_YY_BREAK case 50: TAO_YY_RULE_SETUP +return scan_ccm_token (IDL_PRIMARYKEY); + TAO_YY_BREAK +case 51: +TAO_YY_RULE_SETUP +return scan_ccm_token (IDL_PROVIDES); + TAO_YY_BREAK +case 52: +TAO_YY_RULE_SETUP +return scan_ccm_token (IDL_PUBLISHES); + TAO_YY_BREAK +case 53: +TAO_YY_RULE_SETUP +return scan_ccm_token (IDL_SETRAISES); + TAO_YY_BREAK +case 54: +TAO_YY_RULE_SETUP +return scan_ccm_token (IDL_TYPEID); + TAO_YY_BREAK +case 55: +TAO_YY_RULE_SETUP +return scan_ccm_token (IDL_TYPEPREFIX); + TAO_YY_BREAK +case 56: +TAO_YY_RULE_SETUP +return scan_ccm_token (IDL_USES); + TAO_YY_BREAK +case 57: +TAO_YY_RULE_SETUP +return scan_ccm_token (IDL_MANAGES); + TAO_YY_BREAK +case 58: +TAO_YY_RULE_SETUP +return IDL_TRUETOK; + TAO_YY_BREAK +case 59: +TAO_YY_RULE_SETUP +return IDL_FALSETOK; + TAO_YY_BREAK +case 60: +TAO_YY_RULE_SETUP +return IDL_INOUT; + TAO_YY_BREAK +case 61: +TAO_YY_RULE_SETUP +return IDL_IN; + TAO_YY_BREAK +case 62: +TAO_YY_RULE_SETUP +return IDL_OUT; + TAO_YY_BREAK +case 63: +TAO_YY_RULE_SETUP +return IDL_ONEWAY; + TAO_YY_BREAK +case 64: +TAO_YY_RULE_SETUP +return IDL_LEFT_SHIFT; + TAO_YY_BREAK +case 65: +TAO_YY_RULE_SETUP +return IDL_RIGHT_SHIFT; + TAO_YY_BREAK +case 66: +TAO_YY_RULE_SETUP +{ + tao_yylval.strval = (char *) "::"; + return IDL_SCOPE_DELIMITOR; + } + TAO_YY_BREAK +case 67: +TAO_YY_RULE_SETUP { // Make sure that this identifier is not a C++ keyword. If it is, // prepend it with a _cxx_. Lookup in the perfect hash table for C++ @@ -1300,225 +1433,228 @@ TAO_YY_RULE_SETUP if (entry) tao_yylval.strval = ACE_OS::strdup (entry->mapping_); else + { tao_yylval.strval = ACE_OS::strdup (ace_tao_yytext); + } return IDENTIFIER; } - TAO_YY_BREAK -case 51: + TAO_YY_BREAK +case 68: TAO_YY_RULE_SETUP { tao_yylval.dval = idl_atof(ace_tao_yytext); return IDL_FLOATING_PT_LITERAL; } - TAO_YY_BREAK -case 52: + TAO_YY_BREAK +case 69: TAO_YY_RULE_SETUP { tao_yylval.dval = idl_atof(ace_tao_yytext); return IDL_FLOATING_PT_LITERAL; } - TAO_YY_BREAK -case 53: + TAO_YY_BREAK +case 70: TAO_YY_RULE_SETUP { - tao_yylval.ival = idl_atoi(ace_tao_yytext, 10); - return IDL_INTEGER_LITERAL; - } - TAO_YY_BREAK -case 54: + tao_yylval.ival = idl_atoi(ace_tao_yytext, 10); + return IDL_INTEGER_LITERAL; + } + TAO_YY_BREAK +case 71: TAO_YY_RULE_SETUP { - tao_yylval.uival = idl_atoui(ace_tao_yytext, 10); - return IDL_UINTEGER_LITERAL; - } - TAO_YY_BREAK -case 55: + tao_yylval.uival = idl_atoui(ace_tao_yytext, 10); + return IDL_UINTEGER_LITERAL; + } + TAO_YY_BREAK +case 72: TAO_YY_RULE_SETUP { - tao_yylval.ival = idl_atoi(ace_tao_yytext, 16); - return IDL_INTEGER_LITERAL; - } - TAO_YY_BREAK -case 56: + tao_yylval.ival = idl_atoi(ace_tao_yytext, 16); + return IDL_INTEGER_LITERAL; + } + TAO_YY_BREAK +case 73: TAO_YY_RULE_SETUP { tao_yylval.uival = idl_atoui(ace_tao_yytext, 16); - return IDL_UINTEGER_LITERAL; - } - TAO_YY_BREAK -case 57: + return IDL_UINTEGER_LITERAL; + } + TAO_YY_BREAK +case 74: TAO_YY_RULE_SETUP { - tao_yylval.ival = idl_atoi(ace_tao_yytext, 8); - return IDL_INTEGER_LITERAL; - } - TAO_YY_BREAK -case 58: + tao_yylval.ival = idl_atoi(ace_tao_yytext, 8); + return IDL_INTEGER_LITERAL; + } + TAO_YY_BREAK +case 75: TAO_YY_RULE_SETUP { - tao_yylval.uival = idl_atoui(ace_tao_yytext, 8); - return IDL_UINTEGER_LITERAL; - } - TAO_YY_BREAK -case 59: + tao_yylval.uival = idl_atoui(ace_tao_yytext, 8); + return IDL_UINTEGER_LITERAL; + } + TAO_YY_BREAK +case 76: TAO_YY_RULE_SETUP { - /* Skip the quotes */ - char *tmp = ace_tao_yytext; - tmp[strlen(tmp)-1] = '\0'; - tao_yylval.sval = new UTL_String(tmp + 1); - return IDL_STRING_LITERAL; - } - TAO_YY_BREAK -case 60: + /* Skip the quotes */ + char *tmp = ace_tao_yytext; + tmp[strlen(tmp)-1] = '\0'; + tao_yylval.sval = new UTL_String(tmp + 1); + return IDL_STRING_LITERAL; + } + TAO_YY_BREAK +case 77: TAO_YY_RULE_SETUP { - /* Skip the bookends */ - char *tmp = ACE_OS::strdup (ace_tao_yytext); - tmp[strlen (tmp) - 1] = '\0'; - tao_yylval.wsval = idl_wstring_escape_reader(tmp + 2); - return IDL_WSTRING_LITERAL; - } - TAO_YY_BREAK -case 61: + /* Skip the bookends */ + char *tmp = ACE_OS::strdup (ace_tao_yytext); + tmp[strlen (tmp) - 1] = '\0'; + tao_yylval.wsval = idl_wstring_escape_reader(tmp + 2); + return IDL_WSTRING_LITERAL; + } + TAO_YY_BREAK +case 78: TAO_YY_RULE_SETUP { - tao_yylval.cval = ace_tao_yytext [1]; - return IDL_CHARACTER_LITERAL; - } - TAO_YY_BREAK -case 62: + tao_yylval.cval = ace_tao_yytext [1]; + return IDL_CHARACTER_LITERAL; + } + TAO_YY_BREAK +case 79: TAO_YY_RULE_SETUP { - // octal character constant - tao_yylval.cval = idl_escape_reader(ace_tao_yytext + 1); - return IDL_CHARACTER_LITERAL; - } - TAO_YY_BREAK -case 63: + // octal character constant + tao_yylval.cval = idl_escape_reader(ace_tao_yytext + 1); + return IDL_CHARACTER_LITERAL; + } + TAO_YY_BREAK +case 80: TAO_YY_RULE_SETUP { - // hexadecimal character constant - tao_yylval.cval = idl_escape_reader(ace_tao_yytext + 1); - return IDL_CHARACTER_LITERAL; - } - TAO_YY_BREAK -case 64: + // hexadecimal character constant + tao_yylval.cval = idl_escape_reader(ace_tao_yytext + 1); + return IDL_CHARACTER_LITERAL; + } + TAO_YY_BREAK +case 81: TAO_YY_RULE_SETUP { - tao_yylval.cval = idl_escape_reader(ace_tao_yytext + 1); - return IDL_CHARACTER_LITERAL; - } - TAO_YY_BREAK -case 65: + tao_yylval.cval = idl_escape_reader(ace_tao_yytext + 1); + return IDL_CHARACTER_LITERAL; + } + TAO_YY_BREAK +case 82: TAO_YY_RULE_SETUP { - // wide character constant - tao_yylval.wcval = ace_tao_yytext [2]; - return IDL_WCHAR_LITERAL; - } - TAO_YY_BREAK -case 66: + // wide character constant + tao_yylval.wcval = ace_tao_yytext [2]; + return IDL_WCHAR_LITERAL; + } + TAO_YY_BREAK +case 83: TAO_YY_RULE_SETUP { - // hexadecimal wide character constant - tao_yylval.wcval = idl_wchar_escape_reader(ace_tao_yytext + 2); - return IDL_WCHAR_LITERAL; - } - TAO_YY_BREAK -case 67: -case 68: + // hexadecimal wide character constant + tao_yylval.wcval = idl_wchar_escape_reader(ace_tao_yytext + 2); + return IDL_WCHAR_LITERAL; + } + TAO_YY_BREAK +case 84: +case 85: TAO_YY_RULE_SETUP {/* remember pragma */ - idl_global->set_lineno(idl_global->lineno() + 1); - idl_store_pragma(ace_tao_yytext); -} + idl_global->set_lineno(idl_global->lineno() + 1); + idl_store_pragma(ace_tao_yytext); + } break; -case 69: -case 70: +case 86: +case 87: TAO_YY_RULE_SETUP {/* ignore file */ - idl_global->set_lineno(idl_global->lineno() + 1); - } - break; -case 71: -case 72: + idl_global->set_lineno(idl_global->lineno() + 1); + } + TAO_YY_BREAK +case 88: +case 89: TAO_YY_RULE_SETUP { - idl_parse_line_and_file(ace_tao_yytext); - } - break; -case 73: -case 74: + idl_parse_line_and_file(ace_tao_yytext); + } + TAO_YY_BREAK +case 90: +case 91: TAO_YY_RULE_SETUP { - idl_parse_line_and_file(ace_tao_yytext); - } - break; -case 75: -case 76: + idl_parse_line_and_file(ace_tao_yytext); + } + break; +case 92: +case 93: TAO_YY_RULE_SETUP { - idl_parse_line_and_file(ace_tao_yytext); - } - break; -case 77: -case 78: + idl_parse_line_and_file(ace_tao_yytext); + } + break; +case 94: +case 95: TAO_YY_RULE_SETUP { - idl_parse_line_and_file(ace_tao_yytext); - } - break; -case 79: -case 80: + idl_parse_line_and_file(ace_tao_yytext); + } + break; +case 96: +case 97: TAO_YY_RULE_SETUP { - /* ignore cpp ident */ - idl_global->set_lineno(idl_global->lineno() + 1); - } - break; -case 81: + /* ignore cpp ident */ + idl_global->set_lineno(idl_global->lineno() + 1); + } + break; +case 98: TAO_YY_RULE_SETUP { - /* ignore comments */ - idl_global->set_lineno(idl_global->lineno() + 1); - } - break; -case 82: + /* ignore comments */ + idl_global->set_lineno(idl_global->lineno() + 1); + } + break; +case 99: TAO_YY_RULE_SETUP { - for(;;) { - char c = tao_yyinput(); - if (c == '*') { - char next = tao_yyinput(); - if (next == '/') - break; - else - tao_yyunput(c, NULL); - if (c == '\n') - idl_global->set_lineno(idl_global->lineno() + 1); - } - } - } - break; -case 83: + for(;;) { + char c = tao_yyinput(); + if (c == '*') { + char next = tao_yyinput(); + if (next == '/') + break; + else + tao_yyunput(c, NULL); + if (c == '\n') + idl_global->set_lineno(idl_global->lineno() + 1); + } + } + } + break; +case 100: TAO_YY_RULE_SETUP ; - break; -case 84: + break; +case 101: TAO_YY_RULE_SETUP { - idl_global->set_lineno(idl_global->lineno() + 1); - } - break; -case 85: + idl_global->set_lineno(idl_global->lineno() + 1); + } + break; +case 102: TAO_YY_RULE_SETUP return ace_tao_yytext [0]; -case 86: + break; +case 103: TAO_YY_RULE_SETUP TAO_YY_ECHO; - break; + break; case TAO_YY_STATE_EOF(INITIAL): tao_yyterminate(); @@ -1651,67 +1787,68 @@ case TAO_YY_STATE_EOF(INITIAL): } /* end of scanning one token */ } /* end of tao_yylex */ + /* tao_yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file */ static int tao_yy_get_next_buffer() - { - register char *dest = tao_yy_current_buffer->tao_yy_ch_buf; - register char *source = tao_yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( tao_yy_c_buf_p > &tao_yy_current_buffer->tao_yy_ch_buf[tao_yy_n_chars + 1] ) - TAO_YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( tao_yy_current_buffer->tao_yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( tao_yy_c_buf_p - tao_yytext_ptr - TAO_YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } + { + register char *dest = tao_yy_current_buffer->tao_yy_ch_buf; + register char *source = tao_yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( tao_yy_c_buf_p > &tao_yy_current_buffer->tao_yy_ch_buf[tao_yy_n_chars + 1] ) + TAO_YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( tao_yy_current_buffer->tao_yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( tao_yy_c_buf_p - tao_yytext_ptr - TAO_YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } - /* Try to read more data. */ + /* Try to read more data. */ - /* First move last chars to start of buffer. */ - number_to_move = (int) (tao_yy_c_buf_p - tao_yytext_ptr) - 1; + /* First move last chars to start of buffer. */ + number_to_move = (int) (tao_yy_c_buf_p - tao_yytext_ptr) - 1; - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); - if ( tao_yy_current_buffer->tao_yy_buffer_status == TAO_YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - tao_yy_current_buffer->tao_yy_n_chars = tao_yy_n_chars = 0; + if ( tao_yy_current_buffer->tao_yy_buffer_status == TAO_YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + tao_yy_current_buffer->tao_yy_n_chars = tao_yy_n_chars = 0; - else - { - int num_to_read = - tao_yy_current_buffer->tao_yy_buf_size - number_to_move - 1; + else + { + int num_to_read = + tao_yy_current_buffer->tao_yy_buf_size - number_to_move - 1; - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ #ifdef TAO_YY_USES_REJECT - TAO_YY_FATAL_ERROR( + TAO_YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); #else @@ -1788,41 +1925,42 @@ static int tao_yy_get_next_buffer() return ret_val; } + /* tao_yy_get_previous_state - get the state just before the EOB char was reached */ static tao_yy_state_type tao_yy_get_previous_state() - { - register tao_yy_state_type tao_yy_current_state; - register char *tao_yy_cp; - - tao_yy_current_state = tao_yy_start; - tao_yy_current_state += TAO_YY_AT_BOL(); - - for ( tao_yy_cp = tao_yytext_ptr + TAO_YY_MORE_ADJ; tao_yy_cp < tao_yy_c_buf_p; ++tao_yy_cp ) - { - register TAO_YY_CHAR tao_yy_c = (*tao_yy_cp ? tao_yy_ec[TAO_YY_SC_TO_UI(*tao_yy_cp)] : 1); - if ( tao_yy_accept[tao_yy_current_state] ) - { - tao_yy_last_accepting_state = tao_yy_current_state; - tao_yy_last_accepting_cpos = tao_yy_cp; - } - while ( tao_yy_chk[tao_yy_base[tao_yy_current_state] + tao_yy_c] != tao_yy_current_state ) - { - tao_yy_current_state = (int) tao_yy_def[tao_yy_current_state]; - if ( tao_yy_current_state >= 445 ) - tao_yy_c = tao_yy_meta[(unsigned int) tao_yy_c]; - } - tao_yy_current_state = tao_yy_nxt[tao_yy_base[tao_yy_current_state] + (unsigned int) tao_yy_c]; - } + { + register tao_yy_state_type tao_yy_current_state; + register char *tao_yy_cp; - return tao_yy_current_state; - } + tao_yy_current_state = tao_yy_start; + tao_yy_current_state += TAO_YY_AT_BOL(); + + for ( tao_yy_cp = tao_yytext_ptr + TAO_YY_MORE_ADJ; tao_yy_cp < tao_yy_c_buf_p; ++tao_yy_cp ) + { + register TAO_YY_CHAR tao_yy_c = (*tao_yy_cp ? tao_yy_ec[TAO_YY_SC_TO_UI(*tao_yy_cp)] : 1); + if ( tao_yy_accept[tao_yy_current_state] ) + { + tao_yy_last_accepting_state = tao_yy_current_state; + tao_yy_last_accepting_cpos = tao_yy_cp; + } + while ( tao_yy_chk[tao_yy_base[tao_yy_current_state] + tao_yy_c] != tao_yy_current_state ) + { + tao_yy_current_state = (int) tao_yy_def[tao_yy_current_state]; + if ( tao_yy_current_state >= 538 ) + tao_yy_c = tao_yy_meta[(unsigned int) tao_yy_c]; + } + tao_yy_current_state = tao_yy_nxt[tao_yy_base[tao_yy_current_state] + (unsigned int) tao_yy_c]; + } + + return tao_yy_current_state; + } /* tao_yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis - * next_state = tao_yy_try_NUL_trans( current_state ); + * next_state = tao_yy_try_NUL_trans( current_state ); */ #ifdef TAO_YY_USE_PROTOS @@ -1831,27 +1969,27 @@ static tao_yy_state_type tao_yy_try_NUL_trans( tao_yy_state_type tao_yy_current_ static tao_yy_state_type tao_yy_try_NUL_trans( tao_yy_current_state ) tao_yy_state_type tao_yy_current_state; #endif - { - register int tao_yy_is_jam; - register char *tao_yy_cp = tao_yy_c_buf_p; - - register TAO_YY_CHAR tao_yy_c = 1; - if ( tao_yy_accept[tao_yy_current_state] ) - { - tao_yy_last_accepting_state = tao_yy_current_state; - tao_yy_last_accepting_cpos = tao_yy_cp; - } - while ( tao_yy_chk[tao_yy_base[tao_yy_current_state] + tao_yy_c] != tao_yy_current_state ) - { - tao_yy_current_state = (int) tao_yy_def[tao_yy_current_state]; - if ( tao_yy_current_state >= 445 ) - tao_yy_c = tao_yy_meta[(unsigned int) tao_yy_c]; - } - tao_yy_current_state = tao_yy_nxt[tao_yy_base[tao_yy_current_state] + (unsigned int) tao_yy_c]; - tao_yy_is_jam = (tao_yy_current_state == 444); + { + register int tao_yy_is_jam; + register char *tao_yy_cp = tao_yy_c_buf_p; - return tao_yy_is_jam ? 0 : tao_yy_current_state; - } + register TAO_YY_CHAR tao_yy_c = 1; + if ( tao_yy_accept[tao_yy_current_state] ) + { + tao_yy_last_accepting_state = tao_yy_current_state; + tao_yy_last_accepting_cpos = tao_yy_cp; + } + while ( tao_yy_chk[tao_yy_base[tao_yy_current_state] + tao_yy_c] != tao_yy_current_state ) + { + tao_yy_current_state = (int) tao_yy_def[tao_yy_current_state]; + if ( tao_yy_current_state >= 538 ) + tao_yy_c = tao_yy_meta[(unsigned int) tao_yy_c]; + } + tao_yy_current_state = tao_yy_nxt[tao_yy_base[tao_yy_current_state] + (unsigned int) tao_yy_c]; + tao_yy_is_jam = (tao_yy_current_state == 537); + + return tao_yy_is_jam ? 0 : tao_yy_current_state; + } #ifndef TAO_YY_NO_UNPUT @@ -1862,41 +2000,41 @@ static void tao_yyunput( c, tao_yy_bp ) int c; register char *tao_yy_bp; #endif - { - register char *tao_yy_cp = tao_yy_c_buf_p; - - /* undo effects of setting up tao_yytext */ - *tao_yy_cp = tao_yy_hold_char; - - if ( tao_yy_cp < tao_yy_current_buffer->tao_yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = tao_yy_n_chars + 2; - register char *dest = &tao_yy_current_buffer->tao_yy_ch_buf[ - tao_yy_current_buffer->tao_yy_buf_size + 2]; - register char *source = - &tao_yy_current_buffer->tao_yy_ch_buf[number_to_move]; - - while ( source > tao_yy_current_buffer->tao_yy_ch_buf ) - *--dest = *--source; - - tao_yy_cp += (int) (dest - source); - tao_yy_bp += (int) (dest - source); - tao_yy_current_buffer->tao_yy_n_chars = - tao_yy_n_chars = tao_yy_current_buffer->tao_yy_buf_size; - - if ( tao_yy_cp < tao_yy_current_buffer->tao_yy_ch_buf + 2 ) - TAO_YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } + { + register char *tao_yy_cp = tao_yy_c_buf_p; + + /* undo effects of setting up tao_yytext */ + *tao_yy_cp = tao_yy_hold_char; + + if ( tao_yy_cp < tao_yy_current_buffer->tao_yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = tao_yy_n_chars + 2; + register char *dest = &tao_yy_current_buffer->tao_yy_ch_buf[ + tao_yy_current_buffer->tao_yy_buf_size + 2]; + register char *source = + &tao_yy_current_buffer->tao_yy_ch_buf[number_to_move]; + + while ( source > tao_yy_current_buffer->tao_yy_ch_buf ) + *--dest = *--source; + + tao_yy_cp += (int) (dest - source); + tao_yy_bp += (int) (dest - source); + tao_yy_current_buffer->tao_yy_n_chars = + tao_yy_n_chars = tao_yy_current_buffer->tao_yy_buf_size; + + if ( tao_yy_cp < tao_yy_current_buffer->tao_yy_ch_buf + 2 ) + TAO_YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } - *--tao_yy_cp = (char) c; + *--tao_yy_cp = (char) c; - tao_yytext_ptr = tao_yy_bp; - tao_yy_hold_char = *tao_yy_cp; - tao_yy_c_buf_p = tao_yy_cp; - } -#endif /* ifndef TAO_YY_NO_UNPUT */ + tao_yytext_ptr = tao_yy_bp; + tao_yy_hold_char = *tao_yy_cp; + tao_yy_c_buf_p = tao_yy_cp; + } +#endif /* ifndef TAO_YY_NO_UNPUT */ #ifdef __cplusplus @@ -1904,73 +2042,73 @@ static int tao_yyinput() #else static int input() #endif - { - int c; - - *tao_yy_c_buf_p = tao_yy_hold_char; - - if ( *tao_yy_c_buf_p == TAO_YY_END_OF_BUFFER_CHAR ) - { - /* tao_yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( tao_yy_c_buf_p < &tao_yy_current_buffer->tao_yy_ch_buf[tao_yy_n_chars] ) - /* This was really a NUL. */ - *tao_yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = tao_yy_c_buf_p - tao_yytext_ptr; - ++tao_yy_c_buf_p; - - switch ( tao_yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because tao_yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - tao_yyrestart( tao_yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( tao_yywrap() ) - return EOF; - - if ( ! tao_yy_did_buffer_switch_on_eof ) - TAO_YY_NEW_FILE; + { + int c; + + *tao_yy_c_buf_p = tao_yy_hold_char; + + if ( *tao_yy_c_buf_p == TAO_YY_END_OF_BUFFER_CHAR ) + { + /* tao_yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( tao_yy_c_buf_p < &tao_yy_current_buffer->tao_yy_ch_buf[tao_yy_n_chars] ) + /* This was really a NUL. */ + *tao_yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = tao_yy_c_buf_p - tao_yytext_ptr; + ++tao_yy_c_buf_p; + + switch ( tao_yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because tao_yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + tao_yyrestart( tao_yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( tao_yywrap() ) + return EOF; + + if ( ! tao_yy_did_buffer_switch_on_eof ) + TAO_YY_NEW_FILE; #ifdef __cplusplus - return tao_yyinput(); + return tao_yyinput(); #else - return input(); + return input(); #endif - } + } - case EOB_ACT_CONTINUE_SCAN: - tao_yy_c_buf_p = tao_yytext_ptr + offset; - break; - } - } - } + case EOB_ACT_CONTINUE_SCAN: + tao_yy_c_buf_p = tao_yytext_ptr + offset; + break; + } + } + } - c = *(unsigned char *) tao_yy_c_buf_p; /* cast for 8-bit char's */ - *tao_yy_c_buf_p = '\0'; /* preserve tao_yytext */ - tao_yy_hold_char = *++tao_yy_c_buf_p; + c = *(unsigned char *) tao_yy_c_buf_p; /* cast for 8-bit char's */ + *tao_yy_c_buf_p = '\0'; /* preserve tao_yytext */ + tao_yy_hold_char = *++tao_yy_c_buf_p; - tao_yy_current_buffer->tao_yy_at_bol = (c == '\n'); + tao_yy_current_buffer->tao_yy_at_bol = (c == '\n'); - return c; - } + return c; + } #ifdef TAO_YY_USE_PROTOS @@ -1979,13 +2117,13 @@ void tao_yyrestart( FILE *input_file ) void tao_yyrestart( input_file ) FILE *input_file; #endif - { - if ( ! tao_yy_current_buffer ) - tao_yy_current_buffer = tao_yy_create_buffer( tao_yyin, TAO_YY_BUF_SIZE ); + { + if ( ! tao_yy_current_buffer ) + tao_yy_current_buffer = tao_yy_create_buffer( tao_yyin, TAO_YY_BUF_SIZE ); - tao_yy_init_buffer( tao_yy_current_buffer, input_file ); - tao_yy_load_buffer_state(); - } + tao_yy_init_buffer( tao_yy_current_buffer, input_file ); + tao_yy_load_buffer_state(); + } #ifdef TAO_YY_USE_PROTOS @@ -2017,17 +2155,18 @@ TAO_YY_BUFFER_STATE new_buffer; tao_yy_did_buffer_switch_on_eof = 1; } + #ifdef TAO_YY_USE_PROTOS void tao_yy_load_buffer_state( void ) #else void tao_yy_load_buffer_state() #endif - { - tao_yy_n_chars = tao_yy_current_buffer->tao_yy_n_chars; - tao_yytext_ptr = tao_yy_c_buf_p = tao_yy_current_buffer->tao_yy_buf_pos; - tao_yyin = tao_yy_current_buffer->tao_yy_input_file; - tao_yy_hold_char = *tao_yy_c_buf_p; - } + { + tao_yy_n_chars = tao_yy_current_buffer->tao_yy_n_chars; + tao_yytext_ptr = tao_yy_c_buf_p = tao_yy_current_buffer->tao_yy_buf_pos; + tao_yyin = tao_yy_current_buffer->tao_yy_input_file; + tao_yy_hold_char = *tao_yy_c_buf_p; + } #ifdef TAO_YY_USE_PROTOS @@ -2037,28 +2176,28 @@ TAO_YY_BUFFER_STATE tao_yy_create_buffer( file, size ) FILE *file; int size; #endif - { - TAO_YY_BUFFER_STATE b; + { + TAO_YY_BUFFER_STATE b; - b = (TAO_YY_BUFFER_STATE) tao_yy_flex_alloc( sizeof( struct tao_yy_buffer_state ) ); - if ( ! b ) - TAO_YY_FATAL_ERROR( "out of dynamic memory in tao_yy_create_buffer()" ); + b = (TAO_YY_BUFFER_STATE) tao_yy_flex_alloc( sizeof( struct tao_yy_buffer_state ) ); + if ( ! b ) + TAO_YY_FATAL_ERROR( "out of dynamic memory in tao_yy_create_buffer()" ); - b->tao_yy_buf_size = size; + b->tao_yy_buf_size = size; - /* tao_yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->tao_yy_ch_buf = (char *) tao_yy_flex_alloc( b->tao_yy_buf_size + 2 ); - if ( ! b->tao_yy_ch_buf ) - TAO_YY_FATAL_ERROR( "out of dynamic memory in tao_yy_create_buffer()" ); + /* tao_yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->tao_yy_ch_buf = (char *) tao_yy_flex_alloc( b->tao_yy_buf_size + 2 ); + if ( ! b->tao_yy_ch_buf ) + TAO_YY_FATAL_ERROR( "out of dynamic memory in tao_yy_create_buffer()" ); - b->tao_yy_is_our_buffer = 1; + b->tao_yy_is_our_buffer = 1; - tao_yy_init_buffer( b, file ); + tao_yy_init_buffer( b, file ); - return b; - } + return b; + } #ifdef TAO_YY_USE_PROTOS @@ -2067,18 +2206,18 @@ void tao_yy_delete_buffer( TAO_YY_BUFFER_STATE b ) void tao_yy_delete_buffer( b ) TAO_YY_BUFFER_STATE b; #endif - { - if ( ! b ) - return; + { + if ( ! b ) + return; - if ( b == tao_yy_current_buffer ) - tao_yy_current_buffer = (TAO_YY_BUFFER_STATE) 0; + if ( b == tao_yy_current_buffer ) + tao_yy_current_buffer = (TAO_YY_BUFFER_STATE) 0; - if ( b->tao_yy_is_our_buffer ) - tao_yy_flex_free( (void *) b->tao_yy_ch_buf ); + if ( b->tao_yy_is_our_buffer ) + tao_yy_flex_free( (void *) b->tao_yy_ch_buf ); - tao_yy_flex_free( (void *) b ); - } + tao_yy_flex_free( (void *) b ); + } #ifndef TAO_YY_ALWAYS_INTERACTIVE @@ -2096,22 +2235,22 @@ FILE *file; #endif - { - tao_yy_flush_buffer( b ); + { + tao_yy_flush_buffer( b ); - b->tao_yy_input_file = file; - b->tao_yy_fill_buffer = 1; + b->tao_yy_input_file = file; + b->tao_yy_fill_buffer = 1; #if TAO_YY_ALWAYS_INTERACTIVE - b->tao_yy_is_interactive = 1; + b->tao_yy_is_interactive = 1; #else #if TAO_YY_NEVER_INTERACTIVE - b->tao_yy_is_interactive = 0; + b->tao_yy_is_interactive = 0; #else - b->tao_yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + b->tao_yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; #endif #endif - } + } #ifdef TAO_YY_USE_PROTOS @@ -2121,27 +2260,27 @@ void tao_yy_flush_buffer( b ) TAO_YY_BUFFER_STATE b; #endif - { - if ( ! b ) - return; + { + if ( ! b ) + return; - b->tao_yy_n_chars = 0; + b->tao_yy_n_chars = 0; - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->tao_yy_ch_buf[0] = TAO_YY_END_OF_BUFFER_CHAR; - b->tao_yy_ch_buf[1] = TAO_YY_END_OF_BUFFER_CHAR; + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->tao_yy_ch_buf[0] = TAO_YY_END_OF_BUFFER_CHAR; + b->tao_yy_ch_buf[1] = TAO_YY_END_OF_BUFFER_CHAR; - b->tao_yy_buf_pos = &b->tao_yy_ch_buf[0]; + b->tao_yy_buf_pos = &b->tao_yy_ch_buf[0]; - b->tao_yy_at_bol = 1; - b->tao_yy_buffer_status = TAO_YY_BUFFER_NEW; + b->tao_yy_at_bol = 1; + b->tao_yy_buffer_status = TAO_YY_BUFFER_NEW; - if ( b == tao_yy_current_buffer ) - tao_yy_load_buffer_state(); - } + if ( b == tao_yy_current_buffer ) + tao_yy_load_buffer_state(); + } #ifndef TAO_YY_NO_SCAN_BUFFER @@ -2152,33 +2291,33 @@ TAO_YY_BUFFER_STATE tao_yy_scan_buffer( base, size ) char *base; tao_yy_size_t size; #endif - { - TAO_YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != TAO_YY_END_OF_BUFFER_CHAR || - base[size-1] != TAO_YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (TAO_YY_BUFFER_STATE) tao_yy_flex_alloc( sizeof( struct tao_yy_buffer_state ) ); - if ( ! b ) - TAO_YY_FATAL_ERROR( "out of dynamic memory in tao_yy_scan_buffer()" ); - - b->tao_yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->tao_yy_buf_pos = b->tao_yy_ch_buf = base; - b->tao_yy_is_our_buffer = 0; - b->tao_yy_input_file = 0; - b->tao_yy_n_chars = b->tao_yy_buf_size; - b->tao_yy_is_interactive = 0; - b->tao_yy_at_bol = 1; - b->tao_yy_fill_buffer = 0; - b->tao_yy_buffer_status = TAO_YY_BUFFER_NEW; - - tao_yy_switch_to_buffer( b ); - - return b; - } + { + TAO_YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != TAO_YY_END_OF_BUFFER_CHAR || + base[size-1] != TAO_YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (TAO_YY_BUFFER_STATE) tao_yy_flex_alloc( sizeof( struct tao_yy_buffer_state ) ); + if ( ! b ) + TAO_YY_FATAL_ERROR( "out of dynamic memory in tao_yy_scan_buffer()" ); + + b->tao_yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->tao_yy_buf_pos = b->tao_yy_ch_buf = base; + b->tao_yy_is_our_buffer = 0; + b->tao_yy_input_file = 0; + b->tao_yy_n_chars = b->tao_yy_buf_size; + b->tao_yy_is_interactive = 0; + b->tao_yy_at_bol = 1; + b->tao_yy_fill_buffer = 0; + b->tao_yy_buffer_status = TAO_YY_BUFFER_NEW; + + tao_yy_switch_to_buffer( b ); + + return b; + } #endif @@ -2189,13 +2328,13 @@ TAO_YY_BUFFER_STATE tao_yy_scan_string( tao_yyconst char *tao_yy_str ) TAO_YY_BUFFER_STATE tao_yy_scan_string( tao_yy_str ) tao_yyconst char *tao_yy_str; #endif - { - int len; - for ( len = 0; tao_yy_str[len]; ++len ) - ; + { + int len; + for ( len = 0; tao_yy_str[len]; ++len ) + ; - return tao_yy_scan_bytes( tao_yy_str, len ); - } + return tao_yy_scan_bytes( tao_yy_str, len ); + } #endif @@ -2207,34 +2346,34 @@ TAO_YY_BUFFER_STATE tao_yy_scan_bytes( bytes, len ) tao_yyconst char *bytes; int len; #endif - { - TAO_YY_BUFFER_STATE b; - char *buf; - tao_yy_size_t n; - int i; + { + TAO_YY_BUFFER_STATE b; + char *buf; + tao_yy_size_t n; + int i; - /* Get memory for full buffer, including space for trailing EOB's. */ - n = len + 2; - buf = (char *) tao_yy_flex_alloc( n ); - if ( ! buf ) - TAO_YY_FATAL_ERROR( "out of dynamic memory in tao_yy_scan_bytes()" ); + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) tao_yy_flex_alloc( n ); + if ( ! buf ) + TAO_YY_FATAL_ERROR( "out of dynamic memory in tao_yy_scan_bytes()" ); - for ( i = 0; i < len; ++i ) - buf[i] = bytes[i]; + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; - buf[len] = buf[len+1] = TAO_YY_END_OF_BUFFER_CHAR; + buf[len] = buf[len+1] = TAO_YY_END_OF_BUFFER_CHAR; - b = tao_yy_scan_buffer( buf, n ); - if ( ! b ) - TAO_YY_FATAL_ERROR( "bad buffer in tao_yy_scan_bytes()" ); + b = tao_yy_scan_buffer( buf, n ); + if ( ! b ) + TAO_YY_FATAL_ERROR( "bad buffer in tao_yy_scan_bytes()" ); - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->tao_yy_is_our_buffer = 1; + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->tao_yy_is_our_buffer = 1; - return b; - } + return b; + } #endif @@ -2245,49 +2384,49 @@ static void tao_yy_push_state( int new_state ) static void tao_yy_push_state( new_state ) int new_state; #endif - { - if ( tao_yy_start_stack_ptr >= tao_yy_start_stack_depth ) - { - tao_yy_size_t new_size; + { + if ( tao_yy_start_stack_ptr >= tao_yy_start_stack_depth ) + { + tao_yy_size_t new_size; - tao_yy_start_stack_depth += TAO_YY_START_STACK_INCR; - new_size = tao_yy_start_stack_depth * sizeof( int ); + tao_yy_start_stack_depth += TAO_YY_START_STACK_INCR; + new_size = tao_yy_start_stack_depth * sizeof( int ); - if ( ! tao_yy_start_stack ) - tao_yy_start_stack = (int *) tao_yy_flex_alloc( new_size ); + if ( ! tao_yy_start_stack ) + tao_yy_start_stack = (int *) tao_yy_flex_alloc( new_size ); - else - tao_yy_start_stack = (int *) tao_yy_flex_realloc( - (void *) tao_yy_start_stack, new_size ); + else + tao_yy_start_stack = (int *) tao_yy_flex_realloc( + (void *) tao_yy_start_stack, new_size ); - if ( ! tao_yy_start_stack ) - TAO_YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } + if ( ! tao_yy_start_stack ) + TAO_YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } - tao_yy_start_stack[tao_yy_start_stack_ptr++] = TAO_YY_START; + tao_yy_start_stack[tao_yy_start_stack_ptr++] = TAO_YY_START; - BEGIN(new_state); - } + BEGIN(new_state); + } #endif #ifndef TAO_YY_NO_POP_STATE static void tao_yy_pop_state() - { - if ( --tao_yy_start_stack_ptr < 0 ) - TAO_YY_FATAL_ERROR( "start-condition stack underflow" ); + { + if ( --tao_yy_start_stack_ptr < 0 ) + TAO_YY_FATAL_ERROR( "start-condition stack underflow" ); - BEGIN(tao_yy_start_stack[tao_yy_start_stack_ptr]); - } + BEGIN(tao_yy_start_stack[tao_yy_start_stack_ptr]); + } #endif #ifndef TAO_YY_NO_TOP_STATE static int tao_yy_top_state() - { - return tao_yy_start_stack[tao_yy_start_stack_ptr - 1]; - } + { + return tao_yy_start_stack[tao_yy_start_stack_ptr - 1]; + } #endif #ifndef TAO_YY_EXIT_FAILURE @@ -2300,10 +2439,10 @@ static void tao_yy_fatal_error( tao_yyconst char msg[] ) static void tao_yy_fatal_error( msg ) char msg[]; #endif - { - (void) fprintf( stderr, "%s\n", msg ); - exit( TAO_YY_EXIT_FAILURE ); - } + { + (void) fprintf( stderr, "%s\n", msg ); + exit( TAO_YY_EXIT_FAILURE ); + } @@ -2311,16 +2450,16 @@ char msg[]; #undef tao_yyless #define tao_yyless(n) \ - do \ - { \ - /* Undo effects of setting up tao_yytext. */ \ - tao_yytext[tao_yyleng] = tao_yy_hold_char; \ - tao_yy_c_buf_p = tao_yytext + n; \ - tao_yy_hold_char = *tao_yy_c_buf_p; \ - *tao_yy_c_buf_p = '\0'; \ - tao_yyleng = n; \ - } \ - while ( 0 ) + do \ + { \ + /* Undo effects of setting up tao_yytext. */ \ + tao_yytext[tao_yyleng] = tao_yy_hold_char; \ + tao_yy_c_buf_p = tao_yytext + n; \ + tao_yy_hold_char = *tao_yy_c_buf_p; \ + *tao_yy_c_buf_p = '\0'; \ + tao_yyleng = n; \ + } \ + while ( 0 ) /* Internal utility routines. */ @@ -2334,11 +2473,11 @@ char *s1; tao_yyconst char *s2; int n; #endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } #endif #ifdef TAO_YY_NEED_STRLEN @@ -2348,13 +2487,13 @@ static int tao_yy_flex_strlen( tao_yyconst char *s ) static int tao_yy_flex_strlen( s ) tao_yyconst char *s; #endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; + { + register int n; + for ( n = 0; s[n]; ++n ) + ; - return n; - } + return n; + } #endif @@ -2364,9 +2503,9 @@ static void *tao_yy_flex_alloc( tao_yy_size_t size ) static void *tao_yy_flex_alloc( size ) tao_yy_size_t size; #endif - { - return (void *) malloc( size ); - } + { + return (void *) malloc( size ); + } #ifdef TAO_YY_USE_PROTOS static void *tao_yy_flex_realloc( void *ptr, tao_yy_size_t size ) @@ -2375,16 +2514,16 @@ static void *tao_yy_flex_realloc( ptr, size ) void *ptr; tao_yy_size_t size; #endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } #ifdef TAO_YY_USE_PROTOS static void tao_yy_flex_free( void *ptr ) @@ -2392,19 +2531,19 @@ static void tao_yy_flex_free( void *ptr ) static void tao_yy_flex_free( ptr ) void *ptr; #endif - { - free( ptr ); - } + { + free( ptr ); + } #if TAO_YY_MAIN int main() - { - tao_yylex(); - return 0; - } + { + tao_yylex(); + return 0; + } #endif - /* subroutines */ + /* subroutines */ /* * Strip down a name to the last component, i.e. everything after the last @@ -2413,11 +2552,11 @@ int main() static char * stripped_name(UTL_String *fn) { - char *n = fn->get_string(); - long l; + char *n = fn->get_string(); + long l; if (n == NULL) - return NULL; + return NULL; l = strlen(n); for (n += l; l > 0 && *n != '/'; l--, n--); if (*n == '/') n++; @@ -2532,7 +2671,7 @@ idl_parse_line_and_file (char *buf) idl_global->set_in_main_file (in_main_file); // If it's an import file store the stripped name for the BE to use - if (!(idl_global->in_main_file ()) && idl_global->import ()) + if (!(idl_global->in_main_file ()) && idl_global->import ()) { ACE_NEW (nm, UTL_String (stripped_name (fname))); @@ -2540,7 +2679,9 @@ idl_parse_line_and_file (char *buf) // This call also manages the #pragma prefix. idl_global->store_include_file_name (nm); } - else if (is_main_filename && idl_global->pragma_prefixes ().size () > 1) + else if (is_main_filename + && idl_global->pragma_prefixes ().size () > 1 + && idl_global->scopes ().depth () == 1) { // If we're here, we have come to the end of an included file, so we // pop its prefix. @@ -2605,12 +2746,12 @@ idl_store_pragma (char *buf) if (new_prefix != 0) { - unsigned long depth = idl_global->scopes ()->depth (); + unsigned long depth = idl_global->scopes ().depth (); // At global scope, we always replace the prefix. For all // other scopes, we replace only if there is a prefix already // associated with that scope, otherwise we add the prefix. - if (depth == 1 || idl_global->scopes ()->top ()->has_prefix ()) + if (depth == 1 || idl_global->scopes ().top ()->has_prefix ()) { char *trash = 0; idl_global->pragma_prefixes ().pop (trash); @@ -2619,7 +2760,7 @@ idl_store_pragma (char *buf) if (depth > 1) { - idl_global->scopes ()->top ()->has_prefix (1); + idl_global->scopes ().top ()->has_prefix (1); } idl_global->pragma_prefixes ().push (new_prefix); @@ -2656,7 +2797,7 @@ idl_store_pragma (char *buf) d->version (ACE::strnew (number)); } - else if (ACE_OS::strncmp (buf + 8, "ident", 5) == 0) + else if (ACE_OS::strncmp (buf + 8, "ident", 5) == 0) { idl_global->ident_string (buf + 8); } @@ -2691,25 +2832,25 @@ idl_store_pragma (char *buf) static long idl_atoi(char *s, long b) { - long r = 0; - s++; - - if (b == 8 && *s == '0') - s++; - else if (b == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X')) - s += 2; - - for (; *s; s++) - if (*s <= '9' && *s >= '0') - r = (r * b) + (*s - '0'); - else if (b > 10 && *s <= 'f' && *s >= 'a') - r = (r * b) + (*s - 'a' + 10); - else if (b > 10 && *s <= 'F' && *s >= 'A') - r = (r * b) + (*s - 'A' + 10); - else - break; - - return -r; + long r = 0; + s++; + + if (b == 8 && *s == '0') + s++; + else if (b == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X')) + s += 2; + + for (; *s; s++) + if (*s <= '9' && *s >= '0') + r = (r * b) + (*s - '0'); + else if (b > 10 && *s <= 'f' && *s >= 'a') + r = (r * b) + (*s - 'a' + 10); + else if (b > 10 && *s <= 'F' && *s >= 'A') + r = (r * b) + (*s - 'A' + 10); + else + break; + + return -r; } /* @@ -2718,24 +2859,24 @@ idl_atoi(char *s, long b) static unsigned long idl_atoui(char *s, long b) { - long r = 0; - - if (b == 8 && *s == '0') - s++; - else if (b == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X')) - s += 2; - - for (; *s; s++) - if (*s <= '9' && *s >= '0') - r = (r * b) + (*s - '0'); - else if (b > 10 && *s <= 'f' && *s >= 'a') - r = (r * b) + (*s - 'a' + 10); - else if (b > 10 && *s <= 'F' && *s >= 'A') - r = (r * b) + (*s - 'A' + 10); - else - break; - - return r; + long r = 0; + + if (b == 8 && *s == '0') + s++; + else if (b == 16 && *s == '0' && (*(s + 1) == 'x' || *(s + 1) == 'X')) + s += 2; + + for (; *s; s++) + if (*s <= '9' && *s >= '0') + r = (r * b) + (*s - '0'); + else if (b > 10 && *s <= 'f' && *s >= 'a') + r = (r * b) + (*s - 'a' + 10); + else if (b > 10 && *s <= 'F' && *s >= 'A') + r = (r * b) + (*s - 'A' + 10); + else + break; + + return r; } /* @@ -2744,56 +2885,56 @@ idl_atoui(char *s, long b) static double idl_atof(char *s) { - char *h = s; - double d = 0.0; - double f = 0.0; - double e, k; - long neg = 0, negexp = 0; - - ACE_UNUSED_ARG (f); - ACE_UNUSED_ARG (h); - - if (*s == '-') { - neg = 1; - s++; - } - while (*s >= '0' && *s <= '9') { - d = (d * 10) + *s - '0'; - s++; - } - if (*s == '.') { - s++; - e = 10; - while (*s >= '0' && *s <= '9') { - d += (*s - '0') / (e * 1.0); - e *= 10; - s++; - } - } - if (*s == 'e' || *s == 'E') { - s++; - if (*s == '-') { - negexp = 1; - s++; - } else if (*s == '+') - s++; - e = 0; - while (*s >= '0' && *s <= '9') { - e = (e * 10) + *s - '0'; - s++; - } - if (e > 0) { - for (k = 1; e > 0; k *= 10, e--); - if (negexp) - d /= k; - else - d *= k; - } - } + char *h = s; + double d = 0.0; + double f = 0.0; + double e, k; + long neg = 0, negexp = 0; + + ACE_UNUSED_ARG (f); + ACE_UNUSED_ARG (h); + + if (*s == '-') { + neg = 1; + s++; + } + while (*s >= '0' && *s <= '9') { + d = (d * 10) + *s - '0'; + s++; + } + if (*s == '.') { + s++; + e = 10; + while (*s >= '0' && *s <= '9') { + d += (*s - '0') / (e * 1.0); + e *= 10; + s++; + } + } + if (*s == 'e' || *s == 'E') { + s++; + if (*s == '-') { + negexp = 1; + s++; + } else if (*s == '+') + s++; + e = 0; + while (*s >= '0' && *s <= '9') { + e = (e * 10) + *s - '0'; + s++; + } + if (e > 0) { + for (k = 1; e > 0; k *= 10, e--); + if (negexp) + d /= k; + else + d *= k; + } + } - if (neg) d *= -1.0; + if (neg) d *= -1.0; - return d; + return d; } /* @@ -2805,62 +2946,62 @@ idl_escape_reader( ) { if (str[0] != '\\') { - return str[0]; + return str[0]; } switch (str[1]) { case 'n': - return '\n'; + return '\n'; case 't': - return '\t'; + return '\t'; case 'v': - return '\v'; + return '\v'; case 'b': - return '\b'; + return '\b'; case 'r': - return '\r'; + return '\r'; case 'f': - return '\f'; + return '\f'; case 'a': - return '\a'; + return '\a'; case '\\': - return '\\'; + return '\\'; case '\?': - return '?'; + return '?'; case '\'': - return '\''; + return '\''; case '"': - return '"'; + return '"'; case 'x': - { - int i; - // hex value - for (i = 2; str[i] != '\0' && isxdigit(str[i]); i++) { - continue; - } - char save = str[i]; - str[i] = '\0'; - char out = (char)idl_atoui(&str[2], 16); - str[i] = save; - return out; - } - ACE_NOTREACHED (break;) + { + int i; + // hex value + for (i = 2; str[i] != '\0' && isxdigit(str[i]); i++) { + continue; + } + char save = str[i]; + str[i] = '\0'; + char out = (char)idl_atoui(&str[2], 16); + str[i] = save; + return out; + } + ACE_NOTREACHED (break;) default: - // check for octal value - if (str[1] >= '0' && str[1] <= '7') { - int i; - for (i = 1; str[i] >= '0' && str[i] <= '7'; i++) { - continue; - } - char save = str[i]; - str[i] = '\0'; - char out = (char)idl_atoui(&str[1], 8); - str[i] = save; - return out; - } else { - return str[1] - 'a'; - } - ACE_NOTREACHED (break;) + // check for octal value + if (str[1] >= '0' && str[1] <= '7') { + int i; + for (i = 1; str[i] >= '0' && str[i] <= '7'; i++) { + continue; + } + char save = str[i]; + str[i] = '\0'; + char out = (char)idl_atoui(&str[1], 8); + str[i] = save; + return out; + } else { + return str[1] - 'a'; + } + ACE_NOTREACHED (break;) } } /* @@ -2953,9 +3094,7 @@ idl_valid_version (char *s) char *tmp = minor + 1; - // Some preprocessors leave trailing whitespace, hence the - // check for a space character. - for (i = 0; tmp[i] != '\0' && !ACE_OS::ace_isspace (tmp[i]); ++i) + for (i = 0; tmp[i] != '\0'; ++i) { if (!isdigit (tmp[i])) { @@ -2991,7 +3130,7 @@ idl_find_node (char *s) if (node != 0) { - d = idl_global->scopes ()->top_non_null ()->lookup_by_name (node, + d = idl_global->scopes ().top_non_null ()->lookup_by_name (node, I_TRUE); } diff --git a/TAO/TAO_IDL/fe/lex.yy.cpp.diff b/TAO/TAO_IDL/fe/lex.yy.cpp.diff index 8b1734507cf..7097049493c 100644 --- a/TAO/TAO_IDL/fe/lex.yy.cpp.diff +++ b/TAO/TAO_IDL/fe/lex.yy.cpp.diff @@ -1,3 +1,5 @@ +--- lex.yy.cpp Fri Jan 25 11:06:56 2002 ++++ lex.yy.cpp.mod Fri Jan 25 11:09:03 2002 @@ -987,7 +987,7 @@ /* Code executed at the end of each rule. */ #ifndef TAO_YY_BREAK @@ -14,107 +16,107 @@ + register char *tao_yy_cp = 0, *tao_yy_bp = 0; register int tao_yy_act; -@@ -1435,7 +1435,7 @@ +@@ -1568,7 +1568,7 @@ idl_global->set_lineno(idl_global->lineno() + 1); idl_store_pragma(ace_tao_yytext); } - TAO_YY_BREAK + break; - case 69: - case 70: + case 86: + case 87: -@@ -1442,7 +1442,7 @@ +@@ -1575,7 +1575,7 @@ {/* ignore file */ idl_global->set_lineno(idl_global->lineno() + 1); } - TAO_YY_BREAK + break; -case 71: -case 72: +case 88: +case 89: TAO_YY_RULE_SETUP { idl_parse_line_and_file(ace_tao_yytext); } - TAO_YY_BREAK + break; - case 73: - case 74: + case 90: + case 91: -@@ -1455,7 +1455,7 @@ +@@ -1588,7 +1588,7 @@ TAO_YY_RULE_SETUP { idl_parse_line_and_file(ace_tao_yytext); } - TAO_YY_BREAK + break; - case 75: - case 76: + case 92: + case 93: -@@ -1462,7 +1462,7 @@ +@@ -1595,7 +1595,7 @@ TAO_YY_RULE_SETUP { idl_parse_line_and_file(ace_tao_yytext); } - TAO_YY_BREAK + break; - case 77: - case 78: + case 94: + case 95: -@@ -1469,7 +1469,7 @@ +@@ -1602,7 +1602,7 @@ TAO_YY_RULE_SETUP { idl_parse_line_and_file(ace_tao_yytext); } - TAO_YY_BREAK + break; - case 79: - case 80: + case 96: + case 97: -@@ -1478,14 +1478,14 @@ +@@ -1611,14 +1611,14 @@ /* ignore cpp ident */ idl_global->set_lineno(idl_global->lineno() + 1); } - TAO_YY_BREAK + break; - case 81: + case 98: TAO_YY_RULE_SETUP -@@ -1484,7 +1484,7 @@ +@@ -1617,7 +1617,7 @@ { /* ignore comments */ idl_global->set_lineno(idl_global->lineno() + 1); } - TAO_YY_BREAK + break; - case 82: + case 99: TAO_YY_RULE_SETUP -@@ -1502,25 +1502,25 @@ +@@ -1635,25 +1635,25 @@ } } } - TAO_YY_BREAK + break; - case 83: + case 100: TAO_YY_RULE_SETUP ; - TAO_YY_BREAK + break; - case 84: + case 101: TAO_YY_RULE_SETUP { idl_global->set_lineno(idl_global->lineno() + 1); } - TAO_YY_BREAK + break; - case 85: + case 102: TAO_YY_RULE_SETUP -@@ -1518,7 +1518,7 @@ +@@ -1651,7 +1651,7 @@ return ace_tao_yytext [0]; - TAO_YY_BREAK + break; - case 86: + case 103: TAO_YY_RULE_SETUP TAO_YY_ECHO; - TAO_YY_BREAK diff --git a/TAO/TAO_IDL/fe/y.tab.cpp b/TAO/TAO_IDL/fe/y.tab.cpp index cd060235a96..615afa4156f 100644 --- a/TAO/TAO_IDL/fe/y.tab.cpp +++ b/TAO/TAO_IDL/fe/y.tab.cpp @@ -97,489 +97,520 @@ typedef union { #define IDL_SUPPORTS 300 #define IDL_TRUNCATABLE 301 #define IDL_VALUETYPE 302 -#define IDL_INTEGER_LITERAL 303 -#define IDL_UINTEGER_LITERAL 304 -#define IDL_STRING_LITERAL 305 -#define IDL_CHARACTER_LITERAL 306 -#define IDL_FLOATING_PT_LITERAL 307 -#define IDL_TRUETOK 308 -#define IDL_FALSETOK 309 -#define IDL_SCOPE_DELIMITOR 310 -#define IDL_LEFT_SHIFT 311 -#define IDL_RIGHT_SHIFT 312 -#define IDL_WCHAR_LITERAL 313 -#define IDL_WSTRING_LITERAL 314 +#define IDL_COMPONENT 303 +#define IDL_CONSUMES 304 +#define IDL_EMITS 305 +#define IDL_EVENTTYPE 306 +#define IDL_FINDER 307 +#define IDL_GETRAISES 308 +#define IDL_HOME 309 +#define IDL_IMPORT 310 +#define IDL_MULTIPLE 311 +#define IDL_PRIMARYKEY 312 +#define IDL_PROVIDES 313 +#define IDL_PUBLISHES 314 +#define IDL_SETRAISES 315 +#define IDL_TYPEID 316 +#define IDL_TYPEPREFIX 317 +#define IDL_USES 318 +#define IDL_MANAGES 319 +#define IDL_INTEGER_LITERAL 320 +#define IDL_UINTEGER_LITERAL 321 +#define IDL_STRING_LITERAL 322 +#define IDL_CHARACTER_LITERAL 323 +#define IDL_FLOATING_PT_LITERAL 324 +#define IDL_TRUETOK 325 +#define IDL_FALSETOK 326 +#define IDL_SCOPE_DELIMITOR 327 +#define IDL_LEFT_SHIFT 328 +#define IDL_RIGHT_SHIFT 329 +#define IDL_WCHAR_LITERAL 330 +#define IDL_WSTRING_LITERAL 331 #define TAO_YYERRCODE 256 short tao_yylhs[] = { -1, 0, 72, 72, 74, 73, 76, 73, 78, 73, 80, - 73, 82, 73, 84, 73, 85, 73, 86, 87, 88, - 89, 81, 79, 79, 92, 94, 95, 90, 96, 68, - 33, 33, 33, 97, 22, 22, 83, 83, 83, 83, - 98, 98, 103, 105, 106, 102, 107, 108, 109, 99, - 34, 110, 69, 67, 67, 24, 24, 100, 100, 101, - 104, 104, 111, 111, 111, 116, 112, 117, 112, 93, - 93, 118, 113, 119, 113, 120, 113, 122, 113, 124, - 113, 125, 113, 20, 126, 21, 21, 16, 127, 16, - 128, 16, 70, 91, 91, 91, 129, 130, 131, 132, - 75, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 35, 36, 37, 37, 38, 38, 39, 39, 40, 40, - 40, 41, 41, 41, 42, 42, 42, 42, 43, 43, - 43, 43, 44, 44, 44, 45, 45, 45, 45, 45, - 45, 45, 45, 45, 46, 134, 71, 71, 71, 71, - 71, 135, 133, 1, 1, 2, 2, 2, 59, 59, - 59, 59, 59, 59, 59, 4, 4, 4, 3, 3, - 3, 29, 136, 30, 30, 63, 63, 31, 137, 32, - 32, 64, 65, 51, 51, 57, 57, 57, 58, 58, - 58, 54, 54, 54, 56, 52, 52, 60, 53, 55, - 138, 139, 141, 142, 7, 140, 144, 144, 145, 143, - 146, 147, 115, 148, 115, 149, 150, 151, 152, 153, - 154, 156, 157, 10, 9, 9, 9, 9, 9, 9, - 155, 159, 159, 160, 161, 158, 162, 158, 27, 28, - 28, 163, 48, 164, 165, 48, 166, 49, 167, 168, - 170, 171, 8, 169, 174, 173, 173, 172, 175, 176, - 5, 5, 177, 178, 13, 180, 181, 6, 6, 179, - 183, 184, 14, 14, 182, 185, 11, 25, 26, 26, - 186, 187, 47, 188, 189, 121, 66, 66, 190, 191, - 192, 193, 77, 194, 196, 197, 198, 123, 62, 62, - 62, 12, 12, 199, 201, 114, 202, 200, 204, 200, - 203, 207, 206, 206, 208, 209, 205, 210, 195, 212, - 195, 211, 215, 214, 214, 216, 217, 213, 15, 15, - 15, 15, 61, 61, 61, 218, 219, 23, 23, 220, - 221, 17, 17, 18, 222, 19, 19, + 73, 82, 73, 84, 73, 86, 73, 88, 73, 89, + 73, 90, 91, 92, 93, 85, 83, 83, 96, 98, + 99, 94, 100, 68, 33, 33, 33, 101, 22, 22, + 87, 87, 87, 87, 102, 102, 107, 109, 110, 106, + 111, 112, 113, 103, 34, 114, 69, 67, 67, 24, + 24, 104, 104, 105, 108, 108, 115, 115, 115, 120, + 116, 121, 116, 97, 97, 122, 117, 123, 117, 124, + 117, 125, 117, 126, 117, 128, 117, 130, 117, 131, + 117, 20, 132, 21, 21, 16, 133, 16, 134, 16, + 70, 95, 95, 95, 135, 136, 137, 138, 79, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 35, 36, + 37, 37, 38, 38, 39, 39, 40, 40, 40, 41, + 41, 41, 42, 42, 42, 42, 43, 43, 43, 43, + 44, 44, 44, 45, 45, 45, 45, 45, 45, 45, + 45, 45, 46, 140, 71, 71, 71, 71, 71, 141, + 139, 1, 1, 2, 2, 2, 59, 59, 59, 59, + 59, 59, 59, 4, 4, 4, 3, 3, 3, 29, + 142, 30, 30, 63, 63, 31, 143, 32, 32, 64, + 65, 51, 51, 57, 57, 57, 58, 58, 58, 54, + 54, 54, 56, 52, 52, 60, 53, 55, 144, 145, + 147, 148, 7, 146, 150, 150, 151, 149, 152, 153, + 119, 154, 119, 155, 156, 157, 158, 159, 160, 162, + 163, 10, 9, 9, 9, 9, 9, 9, 161, 165, + 165, 166, 167, 164, 168, 164, 27, 28, 28, 169, + 48, 170, 171, 48, 172, 49, 173, 174, 176, 177, + 8, 175, 180, 179, 179, 178, 181, 182, 5, 5, + 183, 184, 13, 186, 187, 6, 6, 185, 189, 190, + 14, 14, 188, 191, 11, 25, 26, 26, 192, 193, + 47, 194, 195, 127, 66, 66, 196, 197, 198, 199, + 81, 200, 202, 203, 204, 129, 62, 62, 62, 12, + 12, 205, 207, 118, 208, 206, 210, 206, 209, 213, + 212, 212, 214, 215, 211, 216, 201, 218, 201, 217, + 221, 220, 220, 222, 223, 219, 15, 15, 15, 15, + 61, 61, 61, 224, 225, 23, 23, 226, 227, 17, + 17, 18, 228, 19, 19, 75, 77, }; short tao_yylen[] = { 2, 1, 2, 0, 0, 3, 0, 3, 0, 3, 0, - 3, 0, 3, 0, 3, 0, 3, 0, 0, 0, - 0, 9, 1, 1, 0, 0, 0, 7, 0, 3, - 2, 3, 3, 0, 3, 0, 1, 1, 1, 1, - 2, 1, 0, 0, 0, 7, 0, 0, 0, 8, - 4, 0, 3, 1, 0, 2, 0, 2, 1, 2, - 2, 0, 1, 1, 2, 0, 3, 0, 3, 2, - 0, 0, 3, 0, 3, 0, 3, 0, 3, 0, - 3, 0, 3, 2, 0, 4, 0, 1, 0, 3, - 0, 4, 1, 1, 2, 2, 0, 0, 0, 0, - 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 3, 1, 3, 1, 3, 1, 3, - 3, 1, 3, 3, 1, 3, 3, 3, 1, 2, - 2, 2, 1, 1, 3, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 3, 1, 1, 1, - 2, 0, 3, 1, 1, 1, 1, 1, 1, 1, + 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, + 3, 0, 0, 0, 0, 9, 1, 1, 0, 0, + 0, 7, 0, 3, 2, 3, 3, 0, 3, 0, + 1, 1, 1, 1, 2, 1, 0, 0, 0, 7, + 0, 0, 0, 8, 4, 0, 3, 1, 0, 2, + 0, 2, 1, 2, 2, 0, 1, 1, 2, 0, + 3, 0, 3, 2, 0, 0, 3, 0, 3, 0, + 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, + 3, 2, 0, 4, 0, 1, 0, 3, 0, 4, + 1, 1, 2, 2, 0, 0, 0, 0, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 0, 4, 0, 1, 1, 2, 0, 4, - 0, 1, 1, 1, 1, 1, 2, 1, 2, 3, - 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 9, 2, 2, 0, 0, 2, - 0, 0, 5, 0, 3, 0, 0, 0, 0, 0, - 0, 0, 0, 17, 1, 1, 1, 1, 1, 1, - 2, 2, 0, 0, 0, 5, 0, 3, 2, 2, - 0, 0, 3, 0, 0, 5, 0, 3, 0, 0, - 0, 0, 9, 2, 0, 4, 0, 1, 0, 0, - 6, 2, 0, 0, 5, 0, 0, 6, 1, 1, - 0, 0, 6, 1, 1, 0, 3, 2, 2, 0, - 0, 0, 5, 0, 0, 6, 1, 0, 0, 0, - 0, 0, 9, 0, 0, 0, 0, 10, 1, 1, - 0, 1, 1, 0, 0, 5, 0, 3, 0, 4, - 2, 0, 4, 0, 0, 0, 5, 0, 3, 0, - 4, 2, 0, 4, 0, 0, 0, 5, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 6, 0, 0, - 0, 6, 0, 2, 0, 4, 0, + 1, 3, 1, 3, 1, 3, 1, 3, 3, 1, + 3, 3, 1, 3, 3, 3, 1, 2, 2, 2, + 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 3, 1, 1, 1, 2, 0, + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 0, 4, 0, 1, 1, 2, 0, 4, 0, 1, + 1, 1, 1, 1, 2, 1, 2, 3, 2, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 9, 2, 2, 0, 0, 2, 0, 0, + 5, 0, 3, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 1, 1, 1, 1, 1, 1, 2, 2, + 0, 0, 0, 5, 0, 3, 2, 2, 0, 0, + 3, 0, 0, 5, 0, 3, 0, 0, 0, 0, + 9, 2, 0, 4, 0, 1, 0, 0, 6, 2, + 0, 0, 5, 0, 0, 6, 1, 1, 0, 0, + 6, 1, 1, 0, 3, 2, 2, 0, 0, 0, + 5, 0, 0, 6, 1, 0, 0, 0, 0, 0, + 9, 0, 0, 0, 0, 10, 1, 1, 0, 1, + 1, 0, 0, 5, 0, 3, 0, 4, 2, 0, + 4, 0, 0, 0, 5, 0, 3, 0, 4, 2, + 0, 4, 0, 0, 0, 5, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 6, 0, 0, 0, 6, + 0, 2, 0, 4, 0, 3, 3, }; short tao_yydefred[] = { 3, - 0, 0, 16, 97, 18, 29, 146, 201, 216, 249, - 289, 0, 0, 0, 0, 52, 148, 150, 149, 25, - 43, 0, 0, 4, 2, 6, 8, 10, 12, 14, - 23, 24, 37, 38, 39, 40, 42, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 93, 151, 182, 0, - 47, 0, 0, 0, 41, 0, 0, 0, 34, 31, - 0, 188, 0, 192, 193, 196, 197, 198, 199, 195, - 200, 263, 270, 275, 54, 89, 60, 154, 155, 157, - 166, 167, 169, 171, 170, 0, 168, 0, 159, 161, - 162, 160, 165, 164, 184, 185, 156, 163, 0, 88, - 0, 0, 0, 0, 0, 0, 0, 0, 17, 108, - 109, 0, 98, 102, 103, 105, 106, 107, 104, 19, - 30, 152, 147, 202, 217, 250, 290, 32, 0, 33, - 53, 26, 44, 0, 187, 194, 0, 191, 0, 0, - 259, 262, 91, 0, 266, 271, 5, 7, 9, 11, - 13, 15, 0, 0, 0, 0, 0, 0, 0, 48, - 71, 62, 0, 35, 190, 264, 90, 0, 0, 0, - 51, 0, 0, 99, 20, 183, 153, 175, 176, 177, - 0, 203, 218, 251, 291, 71, 0, 0, 0, 0, - 136, 137, 138, 140, 142, 143, 144, 141, 139, 0, - 0, 0, 0, 0, 145, 0, 0, 0, 0, 0, - 0, 125, 129, 134, 260, 92, 0, 267, 272, 0, - 3, 0, 0, 209, 0, 0, 208, 0, 82, 287, - 299, 300, 0, 0, 72, 74, 76, 0, 70, 78, - 80, 304, 68, 66, 0, 61, 63, 64, 0, 85, - 265, 130, 131, 132, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, - 173, 281, 277, 280, 204, 208, 0, 219, 258, 252, - 257, 0, 0, 0, 303, 330, 294, 331, 302, 0, - 329, 284, 0, 0, 0, 28, 0, 0, 0, 0, - 0, 46, 65, 0, 135, 0, 0, 0, 0, 0, - 0, 0, 126, 127, 128, 261, 268, 273, 0, 0, - 0, 0, 0, 0, 0, 214, 211, 210, 0, 0, - 0, 207, 0, 50, 83, 0, 0, 73, 75, 77, - 79, 81, 305, 69, 67, 0, 101, 111, 22, 174, - 282, 279, 205, 0, 0, 0, 229, 220, 0, 225, - 226, 228, 227, 253, 255, 293, 295, 285, 0, 0, - 215, 212, 0, 0, 0, 0, 0, 306, 283, 0, - 221, 256, 0, 296, 286, 181, 0, 0, 213, 0, - 0, 0, 0, 0, 308, 315, 0, 314, 222, 319, - 333, 334, 335, 326, 0, 325, 336, 297, 179, 0, - 310, 0, 0, 0, 321, 0, 0, 0, 0, 316, - 312, 237, 244, 242, 234, 241, 223, 233, 327, 323, - 337, 340, 298, 180, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 317, 313, 238, - 245, 243, 247, 235, 240, 224, 232, 328, 324, 0, - 341, 0, 0, 0, 338, 0, 246, 248, 236, 347, - 0, 0, 342, 345, 0, 346, + 0, 0, 20, 105, 22, 33, 154, 209, 224, 257, + 297, 0, 0, 0, 0, 56, 0, 0, 156, 158, + 157, 29, 47, 0, 0, 4, 2, 6, 8, 10, + 12, 14, 16, 18, 27, 28, 41, 42, 43, 44, + 46, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 101, 159, 190, 0, 51, 0, 0, 0, 45, 0, + 97, 0, 96, 0, 0, 0, 38, 35, 0, 196, + 0, 200, 201, 204, 205, 206, 207, 203, 208, 271, + 278, 283, 58, 64, 162, 163, 165, 174, 175, 177, + 179, 178, 0, 176, 0, 167, 169, 170, 168, 173, + 172, 192, 193, 164, 171, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 21, 116, 117, 0, + 106, 110, 111, 113, 114, 115, 112, 23, 34, 160, + 155, 210, 225, 258, 298, 36, 0, 37, 57, 0, + 356, 99, 357, 30, 48, 0, 195, 202, 0, 199, + 0, 267, 270, 0, 274, 279, 5, 7, 9, 11, + 13, 15, 17, 19, 0, 0, 0, 0, 0, 0, + 0, 52, 98, 0, 75, 66, 0, 39, 198, 272, + 0, 0, 55, 0, 0, 107, 24, 191, 161, 183, + 184, 185, 0, 211, 226, 259, 299, 75, 100, 0, + 0, 0, 0, 144, 145, 146, 148, 150, 151, 152, + 149, 147, 0, 0, 0, 0, 0, 153, 0, 0, + 0, 0, 0, 0, 133, 137, 142, 268, 0, 275, + 280, 0, 3, 0, 0, 217, 0, 0, 216, 0, + 90, 295, 307, 308, 0, 0, 76, 78, 80, 82, + 84, 0, 74, 86, 88, 312, 72, 70, 0, 65, + 67, 68, 0, 93, 273, 138, 139, 140, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 108, 0, 181, 289, 285, 288, 212, 216, + 0, 227, 266, 260, 265, 0, 0, 0, 311, 338, + 302, 339, 310, 0, 337, 292, 0, 0, 0, 0, + 0, 32, 0, 0, 0, 0, 0, 50, 69, 0, + 143, 0, 0, 0, 0, 0, 0, 0, 134, 135, + 136, 269, 276, 281, 0, 0, 0, 0, 0, 0, + 0, 222, 219, 218, 0, 0, 0, 215, 0, 54, + 91, 0, 0, 77, 79, 81, 83, 85, 87, 89, + 313, 73, 71, 0, 109, 119, 26, 182, 290, 287, + 213, 0, 0, 0, 237, 228, 0, 233, 234, 236, + 235, 261, 263, 301, 303, 293, 0, 0, 223, 220, + 0, 0, 0, 0, 0, 314, 291, 0, 229, 264, + 0, 304, 294, 189, 0, 0, 221, 0, 0, 0, + 0, 0, 316, 323, 0, 322, 230, 327, 341, 342, + 343, 334, 0, 333, 344, 305, 187, 0, 318, 0, + 0, 0, 329, 0, 0, 0, 0, 324, 320, 245, + 252, 250, 242, 249, 231, 241, 335, 331, 345, 348, + 306, 188, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 325, 321, 246, 253, 251, + 255, 243, 248, 232, 240, 336, 332, 0, 349, 0, + 0, 0, 346, 0, 254, 256, 244, 355, 0, 0, + 350, 353, 0, 354, }; short tao_yydgoto[] = { 1, - 327, 78, 79, 80, 81, 82, 83, 84, 358, 85, - 176, 287, 86, 87, 289, 204, 433, 471, 472, 164, - 189, 60, 408, 171, 273, 323, 425, 441, 177, 222, - 385, 394, 20, 21, 347, 205, 206, 207, 208, 209, - 210, 211, 212, 213, 214, 215, 274, 426, 454, 113, - 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, - 404, 233, 178, 179, 180, 234, 99, 22, 23, 100, - 235, 2, 25, 103, 236, 104, 237, 105, 28, 106, - 29, 107, 30, 108, 38, 40, 154, 221, 320, 31, - 32, 57, 187, 161, 238, 41, 134, 33, 34, 35, - 36, 37, 58, 188, 162, 245, 129, 186, 283, 56, - 246, 247, 239, 249, 328, 301, 300, 293, 294, 295, - 240, 297, 241, 298, 284, 304, 140, 169, 39, 153, - 220, 319, 123, 42, 155, 321, 419, 43, 156, 275, - 224, 324, 332, 282, 277, 355, 380, 354, 44, 157, - 225, 329, 373, 390, 427, 413, 442, 428, 443, 440, - 464, 437, 439, 438, 462, 463, 45, 158, 280, 226, - 330, 281, 331, 374, 168, 266, 139, 190, 101, 172, - 267, 102, 173, 268, 223, 322, 370, 337, 376, 46, - 159, 227, 333, 336, 384, 375, 393, 418, 299, 378, - 369, 387, 397, 388, 398, 412, 436, 410, 435, 391, - 405, 392, 406, 416, 445, 414, 444, 417, 446, 447, - 466, 475, + 343, 85, 86, 87, 88, 89, 90, 91, 376, 92, + 188, 301, 93, 94, 303, 217, 451, 489, 490, 178, + 202, 68, 426, 183, 287, 339, 443, 459, 189, 234, + 403, 412, 22, 23, 365, 218, 219, 220, 221, 222, + 223, 224, 225, 226, 227, 228, 288, 444, 472, 121, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, + 422, 245, 190, 191, 192, 246, 106, 24, 25, 63, + 247, 2, 27, 109, 248, 110, 249, 111, 250, 112, + 251, 113, 32, 114, 33, 115, 34, 116, 42, 44, + 166, 233, 336, 35, 36, 65, 200, 175, 252, 45, + 146, 37, 38, 39, 40, 41, 66, 201, 176, 259, + 137, 198, 297, 60, 260, 261, 253, 263, 344, 317, + 316, 307, 308, 309, 310, 311, 254, 313, 255, 314, + 298, 320, 140, 174, 43, 165, 232, 335, 131, 46, + 167, 337, 437, 47, 168, 289, 236, 340, 348, 296, + 291, 373, 398, 372, 48, 169, 237, 345, 391, 408, + 445, 431, 460, 446, 461, 458, 482, 455, 457, 456, + 480, 481, 49, 170, 294, 238, 346, 295, 347, 392, + 181, 280, 151, 203, 107, 184, 281, 108, 185, 282, + 235, 338, 388, 353, 394, 50, 171, 239, 349, 352, + 402, 393, 411, 436, 315, 396, 387, 405, 415, 406, + 416, 430, 454, 428, 453, 409, 423, 410, 424, 434, + 463, 432, 462, 435, 464, 465, 484, 493, }; short tao_yysindex[] = { 0, - 0, 575, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -216, -200, -235, -229, 0, 0, 0, 0, 0, - 0, 37, 411, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 42, 536, -173, - -216, 437, -216, -216, -216, -216, 0, 0, 0, 37, - 0, 37, -215, -215, 0, -216, -16, 12, 0, 0, - -171, 0, -125, 0, 0, 0, 0, 0, 0, 0, + 0, 565, 0, 0, 0, 0, 0, 0, 0, 0, + 0, -235, -231, -158, -236, 0, -164, -164, 0, 0, + 0, 0, 0, 31, 396, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 41, 541, -138, -235, 422, -235, -235, -235, -235, + 0, 0, 0, 31, 0, 31, -189, -189, 0, -235, + 0, -259, 0, -181, 16, 24, 0, 0, -211, 0, + -159, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 72, 0, -207, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, - 62, 80, 106, 108, 111, 113, 119, 121, 0, 0, - 0, -207, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, - 0, 0, 0, -220, 0, 0, -67, 0, 140, -216, - 0, 0, 0, -97, 0, 0, 0, 0, 0, 0, - 0, 0, -216, 83, -216, 87, -44, 100, 110, 0, - 0, 0, -207, 0, 0, 0, 0, 13, -216, -220, - 0, 13, 13, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 631, 600, 212, 486, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, - 31, 31, 13, -207, 0, 134, 166, 228, -96, 27, - 122, 0, 0, 0, 0, 0, -207, 0, 0, 207, - 0, 225, 180, 0, 232, 16, 0, 631, 0, 0, - 0, 0, 510, -8, 0, 0, 0, 150, 0, 0, - 0, 0, 0, 0, 152, 0, 0, 0, 224, 0, - 0, 0, 0, 0, 245, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 229, 234, 243, 0, 575, - 0, 0, 0, 0, 0, 0, 381, 0, 0, 0, - 0, 0, 162, 230, 0, 0, 0, 0, 0, -207, - 0, 0, 231, 249, 254, 0, 255, 266, 73, 381, - 381, 0, 0, -220, 0, 166, 228, -96, 27, 27, - 122, 122, 0, 0, 0, 0, 0, 0, 13, 217, - -216, 13, 180, 221, 0, 0, 0, 0, 554, 222, - 288, 0, 226, 0, 0, 95, 361, 0, 0, 0, - 0, 0, 0, 0, 0, -207, 0, 0, 0, 0, - 0, 0, 0, 294, -216, 92, 0, 0, -207, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 315, 264, - 0, 0, 317, 16, 319, -216, 0, 0, 0, 301, - 0, 0, 0, 0, 0, 0, 320, 77, 0, 247, - 327, -63, 90, 338, 0, 0, 330, 0, 0, 0, - 0, 0, 0, 0, 342, 0, 0, 0, 0, 361, - 0, 341, -68, 361, 0, 345, 353, 104, -216, 0, + 0, 0, 73, 0, -204, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 31, 92, 105, 129, 136, + 139, 143, 145, 173, 175, 177, 0, 0, 0, -204, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, -216, 77, 343, 13, 339, 437, - -52, 276, -68, -216, -63, -220, 363, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 364, - 0, 346, -216, 352, 0, 109, 0, 0, 0, 0, - 372, 371, 0, 0, 112, 0, + 0, 0, 0, 0, 0, 0, 137, 0, 0, -235, + 0, 0, 0, 0, 0, -164, 0, 0, -10, 0, + 186, 0, 0, -36, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -235, 150, -235, 158, -9, 161, + 162, 0, 0, -235, 0, 0, -204, 0, 0, 0, + 22, -164, 0, 22, 22, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 635, + 590, 244, 473, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 42, 42, 42, 22, -204, 0, 166, 197, + 254, -145, 149, 154, 0, 0, 0, 0, -204, 0, + 0, 233, 0, 249, 215, 0, 268, 52, 0, 635, + 0, 0, 0, 0, 491, 34, 0, 0, 0, 0, + 0, 194, 0, 0, 0, 0, 0, 0, 195, 0, + 0, 0, 252, 0, 0, 0, 0, 0, 280, 22, + 22, 22, 22, 22, 22, 22, 22, 22, 22, 261, + 262, 270, 0, 565, 0, 0, 0, 0, 0, 0, + 351, 0, 0, 0, 0, 0, 209, 277, 0, 0, + 0, 0, 0, -204, 0, 0, 279, 292, 295, 296, + 297, 0, 299, 300, 78, 351, 351, 0, 0, -164, + 0, 197, 254, -145, 149, 149, 154, 154, 0, 0, + 0, 0, 0, 0, 22, 214, -235, 22, 215, 235, + 0, 0, 0, 0, 379, 245, 336, 0, 256, 0, + 0, 117, 517, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -204, 0, 0, 0, 0, 0, 0, + 0, 324, -235, 122, 0, 0, -204, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 345, 294, 0, 0, + 352, 52, 358, -235, 0, 0, 0, 340, 0, 0, + 0, 0, 0, 0, 361, 119, 0, 282, 365, -67, + 120, 364, 0, 0, 368, 0, 0, 0, 0, 0, + 0, 0, 369, 0, 0, 0, 0, 517, 0, 370, + -111, 517, 0, 371, 373, 125, -235, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -235, 119, 359, 22, 362, 422, -11, 301, + -111, -235, -67, -164, 381, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 378, 0, 372, + -235, 363, 0, 106, 0, 0, 0, 0, 386, 389, + 0, 0, 112, 0, }; short tao_yyrindex[] = { 0, - 0, 416, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 435, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 7, 29, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -1, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, - 0, 26, 56, -43, 0, 0, 0, 0, 0, 0, - 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 49, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -93, 0, - 74, 127, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 163, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 27, 0, 56, 26, -26, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, - 0, 0, 0, 302, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -6, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -97, 65, 70, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 181, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 176, 0, 0, 0, 0, 0, 253, 281, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -19, 0, 135, 543, 350, 328, 51, - 38, 0, 0, 0, 0, 0, 305, 0, 0, 0, - 0, 374, 0, 0, 0, 0, 0, 309, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 39, 0, + 0, 0, 0, 316, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 189, 0, 0, 0, 0, 0, 0, 250, + 276, -24, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 2, 0, 179, 508, + 131, 338, 116, 12, 0, 0, 0, 0, 326, 0, + 0, 0, 0, 394, 0, 0, 0, 0, 0, 318, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 306, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 199, 0, 0, 0, 0, 0, 0, 0, 178, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 548, 541, 336, 88, 125, - 61, 115, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 223, 0, 0, 0, 0, 0, - 313, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 398, 0, 0, 399, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, -27, 0, 0, 0, - 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, - 0, 0, -7, 382, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 331, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 208, 0, 0, 0, 0, + 0, 0, 0, 198, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 401, 0, 0, 0, 404, 0, 387, 0, 0, + 0, 533, 330, 399, 118, 123, 49, 75, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 156, 0, + 232, 0, 0, 0, 0, 0, 334, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 419, 0, 0, 425, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 460, 0, 322, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -23, 0, 0, 0, 0, 0, + -27, 0, 0, 0, 0, 0, 0, 0, 0, 0, + -25, 404, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 426, + 0, 0, 0, 427, 0, 277, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 448, 0, + 366, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 407, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 442, + 0, 0, 0, 0, }; short tao_yygindex[] = { 0, - -21, 259, 0, 0, 0, -35, 14, 4, 0, 34, - 0, 0, 0, -34, -289, -22, 0, 0, 0, 8, - 0, -1, 0, 0, 0, 0, 0, 0, 98, 0, - 0, 0, 0, 436, 0, -192, 0, 201, 202, 200, - -23, -14, -20, 50, 0, -118, 158, 41, 0, 0, - -32, -31, -30, 444, 0, 445, 0, 0, -176, -29, - 0, 0, -239, -9, 0, 0, 0, 227, 239, -12, - 10, 277, 0, 0, 11, 0, 25, 0, 0, 0, + -22, 287, 0, 0, 0, -38, 13, 5, 0, 18, + 0, 0, 0, -37, -307, -16, 0, 0, 0, 60, + 0, 25, 0, 0, 0, 0, 0, 0, 152, 0, + 0, 0, 0, 512, 0, -197, 0, 257, 259, 260, + -30, -19, -51, 36, 0, -107, 192, 77, 0, 0, + -35, -33, -32, 507, 0, 509, 0, 0, -193, -31, + 0, 0, -295, -8, 0, 0, 0, 255, 263, -12, + 11, 320, 0, 0, 14, 0, 19, 0, 21, 0, + 23, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 353, 0, 0, 0, + 0, 0, 0, 0, 0, 542, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 355, 0, -34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 318, 0, 0, 0, 0, 0, 0, 0, - 0, 488, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 323, 0, -36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 322, 271, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 282, 236, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, + 0, 0, 0, 101, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 131, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 78, 0, 0, 0, 0, 0, - 0, 0, 63, 0, 0, 0, 0, 0, 0, 0, - 0, 0, + 111, 0, 0, 0, 0, 0, 0, 0, 108, 0, + 0, 0, 0, 0, 0, 0, 0, 0, }; -#define TAO_YYTABLESIZE 924 -short tao_yytable[] = { 49, - 88, 77, 48, 110, 111, 18, 114, 115, 116, 119, - 255, 24, 26, 307, 55, 17, 112, 133, 133, 88, - 122, 133, 133, 133, 6, 133, 27, 133, 121, 36, - 124, 125, 126, 127, 87, 19, 47, 87, 133, 133, - 47, 86, 133, 131, 86, 186, 189, 368, 128, 189, - 130, 339, 203, 218, 219, 200, 291, 201, 278, 6, - 186, 278, 318, 186, 189, 94, 16, 189, 84, 261, - 203, 262, 16, 133, 133, 122, 278, 95, 122, 55, - 122, 350, 122, 120, 96, 75, 55, 59, 119, 76, - 135, 119, 158, 136, 59, 122, 122, 144, 123, 122, - 109, 123, 143, 123, 133, 123, 132, 158, 119, 119, - 158, 163, 119, 55, 58, 141, 87, 269, 123, 123, - 420, 145, 123, 86, 429, 120, 348, 167, 120, 36, - 122, 122, 269, 142, 133, 269, 137, 138, 202, 146, - 174, 36, 181, 119, 119, 120, 120, 217, 36, 120, - 84, 55, 124, 123, 123, 124, 216, 124, 265, 124, - 291, 122, 121, 263, 147, 121, 148, 88, 264, 149, - 274, 150, 124, 124, 119, 112, 124, 151, 55, 152, - 120, 120, 121, 121, 123, 274, 121, 422, 274, 160, - 18, 18, 112, 112, 165, 448, 112, 286, 288, 166, - 17, 17, 170, 351, 458, 175, 36, 124, 124, 182, - 290, 120, 423, 424, 259, 260, 182, 121, 121, 182, - 19, 19, 184, 468, 401, 402, 403, 112, 423, 424, - 183, 18, 185, 291, 182, 309, 310, 291, 124, 50, - 52, 17, 313, 314, 315, 451, 311, 312, 121, 252, - 253, 254, 53, 54, 88, 250, 55, 256, 186, 257, - 309, 19, 189, 344, 345, 258, 276, 269, 271, 47, - 272, 278, 279, 18, 296, 292, 302, 88, 88, 24, - 26, 346, 303, 17, 339, 305, 334, 47, 335, 338, - 316, 133, 133, 87, 27, 317, 360, 361, 362, 363, - 86, 286, 288, 19, 318, 158, 359, 339, 181, 320, - 320, 320, 340, 341, 290, 191, 192, 193, 194, 195, - 196, 197, 76, 292, 342, 198, 199, 84, 55, 343, - 269, 365, 357, 191, 192, 193, 194, 195, 196, 197, - 76, 349, 181, 198, 199, 353, 364, 206, 122, 122, - 366, 367, 371, 135, 377, 55, 379, 381, 383, 389, - 395, 119, 119, 49, 396, 117, 386, 400, 117, 399, - 411, 123, 123, 118, 286, 288, 118, 27, 286, 288, - 407, 409, 415, 274, 421, 117, 117, 290, 430, 117, - 115, 290, 431, 118, 118, 432, 452, 118, 120, 120, - 456, 450, 461, 467, 465, 45, 49, 115, 115, 434, - 469, 115, 473, 470, 474, 1, 476, 88, 453, 110, - 117, 117, 181, 163, 57, 124, 124, 56, 118, 118, - 21, 181, 172, 49, 332, 121, 121, 254, 186, 230, - 178, 311, 115, 115, 322, 343, 231, 344, 251, 51, - 181, 117, 372, 460, 209, 209, 306, 308, 307, 118, - 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 115, 209, 209, 209, 209, 209, 209, - 352, 455, 117, 118, 209, 209, 209, 209, 209, 209, - 209, 209, 209, 209, 209, 209, 209, 270, 209, 209, - 209, 209, 55, 228, 382, 276, 457, 459, 209, 301, - 248, 325, 0, 449, 301, 301, 301, 301, 301, 301, - 301, 301, 301, 301, 301, 0, 0, 0, 0, 0, - 301, 301, 209, 0, 0, 0, 288, 301, 0, 301, - 0, 0, 301, 301, 301, 301, 301, 301, 301, 301, - 301, 301, 301, 0, 0, 0, 0, 0, 301, 301, - 0, 0, 301, 0, 288, 301, 0, 301, 0, 0, - 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, - 301, 116, 0, 113, 0, 0, 301, 301, 114, 0, - 301, 0, 288, 0, 0, 301, 0, 0, 116, 116, - 113, 113, 116, 0, 113, 114, 114, 0, 0, 114, - 0, 0, 0, 0, 0, 0, 0, 47, 301, 0, - 0, 0, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 116, 116, 113, 326, 47, 73, 74, - 114, 0, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 8, 9, 0, 10, 72, 73, 74, - 0, 0, 0, 0, 116, 0, 113, 47, 0, 0, - 76, 114, 61, 62, 63, 64, 65, 66, 67, 68, - 69, 70, 71, 8, 9, 0, 10, 72, 73, 74, - 76, 0, 0, 47, 0, 0, 0, 0, 61, 62, - 63, 64, 65, 66, 67, 68, 69, 70, 71, 8, - 9, 75, 10, 72, 73, 74, 239, 0, 0, 0, - 76, 239, 239, 239, 239, 239, 239, 239, 239, 239, - 239, 239, 239, 239, 0, 239, 239, 239, 239, 0, - 0, 0, 47, 0, 0, 0, 76, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 0, 0, - 0, 0, 72, 73, 74, 0, 47, 0, 0, 239, - 0, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 0, 0, 0, 0, 0, 73, 74, 0, - 0, 0, 47, 0, 0, 76, 285, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 0, 0, 0, - 47, 0, 0, 73, 74, 356, 62, 63, 0, 76, - 66, 67, 68, 69, 0, 0, 0, 0, 0, 10, +#define TAO_YYTABLESIZE 952 +short tao_yytable[] = { 53, + 62, 64, 84, 52, 118, 119, 20, 122, 95, 123, + 124, 127, 26, 326, 19, 28, 92, 315, 269, 21, + 29, 51, 30, 130, 31, 40, 120, 95, 6, 95, + 95, 59, 129, 347, 132, 133, 134, 135, 141, 141, + 194, 368, 141, 141, 141, 386, 141, 139, 141, 130, + 147, 305, 130, 148, 130, 194, 130, 102, 194, 141, + 141, 216, 141, 141, 213, 16, 214, 142, 94, 130, + 130, 94, 166, 130, 59, 63, 230, 231, 136, 197, + 138, 216, 197, 59, 62, 103, 131, 166, 67, 131, + 166, 131, 51, 131, 141, 141, 59, 197, 92, 117, + 197, 6, 149, 150, 130, 130, 131, 131, 277, 95, + 131, 83, 132, 282, 104, 132, 152, 132, 128, 132, + 438, 40, 142, 277, 447, 141, 277, 173, 282, 177, + 154, 282, 132, 132, 153, 130, 132, 366, 144, 59, + 143, 131, 131, 16, 440, 142, 145, 215, 59, 40, + 94, 155, 186, 127, 193, 128, 127, 466, 128, 305, + 129, 199, 61, 129, 156, 229, 476, 132, 132, 441, + 442, 123, 131, 127, 127, 128, 128, 127, 40, 128, + 129, 129, 273, 274, 129, 486, 95, 157, 123, 123, + 279, 275, 123, 276, 158, 277, 286, 159, 132, 286, + 278, 160, 40, 161, 20, 20, 300, 302, 127, 127, + 128, 128, 19, 19, 286, 129, 129, 21, 21, 120, + 419, 420, 421, 123, 123, 329, 330, 331, 304, 190, + 369, 162, 190, 163, 305, 164, 120, 120, 305, 127, + 120, 128, 325, 326, 20, 180, 129, 190, 266, 267, + 268, 179, 19, 194, 123, 327, 328, 21, 469, 172, + 328, 328, 328, 182, 317, 195, 347, 54, 56, 441, + 442, 120, 187, 59, 95, 92, 57, 58, 51, 284, + 194, 362, 363, 196, 197, 166, 95, 264, 20, 270, + 271, 272, 285, 283, 26, 197, 19, 28, 51, 95, + 95, 21, 29, 364, 30, 286, 31, 292, 293, 378, + 319, 379, 380, 381, 300, 302, 59, 306, 312, 318, + 321, 277, 332, 333, 193, 59, 282, 94, 377, 141, + 141, 334, 300, 350, 361, 351, 304, 354, 367, 130, + 130, 204, 205, 206, 207, 208, 209, 210, 61, 375, + 355, 211, 212, 356, 357, 358, 214, 359, 360, 371, + 193, 204, 205, 206, 207, 208, 209, 210, 61, 382, + 124, 211, 212, 385, 31, 125, 131, 131, 125, 383, + 384, 53, 389, 147, 395, 404, 397, 124, 124, 300, + 302, 124, 399, 300, 302, 125, 125, 401, 407, 125, + 49, 413, 132, 132, 417, 418, 414, 427, 429, 433, + 425, 304, 449, 439, 448, 304, 450, 468, 483, 470, + 479, 487, 124, 124, 53, 474, 491, 488, 452, 485, + 125, 125, 492, 494, 1, 471, 126, 118, 61, 126, + 193, 95, 53, 127, 127, 128, 128, 177, 60, 193, + 129, 129, 180, 124, 340, 25, 126, 126, 262, 194, + 126, 125, 186, 217, 217, 238, 319, 330, 193, 217, + 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 352, 217, 217, 217, 217, 217, 217, 265, + 239, 126, 126, 217, 217, 217, 217, 217, 217, 217, + 217, 217, 217, 217, 217, 217, 309, 217, 217, 217, + 217, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 126, 478, 390, 55, 322, 309, 309, 323, + 370, 324, 309, 296, 217, 473, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 121, 125, + 240, 126, 284, 309, 309, 262, 59, 290, 217, 296, + 341, 475, 309, 400, 467, 121, 121, 0, 0, 121, + 477, 0, 0, 122, 309, 0, 309, 0, 0, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 122, 122, 0, 0, 122, 309, 309, 0, 0, 0, + 121, 296, 309, 0, 309, 0, 342, 51, 0, 0, + 0, 0, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 8, 9, 122, 10, 80, 81, 82, + 0, 121, 0, 0, 0, 51, 0, 0, 0, 0, + 374, 70, 71, 0, 309, 74, 75, 76, 77, 0, + 0, 0, 51, 0, 10, 0, 122, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 8, 9, + 0, 10, 80, 81, 82, 0, 0, 61, 51, 0, + 0, 0, 0, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 78, 79, 8, 9, 83, 10, 80, 81, + 82, 0, 0, 0, 247, 61, 0, 0, 0, 247, + 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, + 247, 247, 61, 247, 247, 247, 247, 0, 0, 51, + 0, 0, 0, 0, 69, 70, 71, 72, 73, 74, + 75, 76, 77, 78, 79, 0, 0, 51, 61, 80, + 81, 82, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 0, 0, 0, 0, 0, 81, 82, + 0, 0, 0, 51, 247, 0, 0, 299, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 78, 79, 0, + 0, 0, 0, 0, 81, 82, 0, 51, 0, 61, + 0, 0, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 0, 0, 0, 0, 0, 61, 81, 82, 3, 0, 4, 5, 6, 7, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 76, 0, 8, 9, 0, - 10, 0, 0, 0, 11, 229, 0, 4, 0, 0, - 7, 0, 0, 76, 0, 0, 0, 12, 13, 14, - 15, 0, 8, 9, 0, 10, 16, 0, 0, 11, - 0, 0, 230, 0, 231, 232, 229, 0, 4, 0, - 0, 7, 12, 0, 0, 0, 242, 243, 244, 0, - 0, 0, 0, 8, 9, 0, 10, 0, 0, 0, - 11, 0, 0, 230, 0, 231, 232, 0, 0, 0, - 0, 0, 0, 12, + 0, 0, 0, 0, 0, 0, 0, 8, 9, 0, + 10, 0, 0, 61, 11, 241, 0, 4, 0, 0, + 7, 0, 0, 0, 0, 0, 0, 12, 13, 14, + 15, 0, 8, 9, 0, 10, 16, 61, 0, 11, + 0, 0, 242, 0, 243, 244, 0, 0, 0, 0, + 17, 18, 12, 0, 0, 0, 256, 257, 258, 0, + 241, 0, 4, 0, 0, 7, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 17, 18, 8, 9, 0, + 10, 0, 0, 0, 11, 0, 0, 242, 0, 243, + 244, 0, 0, 0, 0, 0, 0, 12, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 18, }; short tao_yycheck[] = { 12, - 23, 23, 12, 39, 39, 2, 39, 39, 39, 39, - 203, 2, 2, 41, 58, 2, 39, 37, 38, 42, - 42, 41, 42, 43, 260, 45, 2, 47, 41, 123, - 43, 44, 45, 46, 41, 2, 257, 44, 58, 59, - 257, 41, 62, 56, 44, 44, 41, 337, 50, 44, - 52, 59, 40, 172, 173, 43, 233, 45, 41, 260, - 59, 44, 41, 62, 59, 59, 302, 62, 41, 43, - 40, 45, 302, 93, 94, 38, 59, 59, 41, 123, - 43, 321, 45, 257, 59, 301, 58, 59, 38, 310, - 262, 41, 44, 265, 58, 58, 59, 99, 38, 62, - 59, 41, 310, 43, 124, 45, 123, 59, 58, 59, - 62, 134, 62, 58, 59, 44, 123, 44, 58, 59, - 410, 60, 62, 123, 414, 38, 319, 140, 41, 123, - 93, 94, 59, 62, 123, 62, 262, 263, 126, 60, - 153, 123, 155, 93, 94, 58, 59, 170, 123, 62, - 123, 123, 38, 93, 94, 41, 169, 43, 37, 45, - 337, 124, 38, 42, 59, 41, 59, 190, 47, 59, - 44, 59, 58, 59, 124, 41, 62, 59, 123, 59, - 93, 94, 58, 59, 124, 59, 62, 256, 62, 123, - 187, 188, 58, 59, 262, 435, 62, 233, 233, 60, - 187, 188, 300, 322, 444, 123, 300, 93, 94, 123, - 233, 124, 281, 282, 311, 312, 41, 93, 94, 44, - 187, 188, 123, 463, 288, 289, 290, 93, 281, 282, - 275, 228, 123, 410, 59, 259, 260, 414, 124, 13, - 14, 228, 263, 264, 265, 438, 261, 262, 124, 200, - 201, 202, 14, 15, 277, 44, 300, 124, 257, 94, - 288, 228, 257, 300, 301, 38, 91, 61, 44, 257, - 91, 40, 257, 270, 125, 284, 125, 300, 301, 270, - 270, 304, 59, 270, 292, 41, 125, 257, 59, 59, - 62, 311, 312, 300, 270, 62, 329, 329, 329, 329, - 300, 337, 337, 270, 62, 257, 329, 59, 321, 288, - 289, 290, 59, 59, 337, 303, 304, 305, 306, 307, - 308, 309, 310, 125, 59, 313, 314, 300, 300, 257, - 257, 44, 329, 303, 304, 305, 306, 307, 308, 309, - 310, 125, 355, 313, 314, 125, 125, 125, 311, 312, - 125, 257, 59, 262, 40, 300, 93, 41, 40, 59, - 41, 311, 312, 376, 288, 38, 376, 41, 41, 123, - 41, 311, 312, 38, 410, 410, 41, 125, 414, 414, - 291, 44, 41, 257, 44, 58, 59, 410, 44, 62, - 41, 414, 40, 58, 59, 292, 58, 62, 311, 312, - 125, 59, 40, 58, 41, 125, 419, 58, 59, 419, - 59, 62, 41, 305, 44, 0, 305, 440, 440, 257, - 93, 94, 435, 446, 123, 311, 312, 123, 93, 94, - 125, 444, 59, 125, 257, 311, 312, 125, 41, 41, - 59, 41, 93, 94, 41, 59, 125, 41, 190, 14, - 463, 124, 355, 446, 256, 257, 256, 258, 257, 124, - 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, - 272, 273, 274, 124, 276, 277, 278, 279, 256, 257, - 323, 441, 39, 39, 262, 263, 264, 265, 266, 267, - 268, 269, 270, 271, 272, 273, 274, 221, 276, 277, - 278, 279, 15, 186, 374, 224, 443, 445, 310, 257, - 188, 276, -1, 436, 262, 263, 264, 265, 266, 267, - 268, 269, 270, 271, 272, -1, -1, -1, -1, -1, - 278, 279, 310, -1, -1, -1, 284, 257, -1, 287, + 17, 18, 25, 12, 43, 43, 2, 43, 25, 43, + 43, 43, 2, 41, 2, 2, 41, 41, 216, 2, + 2, 257, 2, 46, 2, 123, 43, 41, 260, 46, + 44, 58, 45, 59, 47, 48, 49, 50, 37, 38, + 44, 337, 41, 42, 43, 353, 45, 60, 47, 38, + 262, 245, 41, 265, 43, 59, 45, 59, 62, 58, + 59, 40, 322, 62, 43, 302, 45, 327, 41, 58, + 59, 44, 44, 62, 58, 59, 184, 185, 54, 41, + 56, 40, 44, 58, 59, 59, 38, 59, 58, 41, + 62, 43, 257, 45, 93, 94, 123, 59, 123, 59, + 62, 260, 262, 263, 93, 94, 58, 59, 44, 123, + 62, 301, 38, 44, 59, 41, 44, 43, 257, 45, + 428, 123, 327, 59, 432, 124, 62, 140, 59, 146, + 106, 62, 58, 59, 62, 124, 62, 335, 123, 123, + 322, 93, 94, 302, 256, 327, 123, 126, 123, 123, + 123, 60, 165, 38, 167, 38, 41, 453, 41, 353, + 38, 174, 327, 41, 60, 182, 462, 93, 94, 281, + 282, 41, 124, 58, 59, 58, 59, 62, 123, 62, + 58, 59, 328, 329, 62, 481, 203, 59, 58, 59, + 37, 43, 62, 45, 59, 42, 41, 59, 124, 44, + 47, 59, 300, 59, 200, 201, 245, 245, 93, 94, + 93, 94, 200, 201, 59, 93, 94, 200, 201, 41, + 288, 289, 290, 93, 94, 277, 278, 279, 245, 41, + 338, 59, 44, 59, 428, 59, 58, 59, 432, 124, + 62, 124, 273, 274, 240, 60, 124, 59, 213, 214, + 215, 262, 240, 257, 124, 275, 276, 240, 456, 123, + 288, 289, 290, 300, 288, 275, 292, 13, 14, 281, + 282, 93, 123, 300, 291, 300, 14, 15, 257, 91, + 123, 316, 317, 123, 123, 257, 300, 44, 284, 124, + 94, 38, 44, 61, 284, 257, 284, 284, 257, 316, + 317, 284, 284, 320, 284, 91, 284, 40, 257, 345, + 59, 345, 345, 345, 353, 353, 300, 284, 125, 125, + 41, 257, 62, 62, 337, 300, 257, 300, 345, 328, + 329, 62, 125, 125, 257, 59, 353, 59, 125, 328, + 329, 320, 321, 322, 323, 324, 325, 326, 327, 345, + 59, 330, 331, 59, 59, 59, 125, 59, 59, 125, + 373, 320, 321, 322, 323, 324, 325, 326, 327, 125, + 41, 330, 331, 257, 125, 38, 328, 329, 41, 44, + 125, 394, 59, 262, 40, 394, 93, 58, 59, 428, + 428, 62, 41, 432, 432, 58, 59, 40, 59, 62, + 125, 41, 328, 329, 123, 41, 288, 44, 41, 41, + 291, 428, 40, 44, 44, 432, 292, 59, 41, 58, + 40, 59, 93, 94, 437, 125, 41, 322, 437, 58, + 93, 94, 44, 322, 0, 458, 38, 257, 123, 41, + 453, 458, 125, 328, 329, 328, 329, 464, 123, 462, + 328, 329, 59, 124, 257, 125, 58, 59, 125, 41, + 62, 124, 59, 256, 257, 41, 41, 41, 481, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 274, 41, 276, 277, 278, 279, 256, 257, 203, + 125, 93, 94, 262, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, 273, 274, 257, 276, 277, 278, + 279, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 124, 464, 373, 14, 270, 278, 279, 271, + 339, 272, 257, 284, 327, 459, 287, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 41, 43, + 198, 43, 233, 278, 279, 201, 15, 236, 327, 284, + 290, 461, 287, 392, 454, 58, 59, -1, -1, 62, + 463, -1, -1, 41, 257, -1, 327, -1, -1, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 58, 59, -1, -1, 62, 278, 279, -1, -1, -1, + 93, 284, 327, -1, 287, -1, 256, 257, -1, -1, -1, -1, 262, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, 273, 274, 93, 276, 277, 278, 279, + -1, 124, -1, -1, -1, 257, -1, -1, -1, -1, + 262, 263, 264, -1, 327, 267, 268, 269, 270, -1, + -1, -1, 257, -1, 276, -1, 124, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + -1, 276, 277, 278, 279, -1, -1, 327, 257, -1, + -1, -1, -1, 262, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, 273, 274, 301, 276, 277, 278, + 279, -1, -1, -1, 257, 327, -1, -1, -1, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 273, 274, 327, 276, 277, 278, 279, -1, -1, 257, + -1, -1, -1, -1, 262, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, -1, 257, 327, 277, + 278, 279, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, -1, -1, -1, -1, 278, 279, - -1, -1, 310, -1, 284, 257, -1, 287, -1, -1, - 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, - 272, 41, -1, 41, -1, -1, 278, 279, 41, -1, - 310, -1, 284, -1, -1, 287, -1, -1, 58, 59, - 58, 59, 62, -1, 62, 58, 59, -1, -1, 62, - -1, -1, -1, -1, -1, -1, -1, 257, 310, -1, + -1, -1, -1, 257, 327, -1, -1, 287, 262, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, -1, + -1, -1, -1, -1, 278, 279, -1, 257, -1, 327, -1, -1, 262, 263, 264, 265, 266, 267, 268, 269, - 270, 271, 272, 93, 94, 93, 256, 257, 278, 279, - 93, -1, 262, 263, 264, 265, 266, 267, 268, 269, - 270, 271, 272, 273, 274, -1, 276, 277, 278, 279, - -1, -1, -1, -1, 124, -1, 124, 257, -1, -1, - 310, 124, 262, 263, 264, 265, 266, 267, 268, 269, - 270, 271, 272, 273, 274, -1, 276, 277, 278, 279, - 310, -1, -1, 257, -1, -1, -1, -1, 262, 263, - 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, - 274, 301, 276, 277, 278, 279, 257, -1, -1, -1, - 310, 262, 263, 264, 265, 266, 267, 268, 269, 270, - 271, 272, 273, 274, -1, 276, 277, 278, 279, -1, - -1, -1, 257, -1, -1, -1, 310, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, -1, -1, - -1, -1, 277, 278, 279, -1, 257, -1, -1, 310, - -1, 262, 263, 264, 265, 266, 267, 268, 269, 270, - 271, 272, -1, -1, -1, -1, -1, 278, 279, -1, - -1, -1, 257, -1, -1, 310, 287, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, -1, -1, -1, - 257, -1, -1, 278, 279, 262, 263, 264, -1, 310, - 267, 268, 269, 270, -1, -1, -1, -1, -1, 276, + 270, 271, -1, -1, -1, -1, -1, 327, 278, 279, 256, -1, 258, 259, 260, 261, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 310, -1, 273, 274, -1, - 276, -1, -1, -1, 280, 256, -1, 258, -1, -1, - 261, -1, -1, 310, -1, -1, -1, 293, 294, 295, - 296, -1, 273, 274, -1, 276, 302, -1, -1, 280, - -1, -1, 283, -1, 285, 286, 256, -1, 258, -1, - -1, 261, 293, -1, -1, -1, 297, 298, 299, -1, - -1, -1, -1, 273, 274, -1, 276, -1, -1, -1, - 280, -1, -1, 283, -1, 285, 286, -1, -1, -1, - -1, -1, -1, 293, + -1, -1, -1, -1, -1, -1, -1, 273, 274, -1, + 276, -1, -1, 327, 280, 256, -1, 258, -1, -1, + 261, -1, -1, -1, -1, -1, -1, 293, 294, 295, + 296, -1, 273, 274, -1, 276, 302, 327, -1, 280, + -1, -1, 283, -1, 285, 286, -1, -1, -1, -1, + 316, 317, 293, -1, -1, -1, 297, 298, 299, -1, + 256, -1, 258, -1, -1, 261, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 316, 317, 273, 274, -1, + 276, -1, -1, -1, 280, -1, -1, 283, -1, 285, + 286, -1, -1, -1, -1, -1, -1, 293, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 316, 317, }; #define TAO_YYFINAL 1 #ifndef TAO_YYDEBUG #define TAO_YYDEBUG 0 #endif -#define TAO_YYMAXTOKEN 314 +#define TAO_YYMAXTOKEN 331 #if TAO_YYDEBUG const char *tao_yyname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -598,10 +629,13 @@ const char *tao_yyname[] = { "IDL_VOID","IDL_IN","IDL_OUT","IDL_INOUT","IDL_RAISES","IDL_CONTEXT", "IDL_NATIVE","IDL_LOCAL","IDL_ABSTRACT","IDL_CUSTOM","IDL_FACTORY", "IDL_PRIVATE","IDL_PUBLIC","IDL_SUPPORTS","IDL_TRUNCATABLE","IDL_VALUETYPE", -"IDL_INTEGER_LITERAL","IDL_UINTEGER_LITERAL","IDL_STRING_LITERAL", -"IDL_CHARACTER_LITERAL","IDL_FLOATING_PT_LITERAL","IDL_TRUETOK","IDL_FALSETOK", -"IDL_SCOPE_DELIMITOR","IDL_LEFT_SHIFT","IDL_RIGHT_SHIFT","IDL_WCHAR_LITERAL", -"IDL_WSTRING_LITERAL", +"IDL_COMPONENT","IDL_CONSUMES","IDL_EMITS","IDL_EVENTTYPE","IDL_FINDER", +"IDL_GETRAISES","IDL_HOME","IDL_IMPORT","IDL_MULTIPLE","IDL_PRIMARYKEY", +"IDL_PROVIDES","IDL_PUBLISHES","IDL_SETRAISES","IDL_TYPEID","IDL_TYPEPREFIX", +"IDL_USES","IDL_MANAGES","IDL_INTEGER_LITERAL","IDL_UINTEGER_LITERAL", +"IDL_STRING_LITERAL","IDL_CHARACTER_LITERAL","IDL_FLOATING_PT_LITERAL", +"IDL_TRUETOK","IDL_FALSETOK","IDL_SCOPE_DELIMITOR","IDL_LEFT_SHIFT", +"IDL_RIGHT_SHIFT","IDL_WCHAR_LITERAL","IDL_WSTRING_LITERAL", }; const char *tao_yyrule[] = { "$accept : start", @@ -611,35 +645,39 @@ const char *tao_yyrule[] = { "$$1 :", "definition : type_dcl $$1 ';'", "$$2 :", -"definition : const_dcl $$2 ';'", +"definition : typeid_dcl $$2 ';'", "$$3 :", -"definition : exception $$3 ';'", +"definition : typeprefix_dcl $$3 ';'", "$$4 :", -"definition : interface_def $$4 ';'", +"definition : const_dcl $$4 ';'", "$$5 :", -"definition : module $$5 ';'", +"definition : exception $$5 ';'", "$$6 :", -"definition : value_def $$6 ';'", +"definition : interface_def $$6 ';'", "$$7 :", -"definition : error $$7 ';'", +"definition : module $$7 ';'", "$$8 :", +"definition : value_def $$8 ';'", "$$9 :", +"definition : error $$9 ';'", "$$10 :", "$$11 :", -"module : IDL_MODULE $$8 IDENTIFIER $$9 '{' $$10 definitions $$11 '}'", -"interface_def : interface", -"interface_def : forward", "$$12 :", "$$13 :", +"module : IDL_MODULE $$10 IDENTIFIER $$11 '{' $$12 definitions $$13 '}'", +"interface_def : interface", +"interface_def : forward", "$$14 :", -"interface : interface_header $$12 '{' $$13 exports $$14 '}'", "$$15 :", -"interface_decl : IDL_INTERFACE $$15 id", +"$$16 :", +"interface : interface_header $$14 '{' $$15 exports $$16 '}'", +"$$17 :", +"interface_decl : IDL_INTERFACE $$17 id", "interface_header : interface_decl inheritance_spec", "interface_header : IDL_LOCAL interface_decl inheritance_spec", "interface_header : IDL_ABSTRACT interface_decl inheritance_spec", -"$$16 :", -"inheritance_spec : ':' $$16 at_least_one_scoped_name", +"$$18 :", +"inheritance_spec : ':' $$18 at_least_one_scoped_name", "inheritance_spec :", "value_def : valuetype", "value_def : value_abs_decl", @@ -647,17 +685,17 @@ const char *tao_yyrule[] = { "value_def : value_box_decl", "valuetype : IDL_CUSTOM value_concrete_decl", "valuetype : value_concrete_decl", -"$$17 :", -"$$18 :", "$$19 :", -"value_concrete_decl : value_header $$17 '{' $$18 value_elements $$19 '}'", "$$20 :", "$$21 :", +"value_concrete_decl : value_header $$19 '{' $$20 value_elements $$21 '}'", "$$22 :", -"value_abs_decl : IDL_ABSTRACT value_header $$20 '{' $$21 exports $$22 '}'", -"value_header : value_decl opt_truncatable inheritance_spec supports_spec", "$$23 :", -"value_decl : IDL_VALUETYPE $$23 id", +"$$24 :", +"value_abs_decl : IDL_ABSTRACT value_header $$22 '{' $$23 exports $$24 '}'", +"value_header : value_decl opt_truncatable inheritance_spec supports_spec", +"$$25 :", +"value_decl : IDL_VALUETYPE $$25 id", "opt_truncatable : IDL_TRUNCATABLE", "opt_truncatable :", "supports_spec : IDL_SUPPORTS scoped_name", @@ -670,42 +708,46 @@ const char *tao_yyrule[] = { "value_element : state_member", "value_element : export", "value_element : init_decl ';'", -"$$24 :", -"state_member : IDL_PUBLIC $$24 member_i", -"$$25 :", -"state_member : IDL_PRIVATE $$25 member_i", -"exports : exports export", -"exports :", "$$26 :", -"export : type_dcl $$26 ';'", +"state_member : IDL_PUBLIC $$26 member_i", "$$27 :", -"export : const_dcl $$27 ';'", +"state_member : IDL_PRIVATE $$27 member_i", +"exports : exports export", +"exports :", "$$28 :", -"export : exception $$28 ';'", +"export : type_dcl $$28 ';'", "$$29 :", -"export : attribute $$29 ';'", +"export : typeid_dcl $$29 ';'", "$$30 :", -"export : operation $$30 ';'", +"export : typeprefix_dcl $$30 ';'", "$$31 :", -"export : error $$31 ';'", -"at_least_one_scoped_name : scoped_name scoped_names", +"export : const_dcl $$31 ';'", "$$32 :", -"scoped_names : scoped_names ',' $$32 scoped_name", -"scoped_names :", -"scoped_name : id", +"export : exception $$32 ';'", "$$33 :", -"scoped_name : IDL_SCOPE_DELIMITOR $$33 id", +"export : attribute $$33 ';'", "$$34 :", -"scoped_name : scoped_name IDL_SCOPE_DELIMITOR $$34 id", -"id : IDENTIFIER", -"forward : interface_decl", -"forward : IDL_LOCAL interface_decl", -"forward : IDL_ABSTRACT interface_decl", +"export : operation $$34 ';'", "$$35 :", +"export : error $$35 ';'", +"at_least_one_scoped_name : scoped_name scoped_names", "$$36 :", +"scoped_names : scoped_names ',' $$36 scoped_name", +"scoped_names :", +"scoped_name : id", "$$37 :", +"scoped_name : IDL_SCOPE_DELIMITOR $$37 id", "$$38 :", -"const_dcl : IDL_CONST $$35 const_type $$36 id $$37 '=' $$38 expression", +"scoped_name : scoped_name IDL_SCOPE_DELIMITOR $$38 id", +"id : IDENTIFIER", +"forward : interface_decl", +"forward : IDL_LOCAL interface_decl", +"forward : IDL_ABSTRACT interface_decl", +"$$39 :", +"$$40 :", +"$$41 :", +"$$42 :", +"const_dcl : IDL_CONST $$39 const_type $$40 id $$41 '=' $$42 expression", "const_type : integer_type", "const_type : char_type", "const_type : octet_type", @@ -750,14 +792,14 @@ const char *tao_yyrule[] = { "literal : IDL_TRUETOK", "literal : IDL_FALSETOK", "positive_int_expr : const_expr", -"$$39 :", -"type_dcl : IDL_TYPEDEF $$39 type_declarator", +"$$43 :", +"type_dcl : IDL_TYPEDEF $$43 type_declarator", "type_dcl : struct_type", "type_dcl : union_type", "type_dcl : enum_type", "type_dcl : IDL_NATIVE simple_declarator", -"$$40 :", -"type_declarator : type_spec $$40 at_least_one_declarator", +"$$44 :", +"type_declarator : type_spec $$44 at_least_one_declarator", "type_spec : simple_type_spec", "type_spec : constructed_type_spec", "simple_type_spec : base_type_spec", @@ -777,14 +819,14 @@ const char *tao_yyrule[] = { "constructed_type_spec : union_type", "constructed_type_spec : enum_type", "at_least_one_declarator : declarator declarators", -"$$41 :", -"declarators : declarators ',' $$41 declarator", +"$$45 :", +"declarators : declarators ',' $$45 declarator", "declarators :", "declarator : simple_declarator", "declarator : complex_declarator", "at_least_one_simple_declarator : simple_declarator simple_declarators", -"$$42 :", -"simple_declarators : simple_declarators ',' $$42 simple_declarator", +"$$46 :", +"simple_declarators : simple_declarators ',' $$46 simple_declarator", "simple_declarators :", "simple_declarator : id", "complex_declarator : array_declarator", @@ -805,30 +847,30 @@ const char *tao_yyrule[] = { "octet_type : IDL_OCTET", "boolean_type : IDL_BOOLEAN", "any_type : IDL_ANY", -"$$43 :", -"$$44 :", -"$$45 :", -"$$46 :", -"struct_type : IDL_STRUCT $$43 id $$44 '{' $$45 at_least_one_member $$46 '}'", -"at_least_one_member : member members", -"members : members member", -"members :", "$$47 :", -"member : $$47 member_i", "$$48 :", "$$49 :", -"member_i : type_spec $$48 at_least_one_declarator $$49 ';'", "$$50 :", -"member_i : error $$50 ';'", +"struct_type : IDL_STRUCT $$47 id $$48 '{' $$49 at_least_one_member $$50 '}'", +"at_least_one_member : member members", +"members : members member", +"members :", "$$51 :", +"member : $$51 member_i", "$$52 :", "$$53 :", +"member_i : type_spec $$52 at_least_one_declarator $$53 ';'", "$$54 :", +"member_i : error $$54 ';'", "$$55 :", "$$56 :", "$$57 :", "$$58 :", -"union_type : IDL_UNION $$51 id $$52 IDL_SWITCH $$53 '(' $$54 switch_type_spec $$55 ')' $$56 '{' $$57 at_least_one_case_branch $$58 '}'", +"$$59 :", +"$$60 :", +"$$61 :", +"$$62 :", +"union_type : IDL_UNION $$55 id $$56 IDL_SWITCH $$57 '(' $$58 switch_type_spec $$59 ')' $$60 '{' $$61 at_least_one_case_branch $$62 '}'", "switch_type_spec : integer_type", "switch_type_spec : char_type", "switch_type_spec : octet_type", @@ -838,101 +880,101 @@ const char *tao_yyrule[] = { "at_least_one_case_branch : case_branch case_branches", "case_branches : case_branches case_branch", "case_branches :", -"$$59 :", -"$$60 :", -"case_branch : at_least_one_case_label $$59 element_spec $$60 ';'", -"$$61 :", -"case_branch : error $$61 ';'", -"at_least_one_case_label : case_label case_labels", -"case_labels : case_labels case_label", -"case_labels :", -"$$62 :", -"case_label : IDL_DEFAULT $$62 ':'", "$$63 :", "$$64 :", -"case_label : IDL_CASE $$63 const_expr $$64 ':'", +"case_branch : at_least_one_case_label $$63 element_spec $$64 ';'", "$$65 :", -"element_spec : type_spec $$65 declarator", +"case_branch : error $$65 ';'", +"at_least_one_case_label : case_label case_labels", +"case_labels : case_labels case_label", +"case_labels :", "$$66 :", +"case_label : IDL_DEFAULT $$66 ':'", "$$67 :", "$$68 :", +"case_label : IDL_CASE $$67 const_expr $$68 ':'", "$$69 :", -"enum_type : IDL_ENUM $$66 id $$67 '{' $$68 at_least_one_enumerator $$69 '}'", -"at_least_one_enumerator : enumerator enumerators", +"element_spec : type_spec $$69 declarator", "$$70 :", -"enumerators : enumerators ',' $$70 enumerator", -"enumerators :", -"enumerator : IDENTIFIER", "$$71 :", "$$72 :", -"sequence_type_spec : seq_head ',' $$71 positive_int_expr $$72 '>'", -"sequence_type_spec : seq_head '>'", "$$73 :", +"enum_type : IDL_ENUM $$70 id $$71 '{' $$72 at_least_one_enumerator $$73 '}'", +"at_least_one_enumerator : enumerator enumerators", "$$74 :", -"seq_head : IDL_SEQUENCE $$73 '<' $$74 simple_type_spec", +"enumerators : enumerators ',' $$74 enumerator", +"enumerators :", +"enumerator : IDENTIFIER", "$$75 :", "$$76 :", -"string_type_spec : string_head '<' $$75 positive_int_expr $$76 '>'", -"string_type_spec : string_head", -"string_head : IDL_STRING", +"sequence_type_spec : seq_head ',' $$75 positive_int_expr $$76 '>'", +"sequence_type_spec : seq_head '>'", "$$77 :", "$$78 :", -"wstring_type_spec : wstring_head '<' $$77 positive_int_expr $$78 '>'", -"wstring_type_spec : wstring_head", -"wstring_head : IDL_WSTRING", +"seq_head : IDL_SEQUENCE $$77 '<' $$78 simple_type_spec", "$$79 :", -"array_declarator : id $$79 at_least_one_array_dim", -"at_least_one_array_dim : array_dim array_dims", -"array_dims : array_dims array_dim", -"array_dims :", "$$80 :", +"string_type_spec : string_head '<' $$79 positive_int_expr $$80 '>'", +"string_type_spec : string_head", +"string_head : IDL_STRING", "$$81 :", -"array_dim : '[' $$80 positive_int_expr $$81 ']'", "$$82 :", +"wstring_type_spec : wstring_head '<' $$81 positive_int_expr $$82 '>'", +"wstring_type_spec : wstring_head", +"wstring_head : IDL_WSTRING", "$$83 :", -"attribute : opt_readonly IDL_ATTRIBUTE $$82 param_type_spec $$83 at_least_one_simple_declarator", -"opt_readonly : IDL_READONLY", -"opt_readonly :", +"array_declarator : id $$83 at_least_one_array_dim", +"at_least_one_array_dim : array_dim array_dims", +"array_dims : array_dims array_dim", +"array_dims :", "$$84 :", "$$85 :", +"array_dim : '[' $$84 positive_int_expr $$85 ']'", "$$86 :", "$$87 :", -"exception : IDL_EXCEPTION $$84 id $$85 '{' $$86 members $$87 '}'", +"attribute : opt_readonly IDL_ATTRIBUTE $$86 param_type_spec $$87 at_least_one_simple_declarator", +"opt_readonly : IDL_READONLY", +"opt_readonly :", "$$88 :", "$$89 :", "$$90 :", "$$91 :", -"operation : opt_op_attribute op_type_spec $$88 IDENTIFIER $$89 parameter_list $$90 opt_raises $$91 opt_context", +"exception : IDL_EXCEPTION $$88 id $$89 '{' $$90 members $$91 '}'", +"$$92 :", +"$$93 :", +"$$94 :", +"$$95 :", +"operation : opt_op_attribute op_type_spec $$92 IDENTIFIER $$93 parameter_list $$94 opt_raises $$95 opt_context", "opt_op_attribute : IDL_ONEWAY", "opt_op_attribute : IDL_IDEMPOTENT", "opt_op_attribute :", "op_type_spec : param_type_spec", "op_type_spec : IDL_VOID", -"$$92 :", -"$$93 :", -"init_decl : IDL_FACTORY $$92 IDENTIFIER $$93 init_parameter_list", -"$$94 :", -"init_parameter_list : '(' $$94 ')'", -"$$95 :", -"init_parameter_list : '(' $$95 at_least_one_in_parameter ')'", -"at_least_one_in_parameter : in_parameter in_parameters", "$$96 :", -"in_parameters : in_parameters ',' $$96 in_parameter", -"in_parameters :", "$$97 :", +"init_decl : IDL_FACTORY $$96 IDENTIFIER $$97 init_parameter_list", "$$98 :", -"in_parameter : IDL_IN $$97 param_type_spec $$98 declarator", +"init_parameter_list : '(' $$98 ')'", "$$99 :", -"parameter_list : '(' $$99 ')'", +"init_parameter_list : '(' $$99 at_least_one_in_parameter ')'", +"at_least_one_in_parameter : in_parameter in_parameters", "$$100 :", -"parameter_list : '(' $$100 at_least_one_parameter ')'", -"at_least_one_parameter : parameter parameters", +"in_parameters : in_parameters ',' $$100 in_parameter", +"in_parameters :", "$$101 :", -"parameters : parameters ',' $$101 parameter", -"parameters :", "$$102 :", +"in_parameter : IDL_IN $$101 param_type_spec $$102 declarator", "$$103 :", -"parameter : direction $$102 param_type_spec $$103 declarator", +"parameter_list : '(' $$103 ')'", +"$$104 :", +"parameter_list : '(' $$104 at_least_one_parameter ')'", +"at_least_one_parameter : parameter parameters", +"$$105 :", +"parameters : parameters ',' $$105 parameter", +"parameters :", +"$$106 :", +"$$107 :", +"parameter : direction $$106 param_type_spec $$107 declarator", "param_type_spec : base_type_spec", "param_type_spec : string_type_spec", "param_type_spec : wstring_type_spec", @@ -940,18 +982,20 @@ const char *tao_yyrule[] = { "direction : IDL_IN", "direction : IDL_OUT", "direction : IDL_INOUT", -"$$104 :", -"$$105 :", -"opt_raises : IDL_RAISES $$104 '(' $$105 at_least_one_scoped_name ')'", +"$$108 :", +"$$109 :", +"opt_raises : IDL_RAISES $$108 '(' $$109 at_least_one_scoped_name ')'", "opt_raises :", -"$$106 :", -"$$107 :", -"opt_context : IDL_CONTEXT $$106 '(' $$107 at_least_one_string_literal ')'", +"$$110 :", +"$$111 :", +"opt_context : IDL_CONTEXT $$110 '(' $$111 at_least_one_string_literal ')'", "opt_context :", "at_least_one_string_literal : IDL_STRING_LITERAL string_literals", -"$$108 :", -"string_literals : string_literals ',' $$108 IDL_STRING_LITERAL", +"$$112 :", +"string_literals : string_literals ',' $$112 IDL_STRING_LITERAL", "string_literals :", +"typeid_dcl : IDL_TYPEID scoped_name IDL_STRING_LITERAL", +"typeprefix_dcl : IDL_TYPEPREFIX scoped_name IDL_STRING_LITERAL", }; #endif #define tao_yyclearin (tao_yychar=(-1)) @@ -1301,182 +1345,242 @@ tao_yyreduce: { case 4: { +/* definition : type_dcl*/ idl_global->set_parse_state (IDL_GlobalData::PS_TypeDeclSeen); } break; case 5: { idl_global->set_parse_state (IDL_GlobalData::PS_NoState); +/* ';'*/ } break; case 6: { - idl_global->set_parse_state (IDL_GlobalData::PS_ConstDeclSeen); +/* | typeid_dcl*/ + idl_global->set_parse_state (IDL_GlobalData::PS_TypeIdDeclSeen); } break; case 7: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } break; case 8: { - idl_global->set_parse_state (IDL_GlobalData::PS_ExceptDeclSeen); +/* | typeprefix_dcl*/ + idl_global->set_parse_state (IDL_GlobalData::PS_TypePrefixDeclSeen); } break; case 9: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } break; case 10: { - idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceDeclSeen); +/* | const_dcl*/ + idl_global->set_parse_state (IDL_GlobalData::PS_ConstDeclSeen); } break; case 11: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } break; case 12: { - idl_global->set_parse_state (IDL_GlobalData::PS_ModuleDeclSeen); +/* | exception*/ + idl_global->set_parse_state (IDL_GlobalData::PS_ExceptDeclSeen); } break; case 13: { - idl_global->set_parse_state (IDL_GlobalData::PS_NoState); +/* ';'*/ + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } break; case 14: { - idl_global->set_parse_state (IDL_GlobalData::PS_ValuetypeDeclSeen); +/* | interface_def*/ + idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceDeclSeen); } break; case 15: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } break; case 16: { - idl_global->err()->syntax_error (idl_global->parse_state()); +/* | module*/ + idl_global->set_parse_state (IDL_GlobalData::PS_ModuleDeclSeen); } break; case 17: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); - tao_yyerrok; } break; case 18: { +/* | value_def*/ + idl_global->set_parse_state (IDL_GlobalData::PS_ValuetypeDeclSeen); + } +break; +case 19: +{ +/* ';'*/ + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); + } +break; +case 20: +{ +/* | error*/ + idl_global->err()->syntax_error (idl_global->parse_state()); + } +break; +case 21: +{ +/* ';'*/ + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); + tao_yyerrok; + } +break; +case 22: +{ +/* module : IDL_MODULE*/ idl_global->set_parse_state (IDL_GlobalData::PS_ModuleSeen); } break; -case 19: +case 23: { - UTL_ScopedName *n = - new UTL_ScopedName(new Identifier (tao_yyvsp[0].strval), 0); +/* IDENTIFIER*/ + Identifier id (tao_yyvsp[0].strval); + UTL_ScopedName n (&id, + 0); AST_Module *m = 0; - UTL_Scope *s = idl_global->scopes ()->top_non_null (); + UTL_Scope *s = idl_global->scopes ().top_non_null (); idl_global->set_parse_state (IDL_GlobalData::PS_ModuleIDSeen); /* * Make a new module and add it to the enclosing scope */ - if (s != 0) { - m = idl_global->gen ()->create_module (s, n); - (void) s->fe_add_module (m); - } + if (s != 0) + { + m = idl_global->gen ()->create_module (s, + &n); + (void) s->fe_add_module (m); + } /* * Push it on the stack */ - idl_global->scopes ()->push (m); + idl_global->scopes ().push (m); } break; -case 20: +case 24: { +/* '{'*/ idl_global->set_parse_state (IDL_GlobalData::PS_ModuleSqSeen); } break; -case 21: +case 25: { +/* definitions*/ idl_global->set_parse_state (IDL_GlobalData::PS_ModuleBodySeen); } break; -case 22: +case 26: { +/* '}'*/ idl_global->set_parse_state (IDL_GlobalData::PS_ModuleQsSeen); /* * Finished with this module - pop it from the scope stack */ - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } break; -case 25: +case 29: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* interface : interface_header */ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Interface *i = 0; /* * Make a new interface node and add it to its enclosing scope */ - if (s != 0 && tao_yyvsp[0].ihval != 0) { - i = idl_global->gen ()->create_interface ( - tao_yyvsp[0].ihval->interface_name (), - tao_yyvsp[0].ihval->inherits (), - tao_yyvsp[0].ihval->n_inherits (), - tao_yyvsp[0].ihval->inherits_flat (), - tao_yyvsp[0].ihval->n_inherits_flat (), - tao_yyvsp[0].ihval->is_local (), - tao_yyvsp[0].ihval->is_abstract () - ); - AST_Interface::fwd_redefinition_helper (i, s); - /* - * Add the interface to its definition scope - */ - (void) s->fe_add_interface (i); - } + if (s != 0 && tao_yyvsp[0].ihval != 0) + { + i = + idl_global->gen ()->create_interface ( + tao_yyvsp[0].ihval->interface_name (), + tao_yyvsp[0].ihval->inherits (), + tao_yyvsp[0].ihval->n_inherits (), + tao_yyvsp[0].ihval->inherits_flat (), + tao_yyvsp[0].ihval->n_inherits_flat (), + tao_yyvsp[0].ihval->is_local (), + tao_yyvsp[0].ihval->is_abstract () + ); + AST_Interface::fwd_redefinition_helper (i, + s); + /* + * Add the interface to its definition scope + */ + (void) s->fe_add_interface (i); + } /* * Push it on the scope stack */ - idl_global->scopes ()->push (i); + idl_global->scopes ().push (i); + /* This FE_InterfaceHeader class isn't destroyed with the AST.*/ + tao_yyvsp[0].ihval->interface_name ()->destroy (); + delete tao_yyvsp[0].ihval; + tao_yyvsp[0].ihval = 0; } break; -case 26: +case 30: { +/* '{'*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSqSeen); } break; -case 27: +case 31: { +/* exports*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceBodySeen); } break; -case 28: +case 32: { +/* '}'*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceQsSeen); /* * Done with this interface - pop it off the scopes stack */ - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } break; -case 29: +case 33: { +/* interface_decl : IDL_INTERFACE*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSeen); } break; -case 30: +case 34: { +/* id*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceIDSeen); tao_yyval.idval = tao_yyvsp[0].idval; } break; -case 31: +case 35: { +/* interface_header : interface_decl inheritance_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen); /* * Create an AST representation of the information in the header @@ -1484,11 +1588,17 @@ case 31: * list of all interfaces which this interface inherits from, * recursively */ - tao_yyval.ihval = new FE_InterfaceHeader (new UTL_ScopedName (tao_yyvsp[-1].idval, 0), tao_yyvsp[0].nlval); + UTL_ScopedName n (tao_yyvsp[-1].idval, + 0); + ACE_NEW_RETURN (tao_yyval.ihval, + FE_InterfaceHeader (&n, + tao_yyvsp[0].nlval), + 1); } break; -case 32: +case 36: { +/* | IDL_LOCAL interface_decl inheritance_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_InheritSpecSeen); /* * Create an AST representation of the information in the header @@ -1496,11 +1606,17 @@ case 32: * list of all interfaces which this interface inherits from, * recursively */ - tao_yyval.ihval = new FE_Local_InterfaceHeader (new UTL_ScopedName(tao_yyvsp[-1].idval, 0), tao_yyvsp[0].nlval); + UTL_ScopedName n (tao_yyvsp[-1].idval, + 0); + ACE_NEW_RETURN (tao_yyval.ihval, + FE_InterfaceHeader (&n, + tao_yyvsp[0].nlval), + 1); } break; -case 33: +case 37: { +/* | IDL_ABSTRACT interface_decl inheritance_spec*/ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error in %s line %d\n"), idl_global->filename ()->get_string (), @@ -1510,23 +1626,27 @@ case 33: ACE_TEXT (" interfaces yet\n"))); } break; -case 34: +case 38: { +/* inheritance_spec : ':'*/ idl_global->set_parse_state (IDL_GlobalData::PS_InheritColonSeen); } break; -case 35: +case 39: { +/* at_least_one_scoped_name*/ tao_yyval.nlval = tao_yyvsp[0].nlval; } break; -case 36: +case 40: { +/* | /* EMPTY * /*/ tao_yyval.nlval = 0; } break; -case 41: +case 45: { +/* valuetype : IDL_CUSTOM value_concrete_decl*/ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error in %s line %d\n"), idl_global->filename ()->get_string (), @@ -1536,145 +1656,187 @@ case 41: ACE_TEXT (" custom yet\n"))); } break; -case 43: +case 47: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* value_concrete_decl : value_header*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Interface *i = 0; - if (s != 0 && tao_yyvsp[0].vhval != 0) { - i = idl_global->gen ()->create_valuetype (tao_yyvsp[0].vhval->interface_name (), - tao_yyvsp[0].vhval->inherits (), - tao_yyvsp[0].vhval->n_inherits ()); - AST_Interface::fwd_redefinition_helper (i, s); - /* - * Add the valuetype to its definition scope - */ - (void) s->fe_add_interface (i); - } + if (s != 0 && tao_yyvsp[0].vhval != 0) + { + i = + idl_global->gen ()->create_valuetype ( + tao_yyvsp[0].vhval->interface_name (), + tao_yyvsp[0].vhval->inherits (), + tao_yyvsp[0].vhval->n_inherits () + ); + AST_Interface::fwd_redefinition_helper (i, + s); + /* + * Add the valuetype to its definition scope + */ + (void) s->fe_add_interface (i); + } /* * Push it on the scope stack */ - idl_global->scopes ()->push (i); + idl_global->scopes ().push (i); } break; -case 44: +case 48: { +/* '{'*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSqSeen); } break; -case 45: +case 49: { +/* value_elements*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceBodySeen); } break; -case 46: +case 50: { +/* '}'*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceQsSeen); /* * Done with this interface - pop it off the scopes stack */ - UTL_Scope* s = idl_global->scopes ()->top (); + UTL_Scope* s = idl_global->scopes ().top (); AST_Interface* m = AST_Interface::narrow_from_scope (s); m->inherited_name_clash (); - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } break; -case 47: +case 51: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* value_abs_decl : IDL_ABSTRACT value_header*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Interface *i = 0; - if (s != 0 && tao_yyvsp[0].vhval != 0) { + if (s != 0 && tao_yyvsp[0].vhval != 0) + { + if (tao_yyvsp[0].vhval->n_concrete() > 0) + { + idl_global->err ()->abstract_inheritance_error ( + tao_yyvsp[0].vhval->interface_name () + ); + } - if (tao_yyvsp[0].vhval->n_concrete() > 0) { - idl_global->err ()->abstract_inheritance_error (tao_yyvsp[0].vhval->interface_name ()); + i = + idl_global->gen ()->create_valuetype ( + tao_yyvsp[0].vhval->interface_name (), + tao_yyvsp[0].vhval->inherits (), + tao_yyvsp[0].vhval->n_inherits () + ); + i->set_abstract_valuetype (); + AST_Interface::fwd_redefinition_helper (i, + s); + /* + * Add the valuetype to its definition scope + */ + (void) s->fe_add_interface (i); } - i = idl_global->gen()->create_valuetype (tao_yyvsp[0].vhval->interface_name (), - tao_yyvsp[0].vhval->inherits (), - tao_yyvsp[0].vhval->n_inherits ()); - i->set_abstract_valuetype (); - AST_Interface::fwd_redefinition_helper (i, s); - /* - * Add the valuetype to its definition scope - */ - (void) s->fe_add_interface (i); - } /* - * Push it on the scope stack + * Push it on the scope stack. */ - idl_global->scopes ()->push (i); + idl_global->scopes ().push (i); } break; -case 48: +case 52: { +/* '{'*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceSqSeen); } break; -case 49: +case 53: { +/* exports*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceBodySeen); } break; -case 50: +case 54: { +/* '}'*/ idl_global->set_parse_state (IDL_GlobalData::PS_InterfaceQsSeen); /* * Done with this interface - pop it off the scopes stack */ - UTL_Scope* s = idl_global->scopes ()->top (); + UTL_Scope* s = idl_global->scopes ().top (); AST_Interface* m = AST_Interface::narrow_from_scope (s); m->inherited_name_clash (); - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } break; -case 51: +case 55: { - tao_yyval.vhval = new FE_obv_header (new UTL_ScopedName (tao_yyvsp[-3].idval, 0), tao_yyvsp[-1].nlval, tao_yyvsp[0].nlval); +/* value_header : value_decl opt_truncatable inheritance_spec supports_spec*/ + UTL_ScopedName *sn = 0; + ACE_NEW_RETURN (sn, + UTL_ScopedName (tao_yyvsp[-3].idval, + 0), + 1); + ACE_NEW_RETURN (tao_yyval.vhval, + FE_obv_header (sn, + tao_yyvsp[-1].nlval, + tao_yyvsp[0].nlval), + 1); } break; -case 52: +case 56: { +/* value_decl : IDL_VALUETYPE*/ idl_global->set_parse_state (IDL_GlobalData::PS_ValuetypeSeen); } break; -case 53: +case 57: { - idl_global->set_parse_state (IDL_GlobalData::PS_ValuetypeIDSeen); - tao_yyval.idval = tao_yyvsp[0].idval; +/* id*/ + idl_global->set_parse_state (IDL_GlobalData::PS_ValuetypeIDSeen); + tao_yyval.idval = tao_yyvsp[0].idval; } break; -case 54: +case 58: { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("warning in %s line %d\n"), - idl_global->filename ()->get_string (), - idl_global->lineno ())); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("truncatable modifier not supported ") - ACE_TEXT ("and is ignored\n"))); - tao_yyval.bval = I_FALSE; - } +/* opt_truncatable : IDL_TRUNCATABLE*/ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("warning in %s line %d\n"), + idl_global->filename ()->get_string (), + idl_global->lineno ())); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("truncatable modifier not supported ") + ACE_TEXT ("and is ignored\n"))); + tao_yyval.bval = I_FALSE; + } break; -case 55: +case 59: { +/* | /* EMPTY * /*/ tao_yyval.bval = I_FALSE; } break; -case 56: +case 60: { - tao_yyval.nlval = new UTL_NameList (tao_yyvsp[0].idlist, 0); - } +/* supports_spec : IDL_SUPPORTS scoped_name*/ + ACE_NEW_RETURN (tao_yyval.nlval, + UTL_NameList (tao_yyvsp[0].idlist, + 0), + 1); + } break; -case 57: +case 61: { - tao_yyval.nlval = 0; - } +/* | /* EMPTY * /*/ + tao_yyval.nlval = 0; + } break; -case 58: +case 62: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName (tao_yyvsp[0].idval, 0); +/* value_forward_decl : IDL_ABSTRACT value_decl*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n (tao_yyvsp[0].idval, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -1682,17 +1844,20 @@ case 58: * Create a node representing a forward declaration of an * valuetype. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen()->create_valuetype_fwd (n); - f->set_abstract_valuetype (); - (void) s->fe_add_interface_fwd (f); + if (s != 0) + { + f = idl_global->gen()->create_valuetype_fwd (&n); + f->set_abstract_valuetype (); + (void) s->fe_add_interface_fwd (f); } } break; -case 59: +case 63: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName (tao_yyvsp[0].idval, 0); +/* | value_decl*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n (tao_yyvsp[0].idval, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -1700,14 +1865,16 @@ case 59: * Create a node representing a forward declaration of an * valuetype. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen ()->create_valuetype_fwd (n); - (void) s->fe_add_interface_fwd (f); - } + if (s != 0) + { + f = idl_global->gen ()->create_valuetype_fwd (&n); + (void) s->fe_add_interface_fwd (f); + } } break; -case 60: +case 64: { +/* value_box_decl : value_decl type_spec*/ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error in %s line %d\n"), idl_global->filename ()->get_string (), @@ -1717,148 +1884,233 @@ case 60: ACE_TEXT (" boxes yet\n"))); } break; -case 66: +case 70: { - /* is $0 to member_i */ - tao_yyval.vival = AST_Field::vis_PUBLIC; - } +/* state_member : IDL_PUBLIC*/ + /* is $0 to member_i */ + tao_yyval.vival = AST_Field::vis_PUBLIC; + } break; -case 68: +case 72: { - /* is $0 to member_i */ - tao_yyval.vival = AST_Field::vis_PRIVATE; - } + /* is $0 to member_i */ + tao_yyval.vival = AST_Field::vis_PRIVATE; + } break; -case 72: +case 76: { +/* export : type_dcl*/ idl_global->set_parse_state (IDL_GlobalData::PS_TypeDeclSeen); } break; -case 73: +case 77: +{ +/* ';'*/ + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); + } +break; +case 78: +{ +/* | typeid_dcl*/ + idl_global->set_parse_state (IDL_GlobalData::PS_TypeIdDeclSeen); + } +break; +case 79: +{ +/* ';'*/ + idl_global->set_parse_state (IDL_GlobalData::PS_NoState); + } +break; +case 80: +{ +/* | typeprefix_dcl*/ + idl_global->set_parse_state (IDL_GlobalData::PS_TypePrefixDeclSeen); + } +break; +case 81: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } break; -case 74: +case 82: { +/* | const_dcl*/ idl_global->set_parse_state (IDL_GlobalData::PS_ConstDeclSeen); } break; -case 75: +case 83: { +/* ';'*/ idl_global->set_parse_state(IDL_GlobalData::PS_NoState); } break; -case 76: +case 84: { +/* | exception*/ idl_global->set_parse_state (IDL_GlobalData::PS_ExceptDeclSeen); } break; -case 77: +case 85: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } break; -case 78: +case 86: { +/* | attribute*/ idl_global->set_parse_state (IDL_GlobalData::PS_AttrDeclSeen); } break; -case 79: +case 87: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } break; -case 80: +case 88: { +/* | operation*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpDeclSeen); } break; -case 81: +case 89: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); } break; -case 82: +case 90: { +/* | error*/ idl_global->err()->syntax_error (idl_global->parse_state()); } break; -case 83: +case 91: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); tao_yyerrok; } break; -case 84: +case 92: { - tao_yyval.nlval = new UTL_NameList (tao_yyvsp[-1].idlist, tao_yyvsp[0].nlval); +/*at_least_one_scoped_name : scoped_name scoped_names*/ + ACE_NEW_RETURN (tao_yyval.nlval, + UTL_NameList (tao_yyvsp[-1].idlist, + tao_yyvsp[0].nlval), + 1); } break; -case 85: +case 93: { +/* scoped_names : scoped_names ','*/ idl_global->set_parse_state (IDL_GlobalData::PS_SNListCommaSeen); } break; -case 86: +case 94: { +/* scoped_name*/ idl_global->set_parse_state (IDL_GlobalData::PS_ScopedNameSeen); if (tao_yyvsp[-3].nlval == 0) - tao_yyval.nlval = new UTL_NameList (tao_yyvsp[0].idlist, 0); - else { - tao_yyvsp[-3].nlval->nconc (new UTL_NameList (tao_yyvsp[0].idlist, 0)); - tao_yyval.nlval = tao_yyvsp[-3].nlval; - } + { + ACE_NEW_RETURN (tao_yyval.nlval, + UTL_NameList (tao_yyvsp[0].idlist, + 0), + 1); + } + else + { + UTL_NameList *nl = 0; + ACE_NEW_RETURN (nl, + UTL_NameList (tao_yyvsp[0].idlist, + 0), + 1); + tao_yyvsp[-3].nlval->nconc (nl); + tao_yyval.nlval = tao_yyvsp[-3].nlval; + } } break; -case 87: +case 95: { +/* | /* EMPTY * /*/ tao_yyval.nlval = 0; } break; -case 88: +case 96: { +/* scoped_name : id*/ idl_global->set_parse_state (IDL_GlobalData::PS_SN_IDSeen); - tao_yyval.idlist = new UTL_IdList(tao_yyvsp[0].idval, 0); + ACE_NEW_RETURN (tao_yyval.idlist, + UTL_IdList (tao_yyvsp[0].idval, + 0), + 1); } break; -case 89: +case 97: { +/* | IDL_SCOPE_DELIMITOR*/ idl_global->set_parse_state (IDL_GlobalData::PS_ScopeDelimSeen); } break; -case 90: +case 98: { +/* id*/ idl_global->set_parse_state (IDL_GlobalData::PS_SN_IDSeen); - tao_yyval.idlist = new UTL_IdList (new Identifier (tao_yyvsp[-2].strval), - new UTL_IdList (tao_yyvsp[0].idval, 0)); + Identifier *id = 0; + ACE_NEW_RETURN (id, + Identifier (tao_yyvsp[-2].strval), + 1); + UTL_IdList *sn = 0; + ACE_NEW_RETURN (sn, + UTL_IdList (tao_yyvsp[0].idval, + 0), + 1); + ACE_NEW_RETURN (tao_yyval.idlist, + UTL_IdList (id, + sn), + 1); } break; -case 91: +case 99: { +/* | scoped_name IDL_SCOPE_DELIMITOR*/ idl_global->set_parse_state (IDL_GlobalData::PS_ScopeDelimSeen); } break; -case 92: +case 100: { +/* id*/ idl_global->set_parse_state (IDL_GlobalData::PS_SN_IDSeen); - tao_yyvsp[-3].idlist->nconc (new UTL_IdList (tao_yyvsp[0].idval, 0)); + UTL_IdList *sn = 0; + ACE_NEW_RETURN (sn, + UTL_IdList (tao_yyvsp[0].idval, + 0), + 1); + tao_yyvsp[-3].idlist->nconc (sn); tao_yyval.idlist = tao_yyvsp[-3].idlist; } break; -case 93: +case 101: { - tao_yyval.idval = new Identifier (tao_yyvsp[0].strval); +/* id: IDENTIFIER*/ + ACE_NEW_RETURN (tao_yyval.idval, + Identifier (tao_yyvsp[0].strval), + 1); + ACE_OS::free (tao_yyvsp[0].strval); } break; -case 94: +case 102: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName(tao_yyvsp[0].idval, 0); +/* forward : interface_decl*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n (tao_yyvsp[0].idval, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -1866,16 +2118,21 @@ case 94: * Create a node representing a forward declaration of an * interface. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen ()->create_interface_fwd (n, 0, 0); - (void) s->fe_add_interface_fwd (f); - } + if (s != 0) + { + f = idl_global->gen ()->create_interface_fwd (&n, + 0, + 0); + (void) s->fe_add_interface_fwd (f); + } } break; -case 95: +case 103: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName (tao_yyvsp[0].idval, 0); +/* | IDL_LOCAL interface_decl*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n (tao_yyvsp[0].idval, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -1883,16 +2140,21 @@ case 95: * Create a node representing a forward declaration of an * interface. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen ()->create_interface_fwd (n, 1, 0); - (void) s->fe_add_interface_fwd (f); - } + if (s != 0) + { + f = idl_global->gen ()->create_interface_fwd (&n, + 1, + 0); + (void) s->fe_add_interface_fwd (f); + } } break; -case 96: +case 104: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName (tao_yyvsp[0].idval, 0); +/* | IDL_ABSTRACT interface_decl*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n (tao_yyvsp[0].idval, + 0); AST_InterfaceFwd *f = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ForwardDeclSeen); @@ -1900,68 +2162,103 @@ case 96: * Create a node representing a forward declaration of an * interface. Store it in the enclosing scope */ - if (s != 0) { - f = idl_global->gen ()->create_interface_fwd (n, 0, 1); - (void) s->fe_add_interface_fwd (f); - } + if (s != 0) + { + f = idl_global->gen ()->create_interface_fwd (&n, + 0, + 1); + (void) s->fe_add_interface_fwd (f); + } } break; -case 97: +case 105: { +/* const_dcl : IDL_CONST*/ idl_global->set_parse_state (IDL_GlobalData::PS_ConstSeen); } break; -case 98: +case 106: { +/* const_type*/ idl_global->set_parse_state (IDL_GlobalData::PS_ConstTypeSeen); } break; -case 99: +case 107: { +/* id*/ idl_global->set_parse_state (IDL_GlobalData::PS_ConstIDSeen); } break; -case 100: +case 108: { +/* '='*/ idl_global->set_parse_state (IDL_GlobalData::PS_ConstAssignSeen); } break; -case 101: +case 109: { - UTL_ScopedName *n = new UTL_ScopedName (tao_yyvsp[-4].idval, 0); - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* expression*/ + UTL_ScopedName n (tao_yyvsp[-4].idval, + 0); + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Constant *c = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ConstExprSeen); /* * Create a node representing a constant declaration. Store - * it in the enclosing scope + * it in the enclosing scope. */ - if (tao_yyvsp[0].exval != 0 && s != 0) { - if (tao_yyvsp[0].exval->coerce (tao_yyvsp[-6].etval) == 0) - idl_global->err ()->coercion_error (tao_yyvsp[0].exval, tao_yyvsp[-6].etval); - else { - c = - idl_global->gen ()->create_constant (tao_yyvsp[-6].etval, tao_yyvsp[0].exval, n); - (void) s->fe_add_constant (c); + if (tao_yyvsp[0].exval != 0 && s != 0) + { + AST_Expression::AST_ExprValue *result = + tao_yyvsp[0].exval->coerce (tao_yyvsp[-6].etval); + + if (result == 0) + { + idl_global->err ()->coercion_error (tao_yyvsp[0].exval, + tao_yyvsp[-6].etval); + } + else + { + c = + idl_global->gen ()->create_constant ( + tao_yyvsp[-6].etval, + tao_yyvsp[0].exval, + &n + ); + (void) s->fe_add_constant (c); + delete result; + } + + tao_yyvsp[-4].idval->destroy (); + delete tao_yyvsp[-4].idval; + tao_yyvsp[-4].idval = 0; } - } } break; -case 108: +case 116: { +/* const_type*/ +/* : integer_type*/ +/* | char_type*/ +/* | octet_type*/ +/* | boolean_type*/ +/* | floating_pt_type*/ +/* | fixed_type*/ +/* | string_type_spec*/ tao_yyval.etval = AST_Expression::EV_string; } break; -case 109: +case 117: { +/* | wstring_type_spec*/ tao_yyval.etval = AST_Expression::EV_wstring; } break; -case 110: +case 118: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - AST_Decl *d = 0; +/* | scoped_name*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_PredefinedType *c = 0; AST_Typedef *t = 0; @@ -1969,135 +2266,217 @@ case 110: * If the constant's type is a scoped name, it must resolve * to a scalar constant type */ - if (s != 0 && (d = s->lookup_by_name (tao_yyvsp[0].idlist, I_TRUE)) != 0) { - /* - * Look through typedefs - */ - while (d->node_type () == AST_Decl::NT_typedef) { - t = AST_Typedef::narrow_from_decl (d); - if (t == 0) - break; - d = t->base_type (); - } - if (d == 0) - tao_yyval.etval = AST_Expression::EV_any; - else if (d->node_type () == AST_Decl::NT_pre_defined) { - c = AST_PredefinedType::narrow_from_decl (d); - if (c != 0) { - tao_yyval.etval = idl_global->PredefinedTypeToExprType (c->pt ()); - } else { - tao_yyval.etval = AST_Expression::EV_any; - } - } else if (d->node_type () == AST_Decl::NT_string) { - tao_yyval.etval = AST_Expression::EV_string; - } else if (d->node_type () == AST_Decl::NT_wstring) { - tao_yyval.etval = AST_Expression::EV_wstring; - } else + AST_Decl *d = + s->lookup_by_name (tao_yyvsp[0].idlist, + I_TRUE); + + if (s != 0 && d != 0) + { + /* + * Look through typedefs. + */ + while (d->node_type () == AST_Decl::NT_typedef) + { + t = AST_Typedef::narrow_from_decl (d); + + if (t == 0) + { + break; + } + + d = t->base_type (); + } + + if (d == 0) + { + tao_yyval.etval = AST_Expression::EV_any; + } + else if (d->node_type () == AST_Decl::NT_pre_defined) + { + c = AST_PredefinedType::narrow_from_decl (d); + + if (c != 0) + { + tao_yyval.etval = idl_global->PredefinedTypeToExprType (c->pt ()); + } + else + { + tao_yyval.etval = AST_Expression::EV_any; + } + } + else if (d->node_type () == AST_Decl::NT_string) + { + tao_yyval.etval = AST_Expression::EV_string; + } + else if (d->node_type () == AST_Decl::NT_wstring) + { + tao_yyval.etval = AST_Expression::EV_wstring; + } + else + { + tao_yyval.etval = AST_Expression::EV_any; + } + } + else + { tao_yyval.etval = AST_Expression::EV_any; - } else - tao_yyval.etval = AST_Expression::EV_any; + } } break; -case 114: +case 122: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_or, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* or_expr : xor_expr*/ +/* | or_expr '|' xor_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_or, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 116: +case 124: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_xor, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* xor_expr : and_expr*/ +/* | xor_expr '^' and_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_xor, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 118: +case 126: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_and, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* and_expr : shift_expr | and_expr '&' shift_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_and, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 120: +case 128: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_left, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* shift_expr : add_expr | shift_expr IDL_LEFT_SHIFT add_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_left, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 121: +case 129: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_right, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* | shift_expr IDL_RIGHT_SHIFT add_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_right, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 123: +case 131: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_add, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* add_expr : mult_expr | add_expr '+' mult_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_add, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 124: +case 132: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_minus, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* | add_expr '-' mult_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_minus, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 126: +case 134: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_mul, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* mult_expr : unary_expr | mult_expr '*' unary_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_mul, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 127: +case 135: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_div, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* | mult_expr '/' unary_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_div, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 128: +case 136: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_mod, - tao_yyvsp[-2].exval, - tao_yyvsp[0].exval); +/* | mult_expr '%' unary_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_mod, + tao_yyvsp[-2].exval, + tao_yyvsp[0].exval + ); } break; -case 130: +case 138: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_u_plus, - tao_yyvsp[0].exval, - 0); +/* unary_expr : primary_expr | '+' primary_expr*/ + tao_yyval.exval = + idl_global->gen ()->create_expr ( + AST_Expression::EC_u_plus, + tao_yyvsp[0].exval, + 0 + ); } break; -case 131: +case 139: { - tao_yyval.exval = idl_global->gen()->create_expr (AST_Expression::EC_u_minus, - tao_yyvsp[0].exval, - 0); +/* | '-' primary_expr*/ + tao_yyval.exval = + idl_global->gen()->create_expr ( + AST_Expression::EC_u_minus, + tao_yyvsp[0].exval, + 0 + ); } break; -case 132: +case 140: { - tao_yyval.exval = idl_global->gen()->create_expr (AST_Expression::EC_bit_neg, - tao_yyvsp[0].exval, - 0); +/* | '~' primary_expr*/ + tao_yyval.exval = + idl_global->gen()->create_expr ( + AST_Expression::EC_bit_neg, + tao_yyvsp[0].exval, + 0 + ); } break; -case 133: +case 141: { +/* primary_expr : scoped_name*/ /* * An expression which is a scoped name is not resolved now, * but only when it is evaluated (such as when it is assigned * as a constant value). */ - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = s->lookup_by_name (tao_yyvsp[0].idlist, 1); @@ -2120,65 +2499,75 @@ case 133: } } break; -case 135: +case 143: { +/* | literal*/ +/* | '(' const_expr ')'*/ tao_yyval.exval = tao_yyvsp[-1].exval; } break; -case 136: +case 144: { +/* literal : IDL_INTEGER_LITERAL*/ tao_yyval.exval = idl_global->gen ()->create_expr (tao_yyvsp[0].ival); } break; -case 137: +case 145: { +/* | IDL_UINTEGER_LITERAL*/ tao_yyval.exval = idl_global->gen ()->create_expr (tao_yyvsp[0].uival); } break; -case 138: +case 146: { +/* | IDL_STRING_LITERAL*/ tao_yyval.exval = idl_global->gen ()->create_expr (tao_yyvsp[0].sval); } break; -case 139: +case 147: { +/* | IDL_WSTRING_LITERAL*/ tao_yyval.exval = idl_global->gen ()->create_expr (tao_yyvsp[0].wsval); } break; -case 140: +case 148: { +/* | IDL_CHARACTER_LITERAL*/ tao_yyval.exval = idl_global->gen ()->create_expr (tao_yyvsp[0].cval); } break; -case 141: +case 149: { +/* | IDL_WCHAR_LITERAL*/ ACE_OutputCDR::from_wchar wc (tao_yyvsp[0].wcval); tao_yyval.exval = idl_global->gen ()->create_expr (wc); } break; -case 142: +case 150: { +/* | IDL_FLOATING_PT_LITERAL*/ tao_yyval.exval = idl_global->gen ()->create_expr (tao_yyvsp[0].dval); } break; -case 143: +case 151: { +/* | IDL_TRUETOK*/ tao_yyval.exval = idl_global->gen ()->create_expr ((idl_bool) I_TRUE, AST_Expression::EV_bool); } break; -case 144: +case 152: { +/* | IDL_FALSETOK*/ tao_yyval.exval = idl_global->gen ()->create_expr ((idl_bool) I_FALSE, AST_Expression::EV_bool); } break; -case 145: +case 153: { +/* positive_int_expr : const_expr*/ int good_expression = 1; - tao_yyvsp[0].exval->evaluate (AST_Expression::EK_positive_int); - AST_Expression::AST_ExprValue *ev = tao_yyvsp[0].exval->ev (); /* @@ -2238,26 +2627,40 @@ case 145: } } break; -case 146: +case 154: { - idl_global->set_parse_state (IDL_GlobalData::PS_TypedefSeen); - } +/* type_dcl : IDL_TYPEDEF*/ + idl_global->set_parse_state (IDL_GlobalData::PS_TypedefSeen); + } break; -case 147: -{tao_yyval.ival = 0;} +case 155: +{ +/* type_declarator */ + tao_yyval.ival = 0; + } break; -case 148: -{ tao_yyval.ival = 0;} +case 156: +{ +/* | struct_type */ + tao_yyval.ival = 0; + } break; -case 149: -{ tao_yyval.ival = 0;} +case 157: +{ +/* | union_type */ + tao_yyval.ival = 0; + } break; -case 150: -{ tao_yyval.ival = 0;} +case 158: +{ +/* | enum_type */ + tao_yyval.ival = 0; + } break; -case 151: +case 159: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* | IDL_NATIVE simple_declarator*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Native *node = 0; idl_global->set_parse_state (IDL_GlobalData::PS_NativeSeen); @@ -2265,23 +2668,29 @@ case 151: * Create a node representing a Native and add it to its * enclosing scope */ - if (s != 0) { - node = idl_global->gen ()->create_native (tao_yyvsp[0].deval->name ()); - /* - * Add it to its defining scope - */ - (void) s->fe_add_native (node); - } + if (s != 0) + { + node = + idl_global->gen ()->create_native ( + tao_yyvsp[0].deval->name () + ); + /* + * Add it to its defining scope + */ + (void) s->fe_add_native (node); + } } break; -case 152: +case 160: { +/* type_declarator : type_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_TypeSpecSeen); } break; -case 153: +case 161: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* at_least_one_declarator*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); FE_Declarator *d = 0; AST_Typedef *t = 0; @@ -2290,155 +2699,247 @@ case 153: * Create a list of type renamings. Add them to the * enclosing scope */ - if (s != 0 && tao_yyvsp[-2].dcval != 0 && tao_yyvsp[0].dlval != 0) { - for (UTL_DecllistActiveIterator l (tao_yyvsp[0].dlval); !l.is_done (); l.next ()) { - d = l.item (); - if (d == 0) - continue; - AST_Type * tp = d->compose (tao_yyvsp[-2].dcval); - if (tp == 0) - continue; - t = idl_global->gen ()->create_typedef (tp, - d->name (), - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_typedef (t); + if (s != 0 && tao_yyvsp[-2].dcval != 0 && tao_yyvsp[0].dlval != 0) + { + for (UTL_DecllistActiveIterator l (tao_yyvsp[0].dlval); + !l.is_done (); + l.next ()) + { + d = l.item (); + + if (d == 0) + { + continue; + } + + AST_Type * tp = d->compose (tao_yyvsp[-2].dcval); + + if (tp == 0) + { + continue; + } + + t = idl_global->gen ()->create_typedef (tp, + d->name (), + s->is_local (), + s->is_abstract ()); + (void) s->fe_add_typedef (t); + } + + /* This FE_Declarator class isn't destroyed with the AST.*/ + tao_yyvsp[0].dlval->destroy (); + delete tao_yyvsp[0].dlval; + tao_yyvsp[0].dlval = 0; } - } } break; -case 156: +case 164: { - tao_yyval.dcval = idl_global->scopes ()->bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); +/* simple_type_spec : base_type_spec*/ + tao_yyval.dcval = + idl_global->scopes ().bottom ()->lookup_primitive_type ( + tao_yyvsp[0].etval + ); } break; -case 158: +case 166: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* | template_type_spec*/ +/* | scoped_name*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = 0; if (s != 0) - d = s->lookup_by_name (tao_yyvsp[0].idlist, I_TRUE); + { + d = s->lookup_by_name (tao_yyvsp[0].idlist, + I_TRUE); + } + if (d == 0) - idl_global->err ()->lookup_error (tao_yyvsp[0].idlist); + { + idl_global->err ()->lookup_error (tao_yyvsp[0].idlist); + } + tao_yyval.dcval = d; } break; -case 172: +case 180: { - tao_yyval.dlval = new UTL_DeclList (tao_yyvsp[-1].deval, tao_yyvsp[0].dlval); +/* at_least_one_declarator : declarator declarators*/ + ACE_NEW_RETURN (tao_yyval.dlval, + UTL_DeclList (tao_yyvsp[-1].deval, + tao_yyvsp[0].dlval), + 1); } break; -case 173: +case 181: { +/* declarators : declarators ','*/ idl_global->set_parse_state (IDL_GlobalData::PS_DeclsCommaSeen); } break; -case 174: +case 182: { +/* declarator*/ idl_global->set_parse_state (IDL_GlobalData::PS_DeclsDeclSeen); if (tao_yyvsp[-3].dlval == 0) - tao_yyval.dlval = new UTL_DeclList (tao_yyvsp[0].deval, 0); - else { - tao_yyvsp[-3].dlval->nconc (new UTL_DeclList (tao_yyvsp[0].deval, 0)); - tao_yyval.dlval = tao_yyvsp[-3].dlval; - } + { + ACE_NEW_RETURN (tao_yyval.dlval, + UTL_DeclList (tao_yyvsp[0].deval, + 0), + 1); + } + else + { + UTL_DeclList *dl = 0; + ACE_NEW_RETURN (dl, + UTL_DeclList (tao_yyvsp[0].deval, + 0), + 1); + tao_yyvsp[-3].dlval->nconc (dl); + tao_yyval.dlval = tao_yyvsp[-3].dlval; + } } break; -case 175: +case 183: { +/* | /* EMPTY * /*/ tao_yyval.dlval = 0; } break; -case 178: +case 186: { - tao_yyval.dlval = new UTL_DeclList (tao_yyvsp[-1].deval, tao_yyvsp[0].dlval); +/* at_least_one_simple_declarator : simple_declarator simple_declarators*/ + ACE_NEW_RETURN (tao_yyval.dlval, + UTL_DeclList (tao_yyvsp[-1].deval, + tao_yyvsp[0].dlval), + 1); } break; -case 179: +case 187: { +/* simple_declarators : simple_declarators ','*/ idl_global->set_parse_state (IDL_GlobalData::PS_DeclsCommaSeen); } break; -case 180: +case 188: { +/* simple_declarator*/ idl_global->set_parse_state (IDL_GlobalData::PS_DeclsDeclSeen); if (tao_yyvsp[-3].dlval == 0) - tao_yyval.dlval = new UTL_DeclList (tao_yyvsp[0].deval, 0); - else { - tao_yyvsp[-3].dlval->nconc (new UTL_DeclList (tao_yyvsp[0].deval, 0)); - tao_yyval.dlval = tao_yyvsp[-3].dlval; - } + { + ACE_NEW_RETURN (tao_yyval.dlval, + UTL_DeclList (tao_yyvsp[0].deval, + 0), + 1); + } + else + { + UTL_DeclList *dl = 0; + ACE_NEW_RETURN (dl, + UTL_DeclList (tao_yyvsp[0].deval, + 0), + 1); + tao_yyvsp[-3].dlval->nconc (dl); + tao_yyval.dlval = tao_yyvsp[-3].dlval; + } } break; -case 181: +case 189: { +/* | /* EMPTY * /*/ tao_yyval.dlval = 0; } break; -case 182: +case 190: { - tao_yyval.deval = new FE_Declarator (new UTL_ScopedName (tao_yyvsp[0].idval, 0), - FE_Declarator::FD_simple, 0); +/* simple_declarator : id*/ + UTL_ScopedName *sn = 0; + ACE_NEW_RETURN (sn, + UTL_ScopedName (tao_yyvsp[0].idval, + 0), + 1); + ACE_NEW_RETURN (tao_yyval.deval, + FE_Declarator (sn, + FE_Declarator::FD_simple, + 0), + 1); } break; -case 183: +case 191: { - tao_yyval.deval = new FE_Declarator (new UTL_ScopedName (tao_yyvsp[0].dcval->local_name (), - 0), - FE_Declarator::FD_complex, - tao_yyvsp[0].dcval); +/* complex_declarator : array_declarator*/ + UTL_ScopedName *sn = 0; + ACE_NEW_RETURN (sn, + UTL_ScopedName (tao_yyvsp[0].dcval->local_name (), + 0), + 1); + ACE_NEW_RETURN (tao_yyval.deval, + FE_Declarator (sn, + FE_Declarator::FD_complex, + tao_yyvsp[0].dcval), + 1); } break; -case 186: +case 194: { +/* signed_int : IDL_LONG*/ tao_yyval.etval = AST_Expression::EV_long; } break; -case 187: +case 195: { +/* | IDL_LONG IDL_LONG*/ tao_yyval.etval = AST_Expression::EV_longlong; } break; -case 188: +case 196: { +/* | IDL_SHORT*/ tao_yyval.etval = AST_Expression::EV_short; } break; -case 189: +case 197: { +/* unsigned_int : IDL_UNSIGNED IDL_LONG*/ tao_yyval.etval = AST_Expression::EV_ulong; } break; -case 190: +case 198: { +/* | IDL_UNSIGNED IDL_LONG IDL_LONG*/ tao_yyval.etval = AST_Expression::EV_ulonglong; } break; -case 191: +case 199: { +/* | IDL_UNSIGNED IDL_SHORT*/ tao_yyval.etval = AST_Expression::EV_ushort; } break; -case 192: +case 200: { +/* floating_pt_type : IDL_DOUBLE*/ tao_yyval.etval = AST_Expression::EV_double; } break; -case 193: +case 201: { +/* | IDL_FLOAT*/ tao_yyval.etval = AST_Expression::EV_float; } break; -case 194: +case 202: { +/* | IDL_LONG IDL_DOUBLE*/ tao_yyval.etval = AST_Expression::EV_longdouble; } break; -case 195: +case 203: { +/* fixed_type : IDL_FIXED*/ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("error in %s line %d\n"), idl_global->filename ()->get_string (), @@ -2448,40 +2949,48 @@ case 195: ACE_TEXT (" fixed types yet\n"))); } break; -case 196: +case 204: { +/* char_type : IDL_CHAR*/ tao_yyval.etval = AST_Expression::EV_char; } break; -case 197: +case 205: { +/* | IDL_WCHAR*/ tao_yyval.etval = AST_Expression::EV_wchar; } break; -case 198: +case 206: { +/* octet_type : IDL_OCTET*/ tao_yyval.etval = AST_Expression::EV_octet; } break; -case 199: +case 207: { +/* boolean_type : IDL_BOOLEAN*/ tao_yyval.etval = AST_Expression::EV_bool; } break; -case 200: +case 208: { +/* any_type : IDL_ANY*/ tao_yyval.etval = AST_Expression::EV_any; } break; -case 201: +case 209: { +/* struct_type : IDL_STRUCT*/ idl_global->set_parse_state (IDL_GlobalData::PS_StructSeen); } break; -case 202: +case 210: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName (tao_yyvsp[0].idval, 0); +/* id*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n (tao_yyvsp[0].idval, + 0); AST_Structure *d = 0; idl_global->set_parse_state (IDL_GlobalData::PS_StructIDSeen); @@ -2489,59 +2998,68 @@ case 202: * Create a node representing a struct declaration. Add it * to the enclosing scope */ - if (s != 0) { - d = idl_global->gen ()->create_structure (n, - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_structure (d); - } + if (s != 0) + { + d = + idl_global->gen ()->create_structure ( + &n, + s->is_local (), + s->is_abstract () + ); + (void) s->fe_add_structure (d); + } /* * Push the scope of the struct on the scopes stack */ - idl_global->scopes ()->push (d); + idl_global->scopes ().push (d); } break; -case 203: +case 211: { idl_global->set_parse_state (IDL_GlobalData::PS_StructSqSeen); } break; -case 204: +case 212: { +/* at_least_one_member*/ idl_global->set_parse_state (IDL_GlobalData::PS_StructBodySeen); } break; -case 205: +case 213: { idl_global->set_parse_state (IDL_GlobalData::PS_StructQsSeen); /* * Done with this struct. Pop its scope off the scopes stack */ tao_yyval.dcval = AST_Structure::narrow_from_scope ( - idl_global->scopes ()->top_non_null () + idl_global->scopes ().top_non_null () ); - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } break; -case 209: +case 217: { +/* member :*/ /* is $0 to member_i */ tao_yyval.vival = AST_Field::vis_NA; } break; -case 211: +case 219: { +/* member_i : type_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_MemberTypeSeen); } break; -case 212: +case 220: { +/* at_least_one_declarator*/ idl_global->set_parse_state (IDL_GlobalData::PS_MemberDeclsSeen); } break; -case 213: +case 221: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* ';'*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); FE_Declarator *d = 0; AST_Field *f = 0; @@ -2549,158 +3067,207 @@ case 213: /* * Check for illegal recursive use of type */ - if (tao_yyvsp[-4].dcval != 0 && AST_illegal_recursive_type (tao_yyvsp[-4].dcval)) - idl_global->err ()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE, - tao_yyvsp[-4].dcval); + if (tao_yyvsp[-4].dcval != 0 + && AST_illegal_recursive_type (tao_yyvsp[-4].dcval)) + { + idl_global->err ()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE, + tao_yyvsp[-4].dcval); + } /* * Create a node representing a struct or exception member * Add it to the enclosing scope */ - else if (s != 0 && tao_yyvsp[-4].dcval != 0 && tao_yyvsp[-2].dlval != 0) { - for (UTL_DecllistActiveIterator l (tao_yyvsp[-2].dlval); !(l.is_done ()); l.next ()) { - d = l.item (); - if (d == 0) - continue; - AST_Type *tp = d->compose (tao_yyvsp[-4].dcval); - if (tp == 0) - continue; - /* $0 denotes Visibility, must be on yacc reduction stack */ - f = idl_global->gen ()->create_field (tp, - d->name (), - tao_yyvsp[-5].vival); - (void) s->fe_add_field (f); - } + else if (s != 0 + && tao_yyvsp[-4].dcval != 0 + && tao_yyvsp[-2].dlval != 0) + { + for (UTL_DecllistActiveIterator l (tao_yyvsp[-2].dlval); + !l.is_done (); + l.next ()) + { + d = l.item (); + + if (d == 0) + { + continue; + } + + AST_Type *tp = d->compose (tao_yyvsp[-4].dcval); + + if (tp == 0) + { + continue; + } + + /* $0 denotes Visibility, must be on yacc reduction stack */ + f = + idl_global->gen ()->create_field ( + tp, + d->name (), + tao_yyvsp[-5].vival + ); + (void) s->fe_add_field (f); + } } } break; -case 214: +case 222: { +/* | error*/ idl_global->err()->syntax_error (idl_global->parse_state ()); } break; -case 215: +case 223: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); tao_yyerrok; } break; -case 216: +case 224: { +/* union_type : IDL_UNION*/ idl_global->set_parse_state (IDL_GlobalData::PS_UnionSeen); } break; -case 217: +case 225: { +/* id*/ idl_global->set_parse_state (IDL_GlobalData::PS_UnionIDSeen); } break; -case 218: +case 226: { +/* IDL_SWITCH*/ idl_global->set_parse_state (IDL_GlobalData::PS_SwitchSeen); } break; -case 219: +case 227: { +/* '('*/ idl_global->set_parse_state (IDL_GlobalData::PS_SwitchOpenParSeen); } break; -case 220: +case 228: { +/* switch_type_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_SwitchTypeSeen); } break; -case 221: +case 229: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName (tao_yyvsp[-8].idval, 0); +/* ')'*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n (tao_yyvsp[-8].idval, + 0); AST_Union *u = 0; idl_global->set_parse_state (IDL_GlobalData::PS_SwitchCloseParSeen); + /* * Create a node representing a union. Add it to its enclosing * scope */ - if (tao_yyvsp[-2].dcval != 0 && s != 0) { - AST_ConcreteType *tp = AST_ConcreteType::narrow_from_decl (tao_yyvsp[-2].dcval); - if (tp == 0) { - idl_global->err ()->not_a_type (tao_yyvsp[-2].dcval); - } else { - u = idl_global->gen ()->create_union (tp, - n, - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_union (u); + if (tao_yyvsp[-2].dcval != 0 + && s != 0) + { + AST_ConcreteType *tp = + AST_ConcreteType::narrow_from_decl (tao_yyvsp[-2].dcval); + + if (tp == 0) + { + idl_global->err ()->not_a_type (tao_yyvsp[-2].dcval); + } + else + { + u = idl_global->gen ()->create_union (tp, + &n, + s->is_local (), + s->is_abstract ()); + } + + (void) s->fe_add_union (u); } - } + /* * Push the scope of the union on the scopes stack */ - idl_global->scopes()->push (u); + idl_global->scopes ().push (u); } break; -case 222: +case 230: { +/* '{'*/ idl_global->set_parse_state (IDL_GlobalData::PS_UnionSqSeen); } break; -case 223: +case 231: { +/* at_least_one_case_branch*/ idl_global->set_parse_state (IDL_GlobalData::PS_UnionBodySeen); } break; -case 224: +case 232: { +/* '}'*/ idl_global->set_parse_state (IDL_GlobalData::PS_UnionQsSeen); /* * Done with this union. Pop its scope from the scopes stack */ tao_yyval.dcval = AST_Union::narrow_from_scope ( - idl_global->scopes ()->top_non_null () + idl_global->scopes ().top_non_null () ); + if (tao_yyval.dcval != 0) { - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } } break; -case 225: +case 233: { - tao_yyval.dcval = idl_global->scopes ()->bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); +/* switch_type_spec : integer_type*/ + tao_yyval.dcval = idl_global->scopes ().bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); } break; -case 226: +case 234: { +/* | char_type*/ /* wchars are not allowed */ if (tao_yyvsp[0].etval == AST_Expression::EV_wchar) { idl_global->err ()->error0 (UTL_Error::EIDL_DISC_TYPE); } - tao_yyval.dcval = - idl_global->scopes ()->bottom ()->lookup_primitive_type ( - tao_yyvsp[0].etval - ); + tao_yyval.dcval = + idl_global->scopes ().bottom ()->lookup_primitive_type ( + tao_yyvsp[0].etval + ); } break; -case 227: +case 235: { +/* | octet_type*/ /* octets are not allowed */ idl_global->err ()->error0 (UTL_Error::EIDL_DISC_TYPE); - tao_yyval.dcval = idl_global->scopes ()->bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); + tao_yyval.dcval = idl_global->scopes ().bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); } break; -case 228: +case 236: { - tao_yyval.dcval = idl_global->scopes ()->bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); +/* | boolean_type*/ + tao_yyval.dcval = idl_global->scopes ().bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); } break; -case 230: +case 238: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* | enum_type*/ +/* | scoped_name*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = 0; AST_PredefinedType *p = 0; AST_Typedef *t = 0; - long found = I_FALSE; + idl_bool found = I_FALSE; /* * The discriminator is a scoped name. Try to resolve to @@ -2708,130 +3275,181 @@ case 230: * typedef's to arrive at the base type at the end of the * chain */ - if (s != 0 && (d = s->lookup_by_name (tao_yyvsp[0].idlist, I_TRUE)) != 0) { - while (!found) { - switch (d->node_type ()) { - case AST_Decl::NT_enum: - tao_yyval.dcval = d; - found = I_TRUE; - break; - case AST_Decl::NT_pre_defined: - p = AST_PredefinedType::narrow_from_decl (d); - if (p != 0) { - switch (p->pt ()) { - case AST_PredefinedType::PT_long: - case AST_PredefinedType::PT_ulong: - case AST_PredefinedType::PT_longlong: - case AST_PredefinedType::PT_ulonglong: - case AST_PredefinedType::PT_short: - case AST_PredefinedType::PT_ushort: - case AST_PredefinedType::PT_char: - case AST_PredefinedType::PT_boolean: - tao_yyval.dcval = p; - found = I_TRUE; - break; - case AST_PredefinedType::PT_wchar: - case AST_PredefinedType::PT_octet: - /* octets and wchars are not allowed */ - idl_global->err ()->error0 (UTL_Error::EIDL_DISC_TYPE); - tao_yyval.dcval = 0; - found = I_TRUE; - break; - default: - tao_yyval.dcval = 0; - found = I_TRUE; - break; - } - } else + d = s->lookup_by_name (tao_yyvsp[0].idlist, + I_TRUE); + + if (s != 0 && d != 0) + { + while (!found) { - tao_yyval.dcval = 0; - found = I_TRUE; + switch (d->node_type ()) + { + case AST_Decl::NT_enum: + tao_yyval.dcval = d; + found = I_TRUE; + break; + case AST_Decl::NT_pre_defined: + p = AST_PredefinedType::narrow_from_decl (d); + + if (p != 0) + { + switch (p->pt ()) + { + case AST_PredefinedType::PT_long: + case AST_PredefinedType::PT_ulong: + case AST_PredefinedType::PT_longlong: + case AST_PredefinedType::PT_ulonglong: + case AST_PredefinedType::PT_short: + case AST_PredefinedType::PT_ushort: + case AST_PredefinedType::PT_char: + case AST_PredefinedType::PT_boolean: + tao_yyval.dcval = p; + found = I_TRUE; + break; + case AST_PredefinedType::PT_wchar: + case AST_PredefinedType::PT_octet: + /* octets and wchars are not allowed */ + idl_global->err ()->error0 ( + UTL_Error::EIDL_DISC_TYPE + ); + tao_yyval.dcval = 0; + found = I_TRUE; + break; + default: + tao_yyval.dcval = 0; + found = I_TRUE; + break; + } + } + else + { + tao_yyval.dcval = 0; + found = I_TRUE; + } + + break; + case AST_Decl::NT_typedef: + t = AST_Typedef::narrow_from_decl (d); + + if (t != 0) + { + d = t->base_type (); + } + + break; + default: + tao_yyval.dcval = 0; + found = I_TRUE; + break; + } } - break; - case AST_Decl::NT_typedef: - t = AST_Typedef::narrow_from_decl (d); - if (t != 0) d = t->base_type (); - break; - default: - tao_yyval.dcval = 0; - found = I_TRUE; - break; - } + } + else + { + tao_yyval.dcval = 0; } - } else - tao_yyval.dcval = 0; if (tao_yyval.dcval == 0) - idl_global->err ()->lookup_error (tao_yyvsp[0].idlist); + { + idl_global->err ()->lookup_error (tao_yyvsp[0].idlist); + } } break; -case 234: +case 242: { +/* case_branch : at_least_one_case_label*/ idl_global->set_parse_state (IDL_GlobalData::PS_UnionLabelSeen); } break; -case 235: +case 243: { +/* element_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemSeen); } break; -case 236: +case 244: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* ';'*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_UnionBranch *b = 0; AST_Field *f = tao_yyvsp[-2].ffval; idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemCompleted); + /* * Create several nodes representing branches of a union. * Add them to the enclosing scope (the union scope) */ - if (s != 0 && tao_yyvsp[-4].llval != 0 && tao_yyvsp[-2].ffval != 0) { - b = idl_global->gen ()->create_union_branch (tao_yyvsp[-4].llval, - f->field_type (), - f->name ()); + if (s != 0 + && tao_yyvsp[-4].llval != 0 + && tao_yyvsp[-2].ffval != 0) + { + b = + idl_global->gen ()->create_union_branch ( + tao_yyvsp[-4].llval, + f->field_type (), + f->name () + ); (void) s->fe_add_union_branch (b); - } + } } break; -case 237: +case 245: { +/* | error*/ idl_global->err()->syntax_error (idl_global->parse_state()); } break; -case 238: +case 246: { +/* ';'*/ idl_global->set_parse_state (IDL_GlobalData::PS_NoState); tao_yyerrok; } break; -case 239: +case 247: { +/* at_least_one_case_label : case_label case_labels*/ tao_yyval.llval = new UTL_LabelList (tao_yyvsp[-1].ulval, tao_yyvsp[0].llval); } break; -case 240: +case 248: { +/* case_labels : case_labels case_label*/ if (tao_yyvsp[-1].llval == 0) - tao_yyval.llval = new UTL_LabelList (tao_yyvsp[0].ulval, 0); - else { - tao_yyvsp[-1].llval->nconc(new UTL_LabelList (tao_yyvsp[0].ulval, 0)); - tao_yyval.llval = tao_yyvsp[-1].llval; - } + { + ACE_NEW_RETURN (tao_yyval.llval, + UTL_LabelList (tao_yyvsp[0].ulval, + 0), + 1); + } + else + { + UTL_LabelList *ll = 0; + ACE_NEW_RETURN (ll, + UTL_LabelList (tao_yyvsp[0].ulval, + 0), + 1); + tao_yyvsp[-1].llval->nconc (ll); + tao_yyval.llval = tao_yyvsp[-1].llval; + } } break; -case 241: +case 249: { +/* | /* EMPTY * /*/ tao_yyval.llval = 0; } break; -case 242: +case 250: { +/* case_label : IDL_DEFAULT*/ idl_global->set_parse_state (IDL_GlobalData::PS_DefaultSeen); } break; -case 243: +case 251: { +/* ':'*/ idl_global->set_parse_state (IDL_GlobalData::PS_LabelColonSeen); tao_yyval.ulval = idl_global->gen ()->create_union_label ( @@ -2840,18 +3458,20 @@ case 243: ); } break; -case 244: +case 252: { +/* | IDL_CASE*/ idl_global->set_parse_state (IDL_GlobalData::PS_CaseSeen); } break; -case 245: +case 253: { idl_global->set_parse_state (IDL_GlobalData::PS_LabelExprSeen); } break; -case 246: +case 254: { +/* const_expr*/ idl_global->set_parse_state (IDL_GlobalData::PS_LabelColonSeen); tao_yyval.ulval = idl_global->gen()->create_union_label ( @@ -2860,52 +3480,73 @@ case 246: ); } break; -case 247: +case 255: { +/* element_spec : type_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemTypeSeen); } break; -case 248: +case 256: { +/* declarator*/ idl_global->set_parse_state (IDL_GlobalData::PS_UnionElemDeclSeen); + /* * Check for illegal recursive use of type */ - if (tao_yyvsp[-2].dcval != 0 && AST_illegal_recursive_type (tao_yyvsp[-2].dcval)) - idl_global->err()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE, tao_yyvsp[-2].dcval); + if (tao_yyvsp[-2].dcval != 0 + && AST_illegal_recursive_type (tao_yyvsp[-2].dcval)) + { + idl_global->err()->error1 (UTL_Error::EIDL_RECURSIVE_TYPE, + tao_yyvsp[-2].dcval); + } /* * Create a field in a union branch */ else if (tao_yyvsp[-2].dcval == 0 || tao_yyvsp[0].deval == 0) - tao_yyval.ffval = 0; - else { - AST_Type *tp = tao_yyvsp[0].deval->compose (tao_yyvsp[-2].dcval); - if (tp == 0) + { tao_yyval.ffval = 0; - else - tao_yyval.ffval = idl_global->gen ()->create_field (tp, - tao_yyvsp[0].deval->name()); - } + } + else + { + AST_Type *tp = tao_yyvsp[0].deval->compose (tao_yyvsp[-2].dcval); + + if (tp == 0) + { + tao_yyval.ffval = 0; + } + else + { + tao_yyval.ffval = idl_global->gen ()->create_field ( + tp, + tao_yyvsp[0].deval->name () + ); + } + } } break; -case 249: +case 257: { +/* enum_type : IDL_ENUM*/ idl_global->set_parse_state (IDL_GlobalData::PS_EnumSeen); } break; -case 250: +case 258: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName(tao_yyvsp[0].idval, 0); +/* id*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n (tao_yyvsp[0].idval, + 0); AST_Enum *e = 0; idl_global->set_parse_state (IDL_GlobalData::PS_EnumIDSeen); + /* * Create a node representing an enum and add it to its * enclosing scope */ if (s != 0) { - e = idl_global->gen ()->create_enum (n, + e = idl_global->gen ()->create_enum (&n, s->is_local (), s->is_abstract ()); /* @@ -2916,45 +3557,54 @@ case 250: /* * Push the enum scope on the scopes stack */ - idl_global->scopes ()->push (e); + idl_global->scopes ().push (e); } break; -case 251: +case 259: { +/* '{'*/ idl_global->set_parse_state (IDL_GlobalData::PS_EnumSqSeen); } break; -case 252: +case 260: { +/* at_least_one_enumerator*/ idl_global->set_parse_state (IDL_GlobalData::PS_EnumBodySeen); } break; -case 253: +case 261: { +/* '}'*/ idl_global->set_parse_state (IDL_GlobalData::PS_EnumQsSeen); /* * Done with this enum. Pop its scope from the scopes stack */ - if (idl_global->scopes ()->top () == 0) - tao_yyval.dcval = 0; - else { - tao_yyval.dcval = AST_Enum::narrow_from_scope ( - idl_global->scopes ()->top_non_null () - ); - idl_global->scopes ()->pop (); - } + if (idl_global->scopes ().top () == 0) + { + tao_yyval.dcval = 0; + } + else + { + tao_yyval.dcval = AST_Enum::narrow_from_scope ( + idl_global->scopes ().top_non_null () + ); + idl_global->scopes ().pop (); + } } break; -case 255: +case 263: { +/* enumerators : enumerators ','*/ idl_global->set_parse_state (IDL_GlobalData::PS_EnumCommaSeen); } break; -case 258: +case 266: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = - new UTL_ScopedName (new Identifier (tao_yyvsp[0].strval), 0); +/* enumerator : IDENTIFIER*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + Identifier id (tao_yyvsp[0].strval); + UTL_ScopedName n (&id, + 0); AST_EnumVal *e = 0; AST_Enum *c = 0; @@ -2962,193 +3612,263 @@ case 258: * Create a node representing one enumerator in an enum * Add it to the enclosing scope (the enum scope) */ - if (s != 0 && s->scope_node_type () == AST_Decl::NT_enum) { - c = AST_Enum::narrow_from_scope (s); - if (c != 0) - e = idl_global->gen ()->create_enum_val (c->next_enum_val (), - n); - (void) s->fe_add_enum_val (e); - } + if (s != 0 + && s->scope_node_type () == AST_Decl::NT_enum) + { + c = AST_Enum::narrow_from_scope (s); + + if (c != 0) + { + e = idl_global->gen ()->create_enum_val ( + c->next_enum_val (), + &n + ); + } + + (void) s->fe_add_enum_val (e); + } } break; -case 259: +case 267: { +/* sequence_type_spec : seq_head ','*/ idl_global->set_parse_state (IDL_GlobalData::PS_SequenceCommaSeen); } break; -case 260: +case 268: { +/* positive_int_expr*/ idl_global->set_parse_state (IDL_GlobalData::PS_SequenceExprSeen); } break; -case 261: +case 269: { +/* '>'*/ idl_global->set_parse_state (IDL_GlobalData::PS_SequenceQsSeen); + /* - * Remove sequence marker from scopes stack + * Remove sequence marker from scopes stack. */ - if (idl_global->scopes ()->top() == 0) - idl_global->scopes ()->pop (); - UTL_Scope *s = idl_global->scopes ()->top_non_null (); + if (idl_global->scopes ().top() == 0) + { + idl_global->scopes ().pop (); + } + + UTL_Scope *s = idl_global->scopes ().top_non_null (); + /* * Create a node representing a sequence */ - if (tao_yyvsp[-2].exval == 0 || tao_yyvsp[-2].exval->coerce(AST_Expression::EV_ulong) == 0) { - idl_global->err ()->coercion_error (tao_yyvsp[-2].exval, AST_Expression::EV_ulong); - tao_yyval.dcval = 0; - } else if (tao_yyvsp[-5].dcval == 0) { - tao_yyval.dcval = 0; - } else { - AST_Type *tp = AST_Type::narrow_from_decl (tao_yyvsp[-5].dcval); - if (tp == 0) - ; /* Error will be caught in FE_Declarator.*/ - else { - tao_yyval.dcval = idl_global->gen ()->create_sequence (tao_yyvsp[-2].exval, - tp, - s->is_local (), - s->is_abstract ()); + if (tao_yyvsp[-2].exval == 0 || tao_yyvsp[-2].exval->coerce (AST_Expression::EV_ulong) == 0) + { + idl_global->err ()->coercion_error (tao_yyvsp[-2].exval, + AST_Expression::EV_ulong); + tao_yyval.dcval = 0; + } + else if (tao_yyvsp[-5].dcval == 0) + { + tao_yyval.dcval = 0; + } + else + { + AST_Type *tp = AST_Type::narrow_from_decl (tao_yyvsp[-5].dcval); + + if (tp == 0) + { + ; /* Error will be caught in FE_Declarator.*/ + } + else + { + tao_yyval.dcval = + idl_global->gen ()->create_sequence ( + tao_yyvsp[-2].exval, + tp, + s->is_local (), + s->is_abstract () + ); + } } - } } break; -case 262: +case 270: { +/* | seq_head '>'*/ idl_global->set_parse_state (IDL_GlobalData::PS_SequenceQsSeen); + /* - * Remove sequence marker from scopes stack + * Remove sequence marker from scopes stack. */ - if (idl_global->scopes ()->top () == 0) - idl_global->scopes ()->pop (); - UTL_Scope *s = idl_global->scopes ()->top_non_null (); + if (idl_global->scopes ().top () == 0) + { + idl_global->scopes ().pop (); + } + + UTL_Scope *s = idl_global->scopes ().top_non_null (); + /* * Create a node representing a sequence */ if (tao_yyvsp[-1].dcval == 0) - tao_yyval.dcval = 0; - else { - AST_Type *tp = AST_Type::narrow_from_decl (tao_yyvsp[-1].dcval); - if (tp == 0) - ; /* Error will be caught in FE_Declarator.*/ - else { - tao_yyval.dcval = - idl_global->gen ()->create_sequence ( - idl_global->gen ()->create_expr ((unsigned long) 0), - tp, - s->is_local (), - s->is_abstract () - ); + { + tao_yyval.dcval = 0; + } + else + { + AST_Type *tp = AST_Type::narrow_from_decl (tao_yyvsp[-1].dcval); + + if (tp == 0) + { + ; /* Error will be caught in FE_Declarator.*/ + } + else + { + tao_yyval.dcval = + idl_global->gen ()->create_sequence ( + idl_global->gen ()->create_expr ((unsigned long) 0), + tp, + s->is_local (), + s->is_abstract () + ); + } } - } } break; -case 263: +case 271: { +/* seq_head : IDL_SEQUENCE*/ idl_global->set_parse_state (IDL_GlobalData::PS_SequenceSeen); /* * Push a sequence marker on scopes stack */ - idl_global->scopes ()->push (0); + idl_global->scopes ().push (0); } break; -case 264: +case 272: { +/* '<'*/ idl_global->set_parse_state (IDL_GlobalData::PS_SequenceSqSeen); } break; -case 265: +case 273: { +/* simple_type_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_SequenceTypeSeen); tao_yyval.dcval = tao_yyvsp[0].dcval; } break; -case 266: +case 274: { +/* string_type_spec : string_head '<'*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringSqSeen); } break; -case 267: +case 275: { +/* positive_int_expr*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringExprSeen); } break; -case 268: +case 276: { +/* '>'*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringQsSeen); + /* - * Create a node representing a string + * Create a node representing a string. */ - if (tao_yyvsp[-2].exval == 0 || tao_yyvsp[-2].exval->coerce (AST_Expression::EV_ulong) == 0) { - idl_global->err ()->coercion_error (tao_yyvsp[-2].exval, AST_Expression::EV_ulong); - tao_yyval.dcval = 0; - } else { - tao_yyval.dcval = idl_global->gen ()->create_string (tao_yyvsp[-2].exval); - /* - * Add this AST_String to the types defined in the global scope - */ - (void) idl_global->root ()->fe_add_string ( - AST_String::narrow_from_decl (tao_yyval.dcval) - ); - } + if (tao_yyvsp[-2].exval == 0 + || tao_yyvsp[-2].exval->coerce (AST_Expression::EV_ulong) == 0) + { + idl_global->err ()->coercion_error (tao_yyvsp[-2].exval, + AST_Expression::EV_ulong); + tao_yyval.dcval = 0; + } + else + { + tao_yyval.dcval = idl_global->gen ()->create_string (tao_yyvsp[-2].exval); + /* + * Add this AST_String to the types defined in the global scope. + */ + (void) idl_global->root ()->fe_add_string ( + AST_String::narrow_from_decl ( + tao_yyval.dcval + ) + ); + } } break; -case 269: +case 277: { +/* | string_head*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringCompleted); /* - * Create a node representing a string + * Create a node representing a string. */ tao_yyval.dcval = idl_global->gen ()->create_string ( idl_global->gen ()->create_expr ((unsigned long) 0) ); /* - * Add this AST_String to the types defined in the global scope + * Add this AST_String to the types defined in the global scope. */ (void) idl_global->root ()->fe_add_string ( - AST_String::narrow_from_decl (tao_yyval.dcval) + AST_String::narrow_from_decl ( + tao_yyval.dcval + ) ); } break; -case 270: +case 278: { +/* string_head : IDL_STRING*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringSeen); } break; -case 271: +case 279: { +/* wstring_type_spec : wstring_head '<'*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringSqSeen); } break; -case 272: +case 280: { +/* positive_int_expr*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringExprSeen); } break; -case 273: +case 281: { +/* '>'*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringQsSeen); + /* - * Create a node representing a string + * Create a node representing a string. */ - if (tao_yyvsp[-2].exval == 0 || tao_yyvsp[-2].exval->coerce(AST_Expression::EV_ulong) == 0) { - idl_global->err ()->coercion_error (tao_yyvsp[-2].exval, AST_Expression::EV_ulong); - tao_yyval.dcval = 0; - } else { - tao_yyval.dcval = idl_global->gen ()->create_wstring (tao_yyvsp[-2].exval); - /* - * Add this AST_String to the types defined in the global scope - */ - (void) idl_global->root ()->fe_add_string ( - AST_String::narrow_from_decl (tao_yyval.dcval) - ); - } + if (tao_yyvsp[-2].exval == 0 + || tao_yyvsp[-2].exval->coerce (AST_Expression::EV_ulong) == 0) + { + idl_global->err ()->coercion_error (tao_yyvsp[-2].exval, + AST_Expression::EV_ulong); + tao_yyval.dcval = 0; + } + else + { + tao_yyval.dcval = idl_global->gen ()->create_wstring (tao_yyvsp[-2].exval); + /* + * Add this AST_String to the types defined in the global scope + */ + (void) idl_global->root ()->fe_add_string ( + AST_String::narrow_from_decl (tao_yyval.dcval) + ); + } } break; -case 274: +case 282: { +/* | wstring_head*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringCompleted); /* - * Create a node representing a string + * Create a node representing a wstring. */ tao_yyval.dcval = idl_global->gen ()->create_wstring ( @@ -3162,294 +3882,396 @@ case 274: ); } break; -case 275: +case 283: { +/* wstring_head : IDL_WSTRING*/ idl_global->set_parse_state (IDL_GlobalData::PS_StringSeen); } break; -case 276: +case 284: { +/* array_declarator : id*/ idl_global->set_parse_state (IDL_GlobalData::PS_ArrayIDSeen); } break; -case 277: +case 285: { +/* at_least_one_array_dim*/ idl_global->set_parse_state (IDL_GlobalData::PS_ArrayCompleted); + /* - * Create a node representing an array + * Create a node representing an array. */ - if (tao_yyvsp[0].elval != 0) { - tao_yyval.dcval = idl_global->gen ()->create_array (new UTL_ScopedName (tao_yyvsp[-2].idval, - 0), - tao_yyvsp[0].elval->length (), - tao_yyvsp[0].elval, - 0, - 0); - } + if (tao_yyvsp[0].elval != 0) + { + UTL_ScopedName sn (tao_yyvsp[-2].idval, + 0); + tao_yyval.dcval = + idl_global->gen ()->create_array ( + &sn, + tao_yyvsp[0].elval->length (), + tao_yyvsp[0].elval, + 0, + 0 + ); + } } break; -case 278: +case 286: { - tao_yyval.elval = new UTL_ExprList (tao_yyvsp[-1].exval, tao_yyvsp[0].elval); +/* at_least_one_array_dim : array_dim array_dims*/ + ACE_NEW_RETURN (tao_yyval.elval, + UTL_ExprList (tao_yyvsp[-1].exval, + tao_yyvsp[0].elval), + 1); } break; -case 279: +case 287: { +/* array_dims : array_dims array_dim*/ if (tao_yyvsp[-1].elval == 0) - tao_yyval.elval = new UTL_ExprList (tao_yyvsp[0].exval, 0); - else { - tao_yyvsp[-1].elval->nconc (new UTL_ExprList (tao_yyvsp[0].exval, 0)); - tao_yyval.elval = tao_yyvsp[-1].elval; - } + { + ACE_NEW_RETURN (tao_yyval.elval, + UTL_ExprList (tao_yyvsp[0].exval, + 0), + 1); + } + else + { + UTL_ExprList *el = 0; + ACE_NEW_RETURN (el, + UTL_ExprList (tao_yyvsp[0].exval, + 0), + 1); + tao_yyvsp[-1].elval->nconc (el); + tao_yyval.elval = tao_yyvsp[-1].elval; + } } break; -case 280: +case 288: { +/* | /* EMPTY * /*/ tao_yyval.elval = 0; } break; -case 281: +case 289: { +/* array_dim : '['*/ idl_global->set_parse_state (IDL_GlobalData::PS_DimSqSeen); } break; -case 282: +case 290: { +/* positive_int_expr*/ idl_global->set_parse_state (IDL_GlobalData::PS_DimExprSeen); } break; -case 283: +case 291: { +/* ']'*/ idl_global->set_parse_state (IDL_GlobalData::PS_DimQsSeen); + /* * Array dimensions are expressions which must be coerced to - * positive integers + * positive integers. */ - if (tao_yyvsp[-2].exval == 0 || tao_yyvsp[-2].exval->coerce (AST_Expression::EV_ulong) == 0) { - idl_global->err ()->coercion_error (tao_yyvsp[-2].exval, AST_Expression::EV_ulong); - tao_yyval.exval = 0; - } else - tao_yyval.exval = tao_yyvsp[-2].exval; + if (tao_yyvsp[-2].exval == 0 + || tao_yyvsp[-2].exval->coerce (AST_Expression::EV_ulong) == 0) + { + idl_global->err ()->coercion_error (tao_yyvsp[-2].exval, + AST_Expression::EV_ulong); + tao_yyval.exval = 0; + } + else + { + tao_yyval.exval = tao_yyvsp[-2].exval; + } } break; -case 284: +case 292: { +/* attribute : opt_readonly IDL_ATTRIBUTE*/ idl_global->set_parse_state (IDL_GlobalData::PS_AttrSeen); } break; -case 285: +case 293: { +/* param_type_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_AttrTypeSeen); } break; -case 286: +case 294: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* at_least_one_simple_declarator*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Attribute *a = 0; FE_Declarator *d = 0; idl_global->set_parse_state (IDL_GlobalData::PS_AttrCompleted); + /* * Create nodes representing attributes and add them to the - * enclosing scope + * enclosing scope. */ - if (s != 0 && tao_yyvsp[-2].dcval != 0 && tao_yyvsp[0].dlval != 0) { - for (UTL_DecllistActiveIterator l (tao_yyvsp[0].dlval); !l.is_done (); l.next ()) { - d = l.item (); - if (d == 0) - continue; - AST_Type *tp = d->compose (tao_yyvsp[-2].dcval); - if (tp == 0) - continue; - a = idl_global->gen ()->create_attribute (tao_yyvsp[-5].bval, - tp, - (UTL_IdList *) d->name()->copy (), - s->is_local (), - s->is_abstract ()); - /* - * Add one attribute to the enclosing scope - */ - (void) s->fe_add_attribute (a); + if (s != 0 + && tao_yyvsp[-2].dcval != 0 + && tao_yyvsp[0].dlval != 0) + { + for (UTL_DecllistActiveIterator l (tao_yyvsp[0].dlval); + !l.is_done (); + l.next ()) + { + d = l.item (); + + if (d == 0) + { + continue; + } + + AST_Type *tp = d->compose (tao_yyvsp[-2].dcval); + + if (tp == 0) + { + continue; + } + + a = + idl_global->gen ()->create_attribute ( + tao_yyvsp[-5].bval, + tp, + (UTL_IdList *) d->name ()->copy (), + s->is_local (), + s->is_abstract () + ); + /* + * Add one attribute to the enclosing scope. + */ + (void) s->fe_add_attribute (a); + } } - } } break; -case 287: +case 295: { +/* opt_readonly : IDL_READONLY*/ idl_global->set_parse_state (IDL_GlobalData::PS_AttrROSeen); tao_yyval.bval = I_TRUE; } break; -case 288: +case 296: { +/* | /* EMPTY * /*/ tao_yyval.bval = I_FALSE; } break; -case 289: +case 297: { +/* exception : IDL_EXCEPTION*/ idl_global->set_parse_state (IDL_GlobalData::PS_ExceptSeen); } break; -case 290: +case 298: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = new UTL_ScopedName (tao_yyvsp[0].idval, 0); +/* id*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + UTL_ScopedName n (tao_yyvsp[0].idval, + 0); AST_Exception *e = 0; idl_global->set_parse_state (IDL_GlobalData::PS_ExceptIDSeen); + /* * Create a node representing an exception and add it to - * the enclosing scope + * the enclosing scope. */ - if (s != 0) { - e = idl_global->gen ()->create_exception (n, - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_exception (e); - } + if (s != 0) + { + e = idl_global->gen ()->create_exception (&n, + s->is_local (), + s->is_abstract ()); + (void) s->fe_add_exception (e); + } + /* - * Push the exception scope on the scope stack + * Push the exception scope on the scope stack. */ - idl_global->scopes()->push (e); + idl_global->scopes ().push (e); } break; -case 291: +case 299: { +/* '{'*/ idl_global->set_parse_state (IDL_GlobalData::PS_ExceptSqSeen); } break; -case 292: +case 300: { +/* members*/ idl_global->set_parse_state (IDL_GlobalData::PS_ExceptBodySeen); } break; -case 293: +case 301: { +/* '}'*/ idl_global->set_parse_state (IDL_GlobalData::PS_ExceptQsSeen); /* - * Done with this exception. Pop its scope from the scope stack + * Done with this exception. Pop its scope from the scope stack. */ - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } break; -case 294: +case 302: { +/* operation : opt_op_attribute op_type_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpTypeSeen); } break; -case 295: +case 303: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_ScopedName *n = - new UTL_ScopedName (new Identifier (tao_yyvsp[0].strval), 0); +/* IDENTIFIER*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + Identifier id (tao_yyvsp[0].strval); + UTL_ScopedName n (&id, 0); AST_Operation *o = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen); + /* * Create a node representing an operation on an interface * and add it to its enclosing scope */ - if (s != 0 && tao_yyvsp[-2].dcval != 0) { - AST_Type *tp = AST_Type::narrow_from_decl (tao_yyvsp[-2].dcval); - if (tp == 0) { - idl_global->err ()->not_a_type (tao_yyvsp[-2].dcval); - } else if (tp->node_type () == AST_Decl::NT_except) { - idl_global->err ()->not_a_type (tao_yyvsp[-2].dcval); - } else { - o = idl_global->gen ()->create_operation (tp, - tao_yyvsp[-3].ofval, - n, - s->is_local (), - s->is_abstract ()); - (void) s->fe_add_operation (o); + if (s != 0 && tao_yyvsp[-2].dcval != 0) + { + AST_Type *tp = AST_Type::narrow_from_decl (tao_yyvsp[-2].dcval); + + if (tp == 0) + { + idl_global->err ()->not_a_type (tao_yyvsp[-2].dcval); + } + else if (tp->node_type () == AST_Decl::NT_except) + { + idl_global->err ()->not_a_type (tao_yyvsp[-2].dcval); + } + else + { + o = + idl_global->gen ()->create_operation (tp, + tao_yyvsp[-3].ofval, + &n, + s->is_local (), + s->is_abstract ()); + (void) s->fe_add_operation (o); + } } - } + + ACE_OS::free (tao_yyvsp[0].strval); + tao_yyvsp[0].strval = 0; + /* * Push the operation scope onto the scopes stack */ - idl_global->scopes()->push (o); + idl_global->scopes ().push (o); } break; -case 296: +case 304: { +/* parameter_list*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpParsCompleted); } break; -case 297: +case 305: { +/* opt_raises*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseCompleted); } break; -case 298: +case 306: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* opt_context*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Operation *o = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpCompleted); + /* - * Add exceptions and context to the operation + * Add exceptions and context to the operation. */ - if (s != 0 && s->scope_node_type() == AST_Decl::NT_op) { + if (s != 0 && s->scope_node_type () == AST_Decl::NT_op) + { o = AST_Operation::narrow_from_scope (s); if (tao_yyvsp[-2].nlval != 0 && o != 0) - (void) o->fe_add_exceptions (tao_yyvsp[-2].nlval); + { + (void) o->fe_add_exceptions (tao_yyvsp[-2].nlval); + } + if (tao_yyvsp[0].slval != 0) - (void) o->fe_add_context (tao_yyvsp[0].slval); - } + { + (void) o->fe_add_context (tao_yyvsp[0].slval); + } + } + /* - * Done with this operation. Pop its scope from the scopes stack + * Done with this operation. Pop its scope from the scopes stack. */ - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } break; -case 299: +case 307: { +/* opt_op_attribute : IDL_ONEWAY*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpAttrSeen); tao_yyval.ofval = AST_Operation::OP_oneway; } break; -case 300: +case 308: { +/* | IDL_IDEMPOTENT*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpAttrSeen); tao_yyval.ofval = AST_Operation::OP_idempotent; } break; -case 301: +case 309: { +/* | /* EMPTY * /*/ tao_yyval.ofval = AST_Operation::OP_noflags; } break; -case 303: +case 311: { +/* op_type_spec : param_type_spec | IDL_VOID*/ tao_yyval.dcval = - idl_global->scopes ()->bottom ()->lookup_primitive_type ( + idl_global->scopes ().bottom ()->lookup_primitive_type ( AST_Expression::EV_void ); } break; -case 304: +case 312: { +/* init_decl : IDL_FACTORY */ /*@@ PS_FactorySeen?*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpTypeSeen); } break; -case 305: +case 313: { +/* IDENTIFIER */ + UTL_Scope *s = idl_global->scopes ().top_non_null (); - UTL_Scope *s = idl_global->scopes ()->top_non_null (); if (s->is_abstract ()) - { - /*@@ Fire error*/ - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("error in %s line %d:\n") - ACE_TEXT ("Abstract valuetype can't have a ") - ACE_TEXT ("factory construct.\n"), - idl_global->filename ()->get_string (), - idl_global->lineno ())); - } - UTL_ScopedName *n = - new UTL_ScopedName (new Identifier (tao_yyvsp[0].strval), 0); + { + /*@@ Fire error*/ + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("error in %s line %d:\n") + ACE_TEXT ("Abstract valuetype can't have a ") + ACE_TEXT ("factory construct.\n"), + idl_global->filename ()->get_string (), + idl_global->lineno ())); + } + + Identifier id (tao_yyvsp[0].strval); + UTL_ScopedName n (&id, + 0); AST_Factory *factory = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpIDSeen); @@ -3459,257 +4281,361 @@ case 305: * and add it to its enclosing scope */ if (s != 0) - { - factory = idl_global->gen ()->create_factory (n); - (void) s->fe_add_factory (factory); - } + { + factory = idl_global->gen ()->create_factory (&n); + (void) s->fe_add_factory (factory); + } + /* - * Push the operation scope onto the scopes stack + * Push the operation scope onto the scopes stack. */ - idl_global->scopes ()->push (factory); + idl_global->scopes ().push (factory); } break; -case 306: +case 314: { - /* TODO: replace parameter_list with rule that accepts only IN args*/ +/* init_parameter_list*/ + /* TODO: replace parameter_list with rule that accepts only IN args */ idl_global->set_parse_state (IDL_GlobalData::PS_OpParsCompleted); - idl_global->scopes ()->pop (); + idl_global->scopes ().pop (); } break; -case 307: +case 315: { +/* init_parameter_list : '('*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen); } break; -case 308: +case 316: { +/* ')'*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen); } break; -case 309: -#line 2588 "fe/idl.tao_yy" +case 317: { +/* | '('*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen); } break; -case 310: +case 318: { +/* at_least_one_in_parameter ')'*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen); } break; -case 312: +case 320: { +/* in_parameters : in_parameters ','*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpParCommaSeen); } break; -case 315: +case 323: { +/* in_parameter : IDL_IN*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpParDirSeen); } break; -case 316: +case 324: { +/* param_type_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpParTypeSeen); } break; -case 317: +case 325: { - - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* declarator*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Argument *a = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpParDeclSeen); + /* * Create a node representing an argument to an operation - * Add it to the enclosing scope (the operation scope) + * Add it to the enclosing scope (the operation scope). */ - if (tao_yyvsp[-2].dcval != 0 && tao_yyvsp[0].deval != 0 && s != 0) - { - AST_Type *tp = tao_yyvsp[0].deval->compose (tao_yyvsp[-2].dcval); - if (tp != 0) + if (tao_yyvsp[-2].dcval != 0 + && tao_yyvsp[0].deval != 0 && + s != 0) { - a = idl_global->gen ()->create_argument ( - AST_Argument::dir_IN, - tp, - (UTL_IdList *) tao_yyvsp[0].deval->name ()->copy () - ); + AST_Type *tp = tao_yyvsp[0].deval->compose (tao_yyvsp[-2].dcval); + + if (tp != 0) + { + a = idl_global->gen ()->create_argument ( + AST_Argument::dir_IN, + tp, + (UTL_IdList *) tao_yyvsp[0].deval->name ()->copy () + ); - (void) s->fe_add_argument (a); + (void) s->fe_add_argument (a); + } } - } } break; -case 318: +case 326: { +/* parameter_list : '('*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen); } break; -case 319: +case 327: { +/* ')'*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen); } break; -case 320: +case 328: { +/* | '('*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen); } break; -case 321: +case 329: { +/* at_least_one_parameter ')'*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpQsSeen); } break; -case 323: +case 331: { +/* parameters : parameters ','*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpParCommaSeen); } break; -case 326: +case 334: { +/* parameter : direction*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpParDirSeen); } break; -case 327: +case 335: { +/* param_type_spec*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpParTypeSeen); } break; -case 328: +case 336: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* declarator*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Argument *a = 0; idl_global->set_parse_state (IDL_GlobalData::PS_OpParDeclSeen); + /* * Create a node representing an argument to an operation * Add it to the enclosing scope (the operation scope) */ - if (tao_yyvsp[-2].dcval != 0 && tao_yyvsp[0].deval != 0 && s != 0) { - AST_Type *tp = tao_yyvsp[0].deval->compose (tao_yyvsp[-2].dcval); - if (tp != 0) { - if (!s->is_local () && tp->is_local ()) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("error in %s line %d\n"), - idl_global->filename ()->get_string (), - idl_global->lineno ())); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Cannot use a local type as an ") - ACE_TEXT ("argument of a remote operation\n"))); - } - else + if (tao_yyvsp[-2].dcval != 0 + && tao_yyvsp[0].deval != 0 + && s != 0) + { + AST_Type *tp = tao_yyvsp[0].deval->compose (tao_yyvsp[-2].dcval); + + if (tp != 0) { - a = idl_global->gen ()->create_argument ( - tao_yyvsp[-4].dival, - tp, - (UTL_IdList *) tao_yyvsp[0].deval->name ()->copy () - ); - (void) s->fe_add_argument (a); + if (!s->is_local () && tp->is_local ()) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("error in %s line %d\n"), + idl_global->filename ()->get_string (), + idl_global->lineno ())); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("Cannot use a local type as an ") + ACE_TEXT ("argument of a remote operation\n"))); + } + else + { + a = idl_global->gen ()->create_argument ( + tao_yyvsp[-4].dival, + tp, + (UTL_IdList *) tao_yyvsp[0].deval->name ()->copy () + ); + (void) s->fe_add_argument (a); + } } } - } } break; -case 329: +case 337: { - tao_yyval.dcval = idl_global->scopes ()->bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); +/* param_type_spec : base_type_spec*/ + tao_yyval.dcval = idl_global->scopes ().bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); } break; -case 332: +case 340: { - UTL_Scope *s = idl_global->scopes ()->top_non_null (); +/* | string_type_spec*/ +/* | wstring_type_spec*/ +/* | scoped_name*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); AST_Decl *d = 0; if (s != 0) - d = s->lookup_by_name (tao_yyvsp[0].idlist, I_TRUE); + { + d = s->lookup_by_name (tao_yyvsp[0].idlist, + I_TRUE); + } + if (d == 0) - idl_global->err ()->lookup_error (tao_yyvsp[0].idlist); + { + idl_global->err ()->lookup_error (tao_yyvsp[0].idlist); + } + tao_yyval.dcval = d; } break; -case 333: +case 341: { +/* direction : IDL_IN*/ tao_yyval.dival = AST_Argument::dir_IN; } break; -case 334: +case 342: { +/* | IDL_OUT*/ tao_yyval.dival = AST_Argument::dir_OUT; } break; -case 335: +case 343: { +/* | IDL_INOUT*/ tao_yyval.dival = AST_Argument::dir_INOUT; } break; -case 336: +case 344: { +/* opt_raises : IDL_RAISES*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseSeen); } break; -case 337: +case 345: { +/* '('*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseSqSeen); } break; -case 338: +case 346: { +/* at_least_one_scoped_name ')'*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpRaiseQsSeen); tao_yyval.nlval = tao_yyvsp[-1].nlval; } break; -case 339: +case 347: { tao_yyval.nlval = 0; +/* | /* EMPTY * /*/ } break; -case 340: +case 348: { +/* opt_context : IDL_CONTEXT*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpContextSeen); } break; -case 341: +case 349: { idl_global->set_parse_state (IDL_GlobalData::PS_OpContextSqSeen); +/* '('*/ } break; -case 342: +case 350: { +/* at_least_one_string_literal ')'*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpContextQsSeen); tao_yyval.slval = tao_yyvsp[-1].slval; } break; -case 343: +case 351: { +/* | /* EMPTY * /*/ tao_yyval.slval = 0; } break; -case 344: +case 352: { - tao_yyval.slval = new UTL_StrList (tao_yyvsp[-1].sval, tao_yyvsp[0].slval); +/* at_least_one_string_literal : IDL_STRING_LITERAL string_literals*/ + ACE_NEW_RETURN (tao_yyval.slval, + UTL_StrList (tao_yyvsp[-1].sval, + tao_yyvsp[0].slval), + 1); } break; -case 345: +case 353: { +/* string_literals : string_literals ','*/ idl_global->set_parse_state (IDL_GlobalData::PS_OpContextCommaSeen); } break; -case 346: +case 354: { +/* IDL_STRING_LITERAL*/ if (tao_yyvsp[-3].slval == 0) - tao_yyval.slval = new UTL_StrList (tao_yyvsp[0].sval, 0); - else { - tao_yyvsp[-3].slval->nconc (new UTL_StrList (tao_yyvsp[0].sval, 0)); - tao_yyval.slval = tao_yyvsp[-3].slval; - } + { + ACE_NEW_RETURN (tao_yyval.slval, + UTL_StrList (tao_yyvsp[0].sval, + 0), + 1); + } + else + { + UTL_StrList *sl = 0; + ACE_NEW_RETURN (sl, + UTL_StrList (tao_yyvsp[0].sval, + 0), + 1); + tao_yyvsp[-3].slval->nconc (sl); + tao_yyval.slval = tao_yyvsp[-3].slval; + } } break; -case 347: +case 355: { +/* | /* EMPTY * /*/ tao_yyval.slval = 0; } break; +case 356: +{ +/* typeid_dcl : IDL_TYPEID scoped_name IDL_STRING_LITERAL*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + AST_Decl *d = s->lookup_by_name (tao_yyvsp[-1].idlist, + I_TRUE); + + if (d == 0) + { + idl_global->err ()->lookup_error (tao_yyvsp[-1].idlist); + } + else + { + d->set_id_with_typeid ( + tao_yyvsp[0].sval->get_string () + ); + } + } +break; +case 357: +{ +/* typeprefix_dcl : IDL_TYPEPREFIX scoped_name IDL_STRING_LITERAL*/ + UTL_Scope *s = idl_global->scopes ().top_non_null (); + AST_Decl *d = s->lookup_by_name (tao_yyvsp[-1].idlist, + I_TRUE); + + if (d == 0) + { + idl_global->err ()->lookup_error (tao_yyvsp[-1].idlist); + } + else + { + d->set_prefix_with_typeprefix ( + tao_yyvsp[0].sval->get_string () + ); + } + } +break; } tao_yyssp -= tao_yym; tao_yystate = *tao_yyssp; diff --git a/TAO/TAO_IDL/fe/y.tab.cpp.diff b/TAO/TAO_IDL/fe/y.tab.cpp.diff index 5406607b7ae..4d7a8021e00 100644 --- a/TAO/TAO_IDL/fe/y.tab.cpp.diff +++ b/TAO/TAO_IDL/fe/y.tab.cpp.diff @@ -40,23 +40,3 @@ ++tao_yynerrs; tao_yyinrecovery: if (tao_yyerrflag < 3) -@@ -2683,7 +2682,10 @@ - idl_global->err ()->error0 (UTL_Error::EIDL_DISC_TYPE); - } - -- tao_yyval.dcval = idl_global->scopes ()->bottom ()->lookup_primitive_type (tao_yyvsp[0].etval); -+ tao_yyval.dcval = -+ idl_global->scopes ()->bottom ()->lookup_primitive_type ( -+ tao_yyvsp[0].etval -+ ); - } - break; - case 227: -@@ -3495,6 +3497,7 @@ - } - break; - case 309: -+#line 2588 "fe/idl.tao_yy" - { - idl_global->set_parse_state (IDL_GlobalData::PS_OpSqSeen); - } diff --git a/TAO/TAO_IDL/fe/y.tab.h b/TAO/TAO_IDL/fe/y.tab.h index 426abceb1e4..c7c22b99a2a 100644 --- a/TAO/TAO_IDL/fe/y.tab.h +++ b/TAO/TAO_IDL/fe/y.tab.h @@ -45,18 +45,35 @@ #define IDL_SUPPORTS 300 #define IDL_TRUNCATABLE 301 #define IDL_VALUETYPE 302 -#define IDL_INTEGER_LITERAL 303 -#define IDL_UINTEGER_LITERAL 304 -#define IDL_STRING_LITERAL 305 -#define IDL_CHARACTER_LITERAL 306 -#define IDL_FLOATING_PT_LITERAL 307 -#define IDL_TRUETOK 308 -#define IDL_FALSETOK 309 -#define IDL_SCOPE_DELIMITOR 310 -#define IDL_LEFT_SHIFT 311 -#define IDL_RIGHT_SHIFT 312 -#define IDL_WCHAR_LITERAL 313 -#define IDL_WSTRING_LITERAL 314 +#define IDL_COMPONENT 303 +#define IDL_CONSUMES 304 +#define IDL_EMITS 305 +#define IDL_EVENTTYPE 306 +#define IDL_FINDER 307 +#define IDL_GETRAISES 308 +#define IDL_HOME 309 +#define IDL_IMPORT 310 +#define IDL_MULTIPLE 311 +#define IDL_PRIMARYKEY 312 +#define IDL_PROVIDES 313 +#define IDL_PUBLISHES 314 +#define IDL_SETRAISES 315 +#define IDL_TYPEID 316 +#define IDL_TYPEPREFIX 317 +#define IDL_USES 318 +#define IDL_MANAGES 319 +#define IDL_INTEGER_LITERAL 320 +#define IDL_UINTEGER_LITERAL 321 +#define IDL_STRING_LITERAL 322 +#define IDL_CHARACTER_LITERAL 323 +#define IDL_FLOATING_PT_LITERAL 324 +#define IDL_TRUETOK 325 +#define IDL_FALSETOK 326 +#define IDL_SCOPE_DELIMITOR 327 +#define IDL_LEFT_SHIFT 328 +#define IDL_RIGHT_SHIFT 329 +#define IDL_WCHAR_LITERAL 330 +#define IDL_WSTRING_LITERAL 331 typedef union { AST_Decl *dcval; /* Decl value */ UTL_StrList *slval; /* String list */ diff --git a/TAO/TAO_IDL/include/ast.h b/TAO/TAO_IDL/include/ast.h index 501ff4a33c1..2485faaccfa 100644 --- a/TAO/TAO_IDL/include/ast.h +++ b/TAO/TAO_IDL/include/ast.h @@ -103,6 +103,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ast_root.h" // class AST_Root #include "ast_interface.h" // class AST_Interface #include "ast_interface_fwd.h" // class AST_InterfaceFwd +#include "ast_component.h" // class AST_Component #include "ast_structure.h" // class AST_Structure #include "ast_exception.h" // class AST_Exception #include "ast_enum.h" // class AST_Enum diff --git a/TAO/TAO_IDL/include/ast_component.h b/TAO/TAO_IDL/include/ast_component.h new file mode 100644 index 00000000000..aa22fdba074 --- /dev/null +++ b/TAO/TAO_IDL/include/ast_component.h @@ -0,0 +1,27 @@ +// This may look like C, but it's really -*- C++ -*- +// $Id$ + +#ifndef _AST_INTERFACE_AST_COMPONENT_HH +#define _AST_INTERFACE_AST_COMPONENT_HH + +class TAO_IDL_FE_Export AST_Component : public virtual AST_Interface +{ +public: + AST_Component (void); + + AST_Component (UTL_ScopedName *n, + AST_Component *parent, + AST_Interface **supports, + long n_supports, + AST_Interface **supports_flat, + long n_supports_flat); + + virtual ~AST_Component (void); + + AST_Component *parent (void); + +private: + AST_Component *parent_; +}; + +#endif // _AST_INTERFACE_AST_COMPONENT_HH diff --git a/TAO/TAO_IDL/include/ast_constant.h b/TAO/TAO_IDL/include/ast_constant.h index 61807f7cb6f..27a9c6a0b9e 100644 --- a/TAO/TAO_IDL/include/ast_constant.h +++ b/TAO/TAO_IDL/include/ast_constant.h @@ -116,6 +116,9 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + // Cleanup. + virtual void destroy (void); + private: // Data. AST_Expression *pd_constant_value; diff --git a/TAO/TAO_IDL/include/ast_decl.h b/TAO/TAO_IDL/include/ast_decl.h index 6ce991ce0ac..40d66efb401 100644 --- a/TAO/TAO_IDL/include/ast_decl.h +++ b/TAO/TAO_IDL/include/ast_decl.h @@ -146,6 +146,10 @@ public: // dependent on the programming // language , NT_factory // Denotes a OBV factory construct + , NT_component // Denotes a CORBA component + , NT_home // Denotes a CORBA component home + , NT_finder // Denotes a home finder + , NT_eventtype // Denotes a CCM event source or sink }; // Operations. @@ -211,10 +215,20 @@ public: const char *version (void); void version (char *value); - // Accessors for the version member. + // Accessors for the version_ member. idl_bool anonymous (void) const; - // Are we an anonymous (no repo ID) type? + // Accessors for the anonymous_ member. + + idl_bool typeid_set (void) const; + void typeid_set (idl_bool val); + // Accessors for the typeid_set_ member. + + void set_id_with_typeid (char *value); + // Called by a 'typeId' declaration. + + void set_prefix_with_typeprefix (char *value); + // Called by a 'type_prefix' declaration. // If there is _cxx_ in the beginning, we will remove that and keep // a copy of the original name. TAO IDL's front end adds _cxx_ @@ -289,7 +303,6 @@ private: // What file defined in. UTL_ScopedName *pd_name; - // As given. Identifier *pd_local_name; // Name in scope. @@ -312,10 +325,16 @@ private: idl_bool anonymous_; // Are we an anonymous (no repo ID) type? + idl_bool typeid_set_; + // Has our repo id been set by a typeId declaration? + // Operations - // Compute the full name of an AST node. void compute_full_name (UTL_ScopedName *n); + // Compute the full name of an AST node. + + void set_prefix_with_typeprefix_r (char *value); + // Non-top-level version of set_prefix_with_typeprefix. }; #endif // _AST_DECL_AST_DECL_HH diff --git a/TAO/TAO_IDL/include/ast_enum.h b/TAO/TAO_IDL/include/ast_enum.h index 39a5f81953d..5ea0a6266ed 100644 --- a/TAO/TAO_IDL/include/ast_enum.h +++ b/TAO/TAO_IDL/include/ast_enum.h @@ -100,16 +100,16 @@ public: virtual void dump (ACE_OSTREAM_TYPE &); // Look up an AST_EnumVal by value - virtual AST_EnumVal *lookup_by_value (const AST_Expression *v); + AST_EnumVal *lookup_by_value (const AST_Expression *v); // Get value to be assigned to next enumerator. - virtual unsigned long next_enum_val (void); + unsigned long next_enum_val (void); // Return the count of members virtual int member_count (void); // Convert a numeric value to the enum's string name for it. - virtual UTL_ScopedName *value_to_name (const unsigned long v); + UTL_ScopedName *value_to_name (const unsigned long v); // Cleanup function. virtual void destroy (void); diff --git a/TAO/TAO_IDL/include/ast_expression.h b/TAO/TAO_IDL/include/ast_expression.h index 5fd20584ab3..600f400779f 100644 --- a/TAO/TAO_IDL/include/ast_expression.h +++ b/TAO/TAO_IDL/include/ast_expression.h @@ -234,6 +234,9 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + // Cleanup. + virtual void destroy (void); + // Other operations. // Evaluation and value coercion. diff --git a/TAO/TAO_IDL/include/ast_extern.h b/TAO/TAO_IDL/include/ast_extern.h index 493a12eaa0b..6e10f10f168 100644 --- a/TAO/TAO_IDL/include/ast_extern.h +++ b/TAO/TAO_IDL/include/ast_extern.h @@ -84,10 +84,10 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // the entire AST. The check ensures that for each fwd declared interface // the full definition was also seen. -extern void AST_record_fwd_interface(AST_InterfaceFwd *i); -extern void AST_check_fwd_interface(); +extern void AST_record_fwd_interface (AST_InterfaceFwd *i); +extern void AST_check_fwd_interface (void); -extern idl_bool AST_illegal_recursive_type(AST_Decl *t); +extern idl_bool AST_illegal_recursive_type (AST_Decl *t); #endif // _AST_EXTERN_AST_EXTERN_HH diff --git a/TAO/TAO_IDL/include/ast_generator.h b/TAO/TAO_IDL/include/ast_generator.h index c58cc827bdd..104b42b88ce 100644 --- a/TAO/TAO_IDL/include/ast_generator.h +++ b/TAO/TAO_IDL/include/ast_generator.h @@ -88,36 +88,48 @@ public: virtual AST_Root *create_root (UTL_ScopedName *n); // Create a node representing an interface. - virtual AST_Interface *create_interface (UTL_ScopedName *n, - AST_Interface **ih, - long nih, - AST_Interface **ih_flat, - long nih_flat, - idl_bool local, - idl_bool abstract); + virtual AST_Interface *create_interface ( + UTL_ScopedName *n, + AST_Interface **ih, + long nih, + AST_Interface **ih_flat, + long nih_flat, + idl_bool local, + idl_bool abstract + ); // Create a node representing a forward declaration of an interface. - virtual AST_InterfaceFwd *create_interface_fwd (UTL_ScopedName *n, - idl_bool local, - idl_bool abstract); + virtual AST_InterfaceFwd *create_interface_fwd ( + UTL_ScopedName *n, + idl_bool local, + idl_bool abstract + ); // Create a node representing an valuetype. - virtual AST_Interface *create_valuetype (UTL_ScopedName *n, - AST_Interface **ih, - long nih); + virtual AST_Interface *create_valuetype ( + UTL_ScopedName *n, + AST_Interface **ih, + long nih + ); // Create a node representing a forward declaration of an valuetype. - virtual AST_InterfaceFwd *create_valuetype_fwd (UTL_ScopedName *n); + virtual AST_InterfaceFwd *create_valuetype_fwd ( + UTL_ScopedName *n + ); // Create a node representing an exception. - virtual AST_Exception *create_exception (UTL_ScopedName *n, - idl_bool local, - idl_bool abstract); + virtual AST_Exception *create_exception ( + UTL_ScopedName *n, + idl_bool local, + idl_bool abstract + ); // Create a node representing a structure. - virtual AST_Structure *create_structure (UTL_ScopedName *n, - idl_bool local, - idl_bool abstract); + virtual AST_Structure *create_structure ( + UTL_ScopedName *n, + idl_bool local, + idl_bool abstract + ); // Create a node representing an enum. virtual AST_Enum *create_enum (UTL_ScopedName *n, @@ -125,11 +137,13 @@ public: idl_bool abstract); // Create a node representing an operation on an interface. - virtual AST_Operation *create_operation (AST_Type *rt, - AST_Operation::Flags fl, - UTL_ScopedName *n, - idl_bool local, - idl_bool abstract); + virtual AST_Operation *create_operation ( + AST_Type *rt, + AST_Operation::Flags fl, + UTL_ScopedName *n, + idl_bool local, + idl_bool abstract + ); // Create a node representing a field in a structure, exception or // union. @@ -139,16 +153,20 @@ public: AST_Field::vis_NA); // Create a node representing an argument to an operation. - virtual AST_Argument *create_argument (AST_Argument::Direction d, - AST_Type *ft, - UTL_ScopedName *n); + virtual AST_Argument *create_argument ( + AST_Argument::Direction d, + AST_Type *ft, + UTL_ScopedName *n + ); // Create a node representing an attribute. - virtual AST_Attribute *create_attribute (idl_bool ro, - AST_Type *ft, - UTL_ScopedName *n, - idl_bool local, - idl_bool abstract); + virtual AST_Attribute *create_attribute ( + idl_bool ro, + AST_Type *ft, + UTL_ScopedName *n, + idl_bool local, + idl_bool abstract + ); // Create a node representing a union. virtual AST_Union *create_union (AST_ConcreteType *dt, @@ -157,18 +175,21 @@ public: idl_bool abstract); // Create a node representing one branch in a union. - virtual AST_UnionBranch *create_union_branch (UTL_LabelList *ll, - AST_Type *ft, - UTL_ScopedName *n); + virtual AST_UnionBranch *create_union_branch ( + UTL_LabelList *ll, + AST_Type *ft, + UTL_ScopedName *n + ); // Create a node representing a label on a union branch. virtual AST_UnionLabel *create_union_label (AST_UnionLabel::UnionLabel ul, AST_Expression *lv); // Create a node representing a constant - virtual AST_Constant *create_constant (AST_Expression::ExprType et, - AST_Expression *ev, - UTL_ScopedName *n); + virtual AST_Constant *create_constant ( + AST_Expression::ExprType et, + AST_Expression *ev, + UTL_ScopedName *n); // Create various kinds of nodes representing expressions. diff --git a/TAO/TAO_IDL/include/ast_interface.h b/TAO/TAO_IDL/include/ast_interface.h index a66c700762b..3b39146c35d 100644 --- a/TAO/TAO_IDL/include/ast_interface.h +++ b/TAO/TAO_IDL/include/ast_interface.h @@ -77,7 +77,6 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "utl_scope.h" #include "ast_decl.h" - class TAO_IDL_FE_Export AST_Interface : public virtual AST_Type, public virtual UTL_Scope { diff --git a/TAO/TAO_IDL/include/ast_predefined_type.h b/TAO/TAO_IDL/include/ast_predefined_type.h index 912f0240ac9..2aa20f19506 100644 --- a/TAO/TAO_IDL/include/ast_predefined_type.h +++ b/TAO/TAO_IDL/include/ast_predefined_type.h @@ -119,6 +119,9 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + // Cleanup. + virtual void destroy (void); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_root.h b/TAO/TAO_IDL/include/ast_root.h index f4f92ae9323..9f1bd33b333 100644 --- a/TAO/TAO_IDL/include/ast_root.h +++ b/TAO/TAO_IDL/include/ast_root.h @@ -92,6 +92,9 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + // Cleanup. + virtual void destroy (); + private: friend class FE_Declarator; friend int tao_yyparse (void); diff --git a/TAO/TAO_IDL/include/ast_string.h b/TAO/TAO_IDL/include/ast_string.h index 634c5648eb4..5973e2d8e97 100644 --- a/TAO/TAO_IDL/include/ast_string.h +++ b/TAO/TAO_IDL/include/ast_string.h @@ -78,10 +78,10 @@ public: // Constructor(s) and destructor AST_String (void); - AST_String (AST_Expression *max_size); - - AST_String (AST_Expression *max_size, - long wide); + AST_String (AST_Decl::NodeType nt, + UTL_ScopedName *n, + AST_Expression *max_size, + long wide = 1); virtual ~AST_String (void); @@ -99,6 +99,9 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + // Cleanup. + virtual void destroy (void); + private: // Data. diff --git a/TAO/TAO_IDL/include/ast_structure.h b/TAO/TAO_IDL/include/ast_structure.h index 1e87b078a5c..bc09173d7e4 100644 --- a/TAO/TAO_IDL/include/ast_structure.h +++ b/TAO/TAO_IDL/include/ast_structure.h @@ -67,8 +67,6 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #ifndef _AST_STRUCTURE_AST_STRUCTURE_HH #define _AST_STRUCTURE_AST_STRUCTURE_HH -#include "ace/Unbounded_Queue.h" - // Representation of structure: // // NOTE: add (AST_ConcreteType *) is defined here because a structure @@ -79,6 +77,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // enums are inserted in the enclosing scope. It is unlikely that // a BE writer will need to overload this function in AST_Structure. +#include "ace/Unbounded_Queue.h" + class TAO_IDL_FE_Export AST_Structure : public virtual AST_ConcreteType, public virtual UTL_Scope { diff --git a/TAO/TAO_IDL/include/ast_type.h b/TAO/TAO_IDL/include/ast_type.h index 66e2d1f72ba..feefba27813 100644 --- a/TAO/TAO_IDL/include/ast_type.h +++ b/TAO/TAO_IDL/include/ast_type.h @@ -115,6 +115,9 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + // Cleanup. + virtual void destroy (void); + protected: // Has the full definition been added to the Interface Repository? // Used for types which can have members and can be forward declared. diff --git a/TAO/TAO_IDL/include/ast_typedef.h b/TAO/TAO_IDL/include/ast_typedef.h index 428aa7bf994..c888f543832 100644 --- a/TAO/TAO_IDL/include/ast_typedef.h +++ b/TAO/TAO_IDL/include/ast_typedef.h @@ -102,6 +102,9 @@ public: // Visiting. virtual int ast_accept (ast_visitor *visitor); + // Cleanup. + virtual void destroy (void); + private: // Data. diff --git a/TAO/TAO_IDL/include/fe_declarator.h b/TAO/TAO_IDL/include/fe_declarator.h index 55e4db68caf..eb76e94902e 100644 --- a/TAO/TAO_IDL/include/fe_declarator.h +++ b/TAO/TAO_IDL/include/fe_declarator.h @@ -95,6 +95,7 @@ public: // Compose an FE_Declarator into an AST_Type once all the needed information // is available. AST_Type *compose (AST_Decl* tc); + virtual void destroy (void); private: // Data. diff --git a/TAO/TAO_IDL/include/fe_extern.h b/TAO/TAO_IDL/include/fe_extern.h index b8627e3609c..2586dccf0f1 100644 --- a/TAO/TAO_IDL/include/fe_extern.h +++ b/TAO/TAO_IDL/include/fe_extern.h @@ -88,10 +88,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // and to populate it with nodes for the predefined types TAO_IDL_FE_Export void -FE_init_stage1 (void); // Initialize stage 1 - -TAO_IDL_FE_Export void -FE_init_stage2 (void); // Initialize stage 2 +FE_init (void); // Initialize FE // Interface to Yacc parser @@ -107,7 +104,6 @@ FE_set_yyin (File *); // Set yyin class UTL_Error; class UTL_Indenter; -class UTL_String; TAO_IDL_FE_Export UTL_Error * FE_new_UTL_Error (void); @@ -115,7 +111,4 @@ FE_new_UTL_Error (void); TAO_IDL_FE_Export UTL_Indenter * FE_new_UTL_Indenter (void); -TAO_IDL_FE_Export UTL_String * -FE_new_UTL_String (char *); - #endif // _FE_EXTERN_FE_EXTERN_HH diff --git a/TAO/TAO_IDL/include/fe_interface_header.h b/TAO/TAO_IDL/include/fe_interface_header.h index bfcd9a2ae89..1e21b4c5c80 100644 --- a/TAO/TAO_IDL/include/fe_interface_header.h +++ b/TAO/TAO_IDL/include/fe_interface_header.h @@ -156,7 +156,7 @@ public: UTL_NameList *supports = 0); virtual idl_bool is_abstract (void); - // See if we are a local interface. + // See if we are an abstract interface. }; class FE_obv_header : public FE_InterfaceHeader diff --git a/TAO/TAO_IDL/include/idl.h b/TAO/TAO_IDL/include/idl.h index 5584939d163..9ee8edc1435 100644 --- a/TAO/TAO_IDL/include/idl.h +++ b/TAO/TAO_IDL/include/idl.h @@ -72,22 +72,23 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // Main include file for IDL compiler. Includes the rest of the // files defining the different units of the compiler -#include "ace/ACE.h" // Most important ACE include file -#include "ace/streams.h" // iostreams +#include "ace/ACE.h" // Most important ACE include file +#include "ace/streams.h" // iostreams + #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "TAO_IDL_FE_Export.h" // Defines export macro -#include "idl_narrow.h" // IDL Narrowing mechanism -#include "idl_defines.h" // Constants for IDL compiler -#include "idl_fwd.h" // Forward decls of classes -#include "idl_bool.h" // Defines boolean for IDL -#include "utl_string.h" // Defines utility string class -#include "utl_identifier.h" // Defines utility identifier class -#include "ast.h" // AST classes -#include "util.h" // Utility classes +#include "TAO_IDL_FE_Export.h" // Defines export macro +#include "idl_narrow.h" // IDL Narrowing mechanism +#include "idl_defines.h" // Constants for IDL compiler +#include "idl_fwd.h" // Forward decls of classes +#include "idl_bool.h" // Defines boolean for IDL +#include "utl_string.h" // Defines utility string class +#include "utl_identifier.h" // Defines utility identifier class +#include "ast.h" // AST classes +#include "util.h" // Utility classes #if defined (interface) // Mingw needs this. diff --git a/TAO/TAO_IDL/include/idl_extern.h b/TAO/TAO_IDL/include/idl_extern.h index 1c3b6deee88..8f4e5e60421 100644 --- a/TAO/TAO_IDL/include/idl_extern.h +++ b/TAO/TAO_IDL/include/idl_extern.h @@ -71,9 +71,9 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // // Global variables and functions for IDL compiler -#include "fe_extern.h" // External API of FE -#include "ast_extern.h" // External API of AST -#include "nr_extern.h" // External API of NR -#include "global_extern.h" // Global data +#include "fe_extern.h" // External API of FE +#include "ast_extern.h" // External API of AST +#include "nr_extern.h" // External API of NR +#include "global_extern.h" // Global data #endif // _IDL_EXTERN_IDL_EXTERN_HH diff --git a/TAO/TAO_IDL/include/idl_global.h b/TAO/TAO_IDL/include/idl_global.h index f2b078b55ef..233c1aba9e0 100644 --- a/TAO/TAO_IDL/include/idl_global.h +++ b/TAO/TAO_IDL/include/idl_global.h @@ -85,7 +85,9 @@ public: // where context sensitive behavior is required enum ParseState { PS_NoState // No state - , PS_TypeDeclSeen // Seen complete typedef declaration + , PS_TypeDeclSeen // Seen complete type declaration + , PS_TypeIdDeclSeen // Seen complete typeId declaration + , PS_TypePrefixDeclSeen // Seen complete type_prefix declaration , PS_ConstDeclSeen // Seen complete const declaration , PS_ExceptDeclSeen // Seen complete exception declaration , PS_InterfaceDeclSeen // Seen complete interface declaration @@ -210,8 +212,8 @@ public: virtual ~IDL_GlobalData (void); // Operations - virtual UTL_ScopeStack *scopes (void); // Scopes stack - virtual void set_scopes (UTL_ScopeStack *); + virtual UTL_ScopeStack &scopes (void); // Scopes stack +// virtual void set_scopes (UTL_ScopeStack *); // Set it virtual AST_Root *root (void); // Root of AST @@ -345,6 +347,12 @@ public: virtual idl_bool obv_support (void); // check if OBV (Valuetype) support is enabled + void component_support (idl_bool); + // set enable/disable CORBA component support + + idl_bool component_support (void); + // check if CORBA component support is enabled + virtual void case_diff_error (idl_bool); // report an error (1) for indentifiers in the same scope // that differ only by case, or report a warning (0). @@ -373,7 +381,7 @@ public: private: // Data - UTL_ScopeStack *pd_scopes; // Store scopes stack + UTL_ScopeStack pd_scopes; // Store scopes stack AST_Root *pd_root; // Store AST root AST_Generator *pd_gen; // Store generator UTL_Error *pd_err; // Error object @@ -430,6 +438,9 @@ private: idl_bool obv_support_; // Do we support OBV (Valuetype)? + idl_bool component_support_; + // Do we support the CCM (CORBA Component Model)? + idl_bool case_diff_error_; // Do we report an error for indentifiers in the same scope that differ // only by case? or just a warning? diff --git a/TAO/TAO_IDL/include/util.h b/TAO/TAO_IDL/include/util.h index c8a35f0e685..4bc69cf38e2 100644 --- a/TAO/TAO_IDL/include/util.h +++ b/TAO/TAO_IDL/include/util.h @@ -69,16 +69,16 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // util.hh - Includes commonly used things defined in the util directory -#include "utl_stack.h" // class fe_stack -#include "utl_exprlist.h" // class UTL_ExprList -#include "utl_strlist.h" // class UTL_StrList -#include "utl_idlist.h" // class UTL_IdList -#include "utl_exceptlist.h" // class UTL_ExceptList -#include "utl_namelist.h" // class UTL_NameList -#include "utl_labellist.h" // class UTL_LabelList -#include "utl_decllist.h" // class UTL_DeclList -#include "idl_global.h" // Class IDL_GlobalData -#include "utl_err.h" // class UTL_Error -#include "utl_indenter.h" // class UTL_Indenter +#include "utl_stack.h" // class fe_stack +#include "utl_exprlist.h" // class UTL_ExprList +#include "utl_strlist.h" // class UTL_StrList +#include "utl_idlist.h" // class UTL_IdList +#include "utl_exceptlist.h" // class UTL_ExceptList +#include "utl_namelist.h" // class UTL_NameList +#include "utl_labellist.h" // class UTL_LabelList +#include "utl_decllist.h" // class UTL_DeclList +#include "idl_global.h" // Class IDL_GlobalData +#include "utl_err.h" // class UTL_Error +#include "utl_indenter.h" // class UTL_Indenter #endif // _UTIL_UTIL_HH diff --git a/TAO/TAO_IDL/include/utl_decllist.h b/TAO/TAO_IDL/include/utl_decllist.h index 0eb903ce37e..a94cc679941 100644 --- a/TAO/TAO_IDL/include/utl_decllist.h +++ b/TAO/TAO_IDL/include/utl_decllist.h @@ -89,14 +89,18 @@ public: // Operations // Constructor(s) - UTL_DeclList(FE_Declarator *s, UTL_DeclList *cdr); + UTL_DeclList (FE_Declarator *s, + UTL_DeclList *cdr); // Get element - FE_Declarator *head(); + FE_Declarator *head (void); + + // Cleanup. + virtual void destroy (void); private: // Data - FE_Declarator *pd_car_data; // The element this list stores + FE_Declarator *pd_car_data; // The element this list stores }; // Active iterator fooor UTL_DeclList @@ -107,10 +111,10 @@ public: // Operations // Constructor(s) - UTL_DecllistActiveIterator(UTL_DeclList *s); + UTL_DecllistActiveIterator (UTL_DeclList *s); // Get current item - FE_Declarator *item(); + FE_Declarator *item (void); }; #endif // _UTL_DECLLIST_UTL_DECLLIST_HH diff --git a/TAO/TAO_IDL/include/utl_err.h b/TAO/TAO_IDL/include/utl_err.h index 17fccba5d85..8333e57d881 100644 --- a/TAO/TAO_IDL/include/utl_err.h +++ b/TAO/TAO_IDL/include/utl_err.h @@ -96,6 +96,9 @@ public: EIDL_ILLEGAL_VERSION, // Bad number in #pragma version statement EIDL_VERSION_RESET, // Can't reset version, even to same number EIDL_ID_RESET, // Tried to set id to a different string + EIDL_TYPEID_RESET, // Can't set repo id with 'typeid' twice + EIDL_INVALID_TYPEID, // Can't use 'typeid' on this type. + EIDL_INVALID_TYPEPREFIX, // Can't use 'typeprefix on this type EIDL_DISC_TYPE, // Illegal discriminator type in union EIDL_LABEL_TYPE, // Mismatch with discriminator type in union EIDL_ILLEGAL_ADD, // Illegal add action diff --git a/TAO/TAO_IDL/include/utl_exceptlist.h b/TAO/TAO_IDL/include/utl_exceptlist.h index 3d411e2a6a4..54debd976f8 100644 --- a/TAO/TAO_IDL/include/utl_exceptlist.h +++ b/TAO/TAO_IDL/include/utl_exceptlist.h @@ -89,7 +89,7 @@ public: // Operations // Constructor(s) - UTL_ExceptList(AST_Exception *s, UTL_ExceptList *cdr); + UTL_ExceptList (AST_Exception *s, UTL_ExceptList *cdr); // Get list item AST_Exception *head(); diff --git a/TAO/TAO_IDL/include/utl_identifier.h b/TAO/TAO_IDL/include/utl_identifier.h index 05a82fb4605..68227a45b86 100644 --- a/TAO/TAO_IDL/include/utl_identifier.h +++ b/TAO/TAO_IDL/include/utl_identifier.h @@ -83,13 +83,13 @@ trademarks or registered trademarks of Sun Microsystems, Inc. class TAO_IDL_FE_Export Identifier { public: - Identifier (); + Identifier (void); // Default Constructor. Identifier (const char *s); // Constructor. - virtual ~Identifier (); + virtual ~Identifier (void); // Destructor. // Operations diff --git a/TAO/TAO_IDL/include/utl_idlist.h b/TAO/TAO_IDL/include/utl_idlist.h index 11113a51807..8886864a85f 100644 --- a/TAO/TAO_IDL/include/utl_idlist.h +++ b/TAO/TAO_IDL/include/utl_idlist.h @@ -100,7 +100,7 @@ public: UTL_IdList *cdr); // Constructor(s) - virtual ~UTL_IdList() {} + virtual ~UTL_IdList (void) {} // destructor // =AST Dumping @@ -113,13 +113,13 @@ public: // Other operations - UTL_List *copy (); + UTL_List *copy (void); // Copy the list - Identifier *head (); + Identifier *head (void); // get element - Identifier *last_component (); + Identifier *last_component (void); // Get last element in this list private: Identifier *pd_car_data; diff --git a/TAO/TAO_IDL/include/utl_list.h b/TAO/TAO_IDL/include/utl_list.h index b66cca0b739..a6d3c89d8ea 100644 --- a/TAO/TAO_IDL/include/utl_list.h +++ b/TAO/TAO_IDL/include/utl_list.h @@ -101,7 +101,7 @@ public: void nconc (UTL_List *l); // Copy the list starting at "this" - virtual UTL_List *copy (); + virtual UTL_List *copy (void); // Get next list UTL_List *tail (); @@ -110,7 +110,10 @@ public: void set_tail (UTL_List *l); // How long is this list? - long length (); + long length (void); + + // Cleanup. + virtual void destroy (void); private: // Data @@ -136,7 +139,7 @@ public: virtual void next (); // Are we at the end of this list? - virtual long is_done (); + virtual idl_bool is_done (void); protected: // Data diff --git a/TAO/TAO_IDL/include/utl_stack.h b/TAO/TAO_IDL/include/utl_stack.h index 91418c4fe50..4596c0de6b2 100644 --- a/TAO/TAO_IDL/include/utl_stack.h +++ b/TAO/TAO_IDL/include/utl_stack.h @@ -78,73 +78,73 @@ trademarks or registered trademarks of Sun Microsystems, Inc. */ // Forward declaration of active iterator for UTL_ScopeStack -class UTL_ScopeStackActiveIterator; +class UTL_ScopeStackActiveIterator; class TAO_IDL_FE_Export UTL_ScopeStack { public: // Operations - // Constructor and destructor - UTL_ScopeStack(); - virtual ~UTL_ScopeStack(); + // Constructor and destructor. + UTL_ScopeStack (void); + virtual ~UTL_ScopeStack (void); - // Return top element - virtual UTL_Scope *top(); + // Return top element. + virtual UTL_Scope *top (void); - // Pop top element - virtual void pop(); + // Pop top element. + virtual void pop (void); - // Clear entire stack - virtual void clear(); + // Clear entire stack. + virtual void clear (void); - // Push an element on the stack and return stack - virtual UTL_ScopeStack *push(UTL_Scope *el); + // Push an element on the stack and return stack. + virtual UTL_ScopeStack *push (UTL_Scope *el); // How deep is the stack now? - virtual unsigned long depth(); + virtual unsigned long depth (void); - // Return bottom element - virtual UTL_Scope *bottom(); + // Return bottom element. + virtual UTL_Scope *bottom (void); - // Return (top - 1) element - virtual UTL_Scope *next_to_top(); + // Return (top - 1) element. + virtual UTL_Scope *next_to_top (void); - // return topmost non-NULL element - virtual UTL_Scope *top_non_null(); + // return topmost non-NULL element. + virtual UTL_Scope *top_non_null (void); private: - // Data - UTL_Scope **pd_stack_data; // Store scopes stack - unsigned long pd_stack_data_nalloced; // How many allocated? - unsigned long pd_stack_top; // How many used? + // Data. + UTL_Scope **pd_stack_data; // Store scopes stack + unsigned long pd_stack_data_nalloced; // How many allocated? + unsigned long pd_stack_top; // How many used? - // Friend active iterator class for UTL_ScopeStack - friend class UTL_ScopeStackActiveIterator; + // Friend active iterator class for UTL_ScopeStack. + friend class UTL_ScopeStackActiveIterator; }; -// Active iterator for UTL_ScopeStack +// Active iterator for UTL_ScopeStack. class TAO_IDL_FE_Export UTL_ScopeStackActiveIterator { public: // Operations // Constructor - UTL_ScopeStackActiveIterator(UTL_ScopeStack *s); + UTL_ScopeStackActiveIterator( UTL_ScopeStack &s); - // Advance to next element - virtual void next(); + // Advance to next element. + virtual void next (void); - // Get current item - virtual UTL_Scope *item(); + // Get current item. + virtual UTL_Scope*item (void); // Is the iteration finished? - virtual long is_done(); + virtual long is_done (void); private: - // Data - UTL_ScopeStack *source; // On what to iterate? - long il; // Where are we in iteration? + // Data. + UTL_ScopeStack &source; // On what to iterate? + long il; // Where are we in iteration? }; #endif // _UTL_STACK_UTL_STACK_HH diff --git a/TAO/TAO_IDL/tao_idl.cpp b/TAO/TAO_IDL/tao_idl.cpp index c83c18c6380..02f1413c8b2 100644 --- a/TAO/TAO_IDL/tao_idl.cpp +++ b/TAO/TAO_IDL/tao_idl.cpp @@ -201,9 +201,6 @@ DRV_drive (const char *s) DRV_pre_proc (s); - // Initialize FE stage 1. - FE_init_stage1 (); - // Initialize BE. AST_Generator *gen = BE_init (); @@ -221,8 +218,8 @@ DRV_drive (const char *s) idl_global->set_gen (gen); } - // Initialize FE stage 2. - FE_init_stage2 (); + // Initialize FE. + FE_init (); // Parse. if (idl_global->compile_flags () & IDL_CF_INFORMATIVE) diff --git a/TAO/TAO_IDL/util/utl_decllist.cpp b/TAO/TAO_IDL/util/utl_decllist.cpp index 07031753b60..d295094b2a8 100644 --- a/TAO/TAO_IDL/util/utl_decllist.cpp +++ b/TAO/TAO_IDL/util/utl_decllist.cpp @@ -74,36 +74,49 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // will cease to operate correctly if you use either multiple or // public virtual inheritance. -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" +#include "fe_declarator.h" -ACE_RCSID(util, utl_decllist, "$Id$") +ACE_RCSID (util, + utl_decllist, + "$Id$") /* * Constructor(s) */ -UTL_DeclList::UTL_DeclList(FE_Declarator *s, UTL_DeclList *cdr) - : UTL_List(cdr), - pd_car_data(s) +UTL_DeclList::UTL_DeclList (FE_Declarator *s, + UTL_DeclList *cdr) + : UTL_List(cdr), + pd_car_data(s) { } /* - * Private operations - */ - -/* * Public operations */ // Get list item FE_Declarator * -UTL_DeclList::head() +UTL_DeclList::head (void) { return pd_car_data; } +void +UTL_DeclList::destroy (void) +{ + if (this->pd_car_data != 0) + { + this->pd_car_data->destroy (); + delete this->pd_car_data; + this->pd_car_data = 0; + } + + this->UTL_List::destroy (); +} + /* * Redefinition of inherited virtual operations */ @@ -115,7 +128,7 @@ UTL_DeclList::head() */ UTL_DecllistActiveIterator::UTL_DecllistActiveIterator (UTL_DeclList *s) - : UTL_ListActiveIterator(s) + : UTL_ListActiveIterator (s) { } @@ -129,14 +142,14 @@ UTL_DecllistActiveIterator::UTL_DecllistActiveIterator (UTL_DeclList *s) // Get current item FE_Declarator * -UTL_DecllistActiveIterator::item() +UTL_DecllistActiveIterator::item (void) { if (source == 0) { return 0; } - return ((UTL_DeclList *) source)->head(); + return ((UTL_DeclList *) source)->head (); } /* diff --git a/TAO/TAO_IDL/util/utl_err.cpp b/TAO/TAO_IDL/util/utl_err.cpp index e22053dac0d..26644667b05 100644 --- a/TAO/TAO_IDL/util/utl_err.cpp +++ b/TAO/TAO_IDL/util/utl_err.cpp @@ -67,8 +67,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // utl_err.cc - Implementation of error reporting object for IDL // compiler program -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(util, utl_err, "$Id$") @@ -115,6 +115,12 @@ error_string (UTL_Error::ErrorCode c) return "version already set by #pragma version or #pragma id, "; case UTL_Error::EIDL_ID_RESET: return "cannot reset id to a different string, "; + case UTL_Error::EIDL_TYPEID_RESET: + return "repo id already set by previous call to 'typeid', "; + case UTL_Error::EIDL_INVALID_TYPEID: + return "'typeid' may not be applied to this type, "; + case UTL_Error::EIDL_INVALID_TYPEPREFIX: + return "'typeprefix' may not be applied to this type, "; case UTL_Error::EIDL_DISC_TYPE: return "union with illegal discriminator type, "; case UTL_Error::EIDL_LABEL_TYPE: @@ -508,7 +514,7 @@ UTL_Error::error1 (UTL_Error::ErrorCode c, idl_error_header (c, idl_global->lineno (), idl_global->filename ()); - d->name ()->dump (cerr); + d->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -522,9 +528,10 @@ UTL_Error::error2 (UTL_Error::ErrorCode c, idl_error_header (c, idl_global->lineno (), idl_global->filename ()); - d1->name ()->dump (cerr); - cerr << ", "; - d2->name ()->dump (cerr); + d1->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; + ACE_ERROR ((LM_ERROR, + ", ")); + d2->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -539,11 +546,13 @@ UTL_Error::error3 (UTL_Error::ErrorCode c, idl_error_header (c, idl_global->lineno (), idl_global->filename ()); - d1->name ()->dump (cerr); - cerr << ", "; - d2->name ()->dump (cerr); - cerr << ", "; - d3->name ()->dump (cerr); + d1->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; + ACE_ERROR ((LM_ERROR, + ", ")); + d2->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; + ACE_ERROR ((LM_ERROR, + ", ")); + d3->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -555,7 +564,8 @@ UTL_Error::warning0 (UTL_Error::ErrorCode c) idl_error_header (c, idl_global->lineno (), idl_global->filename ()); - cerr << "\n"; + ACE_ERROR ((LM_ERROR, + "\n")); } void @@ -565,7 +575,7 @@ UTL_Error::warning1 (UTL_Error::ErrorCode c, idl_error_header (c, idl_global->lineno (), idl_global->filename ()); - d->name ()->dump (cerr); + d->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); } @@ -578,9 +588,10 @@ UTL_Error::warning2 (UTL_Error::ErrorCode c, idl_error_header (c, idl_global->lineno (), idl_global->filename ()); - d1->name ()->dump (cerr); - cerr << ", "; - d2->name ()->dump (cerr); + d1->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; + ACE_ERROR ((LM_ERROR, + ", ")); + d2->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); } @@ -594,11 +605,13 @@ UTL_Error::warning3 (UTL_Error::ErrorCode c, idl_error_header (c, idl_global->lineno (), idl_global->filename ()); - d1->name ()->dump (cerr); - cerr << ", "; - d2->name ()->dump (cerr); - cerr << ", "; - d3->name ()->dump (cerr); + d1->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; + ACE_ERROR ((LM_ERROR, + ", ")); + d2->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; + ACE_ERROR ((LM_ERROR, + ", ")); + d3->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); } @@ -611,8 +624,10 @@ UTL_Error::coercion_error (AST_Expression *v, idl_error_header (EIDL_COERCION_FAILURE, v->line (), v->file_name ()); - v->dump (cerr); - cerr << " to " << exprtype_to_string (t) << "\n"; + v->dump (*ACE_DEFAULT_LOG_STREAM); + ACE_ERROR ((LM_ERROR, + " to %s\n", + exprtype_to_string (t))); idl_global->set_err_count (idl_global->err_count () + 1); } @@ -623,8 +638,9 @@ UTL_Error::lookup_error (UTL_ScopedName *n) idl_error_header (EIDL_LOOKUP_ERROR, idl_global->lineno (), idl_global->filename ()); - n->dump (cerr); - cerr << "\n"; + n->dump (*ACE_DEFAULT_LOG_STREAM);; + ACE_ERROR ((LM_ERROR, + "\n")); idl_global->set_err_count (idl_global->err_count () + 1); } @@ -679,10 +695,10 @@ UTL_Error::inheritance_fwd_error (UTL_ScopedName *n, f->file_name ()); ACE_ERROR ((LM_ERROR, "interface ")); - n->dump (cerr); + n->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, " cannot inherit from forward declared interface ")); - f->local_name ()->dump (cerr); + f->local_name ()->dump (*ACE_DEFAULT_LOG_STREAM); ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -696,10 +712,10 @@ UTL_Error::inheritance_error (UTL_ScopedName *n, idl_error_header (EIDL_CANT_INHERIT, idl_global->lineno (), idl_global->filename ()); - n->dump (cerr); + n->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, " attempts to inherit from ")); - d->name ()->dump (cerr); + d->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -714,7 +730,7 @@ UTL_Error::abstract_inheritance_error (UTL_ScopedName *n) idl_global->filename ()); ACE_ERROR ((LM_ERROR, " abstract valuetype ")); - n->dump (cerr); + n->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, " attempts to inherit from nonabstract type\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -728,7 +744,7 @@ UTL_Error::eval_error (AST_Expression *v) idl_error_header (EIDL_EVAL_ERROR, v->line (), v->file_name ()); - v->dump (cerr); + v->dump (*ACE_DEFAULT_LOG_STREAM); ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -744,10 +760,10 @@ UTL_Error::constant_expected (UTL_ScopedName *n, idl_error_header (EIDL_CONSTANT_EXPECTED, d->line (), d->file_name ()); - n->dump (cerr); + n->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, " bound to ")); - d->dump (cerr); + d->dump (*ACE_DEFAULT_LOG_STREAM); ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -767,7 +783,7 @@ UTL_Error::enum_val_expected (AST_Union *u, ACE_ERROR ((LM_ERROR, " union %s, ", u->local_name ()->get_string ())); - l->dump (cerr); + l->dump (*ACE_DEFAULT_LOG_STREAM); ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -790,7 +806,7 @@ UTL_Error::enum_val_lookup_failure (AST_Union *u, " union %s, enum %s, enumerator ", u->local_name ()->get_string (), e->local_name ()->get_string ())); - n->dump (cerr); + n->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -874,10 +890,10 @@ UTL_Error::ambiguous (UTL_Scope *s, ACE_ERROR ((LM_ERROR, " scope: %s, collision: ", (ScopeAsDecl (s))->local_name ()->get_string ())); - d->name ()->dump (cerr); + d->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, " vs. ")); - l->name ()->dump (cerr); + l->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -888,11 +904,11 @@ void UTL_Error::fwd_decl_not_defined (AST_Interface *d) { idl_error_header (EIDL_DECL_NOT_DEFINED, - d->line(), - d->file_name()); + d->line (), + d->file_name ()); ACE_ERROR ((LM_ERROR, "interface ")); - d->local_name ()->dump (cerr); + d->local_name ()->dump (*ACE_DEFAULT_LOG_STREAM); ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -904,14 +920,14 @@ UTL_Error::fwd_decl_lookup (AST_Interface *d, UTL_ScopedName *n) { idl_error_header (EIDL_FWD_DECL_LOOKUP, - idl_global->lineno(), - idl_global->filename()); + idl_global->lineno (), + idl_global->filename ()); ACE_ERROR ((LM_ERROR, "trying to look up ")); - n->dump (cerr); + n->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, " in undefined forward declared interface ")); - d->local_name ()->dump (cerr); + d->local_name ()->dump (*ACE_DEFAULT_LOG_STREAM); ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -925,10 +941,10 @@ UTL_Error::redefinition_in_scope (AST_Decl *d, idl_error_header (EIDL_REDEF_SCOPE, d->line (), d->file_name ()); - d->name ()->dump (cerr); + d->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, ", ")); - s->name ()->dump (cerr); + s->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; ACE_ERROR ((LM_ERROR, "\n")); idl_global->set_err_count (idl_global->err_count () + 1); @@ -939,8 +955,8 @@ void UTL_Error::not_a_type (AST_Decl *d) { idl_error_header (EIDL_NOT_A_TYPE, - idl_global->lineno(), - idl_global->filename()); + idl_global->lineno (), + idl_global->filename ()); if (d == 0 || d->name () == 0) { ACE_ERROR ((LM_ERROR, @@ -948,7 +964,7 @@ UTL_Error::not_a_type (AST_Decl *d) } else { - d->name ()->dump (cerr); + d->name ()->dump (*ACE_DEFAULT_LOG_STREAM);; } ACE_ERROR ((LM_ERROR, @@ -965,3 +981,4 @@ UTL_Error::back_end (long lineno, s); idl_global->set_err_count (idl_global->err_count () + 1); } + diff --git a/TAO/TAO_IDL/util/utl_global.cpp b/TAO/TAO_IDL/util/utl_global.cpp index 760ee4c1d58..f923e2d41e6 100644 --- a/TAO/TAO_IDL/util/utl_global.cpp +++ b/TAO/TAO_IDL/util/utl_global.cpp @@ -78,41 +78,41 @@ ACE_RCSID(util, utl_global, "$Id$") #define INCREMENT 64 IDL_GlobalData::IDL_GlobalData (void) - : pd_scopes (0), - pd_root (0), - pd_gen (0), - pd_err (0), - pd_err_count (0), - pd_lineno (0), - pd_filename (0), - pd_main_filename (0), - pd_real_filename (0), - pd_stripped_filename (0), - pd_import (I_FALSE), - pd_in_main_file (I_FALSE), - pd_prog_name (0), - pd_cpp_location (0), - pd_compile_flags (0), - pd_be (0), - pd_local_escapes (0), - pd_indent (0), - pd_read_from_stdin (I_FALSE), - pd_include_file_names (0), - pd_n_include_file_names (0), - pd_n_alloced_file_names (0), - included_idl_files_ (0), - n_included_idl_files_ (0), - n_allocated_idl_files_ (0), - pd_parse_state (PS_NoState), - pd_idl_src_file (0), - gperf_path_ (0), - temp_dir_ (0), - ident_string_ (0), - obv_support_ (I_FALSE), - case_diff_error_ (I_TRUE), - idl_flags_ (""), - last_seen_index_ (1) - { + : pd_root (0), + pd_gen (0), + pd_err (0), + pd_err_count (0), + pd_lineno (0), + pd_filename (0), + pd_main_filename (0), + pd_real_filename (0), + pd_stripped_filename (0), + pd_import (I_FALSE), + pd_in_main_file (I_FALSE), + pd_prog_name (0), + pd_cpp_location (0), + pd_compile_flags (0), + pd_be (0), + pd_local_escapes (0), + pd_indent (0), + pd_read_from_stdin (I_FALSE), + pd_include_file_names (0), + pd_n_include_file_names (0), + pd_n_alloced_file_names (0), + included_idl_files_ (0), + n_included_idl_files_ (0), + n_allocated_idl_files_ (0), + pd_parse_state (PS_NoState), + pd_idl_src_file (0), + gperf_path_ (0), + temp_dir_ (0), + ident_string_ (0), + obv_support_ (I_FALSE), + component_support_ (I_FALSE), + case_diff_error_ (I_TRUE), + idl_flags_ (""), + last_seen_index_ (1) +{ // Path for the perfect hash generator(gperf) program. // Default is $ACE_ROOT/bin/gperf unless ACE_GPERF is defined. // Use ACE_GPERF if $ACE_ROOT hasn't been set or won't be set @@ -161,18 +161,12 @@ IDL_GlobalData::~IDL_GlobalData (void) } // Get or set scopes stack -UTL_ScopeStack * +UTL_ScopeStack & IDL_GlobalData::scopes (void) { return this->pd_scopes; } -void -IDL_GlobalData::set_scopes (UTL_ScopeStack *s) -{ - this->pd_scopes = s; -} - // Get or set root of AST AST_Root * IDL_GlobalData::root (void) @@ -411,10 +405,10 @@ IDL_GlobalData::set_local_escapes (const char *e) { if (this->pd_local_escapes != 0) { - ACE_OS::free (this->pd_local_escapes); + delete [] this->pd_local_escapes; } - this->pd_local_escapes = ACE_OS::strdup (e); + this->pd_local_escapes = ACE::strnew (e); } // Get or set indent object @@ -731,13 +725,13 @@ IDL_GlobalData::PredefinedTypeToExprType(AST_PredefinedType::PredefinedType pt) } // returns the IDL source file being copiled -UTL_String* IDL_GlobalData::idl_src_file() +UTL_String* IDL_GlobalData::idl_src_file (void) { return this->pd_idl_src_file; } // set the source IDL file that is being parsed -void IDL_GlobalData::idl_src_file(UTL_String *s) +void IDL_GlobalData::idl_src_file (UTL_String *s) { this->pd_idl_src_file = s; } @@ -806,6 +800,18 @@ IDL_GlobalData::obv_support (void) } void +IDL_GlobalData::component_support (idl_bool val) +{ + this->component_support_ = val; +} + +idl_bool +IDL_GlobalData::component_support (void) +{ + return this->component_support_; +} + +void IDL_GlobalData::case_diff_error (idl_bool val) { this->case_diff_error_ = val; @@ -848,8 +854,12 @@ IDL_GlobalData::destroy (void) this->pd_stripped_filename = 0; } - delete [] this->ident_string_; - this->ident_string_ = 0; + if (this->pd_idl_src_file != 0) + { + this->pd_idl_src_file->destroy (); + delete this->pd_idl_src_file; + this->pd_idl_src_file = 0; + } size_t size = this->pragma_prefixes ().size (); char *trash = 0; @@ -860,6 +870,25 @@ IDL_GlobalData::destroy (void) delete [] trash; trash = 0; } + + this->pd_root->destroy (); + delete this->pd_root; + this->pd_root = 0; + + delete this->pd_err; + this->pd_err = 0; + delete this->pd_gen; + this->pd_gen = 0; + delete this->pd_indent; + this->pd_indent = 0; + delete [] this->pd_local_escapes; + this->pd_local_escapes = 0; + delete [] this->gperf_path_; + this->gperf_path_ = 0; + delete [] this->temp_dir_; + this->temp_dir_ = 0; + delete [] this->ident_string_; + this->ident_string_ = 0; } void diff --git a/TAO/TAO_IDL/util/utl_identifier.cpp b/TAO/TAO_IDL/util/utl_identifier.cpp index 3a1b5c23027..5104f345fcb 100644 --- a/TAO/TAO_IDL/util/utl_identifier.cpp +++ b/TAO/TAO_IDL/util/utl_identifier.cpp @@ -111,16 +111,21 @@ Identifier::Identifier (const char *s) if (shift) { - this->pv_string = ACE_OS::strdup (s + 1); + this->pv_string = ACE::strnew (s + 1); } else { - this->pv_string = ACE_OS::strdup (s); + this->pv_string = ACE::strnew (s); } } Identifier::~Identifier (void) { + if (this->pv_string != 0) + { + delete this->pv_string; + this->pv_string = 0; + } } // Operations. @@ -134,12 +139,12 @@ Identifier::get_string (void) void Identifier::replace_string (const char * s) { - if (this->pv_string) + if (this->pv_string != 0) { - ACE_OS::free (this->pv_string); + delete [] this->pv_string; } - this->pv_string = ACE_OS::strdup (s); + this->pv_string = ACE::strnew (s); } // Compare two Identifier * @@ -179,7 +184,7 @@ long Identifier::case_compare_quiet (Identifier *o) { UTL_String member (this->pv_string); - UTL_String other (o->get_string ()); + UTL_String other (o->pv_string); long result = member.compare_quiet (&other); @@ -217,15 +222,10 @@ Identifier::dump (ACE_OSTREAM_TYPE &o) return; } - o << get_string (); + o << this->pv_string; } void Identifier::destroy (void) { - if (this->pv_string) - { - ACE_OS::free (this->pv_string); - this->pv_string = 0; - } } diff --git a/TAO/TAO_IDL/util/utl_idlist.cpp b/TAO/TAO_IDL/util/utl_idlist.cpp index afa1c933569..1e7551d0b51 100644 --- a/TAO/TAO_IDL/util/utl_idlist.cpp +++ b/TAO/TAO_IDL/util/utl_idlist.cpp @@ -74,8 +74,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. // will cease to operate correctly if you use either multiple or // public virtual inheritance. -#include "idl.h" -#include "idl_extern.h" +#include "idl.h" +#include "idl_extern.h" ACE_RCSID(util, utl_idlist, "$Id$") @@ -117,14 +117,14 @@ UTL_IdList::copy (void) Identifier * UTL_IdList::head (void) { - return pd_car_data; + return this->pd_car_data; } // Get last item of this list. Identifier * UTL_IdList::last_component (void) { - if (this->tail ()== 0) + if (this->tail () == 0) { return this->head (); } @@ -136,12 +136,12 @@ UTL_IdList::last_component (void) void UTL_IdList::dump (ACE_OSTREAM_TYPE &o) { - UTL_IdListActiveIterator i (this); - long first = I_TRUE; long second = I_FALSE; - while (!(i.is_done ())) + for (UTL_IdListActiveIterator i (this); + !i.is_done (); + i.next ()) { if (!first) { @@ -165,30 +165,19 @@ UTL_IdList::dump (ACE_OSTREAM_TYPE &o) second = I_TRUE; } } - - i.next (); } } void UTL_IdList::destroy (void) { - Identifier *id = 0; - UTL_IdListActiveIterator i (this); - - while (!(i.is_done ())) + if (this->pd_car_data != 0) { - id = i.item (); - - if (id != 0) - { - id->destroy (); - delete id; - id = 0; - } - - i.next (); + delete this->pd_car_data; + this->pd_car_data = 0; } + + this->UTL_List::destroy (); } // UTL_IdList active iterator. diff --git a/TAO/TAO_IDL/util/utl_labellist.cpp b/TAO/TAO_IDL/util/utl_labellist.cpp index ac155b68602..7c4d172f06e 100644 --- a/TAO/TAO_IDL/util/utl_labellist.cpp +++ b/TAO/TAO_IDL/util/utl_labellist.cpp @@ -114,8 +114,8 @@ UTL_LabelList::head() * Constructor */ -UTL_LabellistActiveIterator::UTL_LabellistActiveIterator(UTL_LabelList *s) - : UTL_ListActiveIterator(s) +UTL_LabellistActiveIterator::UTL_LabellistActiveIterator (UTL_LabelList *s) + : UTL_ListActiveIterator (s) { } @@ -129,11 +129,14 @@ UTL_LabellistActiveIterator::UTL_LabellistActiveIterator(UTL_LabelList *s) // Get current item AST_UnionLabel * -UTL_LabellistActiveIterator::item() +UTL_LabellistActiveIterator::item (void) { - if (source == NULL) - return NULL; - return ((UTL_LabelList *) source)->head(); + if (source == 0) + { + return 0; + } + + return ((UTL_LabelList *) source)->head (); } /* diff --git a/TAO/TAO_IDL/util/utl_list.cpp b/TAO/TAO_IDL/util/utl_list.cpp index a1c98460ee8..a17b85b089d 100644 --- a/TAO/TAO_IDL/util/utl_list.cpp +++ b/TAO/TAO_IDL/util/utl_list.cpp @@ -88,8 +88,6 @@ UTL_List::UTL_List (UTL_List *c) // Destructor UTL_List::~UTL_List (void) { -// delete this->pd_cdr_data; -// this->pd_cdr_data = 0; } // Private operations @@ -98,56 +96,88 @@ UTL_List::~UTL_List (void) long UTL_List::list_length (long n) { - if (pd_cdr_data == NULL) - return n; + if (this->pd_cdr_data == 0) + { + return n; + } else - return pd_cdr_data->list_length (n+1); + { + return this->pd_cdr_data->list_length (n + 1); + } } // Public operations -// Smash last cdr with l +// Smash last cdr with l. void UTL_List::nconc (UTL_List *l) { - if (pd_cdr_data == NULL) - pd_cdr_data = l; + if (this->pd_cdr_data == 0) + { + this->pd_cdr_data = l; + } else - pd_cdr_data->nconc (l); + { + this->pd_cdr_data->nconc (l); + } } -// Override this operation to copy lists of other types +// Override this operation to copy lists of other types. UTL_List * -UTL_List::copy () +UTL_List::copy (void) { - if (pd_cdr_data == NULL) - return new UTL_List (NULL); + UTL_List *retval = 0; + + if (this->pd_cdr_data == 0) + { + ACE_NEW_RETURN (retval, + UTL_List (0), + 0); + } + else + { + ACE_NEW_RETURN (retval, + UTL_List (this->pd_cdr_data->copy ()), + 0); + } - return new UTL_List (pd_cdr_data->copy ()); + return retval; } // Get next list UTL_List * -UTL_List::tail () +UTL_List::tail (void) { return pd_cdr_data; } -// Set next list +// Set next list. void UTL_List::set_tail (UTL_List *l) { + this->pd_cdr_data->destroy (); this->pd_cdr_data = l; } -// Compute list length +// Compute list length. long -UTL_List::length () +UTL_List::length (void) { return list_length (1); } -// UTL_List active iterator +void +UTL_List::destroy (void) +{ + if (this->pd_cdr_data != 0) + { + this->pd_cdr_data->destroy (); + delete this->pd_cdr_data; + this->pd_cdr_data = 0; + } +} + +// UTL_List active iterator. // Constructor UTL_ListActiveIterator::UTL_ListActiveIterator (UTL_List *s) @@ -160,17 +190,19 @@ UTL_ListActiveIterator::UTL_ListActiveIterator (UTL_List *s) */ // Is iterator done? -long -UTL_ListActiveIterator::is_done () +idl_bool +UTL_ListActiveIterator::is_done (void) { - return (source == NULL) ? I_TRUE : I_FALSE; + return (this->source == 0) ? I_TRUE : I_FALSE; } // Advance to next item void UTL_ListActiveIterator::next () { - if (source != NULL) - source = source->tail (); + if (this->source != 0) + { + this->source = this->source->tail (); + } } diff --git a/TAO/TAO_IDL/util/utl_scope.cpp b/TAO/TAO_IDL/util/utl_scope.cpp index 9fd79747f2d..342be99fa10 100644 --- a/TAO/TAO_IDL/util/utl_scope.cpp +++ b/TAO/TAO_IDL/util/utl_scope.cpp @@ -968,7 +968,7 @@ UTL_Scope::lookup_pseudo (Identifier *e) || ACE_OS::strcmp (name_string, "ValueBase") == 0) { // Iterate over the global scope. - UTL_ScopeActiveIterator global_iter (idl_global->scopes ()->bottom (), + UTL_ScopeActiveIterator global_iter (idl_global->scopes ().bottom (), UTL_Scope::IK_decls); i = &global_iter; @@ -2023,6 +2023,27 @@ UTL_Scope::nmembers (void) void UTL_Scope::destroy (void) { + for (UTL_ScopeActiveIterator iter (this, IK_both); + !iter.is_done (); + iter.next ()) + { + AST_Decl *i = iter.item (); + i->destroy (); + delete i; + i = 0; + } + + delete [] this->pd_decls; + this->pd_decls = 0; + + delete [] this->pd_local_types; + this->pd_local_types = 0; + + delete [] this->pd_referenced; + this->pd_referenced = 0; + + delete [] this->pd_name_referenced; + this->pd_name_referenced = 0; } // Narrowing. @@ -2037,9 +2058,9 @@ UTL_ScopeActiveIterator::UTL_ScopeActiveIterator ( UTL_Scope::ScopeIterationKind i ) : iter_source (s), - ik(i), - stage(i == UTL_Scope::IK_both ? UTL_Scope::IK_localtypes : i), - il(0) + ik (i), + stage (i == UTL_Scope::IK_both ? UTL_Scope::IK_localtypes : i), + il (0) { } diff --git a/TAO/TAO_IDL/util/utl_stack.cpp b/TAO/TAO_IDL/util/utl_stack.cpp index 29f6dc49b26..1ab831aa0b9 100644 --- a/TAO/TAO_IDL/util/utl_stack.cpp +++ b/TAO/TAO_IDL/util/utl_stack.cpp @@ -68,9 +68,9 @@ trademarks or registered trademarks of Sun Microsystems, Inc. * utl_stack.cc - Implementation of class UTL_ScopeStack */ -#include "idl.h" +#include "idl.h" #include "ast_decl.h" -#include "idl_extern.h" +#include "idl_extern.h" ACE_RCSID(util, utl_stack, "$Id$") @@ -83,17 +83,20 @@ ACE_RCSID(util, utl_stack, "$Id$") * Constructor(s) and destructor */ -UTL_ScopeStack::UTL_ScopeStack() - : pd_stack_data(new UTL_Scope *[INCREMENT]), - pd_stack_data_nalloced(INCREMENT), - pd_stack_top(0) +UTL_ScopeStack::UTL_ScopeStack (void) + : pd_stack_data_nalloced (INCREMENT), + pd_stack_top (0) { + ACE_NEW (this->pd_stack_data, + UTL_Scope *[INCREMENT]); } -UTL_ScopeStack::~UTL_ScopeStack() +UTL_ScopeStack::~UTL_ScopeStack (void) { - if (pd_stack_data != NULL) - delete pd_stack_data; + if (this->pd_stack_data != 0) + { + delete this->pd_stack_data; + } } /* @@ -158,36 +161,42 @@ UTL_ScopeStack::pop (void) --this->pd_stack_top; } -// Return top element on stack +// Return top element on stack. UTL_Scope * UTL_ScopeStack::top (void) { - if (pd_stack_top <= 0) - return NULL; - return pd_stack_data[pd_stack_top - 1]; + if (this->pd_stack_top <= 0) + { + return 0; + } + + return this->pd_stack_data[pd_stack_top - 1]; } -// Return bottom element on stack +// Return bottom element on stack. UTL_Scope * UTL_ScopeStack::bottom (void) { - if (pd_stack_top == 0) - return NULL; - return pd_stack_data[0]; + if (this->pd_stack_top == 0) + { + return 0; + } + + return this->pd_stack_data[0]; } // Clear entire stack void UTL_ScopeStack::clear (void) { - pd_stack_top = 0; + this->pd_stack_top = 0; } // How deep is the stack? unsigned long UTL_ScopeStack::depth (void) { - return pd_stack_top; + return this->pd_stack_top; } // Return (top - 1) element on stack @@ -197,12 +206,14 @@ UTL_ScopeStack::next_to_top (void) UTL_Scope *tmp, *retval; if (depth() < 2) - return NULL; + { + return 0; + } - tmp = top(); // Save top - (void) pop(); // Pop it - retval = top(); // Get next one down - (void) push(tmp); // Push top back + tmp = top (); // Save top + (void) pop (); // Pop it + retval = top (); // Get next one down + (void) push (tmp); // Push top back return retval; // Return next one down } @@ -210,12 +221,15 @@ UTL_ScopeStack::next_to_top (void) UTL_Scope * UTL_ScopeStack::top_non_null (void) { - long i; + for (long i = this->pd_stack_top - 1; i >= 0; --i) + { + if (this->pd_stack_data[i] != 0) + { + return this->pd_stack_data[i]; + } + } - for (i = pd_stack_top - 1; i >= 0; i--) - if (pd_stack_data[i] != NULL) - return pd_stack_data[i]; - return NULL; + return 0; } /* @@ -228,9 +242,9 @@ UTL_ScopeStack::top_non_null (void) * Constructor(s) */ -UTL_ScopeStackActiveIterator::UTL_ScopeStackActiveIterator(UTL_ScopeStack *s) - : source(s), - il(s->pd_stack_top - 1) +UTL_ScopeStackActiveIterator::UTL_ScopeStackActiveIterator (UTL_ScopeStack &s) + : source (s), + il (s.pd_stack_top - 1) { } @@ -244,29 +258,32 @@ UTL_ScopeStackActiveIterator::UTL_ScopeStackActiveIterator(UTL_ScopeStack *s) // Advance to next item void -UTL_ScopeStackActiveIterator::next() +UTL_ScopeStackActiveIterator::next (void) { il--; } // Get current item UTL_Scope * -UTL_ScopeStackActiveIterator::item() +UTL_ScopeStackActiveIterator::item (void) { - if (il >= 0) - return source->pd_stack_data[il]; - return NULL; + if (this->il >= 0) + { + return this->source.pd_stack_data[il]; + } + + return 0; } // Is this iteration done? long -UTL_ScopeStackActiveIterator::is_done() +UTL_ScopeStackActiveIterator::is_done (void) { - if (il >= 0) - return I_FALSE; + if (this->il >= 0) + { + return I_FALSE; + } + return I_TRUE; } -/* - * Redefinition of inherited virtual operations - */ diff --git a/TAO/TAO_IDL/util/utl_strlist.cpp b/TAO/TAO_IDL/util/utl_strlist.cpp index c7776e5cff3..ce2a9a630f5 100644 --- a/TAO/TAO_IDL/util/utl_strlist.cpp +++ b/TAO/TAO_IDL/util/utl_strlist.cpp @@ -129,46 +129,50 @@ void UTL_StrList::destroy (void) { UTL_String *str = 0; - UTL_StrlistActiveIterator *i = 0; - ACE_NEW (i, - UTL_StrlistActiveIterator (this)); - while (!(i->is_done ())) + for (UTL_StrlistActiveIterator i (this); !i.is_done (); i.next ()) { - str = i->item (); + str = i.item (); str->destroy (); delete str; str = 0; - i->next (); } - - delete i; } // AST Dumping void -UTL_StrList::dump(ACE_OSTREAM_TYPE &o) +UTL_StrList::dump (ACE_OSTREAM_TYPE &o) { - char *s; - UTL_StrlistActiveIterator *i = new UTL_StrlistActiveIterator(this); - idl_bool first = I_TRUE; - idl_bool second = I_FALSE; - - while (!(i->is_done())) { - if (!first) - o << "::"; - else if (second) - first = second = I_FALSE; - s = i->item()->get_string(); - o << s; - if (first) { - if (strcmp(s, "::") != 0) - first = I_FALSE; - else - second = I_TRUE; + char *s = 0; + idl_bool first = I_TRUE; + idl_bool second = I_FALSE; + + for (UTL_StrlistActiveIterator i (this); !i.is_done(); i.next ()) + { + if (!first) + { + o << "::"; + } + else if (second) + { + first = second = I_FALSE; + } + + s = i.item ()->get_string (); + o << s; + + if (first) + { + if (ACE_OS::strcmp (s, "::") != 0) + { + first = I_FALSE; + } + else + { + second = I_TRUE; + } + } } - i->next(); - } } /* @@ -181,8 +185,8 @@ UTL_StrList::dump(ACE_OSTREAM_TYPE &o) * Constructor */ -UTL_StrlistActiveIterator::UTL_StrlistActiveIterator(UTL_StrList *s) - : UTL_ListActiveIterator(s) +UTL_StrlistActiveIterator::UTL_StrlistActiveIterator (UTL_StrList *s) + : UTL_ListActiveIterator (s) { } @@ -196,11 +200,14 @@ UTL_StrlistActiveIterator::UTL_StrlistActiveIterator(UTL_StrList *s) // Get current item UTL_String * -UTL_StrlistActiveIterator::item() +UTL_StrlistActiveIterator::item (void) { - if (source == NULL) - return NULL; - return ((UTL_StrList *) source)->head(); + if (source == 0) + { + return 0; + } + + return ((UTL_StrList *) source)->head (); } /* diff --git a/TAO/TAO_IDL/util/utl_tmpl/utl_idlist.cpp b/TAO/TAO_IDL/util/utl_tmpl/utl_idlist.cpp index 229376234ba..becb6e8d3d1 100644 --- a/TAO/TAO_IDL/util/utl_tmpl/utl_idlist.cpp +++ b/TAO/TAO_IDL/util/utl_tmpl/utl_idlist.cpp @@ -80,35 +80,48 @@ UTL_IdList::UTL_IdList(Identifier *s, UTL_IdList *cdr) // Get last item of this list Identifier * -UTL_IdList::last_component() +UTL_IdList::last_component (void) { - if (tail() == NULL) - return head(); - return tail()->last_component(); + if (tail() == 0) + { + return head (); + } + + return tail ()->last_component (); } // AST Dumping void -UTL_IdList::dump(ACE_OSTREAM_TYPE &o) +UTL_IdList::dump (ACE_OSTREAM_TYPE &o) { - UTL_IdListActiveIterator *i = new UTL_IdListActiveIterator(this); - long first = I_TRUE; - long second = I_FALSE; - - while (!(i->is_done())) { - if (!first) - o << "::"; - else if (second) - first = second = I_FALSE; - i->item()->dump(o); - if (first) { - if (strcmp(i->item()->get_string(), "::") != 0) - first = I_FALSE; - else - second = I_TRUE; + long first = I_TRUE; + long second = I_FALSE; + + for (UTL_IdListActiveIterator (this); !i.is_done (); i.next ()) + { + if (!first) + { + o << "::"; + } + else if (second) + { + first = second = I_FALSE; + } + + i.item ()->dump (o); + + if (first) + { + if (ACE_OS::strcmp (i.item ()->get_string (), "::") != 0) + { + first = I_FALSE; + } + else + { + second = I_TRUE; + } + } } - i->next(); - } } /* @@ -121,8 +134,8 @@ UTL_IdList::dump(ACE_OSTREAM_TYPE &o) * Constructor */ -UTL_IdListActiveIterator::UTL_IdListActiveIterator(UTL_IdList *s) - : UTL_ListActiveIterator<UTL_IdList, Identifier>(s) +UTL_IdListActiveIterator::UTL_IdListActiveIterator (UTL_IdList *s) + : UTL_ListActiveIterator<UTL_IdList, Identifier> (s) { } diff --git a/TAO/TAO_IDL/util/utl_tmpl/utl_strlist.cpp b/TAO/TAO_IDL/util/utl_tmpl/utl_strlist.cpp index c9649d21b93..baeeb6b0f77 100644 --- a/TAO/TAO_IDL/util/utl_tmpl/utl_strlist.cpp +++ b/TAO/TAO_IDL/util/utl_tmpl/utl_strlist.cpp @@ -89,28 +89,39 @@ UTL_StrList::last_component() // AST Dumping void -UTL_StrList::dump(ACE_OSTREAM_TYPE &o) +UTL_StrList::dump (ACE_OSTREAM_TYPE &o) { - char *s; - UTL_StrlistActiveIterator *i = new UTL_StrlistActiveIterator(this); - long first = I_TRUE; - long second = I_FALSE; - - while (!(i->is_done())) { - if (!first) - o << "::"; - else if (second) - first = second = I_FALSE; - s = i->item()->get_string(); - o << s; - if (first) { - if (strcmp(s, "::") != 0) - first = I_FALSE; - else - second = I_TRUE; + char *s = 0;; + UTL_StrlistActiveIterator *i = new UTL_StrlistActiveIterator (this); + long first = I_TRUE; + long second = I_FALSE; + + for (UTL_StrlistActiveIterator (this); !i.is_done(); i.next ()) + { + if (!first) + { + o << "::"; + } + else if (second) + { + first = second = I_FALSE; + } + + s = i.item ()->get_string (); + o << s; + + if (first) + { + if (ACE_OS::strcmp (s, "::") != 0) + { + first = I_FALSE; + } + else + { + second = I_TRUE; + } + } } - i->next(); - } } /* |