From 78fc76b12da21dae9be6c57d92e08691a533836f Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Tue, 29 Jan 2019 19:52:52 -0500 Subject: Prepare API for Python UI bindings --- python/flowgraph.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'python/flowgraph.py') diff --git a/python/flowgraph.py b/python/flowgraph.py index 90ab33db..d3c57a56 100644 --- a/python/flowgraph.py +++ b/python/flowgraph.py @@ -51,14 +51,20 @@ class FlowGraphEdge(object): class FlowGraphNode(object): - def __init__(self, graph, handle = None): + def __init__(self, graph = None, handle = None): if handle is None: + if graph is None: + self.handle = None + raise ValueError("flow graph node must be associated with a graph") handle = core.BNCreateFlowGraphNode(graph.handle) self.handle = handle self.graph = graph + if self.graph is None: + self.graph = FlowGraph(handle = core.BNGetFlowGraphNodeOwner(self.handle)) def __del__(self): - core.BNFreeFlowGraphNode(self.handle) + if self.handle is not None: + core.BNFreeFlowGraphNode(self.handle) def __eq__(self, value): if not isinstance(value, FlowGraphNode): @@ -91,7 +97,7 @@ class FlowGraphNode(object): block = mediumlevelil.MediumLevelILBasicBlock(view, block, mediumlevelil.MediumLevelILFunction(func.arch, core.BNGetBasicBlockMediumLevelILFunction(block), func)) else: - block = basicblock.BasicBlock(view, block) + block = basicblock.BasicBlock(block, view) return block @property @@ -389,7 +395,7 @@ class FlowGraph(object): func = core.BNGetFunctionForFlowGraph(self.handle) if func is None: return None - return function.Function(binaryview.BinaryView(handle = core.BNGetFunctionData(func)), func) + return function.Function(handle = func) @function.setter def function(self, func): -- cgit v1.3.1