6068e63
2010-06-01  Chris Moller  <cmoller@redhat.com>
6068e63
6068e63
	* python/libstdcxx/v6/printers.py (StdVectorPrinter): Add
6068e63
	detection for matrices as nested vectors.
6068e63
6068e63
Index: libstdc++-v3/python/libstdcxx/v6/printers.py
6068e63
===================================================================
6068e63
--- ./libstdc++-v3-python-r155978/libstdcxx/v6/printers.py	(revision 159937)
6068e63
+++ ./libstdc++-v3-python-r155978/libstdcxx/v6/printers.py	(working copy)
6068e63
@@ -19,6 +19,9 @@
6068e63
 import itertools
6068e63
 import re
6068e63
 
6068e63
+vector_sig = 'std::vector'
6068e63
+vector_regex = re.compile('^' + vector_sig + '<.*>$')
6068e63
+
6068e63
 class StdPointerPrinter:
6068e63
     "Print a smart pointer of some kind"
6068e63
 
6068e63
@@ -186,7 +189,13 @@
6068e63
                 % (self.typename, int (finish - start), int (end - start)))
6068e63
 
6068e63
     def display_hint(self):
6068e63
-        return 'array'
6068e63
+        itype0  = self.val.type.template_argument(0)
6068e63
+        itag = itype0.tag
6068e63
+        if itag and re.match(vector_regex, itag):
6068e63
+            rc = 'matrix'
6068e63
+        else:
6068e63
+            rc = 'array'
6068e63
+        return rc 
6068e63
 
6068e63
 class StdVectorIteratorPrinter:
6068e63
     "Print std::vector::iterator"
6068e63
@@ -692,7 +701,7 @@
6068e63
     pretty_printers_dict[re.compile('^std::set<.*>$')] = lambda val: StdSetPrinter("std::set", val)
6068e63
     pretty_printers_dict[re.compile('^std::stack<.*>$')] = lambda val: StdStackOrQueuePrinter("std::stack", val)
6068e63
     pretty_printers_dict[re.compile('^std::unique_ptr<.*>$')] = UniquePointerPrinter
6068e63
-    pretty_printers_dict[re.compile('^std::vector<.*>$')] = lambda val: StdVectorPrinter("std::vector", val)
6068e63
+    pretty_printers_dict[vector_regex] = lambda val: StdVectorPrinter(vector_sig, val)
6068e63
     # vector<bool>
6068e63
 
6068e63
     # Printer registrations for classes compiled with -D_GLIBCXX_DEBUG.