]> git.rmz.io Git - dotfiles.git/blob - gdb/kde.py
vim: do not set pastetoggle in nvim
[dotfiles.git] / gdb / kde.py
1 # -*- coding: utf-8 -*-
2 # Pretty-printers for KDE4.
3
4 # Copyright (C) 2009 Milian Wolff <mail@milianw.de>
5 # Copyright (C) 2014 Kevin Funk <kfunk@kde.org>
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 import gdb
21 import itertools
22 import re
23
24 import qt
25
26 from helper import *
27
28 class KDevelop_Path:
29 def __init__(self, val):
30 self.val = val
31
32 def to_string(self):
33 iterator = qt.QVectorPrinter(self.val['m_data'], 'QVector').children()
34 pathSegments = [str(it[1]) for it in iterator]
35 return "(" + ", ".join(pathSegments) + ")" if pathSegments else None
36
37 class KTextEditor_CursorPrinter:
38 "Pretty Printer for KTextEditor::Cursor"
39
40 def __init__(self, val):
41 self.val = val
42
43 def to_string(self):
44 return "[%d, %d]" % (self.val['m_line'], self.val['m_column'])
45
46 class KTextEditor_RangePrinter:
47 "Pretty Printer for KTextEditor::Range"
48
49 def __init__(self, val):
50 self.val = val
51
52 def to_string(self):
53 return "[(%d, %d) -> (%d, %d)]" % (self.val['m_start']['m_line'], self.val['m_start']['m_column'],
54 self.val['m_end']['m_line'], self.val['m_end']['m_column'])
55
56 pretty_printers_dict = {}
57
58 def register_kde_printers (obj):
59 if obj == None:
60 obj = gdb
61
62 obj.pretty_printers.append(FunctionLookup(gdb, pretty_printers_dict))
63
64 def build_dictionary ():
65 pretty_printers_dict[re.compile('^KDevelop::Path$')] = lambda val: KDevelop_Path(val)
66
67 pretty_printers_dict[re.compile('^KTextEditor::Cursor$')] = lambda val: KTextEditor_CursorPrinter(val)
68 pretty_printers_dict[re.compile('^KTextEditor::Range$')] = lambda val: KTextEditor_RangePrinter(val)
69
70 build_dictionary ()