summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/python-extensions.swig
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2012-10-08 17:32:55 +0000
committerEnrico Granata <egranata@apple.com>2012-10-08 17:32:55 +0000
commit944b4c4c1b39dbe63f4f2547704a8eb02fb299ba (patch)
tree92c8ad1864d885d654fa8571dcab9af23fba8b47 /lldb/scripts/Python/python-extensions.swig
parent5c6e08435eafb271b5fe148fc9e55d993007aac7 (diff)
downloadbcm5719-llvm-944b4c4c1b39dbe63f4f2547704a8eb02fb299ba.tar.gz
bcm5719-llvm-944b4c4c1b39dbe63f4f2547704a8eb02fb299ba.zip
Retrying to apply Vishal's patch - hopefully this time it won't break Jason's build
llvm-svn: 165410
Diffstat (limited to 'lldb/scripts/Python/python-extensions.swig')
-rw-r--r--lldb/scripts/Python/python-extensions.swig32
1 files changed, 20 insertions, 12 deletions
diff --git a/lldb/scripts/Python/python-extensions.swig b/lldb/scripts/Python/python-extensions.swig
index f9e5a130dbd..050af3a9b0b 100644
--- a/lldb/scripts/Python/python-extensions.swig
+++ b/lldb/scripts/Python/python-extensions.swig
@@ -539,13 +539,15 @@ class value(object):
# Allow array access if this value has children...
if type(key) is int:
return value(self.sbvalue.GetValueForExpressionPath("[%i]" % key))
- raise TypeError
+ if type(key) is value:
+ return value(self.sbvalue.GetValueForExpressionPath("[%i]" % int(key))
+ raise TypeError("No array item of type %s" % str(type(key)))
def __getattr__(self, name):
child_sbvalue = self.sbvalue.GetChildMemberWithName (name)
if child_sbvalue:
return value(child_sbvalue)
- raise AttributeError
+ raise AttributeError("Attribute '%s' is not defined" % name)
def __add__(self, other):
return int(self) + int(other)
@@ -690,16 +692,22 @@ class value(object):
return '0x%x' % self.sbvalue.GetValueAsUnsigned()
def __eq__(self, other):
- self_err = SBError()
- other_err = SBError()
- self_val = self.sbvalue.GetValueAsUnsigned(self_err)
- if self_err.fail:
- raise ValueError("unable to extract value of self")
- other_val = other.sbvalue.GetValueAsUnsigned(other_err)
- if other_err.fail:
- raise ValueError("unable to extract value of other")
- return self_val == other_val
-
+ if type(other) is int:
+ return int(self) == other
+ elif type(other) is str:
+ return str(self) == other
+ elif type(other) is value:
+ self_err = SBError()
+ other_err = SBError()
+ self_val = self.sbvalue.GetValueAsUnsigned(self_err)
+ if self_err.fail:
+ raise ValueError("unable to extract value of self")
+ other_val = other.sbvalue.GetValueAsUnsigned(other_err)
+ if other_err.fail:
+ raise ValueError("unable to extract value of other")
+ return self_val == other_val
+ raise TypeError("Unknown type %s, No equality operation defined." % str(type(other)))
+
def __neq__(self, other):
return not self.__eq__(other)
%}
OpenPOWER on IntegriCloud