[Lldb-commits] [lldb] r165410 - /lldb/trunk/scripts/Python/python-extensions.swig

Enrico Granata egranata at apple.com
Mon Oct 8 10:32:55 PDT 2012


Author: enrico
Date: Mon Oct  8 12:32:55 2012
New Revision: 165410

URL: http://llvm.org/viewvc/llvm-project?rev=165410&view=rev
Log:
Retrying to apply Vishal's patch - hopefully this time it won't break Jason's build

Modified:
    lldb/trunk/scripts/Python/python-extensions.swig

Modified: lldb/trunk/scripts/Python/python-extensions.swig
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/python-extensions.swig?rev=165410&r1=165409&r2=165410&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/python-extensions.swig (original)
+++ lldb/trunk/scripts/Python/python-extensions.swig Mon Oct  8 12:32:55 2012
@@ -539,13 +539,15 @@
         # 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 @@
         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)
 %}





More information about the lldb-commits mailing list