[glibmm] gmmproc: Verify that void methods should not return a value.



commit 31fc9337abe4280de37686d57ad2f0074654f451
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Fri Mar 22 15:36:26 2013 -0400

    gmmproc: Verify that void methods should not return a value.
    
        * tools/gmmproc.in: ($main::return_mismatches): Add boolean to store
        whether method return mismatches should be checked.  Make it false by
        default.
        (parse_command_line_args): Add logic to parse a new
        --return-mismatches option to specify if gmmproc should verify that
        void methods should not return a value.
        (print_usage): Modify the usage message to describe the new option.
    
        For convenience, output the source for which there are unwrapped
        functions, properties and signals.
    
        * tools/pm/DocsParser.pm (remove_example_code): Also output the source
        being processed when the example code is removed (for convenience).
        * tools/pm/Output.pm (error): Once more, output the source being
        processed when an error occurs, for convenience.
        (convert_args_cpp_to_c): Add a check for when the C++ method for which
        the parameters are being converted returns void but the C function
        does not return void.  If the added option above is specified, output
        a warning.
    
        Bug #696364.

 ChangeLog              |   26 ++++++++++++++++++++++++++
 tools/gmmproc.in       |   27 +++++++++++++++++----------
 tools/pm/DocsParser.pm |    2 +-
 tools/pm/Output.pm     |   14 +++++++++++++-
 4 files changed, 57 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0ba25a2..9a0a5e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
 2013-03-22  José Alburquerque  <jaalburquerque gmail com>
 
+       gmmproc: Verify that void methods should not return a value.
+
+       * tools/gmmproc.in: ($main::return_mismatches): Add boolean to store
+       whether method return mismatches should be checked.  Make it false by
+       default.
+       (parse_command_line_args): Add logic to parse a new
+       --return-mismatches option to specify if gmmproc should verify that
+       void methods should not return a value.
+       (print_usage): Modify the usage message to describe the new option.
+
+       For convenience, output the source for which there are unwrapped
+       functions, properties and signals.
+
+       * tools/pm/DocsParser.pm (remove_example_code): Also output the source
+       being processed when the example code is removed (for convenience).
+       * tools/pm/Output.pm (error): Once more, output the source being
+       processed when an error occurs, for convenience.
+       (convert_args_cpp_to_c): Add a check for when the C++ method for which
+       the parameters are being converted returns void but the C function
+       does not return void.  If the added option above is specified, output
+       a warning.
+       
+       Bug #696364.
+
+2013-03-22  José Alburquerque  <jaalburquerque gmail com>
+
        TlsPassword: Correct its constructor parameter order.
 
        * gio/src/tlspassword.hg (TlsPassword): Reorder its parameters so that
diff --git a/tools/gmmproc.in b/tools/gmmproc.in
index ab4ded5..5349c51 100644
--- a/tools/gmmproc.in
+++ b/tools/gmmproc.in
@@ -62,6 +62,7 @@ $main::srcdir    = '.';
 $main::defsdir   = '.';
 $main::source    = '';
 $main::unwrapped = 1;
+$main::return_mismatches = 0;
 $main::debug     = (exists $ENV{'GMMPROC_DEBUG'}) ? $ENV{'GMMPROC_DEBUG'} : '';
 
 # prototypes
@@ -124,17 +125,17 @@ if ($main::unwrapped)
 
     if (@methods)
     {
-      print STDERR ('gmmproc: Unwrapped functions:',
+      print STDERR ("gmmproc: $main::source: Unwrapped functions:",
                     map($$_{c_name}, @methods));
     }
     if (@properties)
     {
-      print STDERR ('gmmproc: Unwrapped properties:',
+      print STDERR ("gmmproc: $main::source: Unwrapped properties:",
                     map($$_{class} . '::' . $$_{name}, @properties));
     }
     if (@signals)
     { 
-      print STDERR ('gmmproc: Unwrapped signals:',
+      print STDERR ("gmmproc: $main::source: Unwrapped signals:",
                     map($$_{class} . '::' . $$_{name}, @signals));
     }
   }
@@ -152,18 +153,20 @@ sub print_usage()
   print
 'Usage: gmmproc [options] name srcdir destdir
   -h 
-  --help      This usage message.
+  --help               This usage message.
 
-  --doc       Produces a header file for documentation.  (FIXME)
+  --doc                Produces a header file for documentation.  (FIXME)
 
-  --debug     Leave intermediate output arround for analysis.
-              Alternatively, set GMMPROC_DEBUG=1 in the environment.
+  --debug              Leave intermediate output arround for analysis.
+                       Alternatively, set GMMPROC_DEBUG=1 in the environment.
 
-  --unwrapped Warn about possible unwrapped functions.
+  --unwrapped          Warn about possible unwrapped functions.
  
-  --defs dir  Change the directory to seach for defs.
+  --return-mismatches  Warn about possible method return mismatches.
+ 
+  --defs dir           Change the directory to seach for defs.
 
-  -I dir      Specify the directory with m4 files.
+  -I dir               Specify the directory with m4 files.
 
 
 Note: This will read srcdir/name.{hg,ccg} file and generates destdir/name.cc
@@ -192,6 +195,10 @@ sub parse_command_line_args()
       {
         $main::unwrapped = 1;
       }
+      elsif (/^--return-mismatches/)
+      {
+        $main::return_mismatches = 1;
+      }
       elsif (/^--defs/)
       {
         $main::defsdir = shift @ARGV;
diff --git a/tools/pm/DocsParser.pm b/tools/pm/DocsParser.pm
index 87fcdfd..b645c33 100644
--- a/tools/pm/DocsParser.pm
+++ b/tools/pm/DocsParser.pm
@@ -365,7 +365,7 @@ sub remove_example_code($$)
     ($$text =~ s"<programlisting>.*?</programlisting>"\n[C example ellipted]"sg);
   $example_removals += ($$text =~ s"\|\[.*?]\|"\n[C example ellipted]"sg);
 
-  print STDERR "gmmproc: $obj_name: Example code discarded.\n"
+  print STDERR "gmmproc: $main::source: $obj_name: Example code discarded.\n"
     if ($example_removals);
 }
 
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index 3300e8c..337c274 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -80,7 +80,7 @@ sub output_wrap_failed($$$)
 sub error
 {
   my $format=shift @_;
-  printf STDERR "Output.pm: $format",@_;
+  printf STDERR "Output.pm: $main::source: $format",@_;
 }
 
 sub ifdef($$)
@@ -951,6 +951,18 @@ sub convert_args_cpp_to_c($$$$$)
     $has_output_param = 1;
     $output_param_index = $$cpp_param_mappings{"OUT"};
   }
+  else
+  {
+    # Check for possible void return mismatch (warn if the option was
+    # specified to gmmproc at the command line).
+    if($main::return_mismatches &&
+      $$objCppfunc{rettype} eq "void" && $$objCDefsFunc{rettype} ne "void")
+    {
+      Output::error(
+        "void return of $$objCppfunc{name}() does not match the "
+        . "$$objCDefsFunc{rettype} return type.\n");
+    }
+  }
 
   # add implicit last error parameter;
   if ( $automatic_error ne "" &&


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