aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/python
diff options
context:
space:
mode:
authorPhilipp Fent <fent@in.tum.de>2022-04-25 13:03:31 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-04-25 13:32:04 +0100
commit71999fde2a454d1fa149e63825d8edbe0748c911 (patch)
treeff6a87cb294117a3d5a0b70de6d392a3dc3badfb /libstdc++-v3/python
parent6cc26f3037a18b9a958b4ac2a1363149a7fccd39 (diff)
downloadgcc-71999fde2a454d1fa149e63825d8edbe0748c911.zip
gcc-71999fde2a454d1fa149e63825d8edbe0748c911.tar.gz
gcc-71999fde2a454d1fa149e63825d8edbe0748c911.tar.bz2
libstdc++: Add pretty printer for std::initializer_list
Re-using the std::span printer, this now shows the contents of the initializer list instead of the pointer and length members. Signed-off-by: Philipp Fent <fent@in.tum.de> libstdc++-v3/ChangeLog: * python/libstdcxx/v6/printers.py (StdSpanPrinter._iterator): Rename as iterator. (StdInitializerListPrinter): Define new printer. (build_libstdcxx_dictionary): Register new printer. * testsuite/libstdc++-prettyprinters/cxx11.cc: Check printer for initializer_list.
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r--libstdc++-v3/python/libstdcxx/v6/printers.py24
1 files changed, 22 insertions, 2 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 6d8b765..c31134b 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -1657,7 +1657,7 @@ class StdRegexStatePrinter:
class StdSpanPrinter:
"Print a std::span"
- class _iterator(Iterator):
+ class iterator(Iterator):
def __init__(self, begin, size):
self.count = 0
self.begin = begin
@@ -1686,7 +1686,24 @@ class StdSpanPrinter:
return '%s of length %d' % (self.typename, self.size)
def children(self):
- return self._iterator(self.val['_M_ptr'], self.size)
+ return self.iterator(self.val['_M_ptr'], self.size)
+
+ def display_hint(self):
+ return 'array'
+
+class StdInitializerListPrinter:
+ "Print a std::initializer_list"
+
+ def __init__(self, typename, val):
+ self.typename = typename
+ self.val = val
+ self.size = val['_M_len']
+
+ def to_string(self):
+ return '%s of length %d' % (self.typename, self.size)
+
+ def children(self):
+ return StdSpanPrinter.iterator(self.val['_M_array'], self.size)
def display_hint(self):
return 'array'
@@ -2156,6 +2173,9 @@ def build_libstdcxx_dictionary ():
libstdcxx_printer.add_version('std::tr1::', 'unordered_multiset',
Tr1UnorderedSetPrinter)
+ libstdcxx_printer.add_version('std::', 'initializer_list',
+ StdInitializerListPrinter)
+
# std::regex components
libstdcxx_printer.add_version('std::__detail::', '_State',
StdRegexStatePrinter)