summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2024-04-11 15:54:34 -0400
committerGlenn Smith <glenn@vector35.com>2024-04-11 15:54:34 -0400
commit3394019790216360933090478665025216727891 (patch)
tree9d0835e90f0d1c55da1cadb54234e38715207cb3 /python
parent62036d41a3e7491e274a5ab4826bdac0522dac1b (diff)
Rename lineWidth -> paddingCols in GetTypeLines()
This is a more accurate name for what the parameter actually does. Documentation was improved as well.
Diffstat (limited to 'python')
-rw-r--r--python/typeprinter.py30
-rw-r--r--python/types.py6
2 files changed, 18 insertions, 18 deletions
diff --git a/python/typeprinter.py b/python/typeprinter.py
index dfddfed4..47793ec3 100644
--- a/python/typeprinter.py
+++ b/python/typeprinter.py
@@ -221,13 +221,13 @@ class TypePrinter(metaclass=_TypePrinterMetaclass):
log_error(traceback.format_exc())
return False
- def _get_type_lines(self, ctxt, type, container, name, line_width, collapsed, escaping, result, result_count):
+ def _get_type_lines(self, ctxt, type, container, name, padding_cols, collapsed, escaping, result, result_count):
try:
result_py = self.get_type_lines(
types.Type.create(handle=core.BNNewTypeReference(type)),
typecontainer.TypeContainer(handle=container),
types.QualifiedName._from_core_struct(name.contents),
- line_width, collapsed, escaping)
+ padding_cols, collapsed, escaping)
TypePrinter._cached_lines = (core.BNTypeDefinitionLine * len(result_py))()
for (i, line) in enumerate(result_py):
@@ -240,7 +240,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass):
log_error(traceback.format_exc())
return False
- def _print_all_types(self, ctxt, names, types_, type_count, data, line_width, escaping, result):
+ def _print_all_types(self, ctxt, names, types_, type_count, data, padding_cols, escaping, result):
try:
types_py = []
for i in range(type_count):
@@ -252,7 +252,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass):
result_py = self.print_all_types(
types_py,
binaryview.BinaryView(handle=core.BNNewViewReference(data)),
- line_width, escaping)
+ padding_cols, escaping)
TypePrinter._cached_string = core.cstr(result_py)
result[0] = TypePrinter._cached_string
@@ -288,7 +288,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass):
log_error(traceback.format_exc())
return False
- def _default_print_all_types(self, types_: List[Tuple[types.QualifiedNameType, types.Type]], data: binaryview.BinaryView, line_width = 80, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> str:
+ def _default_print_all_types(self, types_: List[Tuple[types.QualifiedNameType, types.Type]], data: binaryview.BinaryView, padding_cols = 80, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> str:
cpp_names = (core.BNQualifiedName * len(types_))()
cpp_types = (ctypes.POINTER(core.BNType) * len(types_))()
@@ -299,7 +299,7 @@ class TypePrinter(metaclass=_TypePrinterMetaclass):
i += 1
result = ctypes.c_char_p()
- core.BNTypePrinterDefaultPrintAllTypes(self.handle, cpp_names, cpp_types, len(types_), data.handle, line_width, ctypes.c_int(escaping), result)
+ core.BNTypePrinterDefaultPrintAllTypes(self.handle, cpp_names, cpp_types, len(types_), data.handle, padding_cols, ctypes.c_int(escaping), result)
return core.pyNativeStr(result.value)
def get_type_tokens(self, type: types.Type, platform: Optional[_platform.Platform] = None, name: types.QualifiedNameType = "", base_confidence: int = core.max_confidence, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> List[_function.InstructionTextToken]:
@@ -379,31 +379,31 @@ class TypePrinter(metaclass=_TypePrinterMetaclass):
"""
raise NotImplementedError()
- def get_type_lines(self, type: types.Type, container: 'typecontainer.TypeContainer', name: types.QualifiedNameType, line_width = 80, collapsed = False, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> List[types.TypeDefinitionLine]:
+ def get_type_lines(self, type: types.Type, container: 'typecontainer.TypeContainer', name: types.QualifiedNameType, padding_cols = 80, collapsed = False, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> List[types.TypeDefinitionLine]:
"""
Generate a multi-line representation of a type
:param type: Type to print
:param container: Type Container containing the type and dependencies
:param name: Name of the type
- :param line_width: Maximum width of lines, in characters
+ :param padding_cols: Maximum number of bytes represented by each padding line
:param collapsed: Whether to collapse structure/enum blocks
:param escaping: Style of escaping literals which may not be parsable
:return: List of type definition lines
"""
raise NotImplementedError()
- def print_all_types(self, types: List[Tuple[types.QualifiedNameType, types.Type]], data: binaryview.BinaryView, line_width = 80, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> str:
+ def print_all_types(self, types: List[Tuple[types.QualifiedNameType, types.Type]], data: binaryview.BinaryView, padding_cols = 80, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> str:
"""
Print all types to a single big string, including headers, sections, etc
:param types: All types to print
:param data: Binary View in which all the types are defined
- :param line_width: Maximum width of lines, in characters
+ :param padding_cols: Maximum number of bytes represented by each padding line
:param escaping: Style of escaping literals which may not be parsable
:return: All the types in a string
"""
- return self._default_print_all_types(types, data, line_width, escaping)
+ return self._default_print_all_types(types, data, padding_cols, escaping)
class CoreTypePrinter(TypePrinter):
@@ -491,14 +491,14 @@ class CoreTypePrinter(TypePrinter):
def get_type_lines(self, type: types.Type, container: 'typecontainer.TypeContainer',
name: types.QualifiedNameType,
- line_width = 80, collapsed = False,
+ padding_cols = 80, collapsed = False,
escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType
) -> List[types.TypeDefinitionLine]:
if not isinstance(name, types.QualifiedName):
name = types.QualifiedName(name)
count = ctypes.c_ulonglong()
core_lines = ctypes.POINTER(core.BNTypeDefinitionLine)()
- if not core.BNGetTypePrinterTypeLines(self.handle, type.handle, container.handle, name._to_core_struct(), line_width, collapsed, ctypes.c_int(escaping), core_lines, count):
+ if not core.BNGetTypePrinterTypeLines(self.handle, type.handle, container.handle, name._to_core_struct(), padding_cols, collapsed, ctypes.c_int(escaping), core_lines, count):
raise RuntimeError("BNGetTypePrinterTypeLines returned False")
lines = []
for i in range(count.value):
@@ -507,7 +507,7 @@ class CoreTypePrinter(TypePrinter):
core.BNFreeTypeDefinitionLineList(core_lines, count.value)
return lines
- def print_all_types(self, types_: List[Tuple[types.QualifiedNameType, types.Type]], data: binaryview.BinaryView, line_width = 80, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> str:
+ def print_all_types(self, types_: List[Tuple[types.QualifiedNameType, types.Type]], data: binaryview.BinaryView, padding_cols = 80, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) -> str:
cpp_names = (core.BNQualifiedName * len(types_))()
cpp_types = (ctypes.POINTER(core.BNType) * len(types_))()
@@ -518,5 +518,5 @@ class CoreTypePrinter(TypePrinter):
i += 1
result = ctypes.c_char_p()
- core.BNTypePrinterPrintAllTypes(self.handle, cpp_names, cpp_types, len(types_), data.handle, line_width, ctypes.c_int(escaping), result)
+ core.BNTypePrinterPrintAllTypes(self.handle, cpp_names, cpp_types, len(types_), data.handle, padding_cols, ctypes.c_int(escaping), result)
return core.pyNativeStr(result.value)
diff --git a/python/types.py b/python/types.py
index 57c0824c..e08bc796 100644
--- a/python/types.py
+++ b/python/types.py
@@ -2005,7 +2005,7 @@ class Type:
return result
def get_lines(
- self, bv: Union['binaryview.BinaryView', 'typecontainer.TypeContainer'], name: str, line_width: int = 80, collapsed: bool = False,
+ self, bv: Union['binaryview.BinaryView', 'typecontainer.TypeContainer'], name: str, padding_cols: int = 80, collapsed: bool = False,
escaping: TokenEscapingType = TokenEscapingType.NoTokenEscapingType
) -> List['TypeDefinitionLine']:
"""
@@ -2015,7 +2015,7 @@ class Type:
:param BinaryView bv: BinaryView object owning this Type
:param str name: Displayed name of the Type
- :param int line_width: Maximum width of lines (in characters)
+ :param int padding_cols: Maximum number of bytes represented by each padding line
:param bool collapsed: If the type should be collapsed, and not show fields/members
:param TokenEscapingType escaping: How to escape non-parsable strings in types
:return: Returns a list of :py:class:`TypeDefinitionLine` structures
@@ -2028,7 +2028,7 @@ class Type:
container = bv
else:
assert False, "Unexpected type container type"
- core_lines = core.BNGetTypeLines(self._handle, container.handle, name, line_width, collapsed, escaping, count)
+ core_lines = core.BNGetTypeLines(self._handle, container.handle, name, padding_cols, collapsed, escaping, count)
assert core_lines is not None, "core.BNGetTypeLines returned None"
lines = []
for i in range(count.value):