diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-02-04 16:48:59 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-02-04 16:48:59 +0000 |
commit | 74726b1426daa6db7016097cac90de62e14062c8 (patch) | |
tree | 10489250153b54a62f537bca7ca6367bbfd61dda | |
parent | 1a0ff1fa322e7f4c226e901b7153ce24e2aa68ce (diff) | |
download | ATCD-74726b1426daa6db7016097cac90de62e14062c8.tar.gz |
ChangeLogTag: Mon Feb 4 10:47:52 2002 Jeff Parsons <parsons@cs.wustl.edu>
44 files changed, 2354 insertions, 1863 deletions
diff --git a/TAO/TAO_IDL/ast/ast_decl.cpp b/TAO/TAO_IDL/ast/ast_decl.cpp index 427c0d37458..aac03d7062d 100644 --- a/TAO/TAO_IDL/ast/ast_decl.cpp +++ b/TAO/TAO_IDL/ast/ast_decl.cpp @@ -256,15 +256,11 @@ AST_Decl::compute_full_name (void) else { long namelen = 0; - UTL_IdListActiveIterator *i = 0; long first = I_TRUE; long second = I_FALSE; + char *name = 0; - // In the first loop, compute the total length. - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - while (!i->is_done ()) + for (UTL_IdListActiveIterator i (this->name ());!i.is_done ();i.next ()) { if (!first) { @@ -276,11 +272,12 @@ AST_Decl::compute_full_name (void) } // Print the identifier. - namelen += ACE_OS::strlen (i->item ()->get_string ()); + name = i.item ()->get_string (); + namelen += ACE_OS::strlen (name); if (first) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (name, "") != 0) { // Does not start with a "". first = I_FALSE; @@ -290,12 +287,8 @@ AST_Decl::compute_full_name (void) second = I_TRUE; } } - - i->next (); } - delete i; - ACE_NEW (this->full_name_, char[namelen + 1]); @@ -303,10 +296,7 @@ AST_Decl::compute_full_name (void) first = I_TRUE; second = I_FALSE; - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - while (!(i->is_done ())) + for (UTL_IdListActiveIterator j (this->name ());!j.is_done ();j.next ()) { if (!first) { @@ -318,11 +308,12 @@ AST_Decl::compute_full_name (void) } // Print the identifier. - ACE_OS::strcat (this->full_name_, i->item ()->get_string ()); + name = j.item ()->get_string (); + ACE_OS::strcat (this->full_name_, name); if (first) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (name, "") != 0) { // Does not start with a "". first = I_FALSE; @@ -332,11 +323,7 @@ AST_Decl::compute_full_name (void) second = I_TRUE; } } - - i->next (); } - - delete i; } return; @@ -355,6 +342,7 @@ AST_Decl::compute_repoID (void) long namelen = 4; // for the prefix "IDL:" long first = I_TRUE; long second = I_FALSE; + char *name = 0; // in the first loop compute the total length namelen += ACE_OS::strlen (this->prefix_) + 1; @@ -370,9 +358,7 @@ AST_Decl::compute_repoID (void) namelen += 4; } - UTL_IdListActiveIterator i (this->name ()); - - while (!(i.is_done ())) + for (UTL_IdListActiveIterator i (this->name ());!i.is_done ();i.next ()) { if (!first) { @@ -384,11 +370,12 @@ AST_Decl::compute_repoID (void) } // Print the identifier. - namelen += ACE_OS::strlen (i.item ()->get_string ()); + name = i.item ()->get_string (); + namelen += ACE_OS::strlen (name); if (first) { - if (ACE_OS::strcmp (i.item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (name, "") != 0) { // Does not start with a "". first = I_FALSE; @@ -398,8 +385,6 @@ AST_Decl::compute_repoID (void) second = I_TRUE; } } - - i.next (); } ACE_NEW (this->repoID_, @@ -420,12 +405,10 @@ AST_Decl::compute_repoID (void) ACE_OS::strcat (this->repoID_, "/"); } - UTL_IdListActiveIterator j (this->name ()); - first = I_TRUE; second = I_FALSE; - while (!(j.is_done ())) + for (UTL_IdListActiveIterator j (this->name ());!j.is_done ();j.next ()) { if (!first) { @@ -437,12 +420,13 @@ AST_Decl::compute_repoID (void) } // Print the identifier. + name = j.item ()->get_string (); ACE_OS::strcat (this->repoID_, - j.item ()->get_string ()); + name); if (first) { - if (ACE_OS::strcmp (j.item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (name, "") != 0) { // Does not start with a "". first = I_FALSE; @@ -452,8 +436,6 @@ AST_Decl::compute_repoID (void) second = I_TRUE; } } - - j.next (); } if (this->version_ != 0) @@ -469,8 +451,6 @@ AST_Decl::compute_repoID (void) ":1.0"); } } - - return; } // Public operations. diff --git a/TAO/TAO_IDL/ast/ast_enum.cpp b/TAO/TAO_IDL/ast/ast_enum.cpp index 435db829fae..26024fb0478 100644 --- a/TAO/TAO_IDL/ast/ast_enum.cpp +++ b/TAO/TAO_IDL/ast/ast_enum.cpp @@ -112,30 +112,20 @@ AST_Enum::member_count (void) UTL_ScopedName * AST_Enum::value_to_name (const unsigned long v) { - UTL_ScopeActiveIterator *iter = 0; AST_EnumVal *item = 0; - AST_Decl *i = 0; - - ACE_NEW_RETURN (iter, - UTL_ScopeActiveIterator (this, - IK_decls), - 0); + AST_Decl *d = 0; - while (!iter->is_done ()) + for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ()) { - i = iter->item (); - item = AST_EnumVal::narrow_from_decl (i); + d = i.item (); + item = AST_EnumVal::narrow_from_decl (d); if (item->constant_value ()->ev ()->u.ulval == v) { - delete iter; return item->name (); } - - iter->next (); } - delete iter; return 0; } @@ -144,29 +134,19 @@ AST_EnumVal * AST_Enum::lookup_by_value (const AST_Expression *v) { AST_EnumVal *item = 0; - AST_Decl *i = 0; - - UTL_ScopeActiveIterator *iter = 0; - ACE_NEW_RETURN (iter, - UTL_ScopeActiveIterator (this, - IK_decls), - 0); + AST_Decl *d = 0; - while (!iter->is_done ()) + for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ()) { - i = iter->item (); - item = AST_EnumVal::narrow_from_decl (i); + d = i.item (); + item = AST_EnumVal::narrow_from_decl (d); if (item->constant_value () == v) { - delete iter; return item; } - - iter->next (); } - delete iter; return 0; } @@ -221,27 +201,16 @@ munge_name_for_enumval (UTL_ScopedName *n, int AST_Enum::compute_member_count (void) { - UTL_ScopeActiveIterator *si = 0; - this->member_count_ = 0; // If there are elements in this scope if (this->nmembers () > 0) { - // Instantiate a scope iterator. - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls), - -1); - - while (!(si->is_done ())) - { - // Get the next AST decl node. - this->member_count_++; - si->next (); + for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ()) + { + // Get the next AST decl node. + ++this->member_count_; } - - delete si; } return 0; @@ -318,11 +287,6 @@ AST_Enum::fe_add_enum_val (AST_EnumVal *t) void AST_Enum::dump (ACE_OSTREAM_TYPE &o) { - UTL_ScopeActiveIterator *i = 0; - ACE_NEW (i, - UTL_ScopeActiveIterator (this, - IK_decls)); - AST_Decl *d = 0; if (this->is_local ()) @@ -338,20 +302,19 @@ AST_Enum::dump (ACE_OSTREAM_TYPE &o) this->local_name ()->dump (o); o << " {\n"; - while (!i->is_done ()) + // Must increment the iterator explicitly inside the loop. + for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();) { - d = i->item (); + d = i.item (); d->local_name ()->dump (o); - i->next (); + i.next (); - if (!i->is_done ()) + if (!i.is_done ()) { o << ", "; } } - delete i; - idl_global->indent ()->skip_to (o); o << "}"; } diff --git a/TAO/TAO_IDL/ast/ast_exception.cpp b/TAO/TAO_IDL/ast/ast_exception.cpp index c7e391349d6..069d8e33e46 100644 --- a/TAO/TAO_IDL/ast/ast_exception.cpp +++ b/TAO/TAO_IDL/ast/ast_exception.cpp @@ -112,20 +112,15 @@ AST_Exception::in_recursion (AST_Type *node) // Proceed if the number of members in our scope is greater than 0. if (this->nmembers () > 0) { - // Initialize an iterator to iterate thru our scope. - UTL_ScopeActiveIterator si (this, - UTL_Scope::IK_decls); - // Continue until each element is visited. - while (!si.is_done ()) + for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ()) { - AST_Field *field = AST_Field::narrow_from_decl (si.item ()); + AST_Field *field = AST_Field::narrow_from_decl (i.item ()); if (field == 0) // This will be an enum value or other legitimate non-field // member - in any case, no recursion. { - si.next (); continue; } @@ -144,8 +139,6 @@ AST_Exception::in_recursion (AST_Type *node) { return 1; } - - si.next (); } } diff --git a/TAO/TAO_IDL/ast/ast_factory.cpp b/TAO/TAO_IDL/ast/ast_factory.cpp index c5307a80ecc..2d464a1da90 100644 --- a/TAO/TAO_IDL/ast/ast_factory.cpp +++ b/TAO/TAO_IDL/ast/ast_factory.cpp @@ -141,14 +141,10 @@ AST_Factory::compute_argument_attr (void) // If there are elements in this scope. if (this->nmembers () > 0) { - // Instantiate a scope iterator. - UTL_ScopeActiveIterator si (this, - UTL_Scope::IK_decls); - - while (!si.is_done ()) + for (UTL_ScopeActiveIterator i (this, IK_decls);!i.is_done ();i.next ()) { // Get the next AST decl node. - d = si.item (); + d = i.item (); if (d->node_type () == AST_Decl::NT_argument) { @@ -163,8 +159,6 @@ AST_Factory::compute_argument_attr (void) this->has_native_ = 1; } } - - si.next (); } } diff --git a/TAO/TAO_IDL/ast/ast_interface.cpp b/TAO/TAO_IDL/ast/ast_interface.cpp index d1a7df65cd0..4fade4b5971 100644 --- a/TAO/TAO_IDL/ast/ast_interface.cpp +++ b/TAO/TAO_IDL/ast/ast_interface.cpp @@ -1045,35 +1045,20 @@ AST_Interface::compare_names (AST_Interface *that, Identifier *that_id = 0; Identifier *other_id = 0; - UTL_IdListActiveIterator *that_iter = 0; - ACE_NEW_RETURN (that_iter, - UTL_IdListActiveIterator (that_name), - I_FALSE); - - UTL_IdListActiveIterator *other_iter = 0; - ACE_NEW_RETURN (other_iter, - UTL_IdListActiveIterator (other_name), - I_FALSE); - - for (int i = 0; i < that_length; i++) + for (UTL_IdListActiveIterator that_iter (that_name), other_iter (other_name); + !that_iter.is_done (); + that_iter.next (), other_iter.next ()) { - that_id = that_iter->item (); - other_id = other_iter->item (); + that_id = that_iter.item (); + other_id = other_iter.item (); if (ACE_OS::strcmp (that_id->get_string (), other_id->get_string ())) { - delete that_iter; - delete other_iter; return I_FALSE; } - - that_iter->next (); - other_iter->next (); } - delete that_iter; - delete other_iter; return I_TRUE; } @@ -1086,26 +1071,23 @@ AST_Interface::inherited_name_clash (void) // Compare our members with those of each parent. - UTL_ScopeActiveIterator *my_members = 0; - ACE_NEW (my_members, - UTL_ScopeActiveIterator (DeclAsScope (this), - UTL_Scope::IK_decls)); - - while (!my_members->is_done ()) + for (UTL_ScopeActiveIterator my_members (DeclAsScope (this), IK_decls); + !my_members.is_done (); + my_members.next ()) { - my_member = my_members->item (); + my_member = my_members.item (); Identifier *id = my_member->local_name (); - for (int i = 0; i < this->pd_n_inherits_flat; i ++) + for (int i = 0; i < this->pd_n_inherits_flat; ++i) { - UTL_ScopeActiveIterator *parent_members = 0; - ACE_NEW (parent_members, - UTL_ScopeActiveIterator (DeclAsScope (pd_inherits_flat[i]), - UTL_Scope::IK_decls)); - - while (!parent_members->is_done ()) + for (UTL_ScopeActiveIterator parent_members ( + DeclAsScope (this->pd_inherits_flat[i]), + UTL_Scope::IK_decls + ); + !parent_members.is_done (); + parent_members.next ()) { - parent1_member = parent_members->item (); + parent1_member = parent_members.item (); AST_Decl::NodeType nt = parent1_member->node_type (); // All other member types but these may be redefined in @@ -1139,31 +1121,23 @@ AST_Interface::inherited_name_clash (void) ); } } - } - - parent_members->next (); - } - - delete parent_members; - } - - my_members->next (); - } - - delete my_members; + } // end of IF (nt == AST_Decl::NT_op ....) + } // end of FOR (parent_members ...) + } // end of FOR (i ...) + } // end of FOR (my_members ...) // Now compare members of each parent with each other. for (int i = 0; i < this->pd_n_inherits_flat - 1; i++) { - UTL_ScopeActiveIterator *parent1_members = 0; - ACE_NEW (parent1_members, - UTL_ScopeActiveIterator (DeclAsScope (pd_inherits_flat[i]), - UTL_Scope::IK_decls)); - - while (!parent1_members->is_done ()) + for (UTL_ScopeActiveIterator parent1_members ( + DeclAsScope (this->pd_inherits_flat[i]), + UTL_Scope::IK_decls + ); + !parent1_members.is_done (); + parent1_members.next ()) { - parent1_member = parent1_members->item (); + parent1_member = parent1_members.item (); AST_Decl::NodeType nt1 = parent1_member->node_type (); // Only these member types may cause a clash with other @@ -1174,16 +1148,14 @@ AST_Interface::inherited_name_clash (void) for (int j = i + 1; j < this->pd_n_inherits_flat; j++) { - UTL_ScopeActiveIterator *parent2_members = 0; - ACE_NEW (parent2_members, - UTL_ScopeActiveIterator ( - DeclAsScope (pd_inherits_flat[j]), - UTL_Scope::IK_decls - )); - - while (!parent2_members->is_done ()) + for (UTL_ScopeActiveIterator parent2_members ( + DeclAsScope (this->pd_inherits_flat[j]), + UTL_Scope::IK_decls + ); + !parent2_members.is_done (); + parent2_members.next ()) { - parent2_member = parent2_members->item (); + parent2_member = parent2_members.item (); AST_Decl::NodeType nt2 = parent2_member->node_type (); @@ -1223,20 +1195,12 @@ AST_Interface::inherited_name_clash (void) ); } } - } - - parent2_members->next (); - } - - delete parent2_members; - } - } - - parent1_members->next (); - } - - delete parent1_members; - } + } // end of IF (nt2 == AST_Decl::NT_op ...) + } // end of FOR (parent2_members ...) + } // end of FOR (j ...) + } // end of IF (nt1 == AST_Decl::NT_op ..) + } // end of FOR (parent1_members ...) + } // end of FOR (i ...) } void diff --git a/TAO/TAO_IDL/ast/ast_module.cpp b/TAO/TAO_IDL/ast/ast_module.cpp index 4ccf3e49dc5..7b8e850bbe1 100644 --- a/TAO/TAO_IDL/ast/ast_module.cpp +++ b/TAO/TAO_IDL/ast/ast_module.cpp @@ -847,22 +847,19 @@ AST_Module::add_to_previous (AST_Module *m) // reopenings in its previous_ member. this->previous_ = m->previous_; - UTL_ScopeActiveIterator *iter = - new UTL_ScopeActiveIterator (DeclAsScope (m), - UTL_Scope::IK_decls); - AST_Decl *d = 0; - while (!iter->is_done ()) + for (UTL_ScopeActiveIterator iter (DeclAsScope (m), IK_decls); + !iter.is_done (); + iter.next ()) { - d = iter->item (); + d = iter.item (); // Add all the previous opening's decls (except // for the predefined types) to the 'previous' list // of this one. if (d->node_type () == AST_Decl::NT_pre_defined) { - iter->next (); continue; } else if (d->node_type () == AST_Decl::NT_interface_fwd) @@ -877,16 +874,12 @@ AST_Module::add_to_previous (AST_Module *m) // results of look_in_previous() later, so we skip it. if (i->is_defined ()) { - iter->next (); continue; } } this->previous_.insert (d); - iter->next (); } - - delete iter; } AST_Decl * diff --git a/TAO/TAO_IDL/ast/ast_operation.cpp b/TAO/TAO_IDL/ast/ast_operation.cpp index 8668d833a0f..8d058ee36ee 100644 --- a/TAO/TAO_IDL/ast/ast_operation.cpp +++ b/TAO/TAO_IDL/ast/ast_operation.cpp @@ -159,7 +159,9 @@ AST_Operation::count_arguments_with_direction (int direction_mask) AST_Argument::narrow_from_decl (si.item ()); if ((arg->direction () & direction_mask) != 0) - count++; + { + ++count; + } } return count; @@ -277,20 +279,15 @@ AST_Operation::be_add_exceptions (UTL_ExceptList *t) UTL_NameList * AST_Operation::fe_add_exceptions (UTL_NameList *t) { - UTL_NamelistActiveIterator *nl_i = 0; UTL_ScopedName *nl_n = 0; AST_Exception *fe = 0; AST_Decl *d = 0; this->pd_exceptions = 0; - ACE_NEW_RETURN (nl_i, - UTL_NamelistActiveIterator(t), - 0); - - while (!nl_i->is_done()) + for (UTL_NamelistActiveIterator nl_i (t); !nl_i.is_done (); nl_i.next ()) { - nl_n = nl_i->item (); + nl_n = nl_i.item (); d = lookup_by_name (nl_n, I_TRUE); @@ -298,7 +295,6 @@ AST_Operation::fe_add_exceptions (UTL_NameList *t) if (d == 0 || d->node_type() != AST_Decl::NT_except) { idl_global->err ()->lookup_error (nl_n); - delete nl_i; return 0; } @@ -334,11 +330,8 @@ AST_Operation::fe_add_exceptions (UTL_NameList *t) this->pd_exceptions->nconc (el); } - - nl_i->next (); } - delete nl_i; return t; } @@ -404,9 +397,6 @@ AST_Operation::fe_add_argument (AST_Argument *t) void AST_Operation::dump (ACE_OSTREAM_TYPE &o) { - UTL_ScopeActiveIterator *i = 0; - UTL_StrlistActiveIterator *si = 0; - UTL_ExceptlistActiveIterator *ei = 0; AST_Decl *d = 0; AST_Exception *e = 0; UTL_String *s = 0; @@ -420,50 +410,44 @@ AST_Operation::dump (ACE_OSTREAM_TYPE &o) o << "idempotent "; } - ACE_NEW (i, - UTL_ScopeActiveIterator (this, - IK_decls)); - this->pd_return_type->name ()->dump (o); o << " "; this->local_name ()->dump (o); o << "("; - while (!i->is_done()) + // Must advance the iterator explicity inside the loop. + for (UTL_ScopeActiveIterator i (this, IK_decls); !i.is_done ();) { - d = i->item (); + d = i.item (); d->dump (o); - i->next (); + i.next (); - if (!i->is_done()) + if (!i.is_done()) { o << ", "; } } - delete i; o << ")"; if (this->pd_exceptions != 0) { o << " raises("; - ACE_NEW (ei, - UTL_ExceptlistActiveIterator (pd_exceptions)); - - while (!ei->is_done()) + // Must advance the iterator explicity inside the loop. + for (UTL_ExceptlistActiveIterator ei (this->pd_exceptions); + !ei.is_done ();) { - e = ei->item (); - ei->next (); + e = ei.item (); + ei.next (); e->local_name ()->dump (o); - if (!ei->is_done()) + if (!ei.is_done()) { o << ", "; } } - delete ei; o << ")"; } @@ -471,22 +455,19 @@ AST_Operation::dump (ACE_OSTREAM_TYPE &o) { o << " context("; - ACE_NEW (si, - UTL_StrlistActiveIterator (pd_context)); - - while (!si->is_done()) + // Must advance the iterator explicity inside the loop. + for (UTL_StrlistActiveIterator si (this->pd_context); !si.is_done();) { - s = si->item (); - si->next (); + s = si.item (); + si.next (); o << s->get_string (); - if (!si->is_done()) + if (!si.is_done()) { o << ", "; } } - delete si; o << ")"; } } diff --git a/TAO/TAO_IDL/ast/ast_recursive.cpp b/TAO/TAO_IDL/ast/ast_recursive.cpp index da51c83656d..cf8b2aa80ea 100644 --- a/TAO/TAO_IDL/ast/ast_recursive.cpp +++ b/TAO/TAO_IDL/ast/ast_recursive.cpp @@ -126,25 +126,21 @@ AST_illegal_recursive_type (AST_Decl *t) } } - // OK, iterate up the stack. - UTL_ScopeStackActiveIterator *i = 0; - ACE_NEW_RETURN (i, - UTL_ScopeStackActiveIterator (idl_global->scopes ()), - 0); - UTL_Scope *s = 0; AST_Structure *st2 = 0; AST_Union *un2 = 0; - while (!i->is_done ()) + // OK, iterate up the stack. + for (UTL_ScopeStackActiveIterator i (idl_global->scopes ()); + !i.is_done (); + i.next ()) { - s = i->item (); + s = i.item (); // If we hit a NULL we're done since it means that we're nested inside // a sequence, where recursive types may be used. if (s == 0) { - delete i; return I_FALSE; // NOT ILLEGAL. } @@ -156,7 +152,6 @@ AST_illegal_recursive_type (AST_Decl *t) if (st2 != 0 && st2 == st1) { - delete i; return I_TRUE; // ILLEGAL RECURSIVE TYPE USE. } } @@ -167,17 +162,12 @@ AST_illegal_recursive_type (AST_Decl *t) if (un2 != 0 && un2 == un1) { - delete i; return I_TRUE; // ILLEGAL RECURSIVE TYPE USE. } } - - // This one is fine, get next item. - i->next (); } // No more scopes to check. This type was used legally. - delete i; return I_FALSE; // NOT ILLEGAL. } diff --git a/TAO/TAO_IDL/ast/ast_structure.cpp b/TAO/TAO_IDL/ast/ast_structure.cpp index a3711cdca51..bea188fa9bd 100644 --- a/TAO/TAO_IDL/ast/ast_structure.cpp +++ b/TAO/TAO_IDL/ast/ast_structure.cpp @@ -125,11 +125,10 @@ AST_Structure::in_recursion (AST_Type *node) if (this->nmembers () > 0) { // Initialize an iterator to iterate over our scope. - UTL_ScopeActiveIterator si (this, - UTL_Scope::IK_decls); - // Continue until each element is visited. - while (!si.is_done ()) + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { AST_Field *field = AST_Field::narrow_from_decl (si.item ()); @@ -137,7 +136,6 @@ AST_Structure::in_recursion (AST_Type *node) // This will be an enum value or other legitimate non-field // member - in any case, no recursion. { - si.next (); continue; } @@ -156,8 +154,6 @@ AST_Structure::in_recursion (AST_Type *node) { return 1; } - - si.next (); } } @@ -207,24 +203,16 @@ AST_Structure::is_local (void) if (this->nmembers () > 0) { // Instantiate a scope iterator. - UTL_ScopeActiveIterator *si = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls), - 0); - - while (!si->is_done ()) + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - if (si->item ()->is_local ()) + if (si.item ()->is_local ()) { this->local_struct_ = I_TRUE; break; } - - si->next (); } - - delete si; } } } @@ -479,19 +467,12 @@ AST_Structure::compute_member_count (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 ()) { - this->member_count_++; - si->next (); + ++this->member_count_; } - - delete si; } return 0; diff --git a/TAO/TAO_IDL/ast/ast_union.cpp b/TAO/TAO_IDL/ast/ast_union.cpp index 4791fc227ef..f503197aaff 100644 --- a/TAO/TAO_IDL/ast/ast_union.cpp +++ b/TAO/TAO_IDL/ast/ast_union.cpp @@ -204,11 +204,10 @@ AST_Union::in_recursion (AST_Type *node) if (this->nmembers () > 0) { // Initialize an iterator to iterate thru our scope. - UTL_ScopeActiveIterator si (this, - UTL_Scope::IK_decls); - // Continue until each element is visited. - while (!si.is_done ()) + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { AST_UnionBranch *field = AST_UnionBranch::narrow_from_decl (si.item ()); @@ -217,7 +216,6 @@ AST_Union::in_recursion (AST_Type *node) // This will be an enum value or other legitimate non-field // member - in any case, no recursion. { - si.next (); continue; } @@ -236,8 +234,6 @@ AST_Union::in_recursion (AST_Type *node) { return 1; } - - si.next (); } } @@ -249,18 +245,14 @@ AST_Union::in_recursion (AST_Type *node) AST_UnionBranch * AST_Union::lookup_default (void) { - UTL_ScopeActiveIterator *i = 0; - ACE_NEW_RETURN (i, - UTL_ScopeActiveIterator (this, - IK_both), - 0); - - AST_UnionBranch *b = 0; + AST_UnionBranch *b = 0; AST_Decl *d = 0; - while (!i->is_done()) + for (UTL_ScopeActiveIterator i (this, UTL_Scope::IK_both); + !i.is_done(); + i.next ()) { - d = i->item (); + d = i.item (); if (d->node_type () == AST_Decl::NT_union_branch) { @@ -268,26 +260,21 @@ AST_Union::lookup_default (void) if (b == 0) { - i->next (); continue; } - if (b->label() != 0 + if (b->label () != 0 && b->label ()->label_kind () == AST_UnionLabel::UL_default) { - idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, + idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, this, b); - delete i; - return b; + return b; } } - - i->next (); } - delete i; - return NULL; + return 0; } // Look up a branch by label. @@ -313,15 +300,11 @@ AST_Union::lookup_label (AST_UnionBranch *b) return b; } - UTL_ScopeActiveIterator *i = 0; - ACE_NEW_RETURN (i, - UTL_ScopeActiveIterator (this, - IK_decls), - 0); - - while (!i->is_done()) + for (UTL_ScopeActiveIterator i (this, UTL_Scope::IK_decls); + !i.is_done(); + i.next ()) { - d = i->item (); + d = i.item (); if (d->node_type () == AST_Decl::NT_union_branch) { @@ -329,7 +312,6 @@ AST_Union::lookup_label (AST_UnionBranch *b) if (fb == 0) { - i->next (); continue; } @@ -337,18 +319,14 @@ AST_Union::lookup_label (AST_UnionBranch *b) && fb->label ()->label_kind () == AST_UnionLabel::UL_label && fb->label ()->label_val ()->compare (lv)) { - idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, + idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, this, b); - delete i; - return b; + return b; } } - - i->next(); } - delete i; return 0; } @@ -397,15 +375,11 @@ AST_Union::lookup_enum (AST_UnionBranch *b) // OK, now see if this symbol is already used as the label of // some other branch. - UTL_ScopeActiveIterator *i = 0; - ACE_NEW_RETURN (i, - UTL_ScopeActiveIterator (this, - IK_decls), - 0); - - while (!i->is_done()) + for (UTL_ScopeActiveIterator i (this, UTL_Scope::IK_decls); + !i.is_done(); + i.next ()) { - d = i->item (); + d = i.item (); if (d->node_type () == AST_Decl::NT_union_branch) { @@ -413,27 +387,22 @@ AST_Union::lookup_enum (AST_UnionBranch *b) if (fb == 0) { - i->next (); - continue; + continue; } if (fb->label() != 0 && fb->label ()->label_kind () == AST_UnionLabel::UL_label && fb->label ()->label_val ()->compare (lv)) { - idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, + idl_global->err ()->error2 (UTL_Error::EIDL_MULTIPLE_BRANCH, this, b); - delete i; - return b; + return b; } } - - i->next(); } - delete i; - return NULL; + return 0; } // Look up a branch by value. This is the top level branch label resolution @@ -459,7 +428,7 @@ AST_Union::lookup_branch (AST_UnionBranch *branch) if (this->pd_udisc_type == AST_Expression::EV_any) { // CONVENTION: indicates enum discriminant. - return lookup_enum(branch); + return lookup_enum (branch); } return lookup_label (branch); @@ -502,10 +471,9 @@ AST_Union::compute_default_value (void) int total_case_members = 0; // Instantiate a scope iterator. - UTL_ScopeActiveIterator si (this, - UTL_Scope::IK_decls); - - while (!si.is_done ()) + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { // Get the next AST decl node. AST_UnionBranch *ub = @@ -514,18 +482,14 @@ AST_Union::compute_default_value (void) if (ub != 0) { // If the label is a case label, increment by 1. - for (unsigned long i = 0; - i < ub->label_list_length (); - ++i) + for (unsigned long i = 0; i < ub->label_list_length (); ++i) { if (ub->label (i)->label_kind () == AST_UnionLabel::UL_label) { - total_case_members++; + ++total_case_members; } } } - - si.next (); } // Check if the total_case_members cover the entire @@ -697,13 +661,12 @@ AST_Union::compute_default_value (void) // Proceed until we have found the appropriate default value. while (this->default_value_.computed_ == -2) { - // Instantiate a scope iterator. - UTL_ScopeActiveIterator si (this, - UTL_Scope::IK_decls); - int break_loop = 0; - while (!si.is_done () && break_loop == 0) + // Instantiate a scope iterator. + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done () && break_loop == 0; + si.next ()) { // Get the next AST decl node AST_UnionBranch *ub = @@ -715,8 +678,7 @@ AST_Union::compute_default_value (void) i < ub->label_list_length () && !break_loop; ++i) { - if (ub->label (i)->label_kind () - == AST_UnionLabel::UL_label) + if (ub->label (i)->label_kind () == AST_UnionLabel::UL_label) { // Not a default. AST_Expression *expr = ub->label (i)->label_val (); @@ -725,12 +687,14 @@ AST_Union::compute_default_value (void) { // Error. this->default_value_.computed_ = -1; - ACE_ERROR_RETURN - ((LM_ERROR, + ACE_ERROR_RETURN (( + LM_ERROR, ACE_TEXT ("(%N:%l) AST_Union::") ACE_TEXT ("compute_default_value - ") - ACE_TEXT ("Bad case label value\n")), - -1); + ACE_TEXT ("Bad case label value\n") + ), + -1 + ); } switch (expr->ev ()->et) @@ -823,8 +787,6 @@ AST_Union::compute_default_value (void) } // if label_Kind == label } // End of for loop going thru all labels. } // If valid union branch. - - si.next (); } // End of while scope iterator loop. // We have not aborted the inner loops which means we have found the @@ -857,9 +819,9 @@ AST_Union::compute_default_index (void) if (this->nmembers () > 0) { // Instantiate a scope iterator. - UTL_ScopeActiveIterator si (this, - UTL_Scope::IK_decls); - 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 (); @@ -868,13 +830,11 @@ AST_Union::compute_default_index (void) { ub = AST_UnionBranch::narrow_from_decl (d); - for (unsigned long j = 0; - j < ub->label_list_length (); - ++j) + for (unsigned long j = 0; j < ub->label_list_length (); ++j) { // Check if we are printing the default case. - if (ub->label (j)->label_kind () - == AST_UnionLabel::UL_default) + AST_UnionLabel::UnionLabel ulk = ub->label ()->label_kind (); + if (ulk == AST_UnionLabel::UL_default) { // Zero based indexing. this->default_index_ = i; @@ -884,10 +844,8 @@ AST_Union::compute_default_index (void) // TAO's Typecode class keeps only a member count (not // a label count) so this increment has been moved // out of the inner loop. - i++; + ++i; } - - si.next (); } } diff --git a/TAO/TAO_IDL/ast/ast_union_branch.cpp b/TAO/TAO_IDL/ast/ast_union_branch.cpp index 61309c2bdbb..a8f4a10a3eb 100644 --- a/TAO/TAO_IDL/ast/ast_union_branch.cpp +++ b/TAO/TAO_IDL/ast/ast_union_branch.cpp @@ -125,9 +125,10 @@ AST_UnionLabel * AST_UnionBranch::label (unsigned long index) { unsigned long i = 0; - UTL_LabellistActiveIterator iter (this->pd_ll); - for (; !iter.is_done (); iter.next ()) + for (UTL_LabellistActiveIterator iter (this->pd_ll); + !iter.is_done (); + iter.next ()) { if (i == index) { diff --git a/TAO/TAO_IDL/be/be_decl.cpp b/TAO/TAO_IDL/be/be_decl.cpp index f6f5e972f87..99411cd454a 100644 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ b/TAO/TAO_IDL/be/be_decl.cpp @@ -193,15 +193,14 @@ be_decl::compute_flat_name (void) else { long namelen = 0; - UTL_IdListActiveIterator *i = 0; long first = I_TRUE; long second = I_FALSE; + char *item_name = 0; // In the first loop, compute the total length. - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - while (!(i->is_done ())) + for (UTL_IdListActiveIterator i (this->name ()); + !i.is_done (); + i.next ()) { if (!first) { @@ -213,11 +212,12 @@ be_decl::compute_flat_name (void) } // Print the identifier. - namelen += ACE_OS::strlen (i->item ()->get_string ()); + item_name = i.item ()->get_string (); + namelen += ACE_OS::strlen (item_name); if (first) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (item_name, "") != 0) { // Does not start with a "". first = I_FALSE; @@ -227,12 +227,8 @@ be_decl::compute_flat_name (void) second = I_TRUE; } } - - i->next (); } - delete i; - ACE_NEW (this->flat_name_, char[namelen + 1]); @@ -240,10 +236,9 @@ be_decl::compute_flat_name (void) first = I_TRUE; second = I_FALSE; - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - while (!(i->is_done ())) + for (UTL_IdListActiveIterator j (this->name ()); + !j.is_done (); + j.next ()) { if (!first) { @@ -255,10 +250,12 @@ be_decl::compute_flat_name (void) } // Print the identifier. - ACE_OS::strcat (this->flat_name_, i->item ()->get_string ()); + item_name = j.item ()->get_string (); + ACE_OS::strcat (this->flat_name_, item_name); + if (first) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (item_name, "") != 0) { // Does not start with a "". first = I_FALSE; @@ -268,14 +265,8 @@ be_decl::compute_flat_name (void) second = I_TRUE; } } - - i->next (); } - - delete i; } - - return; } diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 6bde2a5978f..cab41afb47e 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -162,15 +162,14 @@ be_interface::compute_full_skel_name (const char *prefix, else { long namelen = ACE_OS::strlen (prefix); - UTL_IdListActiveIterator *i = 0; long first = I_TRUE; long second = I_FALSE; + char *item_name = 0; // In the first loop compute the total length. - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - while (!i->is_done ()) + for (UTL_IdListActiveIterator i (this->name ()); + !i.is_done (); + i.next ()) { if (!first) { @@ -182,12 +181,13 @@ be_interface::compute_full_skel_name (const char *prefix, } // Print the identifier. - namelen += ACE_OS::strlen (i->item ()->get_string ()); + item_name = i.item ()->get_string (); + namelen += ACE_OS::strlen (item_name); // Additional 4 for the POA_ characters. if (first) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (item_name, "") != 0) { // Does not start with a "". first = I_FALSE; @@ -197,12 +197,8 @@ be_interface::compute_full_skel_name (const char *prefix, second = I_TRUE; } } - - i->next (); } - delete i; - ACE_NEW (skelname, char [namelen+1]); skelname[0] = '\0'; @@ -210,10 +206,9 @@ be_interface::compute_full_skel_name (const char *prefix, second = I_FALSE; ACE_OS::strcat (skelname, prefix); - ACE_NEW (i, - UTL_IdListActiveIterator (this->name ())); - - while (!i->is_done ()) + for (UTL_IdListActiveIterator j (this->name ()); + !j.is_done (); + j.next ()) { if (!first) { @@ -225,11 +220,12 @@ be_interface::compute_full_skel_name (const char *prefix, } // Print the identifier. - ACE_OS::strcat (skelname, i->item ()->get_string ()); + item_name = j.item ()->get_string (); + ACE_OS::strcat (skelname, item_name); if (first) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (item_name, "") != 0) { // Does not start with a "". first = I_FALSE; @@ -239,11 +235,7 @@ be_interface::compute_full_skel_name (const char *prefix, second = I_TRUE; } } - - i->next (); } - - delete i; } } @@ -1288,6 +1280,7 @@ be_interface::gen_optable_entries (const char *full_skeleton_name, { int lookup_strategy = be_global->lookup_strategy (); + if (lookup_strategy == BE_GlobalData::TAO_DYNAMIC_HASH) { for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); @@ -1546,9 +1539,9 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & int found = 0; // Initialize an iterator to search the queue for duplicates. - ACE_Unbounded_Queue_Iterator<be_interface*> q_iter (queue); - - while (!q_iter.done ()) + for (ACE_Unbounded_Queue_Iterator<be_interface*> q_iter (queue); + !q_iter.done (); + (void) q_iter.advance ()) { // Queue element. be_interface **temp; @@ -1564,14 +1557,14 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & { break; } - - (void) q_iter.advance (); } // Initialize an iterator to search the del_queue for duplicates. - ACE_Unbounded_Queue_Iterator<be_interface*> del_q_iter (del_queue); - - while (!found && !del_q_iter.done ()) + for (ACE_Unbounded_Queue_Iterator<be_interface*> del_q_iter ( + del_queue + ); + !found && !del_q_iter.done (); + (void) del_q_iter.advance ()) { // Queue element. be_interface **temp; @@ -1589,8 +1582,6 @@ be_interface::traverse_inheritance_graph (TAO_IDL_Inheritance_Hierarchy_Worker & { break; } - - (void) del_q_iter.advance (); } if (!found) diff --git a/TAO/TAO_IDL/be/be_interface_strategy.cpp b/TAO/TAO_IDL/be/be_interface_strategy.cpp index ade7bd7a2f1..20bbbd231b8 100644 --- a/TAO/TAO_IDL/be/be_interface_strategy.cpp +++ b/TAO/TAO_IDL/be/be_interface_strategy.cpp @@ -89,16 +89,16 @@ be_interface_strategy::compute_coll_names (int type, delete [] this->local_coll_name_; } - static const char *collocated_names[] = { "_tao_thru_poa_collocated_", - "_tao_direct_collocated_" }; + static const char *collocated_names[] = {"_tao_thru_poa_collocated_", + "_tao_direct_collocated_"}; static const char *poa = "POA_"; // Reserve enough room for the "POA_" prefix, the "_tao_collocated_" // prefix and the local name and the (optional) "::" const char *collocated = collocated_names[type]; int name_len = ACE_OS::strlen (collocated) - + ACE_OS::strlen (poa) - + 1; + + ACE_OS::strlen (poa) + + 1; if (prefix) { @@ -110,45 +110,39 @@ be_interface_strategy::compute_coll_names (int type, name_len += ACE_OS::strlen (suffix); } - UTL_IdListActiveIterator *i = 0; - ACE_NEW (i, - UTL_IdListActiveIterator (node_->name ())); - - while (!i->is_done ()) + for (UTL_IdListActiveIterator i (this->node_->name ()); + !i.is_done (); + i.next ()) { // Reserve 2 characters for "::". - name_len += ACE_OS::strlen (i->item ()->get_string ()) + 2; - i->next (); + name_len += ACE_OS::strlen (i.item ()->get_string ()) + 2; } - delete i; - ACE_NEW (this->full_coll_name_, char[name_len + 1]); // Null terminate the string. this->full_coll_name_[0] = 0; - // Iterate again. - ACE_NEW (i, - UTL_IdListActiveIterator (node_->name ())); - // Only the first component get the "POA_" preffix. int poa_added = 0; - while (!i->is_done ()) + // Iterate again. + // Must advance the iterator explicitly inside the loop. + for (UTL_IdListActiveIterator j (this->node_->name ()); + !j.is_done ();) { - const char *item = i->item ()->get_string (); + const char *item = j.item ()->get_string (); // Increase right away, so we can test for the final component // in the loop. - i->next (); + j.next (); // We add the POA_ preffix only if the first component is not // the global scope... if (ACE_OS::strcmp (item, "") != 0) { - if (!i->is_done ()) + if (!j.is_done ()) { // We only add the POA_ preffix if there are more than // two components in the name, in other words, if the @@ -180,12 +174,11 @@ be_interface_strategy::compute_coll_names (int type, } } - delete i; - // Compute the local name for the collocated class. + char *local_name = this->node_->AST_Interface::local_name ()->get_string (); int local_len = ACE_OS::strlen (collocated) - + ACE_OS::strlen (node_->AST_Interface::local_name ()->get_string ()) - + 1; + + ACE_OS::strlen (local_name) + + 1; if (prefix) { local_len += ACE_OS::strlen (prefix); diff --git a/TAO/TAO_IDL/be/be_operation.cpp b/TAO/TAO_IDL/be/be_operation.cpp index 7f9bc10b97c..bcd210104c9 100644 --- a/TAO/TAO_IDL/be/be_operation.cpp +++ b/TAO/TAO_IDL/be/be_operation.cpp @@ -95,6 +95,7 @@ be_operation::compute_size_type (void) // Get the next AST decl node AST_Decl *d = si.item (); be_decl *bd = be_decl::narrow_from_decl (d); + if (bd != 0) { // Our sizetype depends on the sizetype of our members. Although diff --git a/TAO/TAO_IDL/be/be_structure.cpp b/TAO/TAO_IDL/be/be_structure.cpp index d5505f47049..02d193c2380 100644 --- a/TAO/TAO_IDL/be/be_structure.cpp +++ b/TAO/TAO_IDL/be/be_structure.cpp @@ -648,7 +648,6 @@ be_structure::gen_out_impl (char *, ci->decr_indent (); *ci << "}\n\n"; - return 0; } @@ -663,6 +662,7 @@ be_structure::compute_size_type (void) // Get the next AST decl node. AST_Decl *d = si.item (); be_decl *bd = be_decl::narrow_from_decl (d); + if (bd != 0) { // Our sizetype depends on the sizetype of our diff --git a/TAO/TAO_IDL/be/be_sunsoft.cpp b/TAO/TAO_IDL/be/be_sunsoft.cpp index 643d83af2cc..0364348c8ce 100644 --- a/TAO/TAO_IDL/be/be_sunsoft.cpp +++ b/TAO/TAO_IDL/be/be_sunsoft.cpp @@ -30,13 +30,9 @@ TAO_SunSoft_OutStream::print (UTL_IdList *idl) { long first = I_TRUE; long second = I_FALSE; + Identifier *id = 0; - UTL_IdListActiveIterator *i = 0; - ACE_NEW_RETURN (i, - UTL_IdListActiveIterator (idl), - *this); - - while (!i->is_done ()) + for (UTL_IdListActiveIterator i (idl); !i.is_done (); i.next ()) { if (!first) { @@ -48,11 +44,12 @@ TAO_SunSoft_OutStream::print (UTL_IdList *idl) } // Print the identifier. - *this << i->item (); + id = i.item (); + *this << id; if (first) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (id->get_string (), "") != 0) { // Does not start with a "". first = I_FALSE; @@ -62,9 +59,7 @@ TAO_SunSoft_OutStream::print (UTL_IdList *idl) second = I_TRUE; } } - - i->next (); - } + } return *this; } diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp index c55688623ff..d9a2d2461b1 100644 --- a/TAO/TAO_IDL/be/be_union.cpp +++ b/TAO/TAO_IDL/be/be_union.cpp @@ -668,7 +668,6 @@ be_union::gen_out_impl (char *, ci->decr_indent (); *ci << "}\n\n"; - return 0; } @@ -683,6 +682,7 @@ be_union::compute_size_type (void) // Get the next AST decl node. AST_Decl *d = si.item (); be_decl *bd = be_decl::narrow_from_decl (d); + if (bd != 0) { // Our sizetype depends on the sizetype of our members. Although 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 712e6721b4b..38dd4ebdbaf 100644 --- a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp +++ b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp @@ -31,10 +31,12 @@ int be_visitor_amh_pre_proc::visit_root (be_root *node) { if (this->visit_scope (node) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_pre_proc::" - "visit_root - visit scope failed\n"), - -1); + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_pre_proc::" + "visit_root - visit scope failed\n"), + -1); + } return 0; } @@ -45,10 +47,12 @@ int be_visitor_amh_pre_proc::visit_module (be_module *node) { if (!node->imported () && this->visit_scope (node) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_pre_proc::" - "visit_module - visit scope failed\n"), - -1); + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_pre_proc::" + "visit_module - visit scope failed\n"), + -1); + } return 0; } @@ -60,7 +64,9 @@ be_visitor_amh_pre_proc::visit_interface (be_interface *node) { // Do not generate AMH classes for any sort of implied IDL. if (node->original_interface () != 0) - return 0; + { + return 0; + } // don't generate AMH classes for imported or local interfaces // either... @@ -69,16 +75,20 @@ be_visitor_amh_pre_proc::visit_interface (be_interface *node) // because the (imported-AMH-) node could be needed to generate a // non-imported, AMH node, for example, for a derived interface. if (node->imported () || node->is_local ()) - return 0; + { + return 0; + } AST_Module *module = AST_Module::narrow_from_scope (node->defined_in ()); if (module == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_pre_proc::" - "visit_interface - module is null\n"), - -1); + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_pre_proc::" + "visit_interface - module is null\n"), + -1); + } // Create the exception holder, it needs to go before the response // handler, because the response handler uses an exception holder as @@ -93,7 +103,9 @@ be_visitor_amh_pre_proc::visit_interface (be_interface *node) // Create the ResponseHandler class be_interface *response_handler = - this->create_response_handler (node, excep_holder); + this->create_response_handler (node, + excep_holder); + if (response_handler == 0) { ACE_ERROR_RETURN ((LM_ERROR, @@ -105,22 +117,26 @@ be_visitor_amh_pre_proc::visit_interface (be_interface *node) response_handler->set_defined_in (node->defined_in ()); // Insert the response handler after the node. - module->be_add_interface (response_handler, node); + module->be_add_interface (response_handler, + node); // Remember from whom we were cloned response_handler->original_interface (node); // Add the ExceptionHolder after the ResponseHandler, seems to // generate the code in the right order.... - module->be_add_interface (excep_holder, node); + module->be_add_interface (excep_holder, + node); return 0; } be_interface * -be_visitor_amh_pre_proc::create_response_handler (be_interface *node, - be_valuetype *exception_holder) +be_visitor_amh_pre_proc::create_response_handler ( + be_interface *node, + be_valuetype *exception_holder + ) { // Generate 'AMH_InterfaceResponseHandler' ACE_CString class_name; @@ -139,14 +155,16 @@ be_visitor_amh_pre_proc::create_response_handler (be_interface *node, // the inherited classes in the original interface, change their // names and then use the symbol table to look up the // AMH-response-handler nodes. - be_interface *response_handler = - new be_interface (amh_name, // name - 0, // list of inherited - 0, // number of inherited - 0, // list of ancestors - 0, // number of ancestors - 1, // local - 0); // non-abstract + be_interface *response_handler = 0; + ACE_NEW_RETURN (response_handler, + be_interface (amh_name, // name + 0, // list of inherited + 0, // number of inherited + 0, // list of ancestors + 0, // number of ancestors + 1, // local + 0), // non-abstract + 0); response_handler->set_name (amh_name); response_handler->set_defined_in (node->defined_in ()); @@ -176,6 +194,7 @@ be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node, si.next ()) { AST_Decl *d = si.item (); + if (!d) { ACE_ERROR_RETURN ((LM_ERROR, @@ -206,14 +225,17 @@ be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node, } } } + return 1; } int -be_visitor_amh_pre_proc::create_response_handler_operation (be_operation *node, - be_interface *response_handler, - be_valuetype *exception_holder) +be_visitor_amh_pre_proc::create_response_handler_operation ( + be_operation *node, + be_interface *response_handler, + be_valuetype *exception_holder + ) { if (!node) { @@ -230,9 +252,13 @@ be_visitor_amh_pre_proc::create_response_handler_operation (be_operation *node, } if (this->add_normal_reply (node, response_handler) == -1) - return -1; + { + return -1; + } - return this->add_exception_reply (node, response_handler, exception_holder); + return this->add_exception_reply (node, + response_handler, + exception_holder); } int @@ -240,26 +266,54 @@ be_visitor_amh_pre_proc::add_exception_reply (be_operation *node, be_interface *response_handler, be_valuetype *exception_holder) { + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + // Create the return type, which 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 = 0; + ACE_NEW_RETURN (rt, + be_predefined_type (AST_PredefinedType::PT_void, + sn), + -1); // Create the name... - UTL_ScopedName *operation_name = - node->compute_name ("", "_excep"); + UTL_ScopedName *operation_name = node->compute_name ("", + "_excep"); - be_operation *node_excep; + be_operation *node_excep = 0; ACE_NEW_RETURN (node_excep, - be_operation (rt, AST_Operation::OP_noflags, - operation_name, 1, 0), + be_operation (rt, + AST_Operation::OP_noflags, + operation_name, + 1, + 0), + -1); + + ACE_NEW_RETURN (id, + Identifier ("holder"), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + + be_argument *argument = 0; + ACE_NEW_RETURN (argument, + be_argument (AST_Argument::dir_IN, + exception_holder, + sn), -1); - be_argument *argument = - new be_argument (AST_Argument::dir_IN, - exception_holder, - new UTL_ScopedName (new Identifier ("holder"), 0)); argument->set_defined_in (node_excep); node_excep->add_argument_to_scope (argument); @@ -273,38 +327,75 @@ int be_visitor_amh_pre_proc::add_normal_reply (be_operation *node, be_interface *response_handler) { + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + // Create the return type, which 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 = 0; + ACE_NEW_RETURN (rt, + be_predefined_type (AST_PredefinedType::PT_void, + sn), + -1); - ACE_CString original_op_name (node->name ()->last_component ()->get_string ()); + ACE_CString original_op_name ( + node->name ()->last_component ()->get_string () + ); + + UTL_ScopedName *op_name = + ACE_static_cast (UTL_ScopedName *, + response_handler->name ()->copy ()); - UTL_ScopedName *op_name = - ACE_static_cast (UTL_ScopedName *, response_handler->name ()-> copy ()); - op_name->nconc (new UTL_ScopedName (new Identifier (original_op_name.rep ()), - 0)); + ACE_NEW_RETURN (id, + Identifier (original_op_name.rep ()), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + + op_name->nconc (sn); // Create the operation - be_operation *operation = new be_operation (rt, - AST_Operation::OP_noflags, - op_name, - 1, - 0); + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (rt, + AST_Operation::OP_noflags, + op_name, + 1, + 0), + -1); + operation->set_name (op_name); // If return type is non-void add it as first argument if (!node->void_return_type ()) { + ACE_NEW_RETURN (id, + Identifier ("return_value"), + -1); + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); // Create the argument - be_argument *arg = - new be_argument (AST_Argument::dir_IN, - node->return_type (), - new UTL_ScopedName (new Identifier ("return_value"), - 0)); + be_argument *arg = 0; + ACE_NEW_RETURN (arg, + be_argument (AST_Argument::dir_IN, + node->return_type (), + sn), + -1); // Add the response handler to the argument list operation->add_argument_to_scope (arg); @@ -335,9 +426,12 @@ be_visitor_amh_pre_proc::add_normal_reply (be_operation *node, original_arg->direction () == AST_Argument::dir_OUT) { // Create the argument - be_argument *arg = new be_argument (AST_Argument::dir_IN, - original_arg->field_type (), - original_arg->name ()); + be_argument *arg = 0; + ACE_NEW_RETURN (arg, + be_argument (AST_Argument::dir_IN, + original_arg->field_type (), + original_arg->name ()), + -1); operation->add_argument_to_scope (arg); } @@ -364,14 +458,23 @@ be_visitor_amh_pre_proc::visit_operation (be_operation *node) // policy. // We do nothing for oneways! if (node->flags () == AST_Operation::OP_oneway) - return 0; + { + return 0; + } // Set the proper strategy - be_operation_strategy *old_strategy = - node->set_strategy (new be_operation_amh_strategy (node)); + be_operation_amh_strategy *strategy = 0; + ACE_NEW_RETURN (strategy, + be_operation_amh_strategy (node), + -1); + + be_operation_strategy *old_strategy = node->set_strategy (strategy); if (old_strategy) - delete old_strategy; + { + delete old_strategy; + old_strategy = 0; + } return 0; } @@ -381,34 +484,47 @@ int be_visitor_amh_pre_proc::visit_attribute (be_attribute *node) { // Temporarily generate the set operation. - be_operation *set_operation = - this->generate_set_operation (node); + be_operation *set_operation = this->generate_set_operation (node); this->visit_operation (set_operation); - // Retrieve the strategy set by the visit operation + // Retrieve the strategy set by the visit operation. + be_operation_default_strategy *default_strategy = 0; + ACE_NEW_RETURN (default_strategy, + be_operation_default_strategy (set_operation), + -1); + be_operation_strategy *set_operation_strategy = - set_operation->set_strategy ( - new be_operation_default_strategy (set_operation) - ); + set_operation->set_strategy (default_strategy); - // Assign it to the attribute as set_operation strategy + // Assign it to the attribute as set_operation strategy. if (set_operation_strategy) - delete node->set_set_strategy (set_operation_strategy); + { + be_operation_strategy *sos = + node->set_set_strategy (set_operation_strategy); + delete sos; + sos = 0; + } // Temporerily generate the get operation. - be_operation *get_operation = - this->generate_get_operation (node); + be_operation *get_operation = this->generate_get_operation (node); this->visit_operation (get_operation); + ACE_NEW_RETURN (default_strategy, + be_operation_default_strategy (get_operation), + -1); + be_operation_strategy *get_operation_strategy = - get_operation->set_strategy ( - new be_operation_default_strategy (get_operation) - ); + get_operation->set_strategy (default_strategy); if (get_operation_strategy) - delete node->set_get_strategy (get_operation_strategy); + { + be_operation_strategy *gos = + node->set_get_strategy (get_operation_strategy); + delete gos; + gos = 0; + } return 0; @@ -428,12 +544,14 @@ be_visitor_amh_pre_proc::visit_scope (be_scope *node) !si.is_done (); si.next ()) { - number_of_elements++; + ++number_of_elements; } } AST_Decl **elements; - ACE_NEW_RETURN (elements, AST_Decl *[number_of_elements], -1); + ACE_NEW_RETURN (elements, + AST_Decl *[number_of_elements], + -1); { int position = 0; @@ -453,12 +571,14 @@ be_visitor_amh_pre_proc::visit_scope (be_scope *node) while (elem_number < number_of_elements) { AST_Decl *d = elements[elem_number]; + if (!d) { delete [] elements; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); + "bad node in this scope\n"), + -1); } @@ -471,7 +591,7 @@ be_visitor_amh_pre_proc::visit_scope (be_scope *node) // set the node to be visited this->ctx_->node (bd); - elem_number++; + ++elem_number; // Send the visitor. @@ -480,10 +600,12 @@ be_visitor_amh_pre_proc::visit_scope (be_scope *node) delete [] elements; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } } // end of while loop + delete [] elements; } // end of if @@ -493,45 +615,79 @@ be_visitor_amh_pre_proc::visit_scope (be_scope *node) be_valuetype * be_visitor_amh_pre_proc::create_exception_holder (be_interface *node) { + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("Messaging"), + 0); // Create a virtual module named "Messaging" and a valuetype // "ExceptionHolder" from which we inherit. - UTL_ScopedName *inherit_name = - new UTL_ScopedName (new Identifier ("Messaging"), - 0); + UTL_ScopedName *inherit_name = 0; + ACE_NEW_RETURN (inherit_name, + UTL_ScopedName (id, + 0), + 0); + + ACE_NEW_RETURN (id, + Identifier ("ExceptionHolder"), + 0); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); + + inherit_name->nconc (sn); + + be_valuetype *inherit_vt = 0; + ACE_NEW_RETURN (inherit_vt, + be_valuetype (inherit_name, + 0, + 0, + 0), + 0); - inherit_name->nconc (new UTL_ScopedName (new Identifier ("ExceptionHolder"), - 0)); - - be_valuetype *inherit_vt = new be_valuetype (inherit_name, - 0, - 0, - 0); inherit_vt->set_name (inherit_name); - // be_module *msg = new be_module (new UTL_ScopedName (new Identifier ("Messaging"), - // 0), - // 0); + ACE_NEW_RETURN (id, + Identifier ("Messaging"), + 0); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); - be_module *msg = - new be_module (new UTL_ScopedName (new Identifier ("Messaging"), - 0)); + be_module *msg = 0; + ACE_NEW_RETURN (msg, + be_module (sn), + 0); // Notice the valuetype "ExceptionHolder" that it is defined in the - // "Messaging" module + // "Messaging" module. inherit_vt->set_defined_in (msg); - UTL_ScopedName *excep_holder_name = - node->compute_name ("AMH_", "ExceptionHolder"); + UTL_ScopedName *excep_holder_name = node->compute_name ("AMH_", + "ExceptionHolder"); + + AST_Interface **p_intf = 0; + ACE_NEW_RETURN (p_intf, + AST_Interface*[1], + 0); + + p_intf[0] = ACE_static_cast (AST_Interface *, + inherit_vt); + + be_valuetype *excep_holder = 0; + ACE_NEW_RETURN (excep_holder, + be_valuetype (excep_holder_name, // name + p_intf, // list of inherited + 1, // number of inherited + 0), // set abstract + 0); - AST_Interface **p_intf = new AST_Interface*[1]; - p_intf[0] = ACE_static_cast (AST_Interface *, inherit_vt); - - be_valuetype *excep_holder = - new be_valuetype (excep_holder_name, // name - p_intf, // list of inherited - 1, // number of inherited - 0); // set abstract excep_holder->set_name (excep_holder_name); // Now our customized valuetype is created, we have to @@ -559,8 +715,10 @@ be_visitor_amh_pre_proc::create_exception_holder (be_interface *node) { AST_Attribute *attribute = AST_Attribute::narrow_from_decl (d); - if (!attribute) - return 0; + if (attribute == 0) + { + return 0; + } this->create_raise_operation (op, excep_holder, @@ -588,30 +746,49 @@ be_visitor_amh_pre_proc::create_exception_holder (be_interface *node) int -be_visitor_amh_pre_proc::create_raise_operation (be_decl *node, - be_valuetype *excep_holder, - Operation_Kind operation_kind) +be_visitor_amh_pre_proc::create_raise_operation ( + be_decl *node, + be_valuetype *excep_holder, + Operation_Kind operation_kind + ) { + Identifier *id = 0; + UTL_ScopedName *sn = 0; be_operation *orig_op = 0; + if (operation_kind == NORMAL) { orig_op = be_operation::narrow_from_decl (node); + if (orig_op) { // @@ Mayur, we do want to generate code for oneways! This is // needed to support reliable oneways with the SYNC_WITH_TARGET // policy, the user can raise system exceptions here. if (orig_op->flags () == AST_Operation::OP_oneway) - // We do nothing for oneways! - return 0; + { + // We do nothing for oneways! + return 0; + } } } // Create the return type, which is "void" - be_predefined_type *rt = - new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName (new Identifier ("void"), - 0)); + + ACE_NEW_RETURN (id, + Identifier ("void"), + -1); + + 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); // Name the operation properly UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *, @@ -630,14 +807,26 @@ be_visitor_amh_pre_proc::create_raise_operation (be_decl *node, new_local_name += node->name ()->last_component ()->get_string (); - op_name->nconc (new UTL_ScopedName (new Identifier (new_local_name.rep ()), - 0)); + ACE_NEW_RETURN (id, + Identifier (new_local_name.rep ()), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + + op_name->nconc (sn); + + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (rt, + AST_Operation::OP_noflags, + op_name, + 1, + 0), + -1); - be_operation *operation = new be_operation (rt, - AST_Operation::OP_noflags, - op_name, - 1, - 0); operation->set_name (op_name); operation->set_defined_in (excep_holder); @@ -654,15 +843,19 @@ be_visitor_amh_pre_proc::create_raise_operation (be_decl *node, } } - // Set the proper strategy + // Set the proper strategy. + be_operation_ami_exception_holder_raise_strategy *ehrs = 0; + ACE_NEW_RETURN (ehrs, + be_operation_ami_exception_holder_raise_strategy (operation), + -1); + be_operation_strategy *old_strategy = - operation->set_strategy ( - new be_operation_ami_exception_holder_raise_strategy (operation) - ); + operation->set_strategy (ehrs); if (old_strategy) { delete old_strategy; + old_strategy = 0; } // After having generated the operation we insert it into the @@ -700,12 +893,15 @@ be_visitor_amh_pre_proc::generate_get_operation (be_attribute *node) node->name ()-> copy ()); get_name->last_component ()->replace_string (new_op_name.rep ()); - be_operation *operation = - new be_operation (node->field_type (), - AST_Operation::OP_noflags, - get_name, - 1, - 0); + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (node->field_type (), + AST_Operation::OP_noflags, + get_name, + 1, + 0), + 0); + operation->set_name (get_name); operation->set_defined_in (node->defined_in ()); @@ -715,33 +911,52 @@ be_visitor_amh_pre_proc::generate_get_operation (be_attribute *node) be_operation * be_visitor_amh_pre_proc::generate_set_operation (be_attribute *node) { - ACE_CString original_op_name ( - node->name ()->last_component ()->get_string () - ); + ACE_CString original_op_name (node->name ()->last_component ()->get_string ()); ACE_CString new_op_name = ACE_CString ("set_") + original_op_name; UTL_ScopedName *set_name = ACE_static_cast (UTL_ScopedName *, node->name ()-> copy ()); set_name->last_component ()->replace_string (new_op_name.rep ()); - // the return type is "void" - be_predefined_type *rt = - new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName (new Identifier ("void"), - 0)); + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + 0); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); + + // The return type is "void". + be_predefined_type *rt = 0; + ACE_NEW_RETURN (rt, + be_predefined_type (AST_PredefinedType::PT_void, + sn), + 0); // argument type is the same as the attribute type - be_argument *arg = new be_argument (AST_Argument::dir_IN, - node->field_type (), - set_name); + be_argument *arg = 0; + ACE_NEW_RETURN (arg, + be_argument (AST_Argument::dir_IN, + node->field_type (), + set_name), + 0); + arg->set_name (node->name ()); // create the operation - be_operation *operation = new be_operation (rt, - AST_Operation::OP_noflags, - set_name, - 0, - 0); + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (rt, + AST_Operation::OP_noflags, + set_name, + 0, + 0), + 0); + operation->set_name (set_name); operation->set_defined_in (node->defined_in ()); operation->add_argument_to_scope (arg); 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 fb8328f4f99..6d8e4b19a75 100644 --- a/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp +++ b/TAO/TAO_IDL/be/be_visitor_ami_pre_proc.cpp @@ -53,6 +53,7 @@ be_visitor_ami_pre_proc::visit_root (be_root *node) "visit scope failed\n"), -1); } + return 0; } @@ -70,6 +71,7 @@ be_visitor_ami_pre_proc::visit_module (be_module *node) -1); } } + return 0; } @@ -78,7 +80,9 @@ be_visitor_ami_pre_proc::visit_interface (be_interface *node) { if (!node->imported () && !node->is_local ()) { - AST_Module *module = AST_Module::narrow_from_scope (node->defined_in ()); + AST_Module *module = + AST_Module::narrow_from_scope (node->defined_in ()); + if (!module) { ACE_ERROR_RETURN ((LM_ERROR, @@ -113,12 +117,19 @@ be_visitor_ami_pre_proc::visit_interface (be_interface *node) -1); } - // Set the proper strategy - be_interface_strategy *old_strategy = - node->set_strategy (new be_interface_ami_strategy (node, - reply_handler)); + // Set the proper strategy. + be_interface_ami_strategy *bias = 0; + ACE_NEW_RETURN (bias, + be_interface_ami_strategy (node, + reply_handler), + -1); + be_interface_strategy *old_strategy = node->set_strategy (bias); + if (old_strategy) - delete old_strategy; + { + delete old_strategy; + old_strategy = 0; + } if (excep_holder) { @@ -128,13 +139,25 @@ be_visitor_ami_pre_proc::visit_interface (be_interface *node) // ami handler, which is the way we want to have it. module->be_add_interface (excep_holder, node); module->set_has_nested_valuetype (); - // Remember from whom we were cloned + // Remember from whom we were cloned. excep_holder->original_interface (node); - // Set the strategy + + // Set the strategy. + be_interface_ami_exception_holder_strategy *biaehs = 0; + ACE_NEW_RETURN (biaehs, + be_interface_ami_exception_holder_strategy ( + excep_holder + ), + -1); + be_interface_strategy *old_strategy = - excep_holder->set_strategy (new be_interface_ami_exception_holder_strategy (excep_holder)); + excep_holder->set_strategy (biaehs); + if (old_strategy) - delete old_strategy; + { + delete old_strategy; + old_strategy = 0; + } } else { @@ -163,8 +186,10 @@ int be_visitor_ami_pre_proc::visit_operation (be_operation *node) { if (node->flags () == AST_Operation::OP_oneway) - // We do nothing for oneways! - return 0; + { + // We do nothing for oneways! + return 0; + } be_operation *sendc_marshaling = this->create_sendc_operation (node, @@ -185,12 +210,20 @@ be_visitor_ami_pre_proc::visit_operation (be_operation *node) // Set the proper strategy, and store the specialized // marshaling and arguments operations in it. - be_operation_strategy *old_strategy = - node->set_strategy (new be_operation_ami_sendc_strategy (node, - sendc_marshaling, - sendc_arguments)); + be_operation_ami_sendc_strategy * boass= 0; + ACE_NEW_RETURN (boass, + be_operation_ami_sendc_strategy (node, + sendc_marshaling, + sendc_arguments), + -1); + + be_operation_strategy *old_strategy = node->set_strategy (boass); + if (old_strategy) - delete old_strategy; + { + delete old_strategy; + old_strategy = 0; + } } return 0; @@ -206,13 +239,23 @@ be_visitor_ami_pre_proc::visit_attribute (be_attribute *node) this->visit_operation (set_operation); - // Retrieve the strategy set by the visit operation + // Retrieve the strategy set by the visit operation. + be_operation_default_strategy *bods = 0; + ACE_NEW_RETURN (bods, + be_operation_default_strategy (set_operation), + -1); + be_operation_strategy *set_operation_strategy = - set_operation->set_strategy (new be_operation_default_strategy (set_operation)); + set_operation->set_strategy (bods); - // Assign it to the attribute as set_operation strategy + // Assign it to the attribute as set_operation strategy. if (set_operation_strategy) - delete node->set_set_strategy (set_operation_strategy); + { + be_operation_strategy *bos = + node->set_set_strategy (set_operation_strategy); + delete bos; + bos = 0; + } // Temporerily generate the get operation. be_operation *get_operation = @@ -220,12 +263,20 @@ be_visitor_ami_pre_proc::visit_attribute (be_attribute *node) this->visit_operation (get_operation); + ACE_NEW_RETURN (bods, + be_operation_default_strategy (get_operation), + -1); + be_operation_strategy *get_operation_strategy = - get_operation->set_strategy (new be_operation_default_strategy (get_operation)); + get_operation->set_strategy (bods); if (get_operation_strategy) - delete node->set_get_strategy (get_operation_strategy); - + { + be_operation_strategy *bos = + node->set_get_strategy (get_operation_strategy); + delete bos; + bos = 0; + } return 0; } @@ -238,23 +289,54 @@ be_visitor_ami_pre_proc::visit_attribute (be_attribute *node) be_valuetype * be_visitor_ami_pre_proc::create_exception_holder (be_interface *node) { + Identifier *id = 0; + ACE_NEW_RETURN (id, + Identifier ("Messaging"), + 0); + // Create a virtual module named "Messaging" and an valuetype "ExceptionHolder" // from which we inherit. - UTL_ScopedName *inherit_name = - new UTL_ScopedName (new Identifier ("Messaging"), - 0); - - inherit_name->nconc (new UTL_ScopedName (new Identifier ("ExceptionHolder"), - 0)); + UTL_ScopedName *inherit_name = 0; + ACE_NEW_RETURN (inherit_name, + UTL_ScopedName (id, + 0), + 0); + + ACE_NEW_RETURN (id, + Identifier ("ExceptionHolder"), + 0); + + UTL_ScopedName *sn = 0; + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); + + inherit_name->nconc (sn); + + be_valuetype *inherit_vt = 0; + ACE_NEW_RETURN (inherit_vt, + be_valuetype (inherit_name, + 0, + 0, + 0), + 0); - be_valuetype *inherit_vt = new be_valuetype (inherit_name, - 0, - 0, - 0); inherit_vt->set_name (inherit_name); - be_module *msg = new be_module (new UTL_ScopedName (new Identifier ("Messaging"), - 0)); + ACE_NEW_RETURN (id, + Identifier ("Messaging"), + 0); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); + + be_module *msg = 0; + ACE_NEW_RETURN (msg, + be_module (sn), + 0); // Notice the valuetype "ExceptionHolder" that it is defined in the // "Messaging" module @@ -267,16 +349,28 @@ be_visitor_ami_pre_proc::create_exception_holder (be_interface *node) node->name ()->last_component ()->get_string(), "ExceptionHolder"); - UTL_ScopedName *excep_holder_name = ACE_static_cast (UTL_ScopedName *, node->name ()->copy ()); - excep_holder_name->last_component ()->replace_string (excep_holder_local_name.rep ()); + UTL_ScopedName *excep_holder_name = + ACE_static_cast (UTL_ScopedName *, node->name ()->copy ()); + excep_holder_name->last_component ()->replace_string ( + excep_holder_local_name.rep () + ); - AST_Interface_ptr *p_intf = new AST_Interface_ptr[1]; - p_intf[0] = ACE_static_cast (AST_Interface *, inherit_vt); + AST_Interface_ptr *p_intf = 0; + ACE_NEW_RETURN (p_intf, + AST_Interface_ptr[1], + 0); + + p_intf[0] = ACE_static_cast (AST_Interface *, + inherit_vt); + + be_valuetype *excep_holder = 0; + ACE_NEW_RETURN (excep_holder, + be_valuetype (excep_holder_name, // name + p_intf, // list of inherited + 1, // number of inherited + 0), // set abstract + 0); - be_valuetype *excep_holder = new be_valuetype (excep_holder_name, // name - p_intf, // list of inherited - 1, // number of inherited - 0); // set abstract excep_holder->set_name (excep_holder_name); // Now our customized valuetype is created, we have to @@ -290,6 +384,7 @@ be_visitor_ami_pre_proc::create_exception_holder (be_interface *node) si.next ()) { AST_Decl *d = si.item (); + if (d == 0) { ACE_ERROR_RETURN ((LM_ERROR, @@ -305,7 +400,9 @@ be_visitor_ami_pre_proc::create_exception_holder (be_interface *node) AST_Attribute *attribute = AST_Attribute::narrow_from_decl (d); if (!attribute) - return 0; + { + return 0; + } this->create_raise_operation (op, excep_holder, @@ -336,53 +433,96 @@ be_interface * be_visitor_ami_pre_proc::create_reply_handler (be_interface *node, be_valuetype *excep_holder) { + Identifier *id = 0; + UTL_ScopedName *sn = 0; + // Create a virtual module named "Messaging" and an interface "ReplyHandler" // from which we inherit. - UTL_ScopedName *inherit_name = - new UTL_ScopedName (new Identifier ("Messaging"), - 0); - - inherit_name->nconc (new UTL_ScopedName (new Identifier ("ReplyHandler"), - 0)); - - be_interface *inherit_intf = new be_interface (inherit_name, - 0, // inherited interfaces - 0, // number of inherited interfaces - 0, // ancestors - 0, // number of ancestors - 0, // not local - 0); // not abstract + ACE_NEW_RETURN (id, + Identifier ("Messaging"), + 0); + + UTL_ScopedName *inherit_name = 0; + ACE_NEW_RETURN (inherit_name, + UTL_ScopedName (id, + 0), + 0); + + ACE_NEW_RETURN (id, + Identifier ("ReplyHandler"), + 0); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); + + inherit_name->nconc (sn); + + be_interface *inherit_intf = 0; + ACE_NEW_RETURN (inherit_intf, + be_interface (inherit_name, + 0, // inherited interfaces + 0, // number of inherited interfaces + 0, // ancestors + 0, // number of ancestors + 0, // not local + 0), // not abstract + 0); + inherit_intf->set_name (inherit_name); - be_module *msg = new be_module (new UTL_ScopedName (new Identifier ("Messaging"), - 0)); + ACE_NEW_RETURN (id, + Identifier ("Messaging"), + 0); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); + + be_module *msg = 0; + ACE_NEW_RETURN (msg, + be_module (sn), + 0); // Notice the interface "ReplyHandler" that it is defined in the - // "Messaging" module + // "Messaging" module. inherit_intf->set_defined_in (msg); - // Create the reply handler name + // Create the reply handler name. ACE_CString reply_handler_local_name; this->generate_name (reply_handler_local_name, "AMI_", node->name ()->last_component ()->get_string(), "Handler"); - UTL_ScopedName *reply_handler_name = ACE_static_cast (UTL_ScopedName *, node->name ()->copy ()); - reply_handler_name->last_component ()->replace_string (reply_handler_local_name.rep ()); - - AST_Interface_ptr *p_intf = new AST_Interface_ptr[1]; - p_intf[0] = ACE_static_cast (AST_Interface *, inherit_intf); + UTL_ScopedName *reply_handler_name = + ACE_static_cast (UTL_ScopedName *, node->name ()->copy ()); + reply_handler_name->last_component ()->replace_string ( + reply_handler_local_name.rep () + ); + + AST_Interface_ptr *p_intf = 0; + ACE_NEW_RETURN (p_intf, + AST_Interface_ptr[1], + 0); + + p_intf[0] = ACE_static_cast (AST_Interface *, + inherit_intf); + + be_interface *reply_handler = 0; + ACE_NEW_RETURN (reply_handler, + 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, // non-local + 0), // non-abstract + 0); - be_interface *reply_handler = - new 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, // non-local - 0); // non-abstract reply_handler->set_name (reply_handler_name); // Now our customized valuetype is created, we have to @@ -391,12 +531,14 @@ be_visitor_ami_pre_proc::create_reply_handler (be_interface *node, if (node->nmembers () > 0) { this->elem_number_ = 0; - // initialize an iterator to iterate thru our scope + // Initialize an iterator to iterate thru our scope. + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next ()) { AST_Decl *d = si.item (); + if (!d) { ACE_ERROR_RETURN ((LM_ERROR, @@ -410,8 +552,10 @@ be_visitor_ami_pre_proc::create_reply_handler (be_interface *node, { be_attribute *attribute = be_attribute::narrow_from_decl (d); - if (!attribute) - return 0; + if (attribute == 0) + { + return 0; + } be_operation *get_operation = this->generate_get_operation (attribute); @@ -444,7 +588,7 @@ be_visitor_ami_pre_proc::create_reply_handler (be_interface *node, this->create_reply_handler_operation (operation, reply_handler); - this->create_excep_operation (be_operation::narrow_from_decl (d), + this->create_excep_operation (operation, reply_handler, excep_holder); } @@ -457,53 +601,84 @@ be_visitor_ami_pre_proc::create_reply_handler (be_interface *node, int -be_visitor_ami_pre_proc::create_raise_operation (be_decl *node, - be_valuetype *excep_holder, - Operation_Kind operation_kind) +be_visitor_ami_pre_proc::create_raise_operation ( + be_decl *node, + be_valuetype *excep_holder, + Operation_Kind operation_kind + ) { be_operation *orig_op = 0; + if (operation_kind == NORMAL) { orig_op = be_operation::narrow_from_decl (node); + if (orig_op) { if (orig_op->flags () == AST_Operation::OP_oneway) - // We do nothing for oneways! - return 0; + { + // We do nothing for oneways! + return 0; + } } } + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + // Create the return type, which 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 = 0; + ACE_NEW_RETURN (rt, + be_predefined_type (AST_PredefinedType::PT_void, + sn), + -1); // Name the operation properly UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *, excep_holder->name ()-> copy ()); ACE_CString new_local_name ("raise_"); + if (operation_kind == SET_OPERATION) - new_local_name += "set_"; + { + new_local_name += "set_"; + } else if (operation_kind == GET_OPERATION) - new_local_name += "get_"; - new_local_name += node - ->name () - ->last_component () - ->get_string (); - - op_name->nconc (new UTL_ScopedName ( - new Identifier ( - new_local_name.rep ()), - 0)); - - be_operation *operation = new be_operation (rt, - AST_Operation::OP_noflags, - op_name, - 0, - 0); + { + new_local_name += "get_"; + } + + new_local_name += node->name ()->last_component ()->get_string (); + + ACE_NEW_RETURN (id, + Identifier (new_local_name.rep ()), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + + op_name->nconc (sn); + + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (rt, + AST_Operation::OP_noflags, + op_name, + 0, + 0), + -1); + operation->set_name (op_name); operation->set_defined_in (excep_holder); @@ -520,11 +695,19 @@ be_visitor_ami_pre_proc::create_raise_operation (be_decl *node, } } - // Set the proper strategy - be_operation_strategy *old_strategy = - operation->set_strategy (new be_operation_ami_exception_holder_raise_strategy (operation)); + // Set the proper strategy. + be_operation_ami_exception_holder_raise_strategy *boaehrs = 0; + ACE_NEW_RETURN (boaehrs, + be_operation_ami_exception_holder_raise_strategy (operation), + -1); + + be_operation_strategy *old_strategy = operation->set_strategy (boaehrs); + if (old_strategy) - delete old_strategy; + { + delete old_strategy; + old_strategy = 0; + } // After having generated the operation we insert it into the // exceptionholder valuetype. @@ -535,74 +718,107 @@ be_visitor_ami_pre_proc::create_raise_operation (be_decl *node, be_operation * be_visitor_ami_pre_proc::create_sendc_operation (be_operation *node, - int for_arguments) + int for_arguments) { if (node->flags () == AST_Operation::OP_oneway) - // We do nothing for oneways! - return 0; + { + // We do nothing for oneways! + return 0; + } + + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + 0); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); // Create the return type, which is "void" - be_predefined_type *rt = new be_predefined_type ( + be_predefined_type *rt = 0; + ACE_NEW_RETURN (rt, + be_predefined_type ( AST_PredefinedType::PT_void, - new UTL_ScopedName (new Identifier ("void"), - 0) - ); + sn), + 0); // Create the new name // Prepend "sendc_" to the name of the operation - ACE_CString original_op_name (node - ->name () - ->last_component () - ->get_string ()); + ACE_CString original_op_name ( + node->name ()->last_component ()->get_string () + ); ACE_CString new_op_name = ACE_CString ("sendc_") + original_op_name; - UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *, node->name ()-> copy ()); + UTL_ScopedName *op_name = + ACE_static_cast (UTL_ScopedName *, + node->name ()->copy ()); op_name->last_component ()->replace_string (new_op_name.rep ()); // Create the operation - be_operation * op = new be_operation (rt, - AST_Operation::OP_noflags, - op_name, - 0, - 0); + be_operation *op = 0; + ACE_NEW_RETURN (op, + be_operation (rt, + AST_Operation::OP_noflags, + op_name, + 0, + 0), + 0); // Create the first argument, which is a Reply Handler if (for_arguments) { // Create the field type - be_decl *parent = be_scope::narrow_from_scope (node->defined_in ())->decl (); + be_decl *parent = + be_scope::narrow_from_scope (node->defined_in ())->decl (); // Add the pre- and suffix ACE_CString excep_holder_name; this->generate_name (excep_holder_name, "AMI_", - parent - ->name () - ->last_component () - ->get_string (), + parent->name ()->last_component ()->get_string (), "Handler"); - UTL_ScopedName *field_name = ACE_static_cast (UTL_ScopedName *, parent->name ()->copy ()); + + UTL_ScopedName *field_name = + ACE_static_cast (UTL_ScopedName *, parent->name ()->copy ()); field_name->last_component ()->replace_string (excep_holder_name.rep ()); - be_interface *field_type= new be_interface (field_name, - 0, - 0, - 0, - 0, - 0, - 0); + + be_interface *field_type = 0; + ACE_NEW_RETURN (field_type, + be_interface (field_name, + 0, + 0, + 0, + 0, + 0, + 0), + 0); + field_type->set_defined_in (node->defined_in ()); - // Create the argument - be_argument *arg = - new be_argument (AST_Argument::dir_IN, - field_type, // is also a valuetype - new UTL_ScopedName (new Identifier ("ami_handler"), - 0)); + // Create the argument. + ACE_NEW_RETURN (id, + Identifier ("ami_handler"), + 0); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); + + be_argument *arg = 0; + ACE_NEW_RETURN (arg, + be_argument (AST_Argument::dir_IN, + field_type, // is also a valuetype + sn), + 0); // Add the reply handler to the argument list op->add_argument_to_scope (arg); - } // Iterate over the arguments and put all the in and inout @@ -615,12 +831,16 @@ be_visitor_ami_pre_proc::create_sendc_operation (be_operation *node, si.next ()) { AST_Decl *d = si.item (); + if (!d) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_ami_pre_proc::create_sendc_method - " - "bad node in this scope\n"), - 0); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_ami_pre_proc::create_sendc_method - " + "bad node in this scope\n" + ), + 0 + ); } //be_decl *arg = be_decl::narrow_from_decl (d); @@ -629,10 +849,13 @@ be_visitor_ami_pre_proc::create_sendc_operation (be_operation *node, if (original_arg->direction () == AST_Argument::dir_IN || original_arg->direction () == AST_Argument::dir_INOUT) { - // Create the argument - be_argument *arg = new be_argument (AST_Argument::dir_IN, - original_arg->field_type (), - original_arg->name ()); + // Create the argument. + be_argument *arg = 0; + ACE_NEW_RETURN (arg, + be_argument (AST_Argument::dir_IN, + original_arg->field_type (), + original_arg->name ()), + 0); op->add_argument_to_scope (arg); } @@ -642,59 +865,95 @@ be_visitor_ami_pre_proc::create_sendc_operation (be_operation *node, return op; } - - - - int -be_visitor_ami_pre_proc::create_reply_handler_operation (be_operation *node, - be_interface *reply_handler) +be_visitor_ami_pre_proc::create_reply_handler_operation ( + be_operation *node, + be_interface *reply_handler + ) { if (!node) - return -1; + { + return -1; + } if (node->flags () == AST_Operation::OP_oneway) - // We do nothing for oneways! - return 0; + { + // We do nothing for oneways! + return 0; + } + + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); // Create the return type, which is "void" - be_predefined_type *rt = - new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName (new Identifier ("void"), - 0)); - - ACE_CString original_op_name (node - ->name () - ->last_component () - ->get_string ()); - - UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *, reply_handler->name ()-> copy ()); - op_name->nconc (new UTL_ScopedName ( - new Identifier ( - original_op_name.rep ()), - 0)); + be_predefined_type *rt = 0; + ACE_NEW_RETURN (rt, + be_predefined_type (AST_PredefinedType::PT_void, + sn), + -1); + + ACE_CString original_op_name ( + node->name ()->last_component ()->get_string () + ); + + UTL_ScopedName *op_name = + ACE_static_cast (UTL_ScopedName *, + reply_handler->name ()-> copy ()); + + ACE_NEW_RETURN (id, + Identifier (original_op_name.rep ()), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + + op_name->nconc (sn); + + // Create the operation. + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (rt, + AST_Operation::OP_noflags, + op_name, + 0, + 0), + -1); - // Create the operation - be_operation *operation = new be_operation (rt, - AST_Operation::OP_noflags, - op_name, - 0, - 0); operation->set_name (op_name); - // If return type is non-void add it as first argument + // If return type is non-void add it as first argument. if (!node->void_return_type ()) { - - // Create the argument - be_argument *arg = - new be_argument (AST_Argument::dir_IN, - node->return_type (), - new UTL_ScopedName (new Identifier ("ami_return_val"), - 0)); - - // Add the reply handler to the argument list + ACE_NEW_RETURN (id, + Identifier ("ami_return_val"), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + + // Create the argument. + be_argument *arg = 0; + ACE_NEW_RETURN (arg, + be_argument (AST_Argument::dir_IN, + node->return_type (), + sn), + -1); + + // Add the reply handler to the argument list. operation->add_argument_to_scope (arg); } @@ -702,41 +961,54 @@ be_visitor_ami_pre_proc::create_reply_handler_operation (be_operation *node, // into the new method. if (node->nmembers () > 0) { - // initialize an iterator to iterate thru our scope + // Initialize an iterator to iterate thru our scope. for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next ()) { AST_Decl *d = si.item (); + if (d == 0) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_ami_pre_proc::create_reply_handler_operation - " + "(%N:%l) be_visitor_ami_pre_proc::" + "create_reply_handler_operation - " "bad node in this scope\n"), -1); } - //be_decl *arg = be_decl::narrow_from_decl (d); + AST_Argument *original_arg = AST_Argument::narrow_from_decl (d); if (original_arg->direction () == AST_Argument::dir_INOUT || original_arg->direction () == AST_Argument::dir_OUT) { - // Create the argument - be_argument *arg = new be_argument (AST_Argument::dir_IN, - original_arg->field_type (), - original_arg->name ()); + // Create the argument. + be_argument *arg = 0; + ACE_NEW_RETURN (arg, + be_argument (AST_Argument::dir_IN, + original_arg->field_type (), + original_arg->name ()), + -1); operation->add_argument_to_scope (arg); } } // end of while loop } // end of if - // Set the proper strategy - be_operation_strategy *old_strategy = - operation->set_strategy (new be_operation_ami_handler_reply_stub_strategy (operation)); + // Set the proper strategy. + be_operation_ami_handler_reply_stub_strategy *boahrss = 0; + ACE_NEW_RETURN (boahrss, + be_operation_ami_handler_reply_stub_strategy (operation), + -1); + + be_operation_strategy *old_strategy = operation->set_strategy (boahrss); + if (old_strategy) - delete old_strategy; + { + delete old_strategy; + old_strategy = 0; + } operation->set_defined_in (reply_handler); @@ -756,40 +1028,83 @@ be_visitor_ami_pre_proc::create_excep_operation (be_operation *node, be_valuetype *excep_holder) { if (!node) - return -1; + { + return -1; + } if (node->flags () == AST_Operation::OP_oneway) - // We do nothing for oneways! - return 0; + { + // We do nothing for oneways! + return 0; + } - // Create the return type, which is "void" - be_predefined_type *rt = - new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName (new Identifier ("void"), - 0)); - - // Create the argument - be_argument *arg = - new be_argument (AST_Argument::dir_IN, - excep_holder, // is also a valuetype - new UTL_ScopedName (new Identifier ("excep_holder"), - 0)); + // Create the return type, which is "void". + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + -1); + + 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); + + // Create the argument. + ACE_NEW_RETURN (id, + Identifier ("excep_holder"), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + + be_argument *arg = 0; + ACE_NEW_RETURN (arg, + be_argument (AST_Argument::dir_IN, + excep_holder, // is also a valuetype + sn), + -1); // Create the new name // Append _execp to the name of the operation - ACE_CString original_op_name (node->name ()->last_component ()->get_string ()); + ACE_CString original_op_name ( + node->name ()->last_component ()->get_string () + ); ACE_CString new_op_name = original_op_name + ACE_CString ("_excep"); - UTL_ScopedName *op_name = ACE_static_cast (UTL_ScopedName *, reply_handler->name ()-> copy ()); - op_name->nconc (new UTL_ScopedName (new Identifier (new_op_name.rep ()), - 0)); + UTL_ScopedName *op_name = + ACE_static_cast (UTL_ScopedName *, reply_handler->name ()->copy ()); + + ACE_NEW_RETURN (id, + Identifier (new_op_name.rep ()), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + + op_name->nconc (sn); + + // Create the operation. + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (rt, + AST_Operation::OP_noflags, + op_name, + 0, + 0), + -1); - // create the operation - be_operation *operation = new be_operation (rt, - AST_Operation::OP_noflags, - op_name, - 0, - 0); operation->set_name (op_name); operation->add_argument_to_scope (arg); @@ -806,7 +1121,7 @@ be_visitor_ami_pre_proc::create_excep_operation (be_operation *node, } -// visit the scope and its elements +// Visit the scope and its elements. int be_visitor_ami_pre_proc::visit_scope (be_scope *node) { @@ -821,16 +1136,19 @@ be_visitor_ami_pre_proc::visit_scope (be_scope *node) !si.is_done (); si.next ()) { - number_of_elements++; + ++number_of_elements; } } AST_Decl **elements; - ACE_NEW_RETURN (elements, AST_Decl *[number_of_elements], -1); + ACE_NEW_RETURN (elements, + AST_Decl *[number_of_elements], + -1); { int position = 0; - // initialize an iterator to iterate thru our scope + + // Initialize an iterator to iterate thru our scope. for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next ()) @@ -842,42 +1160,48 @@ be_visitor_ami_pre_proc::visit_scope (be_scope *node) int elem_number = 0; - // continue until each element is visited + // Continue until each element is visited. while (elem_number < number_of_elements) { AST_Decl *d = elements[elem_number]; + if (!d) { delete [] elements; + elements = 0; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); + "bad node in this scope\n"), + -1); } 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 + // Set the node to be visited. this->ctx_->node (bd); - elem_number++; + ++elem_number; // Send the visitor. if (bd == 0 || bd->accept (this) == -1) { delete [] elements; + elements = 0; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); - + "codegen for scope failed\n"), + -1); } } // end of while loop + delete [] elements; + elements = 0; } // end of if return 0; @@ -902,22 +1226,24 @@ be_visitor_ami_pre_proc::generate_name (ACE_CString &destination, be_operation * be_visitor_ami_pre_proc::generate_get_operation (be_attribute *node) { - ACE_CString original_op_name (node - ->name () - ->last_component () - ->get_string ()); + ACE_CString original_op_name ( + node->name ()->last_component ()->get_string () + ); ACE_CString new_op_name = ACE_CString ("get_") + original_op_name; UTL_ScopedName *get_name = ACE_static_cast (UTL_ScopedName *, - node->name ()-> copy ()); + node->name ()->copy ()); get_name->last_component ()->replace_string (new_op_name.rep ()); - be_operation *operation = - new be_operation (node->field_type (), - AST_Operation::OP_noflags, - get_name, - 0, - 0); + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (node->field_type (), + AST_Operation::OP_noflags, + get_name, + 0, + 0), + 0); + operation->set_name (get_name); operation->set_defined_in (node->defined_in ()); @@ -927,34 +1253,54 @@ be_visitor_ami_pre_proc::generate_get_operation (be_attribute *node) be_operation * be_visitor_ami_pre_proc::generate_set_operation (be_attribute *node) { - ACE_CString original_op_name (node - ->name () - ->last_component () - ->get_string ()); + ACE_CString original_op_name ( + node->name ()->last_component ()->get_string () + ); ACE_CString new_op_name = ACE_CString ("set_") + original_op_name; UTL_ScopedName *set_name = ACE_static_cast (UTL_ScopedName *, node->name ()-> copy ()); set_name->last_component ()->replace_string (new_op_name.rep ()); - // the return type is "void" - be_predefined_type *rt = - new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName (new Identifier ("void"), - 0)); + // The return type is "void". + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + 0); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + 0); + + be_predefined_type *rt = 0; + ACE_NEW_RETURN (rt, + be_predefined_type (AST_PredefinedType::PT_void, + sn), + 0); + + // 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 (), + set_name), + 0); - // argument type is the same as the attribute type - be_argument *arg = new be_argument (AST_Argument::dir_IN, - node->field_type (), - set_name); arg->set_name (node->name ()); - // create the operation - be_operation *operation = new be_operation (rt, - AST_Operation::OP_noflags, - set_name, - 0, - 0); + // Create the operation. + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (rt, + AST_Operation::OP_noflags, + set_name, + 0, + 0), + 0); + operation->set_name (set_name); operation->set_defined_in (node->defined_in ()); operation->add_argument_to_scope (arg); diff --git a/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp b/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp index 2f40e9fbbf9..90f67a8af36 100644 --- a/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_constant/constant_cs.cpp @@ -85,52 +85,51 @@ be_visitor_constant_cs::visit_constant (be_constant *node) << ";\n\n"; } } + node->cli_stub_gen (I_TRUE); } + return 0; } -// the following needs to be done to deal with the most bizarre behavior of -// MSVC++ compiler +// The following needs to be done until the MSVC++ compiler fixes its +// broken handling of namespaces (hopefully forthcoming in version 7). int be_visitor_constant_cs::gen_nested_namespace_begin (be_module *node) { TAO_OutStream *os = this->ctx_->stream (); - UTL_IdListActiveIterator *i; + char *item_name = 0; - i = new UTL_IdListActiveIterator (node->name ()); - while (!(i->is_done ())) + for (UTL_IdListActiveIterator i (node->name ()); !i.is_done (); i.next ()) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + item_name = i.item ()->get_string (); + + if (ACE_OS::strcmp (item_name, "") != 0) { - // leave the outermost root scope - *os << "TAO_NAMESPACE_BEGIN (" << i->item ()->get_string () + // leave the outermost root scope. + *os << "TAO_NAMESPACE_BEGIN (" << item_name << ")" << be_nl; } - i->next (); } - delete i; + return 0; } -// the following needs to be done to deal with the most bizarre behavior of -// MSVC++ compiler +// The following needs to be done until the MSVC++ compiler fixes its +// broken handling of namespaces (hopefully forthcoming in version 7). int be_visitor_constant_cs::gen_nested_namespace_end (be_module *node) { TAO_OutStream *os = this->ctx_->stream (); - UTL_IdListActiveIterator *i; - i = new UTL_IdListActiveIterator (node->name ()); - while (!(i->is_done ())) + for (UTL_IdListActiveIterator i (node->name ()); !i.is_done (); i.next ()) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (i.item ()->get_string (), "") != 0) { - // leave the outermost root scope + // leave the outermost root scope. *os << "TAO_NAMESPACE_END" << be_nl; } - i->next (); } - delete i; + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp index a9b511b3cbf..5b7ff0cf05b 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp @@ -18,7 +18,9 @@ #include "be_visitor_interface.h" #include "be_visitor_operation.h" -be_visitor_amh_interface_sh::be_visitor_amh_interface_sh (be_visitor_context *ctx) +be_visitor_amh_interface_sh::be_visitor_amh_interface_sh ( + be_visitor_context *ctx + ) : be_visitor_interface_sh (ctx) { } @@ -29,17 +31,21 @@ be_visitor_amh_interface_sh::~be_visitor_amh_interface_sh (void) /** The node is the original interface node but we 'tweak' with the local_name and the the operation signatures to generate the AMH - skeleton on the 'fly' + skeleton on the 'fly'. */ int be_visitor_amh_interface_sh::visit_interface (be_interface *node) { if (node->srv_hdr_gen () || node->imported () || node->is_local ()) - return 0; + { + return 0; + } // Do not generate AMH classes for any sort of implied IDL. if (node->original_interface () != 0) - return 0; + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); // output stream @@ -85,10 +91,12 @@ be_visitor_amh_interface_sh::visit_interface (be_interface *node) be_interface::narrow_from_decl (node->inherits ()[i]); base->compute_full_name ("AMH_", "", buf); amh_name += buf; - delete[] buf; + delete [] buf; if (i != 0) - *os << ", "; + { + *os << ", "; + } *os << "public virtual " << amh_name.c_str () @@ -182,7 +190,6 @@ be_visitor_amh_interface_sh::visit_interface (be_interface *node) *os << be_uidt_nl << "};\n\n"; return 0; - } int @@ -201,11 +208,12 @@ be_visitor_amh_interface_sh::visit_attribute (be_attribute *node) int be_visitor_amh_interface_sh::add_original_members (be_interface *node, - be_interface *amh_node - ) + be_interface *amh_node) { if (!node || !amh_node) - return -1; + { + return -1; + } this->elem_number_ = 0; // initialize an iterator to iterate thru our scope @@ -214,12 +222,16 @@ be_visitor_amh_interface_sh::add_original_members (be_interface *node, si.next ()) { AST_Decl *d = si.item (); + if (!d) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_pre_proc::visit_interface - " - "bad node in this scope\n"), - 0); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_amh_pre_proc::visit_interface - " + "bad node in this scope\n" + ), + 0 + ); } if (d->node_type () == AST_Decl::NT_attr) @@ -227,17 +239,21 @@ be_visitor_amh_interface_sh::add_original_members (be_interface *node, be_attribute *attribute = be_attribute::narrow_from_decl (d); if (!attribute) - return 0; + { + return 0; + } } else { be_operation* operation = be_operation::narrow_from_decl (d); + if (operation) { this->add_amh_operation (operation, amh_node); } } } + return 0; } @@ -247,45 +263,77 @@ be_visitor_amh_interface_sh::add_amh_operation (be_operation *node, be_interface *amh_node) { if (!node || !amh_node) - return -1; + { + return -1; + } // We do nothing for oneways! if (node->flags () == AST_Operation::OP_oneway) - return 0; + { + return 0; + } + + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); // Create the return type, which 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 = 0; + ACE_NEW_RETURN (rt, + be_predefined_type (AST_PredefinedType::PT_void, + sn), + -1); ACE_CString original_op_name ( - node->name ()->last_component ()->get_string () - ); + node->name ()->last_component ()->get_string () + ); UTL_ScopedName *op_name = - ACE_static_cast (UTL_ScopedName *, amh_node->name ()-> copy ()); - op_name->nconc (new UTL_ScopedName (new Identifier (original_op_name.rep ()), - 0)); + ACE_static_cast (UTL_ScopedName *, + amh_node->name ()->copy ()); + + ACE_NEW_RETURN (id, + Identifier (original_op_name.rep ()), + -1); + + ACE_NEW_RETURN (sn, + UTL_ScopedName (id, + 0), + -1); + + op_name->nconc (sn); // Create the operation - be_operation *operation = new be_operation (rt, //node->return_type (), - AST_Operation::OP_noflags, - op_name, - 0, - 0); + be_operation *operation = 0; + ACE_NEW_RETURN (operation, + be_operation (rt, //node->return_type (), + AST_Operation::OP_noflags, + op_name, + 0, + 0), + -1); + operation->set_name (op_name); // Iterate over the arguments and put all the in and inout // into the new method. if (node->nmembers () > 0) { - // initialize an iterator to iterate thru our scope + // Initialize an iterator to iterate thru our scope. for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next ()) { AST_Decl *d = si.item (); + if (!d) { ACE_ERROR_RETURN ((LM_ERROR, @@ -302,10 +350,13 @@ be_visitor_amh_interface_sh::add_amh_operation (be_operation *node, if (original_arg->direction () == AST_Argument::dir_INOUT || original_arg->direction () == AST_Argument::dir_IN) { - // Create the argument - be_argument *arg = new be_argument (original_arg->direction (), - original_arg->field_type (), - original_arg->name ()); + // Create the argument. + be_argument *arg = 0; + ACE_NEW_RETURN (arg, + be_argument (original_arg->direction (), + original_arg->field_type (), + original_arg->name ()), + -1); operation->add_argument_to_scope (arg); } @@ -325,20 +376,29 @@ be_visitor_amh_interface_sh::add_amh_operation (be_operation *node, be_interface * be_visitor_amh_interface_sh::create_amh_class (ACE_CString name) { - UTL_ScopedName *amh_class_name = - new UTL_ScopedName (new Identifier (name.c_str ()), 0); - - be_interface *amh_class = - new be_interface (amh_class_name, // name - 0, // list of inherited - 0, // number of inherited - 0, // list of ancestors - 0, // number of ancestors - 0, // non-local - 0); // non-abstract + Identifier *id = 0; + ACE_NEW_RETURN (id, + Identifier (name.c_str ()), + 0); + + UTL_ScopedName *amh_class_name = 0; + ACE_NEW_RETURN (amh_class_name, + UTL_ScopedName (id, + 0), + 0); + + be_interface *amh_class = 0; + ACE_NEW_RETURN (amh_class, + be_interface (amh_class_name, // name + 0, // list of inherited + 0, // number of inherited + 0, // list of ancestors + 0, // number of ancestors + 0, // non-local + 0), // non-abstract + 0); amh_class->set_name (amh_class_name); - return amh_class; } 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 b63dcab75dc..5421e5ebb95 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 @@ -16,7 +16,9 @@ #include "be_visitor_operation.h" -be_visitor_amh_rh_operation_ss::be_visitor_amh_rh_operation_ss (be_visitor_context *ctx) +be_visitor_amh_rh_operation_ss::be_visitor_amh_rh_operation_ss ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -39,8 +41,13 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) be_interface *intf = be_interface::narrow_from_scope (node->defined_in ()); + if (this->ctx_->attribute () != 0) - intf = be_interface::narrow_from_scope (this->ctx_->attribute()->defined_in ()); + { + intf = be_interface::narrow_from_scope ( + this->ctx_->attribute()->defined_in () + ); + } if (!intf) { @@ -55,7 +62,8 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) intf->compute_full_name ("TAO_", "", buf); ACE_CString response_handler_implementation_name ("POA_"); response_handler_implementation_name += buf; - delete[] buf; + delete [] buf; + buf = 0; // Step 1 : Generate return type: always void *os << be_nl << "void" << be_nl @@ -66,9 +74,13 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) { // now check if we are a "get" or "set" operation if (node->nmembers () == 1) // set - *os << "_set_"; + { + *os << "_set_"; + } else - *os << "_get_"; + { + *os << "_get_"; + } } *os << node->local_name (); @@ -76,20 +88,10 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) // Step 2 : Generate the params of the method be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_ARGLIST_OTHERS); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_rh_operation_ss::" - "visit_operation - " - "Bad visitor to return type\n"), - -1); - } + be_visitor_operation_arglist visitor (&ctx); - if (node->accept (visitor) == -1) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_amh_rh_operation_ss::" "visit_operation - " @@ -97,8 +99,6 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) -1); } - delete visitor; - int is_an_exception_reply = 0; // Find out if the operation is one of the *_excep() operations, the @@ -112,13 +112,16 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) { if (node->nmembers () == 1) { - UTL_ScopeActiveIterator i (node, UTL_Scope::IK_decls); + UTL_ScopeActiveIterator i (node, + UTL_Scope::IK_decls); + if (!i.is_done ()) { be_argument *argument = be_argument::narrow_from_decl (i.item ()); be_valuetype *vt = be_valuetype::narrow_from_decl (argument->field_type ()); + if (vt != 0 && vt->original_interface () == intf->original_interface () && ACE_OS::strstr (vt->full_name (), "ExceptionHolder") != 0) @@ -135,9 +138,6 @@ be_visitor_amh_rh_operation_ss::visit_operation (be_operation *node) << "ACE_TRY" << be_nl << "{" << be_nl << "ACE_UNUSED_ARG (holder);" << be_nl - // << " holder->raise_" << node->local_name () - // << "(ACE_ENV_SINGLE_ARG_PARAMETER);" << be_nl - // << " ACE_TRY_CHECK;" << be_nl << "}" << be_nl << "ACE_CATCH (CORBA::Exception, ex)" << be_nl << "{" << be_nl @@ -167,7 +167,6 @@ int be_visitor_amh_rh_operation_ss::marshal_params (be_operation *node) { 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 @@ -184,11 +183,10 @@ 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); - visitor = tao_cg->make_visitor (&ctx); + be_compiled_visitor_operation_argument_invoke visitor (&ctx); - if (!visitor || (node->accept (visitor) == -1)) + if (node->accept (&visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_amh_rh_operation_ss::" "gen_demarshal_params - " @@ -207,6 +205,7 @@ be_visitor_amh_rh_operation_ss::marshal_params (be_operation *node) "(%N:%l) gen_raise_exception failed\n"), -1); } + *os << be_uidt << "\n"; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp b/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp index 3df34d98d0d..4d5d252ab47 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_sh.cpp @@ -34,7 +34,9 @@ ACE_RCSID(be_visitor_operation, amh_sh, "$Id$") // Visitor for generating AMH skeleton for "operation" in skeleton header. // ****************************************************** -be_visitor_amh_operation_sh::be_visitor_amh_operation_sh (be_visitor_context *ctx) +be_visitor_amh_operation_sh::be_visitor_amh_operation_sh ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -48,7 +50,9 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) { // If there is an argument of type "native", return immediately. if (node->has_native ()) - return 0; + { + return 0; + } // Output stream. TAO_OutStream *os = this->ctx_->stream (); @@ -69,11 +73,15 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) { be_argument *argument = be_argument::narrow_from_decl (i.item ()); + if (argument == 0 || argument->direction () == AST_Argument::dir_OUT) - continue; + { + continue; + } *os << ","; + if (arglist_visitor.visit_argument (argument) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -82,15 +90,21 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) "codegen for upcall args failed\n"), -1); } + *os << be_nl; } + *os << "ACE_ENV_ARG_DECL" << be_uidt_nl << ")" << be_uidt; if (be_global->use_raw_throw ()) - *os << be_idt_nl << "throw ("; + { + *os << be_idt_nl << "throw ("; + } else - *os << be_idt_nl << "ACE_THROW_SPEC (("; + { + *os << be_idt_nl << "ACE_THROW_SPEC (("; + } *os << be_idt_nl << "CORBA::SystemException"; @@ -104,7 +118,6 @@ be_visitor_amh_operation_sh::visit_operation (be_operation *node) } *os << " = 0;\n" << be_nl; - return 0; } @@ -118,11 +131,14 @@ be_visitor_amh_operation_sh::visit_attribute (be_attribute *node) { *os << "ACE_ENV_SINGLE_ARG_DECL"; } + *os << be_uidt_nl << ")" << be_uidt_nl << "ACE_THROW_SPEC ((CORBA::SystemException)) = 0;\n" << be_nl; if (node->readonly ()) - return 0; + { + return 0; + } this->generate_shared_prologue (node, os, "_set_"); @@ -135,7 +151,9 @@ be_visitor_amh_operation_sh::visit_attribute (be_attribute *node) be_visitor_args_arglist visitor (&ctx); if (visitor.visit_argument (&the_argument) == -1) - return -1; + { + return -1; + } *os << the_argument.local_name (); @@ -143,6 +161,7 @@ be_visitor_amh_operation_sh::visit_attribute (be_attribute *node) { *os << be_nl << "ACE_ENV_SINGLE_ARG_DECL"; } + *os << be_uidt_nl << ")" << be_uidt_nl << "ACE_THROW_SPEC ((CORBA::SystemException)) = 0;\n" << be_nl; @@ -150,9 +169,11 @@ be_visitor_amh_operation_sh::visit_attribute (be_attribute *node) } void -be_visitor_amh_operation_sh::generate_shared_prologue (be_decl *node, - TAO_OutStream *os, - const char *skel_prefix) +be_visitor_amh_operation_sh::generate_shared_prologue ( + be_decl *node, + TAO_OutStream *os, + const char *skel_prefix + ) { os->indent (); *os << be_nl << "// TAO_IDL - Generated from " @@ -172,8 +193,13 @@ be_visitor_amh_operation_sh::generate_shared_prologue (be_decl *node, // information from the context be_interface *intf = be_interface::narrow_from_scope (node->defined_in ()); + if (this->ctx_->attribute () != 0) - intf = be_interface::narrow_from_scope (this->ctx_->attribute()->defined_in ()); + { + intf = be_interface::narrow_from_scope ( + this->ctx_->attribute()->defined_in () + ); + } if (intf == 0) { @@ -202,5 +228,6 @@ be_visitor_amh_operation_sh::generate_shared_prologue (be_decl *node, intf->compute_full_name ("AMH_", "ResponseHandler_ptr", buf); *os << buf << " _tao_rh" << be_nl; - delete[] buf; + delete [] buf; + buf = 0; } 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 73a0a577385..f0e40e41975 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/amh_ss.cpp @@ -16,7 +16,9 @@ #include "be_visitor_operation.h" -be_visitor_amh_operation_ss::be_visitor_amh_operation_ss (be_visitor_context *ctx) +be_visitor_amh_operation_ss::be_visitor_amh_operation_ss ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } @@ -30,13 +32,17 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) { // If there is an argument of type "native", return immediately. if (node->has_native ()) - return 0; + { + return 0; + } TAO_OutStream *os = this->ctx_->stream (); this->ctx_->node (node); if (this->generate_shared_prologue (node, os, "") == -1) - return -1; + { + return -1; + } int argument_count = node->count_arguments_with_direction (AST_Argument::dir_IN @@ -60,7 +66,9 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) if (argument == 0 || argument->direction () == AST_Argument::dir_OUT) - continue; + { + continue; + } if (vardecl_visitor.visit_argument (argument) == -1) { @@ -72,7 +80,6 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) } } - *os << be_nl << "TAO_InputCDR &_tao_in =" << " _tao_server_request.incoming ();\n" << be_nl @@ -92,9 +99,12 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) { be_argument *argument = be_argument::narrow_from_decl (sj.item ()); + if (argument == 0 || argument->direction () == AST_Argument::dir_OUT) - continue; + { + continue; + } *os << "&& "; @@ -106,6 +116,7 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) "codegen for demarshal failed\n"), -1); } + *os << be_nl; } @@ -120,11 +131,14 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) "(%N:%l) gen_raise_exception failed\n"), -1); } + *os << be_uidt << "\n"; } if (this->generate_shared_section (node, os) == -1) - return -1; + { + return -1; + } { be_visitor_context ctx (*this->ctx_); @@ -138,11 +152,15 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) { be_argument *argument = be_argument::narrow_from_decl (i.item ()); + if (argument == 0 || argument->direction () == AST_Argument::dir_OUT) - continue; + { + continue; + } *os << ","; + if (argument->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -151,13 +169,17 @@ be_visitor_amh_operation_ss::visit_operation (be_operation *node) "codegen for upcall args failed\n"), -1); } + *os << be_nl; } + *os << "ACE_ENV_ARG_PARAMETER"; } if (this->generate_shared_epilogue (os) == -1) - return -1; + { + return -1; + } return 0; @@ -170,33 +192,43 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) this->ctx_->node (node); if (this->generate_shared_prologue (node, os, "_get_") == -1) - return -1; + { + return -1; + } if (this->generate_shared_section (node, os) == -1) - return -1; + { + return -1; + } *os << "ACE_ENV_ARG_PARAMETER"; if (this->generate_shared_epilogue (os) == -1) - return -1; + { + return -1; + } if (node->readonly ()) - return 0; + { + return 0; + } if (this->generate_shared_prologue (node, os, "_set_") == -1) - return -1; + { + return -1; + } be_argument the_argument (AST_Argument::dir_IN, node->field_type (), node->name ()); - { be_visitor_context ctx (*this->ctx_); be_visitor_args_vardecl_ss visitor (&ctx); if (visitor.visit_argument (&the_argument) == -1) - return -1; - } + { + return -1; + } *os << be_nl << "TAO_InputCDR &_tao_in =" @@ -211,7 +243,9 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) be_visitor_args_marshal_ss visitor (&ctx); if (visitor.visit_argument (&the_argument) == -1) - return -1; + { + return -1; + } } *os << be_uidt_nl << "))" << be_idt_nl; @@ -225,16 +259,21 @@ be_visitor_amh_operation_ss::visit_attribute (be_attribute *node) "(%N:%l) gen_raise_exception failed\n"), -1); } + *os << be_uidt << "\n"; if (this->generate_shared_section (node, os) == -1) - return -1; + { + return -1; + } *os << ", " << node->local_name () << be_nl << "ACE_ENV_ARG_PARAMETER"; if (this->generate_shared_epilogue (os) == -1) - return -1; + { + return -1; + } return 0; } @@ -267,7 +306,8 @@ be_visitor_amh_operation_ss::generate_shared_prologue (be_decl *node, intf->compute_full_name ("AMH_", "", buf); ACE_CString amh_skel_name ("POA_"); amh_skel_name += buf; - delete[] buf; + delete [] buf; + buf = 0; os->indent (); *os << "void" << be_nl @@ -306,12 +346,14 @@ be_visitor_amh_operation_ss::generate_shared_section (be_decl *node, char *buf; intf->compute_full_name ("AMH_", "ResponseHandler", buf); ACE_CString response_handler_name (buf); - delete[] buf; + delete [] buf; + buf = 0; intf->compute_full_name ("TAO_AMH_", "ResponseHandler", buf); ACE_CString response_handler_implementation_name ("POA_"); response_handler_implementation_name += buf; - delete[] buf; + delete [] buf; + buf = 0; *os << be_nl << response_handler_name.c_str () << "_var _tao_rh =" << be_idt_nl diff --git a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp index 8bf51c89647..ed5ef268658 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/ami_exception_holder_operation_cs.cpp @@ -31,57 +31,72 @@ ACE_RCSID(be_visitor_operation, ami_exception_holder_operation_cs, "$Id$") // Operation visitor for client stubs // ************************************************************ -be_visitor_operation_ami_exception_holder_operation_cs::be_visitor_operation_ami_exception_holder_operation_cs (be_visitor_context *ctx) +be_visitor_operation_ami_exception_holder_operation_cs:: +be_visitor_operation_ami_exception_holder_operation_cs ( + be_visitor_context *ctx + ) : be_visitor_operation (ctx) { } -be_visitor_operation_ami_exception_holder_operation_cs::~be_visitor_operation_ami_exception_holder_operation_cs (void) +be_visitor_operation_ami_exception_holder_operation_cs:: +~be_visitor_operation_ami_exception_holder_operation_cs (void) { } int -be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_operation *node) +be_visitor_operation_ami_exception_holder_operation_cs::visit_operation ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - be_type *bt; // type node - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); // Start with the current indentation level. os->indent (); // Init the return type variable. - 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, - "(%N:%l) be_visitor_ami_exception_holder_operation_cs::" - "visit_operation - " - "Bad return type\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_ami_exception_holder_operation_cs::" + "visit_operation - " + "Bad return type\n" + ), + -1 + ); } // Generate the return type. Return type is simply void. *os << "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 == 0) { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_operation_ami_exception_holder_operation_cs::" - "visit_operation - " - "scopeless operation :-<\n"), - -1); + ACE_ERROR_RETURN (( + LM_ERROR, + "(%N:%l) be_visitor_operation_ami_exception_holder_operation_cs::" + "visit_operation - " + "scopeless operation :-<\n" + ), + -1 + ); } be_interface *parent_interface = be_interface::narrow_from_decl (parent); - if (parent_interface->is_nested () && - parent_interface->defined_in ()->scope_node_type () == AST_Decl::NT_module) - *os << "OBV_"; + AST_Decl::NodeType nt = + parent_interface->defined_in ()->scope_node_type (); + + if (parent_interface->is_nested () && nt == AST_Decl::NT_module) + { + *os << "OBV_"; + } // Here we do not have our overridden be_interface methods, // so the interface type strategy does not work here. @@ -97,14 +112,20 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper { // now check if we are a "get" or "set" operation if (node->nmembers () == 1) // set - *os << "set_"; + { + *os << "set_"; + } else - *os << "get_"; + { + *os << "get_"; + } } *os << node->local_name () << "("; if (!be_global->exception_support ()) - *os << "ACE_ENV_SINGLE_ARG_DECL"; + { + *os << "ACE_ENV_SINGLE_ARG_DECL"; + } *os << ")" << be_uidt; @@ -132,14 +153,15 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper *os << "static TAO_Exception_Data " << "exceptions_data [] = " << be_nl; *os << "{" << be_idt_nl; - // Initialize an iterator to iterate thru the exception list. - UTL_ExceptlistActiveIterator ei (node->exceptions ()); int excep_count = 0; AST_Decl *d = 0; + // Initialize an iterator to iterate thru the exception list. // Continue until each element is visited. - while (!ei.is_done ()) + // Iterator must be explicitly advanced inside the loop. + for (UTL_ExceptlistActiveIterator ei (node->exceptions ()); + !ei.is_done ();) { d = ei.item (); @@ -149,7 +171,7 @@ be_visitor_operation_ami_exception_holder_operation_cs::visit_operation (be_oper *os << d->name () << "::_alloc" << be_uidt_nl << "}"; - excep_count++; + ++excep_count; ei.next (); if (!ei.is_done ()) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp index 455a6619aae..f957bcb3397 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/exceptlist_cs.cpp @@ -32,8 +32,9 @@ ACE_RCSID(be_visitor_operation, exceptlist_cs, "$Id$") // visitor to generate the exception list for operations // **************************************************************************** -be_visitor_operation_exceptlist_cs::be_visitor_operation_exceptlist_cs (be_visitor_context - *ctx) +be_visitor_operation_exceptlist_cs::be_visitor_operation_exceptlist_cs ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } @@ -55,13 +56,13 @@ be_visitor_operation_exceptlist_cs::visit_operation (be_operation *node) << "_exceptiondata [] = " << be_nl; *os << "{" << be_idt_nl; - // Initialize an iterator to iterate thru the exception list. - UTL_ExceptlistActiveIterator ei (node->exceptions ()); - AST_Decl *d = 0; + // Initialize an iterator to iterate thru the exception list. // Continue until each element is visited. - while (!ei.is_done ()) + // Iterator must be advanced explicitly inside the loop. + for (UTL_ExceptlistActiveIterator ei (node->exceptions ()); + !ei.is_done ();) { d = ei.item (); @@ -77,7 +78,6 @@ be_visitor_operation_exceptlist_cs::visit_operation (be_operation *node) { *os << "," << be_nl; } - } *os << be_uidt_nl << "};\n\n"; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp index daefb28aa37..483f72c2553 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/interceptors_exceptlist.cpp @@ -31,28 +31,28 @@ ACE_RCSID(be_visitor_operation, interceptors_exceptlist, "$Id$") // Operation visitor for exception list // ************************************************************ -be_visitor_operation_interceptors_exceptlist::be_visitor_operation_interceptors_exceptlist (be_visitor_context *ctx) +be_visitor_operation_interceptors_exceptlist:: +be_visitor_operation_interceptors_exceptlist (be_visitor_context *ctx) : be_visitor_operation (ctx) { } -be_visitor_operation_interceptors_exceptlist::~be_visitor_operation_interceptors_exceptlist (void) +be_visitor_operation_interceptors_exceptlist:: +~be_visitor_operation_interceptors_exceptlist (void) { } int be_visitor_operation_interceptors_exceptlist::visit_operation (be_operation *node) { - TAO_OutStream *os; // output stream - // be_type *bt; // type node - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); // Start with the current indentation level. os->indent (); + TAO_CodeGen::CG_STATE state = this->ctx_->state (); - if (this->ctx_->state () == TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST) + if (state == TAO_CodeGen::TAO_OPERATION_INTERCEPTORS_EXCEPTLIST) { return this->gen_exceptlist (node); } @@ -65,12 +65,12 @@ be_visitor_operation_interceptors_exceptlist::visit_operation (be_operation *nod } int -be_visitor_operation_interceptors_exceptlist::gen_exceptlist (be_operation *node) +be_visitor_operation_interceptors_exceptlist::gen_exceptlist ( + be_operation *node + ) { - TAO_OutStream *os; // output stream - - os = this->ctx_->stream (); - this->ctx_->node (node); // save the node for future use + TAO_OutStream *os = this->ctx_->stream (); + this->ctx_->node (node); // Generate the exception data array. *os << be_nl @@ -78,13 +78,13 @@ be_visitor_operation_interceptors_exceptlist::gen_exceptlist (be_operation *node << "_exceptiondata[] = " << be_nl; *os << "{" << be_idt_nl; - // Initialize an iterator to iterate thru the exception list. - UTL_ExceptlistActiveIterator ei (node->exceptions ()); - be_exception *excp = 0; + // Initialize an iterator to iterate thru the exception list. // Continue until each element is visited. - while (!ei.is_done ()) + // Iterator must be advanced explicitly inside the loop. + for (UTL_ExceptlistActiveIterator ei (node->exceptions ()); + !ei.is_done ();) { excp = be_exception::narrow_from_decl (ei.item ()); @@ -97,18 +97,15 @@ be_visitor_operation_interceptors_exceptlist::gen_exceptlist (be_operation *node "be_exception::narrow_from_decl failed\n"), -1 ); - } *os << excp->tc_name (); - ei.next (); if (!ei.is_done ()) { *os << "," << be_nl; } - } *os << be_uidt_nl << "};" << be_nl; @@ -121,7 +118,8 @@ be_visitor_operation_interceptors_exceptlist::gen_exceptlist (be_operation *node << "{" << be_idt_nl << "CORBA::TypeCode_ptr tcp = _tao_" << node->flat_name () << "_exceptiondata[i];" << be_nl - << "TAO_Pseudo_Object_Manager<CORBA::TypeCode,CORBA::TypeCode_var> tcp_object (&tcp, 1);" << be_nl + << "TAO_Pseudo_Object_Manager<CORBA::TypeCode, " + << "CORBA::TypeCode_var> tcp_object (&tcp, 1);" << be_nl << "(*exception_list)[i] = tcp_object;" << be_uidt_nl << "}\n" << be_uidt; diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index 864423484dd..89a76431275 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -27,12 +27,12 @@ ACE_RCSID(be_visitor_operation, operation, "$Id$") - // ************************************************************ - // Generic Operation visitor - // ************************************************************ +// ************************************************************ +// Generic Operation visitor +// ************************************************************ - be_visitor_operation::be_visitor_operation (be_visitor_context *ctx) - : be_visitor_scope (ctx) +be_visitor_operation::be_visitor_operation (be_visitor_context *ctx) + : be_visitor_scope (ctx) { } @@ -41,17 +41,22 @@ be_visitor_operation::~be_visitor_operation (void) } +// Is the operation return type void? int be_visitor_operation::void_return_type (be_type *bt) { - // is the operation return type void? + if (bt->node_type () == AST_Decl::NT_pre_defined) + { + AST_PredefinedType::PredefinedType pdt = + be_predefined_type::narrow_from_decl (bt)->pt (); - 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; + if (pdt == AST_PredefinedType::PT_void) + { + return 1; + } + } + + return 0; } int @@ -72,7 +77,7 @@ be_visitor_operation::count_non_out_parameters (be_operation *node) // size_t count = 0; - // initialize an iterator to iterate thru our scope + // Initialize an iterator to iterate thru our scope. for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next ()) @@ -81,21 +86,22 @@ be_visitor_operation::count_non_out_parameters (be_operation *node) be_argument::narrow_from_decl (si.item ()); // We do not generate insertion operators for valuetypes - // yet. Do not include them in the count. + // yet. Do not include them in the count. be_valuetype *vt = be_valuetype::narrow_from_decl (bd->field_type ()); if (bd && (bd->direction () != AST_Argument::dir_OUT) && !vt) - count++; - + { + ++count; + } } return count; } -//Method to generate the throw specs for exceptions that are thrown by the -//operation +// Method to generate the throw specs for exceptions that are thrown by the +// operation. int be_visitor_operation::gen_throw_spec (be_operation *node) { @@ -112,10 +118,11 @@ be_visitor_operation::gen_throw_spec (be_operation *node) *os << be_idt_nl << throw_spec_open << be_idt_nl << "CORBA::SystemException"; + if (node->exceptions ()) { - // initialize an iterator to iterate thru the exception list + // Initialize an iterator to iterate thru the exception list. for (UTL_ExceptlistActiveIterator ei (node->exceptions ()); !ei.is_done (); ei.next ()) @@ -128,7 +135,8 @@ be_visitor_operation::gen_throw_spec (be_operation *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation" "gen_throw_spec - " - "bad exception node\n"), -1); + "bad exception node\n"), + -1); } @@ -137,7 +145,6 @@ be_visitor_operation::gen_throw_spec (be_operation *node) } *os << be_uidt_nl << throw_spec_close << be_uidt; - return 0; } @@ -145,32 +152,38 @@ int be_visitor_operation::gen_environment_decl (int argument_emitted, be_operation *node) { - // generate the CORBA::Environment parameter for the alternative mapping + // Generate the CORBA::Environment parameter for the alternative mapping. if (be_global->exception_support ()) - return 0; + { + return 0; + } - TAO_OutStream *os = this->ctx_->stream (); // grab the out stream + TAO_OutStream *os = this->ctx_->stream (); // Use ACE_ENV_SINGLE_ARG_DECL or ACE_ENV_ARG_DECL depending on // whether the operation node has parameters. const char *env_decl = "ACE_ENV_SINGLE_ARG_DECL"; + if (argument_emitted || node->argument_count () > 0) - env_decl = "ACE_ENV_ARG_DECL"; + { + env_decl = "ACE_ENV_ARG_DECL"; + } *os << be_nl; + switch (this->ctx_->state ()) { case TAO_CodeGen::TAO_OPERATION_ARGLIST_CH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_COLLOCATED_SH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_SH: - // last argument - is always CORBA::Environment + // Last argument is always CORBA::Environment. *os << env_decl << "_WITH_DEFAULTS"; break; case TAO_CodeGen::TAO_OPERATION_ARGLIST_IS: case TAO_CodeGen::TAO_OPERATION_ARGLIST_IH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_PROXY_IMPL_XH: case TAO_CodeGen::TAO_OPERATION_ARGLIST_BASE_PROXY_IMPL_CH: - // last argument - is always ACE_ENV_ARG_DECL + // Last argument is always CORBA::Environment. *os << env_decl; break; default: @@ -181,14 +194,15 @@ be_visitor_operation::gen_environment_decl (int argument_emitted, return 0; } -// Method that returns the appropriate CORBA::Environment variable +// Method that returns the appropriate CORBA::Environment variable. const char * be_visitor_operation::gen_environment_var () { static const char *ace_try_env_decl = "ACE_DECLARE_NEW_CORBA_ENV;"; static const char *null_env_decl = ""; - // check if we are generating stubs/skeletons for true C++ exception support + // Check if we are generating stubs/skeletons for + // true C++ exception support. if (be_global->exception_support ()) { return ace_try_env_decl; @@ -215,6 +229,7 @@ be_visitor_operation::gen_raise_exception (be_type *return_type, int is_void = return_type == 0 || this->void_return_type (return_type); + if (is_void) { *os << "ACE_THROW ("; @@ -223,6 +238,7 @@ be_visitor_operation::gen_raise_exception (be_type *return_type, { *os << "ACE_THROW_RETURN ("; } + *os << exception_name << " (" << exception_arguments << ")"; if (is_void) @@ -230,13 +246,15 @@ be_visitor_operation::gen_raise_exception (be_type *return_type, *os << ");\n"; return 0; } + *os << ","; - // Non-void return type.... + // Non-void return type. be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS); be_visitor_operation_rettype_return_cs visitor (&ctx); + if (return_type->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -245,8 +263,8 @@ be_visitor_operation::gen_raise_exception (be_type *return_type, "codegen for return var failed\n"), -1); } - *os << ");\n"; + *os << ");\n"; return 0; } @@ -268,6 +286,7 @@ be_visitor_operation::gen_check_exception (be_type *return_type) ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS); be_visitor_operation_rettype_return_cs visitor (&ctx); + if (return_type->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -276,8 +295,8 @@ be_visitor_operation::gen_check_exception (be_type *return_type) "codegen for return var failed\n"), -1); } - *os << ");\n"; + *os << ");\n"; return 0; } @@ -293,12 +312,13 @@ be_visitor_operation::gen_check_interceptor_exception (be_type *return_type) return 0; } - // Non-void return type.... + // Non-void return type. *os << "TAO_INTERCEPTOR_CHECK_RETURN ("; be_visitor_context ctx (*this->ctx_); ctx.state (TAO_CodeGen::TAO_OPERATION_RETVAL_RETURN_CS); be_visitor_operation_rettype_return_cs visitor (&ctx); + if (return_type->accept (&visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, @@ -307,7 +327,7 @@ be_visitor_operation::gen_check_interceptor_exception (be_type *return_type) "codegen for return var failed\n"), -1); } - *os << ");\n"; + *os << ");\n"; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp index 7b3d8a12ab8..a02cdaa5c9b 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp @@ -33,23 +33,27 @@ ACE_RCSID(be_visitor_operation, operation_cs, "$Id$") be_visitor_operation_cs::be_visitor_operation_cs (be_visitor_context *ctx) : be_visitor_operation (ctx) - // operation_name_ (0) +// operation_name_ (0) { } be_visitor_operation_cs::~be_visitor_operation_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_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; } @@ -77,9 +81,9 @@ be_visitor_operation_cs::visit_operation (be_operation *node) return 0; } - os->indent (); // start with the current indentation level + os->indent (); - // retrieve the operation return type + // Retrieve the operation return type. be_type *bt = be_type::narrow_from_decl (node->return_type ()); if (!bt) @@ -94,11 +98,10 @@ be_visitor_operation_cs::visit_operation (be_operation *node) // 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 rt_visitor = (&ctx); - if ((!visitor) || (bt->accept (visitor) == -1)) + if (bt->accept (&rt_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -106,8 +109,6 @@ be_visitor_operation_cs::visit_operation (be_operation *node) -1); } - delete visitor; - // Generate the operation name *os << " " << node->name (); @@ -115,11 +116,10 @@ be_visitor_operation_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); + be_visitor_operation_arglist al_visitor (&ctx); - if ((!visitor) || (node->accept (visitor) == -1)) + if (node->accept (&al_visitor) == -1) { - delete visitor; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_operation_cs::" "visit_operation - " @@ -127,8 +127,6 @@ be_visitor_operation_cs::visit_operation (be_operation *node) -1); } - delete visitor; - *os << "{" << be_idt_nl; *os << this->gen_environment_var (); @@ -260,13 +258,11 @@ be_visitor_operation_cs::visit_operation (be_operation *node) int be_visitor_operation_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 = be_type::narrow_from_decl (node->field_type ()); - // retrieve the type for this argument - bt = be_type::narrow_from_decl (node->field_type ()); if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -278,6 +274,7 @@ be_visitor_operation_cs::visit_argument (be_argument *node) os->indent (); *os << "{" << bt->tc_name () << ", "; + switch (node->direction ()) { case AST_Argument::dir_IN: @@ -290,7 +287,7 @@ be_visitor_operation_cs::visit_argument (be_argument *node) *os << "PARAM_OUT, "; break; } - *os << "0}"; + *os << "0}"; return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp b/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp index acbc7166c34..a15e855d3c9 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp @@ -68,8 +68,7 @@ be_visitor_root_sth::init (void) int be_visitor_root_sth::visit_scope (be_scope *node) { - for (UTL_ScopeActiveIterator si (node, - UTL_Scope::IK_decls); + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next ()) { @@ -85,7 +84,7 @@ be_visitor_root_sth::visit_scope (be_scope *node) AST_Decl::NodeType nt = d->node_type (); - // These are the onlh types we're interested in. + // These are the only types we're interested in. if (nt != AST_Decl::NT_module && nt != AST_Decl::NT_interface) { diff --git a/TAO/TAO_IDL/be/be_visitor_scope.cpp b/TAO/TAO_IDL/be/be_visitor_scope.cpp index d246c1f5332..e2cc13b8793 100644 --- a/TAO/TAO_IDL/be/be_visitor_scope.cpp +++ b/TAO/TAO_IDL/be/be_visitor_scope.cpp @@ -49,6 +49,7 @@ be_visitor_scope::visit_scope (be_scope *node) { // Proceed if the number of members in our scope is greater than 0. this->elem_number_ = 0; + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next ()) @@ -164,7 +165,9 @@ be_visitor_scope::next_elem (be_decl *elem, } if (bd != elem) - continue; + { + continue; + } // Find who is next to me. si.next (); diff --git a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp index ef6480b53e9..48f0db46537 100644 --- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp @@ -151,6 +151,7 @@ int be_visitor_typecode_defn::visit_members (be_valuetype *node) { this->elem_number_ = 0; + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next()) @@ -161,7 +162,8 @@ be_visitor_typecode_defn::visit_members (be_valuetype *node) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typecode_defn::visit_members - " - "bad node in this scope\n"), -1); + "bad node in this scope\n"), + -1); } AST_Field *field = AST_Field::narrow_from_decl (d); @@ -172,13 +174,13 @@ be_visitor_typecode_defn::visit_members (be_valuetype *node) } 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 - this->ctx_->scope (node->decl ()); - // set the node to be visited + // Set the node to be visited. this->ctx_->node (bd); this->elem_number_++; @@ -186,16 +188,19 @@ be_visitor_typecode_defn::visit_members (be_valuetype *node) if (this->pre_process (bd) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::visit_members - " + "(%N:%l) be_visitor_typecode_defn::" + "visit_members - " "pre processing failed\n" - ), -1); + ), + -1); } // Send the visitor. if (bd == 0 || bd->accept (this) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::visit_members - " + "(%N:%l) be_visitor_typecode_defn::" + "visit_members - " "codegen for scope failed\n" ), -1); } @@ -204,7 +209,8 @@ be_visitor_typecode_defn::visit_members (be_valuetype *node) if (this->post_process (bd) == -1) { ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::visit_members - " + "(%N:%l) be_visitor_typecode_defn::" + "visit_members - " "post processing failed\n" ), -1); } @@ -214,53 +220,50 @@ be_visitor_typecode_defn::visit_members (be_valuetype *node) } -// the following needs to be done to deal with the most bizarre behavior of -// MSVC++ compiler +// The following needs to be done to deal until the MSVC compiler's broken +// handling of namespaces is fixed (hopefully forthcoming in version 7). int be_visitor_typecode_defn::gen_nested_namespace_begin (be_module *node) { TAO_OutStream *os = this->ctx_->stream (); - UTL_IdListActiveIterator *i; + char *item_name = 0; - i = new UTL_IdListActiveIterator (node->name ()); - while (!(i->is_done ())) + for (UTL_IdListActiveIterator i (node->name ()); !i.is_done (); i.next ()) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + item_name = i.item ()->get_string (); + + if (ACE_OS::strcmp (item_name, "") != 0) { - // leave the outermost root scope - *os << "TAO_NAMESPACE_BEGIN (" << i->item ()->get_string () + // Leave the outermost root scope. + *os << "TAO_NAMESPACE_BEGIN (" << item_name << ")" << be_nl; } - i->next (); } - delete i; + return 0; } -// the following needs to be done to deal with the most bizarre behavior of -// MSVC++ compiler +// The following needs to be done to deal until the MSVC compiler's broken +// handling of namespaces is fixed (hopefully forthcoming in version 7). int be_visitor_typecode_defn::gen_nested_namespace_end (be_module *node) { TAO_OutStream *os = this->ctx_->stream (); - UTL_IdListActiveIterator *i; - i = new UTL_IdListActiveIterator (node->name ()); - while (!(i->is_done ())) + for (UTL_IdListActiveIterator i (node->name ()); !i.is_done (); i.next ()) { - if (ACE_OS::strcmp (i->item ()->get_string (), "") != 0) + if (ACE_OS::strcmp (i.item ()->get_string (), "") != 0) { - // leave the outermost root scope + // Leave the outermost root scope. *os << "TAO_NAMESPACE_END" << be_nl; } - i->next (); } - delete i; + return 0; } -// the visit methods will be called for the top-level node whose typecode is -// being generated +// The visit methods will be called for the top-level node whose typecode is +// being generated. int be_visitor_typecode_defn::visit_type (be_type *node) @@ -3635,7 +3638,7 @@ be_visitor_typecode_defn:: queue_lookup (ACE_Unbounded_Queue <be_visitor_typecode_defn::QNode *> &queue, be_type *node) { - for (ACE_Unbounded_Queue_Iterator<be_visitor_typecode_defn::QNode *> + for (ACE_Unbounded_Queue_Iterator<be_visitor_typecode_defn::QNode *> iter (queue); !iter.done (); iter.advance ()) @@ -3647,7 +3650,7 @@ queue_lookup (ACE_Unbounded_Queue <be_visitor_typecode_defn::QNode *> &queue, if (!ACE_OS::strcmp (item->node->full_name (), node->full_name ())) { - // found + // Found. return item; } } diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp index 35b1e72e90c..00d1fcd1659 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp @@ -18,17 +18,17 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_union.h" +#include "be_visitor_typecode/typecode_defn.h" ACE_RCSID(be_visitor_union, union_cs, "$Id$") // ****************************************************** -// for client stubs +// For client stubs. // ****************************************************** be_visitor_union_cs::be_visitor_union_cs (be_visitor_context *ctx) @@ -40,22 +40,23 @@ be_visitor_union_cs::~be_visitor_union_cs (void) { } -// visit the Union_cs node and its scope +// Visit the Union_cs node and its scope. int be_visitor_union_cs::visit_union (be_union *node) { - TAO_OutStream *os; // output stream - be_type *bt; // for discriminant type + TAO_OutStream *os; + be_type *bt = 0; if (!node->cli_stub_gen () && !node->imported ()) { os = this->ctx_->stream (); be_visitor_context ctx (*this->ctx_); - // the discriminant type may have to be defined here if it was an enum + // The discriminant type may have to be defined here if it was an enum // declaration inside of the union statement. We need to generate its - // typecode + // typecode. bt = be_type::narrow_from_decl (node->disc_type ()); + if (!bt) { ACE_ERROR_RETURN ((LM_ERROR, @@ -64,49 +65,44 @@ int be_visitor_union_cs::visit_union (be_union *node) "bad discriminant type\n"), -1); } - ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CS); // 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_cs::" - "visit_union - " - "bad visitor\n"), -1); - } - // generate code for the discriminant - if (bt->accept (visitor) == -1) + ctx.state (TAO_CodeGen::TAO_UNION_DISCTYPEDEFN_CS); + be_visitor_union_discriminant_cs disc_visitor (&ctx); + + if (bt->accept (&disc_visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_cs::" "visit union - " - "codegen for discrminant failed\n"), -1); + "codegen for discrminant failed\n"), + -1); } - // first generate code for any of the members (if required, e.g., - // anonymous sequences, structs, unions, arrays) - this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_CS); // set current code - // gen state + // First generate code for any of the members (if required, e.g., + // anonymous sequences, structs, unions, arrays). + this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_CS); + if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_cs" "visit_union - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } - // now generate the operations on the union such as the copy constructor - // and the assignment operator + // Now generate the operations on the union such as the copy constructor + // and the assignment operator. *os << "// *************************************************************" << be_nl; - *os << "// Operations for union " << node->name () << be_nl; + *os << "// Operations for union " << node->name () << be_nl + << "// TAO_IDL - Generated from" << be_nl + << "// " << __FILE__ << ":" << __LINE__ << be_nl; *os << "// *************************************************************\n\n"; - // generate the copy constructor and the assignment operator here + // Generate the copy constructor and the assignment operator here. os->indent (); - *os << "// default constructor" << be_nl - << node->name () << "::" << node->local_name () << " (void)" << be_nl + *os << node->name () << "::" << node->local_name () << " (void)" << be_nl << "{" << be_idt_nl << "ACE_OS::memset (&this->disc_, 0, sizeof (this->disc_));" << be_nl << "ACE_OS::memset (&this->u_, 0, sizeof (this->u_));" << be_nl @@ -118,8 +114,6 @@ int be_visitor_union_cs::visit_union (be_union *node) // the Any destructor's call to deep_free() will work properly. UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); - // @@ What if there is no first element?! - // Just get the union's first member. AST_Decl *d = si.item (); @@ -143,16 +137,14 @@ int be_visitor_union_cs::visit_union (be_union *node) this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); - // So we know we are generating the copy constructor + // So we know we are generating the copy constructor. this->ctx_->sub_state (TAO_CodeGen::TAO_UNION_COPY_CONSTRUCTOR); - *os << "// copy constructor" << be_nl; *os << node->name () << "::" << node->local_name () << " (const ::" << node->name () << " &u)" << be_nl; *os << "{" << be_idt_nl; *os << "this->disc_ = u.disc_;" << be_nl; - // now switch based on the disc value *os << "switch (this->disc_)" << be_nl; *os << "{" << be_idt_nl; @@ -161,7 +153,8 @@ int be_visitor_union_cs::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_cs" "visit_union - " - "codegen for copy ctor failed\n"), -1); + "codegen for copy ctor failed\n"), + -1); } // If there is no explicit default case, but there @@ -188,24 +181,26 @@ int be_visitor_union_cs::visit_union (be_union *node) << "}" << 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 - << "}\n" << 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 + << "}\n" << be_nl; + } this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_ASSIGN_CS); // Reset this for generating the assignment operator. this->ctx_->sub_state (TAO_CodeGen::TAO_SUB_STATE_UNKNOWN); - // assignment operator + // Assignment operator. os->indent (); *os << "// assignment operator" << be_nl; - *os << node->name () << " &" << be_nl; // return type + *os << node->name () << " &" << be_nl; *os << node->name () << "::operator= (const ::" << node->name () << " &u)" << be_nl; *os << "{" << be_idt_nl; @@ -226,7 +221,8 @@ int be_visitor_union_cs::visit_union (be_union *node) ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_cs" "visit_union - " - "codegen for assign op failed\n"), -1); + "codegen for assign op failed\n"), + -1); } // If there is no explicit default case, but there @@ -249,7 +245,7 @@ int be_visitor_union_cs::visit_union (be_union *node) *os << "return *this;" << be_uidt_nl; *os << "}\n\n"; - // the reset method + // The reset method. this->ctx_->state (TAO_CodeGen::TAO_UNION_PUBLIC_RESET_CS); os->indent (); *os << "// reset method to reset old values of a union" << be_nl; @@ -258,12 +254,14 @@ int be_visitor_union_cs::visit_union (be_union *node) *os << "{" << be_idt_nl; *os << "switch (this->disc_)" << be_nl; *os << "{" << be_idt_nl; + if (this->visit_scope (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_cs" "visit_union - " - "codegen for reset failed\n"), -1); + "codegen for reset failed\n"), + -1); } // If there is no explicit default case, but there @@ -283,27 +281,26 @@ int be_visitor_union_cs::visit_union (be_union *node) *os << be_uidt_nl << "}" << be_uidt_nl << "}\n\n"; - if (!node->is_local ()) + if (!node->is_local () && 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); - if (!visitor || (node->accept (visitor) == -1)) + + be_visitor_typecode_defn tc_visitor (&ctx); + + if (tc_visitor.visit_union (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_cs::" "visit_union - " - "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_union_branch/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp index 892973d5b95..6545710d540 100644 --- a/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp @@ -18,107 +18,120 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" - +#include "idl.h" +#include "idl_extern.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_ci, "$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_ci::be_visitor_union_branch_cdr_op_ci (be_visitor_context *ctx) +be_visitor_union_branch_cdr_op_ci::be_visitor_union_branch_cdr_op_ci ( + be_visitor_context *ctx + ) : be_visitor_decl (ctx) { } -// destructor be_visitor_union_branch_cdr_op_ci::~be_visitor_union_branch_cdr_op_ci (void) { } -// visit the union_branch node +// Visit the union_branch node. int be_visitor_union_branch_cdr_op_ci::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_ci::" "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_ci::" "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_ci::visit_array (be_array *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the union_branch node + // Retrieve the union_branch node. be_union_branch *f = this->ctx_->be_node_as_union_branch (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_array - " - "cannot retrieve union_branch node\n" - ), -1); + "cannot retrieve union_branch node\n"), + -1); } - // for anonymous arrays, the type name has a _ prepended. We compute the + // For anonymous arrays, the type name has a _ prepended. We compute the // fullname with or without the underscore and use it later on. char fname [NAMEBUFSIZE]; // to hold the full and - // save the node's local name and full name in a buffer for quick - // use later on - 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 && node->is_child (this->ctx_->scope ())) { - // for anonymous arrays ... + // 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 + // Typedefed node. ACE_OS::sprintf (fname, "%s", node->full_name ()); } - // 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 ()) { @@ -147,70 +160,61 @@ be_visitor_union_branch_cdr_op_ci::visit_array (be_array *node) // This is done in cdr_op_cs.cpp and hacked into *.i. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_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. + // This is the case for anonymous arrays. - // 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 + ctx.node (node); - // first generate the declaration + // First generate the declaration. 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_union_branch_cdr_op_ci::" - "visit_array - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_array_cdr_op_ci visitor (&ctx); + + if (visitor.visit_array (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_array - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit enum type int be_visitor_union_branch_cdr_op_ci::visit_enum (be_enum *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the union_branch node + // Retrieve the union_branch node be_union_branch *f = this->ctx_->be_node_as_union_branch (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_array - " - "cannot retrieve union_branch node\n" - ), -1); + "cannot retrieve union_branch 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 ()) { @@ -232,69 +236,60 @@ be_visitor_union_branch_cdr_op_ci::visit_enum (be_enum *node) 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_union_branch_cdr_op_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 + // Not a typedef and node is defined inside the union. Otherwise the cdr + // operator is generated elsewhere. + 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 + // 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_union_branch_cdr_op_ci::" - "visit_enum - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_enum_cdr_op_ci visitor (&ctx); + + if (visitor.visit_enum (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_enum - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit interface type int be_visitor_union_branch_cdr_op_ci::visit_interface (be_interface *node) { TAO_OutStream *os = this->ctx_->stream (); - // retrieve the union_branch node + // Retrieve the union_branch node. be_union_branch *f = this->ctx_->be_node_as_union_branch (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_interface - " - "cannot retrieve union_branch node\n" - ), -1); + "cannot retrieve union_branch 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 ()) { @@ -316,39 +311,40 @@ be_visitor_union_branch_cdr_op_ci::visit_interface (be_interface *node) 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 cannot be declared inside a + // union. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_interface - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } + return 0; } -// visit interface forward type int be_visitor_union_branch_cdr_op_ci::visit_interface_fwd (be_interface_fwd *node) { TAO_OutStream *os = this->ctx_->stream (); - // retrieve the union_branch node + // Retrieve the union_branch node. be_union_branch *f = this->ctx_->be_node_as_union_branch (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_interface_fwd - " - "cannot retrieve union_branch node\n" - ), -1); + "cannot retrieve union_branch 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 ()) { @@ -370,40 +366,40 @@ be_visitor_union_branch_cdr_op_ci::visit_interface_fwd (be_interface_fwd *node) 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 cannot be forward declared + // inside a union. break; default: - // error + // Error. ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_interface_fwd - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } + return 0; } -// visit predefined type int be_visitor_union_branch_cdr_op_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 union_branch node + // Retrieve the union_branch node. be_union_branch *f = this->ctx_->be_node_as_union_branch (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_predefined_type - " - "cannot retrieve union_branch node\n" - ), -1); + "cannot retrieve union_branch 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 ()) { @@ -411,11 +407,16 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no if (node->pt () == AST_PredefinedType::PT_pseudo) { - if (!ACE_OS::strcmp (node->local_name ()->get_string (), "TypeCode")) - *os << "CORBA::TypeCode_var _tao_union_tmp;" << be_nl; + char *local_name = node->local_name ()->get_string (); - else if (!ACE_OS::strcmp (node->local_name ()->get_string (), "Object")) - *os << "CORBA::Object_var _tao_union_tmp;" << be_nl; + if (!ACE_OS::strcmp (local_name, "TypeCode")) + { + *os << "CORBA::TypeCode_var _tao_union_tmp;" << be_nl; + } + else if (!ACE_OS::strcmp (local_name, "Object")) + { + *os << "CORBA::Object_var _tao_union_tmp;" << be_nl; + } //@@TODO - case for ValueBase. @@ -426,52 +427,58 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no } else if (node->pt () == AST_PredefinedType::PT_char) - *os << "CORBA::Char _tao_union_tmp;" << be_nl - << "CORBA::Any::to_char _tao_union_helper " - << "(_tao_union_tmp);" << be_nl - << "result = strm >> _tao_union_helper;" << be_nl - << "if (result)" << be_idt_nl - << "{" << be_idt_nl - << "_tao_union." << f->local_name () - << " (_tao_union_tmp);"; - + { + *os << "CORBA::Char _tao_union_tmp;" << be_nl + << "CORBA::Any::to_char _tao_union_helper " + << "(_tao_union_tmp);" << be_nl + << "result = strm >> _tao_union_helper;" << be_nl + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." << f->local_name () + << " (_tao_union_tmp);"; + } else if (node->pt () == AST_PredefinedType::PT_wchar) - *os << "CORBA::WChar _tao_union_tmp;" << be_nl - << "CORBA::Any::to_wchar _tao_union_helper " - << "(_tao_union_tmp);" << be_nl - << "result = strm >> _tao_union_helper;" << be_nl - << "if (result)" << be_idt_nl - << "{" << be_idt_nl - << "_tao_union." << f->local_name () - << " (_tao_union_tmp);"; - + { + *os << "CORBA::WChar _tao_union_tmp;" << be_nl + << "CORBA::Any::to_wchar _tao_union_helper " + << "(_tao_union_tmp);" << be_nl + << "result = strm >> _tao_union_helper;" << be_nl + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." << f->local_name () + << " (_tao_union_tmp);"; + } else if (node->pt () == AST_PredefinedType::PT_octet) - *os << "CORBA::Octet _tao_union_tmp;" << be_nl - << "CORBA::Any::to_octet _tao_union_helper " - << "(_tao_union_tmp);" << be_nl - << "result = strm >> _tao_union_helper;" << be_nl - << "if (result)" << be_idt_nl - << "{" << be_idt_nl - << "_tao_union." << f->local_name () - << " (_tao_union_tmp);"; - + { + *os << "CORBA::Octet _tao_union_tmp;" << be_nl + << "CORBA::Any::to_octet _tao_union_helper " + << "(_tao_union_tmp);" << be_nl + << "result = strm >> _tao_union_helper;" << be_nl + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." << f->local_name () + << " (_tao_union_tmp);"; + } else if (node->pt () == AST_PredefinedType::PT_boolean) - *os << "CORBA::Boolean _tao_union_tmp;" << be_nl - << "CORBA::Any::to_boolean _tao_union_helper " - << "(_tao_union_tmp);" << be_nl - << "result = strm >> _tao_union_helper;" << be_nl - << "if (result)" << be_idt_nl - << "{" << be_idt_nl - << "_tao_union." << f->local_name () - << " (_tao_union_tmp);"; - + { + *os << "CORBA::Boolean _tao_union_tmp;" << be_nl + << "CORBA::Any::to_boolean _tao_union_helper " + << "(_tao_union_tmp);" << be_nl + << "result = strm >> _tao_union_helper;" << be_nl + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." << f->local_name () + << " (_tao_union_tmp);"; + } else - *os << node->name () << " _tao_union_tmp;" << be_nl - << "result = strm >> _tao_union_tmp;" << be_nl - << "if (result)" << be_idt_nl - << "{" << be_idt_nl - << "_tao_union." << f->local_name () - << " (_tao_union_tmp);"; + { + *os << node->name () << " _tao_union_tmp;" << be_nl + << "result = strm >> _tao_union_tmp;" << be_nl + << "if (result)" << be_idt_nl + << "{" << be_idt_nl + << "_tao_union." << f->local_name () + << " (_tao_union_tmp);"; + } *os << be_nl; *os << "_tao_union._d (_tao_discriminant);" << be_uidt_nl; @@ -482,34 +489,48 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no case TAO_CodeGen::TAO_CDR_OUTPUT: *os << "result = "; + if (node->pt () == AST_PredefinedType::PT_pseudo) - *os << "strm << _tao_union." << f->local_name () << " ();"; + { + *os << "strm << _tao_union." << f->local_name () << " ();"; + } else if (node->pt () == AST_PredefinedType::PT_char) - *os << "strm << CORBA::Any::from_char (_tao_union." - << f->local_name () << " ());"; + { + *os << "strm << CORBA::Any::from_char (_tao_union." + << f->local_name () << " ());"; + } else if (node->pt () == AST_PredefinedType::PT_wchar) - *os << "strm << CORBA::Any::from_wchar (_tao_union." - << f->local_name () << " ());"; + { + *os << "strm << CORBA::Any::from_wchar (_tao_union." + << f->local_name () << " ());"; + } else if (node->pt () == AST_PredefinedType::PT_octet) - *os << "strm << CORBA::Any::from_octet (_tao_union." - << f->local_name () << " ());"; + { + *os << "strm << CORBA::Any::from_octet (_tao_union." + << f->local_name () << " ());"; + } else if (node->pt () == AST_PredefinedType::PT_boolean) - *os << "strm << CORBA::Any::from_boolean (_tao_union." - << f->local_name () << " ());"; + { + *os << "strm << CORBA::Any::from_boolean (_tao_union." + << f->local_name () << " ());"; + } else - *os << "strm << _tao_union." << f->local_name () << " ();"; + { + *os << "strm << _tao_union." << f->local_name () << " ();"; + } + 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_union_branch_cdr_op_ci::" "visit_array - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } return 0; @@ -518,10 +539,9 @@ be_visitor_union_branch_cdr_op_ci::visit_predefined_type (be_predefined_type *no int be_visitor_union_branch_cdr_op_ci::visit_sequence (be_sequence *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the union_branch node + // Retrieve the union_branch node. be_union_branch *f = this->ctx_->be_node_as_union_branch (); if (!f) { @@ -532,7 +552,7 @@ be_visitor_union_branch_cdr_op_ci::visit_sequence (be_sequence *node) ), -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 ()) { @@ -570,72 +590,60 @@ be_visitor_union_branch_cdr_op_ci::visit_sequence (be_sequence *node) 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_union_branch_cdr_op_ci::" "visit_sequence - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } + // Not a typedef and node is defined inside the union. 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 + // 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_CI); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_union_branch_cdr_op_ci::" - "visit_sequence - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_sequence_cdr_op_ci visitor (&ctx); + + if (visitor.visit_sequence (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_sequence - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit string type int be_visitor_union_branch_cdr_op_ci::visit_string (be_string *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the union_branch node + // Retrieve the union_branch node. be_union_branch *f = this->ctx_->be_node_as_union_branch (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_string - " - "cannot retrieve union_branch node\n" - ), -1); + "cannot retrieve union_branch 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 ()) { @@ -665,38 +673,38 @@ be_visitor_union_branch_cdr_op_ci::visit_string (be_string *node) 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_union_branch_cdr_op_ci::" "visit_array - " - "bad sub state\n" - ), -1); + "bad sub state\n"), + -1); } return 0; } -// visit structure type int be_visitor_union_branch_cdr_op_ci::visit_structure (be_structure *node) { TAO_OutStream *os = this->ctx_->stream (); - // retrieve the union_branch node + // Retrieve the union_branch node. be_union_branch *f = this->ctx_->be_node_as_union_branch (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_structure - " - "cannot retrieve union_branch node\n" - ), -1); + "cannot retrieve union_branch 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 ()) { @@ -718,92 +726,80 @@ be_visitor_union_branch_cdr_op_ci::visit_structure (be_structure *node) 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_union_branch_cdr_op_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 + // Not a typedef and node is defined inside the union. + 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 + // 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_union_branch_cdr_op_ci::" - "visit_struct - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_structure_cdr_op_ci visitor (&ctx); + + if (visitor.visit_structure (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_struct - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } -// visit typedef type int be_visitor_union_branch_cdr_op_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 typedef\n"), + -1); } this->ctx_->alias (0); return 0; } -// visit union type int be_visitor_union_branch_cdr_op_ci::visit_union (be_union *node) { - TAO_OutStream *os; // output stream - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); - // retrieve the union_branch node + // Retrieve the union_branch node. be_union_branch *f = this->ctx_->be_node_as_union_branch (); + if (!f) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_union - " - "cannot retrieve union_branch node\n" - ), -1); + "cannot retrieve union_branch 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 ()) { @@ -826,48 +822,38 @@ be_visitor_union_branch_cdr_op_ci::visit_union (be_union *node) 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_union_branch_cdr_op_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 + // Not a typedef and node is defined inside the union. + 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 + // 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_union_branch_cdr_op_ci::" - "visit_union - " - "Bad visitor\n" - ), -1); - } - if (node->accept (visitor) == -1) + be_visitor_union_cdr_op_ci visitor (&ctx); + + if (visitor.visit_union (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_union_branch_cdr_op_ci::" "visit_union - " - "codegen failed\n" - ), -1); + "codegen failed\n"), + -1); } - delete visitor; } + return 0; } @@ -882,9 +868,9 @@ be_visitor_union_branch_cdr_op_ci::explicit_default (void) be_union_branch *ub = be_union_branch::narrow_from_decl (this->ctx_->node ()); - int i = 0; // counter + int i = 0; - // instantiate a scope iterator. + // Instantiate a scope iterator. for (UTL_ScopeActiveIterator si (bu, UTL_Scope::IK_decls); !si.is_done (); si.next ()) @@ -894,7 +880,9 @@ be_visitor_union_branch_cdr_op_ci::explicit_default (void) AST_Decl *d = si.item (); if (!d->imported ()) - bub = be_union_branch::narrow_from_decl (d); + { + bub = be_union_branch::narrow_from_decl (d); + } if (bub == ub) { @@ -902,7 +890,7 @@ be_visitor_union_branch_cdr_op_ci::explicit_default (void) } else { - i++; + ++i; } } } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp index f0ec70cb55d..4688584e439 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp @@ -33,8 +33,9 @@ ACE_RCSID(be_visitor_valuetype, marshal_ch, "$Id$") // Structure visitor for generating declarations // *************************************************************************** -be_visitor_valuetype_marshal_ch::be_visitor_valuetype_marshal_ch -(be_visitor_context *ctx) +be_visitor_valuetype_marshal_ch::be_visitor_valuetype_marshal_ch ( + be_visitor_context *ctx + ) : be_visitor_scope (ctx) { } @@ -47,6 +48,7 @@ int be_visitor_valuetype_marshal_ch::visit_valuetype (be_valuetype *node) { this->elem_number_ = 0; + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next()) @@ -66,9 +68,8 @@ be_visitor_valuetype_marshal_ch::visit_valuetype (be_valuetype *node) if (field) { - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_valuetype_field_cdr_ch visitor (new_ctx); + be_visitor_context ctx (*this->ctx_); + be_visitor_valuetype_field_cdr_ch visitor (&ctx); visitor.pre_ = node->field_pd_prefix (); visitor.post_ = node->field_pd_postfix (); diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp index 9168a640ac6..92a1bd49915 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp @@ -152,43 +152,52 @@ be_visitor_valuetype_marshal_cs::gen_fields (be_valuetype *node, be_visitor_context &ctx) { int n_processed = 0; - TAO_OutStream *os = ctx.stream (); - this->elem_number_ = 0; - // initialize an iterator to iterate thru our scope + + // Initialize an iterator to iterate thru our scope. for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); !si.is_done (); si.next()) { AST_Decl *d = si.item (); + if (!d) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); + "bad node in this scope\n"), + -1); } be_field *field = be_field::narrow_from_decl (d); + if (field) { if (n_processed > 0) - *os << " &&" << be_nl; + { + *os << " &&" << be_nl; + } + ++n_processed; - be_visitor_context* new_ctx = - new be_visitor_context (ctx); - be_visitor_valuetype_field_cdr_ci visitor (new_ctx); + be_visitor_valuetype_field_cdr_ci visitor (&ctx); visitor.pre_ = node->field_pd_prefix (); visitor.post_ = node->field_pd_postfix (); + if (visitor.visit_field (field) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_marshal_cs::" "visit_valuetype - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } } } + if (n_processed == 0) - *os << "1"; + { + *os << "1"; + } + return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp index c468e7a18ea..de056427da8 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp @@ -19,11 +19,8 @@ // // ============================================================================ -//#include "idl.h" -//#include "idl_extern.h" -//#include "be.h" - #include "be_visitor_valuetype.h" +#include "be_visitor_field.h" ACE_RCSID(be_visitor_valuetype, valuetype, "$Id$") @@ -36,22 +33,20 @@ be_visitor_valuetype::~be_visitor_valuetype (void) { } -// this method must be overridden by the derived valuetype visitors +// This method must be overridden by the derived valuetype visitors. int be_visitor_valuetype::visit_valuetype (be_valuetype *) { -//! ACE_ASSERT (0); return -1; } -// visit the scope of the valuetype node -// (in public/private field order) 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); !si.is_done (); si.next()) @@ -62,7 +57,8 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); + "bad node in this scope\n"), + -1); } AST_Field *field = AST_Field::narrow_from_decl (d); @@ -89,12 +85,14 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); + "codegen for scope failed\n"), + -1); } } // end of for loop this->elem_number_ = 0; + for (UTL_ScopeActiveIterator sj (node, UTL_Scope::IK_decls); !sj.is_done (); sj.next()) @@ -105,15 +103,17 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); + "bad node in this scope\n"), + -1); } AST_Field *field = AST_Field::narrow_from_decl (d); - if (!field || - (field && field->visibility() != AST_Field::vis_PRIVATE)) + if (!field + || (field && field->visibility () != AST_Field::vis_PRIVATE)) { - continue; // only private fields in this run + // Only private fields. + continue; } ++ n_processed; @@ -124,13 +124,13 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) } 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 + // Set the node to be visited. this->ctx_->node (bd); this->elem_number_++; @@ -146,101 +146,136 @@ be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) return 0; } -// this two are called from visit_valuetype_scope() +// These two are called from visit_valuetype_scope() void be_visitor_valuetype::begin_public () { - // in derived visitors print "public:" in class definition + // In derived visitors print "public:" in class definition } void be_visitor_valuetype::begin_private () { - // in derived visitors print "protected:" in class definition + // In derived visitors print "protected:" in class definition } -// =all common visit methods for valuetype visitor +// All common visit methods for valuetype visitor. -// visit an attribute int be_visitor_valuetype::visit_attribute (be_attribute *node) -// was be_visitor_attribute::visit_attribute (be_attribute *node) { - this->ctx_->node (node); // save the node - this->ctx_->attribute (node); // save this 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; - - // first the "get" operation - op = new be_operation (node->field_type (), - AST_Operation::OP_noflags, - node->name (), - 0, - 0); op->set_name ((UTL_IdList *) node->name ()->copy ()); + if (!op || this->visit_operation (op) == -1) { delete op; + op = 0; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "codegen for get_attribute failed\n"), -1); } + delete op; + op = 0; + if (node->readonly ()) - return 0; // nothing else to do - - // the set method. - // the return type is "void" - be_predefined_type *rt = - new be_predefined_type (AST_PredefinedType::PT_void, - new UTL_ScopedName (new Identifier ("void"), - 0)); - // argument type is the same as the attribute type - be_argument *arg = new be_argument (AST_Argument::dir_IN, - node->field_type (), - node->name ()); + { + // Nothing else to do. + return 0; + } + + // The set method. + // The return type is "void". + + Identifier *id = 0; + UTL_ScopedName *sn = 0; + + ACE_NEW_RETURN (id, + Identifier ("void"), + -1); + + 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); + + // 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); + arg->set_name ((UTL_IdList *) node->name ()->copy ()); - // create the operation - op = new be_operation (rt, - AST_Operation::OP_noflags, - node->name (), - 0, - 0); + + // 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) { delete op; + op = 0; delete arg; + arg = 0; delete rt; + rt = 0; ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_attribute::" "visit_attribute - " "codegen for set_attribute failed\n"), -1); } + delete op; + op = 0; delete rt; + rt = 0; delete arg; + arg = 0; return 0; } -// visit a constant 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 + // 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 + // This switch is acceptable rather than having derived visitors overriding + // this method and differing only in what state they set. switch (this->ctx_->state ()) { @@ -264,52 +299,51 @@ be_visitor_valuetype::visit_constant (be_constant *node) case TAO_CodeGen::TAO_VALUETYPE_IS: case TAO_CodeGen::TAO_VALUETYPE_SI: case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done + return 0; // Nothing to be done. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_constant - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_constant - " - "NUL visitor\n" - ), -1); + "NULL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_constant - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; return 0; } -//visit an enum int be_visitor_valuetype::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 + ctx.node (node); - // this switch is acceptable rather than having derived visitors overriding - // this method and differing only in what state they set + // This switch is acceptable rather than having derived visitors overriding + // this method and differing only in what state they set. switch (this->ctx_->state ()) { @@ -343,61 +377,59 @@ be_visitor_valuetype::visit_enum (be_enum *node) case TAO_CodeGen::TAO_VALUETYPE_IS: case TAO_CodeGen::TAO_VALUETYPE_SI: case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done + return 0; // Nothing to be done. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_enum - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_enum - " - "NUL visitor\n" - ), -1); + "NULL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_enum - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; return 0; } -// visit an operation int be_visitor_valuetype::visit_operation (be_operation *) { - // is overridden in derived visitors + // Is overridden in derived visitors. return 0; } -// visit an exception (not used) 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 + // 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 + // This switch is acceptable rather than having derived visitors overriding + // this method and differing only in what state they set. switch (this->ctx_->state ()) { @@ -442,52 +474,51 @@ be_visitor_valuetype::visit_exception (be_exception *node) case TAO_CodeGen::TAO_VALUETYPE_INIT_CI: case TAO_CodeGen::TAO_VALUETYPE_INIT_CS: case TAO_CodeGen::TAO_VALUETYPE_INIT_ARGLIST_CH: - return 0; // nothing to be done + return 0; // Nothing to be done. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_interface::" "visit_exception - " - "Bad context state\n" - ), -1); + "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_exception - " - "NUL visitor\n" - ), -1); + "NULL 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); + "failed to accept visitor\n"), + -1); } + delete visitor; return 0; } -// visit a structure 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 + // 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 + // This switch is acceptable rather than having derived visitors overriding + // this method and differing only in what state they set. switch (this->ctx_->state ()) { @@ -523,52 +554,51 @@ be_visitor_valuetype::visit_structure (be_structure *node) case TAO_CodeGen::TAO_VALUETYPE_IS: case TAO_CodeGen::TAO_VALUETYPE_SI: case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done + return 0; // Nothing to be done. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_structure - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_structure - " - "NUL visitor\n" - ), -1); + "NULL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_structure - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; return 0; } -// visit a union 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 + // 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 + // This switch is acceptable rather than having derived visitors overriding + // this method and differing only in what state they set. switch (this->ctx_->state ()) { @@ -604,52 +634,51 @@ be_visitor_valuetype::visit_union (be_union *node) case TAO_CodeGen::TAO_VALUETYPE_IS: case TAO_CodeGen::TAO_VALUETYPE_SI: case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done + return 0; // Nothing to be done. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_union - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_union - " - "NUL visitor\n" - ), -1); + "NULL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_union - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; return 0; } -// visit a typedef 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 + // 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 + // This switch is acceptable rather than having derived visitors overriding + // this method and differing only in what state they set. switch (this->ctx_->state ()) { @@ -685,36 +714,37 @@ be_visitor_valuetype::visit_typedef (be_typedef *node) case TAO_CodeGen::TAO_VALUETYPE_IS: case TAO_CodeGen::TAO_VALUETYPE_SI: case TAO_CodeGen::TAO_VALUETYPE_SS: - return 0; // nothing to be done + return 0; // Nothing to be done. default: { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_typedef - " - "Bad context state\n" - ), -1); + "Bad context state\n"), + -1); } } be_visitor *visitor = tao_cg->make_visitor (&ctx); + if (!visitor) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_typedef - " - "NUL visitor\n" - ), -1); + "NULL visitor\n"), + -1); } - // let the node accept this visitor if (node->accept (visitor) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype::" "visit_typedef - " - "failed to accept visitor\n" - ), -1); + "failed to accept visitor\n"), + -1); } + delete visitor; return 0; } @@ -722,12 +752,12 @@ be_visitor_valuetype::visit_typedef (be_typedef *node) int be_visitor_valuetype::visit_field (be_field *) { - // is overridden in derived visitors + // Is overridden in derived visitors. return 0; } -// private data fields for scope +// Private data fields for scope. int be_visitor_valuetype::gen_pd (be_valuetype *node) { @@ -740,21 +770,24 @@ be_visitor_valuetype::gen_pd (be_valuetype *node) si.next()) { AST_Decl *d = si.item (); + if (!d) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); + "bad node in this scope\n"), + -1); } be_field *field = be_field::narrow_from_decl (d); + if (!field) { continue; } - ++ n_processed; - // set the scope node as "node" in which the code is being + ++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 + // for code generation. this->ctx_->scope (node->decl ()); @@ -766,101 +799,85 @@ be_visitor_valuetype::gen_pd (be_valuetype *node) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); - + "codegen for scope failed\n"), + -1); } } + return 0; } -// private data for field +// Private data for field. int be_visitor_valuetype::gen_field_pd (be_field *node) -// derived from be_visitor_field_ch { - TAO_OutStream *os; // output stream - be_type *bt; // field's type - be_valuetype *vt; // field declared in this scope + TAO_OutStream *os = this->ctx_->stream (); + be_type *bt; + be_valuetype *vt; os = this->ctx_->stream (); - // first generate the type information + // First generate the type information. bt = be_type::narrow_from_decl (node->field_type ()); vt = be_valuetype::narrow_from_scope (node->defined_in ()); + if (!bt || !vt) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" "visit_field - " - "Bad field type\n" - ), -1); + "Bad field type\n"), + -1); } - // 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); ctx.sub_state (TAO_CodeGen::TAO_USE_FULL_NAME); ctx.state (TAO_CodeGen::TAO_FIELD_CH); - be_visitor *visitor = tao_cg->make_visitor (&ctx); - if (!visitor) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_structure::" - "visit_field - " - "NUL visitor\n" - ), -1); - } + be_visitor_field_ch visitor (&ctx); - // let the node accept this visitor - if (bt->accept (visitor) == -1) + if (visitor.visit_field (node) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_field_ch::" "visit_field - " - "codegen for field type failed\n" - ), -1); + "codegen for field type failed\n"), + -1); } - delete visitor; - // now output the field name. + // Now output the field name. *os << " " << vt->field_pd_prefix () << node->local_name () << vt->field_pd_postfix() << ";" << be_nl; return 0; - } -// generate the _init definition +// Generate the _init definition. int be_visitor_valuetype::gen_init_defn (be_valuetype *node) { if (node->is_abstract_valuetype ()) - return 0; // no instance of it can created - - TAO_OutStream *os; // output stream + { + return 0; + } - os = this->ctx_->stream (); + TAO_OutStream *os = this->ctx_->stream (); *os << "class " << be_global->stub_export_macro () << " " << node->local_name () << "_init : public CORBA_ValueFactoryBase" << be_nl; - // generate the body - + // Generate the body. *os << "{" << be_nl << "public:" << be_idt_nl << "virtual ~" << node->local_name () << "_init ();" << be_nl; - /* %! << "static " << node->local_name () << "* " - << "_downcast (CORBA::ValueFactoryBase* );" << be_nl */ - *os << "virtual const char* tao_repository_id (void);\n" << be_nl; - *os << "// create () goes here" << be_nl; // %! - + *os << "// create () goes here" << be_nl; *os << be_uidt_nl << "};" << be_nl; return 0; @@ -870,23 +887,31 @@ int be_visitor_valuetype::gen_init_impl (be_valuetype *node) { if (node->is_abstract_valuetype ()) - return 0; // no instance of it can created - - TAO_OutStream *os; // output stream + { + return 0; + } - os = this->ctx_->stream (); - os->indent (); // start with whatever indentation level we are at + TAO_OutStream *os = this->ctx_->stream (); + os->indent (); char fname [NAMEBUFSIZE]; // to hold the full and char lname [NAMEBUFSIZE]; // local _out names - ACE_OS::memset (fname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (fname, "%s_init", node->full_name ()); - - ACE_OS::memset (lname, '\0', NAMEBUFSIZE); - ACE_OS::sprintf (lname, "%s_init", node->local_name ()); - - // destructor + ACE_OS::memset (fname, + '\0', + NAMEBUFSIZE); + ACE_OS::sprintf (fname, + "%s_init", + node->full_name ()); + + ACE_OS::memset (lname, + '\0', + NAMEBUFSIZE); + ACE_OS::sprintf (lname, + "%s_init", + node->local_name ()); + + // Destructor. *os << fname << "::~" << lname << " (void)" << be_nl << "{" << be_nl << "}\n\n"; @@ -897,7 +922,6 @@ be_visitor_valuetype::gen_init_impl (be_valuetype *node) << "::_tao_obv_static_repository_id ();" << be_uidt_nl << "}\n\n"; - return 0; } @@ -911,21 +935,21 @@ be_visitor_valuetype::determine_factory_style (be_valuetype* node) return factory_style; } - // Check whether we have at least one operation or not + // Check whether we have at least one operation or not. idl_bool have_operation = be_visitor_valuetype::have_operation(node); idl_bool have_factory = 0; - // Try only our own scope + // Try only our own scope. if (node->nmembers () > 0) { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator si (node, - UTL_Scope::IK_decls); - + // Initialize an iterator to iterate thru our scope // Continue until each element is visited. - for (; !si.is_done (); si.next()) + for (UTL_ScopeActiveIterator si (node, + UTL_Scope::IK_decls); + !si.is_done (); + si.next()) { AST_Decl *d = si.item (); @@ -969,7 +993,7 @@ be_visitor_valuetype::determine_factory_style (be_valuetype* node) idl_bool be_visitor_valuetype::have_operation(be_valuetype* node) { - // Check whatever scope we get for operations/attributes + // Check whatever scope we get for operations/attributes. if (node == 0) { @@ -983,19 +1007,19 @@ be_visitor_valuetype::have_operation(be_valuetype* node) // -derived (abstract VT | VT | abstract iface | iface) // - // First try our own scope + // First try our own scope. if (node->nmembers () > 0) { // Initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator si (node, - UTL_Scope::IK_decls); - // Continue until each element is checked. - for (; !si.is_done (); si.next()) + for (UTL_ScopeActiveIterator si (node, + UTL_Scope::IK_decls); + !si.is_done (); + si.next()) { AST_Decl *d = si.item (); - if (!d) + if (!d) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_valuetype_init::" @@ -1076,7 +1100,7 @@ be_visitor_valuetype::obv_need_ref_counter (be_valuetype* node) return 0; } - // now go thru our base VTs and see if one has already + // Now go thru our base VTs and see if one has already. int i; // loop index @@ -1108,7 +1132,7 @@ idl_bool be_visitor_valuetype::obv_have_ref_counter (be_valuetype* node) { - // just try to find a VT with concrete factory in inheritance tree + // Just try to find a VT with concrete factory in inheritance tree. if(node == 0) { return 0; @@ -1119,7 +1143,7 @@ be_visitor_valuetype::obv_have_ref_counter (be_valuetype* node) return 1; } - // now go thru our base VTs + // Now go thru our base VTs. int i; // loop index diff --git a/TAO/TAO_IDL/be_include/be_attribute.h b/TAO/TAO_IDL/be_include/be_attribute.h index 19d327edea0..882ee417deb 100644 --- a/TAO/TAO_IDL/be_include/be_attribute.h +++ b/TAO/TAO_IDL/be_include/be_attribute.h @@ -64,14 +64,13 @@ public: // Retrieve the underlying get_operation strategy. be_operation_strategy *get_set_strategy (void); - // Retrieve the underlying set operation strategy. + // Retrieve the underlying set_operation strategy. // Narrowing DEF_NARROW_METHODS2 (be_attribute, AST_Attribute, be_decl); DEF_NARROW_FROM_DECL (be_attribute); private: - be_operation_strategy *get_strategy_; be_operation_strategy *set_strategy_; diff --git a/TAO/TAO_IDL/fe/fe_interface_header.cpp b/TAO/TAO_IDL/fe/fe_interface_header.cpp index 0f4f085904b..527e673f11b 100644 --- a/TAO/TAO_IDL/fe/fe_interface_header.cpp +++ b/TAO/TAO_IDL/fe/fe_interface_header.cpp @@ -273,8 +273,8 @@ void FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, UTL_NameList *supports) { - UTL_NamelistActiveIterator *l = 0; AST_Decl *d = 0; + UTL_ScopedName *item; AST_Interface *i = 0; long j, k; UTL_NameList *nl = ifaces; @@ -293,22 +293,21 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, { if (nl != NULL) { - ACE_NEW (l, - UTL_NamelistActiveIterator (nl)); - - while (!l->is_done ()) + 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 (l->item ()); + idl_global->err ()->lookup_error (item); return; } // Look it up. UTL_Scope *s = idl_global->scopes ()->top (); - d = s->lookup_by_name (l->item (), + d = s->lookup_by_name (item, I_TRUE); if (d == 0) @@ -319,14 +318,14 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, { AST_Module *m = AST_Module::narrow_from_decl (sad); - d = m->look_in_previous (l->item ()->last_component ()); + d = m->look_in_previous (item->last_component ()); } } // Not found? if (d == 0) { - idl_global->err ()->lookup_error (l->item ()); + idl_global->err ()->lookup_error (item); return; } @@ -389,10 +388,7 @@ FE_InterfaceHeader::compile_inheritance (UTL_NameList *ifaces, // Next element in header list. ++ichecked; - l->next (); } - - delete l; } in_supports = 1; @@ -521,7 +517,7 @@ FE_Abstract_InterfaceHeader::is_abstract (void) return 1; } -// FE_obv_header +// FE_obv_header. FE_obv_header::FE_obv_header (UTL_ScopedName *n, UTL_NameList *nl, diff --git a/TAO/TAO_IDL/fe/idl.yy b/TAO/TAO_IDL/fe/idl.yy index 89476e2d6f2..73604a87d16 100644 --- a/TAO/TAO_IDL/fe/idl.yy +++ b/TAO/TAO_IDL/fe/idl.yy @@ -1286,7 +1286,6 @@ type_declarator : at_least_one_declarator { UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_DecllistActiveIterator *l; FE_Declarator *d = 0; AST_Typedef *t = 0; @@ -1296,9 +1295,8 @@ type_declarator : * enclosing scope */ if (s != 0 && $1 != 0 && $3 != 0) { - l = new UTL_DecllistActiveIterator ($3); - for (;!(l->is_done ()); l->next ()) { - d = l->item (); + for (UTL_DecllistActiveIterator l ($3); !l.is_done (); l.next ()) { + d = l.item (); if (d == 0) continue; AST_Type * tp = d->compose ($1); @@ -1310,7 +1308,6 @@ type_declarator : s->is_abstract ()); (void) s->fe_add_typedef (t); } - delete l; } } ; @@ -1614,7 +1611,6 @@ member_i: ';' { UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_DecllistActiveIterator *l = 0; FE_Declarator *d = 0; AST_Field *f = 0; @@ -1630,9 +1626,8 @@ member_i: * Add it to the enclosing scope */ else if (s != 0 && $1 != 0 && $3 != 0) { - l = new UTL_DecllistActiveIterator ($3); - for (;!(l->is_done ()); l->next ()) { - d = l->item (); + for (UTL_DecllistActiveIterator l ($3); !(l.is_done ()); l.next ()) { + d = l.item (); if (d == 0) continue; AST_Type *tp = d->compose ($1); @@ -1644,7 +1639,6 @@ member_i: $<vival>0); (void) s->fe_add_field (f); } - delete l; } } | error @@ -2333,7 +2327,6 @@ attribute: at_least_one_simple_declarator { UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_DecllistActiveIterator *l = 0; AST_Attribute *a = 0; FE_Declarator *d = 0; @@ -2343,9 +2336,8 @@ attribute: * enclosing scope */ if (s != 0 && $4 != 0 && $6 != 0) { - l = new UTL_DecllistActiveIterator ($6); - for (; !(l->is_done ()); l->next ()) { - d = l->item (); + for (UTL_DecllistActiveIterator l ($6); !l.is_done (); l.next ()) { + d = l.item (); if (d == 0) continue; AST_Type *tp = d->compose ($4); @@ -2361,7 +2353,6 @@ attribute: */ (void) s->fe_add_attribute (a); } - delete l; } } ; diff --git a/TAO/TAO_IDL/fe/y.tab.cpp b/TAO/TAO_IDL/fe/y.tab.cpp index 147f58d6e67..cd060235a96 100644 --- a/TAO/TAO_IDL/fe/y.tab.cpp +++ b/TAO/TAO_IDL/fe/y.tab.cpp @@ -1279,7 +1279,7 @@ tao_yyinrecovery: if (5 < tao_yydebug) printf("tao_yydebug: state %d, error recovery discards token %d (%s)\n", tao_yystate, tao_yychar, tao_yys); - else + else TAO_YYDEBUG_DISCARD_TOKEN(tao_yystate, tao_yychar, tao_yys, tao_yyssp-tao_yyss); } #endif @@ -2000,71 +2000,71 @@ case 110: break; case 114: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_or, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_or, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; case 116: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_xor, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_xor, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; case 118: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_and, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_and, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; case 120: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_left, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_left, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; case 121: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_right, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_right, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; case 123: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_add, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_add, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; case 124: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_minus, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_minus, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; case 126: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_mul, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_mul, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; case 127: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_div, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_div, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; case 128: { - tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_mod, - tao_yyvsp[-2].exval, + tao_yyval.exval = idl_global->gen ()->create_expr (AST_Expression::EC_mod, + tao_yyvsp[-2].exval, tao_yyvsp[0].exval); } break; @@ -2103,9 +2103,9 @@ case 133: /* * If the scoped name is an IDL constant, it may be used in an - * array dim, a string bound, or a sequence bound. If so, it + * array dim, a string bound, or a sequence bound. If so, it * must be unsigned and > 0. We assign the constant's value - * and type to the expression created here so we can check + * and type to the expression created here so we can check * them later. */ if (d != 0 && d->node_type () == AST_Decl::NT_const) @@ -2228,8 +2228,8 @@ case 145: if (good_expression) { - tao_yyval.exval = - idl_global->gen()->create_expr (tao_yyvsp[0].exval, + tao_yyval.exval = + idl_global->gen()->create_expr (tao_yyvsp[0].exval, AST_Expression::EV_ulong); } else @@ -2282,7 +2282,6 @@ break; case 153: { UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_DecllistActiveIterator *l; FE_Declarator *d = 0; AST_Typedef *t = 0; @@ -2292,21 +2291,19 @@ case 153: * enclosing scope */ if (s != 0 && tao_yyvsp[-2].dcval != 0 && tao_yyvsp[0].dlval != 0) { - l = new UTL_DecllistActiveIterator (tao_yyvsp[0].dlval); - for (;!(l->is_done ()); l->next ()) { - d = l->item (); + 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, + t = idl_global->gen ()->create_typedef (tp, d->name (), s->is_local (), s->is_abstract ()); (void) s->fe_add_typedef (t); } - delete l; } } break; @@ -2389,7 +2386,7 @@ case 182: break; case 183: { - tao_yyval.deval = new FE_Declarator (new UTL_ScopedName (tao_yyvsp[0].dcval->local_name (), + tao_yyval.deval = new FE_Declarator (new UTL_ScopedName (tao_yyvsp[0].dcval->local_name (), 0), FE_Declarator::FD_complex, tao_yyvsp[0].dcval); @@ -2545,7 +2542,6 @@ break; case 213: { UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_DecllistActiveIterator *l = 0; FE_Declarator *d = 0; AST_Field *f = 0; @@ -2554,28 +2550,26 @@ 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, + 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) { - l = new UTL_DecllistActiveIterator (tao_yyvsp[-2].dlval); - for (;!(l->is_done ()); l->next ()) { - d = l->item (); + 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 (), + f = idl_global->gen ()->create_field (tp, + d->name (), tao_yyvsp[-5].vival); (void) s->fe_add_field (f); } - delete l; } } break; @@ -2971,7 +2965,7 @@ case 258: 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 (), + e = idl_global->gen ()->create_enum_val (c->next_enum_val (), n); (void) s->fe_add_enum_val (e); } @@ -3185,11 +3179,11 @@ case 277: * 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, + 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, + tao_yyvsp[0].elval->length (), + tao_yyvsp[0].elval, + 0, 0); } } @@ -3251,7 +3245,6 @@ break; case 286: { UTL_Scope *s = idl_global->scopes ()->top_non_null (); - UTL_DecllistActiveIterator *l = 0; AST_Attribute *a = 0; FE_Declarator *d = 0; @@ -3261,9 +3254,8 @@ case 286: * enclosing scope */ if (s != 0 && tao_yyvsp[-2].dcval != 0 && tao_yyvsp[0].dlval != 0) { - l = new UTL_DecllistActiveIterator (tao_yyvsp[0].dlval); - for (; !(l->is_done ()); l->next ()) { - d = l->item (); + 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); @@ -3279,7 +3271,6 @@ case 286: */ (void) s->fe_add_attribute (a); } - delete l; } } break; @@ -3456,7 +3447,7 @@ case 305: 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); @@ -3533,14 +3524,14 @@ case 317: * 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) + 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 (tp != 0) { a = idl_global->gen ()->create_argument ( - AST_Argument::dir_IN, - tp, + AST_Argument::dir_IN, + tp, (UTL_IdList *) tao_yyvsp[0].deval->name ()->copy () ); @@ -3610,8 +3601,8 @@ case 328: else { a = idl_global->gen ()->create_argument ( - tao_yyvsp[-4].dival, - tp, + tao_yyvsp[-4].dival, + tp, (UTL_IdList *) tao_yyvsp[0].deval->name ()->copy () ); (void) s->fe_add_argument (a); diff --git a/TAO/TAO_IDL/fe/y.tab.cpp.diff b/TAO/TAO_IDL/fe/y.tab.cpp.diff index b1b2f77b054..5406607b7ae 100644 --- a/TAO/TAO_IDL/fe/y.tab.cpp.diff +++ b/TAO/TAO_IDL/fe/y.tab.cpp.diff @@ -1,11 +1,5 @@ --- y.tab.cpp Fri Jan 25 11:06:56 2002 +++ y.tab.cpp.mod Fri Jan 25 11:09:03 2002 -@@ -1,4 +1,4 @@ --// $Id$ -+// $Id$ - #ifndef lint - char tao_yysccsid[] = "@(#)yaccpar 1.4 (Berkeley) 02/25/90 \n\ - Modified 5/2/90 by J. Roskind to support graphic debugging modes"; @@ -960,7 +960,7 @@ #ifdef TAO_YYMAXDEPTH #define TAO_YYSTACKSIZE TAO_YYMAXDEPTH diff --git a/TAO/TAO_IDL/util/utl_decllist.cpp b/TAO/TAO_IDL/util/utl_decllist.cpp index 030ef90946a..07031753b60 100644 --- a/TAO/TAO_IDL/util/utl_decllist.cpp +++ b/TAO/TAO_IDL/util/utl_decllist.cpp @@ -114,8 +114,8 @@ UTL_DeclList::head() * Constructor */ -UTL_DecllistActiveIterator::UTL_DecllistActiveIterator(UTL_DeclList *s) - : UTL_ListActiveIterator(s) +UTL_DecllistActiveIterator::UTL_DecllistActiveIterator (UTL_DeclList *s) + : UTL_ListActiveIterator(s) { } @@ -131,8 +131,10 @@ UTL_DecllistActiveIterator::UTL_DecllistActiveIterator(UTL_DeclList *s) FE_Declarator * UTL_DecllistActiveIterator::item() { - if (source == NULL) - return NULL; + if (source == 0) + { + return 0; + } return ((UTL_DeclList *) source)->head(); } |