From 38fb1d656559cb4fb95201077d7aaf57d992a8c5 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Mon, 13 Feb 2023 13:23:49 -0500 Subject: Make Function.function_type transparently use Function.type --- python/function.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'python') diff --git a/python/function.py b/python/function.py index d065f454..856d9cca 100644 --- a/python/function.py +++ b/python/function.py @@ -960,25 +960,21 @@ class Function: return None return highlevelil.HighLevelILFunction(self.arch, result, self) + # TODO: Uncomment, move below the property decorator, and mark deprecated after the next stable #@deprecation.deprecated(details="Use .type instead.") - # Uncomment, move below the property decorator, - # and mark deprecated after the next stable @property def function_type(self) -> 'types.FunctionType': """ Function type object, can be set with either a string representing the function prototype (`str(function)` shows examples) or a :py:class:`Type` object """ - return types.FunctionType(core.BNGetFunctionType(self.handle), platform=self.platform) + return self.type + # TODO: Uncomment, move below the setter decorator, and mark deprecated after the next stable + #@deprecation.deprecated(details="Use .type instead.") @function_type.setter - def function_type(self, value: Union['types.FunctionType', str]) -> None: # type: ignore - if isinstance(value, str): - (parsed_value, new_name) = self.view.parse_type_string(value) - self.name = str(new_name) - self.set_user_type(parsed_value) - else: - self.set_user_type(value) + def function_type(self, value: Union['types.FunctionType', str]) -> None: + self.type = value @property def type(self) -> 'types.FunctionType': @@ -989,7 +985,7 @@ class Function: return types.FunctionType(core.BNGetFunctionType(self.handle), platform=self.platform) @type.setter - def type(self, value: Union['types.FunctionType', str]) -> None: # type: ignore + def type(self, value: Union['types.FunctionType', str]) -> None: if isinstance(value, str): (parsed_value, new_name) = self.view.parse_type_string(value) self.name = str(new_name) -- cgit v1.3.1