diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2015-05-01 20:47:55 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2015-05-01 20:47:55 +0100 |
commit | a00d74c4903b344910f1062e1746c15138c8f4b1 (patch) | |
tree | 27fc9999afd8c9cdf4340b529b60b1eb0e1e7216 /libstdc++-v3/python | |
parent | d532ea918144fc0fe34c81da78394efcff434d41 (diff) | |
download | gcc-a00d74c4903b344910f1062e1746c15138c8f4b1.zip gcc-a00d74c4903b344910f1062e1746c15138c8f4b1.tar.gz gcc-a00d74c4903b344910f1062e1746c15138c8f4b1.tar.bz2 |
fs_path.h (path::_List): Use vector instead of list.
* include/experimental/fs_path.h (path::_List): Use vector instead of
list.
* python/libstdcxx/v6/printers.py (StdExpPathPrinter): Adapt.
* src/filesystem/path.cc: Use std::prev instead of decrementing
rvalues. Fix whitespace.
* testsuite/experimental/filesystem/path/decompose/parent_path.cc:
Do not decrement iterators before begin.
From-SVN: r222702
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r-- | libstdc++-v3/python/libstdcxx/v6/printers.py | 53 |
1 files changed, 44 insertions, 9 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 37c3b9b..c6f96d7 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -984,16 +984,51 @@ class StdExpPathPrinter: def __init__ (self, typename, val): self.val = val - self.list_visualizer = gdb.default_visualizer(val['_M_cmpts']) + start = self.val['_M_cmpts']['_M_impl']['_M_start'] + finish = self.val['_M_cmpts']['_M_impl']['_M_finish'] + self.num_cmpts = int (finish - start) + + def _path_type(self): + t = str(self.val['_M_type']) + if t[-9:] == '_Root_dir': + return "root-directory" + if t[-10:] == '_Root_name': + return "root-name" + return None def to_string (self): - path = self.val ['_M_pathname'] - if self.list_visualizer: - list_head = self.val['_M_cmpts']['_M_impl']['_M_node'] - if list_head.address != list_head['_M_next']: - cmpts = self.list_visualizer.to_string() - path = "%s [Components %s]" % (path, cmpts) - return path + path = "%s" % self.val ['_M_pathname'] + if self.num_cmpts == 0: + t = self._path_type() + if t: + path = '%s [%s]' % (path, t) + return "filesystem::path %s" % path + + class _iterator(Iterator): + def __init__(self, cmpts): + self.item = cmpts['_M_impl']['_M_start'] + self.finish = cmpts['_M_impl']['_M_finish'] + self.count = 0 + + def __iter__(self): + return self + + def __next__(self): + if self.item == self.finish: + raise StopIteration + item = self.item.dereference() + count = self.count + self.count = self.count + 1 + self.item = self.item + 1 + path = item['_M_pathname'] + t = StdExpPathPrinter(item.type.name, item)._path_type() + if not t: + t = count + return ('[%s]' % t, path) + + def children(self): + return self._iterator(self.val['_M_cmpts']) + # A "regular expression" printer which conforms to the # "SubPrettyPrinter" protocol from gdb.printing. @@ -1383,7 +1418,7 @@ def build_libstdcxx_dictionary (): # Filesystem TS components libstdcxx_printer.add_version('std::experimental::filesystem::v1::', 'path', StdExpPathPrinter) - libstdcxx_printer.add_version('std::experimental::filesystem::v1::__cxx11', + libstdcxx_printer.add_version('std::experimental::filesystem::v1::__cxx11::', 'path', StdExpPathPrinter) # Extensions. |