typeprinter module¶
|
|
|
Class for turning Type objects into strings and tokens. |
- class CoreTypePrinter(handle=None)[source]¶
Bases:
TypePrinter
- get_type_lines(type: Type, data: BinaryView, name: Union[Iterable[Union[str, bytes]], str, QualifiedName], line_width=80, collapsed=False, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[TypeDefinitionLine] [source]¶
Generate a multi-line representation of a type
- Parameters:
type (Type) – Type to print
data (BinaryView) – Binary View in which the type is defined
name (Union[Iterable[Union[str, bytes]], str, QualifiedName]) – Name of the type
line_width – Maximum width of lines, in characters
collapsed – Whether to collapse structure/enum blocks
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
List of type definition lines
- Return type:
- get_type_string(type: Type, platform: Optional[Platform] = None, name: Union[Iterable[Union[str, bytes]], str, QualifiedName] = '', escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str [source]¶
Generate a single-line text representation of a type
- Parameters:
- Returns:
String representing the type
- Return type:
- get_type_string_after_name(type: Type, platform: Optional[Platform] = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str [source]¶
In a single-line text representation of a type, generate the string that should be printed after the type’s name.
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
String representing the type
- Return type:
- get_type_string_before_name(type: Type, platform: Optional[Platform] = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str [source]¶
In a single-line text representation of a type, generate the string that should be printed before the type’s name.
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
String representing the type
- Return type:
- get_type_tokens(type: Type, platform: Optional[Platform] = None, name: Union[Iterable[Union[str, bytes]], str, QualifiedName] = '', base_confidence: int = 255, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken] [source]¶
Generate a single-line text representation of a type
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
name (Union[Iterable[Union[str, bytes]], str, QualifiedName]) – Name of the type
base_confidence (int) – Confidence to use for tokens created for this type
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
List of text tokens representing the type
- Return type:
- get_type_tokens_after_name(type: Type, platform: Optional[Platform] = None, base_confidence: int = 255, parent_type: Optional[Type] = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken] [source]¶
In a single-line text representation of a type, generate the tokens that should be printed after the type’s name.
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
base_confidence (int) – Confidence to use for tokens created for this type
parent_type (Optional[Type]) – Type of the parent of this type, or None
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
List of text tokens representing the type
- Return type:
- get_type_tokens_before_name(type: Type, platform: Optional[Platform] = None, base_confidence: int = 255, parent_type: Optional[Type] = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken] [source]¶
In a single-line text representation of a type, generate the tokens that should be printed before the type’s name.
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
base_confidence (int) – Confidence to use for tokens created for this type
parent_type (Optional[Type]) – Type of the parent of this type, or None
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
List of text tokens representing the type
- Return type:
- print_all_types(types_: List[Tuple[Union[Iterable[Union[str, bytes]], str, QualifiedName], Type]], data: BinaryView, line_width=80, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str [source]¶
Print all types to a single big string, including headers, sections, etc
- Parameters:
types – All types to print
data (BinaryView) – Binary View in which all the types are defined
line_width – Maximum width of lines, in characters
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
types_ (List[Tuple[Union[Iterable[Union[str, bytes]], str, QualifiedName], Type]]) –
- Returns:
All the types in a string
- Return type:
- class TypePrinter(handle=None)[source]¶
Bases:
object
Class for turning Type objects into strings and tokens.
- get_type_lines(type: Type, data: BinaryView, name: Union[Iterable[Union[str, bytes]], str, QualifiedName], line_width=80, collapsed=False, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[TypeDefinitionLine] [source]¶
Generate a multi-line representation of a type
- Parameters:
type (Type) – Type to print
data (BinaryView) – Binary View in which the type is defined
name (Union[Iterable[Union[str, bytes]], str, QualifiedName]) – Name of the type
line_width – Maximum width of lines, in characters
collapsed – Whether to collapse structure/enum blocks
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
List of type definition lines
- Return type:
- get_type_string(type: Type, platform: Optional[Platform] = None, name: Union[Iterable[Union[str, bytes]], str, QualifiedName] = '', escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str [source]¶
Generate a single-line text representation of a type
- Parameters:
- Returns:
String representing the type
- Return type:
- get_type_string_after_name(type: Type, platform: Optional[Platform] = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str [source]¶
In a single-line text representation of a type, generate the string that should be printed after the type’s name.
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
String representing the type
- Return type:
- get_type_string_before_name(type: Type, platform: Optional[Platform] = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str [source]¶
In a single-line text representation of a type, generate the string that should be printed before the type’s name.
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
String representing the type
- Return type:
- get_type_tokens(type: Type, platform: Optional[Platform] = None, name: Union[Iterable[Union[str, bytes]], str, QualifiedName] = '', base_confidence: int = 255, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken] [source]¶
Generate a single-line text representation of a type
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
name (Union[Iterable[Union[str, bytes]], str, QualifiedName]) – Name of the type
base_confidence (int) – Confidence to use for tokens created for this type
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
List of text tokens representing the type
- Return type:
- get_type_tokens_after_name(type: Type, platform: Optional[Platform] = None, base_confidence: int = 255, parent_type: Optional[Type] = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken] [source]¶
In a single-line text representation of a type, generate the tokens that should be printed after the type’s name.
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
base_confidence (int) – Confidence to use for tokens created for this type
parent_type (Optional[Type]) – Type of the parent of this type, or None
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
List of text tokens representing the type
- Return type:
- get_type_tokens_before_name(type: Type, platform: Optional[Platform] = None, base_confidence: int = 255, parent_type: Optional[Type] = None, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) List[InstructionTextToken] [source]¶
In a single-line text representation of a type, generate the tokens that should be printed before the type’s name.
- Parameters:
type (Type) – Type to print
platform (Optional[Platform]) – Platform responsible for this type
base_confidence (int) – Confidence to use for tokens created for this type
parent_type (Optional[Type]) – Type of the parent of this type, or None
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
List of text tokens representing the type
- Return type:
- print_all_types(types: List[Tuple[Union[Iterable[Union[str, bytes]], str, QualifiedName], Type]], data: BinaryView, line_width=80, escaping: TokenEscapingType = TokenEscapingType.BackticksTokenEscapingType) str [source]¶
Print all types to a single big string, including headers, sections, etc
- Parameters:
types (List[Tuple[Union[Iterable[Union[str, bytes]], str, QualifiedName], Type]]) – All types to print
data (BinaryView) – Binary View in which all the types are defined
line_width – Maximum width of lines, in characters
escaping (TokenEscapingType) – Style of escaping literals which may not be parsable
- Returns:
All the types in a string
- Return type:
- name = None¶