| 36 | |
| 37 | @dataclass(frozen=True) |
| 38 | class LineFormatterSettings: |
| 39 | hlil: highlevelil.HighLevelILFunction |
| 40 | desired_line_length: int |
| 41 | minimum_content_length: int |
| 42 | tab_width: int |
| 43 | language_name: Optional[str] |
| 44 | comment_start_string: str |
| 45 | comment_end_string: str |
| 46 | annotation_start_string: str |
| 47 | annotation_end_string: str |
| 48 | |
| 49 | @staticmethod |
| 50 | def default(settings: Optional['function.DisassemblySettings'], hlil: 'highlevelil.HighLevelILFunction') -> 'LineFormatterSettings': |
| 51 | """ |
| 52 | Gets the default line formatter settings for High Level IL code. |
| 53 | """ |
| 54 | if settings is not None: |
| 55 | settings = settings.handle |
| 56 | api_obj = core.BNGetDefaultLineFormatterSettings(settings, hlil.handle) |
| 57 | result = LineFormatterSettings._from_core_struct(api_obj[0]) |
| 58 | core.BNFreeLineFormatterSettings(api_obj) |
| 59 | return result |
| 60 | |
| 61 | @staticmethod |
| 62 | def language_representation_settings( |
| 63 | settings: Optional['function.DisassemblySettings'], func: 'languagerepresentation.LanguageRepresentationFunction' |
| 64 | ) -> 'LineFormatterSettings': |
| 65 | """ |
| 66 | Gets the default line formatter settings for a language representation function. |
| 67 | """ |
| 68 | if settings is not None: |
| 69 | settings = settings.handle |
| 70 | api_obj = core.BNGetLanguageRepresentationLineFormatterSettings(settings, func.handle) |
| 71 | result = LineFormatterSettings._from_core_struct(api_obj[0]) |
| 72 | core.BNFreeLineFormatterSettings(api_obj) |
| 73 | return result |
| 74 | |
| 75 | @staticmethod |
| 76 | def _from_core_struct(settings: core.BNLineFormatterSettings) -> 'LineFormatterSettings': |
| 77 | if len(settings.languageName) == 0: |
| 78 | language_name = None |
| 79 | else: |
| 80 | language_name = settings.languageName |
| 81 | hlil = highlevelil.HighLevelILFunction(handle=core.BNNewHighLevelILFunctionReference(settings.highLevelIL)) |
| 82 | return LineFormatterSettings( |
| 83 | hlil, settings.desiredLineLength, settings.minimumContentLength, settings.tabWidth, language_name, |
| 84 | settings.commentStartString, settings.commentEndString, |
| 85 | settings.annotationStartString, settings.annotationEndString |
| 86 | ) |
| 87 | |
| 88 | def _to_core_struct(self) -> core.BNLineFormatterSettings: |
| 89 | result = core.BNLineFormatterSettings() |
| 90 | result.highLevelIL = self.hlil.handle |
| 91 | result.desiredLineLength = self.desired_line_length |
| 92 | result.minimumContentLength = self.minimum_content_length |
| 93 | result.tabWidth = self.tab_width |
| 94 | result.languageName = self.language_name if self.language_name is not None else "" |
| 95 | result.commentStartString = self.comment_start_string |
no outgoing calls
no test coverage detected