From 4bfebc66f9e27c3c9d94a65bda1a4c2f0c579ce2 Mon Sep 17 00:00:00 2001 From: Sangmo Kang Date: Tue, 9 Apr 2024 17:46:08 +0900 Subject: [PATCH 1/2] Fix to create a fake properly that takes a pointer to function returning pointer --- 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..6ec6f3a 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 5574b59..3569ae1 100644 --- a/examples/simple-headers/driver.h +++ b/examples/simple-headers/driver.h @@ -36,6 +36,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 */ From 1c03004157f7f09e15a185ca71f6414e860e0f97 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 08:55:19 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- autofff/generator.py | 2 +- examples/simple-headers/driver.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autofff/generator.py b/autofff/generator.py index 6ec6f3a..34d6bda 100644 --- a/autofff/generator.py +++ b/autofff/generator.py @@ -55,7 +55,7 @@ def _generateTypeDefForDecl(self, decl: Decl) -> str: name = utils.create_typedef_name_for_fnc_ptr(decl, param) type = param.type.type.type - while not hasattr(type, 'declname'): + while not hasattr(type, "declname"): type = type.type type.declname = name typedef = Typedef(name, param.quals, ["typedef"], param.type) diff --git a/examples/simple-headers/driver.h b/examples/simple-headers/driver.h index 3569ae1..271444d 100644 --- a/examples/simple-headers/driver.h +++ b/examples/simple-headers/driver.h @@ -37,7 +37,7 @@ 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)); +void Driver_Register_Callback(void *(*cb)(void *arg)); int Driver_Deinitialize(void);