diff options
author | Steven Knight <knight@baldmt.com> | 2002-01-17 16:50:33 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-01-17 16:50:33 (GMT) |
commit | 18b7084dfae75655011c65ea7354436d04c8790e (patch) | |
tree | 2d13a122cda08922e3a62cba81399e26d0aa315d | |
parent | 97a79ce0ff7031c09ccc3b4afc6edf765182ed5c (diff) | |
download | SCons-18b7084dfae75655011c65ea7354436d04c8790e.zip SCons-18b7084dfae75655011c65ea7354436d04c8790e.tar.gz SCons-18b7084dfae75655011c65ea7354436d04c8790e.tar.bz2 |
Remove the Wrapper class in between the Walker and Node.
-rw-r--r-- | src/CHANGES.txt | 2 | ||||
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 25 |
2 files changed, 12 insertions, 15 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 393db1e..bfc275f 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -31,6 +31,8 @@ RELEASE 0.04 - - Add 'Action' and 'Scanner' to the global keywords so SConscript files can use them too. + - Removed the Wrapper class between Nodes and Walkers. + RELEASE 0.03 - Fri, 11 Jan 2002 01:09:30 -0600 diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 102b532..b11027f 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -59,6 +59,7 @@ class Node: self.depends = [] # explicit dependencies (from Depends) self.implicit = {} # implicit (scanned) dependencies self.parents = [] + self.wkids = None # Kids yet to walk, when it's an array self.builder = None self.scanners = [] self.scanned = {} @@ -217,16 +218,6 @@ class Node: def get_children(node): return node.children() def ignore_cycle(node, stack): pass -class Wrapper: - def __init__(self, node, kids_func): - self.node = node - self.kids = copy.copy(kids_func(node)) - - # XXX randomize kids here, if requested - - def __str__(self): - return str(self.node) - class Walker: """An iterator for walking a Node tree. @@ -244,7 +235,8 @@ class Walker: def __init__(self, node, kids_func=get_children, cycle_func=ignore_cycle): self.kids_func = kids_func self.cycle_func = cycle_func - self.stack = [Wrapper(node, self.kids_func)] + node.wkids = copy.copy(kids_func(node)) + self.stack = [node] self.history = {} # used to efficiently detect and avoid cycles self.history[node] = None @@ -256,15 +248,18 @@ class Walker: """ while self.stack: - if self.stack[-1].kids: - node = self.stack[-1].kids.pop(0) + if self.stack[-1].wkids: + node = self.stack[-1].wkids.pop(0) + if not self.stack[-1].wkids: + self.stack[-1].wkids = None if self.history.has_key(node): self.cycle_func(node, self.stack) else: - self.stack.append(Wrapper(node, self.kids_func)) + node.wkids = copy.copy(self.kids_func(node)) + self.stack.append(node) self.history[node] = None else: - node = self.stack.pop().node + node = self.stack.pop() del self.history[node] return node |