From 768094b1a889b2253b3e905b99792efaecd3e879 Mon Sep 17 00:00:00 2001 From: angie Date: Sun, 12 Mar 2023 11:23:25 -0300 Subject: [PATCH] git subrepo pull tools/graphovl --force subrepo: subdir: "tools/graphovl" merged: "dab4addae" upstream: origin: "https://github.com/AngheloAlf/graphovl.git" branch: "master" commit: "dab4addae" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" --- tools/graphovl/.gitrepo | 4 ++-- tools/graphovl/graphovl.py | 28 ++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tools/graphovl/.gitrepo b/tools/graphovl/.gitrepo index 064b8ee581..ca544b8858 100644 --- a/tools/graphovl/.gitrepo +++ b/tools/graphovl/.gitrepo @@ -6,7 +6,7 @@ [subrepo] remote = https://github.com/AngheloAlf/graphovl.git branch = master - commit = f5fe93d75bb75ea4bea65f62c43f41f6a1e70679 - parent = 6c5a50ef95f351acc7c4c0455a347a94443adbe1 + commit = dab4addae0c5db6274ab5daf7780c62c346120a1 + parent = 5da1ae553569ddb0016d302cfac8c45d9cb22e73 method = merge cmdver = 0.4.3 diff --git a/tools/graphovl/graphovl.py b/tools/graphovl/graphovl.py index 28f0a361c0..7cb7af2c51 100755 --- a/tools/graphovl/graphovl.py +++ b/tools/graphovl/graphovl.py @@ -18,7 +18,7 @@ except ModuleNotFoundError: script_dir = os.path.dirname(os.path.realpath(__file__)) config = ConfigParser() -func_names = None +func_names = list() func_definitions = list() line_numbers_of_functions = list() @@ -72,6 +72,19 @@ def capture_setupaction_call_arg(content): transitionList.append(func) return transitionList +setaction_regexpr = re.compile(r"_SetAction+\([^\)]*\)(\.[^\)]*\))?;") + +def capture_setaction_calls(content): + return [x.group() for x in re.finditer(setaction_regexpr, content)] + +def capture_setaction_call_arg(content): + transitionList = [] + for x in re.finditer(setaction_regexpr, content): + func = x.group().split(",")[2].strip().split(");")[0].strip() + if func not in transitionList: + transitionList.append(func) + return transitionList + # Search for the function definition by supplied function name def definition_by_name(content, name): for definition in capture_definitions(content): @@ -206,7 +219,11 @@ def addFunctionTransitionToGraph(dot, index: int, func_name: str, action_transit fontColor = config.get("colors", "fontcolor") bubbleColor = config.get("colors", "bubbleColor") indexStr = str(index) - funcIndex = str(index_of_func(action_transition)) + try: + funcIndex = str(index_of_func(action_transition)) + except ValueError: + print(f"Warning: function '{action_transition}' called by '{func_name}' was not found. Skiping...", file=sys.stderr) + return dot.node(indexStr, func_name, fontcolor=fontColor, color=bubbleColor) dot.node(funcIndex, action_transition, fontcolor=fontColor, color=bubbleColor) @@ -230,7 +247,7 @@ def addCallNamesToGraph(dot, func_names: list, index: int, code_body: str, remov if call in removeList: continue - if setupAction and "_SetupAction" in call: + if setupAction and ("_SetupAction" in call or "_SetAction" in call): continue seen.add(call) @@ -342,10 +359,11 @@ def main(): actionIdentifier = "this->actionFunc" setupAction = func_prefix + "_SetupAction" in func_names + setAction = func_prefix + "_SetAction" in func_names arrayActorFunc = match_obj is not None rawActorFunc = actionIdentifier in contents - if not setupAction and not arrayActorFunc and not rawActorFunc: + if not setupAction and not setAction and not arrayActorFunc and not rawActorFunc: print("No actor action-based structure found") os._exit(1) @@ -383,6 +401,8 @@ def main(): Create all edges for SetupAction-based actors """ transitionList = capture_setupaction_call_arg(code_body) + elif setAction: + transitionList = capture_setaction_call_arg(code_body) elif arrayActorFunc: """ Create all edges for ActorFunc array-based actors