]> git.pld-linux.org Git - packages/gcc.git/blame - gcc-python-pretty-printer-bool-vector.patch
- rel 6; branch diff update
[packages/gcc.git] / gcc-python-pretty-printer-bool-vector.patch
CommitLineData
3e4cc0df
PS
1--- libstdc++-v3/python/libstdcxx/v6/printers.py (revision 163281)
2+++ libstdc++-v3/python/libstdcxx/v6/printers.py (revision 163282)
3@@ -153,37 +153,71 @@
4 "Print a std::vector"
5
6 class _iterator:
7- def __init__ (self, start, finish):
8- self.item = start
9- self.finish = finish
10+ def __init__ (self, start, finish, bitvec):
11+ self.bitvec = bitvec
12+ if bitvec:
13+ self.item = start['_M_p']
14+ self.so = start['_M_offset']
15+ self.finish = finish['_M_p']
16+ self.fo = finish['_M_offset']
17+ itype = self.item.dereference().type
18+ self.isize = 8 * itype.sizeof
19+ else:
20+ self.item = start
21+ self.finish = finish
22 self.count = 0
23
24 def __iter__(self):
25 return self
26
27 def next(self):
28- if self.item == self.finish:
29- raise StopIteration
30 count = self.count
31 self.count = self.count + 1
32- elt = self.item.dereference()
33- self.item = self.item + 1
34- return ('[%d]' % count, elt)
35+ if self.bitvec:
36+ if self.item == self.finish and self.so >= self.fo:
37+ raise StopIteration
38+ elt = self.item.dereference()
39+ obit = 1 if elt & (1 << self.so) else 0
40+ self.so = self.so + 1
41+ if self.so >= self.isize:
42+ self.item = self.item + 1
43+ self.so = 0
44+ return ('[%d]' % count, obit)
45+ else:
46+ if self.item == self.finish:
47+ raise StopIteration
48+ elt = self.item.dereference()
49+ self.item = self.item + 1
50+ return ('[%d]' % count, elt)
51
52 def __init__(self, typename, val):
53 self.typename = typename
54 self.val = val
55+ self.is_bool = val.type.template_argument(0).code == gdb.TYPE_CODE_BOOL
56
57 def children(self):
58 return self._iterator(self.val['_M_impl']['_M_start'],
59- self.val['_M_impl']['_M_finish'])
60+ self.val['_M_impl']['_M_finish'],
61+ self.is_bool)
62
63 def to_string(self):
64 start = self.val['_M_impl']['_M_start']
65 finish = self.val['_M_impl']['_M_finish']
66 end = self.val['_M_impl']['_M_end_of_storage']
67- return ('%s of length %d, capacity %d'
68- % (self.typename, int (finish - start), int (end - start)))
69+ if self.is_bool:
70+ start = self.val['_M_impl']['_M_start']['_M_p']
71+ so = self.val['_M_impl']['_M_start']['_M_offset']
72+ finish = self.val['_M_impl']['_M_finish']['_M_p']
73+ fo = self.val['_M_impl']['_M_finish']['_M_offset']
74+ itype = start.dereference().type
75+ bl = 8 * itype.sizeof
76+ length = (bl - so) + bl * ((finish - start) - 1) + fo
77+ capacity = bl * (end - start)
78+ return ('%s<bool> of length %d, capacity %d'
79+ % (self.typename, int (length), int (capacity)))
80+ else:
81+ return ('%s of length %d, capacity %d'
82+ % (self.typename, int (finish - start), int (end - start)))
83
84 def display_hint(self):
85 return 'array'
This page took 0.037971 seconds and 4 git commands to generate.