Commit bc16e882 authored by Eike Ziller's avatar Eike Ziller Committed by hjk
Browse files

dumpers: share the code for extractTemplateArgument



Change-Id: Ic1b03d2dffdfb7ba6ead191601127b54af38b3cd
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 4afa596a
......@@ -340,6 +340,34 @@ class DumperBase:
def stringData(self, value):
return self.byteArrayDataHelper(self.dereferenceValue(value))
def extractTemplateArgument(self, typename, position):
level = 0
skipSpace = False
inner = ''
for c in typename[typename.find('<') + 1 : -1]:
if c == '<':
inner += c
level += 1
elif c == '>':
level -= 1
inner += c
elif c == ',':
if level == 0:
if position == 0:
return inner.strip()
position -= 1
inner = ''
else:
inner += c
skipSpace = True
else:
if skipSpace and c == ' ':
pass
else:
inner += c
skipSpace = False
return inner.strip()
def putStringValue(self, value):
return self.putValue(self.encodeString(value), Hex4EncodedLittleEndian)
......
......@@ -596,35 +596,6 @@ def lookupType(typestring):
typesToReport[typestring] = type
return type
def extractTemplateArgument(type, position):
level = 0
skipSpace = False
inner = ""
type = str(type)
for c in type[type.find('<') + 1 : -1]:
if c == '<':
inner += c
level += 1
elif c == '>':
level -= 1
inner += c
elif c == ',':
if level == 0:
if position == 0:
return inner
position -= 1
inner = ""
else:
inner += c
skipSpace = True
else:
if skipSpace and c == ' ':
pass
else:
inner += c
skipSpace = False
return inner
def templateArgument(type, position):
try:
# This fails on stock 7.2 with
......@@ -632,7 +603,7 @@ def templateArgument(type, position):
return type.template_argument(position)
except:
# That's something like "myns::QList<...>"
return lookupType(extractTemplateArgument(type.strip_typedefs(), position))
return lookupType(self.extractTemplateArgument(str(type.strip_typedefs()), position))
# Workaround for gdb < 7.1
......
......@@ -431,34 +431,6 @@ class Dumper(DumperBase):
def directBaseClass(self, typeobj, index = 0):
return typeobj.GetDirectBaseClassAtIndex(index)
def extractTemplateArgument(self, typename, index):
level = 0
skipSpace = False
inner = ''
for c in typename[typename.find('<') + 1 : -1]:
if c == '<':
inner += c
level += 1
elif c == '>':
level -= 1
inner += c
elif c == ',':
if level == 0:
if index == 0:
return inner.strip()
index -= 1
inner = ''
else:
inner += c
skipSpace = True
else:
if skipSpace and c == ' ':
pass
else:
inner += c
skipSpace = False
return inner.strip()
def templateArgument(self, typeobj, index):
type = typeobj.GetTemplateArgumentType(index)
if type.IsValid():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment