[gtk-doc: 3/5] Fix parsing of g_set_object()



commit a9b4a1a156ef39336cf7b51e6f91b37dfd31960d
Author: Xavier Claessens <xavier claessens collabora com>
Date:   Tue Jul 9 11:03:34 2019 -0400

    Fix parsing of g_set_object()
    
    GLib wraps its name in parenthesis to avoid macro expansion. A few other
    functions does the same pattern in glib.

 gtkdoc/scan.py                      |  4 ++--
 tests/bugs/docs/tester-sections.txt |  1 +
 tests/bugs/src/tester.h             | 16 ++++++++++++++++
 3 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/gtkdoc/scan.py b/gtkdoc/scan.py
index 4ffe5fe..ae4f866 100644
--- a/gtkdoc/scan.py
+++ b/gtkdoc/scan.py
@@ -128,7 +128,7 @@ CLINE_MATCHER = [
     # 18-21: FUNCTIONS
     None,  # in ScanHeaderContent()
     None,  # in ScanHeaderContent()
-    re.compile(r'^\s*([A-Za-z]\w*)\s*\('),
+    re.compile(r'^\s*\(?([A-Za-z]\w*)\)?\s*\('),
     re.compile(r'^\s*\('),
     # 22-23: STRUCTS
     re.compile(r'^\s*struct\s+_?(\w+)\s*\*'),
@@ -417,7 +417,7 @@ def ScanHeaderContent(input_lines, decl_list, get_types, options):
         (?:\b(?:extern|static|inline|G_INLINE_FUNC%s)\s*)*
         (%s\w+)                                                     # 1: return type
         ([\s*]+(?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*     # 2: .. cont'
-        ([A-Za-z]\w*)                                               # 3: name
+        \(?([A-Za-z]\w*)\)?                                         # 3: name
         \s*\(""" % (ignore_decorators, RET_TYPE_MODIFIER), re.VERBOSE)
 
     PLINE_MATCHER[2] = re.compile(
diff --git a/tests/bugs/docs/tester-sections.txt b/tests/bugs/docs/tester-sections.txt
index 4329e37..e71d1bd 100644
--- a/tests/bugs/docs/tester-sections.txt
+++ b/tests/bugs/docs/tester-sections.txt
@@ -63,6 +63,7 @@ bug_783420
 gst_play_marshal_BUFFER__BOXED
 BUG_791928
 _
+inline_func_with_macro
 <SUBSECTION Standard>
 <SUBSECTION Private>
 GTKDOC_GNUC_CONST
diff --git a/tests/bugs/src/tester.h b/tests/bugs/src/tester.h
index 6e05de8..3ed3fc0 100644
--- a/tests/bugs/src/tester.h
+++ b/tests/bugs/src/tester.h
@@ -479,4 +479,20 @@ typedef struct {
   guint index_plop;
 } MyNotDeprecatedStruct;
 
+/**
+ * inline_func_with_macro:
+ * @obj: arg
+ *
+ * GLib has a few inline functions with a macro that has the same name. It puts
+ * the inline function name into parenthesis to avoid macro expansion.
+ * See g_set_object().
+ */
+static inline gboolean
+(inline_func_with_macro) (void *obj)
+{
+  return TRUE;
+}
+
+#define inline_func_with_macro(obj)
+
 #endif // GTKDOC_TESTER_H


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]