summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorThorsten Behrens <tbehrens@suse.com>2013-05-22 12:33:06 +0200
committerThorsten Behrens <tbehrens@suse.com>2013-05-22 12:49:07 +0200
commiteed0e18b21cc807b40217d8f4adbfd376cb5d475 (patch)
treef1fd0ed526131f5bd7ece6591f6b0b90c01a0a1f /solenv
parent36ea135d9b9cfbe34de364d32af52d8c9a0ace92 (diff)
Add gdb pretty-printers for basegfx
First cut - polygons and B2DRange covered. Change-Id: I042bff8c3fa5c889a926d450090494e2e20f76b1
Diffstat (limited to 'solenv')
-rwxr-xr-xsolenv/bin/install-gdb-printers4
-rw-r--r--solenv/gdb/libreoffice/basegfx.py170
2 files changed, 173 insertions, 1 deletions
diff --git a/solenv/bin/install-gdb-printers b/solenv/bin/install-gdb-printers
index e55e305226e8..6201e0cfc72c 100755
--- a/solenv/bin/install-gdb-printers
+++ b/solenv/bin/install-gdb-printers
@@ -157,13 +157,14 @@ if [[ ${DESTDIR}${pythondir} != ${GDBDIR} ]]; then
fi
if [[ -n "${MERGELIBS}" ]]; then
- make_autoload merged program libmergedlo."$DYLIB" merge svl tl `[[ ${MERGELIBS} == "ALL" ]] && echo sw`
+ make_autoload merged program libmergedlo."$DYLIB" merge svl tl basegfx `[[ ${MERGELIBS} == "ALL" ]] && echo sw`
if [[ ${MERGELIBS} == "ALL" ]]; then
make_autoload urelibs ure-link/lib liburelibs."$DYLIB" merge cppu sal
else
make_autoload cppu ure-link/lib libuno_cppu."$DYLIB".3
make_autoload sal ure-link/lib libuno_sal."$DYLIB".3
make_autoload sw program libswlo."$DYLIB"
+ make_autoload basegfx program libbasegfxlo."$DYLIB"
fi
else
make_autoload cppu ure-link/lib libuno_cppu."$DYLIB".3
@@ -171,6 +172,7 @@ else
make_autoload svl program libsvllo."$DYLIB"
make_autoload tl program libtllo."$DYLIB"
make_autoload sw program libswlo."$DYLIB"
+ make_autoload basegfx program libbasegfxlo."$DYLIB"
fi
# vim:set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/solenv/gdb/libreoffice/basegfx.py b/solenv/gdb/libreoffice/basegfx.py
new file mode 100644
index 000000000000..10381c1210fa
--- /dev/null
+++ b/solenv/gdb/libreoffice/basegfx.py
@@ -0,0 +1,170 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+import gdb
+
+from libreoffice.util import printing
+
+class B2DRangePrinter(object):
+ '''Prints a B2DRange object.'''
+
+ def __init__(self, typename, value):
+ self.typename = typename
+ self.value = value
+ # inject children() func dynamically
+ if not self._isEmpty():
+ self.children = self._children
+
+ def to_string(self):
+ if self._isEmpty():
+ return "empty %s" % (self.typename)
+ else:
+ return "%s" % (self.typename)
+
+ def _isEmpty(self):
+ return (self.value['maRangeX']['mnMinimum'] > self.value['maRangeX']['mnMaximum']
+ or self.value['maRangeY']['mnMinimum'] > self.value['maRangeY']['mnMaximum'])
+
+ def _children(self):
+ left = self.value['maRangeX']['mnMinimum']
+ top = self.value['maRangeY']['mnMinimum']
+ right = self.value['maRangeX']['mnMaximum']
+ bottom = self.value['maRangeY']['mnMaximum']
+ children = [('left', left), ('top', top), ('right', right), ('bottom', bottom)]
+ return children.__iter__()
+
+class B2DPolygonPrinter(object):
+ '''Prints a B2DPolygon object.'''
+
+ def __init__(self, typename, value):
+ self.typename = typename
+ self.value = value
+ # inject children() func dynamically
+ if not self._isEmpty():
+ self.children = self._children
+
+ def to_string(self):
+ if self._isEmpty():
+ return "empty %s" % (self.typename)
+ else:
+ return "%s %s" % ('bezier curve' if self._hasCurves() else 'straight line',
+ self.typename)
+
+ def _count(self):
+ return int(gdb.parse_and_eval(
+ '((basegfx::B2DPolygon*)%d)->count()' % self.value.address))
+
+ def _isEmpty(self):
+ return self._count() == 0
+
+ def _hasCurves(self):
+ return int(gdb.parse_and_eval(
+ '((basegfx::B2DPolygon*)%d)->areControlPointsUsed()' % self.value.address)) != 0
+
+ def _children(self):
+ if self._hasCurves():
+ return self._bezierIterator(self._count(), self.value)
+ else:
+ return self._plainIterator(self._count(), self.value)
+
+ class _plainIterator(object):
+ def __init__(self, count, value):
+ self.count = count
+ self.value = value
+ self.index = 0
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.index >= self.count:
+ raise StopIteration()
+ currPoint = gdb.parse_and_eval(
+ '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
+ self.value.address, self.index))
+ currPoint = gdb.parse_and_eval(
+ '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
+ self.value.address, self.index))
+ self.index += 1
+ return ('point %d' % (self.index-1),
+ '(%15f, %15f)' % (currPoint['mfX'], currPoint['mfY']))
+
+ class _bezierIterator(object):
+ def __init__(self, count, value):
+ self.count = count
+ self.value = value
+ self.index = 0
+
+ def __iter__(self):
+ return self
+
+ def next(self):
+ if self.index >= self.count:
+ raise StopIteration()
+ currPoint = gdb.parse_and_eval(
+ '((basegfx::B2DPolygon*)%d)->getB2DPoint(%d)' % (
+ self.value.address, self.index))
+ prevControl = gdb.parse_and_eval(
+ '((basegfx::B2DPolygon*)%d)->getPrevControlPoint(%d)' % (
+ self.value.address, self.index))
+ nextControl = gdb.parse_and_eval(
+ '((basegfx::B2DPolygon*)%d)->getNextControlPoint(%d)' % (
+ self.value.address, self.index))
+ self.index += 1
+ return ('point %d' % (self.index-1),
+ 'p: (%15f, %15f) c-1: (%15f, %15f) c1: (%15f, %15f)' %
+ (currPoint['mfX'], currPoint['mfY'],
+ prevControl['mfX'], prevControl['mfY'],
+ nextControl['mfX'], nextControl['mfY']))
+
+class B2DPolyPolygonPrinter(object):
+ '''Prints a B2DPolyPolygon object.'''
+
+ def __init__(self, typename, value):
+ self.typename = typename
+ self.value = value
+
+ def to_string(self):
+ if self._isEmpty():
+ return "empty %s" % (self.typename)
+ else:
+ return "%s %s with %d sub-polygon(s)" % ('closed' if self._isClosed() else 'open',
+ self.typename,
+ self._count())
+
+ def _count(self):
+ return int(gdb.parse_and_eval(
+ '((basegfx::B2DPolyPolygon*)%d)->count()' % self.value.address))
+
+ def _isClosed(self):
+ return int(gdb.parse_and_eval(
+ '((basegfx::B2DPolyPolygon*)%d)->isClosed()' % self.value.address)) != 0
+
+ def _isEmpty(self):
+ return self._count() == 0
+
+printer = None
+
+def build_pretty_printers():
+ global printer
+
+ printer = printing.Printer('libreoffice/basegfx')
+
+ # basic types
+ printer.add('basegfx::B2DRange', B2DRangePrinter)
+ printer.add('basegfx::B2DPolygon', B2DPolygonPrinter)
+ printer.add('basegfx::B2DPolyPolygon', B2DPolyPolygonPrinter)
+
+def register_pretty_printers(obj):
+ printing.register_pretty_printer(printer, obj)
+
+build_pretty_printers()
+
+# vim:set shiftwidth=4 softtabstop=4 expandtab:
+