[gtk-doc] vargars: cleanup varargs handling



commit 4c9d4db0e264d403b301dad9be1c290134846d03
Author: Stefan Kost <ensonic users sf net>
Date:   Fri Apr 22 15:41:07 2011 -0400

    vargars: cleanup varargs handling
    
    Just always call them "..." internaly to avoid converting them for doc output.
    Handle more vararg variants.

 gtkdoc-common.pl.in |    8 ++++++--
 gtkdoc-mkdb.in      |   26 ++++++++++----------------
 2 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/gtkdoc-common.pl.in b/gtkdoc-common.pl.in
index 536f16e..6613a9c 100644
--- a/gtkdoc-common.pl.in
+++ b/gtkdoc-common.pl.in
@@ -337,7 +337,7 @@ sub ParseFunctionDeclaration {
 
     my ($param_num) = 0;
     while ($declaration ne "") {
-        # TRACE@("$declaration");
+        # TRACE@("[$declaration]");
 
         if ($declaration =~ s/^[\s,]+//) {
             # skip whitespace and commas
@@ -353,7 +353,7 @@ sub ParseFunctionDeclaration {
             my $label = defined $namefunc ? $namefunc->($xref) : $xref;
             push @result, $label;
 
-        } elsif ($declaration =~ s/^...\s*[,\n]//) {
+        } elsif ($declaration =~ s/^\s*[_a-zA-Z0-9]*\.\.\.\s*[,\n]//) {
             push @result, "...";
             my $label = defined $namefunc ? $namefunc->("...") : "...";
             push @result, $label;
@@ -455,6 +455,10 @@ sub ParseMacroDeclaration {
         foreach $param (split (/,/, $params)) {
             $param =~ s/^\s+//;
             $param =~ s/\s*$//;
+            # Allow varargs variations
+            if ($param =~ m/^.*\.\.\.$/) {
+                $param = "...";
+            }
             if ($param =~ m/\S/) {
                 push @result, $param;
                 push @result, defined $namefunc ? $namefunc->($param) : $param;
diff --git a/gtkdoc-mkdb.in b/gtkdoc-mkdb.in
index 31f51d6..f3f709c 100755
--- a/gtkdoc-mkdb.in
+++ b/gtkdoc-mkdb.in
@@ -2029,10 +2029,6 @@ sub OutputFunction {
     for (my $i = 1; $i <= $#fields; $i += 2) {
         my $field_name = $fields[$i];
 
-        if ($field_name eq "Varargs") {
-            $field_name = "...";
-        }
-
         if ($i == 1) {
             $synop .= "$field_name";
             $desc  .= "$field_name";
@@ -2125,9 +2121,6 @@ sub OutputParamDescriptions {
             } elsif ($param_name eq "void") {
                 #print "!!!! void in params for $symbol?\n";
             } else {
-                if ($param_name eq "Varargs") {
-                    $param_name = "...";
-                }
                 if (@fields) {
                     if (!defined $field_descrs{$param_name}) {
                         &LogWarning (&GetSymbolSourceFile ($symbol), &GetSymbolSourceLine($symbol),
@@ -4071,14 +4064,16 @@ sub ScanSourceFile {
             my $param_desc = $';
 
             #print "Found parameter: $param_name\n";
-            # Allow '...' as the Varargs parameter.
-            if ($param_name eq "...") {
-                $param_name = "Varargs";
+            # Allow varargs variations
+            if ($param_name =~ m/^.*\.\.\.$/) {
+                $param_name = "...";
             }
             if ("\L$param_name" eq "returns") {
                 $return_style = 'sane';
                 $ignore_broken_returns = 1;
             }
+            @TRACE@("Found param for symbol $symbol : '$param_name'= '$_'");
+
             push (@params, $param_name);
             push (@params, $param_desc);
             $current_param += $PARAM_FIELD_COUNT;
@@ -4465,11 +4460,6 @@ sub MergeSourceDocumentation {
                     for ($j = 0; $j <= $#$tmpl_params; $j += $PARAM_FIELD_COUNT) {
                         my $tmpl_param_name = $$tmpl_params[$j];
 
-                        # Allow '...' as the Varargs parameter.
-                        if ($tmpl_param_name eq "...") {
-                            $tmpl_param_name = "Varargs";
-                        }
-
                         # Try to find the param in the source comment documentation.
                         my $found = 0;
                         my $k;
@@ -5029,11 +5019,15 @@ sub ReadTemplateFile {
                 if ($param_name =~ m/^[Rr]eturns?$/) {
                     $param_name = "Returns";
                 }
+                # Allow varargs variations
+                if ($param_name =~ m/^.*\.\.\.$/) {
+                    $param_name = "...";
+                }
 
                 # strip trailing whitespaces and blank lines
                 s/\s+\n$/\n/m;
                 s/\n+$/\n/sm;
-                #print "Found param for symbol $current_symbol : '$param_name'= '$_'";
+                @TRACE@("Found param for symbol $current_symbol : '$param_name'= '$_'");
 
                 if ($param_name eq "Deprecated") {
                     $in_deprecated = 1;



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