forked from qt-creator/qt-creator
Debugger: Allow use of regular expressions for dumpers
The pattern is given as (unused) default value of a third parameter of the dump__* functions. Change-Id: Ia9092427c240f2198acd00267cd136a3becc71b6 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -30,6 +30,7 @@ import base64
|
|||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
|
import inspect
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
xrange = range
|
xrange = range
|
||||||
@@ -372,7 +373,8 @@ class DumperBase:
|
|||||||
self.qqFormats = { "QVariant (QVariantMap)" : mapForms() }
|
self.qqFormats = { "QVariant (QVariantMap)" : mapForms() }
|
||||||
|
|
||||||
# This is a cache of all known dumpers.
|
# This is a cache of all known dumpers.
|
||||||
self.qqDumpers = {}
|
self.qqDumpers = {} # Direct type match
|
||||||
|
self.qqDumpersEx = {} # Using regexp
|
||||||
|
|
||||||
# This is a cache of all dumpers that support writing.
|
# This is a cache of all dumpers that support writing.
|
||||||
self.qqEditable = {}
|
self.qqEditable = {}
|
||||||
@@ -1025,6 +1027,12 @@ class DumperBase:
|
|||||||
dumper(self, value)
|
dumper(self, value)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
for pattern in self.qqDumpersEx.keys():
|
||||||
|
dumper = self.qqDumpersEx[pattern]
|
||||||
|
if re.match(pattern, nsStrippedType):
|
||||||
|
dumper(self, value)
|
||||||
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def putSimpleCharArray(self, base, size = None):
|
def putSimpleCharArray(self, base, size = None):
|
||||||
@@ -1731,11 +1739,13 @@ class DumperBase:
|
|||||||
|
|
||||||
def registerDumper(self, funcname, function):
|
def registerDumper(self, funcname, function):
|
||||||
try:
|
try:
|
||||||
#warn("FUNCTION: %s " % funcname)
|
|
||||||
#funcname = function.func_name
|
|
||||||
if funcname.startswith("qdump__"):
|
if funcname.startswith("qdump__"):
|
||||||
typename = funcname[7:]
|
typename = funcname[7:]
|
||||||
self.qqDumpers[typename] = function
|
spec = inspect.getargspec(function)
|
||||||
|
if len(spec.args) == 2:
|
||||||
|
self.qqDumpers[typename] = function
|
||||||
|
elif len(spec.args) == 3 and len(spec.defaults) == 1:
|
||||||
|
self.qqDumpersEx[spec.defaults[0]] = function
|
||||||
self.qqFormats[typename] = self.qqFormats.get(typename, [])
|
self.qqFormats[typename] = self.qqFormats.get(typename, [])
|
||||||
elif funcname.startswith("qform__"):
|
elif funcname.startswith("qform__"):
|
||||||
typename = funcname[7:]
|
typename = funcname[7:]
|
||||||
|
Reference in New Issue
Block a user