[glibmm] gmmproc: Warn if parameter lists are not compatible



commit ba72548b01cb010cb570f6aa1d1c057ded86cfc0
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Dec 11 09:49:23 2017 +0100

    gmmproc: Warn if parameter lists are not compatible
    
    * tools/pm/DocsParser.pm: append_parameter_docs(): Warn if the lengths of
    the parameter lists in the docs.xml file, the methods.defs file and the _WRAP
    macro are not compatible. Don't assume that the last parameter is always a
    GError** output parameter just because it's called "error".
    Without this fix a too long parameter list in the docs.xml file caused very
    cryptic error messages, a too short list usually went undetected, but the
    generated documentation was incomplete.

 tools/pm/DocsParser.pm |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/tools/pm/DocsParser.pm b/tools/pm/DocsParser.pm
index bf7e058..20bcaf3 100644
--- a/tools/pm/DocsParser.pm
+++ b/tools/pm/DocsParser.pm
@@ -472,6 +472,12 @@ sub append_parameter_docs($$;$)
   # due to imperfections in the C docs, and it's difficult to get the C docs
   # corrected, correct docs can be added to the docs_override.xml file.
 
+  if (scalar @docs_param_names != scalar @c_param_names)
+  {
+    print STDERR "DocsParser.pm: Warning, $$obj_function{name}\n" .
+      "  Incompatible parameter lists in the docs.xml file and the methods.defs file.\n";
+  }
+
   # Skip first param if this is a signal.
   if ($$obj_function{name} =~ /\w+::/)
   {
@@ -508,8 +514,14 @@ sub append_parameter_docs($$;$)
   # Skip the last param if it's an error output param.
   if (scalar @docs_param_names && $docs_param_names[-1] eq "error")
   {
-    pop(@docs_param_names);
-    pop(@c_param_names);
+    # If the number of parameters in @docs_param_names is not greater than
+    # the number of parameters in the _WRAP macro, the parameter called "error"
+    # is probably not an error output parameter.
+    if (!defined($objCppfunc) || scalar @docs_param_names > scalar @{$$objCppfunc{param_names}})
+    {
+      pop(@docs_param_names);
+      pop(@c_param_names);
+    }
   }
 
   my $cpp_param_names;
@@ -523,6 +535,11 @@ sub append_parameter_docs($$;$)
     {
       $out_param_index = $$param_mappings{OUT};
     }
+    if (scalar @docs_param_names != scalar @$cpp_param_names)
+    {
+      print STDERR "DocsParser.pm: Warning, $$obj_function{name}\n" .
+        "  Incompatible parameter lists in the docs.xml file and the _WRAP macro.\n";
+    }
   }
   my %param_name_mappings; # C name -> C++ name
 


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