From 9b04fd16df483acbed23707f6faf66a28d0185a8 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Mon, 26 Jan 2009 08:35:34 +0000 Subject: [PATCH] Handle inline functions in headers. Fixes #532395. * gtkdoc-scan.in: * tests/bugs/docs/tester-sections.txt: * tests/bugs/src/tester.c: * tests/bugs/src/tester.h: Handle inline functions in headers. Fixes #532395. svn path=/trunk/; revision=665 --- ChangeLog | 8 +++++ gtkdoc-scan.in | 63 +++++++++++++++++++++++++++---------- tests/bugs/docs/tester-sections.txt | 2 ++ tests/bugs/src/tester.c | 7 +++-- tests/bugs/src/tester.h | 31 ++++++++++++++++++ 5 files changed, 92 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba61c1e..677923a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2009-01-26 Stefan Kost + * gtkdoc-scan.in: + * tests/bugs/docs/tester-sections.txt: + * tests/bugs/src/tester.c: + * tests/bugs/src/tester.h: + Handle inline functions in headers. Fixes #532395. + +2009-01-26 Stefan Kost + * HACKING: Mention onine site for regexp testing. diff --git a/gtkdoc-scan.in b/gtkdoc-scan.in index a9452e4..27b039a 100755 --- a/gtkdoc-scan.in +++ b/gtkdoc-scan.in @@ -237,6 +237,7 @@ sub ScanHeader { my ($in_comment) = 0; # True if we are in a comment. my ($in_declaration) = ""; # The type of declaration we are in, e.g. # 'function' or 'macro'. + my ($skip_block) = 0; # True if we should skip a block. my ($symbol); # The current symbol being declared. my ($decl); # Holds the declaration of the current symbol. my ($ret_type); # For functions and function typedefs this @@ -303,6 +304,18 @@ sub ScanHeader { } next; } + # Skip complete blocks, needed fo inline macros + if ($skip_block==1) { + if (m%{%) { + $skip_block=2; + } + next; + } elsif ($skip_block==2) { + if (m%}%) { + $skip_block=0; + } + next; + } # Keep a count of #if, #ifdef, #ifndef nesting, # and if we enter a deprecation-symbol-bracketed @@ -485,14 +498,32 @@ sub ScanHeader { $symbol = $1; $decl = $'; - if ($previous_line !~ m/^\s*G_INLINE_FUNC/ - && $previous_line !~ m/^\s*static\s+/) { - if ($previous_line =~ m/^\s*(?:\b(?:extern|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|unsigned\s+|struct\s+|enum\s+)?\w+)((?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*$/o) { - $ret_type = $1; - if (defined ($2)) { $ret_type .= " $2"; } - #print "DEBUG: Function: $symbol, Returns: $ret_type\n"; - $in_declaration = "function"; - } + if ($previous_line !~ m/^\s*G_INLINE_FUNC/) { + if ($previous_line !~ m/^\s*static\s+/) { + # $1 $2 + if ($previous_line =~ m/^\s*(?:\b(?:extern|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|unsigned\s+|struct\s+|enum\s+)?\w+)((?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*$/o) { + $ret_type = $1; + if (defined ($2)) { $ret_type .= " $2"; } + #print "DEBUG: Function: $symbol, Returns: $ret_type\n"; + $in_declaration = "function"; + } + } + } + else { + if ($previous_line !~ m/^\s*static\s+/) { + #print "DEBUG: skip block after inline function\n"; + # now we we need to skip a whole { } block + $skip_block = 1; + # $1 $2 + if ($previous_line =~ m/^\s*(?:\b(?:extern|G_INLINE_FUNC|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|unsigned\s+|struct\s+|enum\s+)?\w+)((?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*$/o) { + $ret_type = $1; + if (defined ($2)) { $ret_type .= " $2"; } + #print "DEBUG: Function: $symbol, Returns: $ret_type\n"; + $in_declaration = "function"; + # this is a hack to detect the end of declaration + $decl.=";" + } + } } # Try to catch function declarations with the return type and name @@ -507,14 +538,14 @@ sub ScanHeader { } elsif ($previous_line =~ m/^\s*\w+\s*$/ && $pre_previous_line =~ m/^\s*(?:\b(?:extern|G_INLINE_FUNC|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|unsigned\s+|struct\s+|enum\s+)*\w+(?:\**\s+\**(?:const|G_CONST_RETURN))?(?:\s+|\s*\*+))\s*$/o) { - $ret_type = $1; - $ret_type =~ s/\s*\n//; - $in_declaration = "function"; - - $symbol = $previous_line; - $symbol =~ s/^\s+//; - $symbol =~ s/\s*\n//; - #print "DEBUG: Function: $symbol, Returns: $ret_type\n"; + $ret_type = $1; + $ret_type =~ s/\s*\n//; + $in_declaration = "function"; + + $symbol = $previous_line; + $symbol =~ s/^\s+//; + $symbol =~ s/\s*\n//; + #print "DEBUG: Function: $symbol, Returns: $ret_type\n"; } #} elsif (m/^extern\s+/) { diff --git a/tests/bugs/docs/tester-sections.txt b/tests/bugs/docs/tester-sections.txt index 7713395..88a2e10 100644 --- a/tests/bugs/docs/tester-sections.txt +++ b/tests/bugs/docs/tester-sections.txt @@ -18,6 +18,8 @@ bug_460127 bug_471014 bug_477532 bug_501038 +bug_532395a +bug_532395b bug_544172 bug_552602 bug_554833 diff --git a/tests/bugs/src/tester.c b/tests/bugs/src/tester.c index 3f3cbb4..486eddc 100644 --- a/tests/bugs/src/tester.c +++ b/tests/bugs/src/tester.c @@ -109,9 +109,9 @@ G_CONST_RETURN gchar* G_CONST_RETURN * bug_471014 (void) { * * http://bugzilla.gnome.org/show_bug.cgi?id=446648 **/ - - - /** + + +/** * bug_552602: * * http://bugzilla.gnome.org/show_bug.cgi?id=552602 @@ -122,3 +122,4 @@ const char* const * bug_552602 (void) { return NULL; } + diff --git a/tests/bugs/src/tester.h b/tests/bugs/src/tester.h index b8ad1ad..29641e5 100644 --- a/tests/bugs/src/tester.h +++ b/tests/bugs/src/tester.h @@ -120,6 +120,36 @@ typedef struct { */ #define BUG_530758 "dummy" + +/** + * bug_532395a: + * @number: a number + * + * http://bugzilla.gnome.org/show_bug.cgi?id=532395 + * + * Returns: number + */ +/** + * bug_532395b: + * + * http://bugzilla.gnome.org/show_bug.cgi?id=532395 + */ +G_INLINE_FUNC guint +bug_532395a (gulong number) +{ +#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) + return G_LIKELY (number) ? + ((GLIB_SIZEOF_LONG * 8 - 1) ^ __builtin_clzl(number)) + 1 : 1; +#else + return 0; +#endif +} +G_INLINE_FUNC void +bug_532395b (void) +{ +} + + /** * bug_544172: * @self: object pointer. @@ -142,5 +172,6 @@ struct _bug_554833 { struct _bug_554833 * bug_554833_new (void); + #endif // GTKDOC_TESTER_H -- 2.11.4.GIT