[gtk-doc] scan: be smarter in when trying to figure the get_type functions, Fixes #580300



commit 613e1f7dca2ccb1cbe95386070e94ba0c41cddf8
Author: Stefan Kost <ensonic users sf net>
Date:   Sat Jun 27 22:46:11 2009 +0300

    scan: be smarter in when trying to figure the get_type functions, Fixes #580300
    
    Check full prototype instead of just the name when using --rebuild-types. Also
    sort the types by name to minimize the delta when rebuilding.

 gtkdoc-scan.in                 |   26 ++++++++++++++++++--------
 tests/bugs/docs/Makefile.am    |    1 +
 tests/bugs/src/tester.c        |   12 ++++++++++--
 tests/bugs/src/tester.h        |    5 +++++
 tests/gobject/docs/Makefile.am |    4 +++-
 5 files changed, 37 insertions(+), 11 deletions(-)
---
diff --git a/gtkdoc-scan.in b/gtkdoc-scan.in
index 354749e..d199fb5 100755
--- a/gtkdoc-scan.in
+++ b/gtkdoc-scan.in
@@ -141,6 +141,9 @@ my $main_list = "";
 my $object_list = "";
 my $file;
 
+my @get_types = ();
+
+
 # do not read files twice; checking it here permits to give both srcdir and
 # builddir as --source-dir without fear of duplicities
 my %seen_headers;
@@ -157,7 +160,14 @@ for my $dir (@SOURCE_DIRS) {
 print DECLLIST $object_list, $main_list;
 close (DECLLIST);
 close (DECL);
-close (TYPES) if ($REBUILD_TYPES);
+if ($REBUILD_TYPES) {
+    my $func;
+
+    foreach $func (sort(@get_types)) {
+       print TYPES "$func\n"; 
+    }
+    close (TYPES);
+}
 
 &UpdateFileIfChanged ($old_decl_list, $new_decl_list, 1);
 &UpdateFileIfChanged ($old_decl, $new_decl, 1);
@@ -601,6 +611,13 @@ sub ScanHeader {
 		$ret_type =~ s%/\*.*?\*/%%g;	# remove comments in ret type.
 		&AddSymbolToList (\$list, $symbol);
 		print DECL "<FUNCTION>\n<NAME>$symbol</NAME>\n$deprecated<RETURNS>$ret_type</RETURNS>\n$decl\n</FUNCTION>\n";
+                if ($REBUILD_TYPES) {
+                    # check if this looks like a get_type function and if so remember
+                    if (($symbol =~ m/_get_type$/) && ($ret_type =~ m/GType/) && ($decl =~ m/(void|)/)) {
+                        #print "Adding get-type: [$ret_type] [$symbol] [$decl]\tfrom $input_file\n";
+                        push (@get_types, $symbol);
+                    }
+                }
 		$in_declaration = "";
 	    }
 	}
@@ -695,13 +712,6 @@ sub ScanHeader {
 	$class = $1;
     }
 
-    if ($REBUILD_TYPES) {
-      while ($list =~ m/^\S+_.*_get_type\n/mg) {
-#        print "Adding get-type: $&\tfrom $input_file\n";
-	print TYPES $&;
-      }
-    }
-
     if ($class ne "") {
 	if ($list =~ s/^\S+_IS_$class\n//m)          { $standard_decl .= $&; }
 	if ($list =~ s/^\S+_TYPE_$class\n//m)        { $standard_decl .= $&; }
diff --git a/tests/bugs/docs/Makefile.am b/tests/bugs/docs/Makefile.am
index f8a1d92..576dd33 100644
--- a/tests/bugs/docs/Makefile.am
+++ b/tests/bugs/docs/Makefile.am
@@ -20,6 +20,7 @@ SCANGOBJ_OPTIONS=2>&1 | tee gtkdoc-scangobj.log
 # Extra options to supply to gtkdoc-scan.
 SCAN_OPTIONS=--deprecated-guards="GTKDOC_TESTER_DISABLE_DEPRECATED" \
   --ignore-decorators="GLIB_VAR|GTKDOC_GNUC_CONST" \
+  --rebuild-types \
   2>&1 | tee gtkdoc-scan.log
 
 # Extra options to supply to gtkdoc-mkdb.
diff --git a/tests/bugs/src/tester.c b/tests/bugs/src/tester.c
index faee44e..a60db02 100644
--- a/tests/bugs/src/tester.c
+++ b/tests/bugs/src/tester.c
@@ -139,6 +139,14 @@ int bug_574654a(void) {
   return 0;
 }
 
-void bug_574654b(double offset) {
-}
+void bug_574654b(double offset) { }
+
+
+void bug_580300a_get_type(void) { }
+
+void bug_580300b_get_type(gint a) { }
+
+void bug_580300c_get_type() { }
+
+int bug_580300d_get_type() { }
 
diff --git a/tests/bugs/src/tester.h b/tests/bugs/src/tester.h
index 741bfa1..7afc725 100644
--- a/tests/bugs/src/tester.h
+++ b/tests/bugs/src/tester.h
@@ -186,5 +186,10 @@ int bug_574654a(void) GTKDOC_GNUC_CONST;
 void bug_574654b(double offset);
 
 
+void bug_580300a_get_type(void);
+void bug_580300b_get_type(gint a);
+void bug_580300c_get_type();
+extern int bug_580300d_get_type();
+
 #endif // GTKDOC_TESTER_H
 
diff --git a/tests/gobject/docs/Makefile.am b/tests/gobject/docs/Makefile.am
index 365584d..151da83 100644
--- a/tests/gobject/docs/Makefile.am
+++ b/tests/gobject/docs/Makefile.am
@@ -18,7 +18,9 @@ DOC_SOURCE_DIR=$(top_srcdir)/tests/gobject/src
 SCANGOBJ_OPTIONS=2>&1 | tee gtkdoc-scangobj.log
 
 # Extra options to supply to gtkdoc-scan.
-SCAN_OPTIONS=--deprecated-guards="GTKDOC_TESTER_DISABLE_DEPRECATED" 2>&1 | tee gtkdoc-scan.log
+SCAN_OPTIONS=--deprecated-guards="GTKDOC_TESTER_DISABLE_DEPRECATED" \
+  --rebuild-types \
+  2>&1 | tee gtkdoc-scan.log
 
 # Extra options to supply to gtkdoc-mkdb.
 MKDB_OPTIONS=--sgml-mode 2>&1 | tee gtkdoc-mkdb.log



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