Skip to content

Commit 5923675

Browse files
committed
Update Render Layer docs and type annotations
1 parent 8862696 commit 5923675

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

binaryninjaapi.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19108,6 +19108,10 @@ namespace BinaryNinja {
1910819108
public:
1910919109
/*! Register a custom Render Layer.
1911019110

19111+
Specify enableState to change whether the layer is enabled by default in the UI.
19112+
If it is set to AlwaysEnabled, the Render Layer will always be enabled
19113+
and will not be displayed in the UI.
19114+
1911119115
\param layer Render Layer to register
1911219116
\param enableState Whether the layer should be enabled by default
1911319117
*/

python/renderlayer.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ class RenderLayer(metaclass=_RenderLayerMetaclass):
6464
"""
6565

6666
name = None
67+
"""Name of the Render Layer, to be displayed in the UI."""
68+
6769
default_enable_state = RenderLayerDefaultEnableState.DisabledByDefaultRenderLayerDefaultEnableState
70+
"""
71+
Whether the Render Layer is enabled by default in the UI. If set to AlwaysEnabled,
72+
the Render Layer will always be enabled and will not be displayed in the UI.
73+
"""
74+
6875
_registered_instances = {}
6976
_pending_lines = {}
7077

@@ -150,11 +157,10 @@ def apply_to_disassembly_block(
150157
self,
151158
block: 'binaryninja.BasicBlock',
152159
lines: List['binaryninja.DisassemblyTextLine']
153-
):
160+
) -> List['binaryninja.DisassemblyTextLine']:
154161
"""
155162
Apply this Render Layer to a single Basic Block of Disassembly lines.
156-
Subclasses should modify the input `lines` list to make modifications to
157-
the presentation of the block.
163+
Subclasses should return a modified list of lines to be rendered in the UI.
158164
159165
.. note:: This function will only handle Disassembly lines, and not any ILs.
160166
@@ -168,14 +174,13 @@ def apply_to_low_level_il_block(
168174
self,
169175
block: 'binaryninja.LowLevelILBasicBlock',
170176
lines: List['binaryninja.DisassemblyTextLine']
171-
):
177+
) -> List['binaryninja.DisassemblyTextLine']:
172178
"""
173179
Apply this Render Layer to a single Basic Block of Low Level IL lines.
174-
Subclasses should modify the input `lines` list to make modifications to
175-
the presentation of the block.
180+
Subclasses should return a modified list of lines to be rendered in the UI.
176181
177182
.. note:: This function will only handle Lifted IL/LLIL/LLIL(SSA) lines. \
178-
You can use the block's `function_graph_type` property to determine which is being handled.
183+
You can use the block's ``function_graph_type`` property to determine which is being handled.
179184
180185
:param block: Basic Block containing those lines
181186
:param lines: Original lines of text for the block
@@ -187,14 +192,13 @@ def apply_to_medium_level_il_block(
187192
self,
188193
block: 'binaryninja.MediumLevelILBasicBlock',
189194
lines: List['binaryninja.DisassemblyTextLine']
190-
):
195+
) -> List['binaryninja.DisassemblyTextLine']:
191196
"""
192197
Apply this Render Layer to a single Basic Block of Medium Level IL lines.
193-
Subclasses should modify the input `lines` list to make modifications to
194-
the presentation of the block.
198+
Subclasses should return a modified list of lines to be rendered in the UI.
195199
196200
.. note:: This function will only handle MLIL/MLIL(SSA)/Mapped MLIL/Mapped MLIL(SSA) lines. \
197-
You can use the block's `function_graph_type` property to determine which is being handled.
201+
You can use the block's ``function_graph_type`` property to determine which is being handled.
198202
199203
:param block: Basic Block containing those lines
200204
:param lines: Original lines of text for the block
@@ -206,17 +210,16 @@ def apply_to_high_level_il_block(
206210
self,
207211
block: 'binaryninja.HighLevelILBasicBlock',
208212
lines: List['binaryninja.DisassemblyTextLine']
209-
):
213+
) -> List['binaryninja.DisassemblyTextLine']:
210214
"""
211215
Apply this Render Layer to a single Basic Block of High Level IL lines.
212-
Subclasses should modify the input `lines` list to make modifications to
213-
the presentation of the block.
216+
Subclasses should return a modified list of lines to be rendered in the UI.
214217
215218
.. note:: This function will only handle HLIL/HLIL(SSA)/Language Representation lines. \
216-
You can use the block's `function_graph_type` property to determine which is being handled.
219+
You can use the block's ``function_graph_type`` property to determine which is being handled.
217220
218221
.. warning:: This function will NOT apply to High Level IL bodies as displayed \
219-
in Linear View! Those are handled by `apply_to_high_level_il_body` instead as they \
222+
in Linear View! Those are handled by ``apply_to_high_level_il_body`` instead as they \
220223
do not have a Basic Block associated with them.
221224
222225
:param block: Basic Block containing those lines
@@ -229,14 +232,13 @@ def apply_to_high_level_il_body(
229232
self,
230233
function: 'binaryninja.Function',
231234
lines: List['binaryninja.LinearDisassemblyLine']
232-
):
235+
) -> List['binaryninja.LinearDisassemblyLine']:
233236
"""
234237
Apply this Render Layer to the entire body of a High Level IL function.
235-
Subclasses should modify the input `lines` list to make modifications to
236-
the presentation of the function.
238+
Subclasses should return a modified list of lines to be rendered in the UI.
237239
238240
.. warning:: This function only applies to Linear View, and not to Graph View! \
239-
If you want to handle Graph View too, you will need to use `apply_to_high_level_il_block` \
241+
If you want to handle Graph View too, you will need to use ``apply_to_high_level_il_block`` \
240242
and handle the lines one block at a time.
241243
242244
:param function: Function containing those lines
@@ -251,11 +253,12 @@ def apply_to_misc_linear_lines(
251253
prev: Optional['binaryninja.LinearViewObject'],
252254
next: Optional['binaryninja.LinearViewObject'],
253255
lines: List['binaryninja.LinearDisassemblyLine']
254-
):
256+
) -> List['binaryninja.DisassemblyTextLine']:
255257
"""
256258
Apply to lines generated by Linear View that are not part of a function.
257259
It is up to your implementation to figure out which type of Linear View Object
258260
lines these are, and what to do with them.
261+
Subclasses should return a modified list of lines to be rendered in the UI.
259262
260263
:param obj: Linear View Object being rendered
261264
:param prev: Linear View Object located directly above this one
@@ -269,10 +272,11 @@ def apply_to_block(
269272
self,
270273
block: 'binaryninja.BasicBlock',
271274
lines: List['binaryninja.DisassemblyTextLine'],
272-
):
275+
) -> List['binaryninja.DisassemblyTextLine']:
273276
"""
274277
Apply to lines generated by a Basic Block, of any type. If not overridden, this
275-
function will call the appropriate apply_to_X_level_il_block function.
278+
function will call the appropriate ``apply_to_X_level_il_block`` function.
279+
Subclasses should return a modified list of lines to be rendered in the UI.
276280
277281
:param block: Basic Block containing those lines
278282
:param lines: Original lines of text for the block

0 commit comments

Comments
 (0)