+class wxDateTimePrinter:
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ # A value of type wxLongLong can't be used in Python arithmetic
+ # expressions directly so we need to convert it to long long first and
+ # then cast to int explicitly to be able to use it as a timestamp.
+ msec = self.val['m_time'].cast(gdb.lookup_type('long long'))
+ if msec == 0x8000000000000000:
+ return 'NONE'
+ sec = int(msec / 1000)
+ return datetime.datetime.fromtimestamp(sec).isoformat(' ')
+
+class wxFileNamePrinter:
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ # It is simpler to just call the internal function here than to iterate
+ # over m_dirs array ourselves. The disadvantage of this approach is
+ # that it requires a live inferior process and so doesn't work when
+ # debugging using only a core file. If this ever becomes a serious
+ # problem, this should be rewritten to use m_dirs and m_name and m_ext.
+ return gdb.parse_and_eval('((wxFileName*)%s)->GetFullPath(0)' %
+ self.val.address)
+
+class wxXYPrinterBase:
+ def __init__(self, val):
+ self.x = val['x']
+ self.y = val['y']
+
+class wxPointPrinter(wxXYPrinterBase):
+ def to_string(self):
+ return '(%d, %d)' % (self.x, self.y)
+
+class wxSizePrinter(wxXYPrinterBase):
+ def to_string(self):
+ return '%d*%d' % (self.x, self.y)
+
+class wxRectPrinter(wxXYPrinterBase):
+ def __init__(self, val):
+ wxXYPrinterBase.__init__(self, val)
+ self.width = val['width']
+ self.height = val['height']
+
+ def to_string(self):
+ return '(%d, %d) %d*%d' % (self.x, self.y, self.width, self.height)
+
+
+# The function looking up the pretty-printer to use for the given value.