summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/util/utl_stack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/TAO_IDL/util/utl_stack.cpp')
-rw-r--r--TAO/TAO_IDL/util/utl_stack.cpp103
1 files changed, 60 insertions, 43 deletions
diff --git a/TAO/TAO_IDL/util/utl_stack.cpp b/TAO/TAO_IDL/util/utl_stack.cpp
index 29f6dc49b26..1ab831aa0b9 100644
--- a/TAO/TAO_IDL/util/utl_stack.cpp
+++ b/TAO/TAO_IDL/util/utl_stack.cpp
@@ -68,9 +68,9 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
* utl_stack.cc - Implementation of class UTL_ScopeStack
*/
-#include "idl.h"
+#include "idl.h"
#include "ast_decl.h"
-#include "idl_extern.h"
+#include "idl_extern.h"
ACE_RCSID(util, utl_stack, "$Id$")
@@ -83,17 +83,20 @@ ACE_RCSID(util, utl_stack, "$Id$")
* Constructor(s) and destructor
*/
-UTL_ScopeStack::UTL_ScopeStack()
- : pd_stack_data(new UTL_Scope *[INCREMENT]),
- pd_stack_data_nalloced(INCREMENT),
- pd_stack_top(0)
+UTL_ScopeStack::UTL_ScopeStack (void)
+ : pd_stack_data_nalloced (INCREMENT),
+ pd_stack_top (0)
{
+ ACE_NEW (this->pd_stack_data,
+ UTL_Scope *[INCREMENT]);
}
-UTL_ScopeStack::~UTL_ScopeStack()
+UTL_ScopeStack::~UTL_ScopeStack (void)
{
- if (pd_stack_data != NULL)
- delete pd_stack_data;
+ if (this->pd_stack_data != 0)
+ {
+ delete this->pd_stack_data;
+ }
}
/*
@@ -158,36 +161,42 @@ UTL_ScopeStack::pop (void)
--this->pd_stack_top;
}
-// Return top element on stack
+// Return top element on stack.
UTL_Scope *
UTL_ScopeStack::top (void)
{
- if (pd_stack_top <= 0)
- return NULL;
- return pd_stack_data[pd_stack_top - 1];
+ if (this->pd_stack_top <= 0)
+ {
+ return 0;
+ }
+
+ return this->pd_stack_data[pd_stack_top - 1];
}
-// Return bottom element on stack
+// Return bottom element on stack.
UTL_Scope *
UTL_ScopeStack::bottom (void)
{
- if (pd_stack_top == 0)
- return NULL;
- return pd_stack_data[0];
+ if (this->pd_stack_top == 0)
+ {
+ return 0;
+ }
+
+ return this->pd_stack_data[0];
}
// Clear entire stack
void
UTL_ScopeStack::clear (void)
{
- pd_stack_top = 0;
+ this->pd_stack_top = 0;
}
// How deep is the stack?
unsigned long
UTL_ScopeStack::depth (void)
{
- return pd_stack_top;
+ return this->pd_stack_top;
}
// Return (top - 1) element on stack
@@ -197,12 +206,14 @@ UTL_ScopeStack::next_to_top (void)
UTL_Scope *tmp, *retval;
if (depth() < 2)
- return NULL;
+ {
+ return 0;
+ }
- tmp = top(); // Save top
- (void) pop(); // Pop it
- retval = top(); // Get next one down
- (void) push(tmp); // Push top back
+ tmp = top (); // Save top
+ (void) pop (); // Pop it
+ retval = top (); // Get next one down
+ (void) push (tmp); // Push top back
return retval; // Return next one down
}
@@ -210,12 +221,15 @@ UTL_ScopeStack::next_to_top (void)
UTL_Scope *
UTL_ScopeStack::top_non_null (void)
{
- long i;
+ for (long i = this->pd_stack_top - 1; i >= 0; --i)
+ {
+ if (this->pd_stack_data[i] != 0)
+ {
+ return this->pd_stack_data[i];
+ }
+ }
- for (i = pd_stack_top - 1; i >= 0; i--)
- if (pd_stack_data[i] != NULL)
- return pd_stack_data[i];
- return NULL;
+ return 0;
}
/*
@@ -228,9 +242,9 @@ UTL_ScopeStack::top_non_null (void)
* Constructor(s)
*/
-UTL_ScopeStackActiveIterator::UTL_ScopeStackActiveIterator(UTL_ScopeStack *s)
- : source(s),
- il(s->pd_stack_top - 1)
+UTL_ScopeStackActiveIterator::UTL_ScopeStackActiveIterator (UTL_ScopeStack &s)
+ : source (s),
+ il (s.pd_stack_top - 1)
{
}
@@ -244,29 +258,32 @@ UTL_ScopeStackActiveIterator::UTL_ScopeStackActiveIterator(UTL_ScopeStack *s)
// Advance to next item
void
-UTL_ScopeStackActiveIterator::next()
+UTL_ScopeStackActiveIterator::next (void)
{
il--;
}
// Get current item
UTL_Scope *
-UTL_ScopeStackActiveIterator::item()
+UTL_ScopeStackActiveIterator::item (void)
{
- if (il >= 0)
- return source->pd_stack_data[il];
- return NULL;
+ if (this->il >= 0)
+ {
+ return this->source.pd_stack_data[il];
+ }
+
+ return 0;
}
// Is this iteration done?
long
-UTL_ScopeStackActiveIterator::is_done()
+UTL_ScopeStackActiveIterator::is_done (void)
{
- if (il >= 0)
- return I_FALSE;
+ if (this->il >= 0)
+ {
+ return I_FALSE;
+ }
+
return I_TRUE;
}
-/*
- * Redefinition of inherited virtual operations
- */