summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Wiens <jordan@psifertex.com>2019-09-03 15:48:35 -0400
committerJordan Wiens <jordan@psifertex.com>2019-09-03 15:48:35 -0400
commit3ccd563f68ab9b19edfe8e79d592e59645a44d36 (patch)
treeb656cb2a386d281613ecab5852d8c27a93282386
parentcc850ebdf753a4fa8643e6b3e596d212251f010c (diff)
add a few missing len properties and __str__ for StringReference
-rw-r--r--python/binaryview.py18
-rw-r--r--python/function.py3
-rw-r--r--python/plugin.py3
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):
""" """