diff options
| author | Peter LaFosse <peter@vector35.com> | 2020-05-02 11:01:35 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2020-05-03 13:20:56 -0400 |
| commit | 8f1bc5944b849f3ad0cbbd5972d5ab9948ed4d57 (patch) | |
| tree | 43b48da8a1ec93b148575bc3346059e5316e6bf6 /python/callingconvention.py | |
| parent | 5b84fdea8abcb4abba61d07e0d12b4115b516c52 (diff) | |
Fix up equality operators and had hash operators
Diffstat (limited to 'python/callingconvention.py')
| -rw-r--r-- | python/callingconvention.py | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/python/callingconvention.py b/python/callingconvention.py index c6e5895a..66569a96 100644 --- a/python/callingconvention.py +++ b/python/callingconvention.py @@ -159,15 +159,24 @@ class CallingConvention(object): if self.handle is not None: core.BNFreeCallingConvention(self.handle) - def __eq__(self, value): - if not isinstance(value, CallingConvention): - return False - return ctypes.addressof(self.handle.contents) == ctypes.addressof(value.handle.contents) + def __repr__(self): + return "<calling convention: %s %s>" % (self.arch.name, self.name) + + def __str__(self): + return self.name + + def __eq__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return ctypes.addressof(self.handle.contents) == ctypes.addressof(other.handle.contents) - def __ne__(self, value): - if not isinstance(value, CallingConvention): - return True - return ctypes.addressof(self.handle.contents) != ctypes.addressof(value.handle.contents) + def __ne__(self, other): + if not isinstance(other, self.__class__): + return NotImplemented + return not (self == other) + + def __hash__(self): + return hash(ctypes.addressof(self.handle.contents)) def _get_caller_saved_regs(self, ctxt, count): try: @@ -364,12 +373,6 @@ class CallingConvention(object): result[0].index = in_var[0].index result[0].storage = in_var[0].storage - def __repr__(self): - return "<calling convention: %s %s>" % (self.arch.name, self.name) - - def __str__(self): - return self.name - def perform_get_incoming_reg_value(self, reg, func): reg_stack = self.arch.get_reg_stack_for_reg(reg) if reg_stack is not None: |
