Lines Matching refs:printer

1 # Pretty-printer utilities.
25 """A basic pretty-printer.
35 enabled: A boolean indicating if the printer is enabled.
37 Subprinters are for situations where "one" pretty-printer is actually a
38 collection of several printers. E.g., The libstdc++ pretty-printer has
39 a pretty-printer for each of several different types, based on regexps.
71 def register_pretty_printer(obj, printer):
72 """Register pretty-printer PRINTER with OBJ.
74 The printer is added to the front of the search list, thus one can override
75 an existing printer if one needs to.
78 obj: Either an objfile, progspace, or None (in which case the printer
80 printer: Either a function of one argument (old way) or any object
87 TypeError: A problem with the type of the printer.
88 ValueError: The printer's name contains a semicolon ";".
90 If the caller wants the printer to be listable and disableable, it must
92 If printer is an object, __call__ is a method of two arguments:
99 # If printer has both, we use `name'.
100 if not hasattr(printer, "__name__") and not hasattr(printer, "name"):
101 raise TypeError("printer missing attribute: name")
102 if hasattr(printer, "name") and not hasattr(printer, "enabled"):
103 raise TypeError("printer missing attribute: enabled")
104 if not hasattr(printer, "__call__"):
105 raise TypeError("printer missing attribute: __call__")
109 gdb.write("Registering global %s pretty-printer ...\n" % name)
113 gdb.write("Registering %s pretty-printer for %s ...\n" %
114 (printer.name, obj.filename))
116 if hasattr(printer, "name"):
117 if not isinstance(printer.name, basestring):
118 raise TypeError("printer name is not a string")
119 # If printer provides a name, make sure it doesn't contain ";".
120 # Semicolon is used by the info/enable/disable pretty-printer commands
122 if printer.name.find(";") >= 0:
123 raise ValueError("semicolon ';' in printer name")
128 if (printer.name in
130 raise RuntimeError("pretty-printer already registered: %s" %
131 printer.name)
133 obj.pretty_printers.insert(0, printer)
159 """Add a printer to the list.
161 The printer is added to the end of the list.
173 # NOTE: A previous version made the name of each printer the regexp.
182 """Lookup the pretty-printer for the provided value."""
190 # if a printer is registered for that type.
191 # Return an instantiation of the printer if found.
192 for printer in self.subprinters:
193 if printer.enabled and printer.compiled_re.search(typename):
194 return printer.gen_printer(val)
196 # Cannot find a pretty printer. Return None.