From de47f2db0f95caa0c92ed4a6bb73d60b6c12c963 Mon Sep 17 00:00:00 2001 From: Sangmo Kang Date: Thu, 11 Apr 2024 04:14:54 +0900 Subject: [PATCH] Fix to create a fake properly that takes a pointer to function returning pointer (#77) * Fix to create a fake properly that takes a pointer to function returning pointer * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- autofff/generator.py | 5 ++++- examples/simple-headers/driver.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/autofff/generator.py b/autofff/generator.py index 09fb5c6..34d6bda 100644 --- a/autofff/generator.py +++ b/autofff/generator.py @@ -54,7 +54,10 @@ def _generateTypeDefForDecl(self, decl: Decl) -> str: ): name = utils.create_typedef_name_for_fnc_ptr(decl, param) - param.type.type.type.declname = name + type = param.type.type.type + while not hasattr(type, "declname"): + type = type.type + type.declname = name typedef = Typedef(name, param.quals, ["typedef"], param.type) param.type = TypeDecl( diff --git a/examples/simple-headers/driver.h b/examples/simple-headers/driver.h index ff2e426..70fca46 100644 --- a/examples/simple-headers/driver.h +++ b/examples/simple-headers/driver.h @@ -38,6 +38,9 @@ void Driver_PowerUp(Config (*config_cb)(void *arg)); void Driver_PowerDown(void); +/* Showcasing in-line function pointer parameters that return pointer */ +void Driver_Register_Callback(void *(*cb)(void *arg)); + int Driver_Deinitialize(void); /* Showcasing inline definition workaround */