diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 18 | ||||
| -rw-r--r-- | python/function.py | 3 | ||||
| -rw-r--r-- | python/plugin.py | 3 |
3 files changed, 16 insertions, 8 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index c5d9c363..2732a8d7 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -43,6 +43,7 @@ from binaryninja import metadata from binaryninja import highlight from binaryninja import function from binaryninja import settings +from binaryninja import pyNativeStr # 2-3 compatibility from binaryninja import range @@ -118,6 +119,12 @@ class StringReference(object): def raw(self): return self._view.read(self._start, self._length) + def __str__(self): + return pyNativeStr(self.raw) + + def __len__(self): + return self._length + def __repr__(self): return "<%s: %#x, len %#x>" % (self._type, self._start, self._length) @@ -144,19 +151,11 @@ class StringReference(object): """ """ return self._length - @length.setter - def length(self, value): - self._length = value - @property def view(self): """ """ return self._view - @view.setter - def view(self, value): - self._view = value - _pending_analysis_completion_events = {} class AnalysisCompletionEvent(object): @@ -882,6 +881,9 @@ class AddressRange(object): self._start = start self._end = end + def __len__(self): + return self._end - self.start + @property def length(self): return self._end - self._start diff --git a/python/function.py b/python/function.py index 6330f656..8080c626 100644 --- a/python/function.py +++ b/python/function.py @@ -2686,6 +2686,9 @@ class InstructionInfo(object): def add_branch(self, branch_type, target = 0, arch = None): self._branches.append(InstructionBranch(branch_type, target, arch)) + def __len__(self): + return self._length + def __repr__(self): branch_delay = "" if self._branch_delay: diff --git a/python/plugin.py b/python/plugin.py index 27549c3d..72a5ed42 100644 --- a/python/plugin.py +++ b/python/plugin.py @@ -43,6 +43,9 @@ class PluginCommandContext(object): self._function = None self._instruction = None + def __len__(self): + return self._length + @property def view(self): """ """ |
