[pygccxml-commit] source/pyplusplus/experimental treerange.py,1.1,1.2
Brought to you by:
mbaas,
roman_yakovenko
From: Matthias B. <mb...@us...> - 2006-03-15 17:12:22
|
Update of /cvsroot/pygccxml/source/pyplusplus/experimental In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31182 Modified Files: treerange.py Log Message: The main intersect() function was plain wrong. Index: treerange.py =================================================================== RCS file: /cvsroot/pygccxml/source/pyplusplus/experimental/treerange.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** treerange.py 14 Mar 2006 22:48:53 -0000 1.1 --- treerange.py 15 Mar 2006 17:12:17 -0000 1.2 *************** *** 9,12 **** --- 9,14 ---- """ + from pygccxml.declarations import scopedef_t + # TreeRange class TreeRange: *************** *** 93,97 **** for ch in children: yield ch ! if recursive: for node in self._iterdecls(ch, True): yield node --- 95,99 ---- for ch in children: yield ch ! if recursive and isinstance(ch, scopedef_t): for node in self._iterdecls(ch, True): yield node *************** *** 102,105 **** --- 104,108 ---- The ranges are iterated from bottom to top. + All ranges are disjoint! """ *************** *** 124,130 **** """ ! res = self for rng in other.iterRanges(): ! res = res._simpleIntersect(rng) return res --- 127,141 ---- """ ! res = TreeRange(None, False) ! ! # Intersect self with each disjoint component of other and ! # "add" the result to res... for rng in other.iterRanges(): ! intersection = self._simpleIntersect(rng) ! res = res.union(intersection) ! ! # Check if the result only contains one sub range... ! if res.parent==None and len(res.subranges)==1: ! res = res.subranges[0] return res *************** *** 330,333 **** --- 341,352 ---- return res + def _dump(self, level=0): + """Dump the range tree for debugging purposes. + """ + s = "Rng: (%s:%s, %s)"%(getattr(self.parent, "name", "None"), self.parent.__class__.__name__, self.recursive) + print "%s%s"%((2*level)*" ", s) + for sr in self.subranges: + sr._dump(level+1) + ###################################################################### |