On 21:08:33 2021-01-25, Jani Nikula wrote:
Sphinx expects the declaration to be as in C.
This is a quick fix, and leaves an extra space in the output.
Update the tests accordingly.
Fixes: #21
---
hawkmoth/parser.py | 6 ++++++
test/struct.c | 8 ++++++++
test/struct.rst | 10 ++++++++++
test/variable.c | 5 +++++
test/variable.rst | 5 +++++
5 files changed, 34 insertions(+)
diff --git a/hawkmoth/parser.py b/hawkmoth/parser.py
index 35213739f2de..1bcf16e20820 100644
--- a/hawkmoth/parser.py
+++ b/hawkmoth/parser.py
@@ -178,6 +178,12 @@ def _recursive_parse(comments, cursor, nest, compat):
ttype = ttype.rsplit(' ', 1)[0]
name = name + dims
+ # The function pointer name should be in (*foo).
+ fptr_type = ttype.replace('(*)', '(*{})'.format(name), 1)
+ if fptr_type != ttype:
+ name = fptr_type
+ ttype = ''
+
return _result(comment, cursor=cursor, fmt=fmt,
nest=nest, name=name, ttype=ttype, compat=compat)
diff --git a/test/struct.c b/test/struct.c
index d8353f5b66f5..41c00ac13c25 100644
--- a/test/struct.c
+++ b/test/struct.c
@@ -12,6 +12,14 @@ struct sample_struct {
* array member
*/
int array_member[5];
+ /**
+ * pointer member
+ */
+ void *pointer_member;
+ /**
+ * function pointer member
+ */
+ int (*function_pointer_member)(int, int);
/**
* foo next
*/
diff --git a/test/struct.rst b/test/struct.rst
index fb2b1abaf980..d934af910649 100644
--- a/test/struct.rst
+++ b/test/struct.rst
@@ -16,6 +16,16 @@
array member
+ .. c:member:: void * pointer_member
+
+ pointer member
+
+
+ .. c:member:: int (*function_pointer_member)(int, int)
+
+ function pointer member
+
+
.. c:member:: struct sample_struct * next
foo next
diff --git a/test/variable.c b/test/variable.c
index 886033938826..6df5d683f267 100644
--- a/test/variable.c
+++ b/test/variable.c
@@ -2,3 +2,8 @@
* This is a variable document.
*/
static int sheesh;
+
+/**
+ * function pointer variable
+ */
+int (*function_pointer_variable)(int *param_name_ignored);
diff --git a/test/variable.rst b/test/variable.rst
index 4efaece905e9..84168d860483 100644
--- a/test/variable.rst
+++ b/test/variable.rst
@@ -3,3 +3,8 @@
This is a variable document.
+
+.. c:var:: int (*function_pointer_variable)(int *)
+
+ function pointer variable
+