From 16c4864cb9aa3a1d862600fce42256036e9c18e7 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Thu, 18 Jun 2020 11:17:23 -0400 Subject: Add ability to set can_return on mutable function type objects --- python/types.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/types.py b/python/types.py index 94e1f42d..92735fc6 100644 --- a/python/types.py +++ b/python/types.py @@ -548,13 +548,26 @@ class Type(object): @property def can_return(self): - """Whether type can return (read-only)""" + """Whether type can return""" if self._mutable: result = core.BNFunctionTypeBuilderCanReturn(self._handle) else: result = core.BNFunctionTypeCanReturn(self._handle) return BoolWithConfidence(result.value, confidence = result.confidence) + @can_return.setter + def can_return(self, value): + """Whether type can return (read-only)""" + if not self._mutable: + raise AttributeError("Finalized Type object is immutable, use mutable_copy()") + bc = core.BNBoolWithConfidence() + bc.value = bool(value) + if hasattr(value, 'confidence'): + bc.confidence = value.confidence + else: + bc.confidence = max_confidence + core.BNSetFunctionTypeBuilderCanReturn(self._handle, bc) + @property def structure(self): """Structure of the type (read-only)""" -- cgit v1.3.1