[gtk-doc] scan: remove special case for '_' macro



commit 070acc51771b0e9b839d72264889ebbc1c2e6f13
Author: Stefan Sauer <ensonic users sf net>
Date:   Thu Mar 24 19:06:10 2016 +0100

    scan: remove special case for '_' macro
    
    As discussed in #753052, the special case for '_' is not very useful. The '_'
    macro is not part of the library API anyway. Further this is inconsitent w.r.t
    the _N() macros and others. Hence remove the special case.

 gtkdoc-scan.in                      |   75 +++++++++++++++++------------------
 tests/bugs/docs/tester-sections.txt |    1 -
 2 files changed, 36 insertions(+), 40 deletions(-)
---
diff --git a/gtkdoc-scan.in b/gtkdoc-scan.in
index 048e5c9..26566cf 100755
--- a/gtkdoc-scan.in
+++ b/gtkdoc-scan.in
@@ -85,16 +85,16 @@ sub run {
     GetOptions(\%optctl, "module=s", "source-dir:s", "ignore-headers:s",
                "output-dir:s", "rebuild-types", "rebuild-sections", "version",
                "help", "deprecated-guards:s", "ignore-decorators:s");
-    
+
     if ($PRINT_VERSION) {
         print "@VERSION \n";
         exit 0;
     }
-    
+
     if (!$MODULE) {
         $PRINT_HELP = 1;
     }
-    
+
     if ($PRINT_HELP) {
         print <<EOF;
 gtkdoc-scan version @VERSION@ - scan header files for public symbols
@@ -116,17 +116,17 @@ gtkdoc-scan version @VERSION@ - scan header files for public symbols
 EOF
         exit 0;
     }
-    
+
     $DEPRECATED_GUARDS = $DEPRECATED_GUARDS ? $DEPRECATED_GUARDS : 
"does_not_match_any_cpp_symbols_at_all_nope";
-    
+
     $IGNORE_DECORATORS = $IGNORE_DECORATORS || "(?=no)match";
-    
+
     $OUTPUT_DIR = $OUTPUT_DIR ? $OUTPUT_DIR : ".";
-    
+
     if (!-d ${OUTPUT_DIR}) {
         mkdir($OUTPUT_DIR, 0755) || die "Cannot create $OUTPUT_DIR: $!";
     }
-    
+
     my $old_decl_list = "${OUTPUT_DIR}/$MODULE-decl-list.txt";
     my $new_decl_list = "${OUTPUT_DIR}/$MODULE-decl-list.new";
     my $old_decl = "${OUTPUT_DIR}/$MODULE-decl.txt";
@@ -134,12 +134,12 @@ EOF
     my $old_types = "${OUTPUT_DIR}/$MODULE.types";
     my $new_types = "${OUTPUT_DIR}/$MODULE.types.new";
     my $sections_file = "${OUTPUT_DIR}/$MODULE-sections.txt";
-    
+
     # If this is the very first run then we create the .types file automatically.
     if (! -e $sections_file && ! -e $old_types) {
         $REBUILD_TYPES = 1;
     }
-    
+
     open (DECLLIST, ">$new_decl_list")
         || die "Can't open $new_decl_list";
     open (DECL, ">$new_decl")
@@ -148,54 +148,54 @@ EOF
         open (TYPES, ">$new_types")
             || die "Can't open $new_types";
     }
-    
+
     my %section_list = ();
     my $file;
-   
+
     # The header files to scan are passed in as command-line args.
     for $file (@ARGV) {
         &ScanHeader ($file, \%section_list);
     }
-    
+
     for my $dir (@SOURCE_DIRS) {
         &ScanHeaders ($dir, \%section_list);
     }
-    
+
     ## FIXME: sort by key and output
     #print DECLLIST $section_list;
     my $section;
     foreach $section (sort(keys %section_list)) {
         print DECLLIST "$section_list{$section}";
     }
-    
+
     close (DECLLIST);
     close (DECL);
-    
+
     if ($REBUILD_TYPES) {
         my $func;
-    
+
         foreach $func (sort(@get_types)) {
            print TYPES "$func\n";
         }
         close (TYPES);
         &UpdateFileIfChanged ($old_types, $new_types, 1);
-    
+
         # remove the file if empty
         if (scalar (@get_types) == 0) {
             unlink ("$new_types");
         }
     }
-    
+
     &UpdateFileIfChanged ($old_decl_list, $new_decl_list, 1);
     &UpdateFileIfChanged ($old_decl, $new_decl, 1);
-    
+
     # If there is no MODULE-sections.txt file yet or we are asked to rebuild it,
     # we copy the MODULE-decl-list.txt file into its place. The user can tweak it
     # later if they want.
     if ($REBUILD_SECTIONS || ! -e $sections_file) {
       `cp $old_decl_list $sections_file`;
     }
