diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-01-25 19:47:05 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-01-25 19:47:05 +0000 |
commit | 23339bc65c4fa68f669393f744bab5768e8ee5f5 (patch) | |
tree | 08f6344884ec9eb62b4b89914d7a9f81d8cf6b17 | |
parent | a928f8b379abe6de9ec4f9b0f8266170604d00ad (diff) | |
download | ATCD-23339bc65c4fa68f669393f744bab5768e8ee5f5.tar.gz |
ChangeLogTag:Fri Jan 25 11:34:35 2002 Carlos O'Ryan <coryan@uci.edu>
22 files changed, 701 insertions, 1003 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a index 17ef91e63d1..92550f12235 100644 --- a/TAO/ChangeLogs/ChangeLog-02a +++ b/TAO/ChangeLogs/ChangeLog-02a @@ -1,3 +1,34 @@ +Fri Jan 25 11:34:35 2002 Carlos O'Ryan <coryan@uci.edu> + + * TAO_IDL/ast/ast_operation.cpp: + * TAO_IDL/be/be_generator.cpp: + * TAO_IDL/be/be_operation.cpp: + * TAO_IDL/be/be_scope.cpp: + * TAO_IDL/be/be_structure.cpp: + * TAO_IDL/be/be_union.cpp: + * TAO_IDL/be/be_valuetype.cpp: + * TAO_IDL/be/be_visitor_amh_pre_proc.cpp: + * TAO_IDL/be/be_visitor_scope.cpp: + * TAO_IDL/be/be_visitor_interface/amh_sh.cpp: + * TAO_IDL/be/be_visitor_operation/operation.cpp: + * TAO_IDL/be/be_visitor_operation/operation_cs.cpp: + * TAO_IDL/be/be_visitor_operation/operation_ss.cpp: + * TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp: + * TAO_IDL/be/be_visitor_root/root_sth.cpp: + * TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp: + * TAO_IDL/be/be_visitor_union/union_cs.cpp: + * TAO_IDL/be/be_visitor_union_branch/cdr_op_ci.cpp: + * TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp: + * TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp: + * TAO_IDL/be/be_visitor_valuetype/valuetype.cpp: + For some mystifying reason many UTL_ScopeActiveIterator + instances were created on the heap, and immediately deleted (or + not, leaking memory.) + Funny enough the language has a perfectly usable feature for + that kind of behavior, it is called "automatic variables". + Also, several while()-loops were really for()-loops in disguise, + changed them to make the behavior more obvious. + Fri Jan 25 10:40:03 2002 Ossama Othman <ossama@uci.edu> * orbsvcs/tests/Security/SecurityLevel1/client.dsp: diff --git a/TAO/TAO_IDL/ast/ast_operation.cpp b/TAO/TAO_IDL/ast/ast_operation.cpp index b3d162ee29c..8668d833a0f 100644 --- a/TAO/TAO_IDL/ast/ast_operation.cpp +++ b/TAO/TAO_IDL/ast/ast_operation.cpp @@ -157,7 +157,7 @@ AST_Operation::count_arguments_with_direction (int direction_mask) { AST_Argument *arg = AST_Argument::narrow_from_decl (si.item ()); - + if ((arg->direction () & direction_mask) != 0) count++; } diff --git a/TAO/TAO_IDL/be/be_generator.cpp b/TAO/TAO_IDL/be/be_generator.cpp index 09c0088646a..787cfa85bdb 100644 --- a/TAO/TAO_IDL/be/be_generator.cpp +++ b/TAO/TAO_IDL/be/be_generator.cpp @@ -104,15 +104,6 @@ AST_Module * be_generator::create_module (UTL_Scope *s, UTL_ScopedName *n) { - AST_Decl *d = 0; - AST_Module *m = 0; - - UTL_ScopeActiveIterator *iter = 0; - ACE_NEW_RETURN (iter, - UTL_ScopeActiveIterator (s, - UTL_Scope::IK_decls), - 0); - // We create this first so if we find a module with the // same name from an included file, we can add its // members to the new module's scope. @@ -123,9 +114,11 @@ be_generator::create_module (UTL_Scope *s, // Check for another module of the same name in this scope. - while (!iter->is_done ()) + for (UTL_ScopeActiveIterator iter (s, UTL_Scope::IK_decls); + !iter.is_done (); + iter.next ()) { - d = iter->item (); + AST_Decl *d = iter.item (); if (d->node_type () == AST_Decl::NT_module) { @@ -133,28 +126,24 @@ be_generator::create_module (UTL_Scope *s, // supposed to create. if (d->local_name ()->compare (n->last_component ())) { - m = AST_Module::narrow_from_decl (d); + AST_Module *m = AST_Module::narrow_from_decl (d); // Get m's previous_ member, plus all it's decls, // into the new modules's previous_ member. retval->add_to_previous (m); } } - - iter->next (); } - delete iter; - // If this scope is itself a module, and has been previously // opened, the previous opening may contain a previous opening // of the module we're creating. - d = ScopeAsDecl (s); + AST_Decl *d = ScopeAsDecl (s); AST_Decl::NodeType nt = d->node_type (); if (nt == AST_Decl::NT_module || nt == AST_Decl::NT_root) { - m = AST_Module::narrow_from_decl (d); + AST_Module *m = AST_Module::narrow_from_decl (d); // AST_Module::previous_ is a set, so it contains each // entry only once, but previous_ will contain the decls diff --git a/TAO/TAO_IDL/be/be_operation.cpp b/TAO/TAO_IDL/be/be_operation.cpp index 4af73933e07..7f9bc10b97c 100644 --- a/TAO/TAO_IDL/be/be_operation.cpp +++ b/TAO/TAO_IDL/be/be_operation.cpp @@ -87,42 +87,28 @@ be_operation::add_argument_to_scope (be_argument *arg) int be_operation::compute_size_type (void) { - UTL_ScopeActiveIterator *si = 0; - AST_Decl *d = 0; - be_decl *bd = 0; - if (this->nmembers () > 0) + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // If there are elements in this scope, - // 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 + AST_Decl *d = si.item (); + be_decl *bd = be_decl::narrow_from_decl (d); + if (bd != 0) { - // Get the next AST decl node - d = si->item (); - bd = be_decl::narrow_from_decl (d); - if (bd != 0) - { - // Our sizetype depends on the sizetype of our members. Although - // previous value of sizetype may get overwritten, we are - // guaranteed by the "size_type" call that once the value reached - // be_decl::VARIABLE, nothing else can overwrite it. - this->size_type (bd->size_type ()); - } - else - { - ACE_DEBUG ((LM_DEBUG, - "WARNING (%N:%l) be_operation::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - - si->next (); + // Our sizetype depends on the sizetype of our members. Although + // previous value of sizetype may get overwritten, we are + // guaranteed by the "size_type" call that once the value reached + // be_decl::VARIABLE, nothing else can overwrite it. + this->size_type (bd->size_type ()); + } + else + { + ACE_DEBUG ((LM_DEBUG, + "WARNING (%N:%l) be_operation::compute_size_type - " + "narrow_from_decl returned 0\n")); } - delete si; } return 0; diff --git a/TAO/TAO_IDL/be/be_scope.cpp b/TAO/TAO_IDL/be/be_scope.cpp index ef16389e033..c7fde75337d 100644 --- a/TAO/TAO_IDL/be/be_scope.cpp +++ b/TAO/TAO_IDL/be/be_scope.cpp @@ -71,27 +71,18 @@ be_scope::decl (void) void be_scope::destroy (void) { - AST_Decl *i = 0; - UTL_ScopeActiveIterator *iter = 0; - - ACE_NEW (iter, - UTL_ScopeActiveIterator (this, - IK_decls)); - - while (!iter->is_done ()) + for (UTL_ScopeActiveIterator iter (this, IK_decls); + !iter.is_done (); + iter.next ()) { - i = iter->item (); + AST_Decl *i = iter.item (); i->destroy (); delete i; i = 0; - iter->next (); } - - delete iter; - -// Still some glitches, but the call should eventually -// be made here. -// UTL_Scope::destroy (); + // Still some glitches, but the call should eventually + // be made here. + // UTL_Scope::destroy (); } int diff --git a/TAO/TAO_IDL/be/be_structure.cpp b/TAO/TAO_IDL/be/be_structure.cpp index 1df45009625..d5505f47049 100644 --- a/TAO/TAO_IDL/be/be_structure.cpp +++ b/TAO/TAO_IDL/be/be_structure.cpp @@ -656,45 +656,31 @@ be_structure::gen_out_impl (char *, int be_structure::compute_size_type (void) { - UTL_ScopeActiveIterator *si = 0; - AST_Decl *d = 0; - be_decl *bd = 0; - - if (this->nmembers () > 0) + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // If there are elements in this scope, - // 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. + AST_Decl *d = si.item (); + be_decl *bd = be_decl::narrow_from_decl (d); + if (bd != 0) { - // Get the next AST decl node. - d = si->item (); - bd = be_decl::narrow_from_decl (d); - if (bd != 0) - { - // Our sizetype depends on the sizetype of our members. Although - // previous value of sizetype may get overwritten, we are - // guaranteed by the "size_type" call that once the value reached - // be_decl::VARIABLE, nothing else can overwrite it. - this->size_type (bd->size_type ()); - - // While we're iterating, we might as well do this one too. - this->has_constructor (bd->has_constructor ()); - } - else - { - ACE_DEBUG ((LM_DEBUG, - "WARNING (%N:%l) be_structure::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - si->next (); + // Our sizetype depends on the sizetype of our + // members. Although previous value of sizetype may get + // overwritten, we are guaranteed by the "size_type" call + // that once the value reached be_decl::VARIABLE, nothing + // else can overwrite it. + this->size_type (bd->size_type ()); + + // While we're iterating, we might as well do this one too. + this->has_constructor (bd->has_constructor ()); + } + else + { + ACE_DEBUG ((LM_DEBUG, + "WARNING (%N:%l) be_structure::compute_size_type - " + "narrow_from_decl returned 0\n")); } - - delete si; } return 0; diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp index 569a2705857..c55688623ff 100644 --- a/TAO/TAO_IDL/be/be_union.cpp +++ b/TAO/TAO_IDL/be/be_union.cpp @@ -676,44 +676,27 @@ be_union::gen_out_impl (char *, int be_union::compute_size_type (void) { - UTL_ScopeActiveIterator *si = 0; - AST_Decl *d = 0; - be_decl *bd = 0; - - if (this->nmembers () > 0) + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // If there are elements in this scope, - // 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. + AST_Decl *d = si.item (); + be_decl *bd = be_decl::narrow_from_decl (d); + if (bd != 0) { - // Get the next AST decl node. - d = si->item (); - bd = be_decl::narrow_from_decl (d); - if (bd != 0) - { - // Our sizetype depends on the sizetype of our members. Although - // previous value of sizetype may get overwritten, we are - // guaranteed by the "size_type" call that once the value reached - // be_decl::VARIABLE, nothing else can overwrite it. - this->size_type (bd->size_type ()); - } - else - { - ACE_DEBUG ((LM_DEBUG, - "WARNING (%N:%l) be_union::compute_size_type - " - "narrow_from_decl returned 0\n")); - } - - si->next (); + // Our sizetype depends on the sizetype of our members. Although + // previous value of sizetype may get overwritten, we are + // guaranteed by the "size_type" call that once the value reached + // be_decl::VARIABLE, nothing else can overwrite it. + this->size_type (bd->size_type ()); + } + else + { + ACE_DEBUG ((LM_DEBUG, + "WARNING (%N:%l) be_union::compute_size_type - " + "narrow_from_decl returned 0\n")); } - - delete si; } return 0; @@ -722,25 +705,18 @@ be_union::compute_size_type (void) idl_bool be_union::has_duplicate_case_labels (void) { - // 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 ()) { - AST_Decl *d = si->item (); - AST_UnionBranch *ub = AST_UnionBranch::narrow_from_decl (d); + AST_Decl *d = si.item (); + AST_UnionBranch *ub = + AST_UnionBranch::narrow_from_decl (d); if (ub->label_list_length () > 1) { - delete si; return I_TRUE; } - - si->next (); } return I_FALSE; diff --git a/TAO/TAO_IDL/be/be_valuetype.cpp b/TAO/TAO_IDL/be/be_valuetype.cpp index fa2738fa29a..714d12c198c 100644 --- a/TAO/TAO_IDL/be/be_valuetype.cpp +++ b/TAO/TAO_IDL/be/be_valuetype.cpp @@ -748,59 +748,44 @@ be_valuetype::accept (be_visitor *visitor) return visitor->visit_valuetype (this); } -ACE_CDR::ULong +ACE_CDR::ULong be_valuetype::data_members_count (AST_Field::Visibility vis) { ACE_CDR::ULong count = 0; - // 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; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (this, - UTL_Scope::IK_decls), - 0); - - // continue until each element is visited - for (;!si->is_done ();si->next()) + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next()) + { + AST_Decl *d = si.item (); + + if (!d) { - AST_Decl *d = si->item (); - - if (!d) - { - delete si; - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_valuetype::data_members_count - " - "bad node in this scope\n"), 0); - } - - AST_Field *field = AST_Field::narrow_from_decl (d); - - if (!field) - { - continue; - } - - if (vis != AST_Field::vis_NA) - { - if (vis == field->visibility ()) ++count; - } - else - { - ++count; - } - - } // end of for loop - - delete si; - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_valuetype::data_members_count - " + "bad node in this scope\n"), 0); + } + + AST_Field *field = AST_Field::narrow_from_decl (d); + + if (!field) + { + continue; + } + + if (vis != AST_Field::vis_NA) + { + if (vis == field->visibility ()) ++count; + } + else + { + ++count; + } + } // end of for loop return count; } -idl_bool +idl_bool be_valuetype::in_recursion (AST_Type *node) { if (node == 0) @@ -808,70 +793,63 @@ be_valuetype::in_recursion (AST_Type *node) node = this; } - // 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); + for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls); + !si.is_done (); + si.next()) + { + AST_Decl *d = si.item (); - // Continue until each element is visited. - for (; !si.is_done (); si.next()) + if (!d) { - AST_Decl *d = si.item (); - - if (!d) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_valuetype::in_recursion - " - "bad node in this scope\n"), - 0); - } - - AST_Field *field = AST_Field::narrow_from_decl (d); - - if (!field) - { - continue; - } - - AST_Type *type = field->field_type (); - - // A valuetype may contain itself as a member. This will not - // cause a problem when checking if the valuetype itself is - // recursive, but if another valuetype contains a recursive - // one, the string compare below is not sufficient, and we - // will go into an infinite recursion of calls to in_recursion ;-). - // The check below will catch that use case. - if (this == type) - { - return 1; - } - - if (!type) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_valuetype::in_recursion - " - "bad base type\n"), - 0); - } - - // IDL doesn't have such a feature as name reuse so - // just compare fully qualified names. - if (!ACE_OS::strcmp (node->full_name (), - type->full_name ())) - { - return 1; - } - - // Now hand over to our field type. - if (type->in_recursion (node)) - { - return 1; - } - - } // end of for loop - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_valuetype::in_recursion - " + "bad node in this scope\n"), + 0); + } + + AST_Field *field = AST_Field::narrow_from_decl (d); + + if (!field) + { + continue; + } + + AST_Type *type = field->field_type (); + + // A valuetype may contain itself as a member. This will not + // cause a problem when checking if the valuetype itself is + // recursive, but if another valuetype contains a recursive + // one, the string compare below is not sufficient, and we + // will go into an infinite recursion of calls to in_recursion ;-). + // The check below will catch that use case. + if (this == type) + { + return 1; + } + + if (!type) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_valuetype::in_recursion - " + "bad base type\n"), + 0); + } + + // IDL doesn't have such a feature as name reuse so + // just compare fully qualified names. + if (!ACE_OS::strcmp (node->full_name (), + type->full_name ())) + { + return 1; + } + + // Now hand over to our field type. + if (type->in_recursion (node)) + { + return 1; + } + + } // end of for loop return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp index 1de3d0d5d98..297508c9a54 100644 --- a/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp +++ b/TAO/TAO_IDL/be/be_visitor_amh_pre_proc.cpp @@ -150,57 +150,43 @@ be_visitor_amh_pre_proc::add_rh_node_members ( be_interface *node, // Now our customized valuetype is created, we have to // add now the operations and attributes to the scope. - if (node->nmembers () > 0) - { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - 0); + this->elem_number_ = 0; - this->elem_number_ = 0; - // continue until each element is visited - while (!si->is_done ()) + // 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) { - AST_Decl *d = si->item (); - if (!d) - { - delete si; - 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) + { + be_attribute *attribute = be_attribute::narrow_from_decl (d); - if (d->node_type () == AST_Decl::NT_attr) + if (!attribute) { - 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->create_response_handler_operation (operation, - response_handler); - } + } + else + { + be_operation* operation = be_operation::narrow_from_decl (d); + if (operation) + { + this->create_response_handler_operation (operation, + response_handler); } - - si->next (); - } // end of while loop - - delete si; - } // end of if + } + } return 1; } @@ -260,49 +246,36 @@ be_visitor_amh_pre_proc::create_response_handler_operation (be_operation *node, // Iterate over the arguments and put all the out and inout arguments // into the new method. - if (node->nmembers () > 0) + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - 0); + AST_Decl *d = si.item (); - // continue until each element is visited - while (!si->is_done ()) + if (!d) { - AST_Decl *d = si->item (); - - if (!d) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_amh_pre_proc::" - "create_response_handler_operation - " - "bad node in this scope\n"), - -1); - - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_amh_pre_proc::" + "create_response_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 ()); + //be_decl *arg = be_decl::narrow_from_decl (d); + AST_Argument *original_arg = AST_Argument::narrow_from_decl (d); - operation->add_argument_to_scope (arg); - } - si->next (); - } // end of while loop + 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 ()); - delete si; - } // end of if + operation->add_argument_to_scope (arg); + } + } operation->set_defined_in (response_handler); 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 9ea03ac459f..fce022ee17f 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_sh.cpp @@ -207,48 +207,37 @@ be_visitor_amh_interface_sh::add_original_members (be_interface *node, if (!node || !amh_node) return -1; - if (node->nmembers () > 0) + this->elem_number_ = 0; + // initialize an iterator to iterate thru our scope + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, UTL_Scope::IK_decls), - 0); - this->elem_number_ = 0; - - // continue until each element is visited - while (!si->is_done ()) + AST_Decl *d = si.item (); + if (!d) { - AST_Decl *d = si->item (); - if (!d) - { - delete si; - 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) - { - be_attribute *attribute = be_attribute::narrow_from_decl (d); + if (d->node_type () == AST_Decl::NT_attr) + { + be_attribute *attribute = be_attribute::narrow_from_decl (d); - if (!attribute) - return 0; - } - else + if (!attribute) + return 0; + } + else + { + be_operation* operation = be_operation::narrow_from_decl (d); + if (operation) { - be_operation* operation = be_operation::narrow_from_decl (d); - if (operation) - { - this->add_amh_operation (operation, amh_node); - } + this->add_amh_operation (operation, amh_node); } - si->next (); - } // end of while loop - delete si; - } // end of if + } + } return 0; } diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp index 3d61978a2c1..1a4df226278 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation.cpp @@ -72,34 +72,22 @@ be_visitor_operation::count_non_out_parameters (be_operation *node) // size_t count = 0; - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) + // initialize an iterator to iterate thru our scope + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - 0); - - // Continue until each element is visited - while (!si->is_done ()) - { - be_argument *bd = - be_argument::narrow_from_decl (si->item ()); - - // We do not generate insertion operators for valuetypes - // yet. Do not include them in the count. - be_valuetype *vt = - be_valuetype::narrow_from_decl (bd->field_type ()); + be_argument *bd = + be_argument::narrow_from_decl (si.item ()); - if (bd && (bd->direction () != AST_Argument::dir_OUT) && !vt) - count++; + // We do not generate insertion operators for valuetypes + // yet. Do not include them in the count. + be_valuetype *vt = + be_valuetype::narrow_from_decl (bd->field_type ()); - si->next (); - } + if (bd && (bd->direction () != AST_Argument::dir_OUT) && !vt) + count++; - delete si; } return count; 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 b68eba30039..829cf9a36b7 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_cs.cpp @@ -227,36 +227,24 @@ be_visitor_operation_cs::visit_operation (be_operation *node) *os << "proxy." << node->local_name () << " (" << be_idt << be_idt_nl << "this"; - if (node->nmembers () > 0) + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { + AST_Decl *d = si.item (); - // Initialize an iterator to iterate over our scope. - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - - while (!si->is_done ()) + if (d == 0) { - AST_Decl *d = si->item (); - - if (d == 0) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), - -1); - - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "bad node in this scope\n"), + -1); + } - *os << "," << be_nl; - be_decl *decl = be_decl::narrow_from_decl (d); + be_decl *decl = be_decl::narrow_from_decl (d); - *os << decl->local_name(); - si->next (); - } + *os << "," << be_nl + << decl->local_name(); } if (!be_global->exception_support ()) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp index 9c69f7048c4..35606d79667 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/operation_ss.cpp @@ -160,27 +160,9 @@ be_visitor_operation_ss::visit_operation (be_operation *node) be_visitor *visitor = tao_cg->make_visitor (&ctx); // Do we have any arguments in the operation that needs marshalling. - UTL_ScopeActiveIterator si (node, - UTL_Scope::IK_decls); - AST_Decl *d = 0; - AST_Argument *arg = 0; - int flag = 0; - - while (!si.is_done ()) - { - d = si.item (); - arg = AST_Argument::narrow_from_decl (d); - - if (arg->direction () == AST_Argument::dir_INOUT || - arg->direction () == AST_Argument::dir_OUT) - { - // There are return type that needs to get marshalled. - flag = 1; - break; - } - - si.next (); - } + int flag = + node->count_arguments_with_direction (AST_Argument::dir_INOUT | + AST_Argument::dir_OUT); // Check if the flag is zero and for the return type. if (flag == 0 && node->void_return_type () == 1) diff --git a/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp b/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp index 0b11844f9b5..969b8c081c1 100644 --- a/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_operation/remote_proxy_impl_cs.cpp @@ -337,26 +337,9 @@ be_visitor_operation_remote_proxy_impl_cs::gen_marshal_and_invoke ( size_t ext = this->ctx_->attribute () ? 5 : 0; // Do we have any arguments in the operation that needs marshalling - UTL_ScopeActiveIterator si (node, - UTL_Scope::IK_decls); - AST_Decl *d = 0; - AST_Argument *arg = 0; - int flag = 0; - - while (!si.is_done ()) - { - d = si.item (); - arg = AST_Argument::narrow_from_decl (d); - - if (arg->direction () == AST_Argument::dir_IN || - arg->direction () == AST_Argument::dir_INOUT) - { - // There is something that needs marshalling - flag = 1; - break; - } - si.next (); - } + int flag = + node->count_arguments_with_direction (AST_Argument::dir_IN + | AST_Argument::dir_INOUT); *os << "(" << be_idt << be_idt_nl << "istub," << be_nl 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 32c4b826614..acbc7166c34 100644 --- a/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp +++ b/TAO/TAO_IDL/be/be_visitor_root/root_sth.cpp @@ -68,59 +68,50 @@ be_visitor_root_sth::init (void) int be_visitor_root_sth::visit_scope (be_scope *node) { - // Proceed if the number of members in our scope is greater than 0. - if (node->nmembers () > 0) + for (UTL_ScopeActiveIterator si (node, + UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // Initialize an iterator to iterate over our scope. - UTL_ScopeActiveIterator si (node, - UTL_Scope::IK_decls); - // Continue until each element is visited. - while (!si.is_done ()) - { - AST_Decl *d = si.item (); - - if (d == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_sth::visit_scope - " - "bad node in this scope\n"), - -1); + AST_Decl *d = si.item (); - } - - AST_Decl::NodeType nt = d->node_type (); + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root_sth::visit_scope - " + "bad node in this scope\n"), + -1); + } - // These are the onlh types we're interested in. - if (nt != AST_Decl::NT_module - && nt != AST_Decl::NT_interface) - { - si.next (); - continue; - } + AST_Decl::NodeType nt = d->node_type (); - be_decl *bd = be_decl::narrow_from_decl (d); + // These are the onlh types we're interested in. + if (nt != AST_Decl::NT_module + && nt != AST_Decl::NT_interface) + { + continue; + } - // 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 ()); + be_decl *bd = be_decl::narrow_from_decl (d); - // Set the node to be visited. - this->ctx_->node (bd); + // 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 ()); - // Send the visitor. - if (bd == 0 || bd->accept (this) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_root_sth::visit_scope - " - "codegen for scope failed\n"), - -1); + // Set the node to be visited. + this->ctx_->node (bd); - } + // Send the visitor. + if (bd == 0 || bd->accept (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_root_sth::visit_scope - " + "codegen for scope failed\n"), + -1); - si.next (); - } // End of while loop. - } // End of if. + } + } return 0; } @@ -212,4 +203,3 @@ be_visitor_root_sth::visit_interface (be_interface *node) return 0; } - diff --git a/TAO/TAO_IDL/be/be_visitor_scope.cpp b/TAO/TAO_IDL/be/be_visitor_scope.cpp index 3e12efb3841..d246c1f5332 100644 --- a/TAO/TAO_IDL/be/be_visitor_scope.cpp +++ b/TAO/TAO_IDL/be/be_visitor_scope.cpp @@ -48,79 +48,59 @@ int be_visitor_scope::visit_scope (be_scope *node) { // Proceed if the number of members in our scope is greater than 0. - if (node->nmembers () > 0) + this->elem_number_ = 0; + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // Initialize an iterator to iterate over our scope. - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); + AST_Decl *d = si.item (); - this->elem_number_ = 0; + if (d == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "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 + // generated so that elements in the node's scope can use it + // for code generation. + this->ctx_->scope (node->decl ()); - // Continue until each element is visited. - while (!si->is_done ()) + // Set the node to be visited. + this->ctx_->node (bd); + this->elem_number_++; + + // Do any pre processing using the next item info. + if (this->pre_process (bd) == -1) { - AST_Decl *d = si->item (); - - if (d == 0) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "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 - // 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. - this->ctx_->node (bd); - this->elem_number_++; - - // Do any pre processing using the next item info. - if (this->pre_process (bd) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "pre processing failed\n"), - -1); - } - - // Send the visitor. - if (bd == 0 || bd->accept (this) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), - -1); - - } - - // Do any post processing using this item info. - if (this->post_process (bd) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "post processing failed\n"), - -1); - } - - si->next (); - } // End of while loop. - - delete si; - } // End of if. + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "pre processing failed\n"), + -1); + } + + // Send the visitor. + if (bd == 0 || bd->accept (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "codegen for scope failed\n"), + -1); + } + + // Do any post processing using this item info. + if (this->post_process (bd) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "post processing failed\n"), + -1); + } + } return 0; } @@ -168,68 +148,46 @@ be_visitor_scope::next_elem (be_decl *elem, successor = 0; - // Proceed if the number of members in our scope is greater than 0. - if (node->nmembers () > 0) + // Initialize an iterator to iterate thru our scope. + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // Initialize an iterator to iterate thru our scope. - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - - // Continue until each element is visited. - while (!si->is_done ()) + be_decl *bd = be_decl::narrow_from_decl (si.item ()); + + if (bd == 0) { - be_decl *bd = be_decl::narrow_from_decl (si->item ()); - - if (bd == 0) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::next_elem - " - "bad node in this scope\n"), - -1); - - } - - if (bd == elem) - { - // Find who is next to me. - si->next (); - - if (si->is_done ()) - { - // Nobody left in the list. - delete si; - return 0; - } - - successor = be_decl::narrow_from_decl (si->item ()); - - if (successor == 0) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::next_elem - " - "bad node in this scope\n"), - -1); - - } - - // Nothing else to do. - delete si; - return 0; - } - else - { - // Proceed to the next element. - si->next (); - } - } // End of while loop. - - delete si; - } // End of if. + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::next_elem - " + "bad node in this scope\n"), + -1); + } + + if (bd != elem) + continue; + + // Find who is next to me. + si.next (); + + if (si.is_done ()) + { + // Nobody left in the list. + return 0; + } + + successor = be_decl::narrow_from_decl (si.item ()); + + if (successor == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::next_elem - " + "bad node in this scope\n"), + -1); + } + + // Nothing else to do. + return 0; + } return 0; } @@ -280,4 +238,3 @@ be_visitor_scope::last_inout_or_out_node (be_decl *) // I am the last one. return 1; } - 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 716a137d561..ef6480b53e9 100644 --- a/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp +++ b/TAO/TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp @@ -58,7 +58,7 @@ Scoped_Compute_Queue_Guard::~Scoped_Compute_Queue_Guard (void) { // reset the compute queue since we must not affect computation of other // nodes - customer_->queue_reset (customer_->compute_queue_); + customer_->queue_reset (customer_->compute_queue_); } } @@ -73,7 +73,7 @@ be_visitor_typecode_defn::be_visitor_typecode_defn (be_visitor_context *ctx) computed_scope_encap_len_ (0), tc_offset_ (0), index_ (-1) - + { } @@ -147,87 +147,67 @@ be_visitor_typecode_defn::visit_members (AST_Structure *node) return 0; } -int +int be_visitor_typecode_defn::visit_members (be_valuetype *node) { - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) - { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - - this->elem_number_ = 0; + this->elem_number_ = 0; + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next()) + { + AST_Decl *d = si.item (); - // continue until each element is visited - for (;!si->is_done ();si->next()) + if (!d) { - AST_Decl *d = si->item (); - - if (!d) - { - delete si; - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::visit_members - " - "bad node in this scope\n"), -1); - } - - AST_Field *field = AST_Field::narrow_from_decl (d); - - if (!field) - { - continue; - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_typecode_defn::visit_members - " + "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 - // generated so that elements in the node's scope can use it - // for code generation + AST_Field *field = AST_Field::narrow_from_decl (d); - this->ctx_->scope (node->decl ()); + if (!field) + { + continue; + } - // set the node to be visited - this->ctx_->node (bd); - this->elem_number_++; + be_decl *bd = be_decl::narrow_from_decl (d); + // set the scope node as "node" in which the code is being + // generated so that elements in the node's scope can use it + // for code generation - // Do any pre processing using the next item info. - if (this->pre_process (bd) == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::visit_members - " - "pre processing failed\n" - ), -1); - } + this->ctx_->scope (node->decl ()); - // Send the visitor. - if (bd == 0 || bd->accept (this) == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::visit_members - " - "codegen for scope failed\n" - ), -1); - - } + // set the node to be visited + this->ctx_->node (bd); + this->elem_number_++; - // Do any post processing using this item info. - if (this->post_process (bd) == -1) - { - ACE_ERROR_RETURN (( - LM_ERROR, - "(%N:%l) be_visitor_typecode_defn::visit_members - " - "post processing failed\n" - ), -1); - } + // Do any pre processing using the next item info. + if (this->pre_process (bd) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_typecode_defn::visit_members - " + "pre processing failed\n" + ), -1); + } - } // end of for loop + // Send the visitor. + if (bd == 0 || bd->accept (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_typecode_defn::visit_members - " + "codegen for scope failed\n" + ), -1); + } - delete si; + // Do any post processing using this item info. + if (this->post_process (bd) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_typecode_defn::visit_members - " + "post processing failed\n" + ), -1); + } } return 0; @@ -822,7 +802,7 @@ be_visitor_typecode_defn::visit_union (be_union *node) -1); } -int +int be_visitor_typecode_defn::visit_valuetype (be_valuetype *node) { switch (this->ctx_->sub_state ()) @@ -1053,7 +1033,7 @@ be_visitor_typecode_defn::gen_typecode (be_enum *node) { Scoped_Compute_Queue_Guard guard (this); - + // emit the encapsulation length this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); if (node->accept (this) == -1) @@ -1181,7 +1161,7 @@ be_visitor_typecode_defn::gen_typecode (be_exception *node) { Scoped_Compute_Queue_Guard guard (this); - + // emit the encapsulation length this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); if (node->accept (this) == -1) @@ -1292,15 +1272,15 @@ be_visitor_typecode_defn::gen_encapsulation (be_field *node) { // generate visibility marker - // Even though visibility marker is UShort it seems that + // Even though visibility marker is UShort it seems that // it would always be aligned on ULong boundary. - ACE_CDR::ULong visibility = + ACE_CDR::ULong visibility = node->visibility() == AST_Field::vis_PRIVATE ? 0 : 1; - + os->indent (); // start from current indentation level - *os << visibility << ", // data memeber visibility marker" + *os << visibility << ", // data memeber visibility marker" << "\n\n"; - + this->tc_offset_ += sizeof (ACE_CDR::ULong); } @@ -1346,7 +1326,7 @@ be_visitor_typecode_defn::gen_typecode (be_interface *node) { Scoped_Compute_Queue_Guard guard (this); - + // emit the encapsulation length this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); if (node->accept (this) == -1) @@ -1497,8 +1477,8 @@ be_visitor_typecode_defn::gen_typecode (be_predefined_type *node) { // Insert node into tc_queue_ in case the node is involved in // some form of recursion. - if (this->queue_insert (this->tc_queue_, - node, + if (this->queue_insert (this->tc_queue_, + node, this->tc_offset_) == 0) { ACE_ERROR_RETURN ((LM_ERROR, @@ -1512,7 +1492,7 @@ be_visitor_typecode_defn::gen_typecode (be_predefined_type *node) { Scoped_Compute_Queue_Guard guard (this); - + // emit the encapsulation length this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); if (node->accept (this) == -1) @@ -1589,7 +1569,7 @@ be_visitor_typecode_defn::gen_typecode (be_sequence *node) { Scoped_Compute_Queue_Guard guard (this); - + // emit the encapsulation length this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); if (node->accept (this) == -1) @@ -1732,7 +1712,7 @@ be_visitor_typecode_defn::gen_typecode (be_structure *node) { Scoped_Compute_Queue_Guard guard (this); - + // emit the encapsulation length this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); if (node->accept (this) == -1) @@ -2236,15 +2216,15 @@ be_visitor_typecode_defn::gen_encapsulation (be_union_branch *node) return 0; } -int +int be_visitor_typecode_defn::gen_typecode (be_valuetype *node) { TAO_OutStream *os = this->ctx_->stream (); // output stream os->indent (); // start from whatever indentation level we were at - + // check if we are repeated - const be_visitor_typecode_defn::QNode *qnode = + const be_visitor_typecode_defn::QNode *qnode = this->queue_lookup (this->tc_queue_, node); if (qnode) { @@ -2253,8 +2233,8 @@ be_visitor_typecode_defn::gen_typecode (be_valuetype *node) this->tc_offset_ += sizeof (ACE_CDR::ULong); // the offset must point to the tc_kind value of the first occurrence of // this type - os->print ("0x%x, // negative offset (%ld)\n", - (qnode->offset - this->tc_offset_), + os->print ("0x%x, // negative offset (%ld)\n", + (qnode->offset - this->tc_offset_), (qnode->offset - this->tc_offset_)); this->tc_offset_ += sizeof (ACE_CDR::ULong); } @@ -2262,14 +2242,14 @@ be_visitor_typecode_defn::gen_typecode (be_valuetype *node) { // Insert node into tc_queue_ in case the node is involved in // some form of recursion. - if (this->queue_insert (this->tc_queue_, - node, + if (this->queue_insert (this->tc_queue_, + node, this->tc_offset_) == 0) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typecode_defn::" "visit_type - " - "queue insert failed\n"), + "queue insert failed\n"), -1); } @@ -2292,7 +2272,7 @@ be_visitor_typecode_defn::gen_typecode (be_valuetype *node) } } - *os << this->computed_encap_len_ << ", // encapsulation length" + *os << this->computed_encap_len_ << ", // encapsulation length" << be_idt << "\n"; // size of the encap length this->tc_offset_ += sizeof (ACE_CDR::ULong); @@ -2309,10 +2289,10 @@ be_visitor_typecode_defn::gen_typecode (be_valuetype *node) } *os << be_uidt << "\n"; } - return 0; + return 0; } -int +int be_visitor_typecode_defn::gen_encapsulation (be_valuetype *node) { TAO_OutStream *os = this->ctx_->stream (); // output stream @@ -2338,20 +2318,20 @@ be_visitor_typecode_defn::gen_encapsulation (be_valuetype *node) os->indent (); // TAO doesn't support neither CUSTOM nor TRUNCATABLE - // valuetypes. So basically need to choose between + // valuetypes. So basically need to choose between // VM_NONE = 0 and VM_ABSTRACT = 2 ACE_CDR::ULong value_modifier = node->is_abstract_valuetype () ? 2 : 0; - + *os << value_modifier << ", // value modifier" << "\n"; - + this->tc_offset_ += sizeof (ACE_CDR::ULong); //STEP 4: generate TypeCode of concrete base - + AST_Interface *inherited = 0; if (node->n_inherits () > 0 && ( // Statefull base valuetype is always first - inherited = + inherited = AST_Interface::narrow_from_decl(node->inherits ()[0]) ) != 0 && inherited->is_valuetype () && @@ -2369,18 +2349,18 @@ be_visitor_typecode_defn::gen_encapsulation (be_valuetype *node) ACE_TEXT ("failed to generate typecode\n")), -1); } - // revert the state to what it was before + // revert the state to what it was before this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE); } else { // emit tk_null os->indent (); - *os << "CORBA::tk_null, // no stateful base valuetype" + *os << "CORBA::tk_null, // no stateful base valuetype" << "\n\n"; // size of the enum - this->tc_offset_ += sizeof (ACE_CDR::ULong); + this->tc_offset_ += sizeof (ACE_CDR::ULong); } //STEP 5: generate the member count @@ -2396,7 +2376,7 @@ be_visitor_typecode_defn::gen_encapsulation (be_valuetype *node) if (node->accept (this) == -1) { ACE_ERROR_RETURN(( - LM_ERROR, + LM_ERROR, "be_valuetype: cannot generate typecode for members\n"), -1); } @@ -2695,7 +2675,7 @@ be_visitor_typecode_defn::compute_encap_length (be_field *node) { // count visibility marker - // Even though visibility marker is UShort it seems that + // Even though visibility marker is UShort it seems that // it would always be aligned on ULong boundary. this->computed_encap_len_ += 4; } @@ -3220,7 +3200,7 @@ be_visitor_typecode_defn::compute_encap_length (be_union_branch *node) return this->computed_encap_len_; } -ACE_CDR::Long +ACE_CDR::Long be_visitor_typecode_defn::compute_tc_size (be_valuetype *node) { // while computing the encapsulation length we must keep in mind the typecode @@ -3236,37 +3216,37 @@ be_visitor_typecode_defn::compute_tc_size (be_valuetype *node) { this->computed_tc_size_ = 4 + 4; } - else + else { // Insert node into tc_queue_ in case the node is involved in // some form of recursion. - if (this->queue_insert (this->compute_queue_, - node, + if (this->queue_insert (this->compute_queue_, + node, this->tc_offset_) == 0) { ACE_ERROR_RETURN ((LM_ERROR, "(%N:%l) be_visitor_typecode_defn::" "compute_tc_size (valuetype) - " - "queue insert failed\n"), + "queue insert failed\n"), -1); } this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); if (node->accept (this) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") ACE_TEXT ("::compute_tc_size (valuetype) - ") ACE_TEXT ("cannot compute encap len\n")), -1); } - + this->computed_tc_size_ = 4 + 4 + this->computed_encap_len_; } return this->computed_tc_size_; } -ACE_CDR::Long +ACE_CDR::Long be_visitor_typecode_defn::compute_encap_length (be_valuetype *node) { // STEP 1: @@ -3280,13 +3260,13 @@ be_visitor_typecode_defn::compute_encap_length (be_valuetype *node) // STEP 4: encap_len += 4; // to hold the ValueModifier - + // STEP 5: get encapsulation length for concrete base valuetype AST_Interface *inherited = 0; if (node->n_inherits () > 0 && ( // Statefull abse valuetype is always first - inherited = + inherited = AST_Interface::narrow_from_decl(node->inherits ()[0]) ) != 0 && inherited->is_valuetype () && @@ -3294,7 +3274,7 @@ be_visitor_typecode_defn::compute_encap_length (be_valuetype *node) ) { // Got non-abstract base valuetype. - + this->computed_encap_len_ = 0; be_valuetype *vt = be_valuetype::narrow_from_decl(node->inherits ()[0]); @@ -3307,7 +3287,7 @@ be_visitor_typecode_defn::compute_encap_length (be_valuetype *node) ACE_TEXT ("failed to compute len\n")), -1); } - // revert the state to what it was before + // revert the state to what it was before this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_ENCAP_LEN); encap_len += this->computed_encap_len_; @@ -3316,7 +3296,7 @@ be_visitor_typecode_defn::compute_encap_length (be_valuetype *node) { encap_len += 4; // to hold the CORBA::tk_null } - + //STEP 6: encap_len += 4; // to hold the member count @@ -3336,7 +3316,7 @@ be_visitor_typecode_defn::compute_encap_length (be_valuetype *node) this->ctx_->sub_state (TAO_CodeGen::TAO_TC_DEFN_SCOPE_LEN); if (node->accept (this) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, + ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%N:%l) be_visitor_typecode_defn") ACE_TEXT ("::compute_encap_len (valuetype) - ") ACE_TEXT ("cannot compute scope tc size\n")), 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 20b70bab04d..35b1e72e90c 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp @@ -18,9 +18,9 @@ // // ============================================================================ -#include "idl.h" -#include "idl_extern.h" -#include "be.h" +#include "idl.h" +#include "idl_extern.h" +#include "be.h" #include "be_visitor_union.h" @@ -116,25 +116,22 @@ int be_visitor_union_cs::visit_union (be_union *node) // to the first case label value found in the union declaration // so that, if the uninitialized union is inserted into an Any, // the Any destructor's call to deep_free() will work properly. - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); + 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 (); - delete si; + AST_Decl *d = si.item (); be_union_branch *ub = be_union_branch::narrow_from_decl (d); // Get the first label in its list. AST_UnionLabel *ul = ub->label (0); - if (ul->label_kind () == AST_UnionLabel::UL_label) - { + if (ul->label_kind () == AST_UnionLabel::UL_label) + { ub->gen_label_value (os); - } + } else { ub->gen_default_label_value (os, node); 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 be713ac0b25..892973d5b95 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 @@ -882,36 +882,29 @@ be_visitor_union_branch_cdr_op_ci::explicit_default (void) be_union_branch *ub = be_union_branch::narrow_from_decl (this->ctx_->node ()); - // instantiate a scope iterator. - UTL_ScopeActiveIterator *si = - new UTL_ScopeActiveIterator (bu, - UTL_Scope::IK_decls); - int i = 0; // counter - be_union_branch *bub = 0; // union branch node - AST_Decl *d = 0; // temp node - while (!(si->is_done ())) + // instantiate a scope iterator. + for (UTL_ScopeActiveIterator si (bu, UTL_Scope::IK_decls); + !si.is_done (); + si.next ()) { - // get the next AST decl node - d = si->item (); + be_union_branch *bub = 0; // union branch node + + AST_Decl *d = si.item (); if (!d->imported ()) bub = be_union_branch::narrow_from_decl (d); if (bub == ub) { - delete si; return (i == def_index); } else { i++; - si->next (); } } - - delete si; } return 0; 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 ced4eefeeb5..f0ec70cb55d 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_ch.cpp @@ -46,54 +46,41 @@ be_visitor_valuetype_marshal_ch::~be_visitor_valuetype_marshal_ch (void) int be_visitor_valuetype_marshal_ch::visit_valuetype (be_valuetype *node) { - // Proceed if the number of members in our scope is greater than 0. - if (node->nmembers () > 0) + this->elem_number_ = 0; + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next()) { - // Initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; + AST_Decl *d = si.item (); - // Continue until each field is visited. - for (;!si->is_done ();si->next()) + if (!d) { - AST_Decl *d = si->item (); + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "bad node in this scope\n"), + -1); - if (!d) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), - -1); + } - } + be_field *field = be_field::narrow_from_decl (d); - be_field *field = be_field::narrow_from_decl (d); + if (field) + { + be_visitor_context* new_ctx = + new be_visitor_context (*this->ctx_); + be_visitor_valuetype_field_cdr_ch visitor (new_ctx); + visitor.pre_ = node->field_pd_prefix (); + visitor.post_ = node->field_pd_postfix (); - if (field) + if (visitor.visit_field (field) == -1) { - be_visitor_context* new_ctx = - new be_visitor_context (*this->ctx_); - be_visitor_valuetype_field_cdr_ch visitor (new_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_ch::" - "visit_valuetype - " - "codegen for scope failed\n"), - -1); - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_valuetype_marshal_ch::" + "visit_valuetype - " + "codegen for scope failed\n"), + -1); } } - - delete si; } return 0; 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 b00c5805a9d..f16cddc12bc 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/marshal_cs.cpp @@ -154,50 +154,39 @@ be_visitor_valuetype_marshal_cs::gen_fields (be_valuetype *node, int n_processed = 0; TAO_OutStream *os = ctx.stream (); - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) + + this->elem_number_ = 0; + // initialize an iterator to iterate thru our scope + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next()) { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; - // continue until each field is visited - for (;!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); + } + be_field *field = be_field::narrow_from_decl (d); + if (field) { - AST_Decl *d = si->item (); - if (!d) + if (n_processed > 0) + *os << " &&" << be_nl; + ++n_processed; + be_visitor_context* new_ctx = + new be_visitor_context (ctx); + be_visitor_valuetype_field_cdr_ci visitor (new_ctx); + visitor.pre_ = node->field_pd_prefix (); + visitor.post_ = node->field_pd_postfix (); + if (visitor.visit_field (field) == -1) { - delete si; ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); - + "(%N:%l) be_visitor_valuetype_marshal_cs::" + "visit_valuetype - " + "codegen for scope failed\n"), -1); } - be_field *field = be_field::narrow_from_decl (d); - if (field) - { - if (n_processed > 0) - *os << " &&" << be_nl; - ++n_processed; - be_visitor_context* new_ctx = - new be_visitor_context (ctx); - be_visitor_valuetype_field_cdr_ci visitor (new_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); - } - - } - } // end of for loop - delete si; + } } if (n_processed == 0) *os << "1"; diff --git a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp index daaba05c495..329e1b42f3f 100644 --- a/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp +++ b/TAO/TAO_IDL/be/be_visitor_valuetype/valuetype.cpp @@ -49,123 +49,99 @@ be_visitor_valuetype::visit_valuetype (be_valuetype *) int be_visitor_valuetype::visit_valuetype_scope (be_valuetype *node) { - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) - { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - int n_processed = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; - - // continue until each element is visited - for (;!si->is_done ();si->next()) - { - AST_Decl *d = si->item (); + int n_processed = 0; - if (!d) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); - - } + this->elem_number_ = 0; + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next()) + { + AST_Decl *d = si.item (); - AST_Field *field = AST_Field::narrow_from_decl (d); + if (!d) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "bad node in this scope\n"), -1); + } - if (field && field->visibility() == AST_Field::vis_PRIVATE) - { - continue; // ignore private fields in this run - // AST_Attribute derives from AST_Field, so test for - // vis_PRIVATE is ok (the attribute has it set to vis_NA) - } + AST_Field *field = AST_Field::narrow_from_decl (d); - be_decl *bd = be_decl::narrow_from_decl (d); - // set the scope node as "node" in which the code is being - // generated so that elements in the node's scope can use it - // for code generation + if (field && field->visibility() == AST_Field::vis_PRIVATE) + { + continue; // ignore private fields in this run + // AST_Attribute derives from AST_Field, so test for + // vis_PRIVATE is ok (the attribute has it set to vis_NA) + } - this->ctx_->scope (node->decl ()); + be_decl *bd = be_decl::narrow_from_decl (d); + // set the scope node as "node" in which the code is being + // generated so that elements in the node's scope can use it + // for code generation - // set the node to be visited - this->ctx_->node (bd); - this->elem_number_++; + this->ctx_->scope (node->decl ()); - if (bd == 0 || bd->accept (this) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); + // set the node to be visited + this->ctx_->node (bd); + this->elem_number_++; - } - } // end of for loop - - delete si; - - // next run with private fields only - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; - // continue until each element is visited - for (;!si->is_done ();si->next()) + if (bd == 0 || bd->accept (this) == -1) { - AST_Decl *d = si->item (); - - if (!d) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "bad node in this scope\n"), -1); - - } + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "codegen for scope failed\n"), -1); + + } + } // end of for loop - AST_Field *field = AST_Field::narrow_from_decl (d); + this->elem_number_ = 0; + for (UTL_ScopeActiveIterator sj (node, UTL_Scope::IK_decls); + !sj.is_done (); + sj.next()) + { + AST_Decl *d = sj.item (); - if (!field || - (field && field->visibility() != AST_Field::vis_PRIVATE)) - { - continue; // only private fields in this run - } + if (!d) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "bad node in this scope\n"), -1); + } - ++ n_processed; + AST_Field *field = AST_Field::narrow_from_decl (d); - if (n_processed == 1) - { - this->begin_private (); - } + if (!field || + (field && field->visibility() != AST_Field::vis_PRIVATE)) + { + continue; // only private fields in this run + } - be_decl *bd = be_decl::narrow_from_decl (d); - // set the scope node as "node" in which the code is being - // generated so that elements in the node's scope can use it - // for code generation + ++ n_processed; - this->ctx_->scope (node->decl ()); + if (n_processed == 1) + { + this->begin_private (); + } - // set the node to be visited - this->ctx_->node (bd); - this->elem_number_++; + be_decl *bd = be_decl::narrow_from_decl (d); + // set the scope node as "node" in which the code is being + // generated so that elements in the node's scope can use it + // for code generation - if (bd == 0 || bd->accept (this) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), - -1); + this->ctx_->scope (node->decl ()); - } - } // end of for loop + // set the node to be visited + this->ctx_->node (bd); + this->elem_number_++; - delete si; - } // end of if + if (bd == 0 || bd->accept (this) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "codegen for scope failed\n"), + -1); + } + } return 0; } @@ -673,55 +649,44 @@ be_visitor_valuetype::visit_field (be_field *) int be_visitor_valuetype::gen_pd (be_valuetype *node) { - // proceed if the number of members in our scope is greater than 0 - if (node->nmembers () > 0) + int n_processed = 0; + + this->elem_number_ = 0; + + for (UTL_ScopeActiveIterator si (node, UTL_Scope::IK_decls); + !si.is_done (); + si.next()) { - // initialize an iterator to iterate thru our scope - UTL_ScopeActiveIterator *si; - int n_processed = 0; - ACE_NEW_RETURN (si, - UTL_ScopeActiveIterator (node, - UTL_Scope::IK_decls), - -1); - this->elem_number_ = 0; - // continue until each field is visited - for (;!si->is_done ();si->next()) + AST_Decl *d = si.item (); + if (!d) { - AST_Decl *d = si->item (); - if (!d) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "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 - // generated so that elements in the node's scope can use it - // for code generation + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "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 + // generated so that elements in the node's scope can use it + // for code generation - this->ctx_->scope (node->decl ()); + this->ctx_->scope (node->decl ()); - // set the node to be visited - this->ctx_->node (field); - this->elem_number_++; + // set the node to be visited + this->ctx_->node (field); + this->elem_number_++; - if (this->gen_field_pd (field) == -1) - { - delete si; - ACE_ERROR_RETURN ((LM_ERROR, - "(%N:%l) be_visitor_scope::visit_scope - " - "codegen for scope failed\n"), -1); + if (this->gen_field_pd (field) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "(%N:%l) be_visitor_scope::visit_scope - " + "codegen for scope failed\n"), -1); - } - } // end of for loop - delete si; + } } return 0; } |