diff options
| author | Alexander Taylor <alex@vector35.com> | 2026-05-12 21:19:28 -0400 |
|---|---|---|
| committer | Alexander Taylor <alex@vector35.com> | 2026-05-13 13:32:22 -0400 |
| commit | 4c278a57b59c4b8e913d17b47bc4828659b32659 (patch) | |
| tree | d179792a704c615a3838ecfbfe636bc537d82216 /python | |
| parent | 6a1c332697cbe12d6b2b7857bf21bc440706c0be (diff) | |
Changes related to display as/type toggling.
Diffstat (limited to 'python')
| -rw-r--r-- | python/function.py | 11 | ||||
| -rw-r--r-- | python/types.py | 16 |
2 files changed, 26 insertions, 1 deletions
diff --git a/python/function.py b/python/function.py index b2c3ef4c..9f5e89bb 100644 --- a/python/function.py +++ b/python/function.py @@ -4181,6 +4181,17 @@ class DisassemblyTextRenderer: def is_integer_token(token: 'InstructionTextToken') -> bool: return core.BNIsIntegerToken(token.type) + @staticmethod + def get_display_string_for_integer( + binary_view: Optional['binaryview.BinaryView'], display_type: IntegerDisplayType, value: int, input_width: int, + is_signed: bool = True + ) -> str: + if isinstance(display_type, str): + display_type = IntegerDisplayType[display_type] + return core.BNGetDisplayStringForInteger( + binary_view.handle if binary_view is not None else None, display_type, value, input_width, is_signed + ) + def add_integer_token( self, tokens: List['InstructionTextToken'], int_token: 'InstructionTextToken', addr: int, arch: Optional['architecture.Architecture'] = None diff --git a/python/types.py b/python/types.py index b47d98ce..80c70e14 100644 --- a/python/types.py +++ b/python/types.py @@ -32,7 +32,7 @@ from .enums import ( TypeReferenceType, MemberAccess, MemberScope, TypeDefinitionLineType, TokenEscapingType, NameType, PointerSuffix, PointerBaseType, - Endianness + Endianness, IntegerDisplayType ) from . import callingconvention from . import function as _function @@ -904,6 +904,15 @@ class TypeBuilder: core.BNTypeBuilderSetSigned(self._handle, _value) @property + def display_type(self) -> IntegerDisplayType: + """Integer display type for this type.""" + return core.BNGetIntegerTypeDisplayType(self.immutable_copy().handle) + + @display_type.setter + def display_type(self, value: IntegerDisplayType) -> None: + core.BNSetIntegerTypeDisplayType(self._handle, value) + + @property def children(self) -> List['TypeBuilder']: return [] @@ -2145,6 +2154,11 @@ class Type: core.BNFreeTypeAttributeList(attributes, count.value) return result + @property + def display_type(self) -> IntegerDisplayType: + """Integer display type for this type.""" + return core.BNGetIntegerTypeDisplayType(self._handle) + def _to_core_struct(self) -> core.BNTypeWithConfidence: type_conf = core.BNTypeWithConfidence() type_conf.type = self._handle |