-    
+
     # If there is no MODULE-overrides.txt file we create an empty one
     # because EXTRA_DIST in gtk-doc.make requires it.
     my $overrides_file = "${OUTPUT_DIR}/$MODULE-overrides.txt";
@@ -257,7 +257,7 @@ sub ScanHeader {
     my ($input_file, $section_list) = @_;
 
     my $list = "";                  # Holds the resulting list of declarations.
-    my $title = "";                 # Holds the title of the section    
+    my $title = "";                 # Holds the title of the section
     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'.
@@ -286,7 +286,7 @@ sub ScanHeader {
                                     #   later.
     my %doc_comments = ();          # hastable of doc-comment we found. We can
                                     # use that to put element to the right
-                                    # sction in the generated section-file 
+                                    # sction in the generated section-file
 
     my $file_basename;
 
@@ -424,18 +424,15 @@ sub ScanHeader {
             if (m/^\s*#\s*define\s+(\w+)/) {
                 $symbol = $1;
                 $decl = $_;
-                # We assume all macros which start with '_' are private, but
-                # we accept '_' itself which is the standard gettext macro.
+                # We assume all macros which start with '_' are private.
                 # We also try to skip the first macro if it looks like the
                 # standard #ifndef HEADER_FILE #define HEADER_FILE etc.
-                # And we only want TRUE & FALSE defined in GLib (libdefs.h in
-                # libgnome also defines them if they are not already defined).
-                if (($symbol !~ m/^_/
+                # And we only want TRUE & FALSE defined in GLib.
+                if ($symbol !~ m/^_/
                      && ($previous_line !~ m/#ifndef\s+$symbol/
                          || $first_macro == 0)
                      && (($symbol ne 'TRUE' && $symbol ne 'FALSE')
-                         || $MODULE eq 'glib'))
-                    || $symbol eq "_") {
+                         || $MODULE eq 'glib')) {
                     $in_declaration = "macro";
                     @TRACE@("Macro: $symbol");
                 } else {
@@ -890,9 +887,9 @@ sub ScanHeader {
 
     # add title
     $list = "$title$list";
-    
+
     @TRACE@("Scanning $input_file done\n");
-    
+
     # Try to separate the standard macros and functions, placing them at the
     # end of the current section, in a subsection named 'Standard'.
     # do this in a loop to catch object, enums and flags
@@ -920,15 +917,15 @@ sub ScanHeader {
         } else {
           $class = $lclass = "";
         }
-    
+
         if ($class ne "") {
             my ($cclass) = $lclass;
             $cclass =~ s/_//g;
             my ($type) = $lprefix.$cclass;
-            
+
             if ($list =~ s/^${type}Private\n//im)               { $standard_decl .= $&; }
-            
-            # We only leave XxYy* in the normal section if they have docs 
+
+            # We only leave XxYy* in the normal section if they have docs
             if (! defined($doc_comments{$type})) {
               @TRACE@("  Hide instance docs for $type");
               if ($list =~ s/^${type}\n//im)                    { $standard_decl .= $&; }
@@ -945,7 +942,7 @@ sub ScanHeader {
               @TRACE@("  Hide iface docs for $type");
               if ($list =~ s/${type}Iface\n//im)                { $standard_decl .= $&; }
             }
-            
+
             while ($list =~ s/^\S+_IS_$class\n//m)              { $standard_decl .= $&; }
             while ($list =~ s/^\S+_TYPE_$class\n//m)            { $standard_decl .= $&; }
             while ($list =~ s/^\S+_${lclass}_get_type\n//m)     { $standard_decl .= $&; }
@@ -954,10 +951,10 @@ sub ScanHeader {
             while ($list =~ s/^\S+_${class}_GET_CLASS\n//m)     { $standard_decl .= $&; }
             while ($list =~ s/^\S+_${class}_GET_IFACE\n//m)     { $standard_decl .= $&; }
             while ($list =~ s/^\S+_${class}_GET_INTERFACE\n//m) { $standard_decl .= $&; }
-    
+
             # We do this one last, otherwise it tends to be caught by the IS_$class macro
             while ($list =~ s/^\S+_$class\n//m)                 { $standard_decl .= $&; }
-            
+
             @TRACE@("Decl '".join(",",split("\n",$list))."'\n");
             @TRACE@("Std  '".join(",",split("\n",$standard_decl))."'\n");
         }
diff --git a/tests/bugs/docs/tester-sections.txt b/tests/bugs/docs/tester-sections.txt
index 6389649..ca23ab0 100644
--- a/tests/bugs/docs/tester-sections.txt
+++ b/tests/bugs/docs/tester-sections.txt
@@ -71,7 +71,6 @@ deprecation_notice
 bug_741941
 bug_732689
 gst_play_marshal_BUFFER__BOXED
-_
 <SUBSECTION Standard>
 <SUBSECTION Private>
 GTKDOC_GNUC_CONST


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