resetting manifest requested domain to floor
[platform/upstream/gst-common.git] / gstdoc-scangobj
index 6555ab0..09039a5 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 # -*- cperl -*-
 #
 # gtk-doc - GTK DocBook documentation generator.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 #
 
 #
-# This gets information about object heirarchies and signals
+# This gets information about object hierarchies and signals
 # by compiling a small C program. CFLAGS and LDFLAGS must be
 # set appropriately before running this script.
 #
-# NOTE: the lookup_signal_arg_names() function contains the argument names of
-#       standard GTK signal handlers. This may need to be updated for new
-#       GTK signals or Gnome widget signals.
 
 use Getopt::Long;
 
-unshift @INC, '/usr/share/gtk-doc/data';
+my $GTK_DOC_PREFIX=`pkg-config --variable prefix gtk-doc`;
+if ($GTK_DOC_PREFIX) {
+  chomp $GTK_DOC_PREFIX;
+  #print "Adding $GTK_DOC_PREFIX/share/gtk-doc/data to \@INC\n";
+  unshift @INC, "$GTK_DOC_PREFIX/share/gtk-doc/data";
+} else {
+  unshift @INC, '/usr/share/gtk-doc/data';
+}
 require "gtkdoc-common.pl";
 
 # Options
@@ -38,27 +42,33 @@ require "gtkdoc-common.pl";
 # name of documentation module
 my $MODULE;
 my $OUTPUT_DIR;
+my $INSPECT_DIR;
+my $VERBOSE;
 my $PRINT_VERSION;
 my $PRINT_HELP;
 my $TYPE_INIT_FUNC="g_type_init ()";
 
 # --nogtkinit is deprecated, as it is the default now anyway.
 %optctl = (module => \$MODULE,
+           source => \$SOURCE,
           types => \$TYPES_FILE,
           nogtkinit => \$NO_GTK_INIT,
           'type-init-func' => \$TYPE_INIT_FUNC,
           'output-dir' => \$OUTPUT_DIR,
+          'inspect-dir' => \$INSPECT_DIR,
+          'verbose' => \$VERBOSE,
           'version' => \$PRINT_VERSION,
           'help' => \$PRINT_HELP);
-          
-GetOptions(\%optctl, "module=s", "types:s", "output-dir:s", "nogtkinit", "type-init-func:s", "version", "help");
+
+GetOptions(\%optctl, "module=s", "source=s", "types:s", "output-dir:s", "inspect-dir:s", "nogtkinit", "type-init-func:s", "verbose", "version", "help");
 
 if ($NO_GTK_INIT) {
   # Do nothing. This just avoids a warning.
+  # the option is not used anymore
 }
 
 if ($PRINT_VERSION) {
-    print "1.3\n";
+    print "1.5\n";
     exit 0;
 }
 
@@ -67,23 +77,28 @@ if (!$MODULE) {
 }
 
 if ($PRINT_HELP) {
-    print "gtkdoc-scangobj version 1.3\n";
-    print "\n--module=MODULE_NAME  Name of the doc module being parsed";
-    print "\n--types=FILE          The name of the file to store the types in";
-    print "\n--type-init-func=FUNC The init function to call instead of g_type_init ()";
-    print "\n--output-dir=DIRNAME  The directory where the results are stored";
-    print "\n--version             Print the version of this program";
-    print "\n--help                Print this help\n";
+    print <<EOF;
+gstdoc-scangobj version 1.5 - introspect gstreamer-plugins
+
+--module=MODULE_NAME          Name of the doc module being parsed
+--source=SOURCE_NAME          Name of the source module for plugins
+--types=FILE                  The name of the file to store the types in
+--type-init-func=FUNC         The init function to call instead of g_type_init()
+--output-dir=DIRNAME          The directory where the results are stored
+--inspect-dir=DIRNAME         The directory where the plugin inspect data is stored
+--verbose                     Print extra output while processing
+--version                     Print the version of this program
+--help                        Print this help
+EOF
     exit 0;
 }
 
 $OUTPUT_DIR = $OUTPUT_DIR ? $OUTPUT_DIR : ".";
 
-# THOMAS: dynamic types; only use types file for headers
- $TYPES_FILE = $TYPES_FILE ? $TYPES_FILE : "$OUTPUT_DIR/$MODULE.types";
+$TYPES_FILE = $TYPES_FILE ? $TYPES_FILE : "$OUTPUT_DIR/$MODULE.types";
 
-open TYPES, $TYPES_FILE || die "Cannot open $TYPES_FILE: $!\n";
-open OUTPUT, ">$MODULE-scan.c" || die "Cannot open $MODULE-scan.c: $!\n";
+open (TYPES, $TYPES_FILE) || die "Cannot open $TYPES_FILE: $!\n";
+open (OUTPUT, ">$MODULE-scan.c") || die "Cannot open $MODULE-scan.c: $!\n";
 
 my $old_signals_filename = "$OUTPUT_DIR/$MODULE.signals";
 my $new_signals_filename = "$OUTPUT_DIR/$MODULE.signals.new";
@@ -96,144 +111,337 @@ my $new_prerequisites_filename = "$OUTPUT_DIR/$MODULE.prerequisites.new";
 my $old_args_filename = "$OUTPUT_DIR/$MODULE.args";
 my $new_args_filename = "$OUTPUT_DIR/$MODULE.args.new";
 
+my $debug_log="g_message";
+if (!defined($VERBOSE) or $VERBOSE eq "0") {
+    $debug_log="//$debug_log";
+}
+
 # write a C program to scan the types
 
 $includes = "";
-#@types = ();
+@types = ();
+@impl_types = ();
 
 for (<TYPES>) {
     if (/^#include/) {
        $includes .= $_;
-#    } elsif (/^%/) {
-#      next;
-#    } elsif (/^\s*$/) {
-#      next;
-#    } else {
-#      chomp;
-#      push @types, $_;
+    } elsif (/^%/) {
+       next;
+    } elsif (/^\s*$/) {
+       next;
+    } elsif (/^type:(.*)$/) {
+       $t = $1;
+        chomp $t;
+       push @impl_types, $t;
+    } else {
+       chomp;
+       push @types, $_;
     }
 }
 
-#$ntypes = @types + 1;
+$ntypes = @types + @impl_types + 1;
 
 print OUTPUT <<EOT;
+
+/* file generated by common/gstdoc-scangobj */
+
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <errno.h>
 
 $includes
+
 #ifdef GTK_IS_WIDGET_CLASS
 #include <gtk/gtkversion.h>
 #endif
-gint num_object_types = 0;
-GType *object_types = NULL;
+
+static GType *object_types = NULL;
+
+static GString *xmlstr = NULL;
+
+static const gchar*
+xmlprint (gint indent, const gchar *tag, const gchar *data)
+{
+  const gchar indent_str[] = "                                               ";
+
+  /* reset */
+  g_string_truncate (xmlstr, 0);
+  g_string_append_len (xmlstr, indent_str, MIN (indent, strlen (indent_str)));
+  g_string_append_printf (xmlstr, "<%s>", tag);
+
+  if (data) {
+    gchar *s;
+
+    s = g_markup_escape_text (data, -1);
+    g_string_append (xmlstr, s);
+    g_free (s);
+  }
+
+  g_string_append_printf (xmlstr, "</%s>\\n", tag);
+  return xmlstr->str;
+}
+
+static gint
+gst_feature_sort_compare (gconstpointer a, gconstpointer b)
+{
+  const gchar *name_a = gst_plugin_feature_get_name ((GstPluginFeature *) a);
+  const gchar *name_b = gst_plugin_feature_get_name ((GstPluginFeature *) b);
+  return strcmp (name_a, name_b);
+}
+
+static gint
+static_pad_template_compare (gconstpointer a, gconstpointer b)
+{
+  GstStaticPadTemplate *spt_a = (GstStaticPadTemplate *) a;
+  GstStaticPadTemplate *spt_b = (GstStaticPadTemplate *) b;
+
+  /* we want SINK before SRC (enum is UNKNOWN, SRC, SINK) */
+  if (spt_a->direction != spt_b->direction)
+    return spt_b->direction - spt_a->direction;
+
+  /* we want ALWAYS first, SOMETIMES second, REQUEST last
+   * (enum is ALWAYS, SOMETIMES, REQUEST) */
+  if (spt_a->presence != spt_b->presence)
+    return spt_a->presence - spt_b->presence;
+
+  return strcmp (spt_a->name_template, spt_b->name_template);
+}
 
 static GType *
 get_object_types (void)
 {
+    gpointer g_object_class;
     GList *plugins = NULL;
     GList *factories = NULL;
     GList *l;
     GstElementFactory *factory = NULL;
-
+    GType type;
     gint i = 0;
+    gboolean reinspect;
+
+    /* get a list of features from plugins in our source module */
+    plugins = gst_registry_get_plugin_list (gst_registry_get ());
+
+    xmlstr = g_string_new ("");
 
-    /* get the number of types from the registry */
-    plugins = gst_registry_pool_plugin_list ();
+    reinspect = !g_file_test ("scanobj-build.stamp", G_FILE_TEST_EXISTS);
 
     while (plugins) {
       GList *features;
       GstPlugin *plugin;
+      const gchar *source;
+      FILE *inspect = NULL;
+      gchar *inspect_name;
 
       plugin = (GstPlugin *) (plugins->data);
       plugins = g_list_next (plugins);
+      source = gst_plugin_get_source (plugin);
+      if (!source || strcmp (source, "$SOURCE") != 0) {
+        continue;
+      }
+
+      /* skip static coreelements plugin with pipeline and bin element factory */
+      if (gst_plugin_get_filename (plugin) == NULL)
+        continue;
+
+      $debug_log ("plugin: %s source: %s", gst_plugin_get_name (plugin), source);
+
+      if (reinspect) {
+        gchar *basename;
+
+        inspect_name = g_strdup_printf ("$INSPECT_DIR" G_DIR_SEPARATOR_S "plugin-%s.xml",
+            gst_plugin_get_name (plugin));
+        inspect = fopen (inspect_name, "w");
+        if (inspect == NULL) {
+          g_error ("Could not open %s for writing: %s\\n", inspect_name,
+              g_strerror (errno));
+        }
+        g_free (inspect_name);
+
+                 basename = g_path_get_basename (gst_plugin_get_filename (plugin));
+
+        /* output plugin data */
+        fputs ("<plugin>\\n",inspect);
+        fputs (xmlprint(2, "name", gst_plugin_get_name (plugin)),inspect);
+        fputs (xmlprint(2, "description", gst_plugin_get_description (plugin)),inspect);
+        fputs (xmlprint(2, "filename", gst_plugin_get_filename (plugin)),inspect);
+        fputs (xmlprint(2, "basename", basename),inspect);
+        fputs (xmlprint(2, "version", gst_plugin_get_version (plugin)),inspect);
+        fputs (xmlprint(2, "license", gst_plugin_get_license (plugin)),inspect);
+        fputs (xmlprint(2, "source", gst_plugin_get_source (plugin)),inspect);
+        fputs (xmlprint(2, "package", gst_plugin_get_package (plugin)),inspect);
+        fputs (xmlprint(2, "origin", gst_plugin_get_origin (plugin)),inspect);
+        fputs ("  <elements>\\n", inspect);
+
+                 g_free (basename);
+      }
+
+      features =
+          gst_registry_get_feature_list_by_plugin (gst_registry_get (),
+          gst_plugin_get_name (plugin));
+
+      /* sort factories by feature->name */
+      features = g_list_sort (features, gst_feature_sort_compare);
 
-      features = gst_plugin_get_feature_list (plugin);
       while (features) {
         GstPluginFeature *feature;
         feature = GST_PLUGIN_FEATURE (features->data);
-        if (!gst_plugin_feature_ensure_loaded (feature)) {
+        feature = gst_plugin_feature_load (feature);
+        if (!feature) {
           g_warning ("Could not load plugin feature %s",
                      gst_plugin_feature_get_name (feature));
         }
 
         if (GST_IS_ELEMENT_FACTORY (feature)) {
+          const gchar *pad_dir[] = { "unknown","source","sink" };
+          const gchar *pad_pres[] = { "always","sometimes","request" };
+          GList *pads, *pad;
+
+          $debug_log ("  feature: %s", gst_plugin_feature_get_name (feature));
+
           factory = GST_ELEMENT_FACTORY (feature);
-          factories = g_list_append (factories, factory);
+          factories = g_list_prepend (factories, factory);
+
+          if (reinspect) {
+            /* output element data */
+            fputs ("    <element>\\n", inspect);
+            fputs (xmlprint(6, "name", gst_plugin_feature_get_name (feature)),inspect);
+            fputs (xmlprint(6, "longname", gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_LONGNAME)),inspect);
+            fputs (xmlprint(6, "class", gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_KLASS)),inspect);
+            fputs (xmlprint(6, "description", gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_DESCRIPTION)),inspect);
+            fputs (xmlprint(6, "author", gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_AUTHOR)),inspect);
+            fputs ("      <pads>\\n", inspect);
+
+            /* output pad-template data */
+            pads = g_list_copy ((GList *) gst_element_factory_get_static_pad_templates (factory));
+            pads = g_list_sort (pads, static_pad_template_compare);
+            for (pad = pads; pad != NULL; pad = pad->next) {
+              GstStaticPadTemplate *pt = pad->data;
+
+              fputs ("        <caps>\\n", inspect);
+              fputs (xmlprint(10, "name", pt->name_template),inspect);
+              fputs (xmlprint(10, "direction", pad_dir[pt->direction]),inspect);
+              fputs (xmlprint(10, "presence", pad_pres[pt->presence]),inspect);
+              fputs (xmlprint(10, "details", pt->static_caps.string),inspect);
+              fputs ("        </caps>\\n", inspect);
+            }
+            g_list_free (pads);
+            fputs ("      </pads>\\n    </element>\\n", inspect);
+          }
         }
         features = g_list_next (features);
       }
+
+      if (reinspect) {
+        fputs ("  </elements>\\n</plugin>", inspect);
+        fclose (inspect);
+      }
     }
 
-    num_object_types = g_list_length (factories);
-    g_debug ("number of element factories: %d", g_list_length (factories));
+    g_string_free (xmlstr, TRUE);
+
+    $debug_log ("number of element factories: %d", g_list_length (factories));
 
     /* allocate the object_types array to hold them */
-    object_types = g_new0 (GType, g_list_length (factories));
+    object_types = g_new0 (GType, g_list_length (factories)+$ntypes+1);
 
     l = factories;
     i = 0;
 
     /* fill it */
     while (l) {
-      GType type;
       factory = GST_ELEMENT_FACTORY (l->data);
-      g_debug ("adding type for factory %s", gst_element_factory_get_longname (factory));
       type = gst_element_factory_get_element_type (factory);
-      g_debug ("adding type %p", (void *) type);
-      object_types[i] = type;
-      i++;
+      if (type != 0) {
+        $debug_log ("adding type for factory %s", gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_LONGNAME));
+        object_types[i++] = type;
+      } else {
+        g_message ("type info for factory %s not found",
+            gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_LONGNAME));
+      }
       l = g_list_next (l);
     }
+
+EOT
+
+# get_type functions:
+for (@types) {
+print OUTPUT <<EOT;
+    type = $_ ();
+    if (type == 0) {
+      g_message ("$_ () didn't return a valid type");
+    }
+    else {
+      object_types[i++] = type;
+    }
 EOT
+}
 
+# Implicit types retrieved from GLib:
+for (@impl_types) {
 print OUTPUT <<EOT;
+    type = g_type_from_name ("$_");
+    if (type == 0) {
+      g_message ("Implicit type $_ not found");
+    }
+    else {
+      object_types[i++] = type;
+    }
+EOT
+}
+
+print OUTPUT <<EOT;
+
+    object_types[i] = 0;
+
+    /* reference the GObjectClass to initialize the param spec pool
+     * potentially needed by interfaces. See http://bugs.gnome.org/571820 */
+    g_object_class = g_type_class_ref (G_TYPE_OBJECT);
 
     /* Need to make sure all the types are loaded in and initialize
      * their signals and properties.
      */
-    g_debug ("class reffing");
+    for (i=0; object_types[i]; i++)
+      {
+        if (G_TYPE_IS_CLASSED (object_types[i]))
+          g_type_class_ref (object_types[i]);
+        if (G_TYPE_IS_INTERFACE (object_types[i]))
+          g_type_default_interface_ref (object_types[i]);
+      }
 
-    for (i=0; i < num_object_types; i++) {
-      if (G_TYPE_IS_CLASSED (object_types[i]))
-        g_type_class_ref (object_types[i]);
-    }
+    g_type_class_unref (g_object_class);
 
     return object_types;
 }
 
 /*
- * This uses GTK type functions to output signal prototypes and the widget
+ * This uses GObject type functions to output signal prototypes and the object
  * hierarchy.
  */
 
 /* The output files */
-gchar *signals_filename = "$new_signals_filename";
-gchar *hierarchy_filename = "$new_hierarchy_filename";
-gchar *interfaces_filename = "$new_interfaces_filename";
-gchar *prerequisites_filename = "$new_prerequisites_filename";
-gchar *args_filename = "$new_args_filename";
+const gchar *signals_filename = "$new_signals_filename";
+const gchar *hierarchy_filename = "$new_hierarchy_filename";
+const gchar *interfaces_filename = "$new_interfaces_filename";
+const gchar *prerequisites_filename = "$new_prerequisites_filename";
+const gchar *args_filename = "$new_args_filename";
 
 
 static void output_signals (void);
-static void output_widget_signals (FILE *fp,
+static void output_object_signals (FILE *fp,
                                   GType object_type);
-static void output_widget_signal (FILE *fp,
-                                 GType object_type,
+static void output_object_signal (FILE *fp,
                                  const gchar *object_class_name,
                                  guint signal_id);
 static const gchar * get_type_name (GType type,
                                    gboolean * is_pointer);
-static gchar * get_gdk_event (const gchar * signal_name);
-static gchar ** lookup_signal_arg_names (const gchar * type,
-                                        const gchar * signal_name);
-
-static void output_widget_hierarchy (void);
+static void output_object_hierarchy (void);
 static void output_hierarchy (FILE *fp,
                              GType type,
                              guint level);
 
-static void output_widget_interfaces (void);
+static void output_object_interfaces (void);
 static void output_interfaces (FILE *fp,
                               GType type);
 
@@ -242,22 +450,22 @@ static void output_prerequisites (FILE *fp,
                                  GType type);
 
 static void output_args (void);
-static void output_widget_args (FILE *fp, GType object_type);
+static void output_object_args (FILE *fp, GType object_type);
 
 int
 main (int argc, char *argv[])
 {
+  /* Silence the compiler: */
+  if (argv != argv) argc = argc;
+
   $TYPE_INIT_FUNC;
 
   get_object_types ();
 
-  g_debug ("output signals");
   output_signals ();
-  g_debug ("output widget hierarchy");
-  output_widget_hierarchy ();
-  output_widget_interfaces ();
+  output_object_hierarchy ();
+  output_object_interfaces ();
   output_interface_prerequisites ();
-  g_debug ("output args");
   output_args ();
 
   return 0;
@@ -273,12 +481,12 @@ output_signals (void)
   fp = fopen (signals_filename, "w");
   if (fp == NULL)
     {
-      g_warning ("Couldn't open output file: %s", signals_filename);
+      g_warning ("Couldn't open output file: %s : %s", signals_filename, g_strerror(errno));
       return;
     }
 
-  for (i = 0; i < num_object_types; i++)
-    output_widget_signals (fp, object_types[i]);
+  for (i = 0; object_types[i]; i++)
+    output_object_signals (fp, object_types[i]);
 
   fclose (fp);
 }
@@ -292,9 +500,9 @@ compare_signals (const void *a, const void *b)
   return strcmp (g_signal_name (*signal_a), g_signal_name (*signal_b));
 }
 
-/* This outputs all the signals of one widget. */
+/* This outputs all the signals of one object. */
 static void
-output_widget_signals (FILE *fp, GType object_type)
+output_object_signals (FILE *fp, GType object_type)
 {
   const gchar *object_class_name;
   guint *signals, n_signals;
@@ -311,8 +519,7 @@ output_widget_signals (FILE *fp, GType object_type)
 
       for (sig = 0; sig < n_signals; sig++)
         {
-           output_widget_signal (fp, object_type, object_class_name,
-                                signals[sig]);
+           output_object_signal (fp, object_class_name, signals[sig]);
         }
       g_free (signals);
    }
@@ -321,35 +528,28 @@ output_widget_signals (FILE *fp, GType object_type)
 
 /* This outputs one signal. */
 static void
-output_widget_signal (FILE *fp,
-                     GType object_type,
+output_object_signal (FILE *fp,
                      const gchar *object_name,
                      guint signal_id)
 {
   GSignalQuery query_info;
-  const gchar *type_name, *ret_type, *object_arg;
-  gchar *pos, *arg_name, *object_arg_lower;
+  const gchar *type_name, *ret_type, *object_arg, *arg_name;
+  gchar *pos, *object_arg_lower;
   gboolean is_pointer;
-  gchar ret_type_buffer[1024], buffer[1024];
+  gchar buffer[1024];
   guint i, param;
-  gchar **arg_names;
   gint param_num, widget_num, event_num, callback_num;
   gint *arg_num;
   gchar signal_name[128];
+  gchar flags[16];
 
-
-  /*  g_print ("Object: %s Type: %i Signal: %u\\n", object_name, object_type,
-      signal_id);*/
+  $debug_log ("Object: %s Signal: %u", object_name, signal_id);
 
   param_num = 1;
   widget_num = event_num = callback_num = 0;
 
   g_signal_query (signal_id, &query_info);
 
-  /* Output the return type and function name. */
-  ret_type = get_type_name (query_info.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE, &is_pointer);
-  sprintf (ret_type_buffer, "%s%s", ret_type, is_pointer ? "*" : "");
-
   /* Output the signal object type and the argument name. We assume the
      type is a pointer - I think that is OK. We remove "Gtk" or "Gnome" and
      convert to lower case for the argument name. */
@@ -357,6 +557,17 @@ output_widget_signal (FILE *fp,
   sprintf (pos, "%s ", object_name);
   pos += strlen (pos);
 
+  /* Try to come up with a sensible variable name for the first arg
+   * It chops off 2 know prefixes :/ and makes the name lowercase
+   * It should replace lowercase -> uppercase with '_'
+   * GFileMonitor -> file_monitor
+   * GIOExtensionPoint -> extension_point
+   * GtkTreeView -> tree_view
+   * if 2nd char is upper case too
+   *   search for first lower case and go back one char
+   * else
+   *   search for next upper case
+   */
   if (!strncmp (object_name, "Gtk", 3))
       object_arg = object_name + 3;
   else if (!strncmp (object_name, "Gnome", 5))
@@ -372,7 +583,8 @@ output_widget_signal (FILE *fp,
   g_free(object_arg_lower);
 
   /* Convert signal name to use underscores rather than dashes '-'. */
-  strcpy (signal_name, query_info.signal_name);
+  strncpy (signal_name, query_info.signal_name, 127);
+  signal_name[127] = '\\0';
   for (i = 0; signal_name[i]; i++)
     {
       if (signal_name[i] == '-')
@@ -380,69 +592,72 @@ output_widget_signal (FILE *fp,
     }
 
   /* Output the signal parameters. */
-  arg_names = lookup_signal_arg_names (object_name, signal_name);
-
   for (param = 0; param < query_info.n_params; param++)
     {
-      if (arg_names)
-       {
-         sprintf (pos, "%s\\n", arg_names[param]);
-         pos += strlen (pos);
-       }
+      type_name = get_type_name (query_info.param_types[param] & ~G_SIGNAL_TYPE_STATIC_SCOPE, &is_pointer);
+
+      /* Most arguments to the callback are called "arg1", "arg2", etc.
+         GtkWidgets are called "widget", "widget2", ...
+         GtkCallbacks are called "callback", "callback2", ... */
+      if (!strcmp (type_name, "GtkWidget"))
+        {
+          arg_name = "widget";
+          arg_num = &widget_num;
+        }
+      else if (!strcmp (type_name, "GtkCallback")
+               || !strcmp (type_name, "GtkCCallback"))
+        {
+          arg_name = "callback";
+          arg_num = &callback_num;
+        }
       else
-       {
-         type_name = get_type_name (query_info.param_types[param] & ~G_SIGNAL_TYPE_STATIC_SCOPE, &is_pointer);
-
-         /* Most arguments to the callback are called "arg1", "arg2", etc.
-            GdkWidgets are called "widget", "widget2", ...
-            GdkEvents are called "event", "event2", ...
-            GtkCallbacks are called "callback", "callback2", ... */
-         if (!strcmp (type_name, "GtkWidget"))
-           {
-             arg_name = "widget";
-             arg_num = &widget_num;
-           }
-         else if (!strcmp (type_name, "GdkEvent"))
-           {
-             type_name = get_gdk_event (signal_name);
-             arg_name = "event";
-             arg_num = &event_num;
-             is_pointer = TRUE;
-           }
-         else if (!strcmp (type_name, "GtkCallback")
-                  || !strcmp (type_name, "GtkCCallback"))
-           {
-             arg_name = "callback";
-             arg_num = &callback_num;
-           }
-         else
-           {
-             arg_name = "arg";
-             arg_num = &param_num;
-           }
-         sprintf (pos, "%s ", type_name);
-         pos += strlen (pos);
-
-         if (!arg_num || *arg_num == 0)
-           sprintf (pos, "%s%s\\n", is_pointer ? "*" : " ", arg_name);
-         else
-           sprintf (pos, "%s%s%i\\n", is_pointer ? "*" : " ", arg_name,
-                    *arg_num);
-         pos += strlen (pos);
-
-         if (arg_num)
-           {
-             if (*arg_num == 0)
-               *arg_num = 2;
-             else
-               *arg_num += 1;
-           }
-       }
+        {
+          arg_name = "arg";
+          arg_num = &param_num;
+        }
+      sprintf (pos, "%s ", type_name);
+      pos += strlen (pos);
+
+      if (!arg_num || *arg_num == 0)
+        sprintf (pos, "%s%s\\n", is_pointer ? "*" : " ", arg_name);
+      else
+        sprintf (pos, "%s%s%i\\n", is_pointer ? "*" : " ", arg_name,
+                 *arg_num);
+      pos += strlen (pos);
+
+      if (arg_num)
+        {
+          if (*arg_num == 0)
+            *arg_num = 2;
+          else
+            *arg_num += 1;
+        }
     }
 
+  pos = flags;
+  /* We use one-character flags for simplicity. */
+  if (query_info.signal_flags & G_SIGNAL_RUN_FIRST)
+    *pos++ = 'f';
+  if (query_info.signal_flags & G_SIGNAL_RUN_LAST)
+    *pos++ = 'l';
+  if (query_info.signal_flags & G_SIGNAL_RUN_CLEANUP)
+    *pos++ = 'c';
+  if (query_info.signal_flags & G_SIGNAL_NO_RECURSE)
+    *pos++ = 'r';
+  if (query_info.signal_flags & G_SIGNAL_DETAILED)
+    *pos++ = 'd';
+  if (query_info.signal_flags & G_SIGNAL_ACTION)
+    *pos++ = 'a';
+  if (query_info.signal_flags & G_SIGNAL_NO_HOOKS)
+    *pos++ = 'h';
+  *pos = 0;
+
+  /* Output the return type and function name. */
+  ret_type = get_type_name (query_info.return_type & ~G_SIGNAL_TYPE_STATIC_SCOPE, &is_pointer);
+
   fprintf (fp,
-          "<SIGNAL>\\n<NAME>%s::%s</NAME>\\n<RETURNS>%s</RETURNS>\\n%s</SIGNAL>\\n\\n",
-          object_name, query_info.signal_name, ret_type_buffer, buffer);
+          "<SIGNAL>\\n<NAME>%s::%s</NAME>\\n<RETURNS>%s%s</RETURNS>\\n<FLAGS>%s</FLAGS>\\n%s</SIGNAL>\\n\\n",
+          object_name, query_info.signal_name, ret_type, is_pointer ? "*" : "", flags, buffer);
 }
 
 
@@ -493,322 +708,95 @@ get_type_name (GType type, gboolean * is_pointer)
     *is_pointer = TRUE;
     return "GParamSpec";
 
-  default:
+#if GLIB_CHECK_VERSION (2, 25, 9)
+  case G_TYPE_VARIANT:
+    *is_pointer = TRUE;
+    return "GVariant";
+#endif
+
+default:
     break;
   }
 
-  /* For all GtkObject subclasses we can use the class name with a "*",
+  /* For all GObject subclasses we can use the class name with a "*",
      e.g. 'GtkWidget *'. */
   if (g_type_is_a (type, G_TYPE_OBJECT))
     *is_pointer = TRUE;
 
+  /* Also catch non GObject root types */
+  if (G_TYPE_IS_CLASSED (type))
+    *is_pointer = TRUE;
+
   /* All boxed subtypes will be pointers as well. */
-  if (g_type_is_a (type, G_TYPE_BOXED))
+  /* Exception: GStrv */
+  if (g_type_is_a (type, G_TYPE_BOXED) &&
+      !g_type_is_a (type, G_TYPE_STRV))
     *is_pointer = TRUE;
 
   /* All pointer subtypes will be pointers as well. */
   if (g_type_is_a (type, G_TYPE_POINTER))
     *is_pointer = TRUE;
 
-  return type_name;
-}
-
-
-static gchar *
-get_gdk_event (const gchar * signal_name)
-{
-  static gchar *GbGDKEvents[] =
-  {
-    "button_press_event", "GdkEventButton",
-    "button_release_event", "GdkEventButton",
-    "motion_notify_event", "GdkEventMotion",
-    "delete_event", "GdkEvent",
-    "destroy_event", "GdkEvent",
-    "expose_event", "GdkEventExpose",
-    "key_press_event", "GdkEventKey",
-    "key_release_event", "GdkEventKey",
-    "enter_notify_event", "GdkEventCrossing",
-    "leave_notify_event", "GdkEventCrossing",
-    "configure_event", "GdkEventConfigure",
-    "focus_in_event", "GdkEventFocus",
-    "focus_out_event", "GdkEventFocus",
-    "map_event", "GdkEvent",
-    "unmap_event", "GdkEvent",
-    "property_notify_event", "GdkEventProperty",
-    "selection_clear_event", "GdkEventSelection",
-    "selection_request_event", "GdkEventSelection",
-    "selection_notify_event", "GdkEventSelection",
-    "proximity_in_event", "GdkEventProximity",
-    "proximity_out_event", "GdkEventProximity",
-    "drag_begin_event", "GdkEventDragBegin",
-    "drag_request_event", "GdkEventDragRequest",
-    "drag_end_event", "GdkEventDragRequest",
-    "drop_enter_event", "GdkEventDropEnter",
-    "drop_leave_event", "GdkEventDropLeave",
-    "drop_data_available_event", "GdkEventDropDataAvailable",
-    "other_event", "GdkEventOther",
-    "client_event", "GdkEventClient",
-    "no_expose_event", "GdkEventNoExpose",
-    "visibility_notify_event", "GdkEventVisibility",
-    "window_state_event", "GdkEventWindowState",
-    "scroll_event", "GdkEventScroll",
-    NULL
-  };
+  /* But enums are not */
+  if (g_type_is_a (type, G_TYPE_ENUM) ||
+      g_type_is_a (type, G_TYPE_FLAGS))
+    *is_pointer = FALSE;
 
-  gint i;
-
-  for (i = 0; GbGDKEvents[i]; i += 2)
-    {
-      if (!strcmp (signal_name, GbGDKEvents[i]))
-       return GbGDKEvents[i + 1];
-    }
-  return "GdkEvent";
+  return type_name;
 }
 
 
-/* This returns argument names to use for some known GTK signals.
-    It is passed a widget name, e.g. 'GtkCList' and a signal name, e.g.
-    'select_row' and it returns a pointer to an array of argument types and
-    names. */
-static gchar **
-lookup_signal_arg_names (const gchar * type, const gchar * signal_name)
-{
-  /* Each arg array starts with the object type name and the signal name,
-     and then signal arguments follow. */
-  static gchar *GbArgTable[][16] =
-  {
-    {"GtkCList", "select_row",
-     "gint             row",
-     "gint             column",
-     "GdkEventButton  *event"},
-    {"GtkCList", "unselect_row",
-     "gint             row",
-     "gint             column",
-     "GdkEventButton  *event"},
-    {"GtkCList", "click_column",
-     "gint             column"},
-
-    {"GtkCList", "resize_column",
-     "gint             column",
-     "gint             width"},
-
-    {"GtkCList", "extend_selection",
-     "GtkScrollType    scroll_type",
-     "gfloat           position",
-     "gboolean         auto_start_selection"},
-    {"GtkCList", "scroll_vertical",
-     "GtkScrollType    scroll_type",
-     "gfloat           position"},
-    {"GtkCList", "scroll_horizontal",
-     "GtkScrollType    scroll_type",
-     "gfloat           position"},
-
-    {"GtkCTree", "tree_select_row",
-     "GtkCTreeNode    *node",
-     "gint             column"},
-    {"GtkCTree", "tree_unselect_row",
-     "GtkCTreeNode    *node",
-     "gint             column"},
-    {"GtkCTree", "tree_expand",
-     "GtkCTreeNode    *node"},
-    {"GtkCTree", "tree_collapse",
-     "GtkCTreeNode    *node"},
-    {"GtkCTree", "tree_move",
-     "GtkCTreeNode    *node",
-     "GtkCTreeNode    *new_parent",
-     "GtkCTreeNode    *new_sibling"},
-    {"GtkCTree", "change_focus_row_expansion",
-     "GtkCTreeExpansionType expansion"},
-
-    {"GtkEditable", "insert_text",
-     "gchar           *new_text",
-     "gint             new_text_length",
-     "gint            *position"},
-    {"GtkEditable", "delete_text",
-     "gint             start_pos",
-     "gint             end_pos"},
-    {"GtkEditable", "set_editable",
-     "gboolean         is_editable"},
-    {"GtkEditable", "move_cursor",
-     "gint             x",
-     "gint             y"},
-    {"GtkEditable", "move_word",
-     "gint             num_words"},
-    {"GtkEditable", "move_page",
-     "gint             x",
-     "gint             y"},
-    {"GtkEditable", "move_to_row",
-     "gint             row"},
-    {"GtkEditable", "move_to_column",
-     "gint             column"},
-
-    {"GtkEditable", "kill_char",
-     "gint             direction"},
-    {"GtkEditable", "kill_word",
-     "gint             direction"},
-    {"GtkEditable", "kill_line",
-     "gint             direction"},
-
-
-    {"GtkInputDialog", "enable_device",
-     "GdkDevice       *deviceid"},
-    {"GtkInputDialog", "disable_device",
-     "GdkDevice       *deviceid"},
-
-    {"GtkListItem", "extend_selection",
-     "GtkScrollType    scroll_type",
-     "gfloat           position",
-     "gboolean         auto_start_selection"},
-    {"GtkListItem", "scroll_vertical",
-     "GtkScrollType    scroll_type",
-     "gfloat           position"},
-    {"GtkListItem", "scroll_horizontal",
-     "GtkScrollType    scroll_type",
-     "gfloat           position"},
-
-    {"GtkMenuShell", "move_current",
-     "GtkMenuDirectionType direction"},
-    {"GtkMenuShell", "activate_current",
-     "gboolean         force_hide"},
-
-
-    {"GtkNotebook", "switch_page",
-     "GtkNotebookPage *page",
-     "guint            page_num"},
-    {"GtkStatusbar", "text_pushed",
-     "guint            context_id",
-     "gchar           *text"},
-    {"GtkStatusbar", "text_popped",
-     "guint            context_id",
-     "gchar           *text"},
-    {"GtkTipsQuery", "widget_entered",
-     "GtkWidget       *widget",
-     "gchar           *tip_text",
-     "gchar           *tip_private"},
-    {"GtkTipsQuery", "widget_selected",
-     "GtkWidget       *widget",
-     "gchar           *tip_text",
-     "gchar           *tip_private",
-     "GdkEventButton  *event"},
-    {"GtkToolbar", "orientation_changed",
-     "GtkOrientation   orientation"},
-    {"GtkToolbar", "style_changed",
-     "GtkToolbarStyle  style"},
-    {"GtkWidget", "draw",
-     "GdkRectangle    *area"},
-    {"GtkWidget", "size_request",
-     "GtkRequisition  *requisition"},
-    {"GtkWidget", "size_allocate",
-     "GtkAllocation   *allocation"},
-    {"GtkWidget", "state_changed",
-     "GtkStateType     state"},
-    {"GtkWidget", "style_set",
-     "GtkStyle        *previous_style"},
-
-    {"GtkWidget", "install_accelerator",
-     "gchar           *signal_name",
-     "gchar            key",
-     "gint             modifiers"},
-
-    {"GtkWidget", "add_accelerator",
-     "guint            accel_signal_id",
-     "GtkAccelGroup   *accel_group",
-     "guint            accel_key",
-     "GdkModifierType  accel_mods",
-     "GtkAccelFlags    accel_flags"},
-
-    {"GtkWidget", "parent_set",
-     "GtkObject       *old_parent"},
-
-    {"GtkWidget", "remove_accelerator",
-     "GtkAccelGroup   *accel_group",
-     "guint            accel_key",
-     "GdkModifierType  accel_mods"},
-    {"GtkWidget", "debug_msg",
-     "gchar           *message"},
-    {"GtkWindow", "move_resize",
-     "gint            *x",
-     "gint            *y",
-     "gint             width",
-     "gint             height"},
-    {"GtkWindow", "set_focus",
-     "GtkWidget       *widget"},
-
-    {"GtkWidget", "selection_get",
-     "GtkSelectionData *data",
-     "guint            info",
-     "guint            time"},
-    {"GtkWidget", "selection_received",
-     "GtkSelectionData *data",
-     "guint            time"},
-
-    {"GtkWidget", "drag_begin",
-     "GdkDragContext  *drag_context"},
-    {"GtkWidget", "drag_end",
-     "GdkDragContext  *drag_context"},
-    {"GtkWidget", "drag_data_delete",
-     "GdkDragContext  *drag_context"},
-    {"GtkWidget", "drag_leave",
-     "GdkDragContext  *drag_context",
-     "guint            time"},
-    {"GtkWidget", "drag_motion",
-     "GdkDragContext  *drag_context",
-     "gint             x",
-     "gint             y",
-     "guint            time"},
-    {"GtkWidget", "drag_drop",
-     "GdkDragContext  *drag_context",
-     "gint             x",
-     "gint             y",
-     "guint            time"},
-    {"GtkWidget", "drag_data_get",
-     "GdkDragContext  *drag_context",
-     "GtkSelectionData *data",
-     "guint            info",
-     "guint            time"},
-    {"GtkWidget", "drag_data_received",
-     "GdkDragContext  *drag_context",
-     "gint             x",
-     "gint             y",
-     "GtkSelectionData *data",
-     "guint            info",
-     "guint            time"},
-
-    {NULL}
-  };
-
-  gint i;
-
-  for (i = 0; GbArgTable[i][0]; i++)
-    {
-#if 1
-      if (!strcmp (type, GbArgTable[i][0])
-         && !strcmp (signal_name, GbArgTable[i][1]))
-       return &GbArgTable[i][2];
-#endif
-    }
-  return NULL;
-}
-
-/* This outputs the hierarchy of all widgets which have been initialized,
+/* This outputs the hierarchy of all objects which have been initialized,
    i.e. by calling their XXX_get_type() initialization function. */
 static void
-output_widget_hierarchy (void)
+output_object_hierarchy (void)
 {
   FILE *fp;
+  gint i,j;
+  GType root, type;
+  GType root_types[$ntypes] = { G_TYPE_INVALID, };
 
   fp = fopen (hierarchy_filename, "w");
   if (fp == NULL)
     {
-      g_warning ("Couldn't open output file: %s", hierarchy_filename);
+      g_warning ("Couldn't open output file: %s : %s", hierarchy_filename, g_strerror(errno));
       return;
     }
   output_hierarchy (fp, G_TYPE_OBJECT, 0);
   output_hierarchy (fp, G_TYPE_INTERFACE, 0);
+
+  for (i=0; object_types[i]; i++) {
+    root = object_types[i];
+    while ((type = g_type_parent (root))) {
+      root = type;
+    }
+    if ((root != G_TYPE_OBJECT) && (root != G_TYPE_INTERFACE)) {
+      for (j=0; root_types[j]; j++) {
+        if (root == root_types[j]) {
+          root = G_TYPE_INVALID; break;
+        }
+      }
+      if(root) {
+        root_types[j] = root;
+        output_hierarchy (fp, root, 0);
+      }
+    }
+  }
+
   fclose (fp);
 }
 
-/* This is called recursively to output the hierarchy of a widget. */
+static int
+compare_types (const void *a, const void *b)
+{
+  const char *na = g_type_name (*((GType *)a));
+  const char *nb = g_type_name (*((GType *)b));
+
+  return g_strcmp0 (na, nb);
+}
+
+
+/* This is called recursively to output the hierarchy of a object. */
 static void
 output_hierarchy (FILE  *fp,
                  GType  type,
@@ -823,10 +811,11 @@ output_hierarchy (FILE  *fp,
 
   for (i = 0; i < level; i++)
     fprintf (fp, "  ");
-  fprintf (fp, g_type_name (type));
-  fprintf (fp, "\\n");
+  fprintf (fp, "%s\\n", g_type_name (type));
 
   children = g_type_children (type, &n_children);
+  qsort (children, n_children, sizeof (GType), compare_types);
+
 
   for (i=0; i < n_children; i++)
     output_hierarchy (fp, children[i], level + 1);
@@ -834,17 +823,28 @@ output_hierarchy (FILE  *fp,
   g_free (children);
 }
 
-static void output_widget_interfaces (void)
+static void output_object_interfaces (void)
 {
+  guint i;
   FILE *fp;
 
   fp = fopen (interfaces_filename, "w");
   if (fp == NULL)
     {
-      g_warning ("Couldn't open output file: %s", interfaces_filename);
+      g_warning ("Couldn't open output file: %s : %s", interfaces_filename, g_strerror(errno));
       return;
     }
   output_interfaces (fp, G_TYPE_OBJECT);
+
+  for (i = 0; object_types[i]; i++)
+    {
+      if (!g_type_parent (object_types[i]) &&
+          (object_types[i] != G_TYPE_OBJECT) &&
+          G_TYPE_IS_INSTANTIATABLE (object_types[i]))
+        {
+          output_interfaces (fp, object_types[i]);
+        }
+    }
   fclose (fp);
 }
 
@@ -863,7 +863,7 @@ output_interfaces (FILE  *fp,
 
   if (n_interfaces > 0)
     {
-      fprintf (fp, g_type_name (type));
+      fprintf (fp, "%s", g_type_name (type));
       for (i=0; i < n_interfaces; i++)
           fprintf (fp, " %s", g_type_name (interfaces[i]));
       fprintf (fp, "\\n");
@@ -885,7 +885,7 @@ static void output_interface_prerequisites (void)
   fp = fopen (prerequisites_filename, "w");
   if (fp == NULL)
     {
-      g_warning ("Couldn't open output file: %s", prerequisites_filename);
+      g_warning ("Couldn't open output file: %s : %s", prerequisites_filename, g_strerror(errno));
       return;
     }
   output_prerequisites (fp, G_TYPE_INTERFACE);
@@ -908,7 +908,7 @@ output_prerequisites (FILE  *fp,
 
   if (n_prerequisites > 0)
     {
-      fprintf (fp, g_type_name (type));
+      fprintf (fp, "%s", g_type_name (type));
       for (i=0; i < n_prerequisites; i++)
           fprintf (fp, " %s", g_type_name (prerequisites[i]));
       fprintf (fp, "\\n");
@@ -933,12 +933,13 @@ output_args (void)
   fp = fopen (args_filename, "w");
   if (fp == NULL)
     {
-      g_warning ("Couldn't open output file: %s", args_filename);
+      g_warning ("Couldn't open output file: %s : %s", args_filename, g_strerror(errno));
       return;
     }
 
-  for (i = 0; i < num_object_types; i++)
-    output_widget_args (fp, object_types[i]);
+  for (i = 0; object_types[i]; i++) {
+    output_object_args (fp, object_types[i]);
+  }
 
   fclose (fp);
 }
@@ -957,80 +958,120 @@ compare_param_specs (const void *a, const void *b)
  * a bit nicer by spelling out the max constants.
  */
 
+/* Don't use "==" with floats, it might trigger a gcc warning.  */
+#define GTKDOC_COMPARE_FLOAT(x, y) (x <= y && x >= y)
+
 static gchar*
 describe_double_constant (gdouble value)
 {
   gchar *desc;
 
-  if (value == G_MAXDOUBLE)
+  if (GTKDOC_COMPARE_FLOAT (value, G_MAXDOUBLE))
     desc = g_strdup ("G_MAXDOUBLE");
-  else if (value == G_MINDOUBLE)
+  else if (GTKDOC_COMPARE_FLOAT (value, G_MINDOUBLE))
     desc = g_strdup ("G_MINDOUBLE");
-  else if (value == -G_MAXDOUBLE)
+  else if (GTKDOC_COMPARE_FLOAT (value, -G_MAXDOUBLE))
     desc = g_strdup ("-G_MAXDOUBLE");
-  else if (value == G_MAXFLOAT)
+  else if (GTKDOC_COMPARE_FLOAT (value, G_MAXFLOAT))
     desc = g_strdup ("G_MAXFLOAT");
-  else if (value == G_MINFLOAT)
+  else if (GTKDOC_COMPARE_FLOAT (value, G_MINFLOAT))
     desc = g_strdup ("G_MINFLOAT");
-  else if (value == -G_MAXFLOAT)
+  else if (GTKDOC_COMPARE_FLOAT (value, -G_MAXFLOAT))
     desc = g_strdup ("-G_MAXFLOAT");
-  else
-    desc = g_strdup_printf ("%lg", value);
+  else{
+    /* make sure floats are output with a decimal dot irrespective of
+    * current locale. Use formatd since we want human-readable numbers
+    * and do not need the exact same bit representation when deserialising */
+    desc = g_malloc0 (G_ASCII_DTOSTR_BUF_SIZE);
+    g_ascii_formatd (desc, G_ASCII_DTOSTR_BUF_SIZE, "%g", value);
+  }
 
   return desc;
 }
 
 static gchar*
-describe_signed_constant (gint64 value)
+describe_signed_constant (gsize size, gint64 value)
 {
-  gchar *desc;
-
-  if (value == G_MAXINT)
-    desc = g_strdup ("G_MAXINT");
-  else if (value == G_MININT)
-    desc = g_strdup ("G_MININT");
-  else if (value == G_MAXUINT)
-    desc = g_strdup ("G_MAXUINT");
-  else if (value == G_MAXLONG)
-    desc = g_strdup ("G_MAXLONG");
-  else if (value == G_MINLONG)
-    desc = g_strdup ("G_MINLONG");
-  else if (value == G_MAXULONG)
-    desc = g_strdup ("G_MAXULONG");
-  else if (value == G_MAXINT64)
-    desc = g_strdup ("G_MAXINT64");
-  else if (value == G_MININT64)
-    desc = g_strdup ("G_MININT64");
-  else
+  gchar *desc = NULL;
+
+  switch (size) {
+    case 8:
+      if (value == G_MAXINT64)
+        desc = g_strdup ("G_MAXINT64");
+      else if (value == G_MININT64)
+        desc = g_strdup ("G_MININT64");
+      /* fall through */
+    case 4:
+      if (sizeof (int) == 4) {
+        if (value == G_MAXINT)
+          desc = g_strdup ("G_MAXINT");
+        else if (value == G_MININT)
+          desc = g_strdup ("G_MININT");
+        else if (value == (gint64)G_MAXUINT)
+          desc = g_strdup ("G_MAXUINT");
+      }
+      if (value == G_MAXLONG)
+        desc = g_strdup ("G_MAXLONG");
+      else if (value == G_MINLONG)
+        desc = g_strdup ("G_MINLONG");
+      else if (value == (gint64)G_MAXULONG)
+        desc = g_strdup ("G_MAXULONG");
+      /* fall through */
+    case 2:
+      if (sizeof (int) == 2) {
+        if (value == G_MAXINT)
+          desc = g_strdup ("G_MAXINT");
+        else if (value == G_MININT)
+          desc = g_strdup ("G_MININT");
+        else if (value == (gint64)G_MAXUINT)
+          desc = g_strdup ("G_MAXUINT");
+      }
+      break;
+    default:
+      break;
+  }
+  if (!desc)
     desc = g_strdup_printf ("%" G_GINT64_FORMAT, value);
 
   return desc;
 }
 
 static gchar*
-describe_unsigned_constant (guint64 value)
+describe_unsigned_constant (gsize size, guint64 value)
 {
-  gchar *desc;
-
-  if (value == G_MAXINT)
-    desc = g_strdup ("G_MAXINT");
-  else if (value == G_MININT)
-    desc = g_strdup ("G_MININT");
-  else if (value == G_MAXUINT)
-    desc = g_strdup ("G_MAXUINT");
-  else if (value == G_MAXLONG)
-    desc = g_strdup ("G_MAXLONG");
-  else if (value == G_MINLONG)
-    desc = g_strdup ("G_MINLONG");
-  else if (value == G_MAXULONG)
-    desc = g_strdup ("G_MAXULONG");
-  else if (value == G_MAXINT64)
-    desc = g_strdup ("G_MAXINT64");
-  else if (value == G_MININT64)
-    desc = g_strdup ("G_MININT64");
-  else if (value == G_MAXUINT64)
-    desc = g_strdup ("G_MAXUINT64");
-  else
+  gchar *desc = NULL;
+
+  switch (size) {
+    case 8:
+      if (value == G_MAXINT64)
+        desc = g_strdup ("G_MAXINT64");
+      else if (value == G_MAXUINT64)
+        desc = g_strdup ("G_MAXUINT64");
+      /* fall through */
+    case 4:
+      if (sizeof (int) == 4) {
+        if (value == (guint64)G_MAXINT)
+          desc = g_strdup ("G_MAXINT");
+        else if (value == G_MAXUINT)
+          desc = g_strdup ("G_MAXUINT");
+      }
+      if (value == (guint64)G_MAXLONG)
+        desc = g_strdup ("G_MAXLONG");
+      else if (value == G_MAXULONG)
+        desc = g_strdup ("G_MAXULONG");
+      /* fall through */
+    case 2:
+      if (sizeof (int) == 2) {
+        if (value == (guint64)G_MAXINT)
+          desc = g_strdup ("G_MAXINT");
+        else if (value == G_MAXUINT)
+          desc = g_strdup ("G_MAXUINT");
+      }
+      break;
+    default:
+      break;
+  }
+  if (!desc)
     desc = g_strdup_printf ("%" G_GUINT64_FORMAT, value);
 
   return desc;
@@ -1047,8 +1088,8 @@ describe_type (GParamSpec *spec)
     {
       GParamSpecChar *pspec = G_PARAM_SPEC_CHAR (spec);
 
-      lower = describe_signed_constant (pspec->minimum);
-      upper = describe_signed_constant (pspec->maximum);
+      lower = describe_signed_constant (sizeof(gchar), pspec->minimum);
+      upper = describe_signed_constant (sizeof(gchar), pspec->maximum);
       if (pspec->minimum == G_MININT8 && pspec->maximum == G_MAXINT8)
        desc = g_strdup ("");
       else if (pspec->minimum == G_MININT8)
@@ -1064,8 +1105,8 @@ describe_type (GParamSpec *spec)
     {
       GParamSpecUChar *pspec = G_PARAM_SPEC_UCHAR (spec);
 
-      lower = describe_unsigned_constant (pspec->minimum);
-      upper = describe_unsigned_constant (pspec->maximum);
+      lower = describe_unsigned_constant (sizeof(guchar), pspec->minimum);
+      upper = describe_unsigned_constant (sizeof(guchar), pspec->maximum);
       if (pspec->minimum == 0 && pspec->maximum == G_MAXUINT8)
        desc = g_strdup ("");
       else if (pspec->minimum == 0)
@@ -1081,8 +1122,8 @@ describe_type (GParamSpec *spec)
     {
       GParamSpecInt *pspec = G_PARAM_SPEC_INT (spec);
 
-      lower = describe_signed_constant (pspec->minimum);
-      upper = describe_signed_constant (pspec->maximum);
+      lower = describe_signed_constant (sizeof(gint), pspec->minimum);
+      upper = describe_signed_constant (sizeof(gint), pspec->maximum);
       if (pspec->minimum == G_MININT && pspec->maximum == G_MAXINT)
        desc = g_strdup ("");
       else if (pspec->minimum == G_MININT)
@@ -1098,8 +1139,8 @@ describe_type (GParamSpec *spec)
     {
       GParamSpecUInt *pspec = G_PARAM_SPEC_UINT (spec);
 
-      lower = describe_unsigned_constant (pspec->minimum);
-      upper = describe_unsigned_constant (pspec->maximum);
+      lower = describe_unsigned_constant (sizeof(guint), pspec->minimum);
+      upper = describe_unsigned_constant (sizeof(guint), pspec->maximum);
       if (pspec->minimum == 0 && pspec->maximum == G_MAXUINT)
        desc = g_strdup ("");
       else if (pspec->minimum == 0)
@@ -1115,8 +1156,8 @@ describe_type (GParamSpec *spec)
     {
       GParamSpecLong *pspec = G_PARAM_SPEC_LONG (spec);
 
-      lower = describe_signed_constant (pspec->minimum);
-      upper = describe_signed_constant (pspec->maximum);
+      lower = describe_signed_constant (sizeof(glong), pspec->minimum);
+      upper = describe_signed_constant (sizeof(glong), pspec->maximum);
       if (pspec->minimum == G_MINLONG && pspec->maximum == G_MAXLONG)
        desc = g_strdup ("");
       else if (pspec->minimum == G_MINLONG)
@@ -1131,10 +1172,9 @@ describe_type (GParamSpec *spec)
   else if (G_IS_PARAM_SPEC_ULONG (spec))
     {
       GParamSpecULong *pspec = G_PARAM_SPEC_ULONG (spec);
-      gchar *upper;
 
-      lower = describe_unsigned_constant (pspec->minimum);
-      upper = describe_unsigned_constant (pspec->maximum);
+      lower = describe_unsigned_constant (sizeof(gulong), pspec->minimum);
+      upper = describe_unsigned_constant (sizeof(gulong), pspec->maximum);
       if (pspec->minimum == 0 && pspec->maximum == G_MAXULONG)
        desc = g_strdup ("");
       else if (pspec->minimum == 0)
@@ -1150,8 +1190,8 @@ describe_type (GParamSpec *spec)
     {
       GParamSpecInt64 *pspec = G_PARAM_SPEC_INT64 (spec);
 
-      lower = describe_signed_constant (pspec->minimum);
-      upper = describe_signed_constant (pspec->maximum);
+      lower = describe_signed_constant (sizeof(gint64), pspec->minimum);
+      upper = describe_signed_constant (sizeof(gint64), pspec->maximum);
       if (pspec->minimum == G_MININT64 && pspec->maximum == G_MAXINT64)
        desc = g_strdup ("");
       else if (pspec->minimum == G_MININT64)
@@ -1167,8 +1207,8 @@ describe_type (GParamSpec *spec)
     {
       GParamSpecUInt64 *pspec = G_PARAM_SPEC_UINT64 (spec);
 
-      lower = describe_unsigned_constant (pspec->minimum);
-      upper = describe_unsigned_constant (pspec->maximum);
+      lower = describe_unsigned_constant (sizeof(guint64), pspec->minimum);
+      upper = describe_unsigned_constant (sizeof(guint64), pspec->maximum);
       if (pspec->minimum == 0 && pspec->maximum == G_MAXUINT64)
        desc = g_strdup ("");
       else if (pspec->minimum == 0)
@@ -1186,11 +1226,14 @@ describe_type (GParamSpec *spec)
 
       lower = describe_double_constant (pspec->minimum);
       upper = describe_double_constant (pspec->maximum);
-      if (pspec->minimum == -G_MAXFLOAT && pspec->maximum == G_MAXFLOAT)
-       desc = g_strdup ("");
-      else if (pspec->minimum == -G_MAXFLOAT)
-       desc = g_strdup_printf ("<= %s", upper);
-      else if (pspec->maximum == G_MAXFLOAT)
+      if (GTKDOC_COMPARE_FLOAT (pspec->minimum, -G_MAXFLOAT))
+       {
+         if (GTKDOC_COMPARE_FLOAT (pspec->maximum, G_MAXFLOAT))
+           desc = g_strdup ("");
+         else
+           desc = g_strdup_printf ("<= %s", upper);
+       }
+      else if (GTKDOC_COMPARE_FLOAT (pspec->maximum, G_MAXFLOAT))
        desc = g_strdup_printf (">= %s", lower);
       else
        desc = g_strdup_printf ("[%s,%s]", lower, upper);
@@ -1203,17 +1246,40 @@ describe_type (GParamSpec *spec)
 
       lower = describe_double_constant (pspec->minimum);
       upper = describe_double_constant (pspec->maximum);
-      if (pspec->minimum == -G_MAXDOUBLE && pspec->maximum == G_MAXDOUBLE)
-       desc = g_strdup ("");
-      else if (pspec->minimum == -G_MAXDOUBLE)
-       desc = g_strdup_printf ("<= %s", upper);
-      else if (pspec->maximum == G_MAXDOUBLE)
+      if (GTKDOC_COMPARE_FLOAT (pspec->minimum, -G_MAXDOUBLE))
+       {
+         if (GTKDOC_COMPARE_FLOAT (pspec->maximum, G_MAXDOUBLE))
+           desc = g_strdup ("");
+         else
+           desc = g_strdup_printf ("<= %s", upper);
+       }
+      else if (GTKDOC_COMPARE_FLOAT (pspec->maximum, G_MAXDOUBLE))
        desc = g_strdup_printf (">= %s", lower);
       else
        desc = g_strdup_printf ("[%s,%s]", lower, upper);
       g_free (lower);
       g_free (upper);
     }
+#if GLIB_CHECK_VERSION (2, 12, 0)
+  else if (G_IS_PARAM_SPEC_GTYPE (spec))
+    {
+      GParamSpecGType *pspec = G_PARAM_SPEC_GTYPE (spec);
+      gboolean is_pointer;
+
+      desc = g_strdup (get_type_name (pspec->is_a_type, &is_pointer));
+    }
+#endif
+#if GLIB_CHECK_VERSION (2, 25, 9)
+  else if (G_IS_PARAM_SPEC_VARIANT (spec))
+    {
+      GParamSpecVariant *pspec = G_PARAM_SPEC_VARIANT (spec);
+      gchar *variant_type;
+
+      variant_type = g_variant_type_dup_string (pspec->type);
+      desc = g_strdup_printf ("GVariant<%s>", variant_type);
+      g_free (variant_type);
+    }
+#endif
   else
     {
       desc = g_strdup ("");
@@ -1335,13 +1401,23 @@ describe_default (GParamSpec *spec)
     {
       GParamSpecFloat *pspec = G_PARAM_SPEC_FLOAT (spec);
 
-      desc = g_strdup_printf ("%g", pspec->default_value);
+      /* make sure floats are output with a decimal dot irrespective of
+       * current locale. Use formatd since we want human-readable numbers
+       * and do not need the exact same bit representation when deserialising */
+      desc = g_malloc0 (G_ASCII_DTOSTR_BUF_SIZE);
+      g_ascii_formatd (desc, G_ASCII_DTOSTR_BUF_SIZE, "%g",
+          pspec->default_value);
     }
   else if (G_IS_PARAM_SPEC_DOUBLE (spec))
     {
       GParamSpecDouble *pspec = G_PARAM_SPEC_DOUBLE (spec);
 
-      desc = g_strdup_printf ("%lg", pspec->default_value);
+      /* make sure floats are output with a decimal dot irrespective of
+       * current locale. Use formatd since we want human-readable numbers
+       * and do not need the exact same bit representation when deserialising */
+      desc = g_malloc0 (G_ASCII_DTOSTR_BUF_SIZE);
+      g_ascii_formatd (desc, G_ASCII_DTOSTR_BUF_SIZE, "%g",
+          pspec->default_value);
     }
   else if (G_IS_PARAM_SPEC_STRING (spec))
     {
@@ -1368,7 +1444,7 @@ describe_default (GParamSpec *spec)
 
 
 static void
-output_widget_args (FILE *fp, GType object_type)
+output_object_args (FILE *fp, GType object_type)
 {
   gpointer class;
   const gchar *object_class_name;
@@ -1378,10 +1454,12 @@ output_widget_args (FILE *fp, GType object_type)
   guint n_properties;
   gboolean child_prop;
   gboolean style_prop;
+  gboolean is_pointer;
+  const gchar *type_name;
   gchar *type_desc;
   gchar *default_value;
 
-  if (G_TYPE_IS_CLASSED (object_type))
+  if (G_TYPE_IS_OBJECT (object_type))
     {
       class = g_type_class_peek (object_type);
       if (!class)
@@ -1446,8 +1524,9 @@ output_widget_args (FILE *fp, GType object_type)
 
        type_desc = describe_type (spec);
        default_value = describe_default (spec);
-        fprintf (fp, "<ARG>\\n<NAME>%s::%s</NAME>\\n<TYPE>%s</TYPE>\\n<RANGE>%s</RANGE>\\n<FLAGS>%s</FLAGS>\\n<NICK>%s</NICK>\\n<BLURB>%s%s</BLURB>\\n<DEFAULT>%s</DEFAULT>\\n</ARG>\\n\\n",
-                object_class_name, g_param_spec_get_name (spec), g_type_name (spec->value_type), type_desc, flags, nick ? nick : "(null)", blurb ? blurb : "(null)", dot, default_value);
+       type_name = get_type_name (spec->value_type, &is_pointer);
+        fprintf (fp, "<ARG>\\n<NAME>%s::%s</NAME>\\n<TYPE>%s%s</TYPE>\\n<RANGE>%s</RANGE>\\n<FLAGS>%s</FLAGS>\\n<NICK>%s</NICK>\\n<BLURB>%s%s</BLURB>\\n<DEFAULT>%s</DEFAULT>\\n</ARG>\\n\\n",
+                object_class_name, g_param_spec_get_name (spec), type_name, is_pointer ? "*" : "", type_desc, flags, nick ? nick : "(null)", blurb ? blurb : "(null)", dot, default_value);
        g_free (type_desc);
        g_free (default_value);
       }
@@ -1462,6 +1541,14 @@ output_widget_args (FILE *fp, GType object_type)
     }
 #endif
 
+#ifdef GTK_IS_CELL_AREA_CLASS
+    if (!child_prop && GTK_IS_CELL_AREA_CLASS (class)) {
+      properties = gtk_cell_area_class_list_cell_properties (class, &n_properties);
+      child_prop = TRUE;
+      continue;
+    }
+#endif
+
 #ifdef GTK_IS_WIDGET_CLASS
 #if GTK_CHECK_VERSION(2,1,0)
     if (!style_prop && GTK_IS_WIDGET_CLASS (class)) {
@@ -1483,7 +1570,7 @@ close OUTPUT;
 
 $CC = $ENV{CC} ? $ENV{CC} : "gcc";
 $LD = $ENV{LD} ? $ENV{LD} : $CC;
-$CFLAGS = $ENV{CFLAGS} ? $ENV{CFLAGS} : "";
+$CFLAGS = $ENV{CFLAGS} ? "$ENV{CFLAGS}" : "";
 $LDFLAGS = $ENV{LDFLAGS} ? $ENV{LDFLAGS} : "";
 
 my $o_file;
@@ -1493,18 +1580,30 @@ if ($CC =~ /libtool/) {
   $o_file = "$MODULE-scan.o"
 }
 
-$command = "$CC $CFLAGS -c -o $o_file $MODULE-scan.c && $LD -o $MODULE-scan $o_file $LDFLAGS";
+my $stdout="";
+if (!defined($VERBOSE) or $VERBOSE eq "0") {
+    $stdout=">/dev/null";
+}
 
-system($command) == 0 or die "Compilation of scanner failed\n";
+# Compiling scanner
+$command = "$CC $stdout $CFLAGS -c -o $o_file $MODULE-scan.c";
+system("($command)") == 0 or die "Compilation of scanner failed: $!\n";
 
-system("./$MODULE-scan") == 0 or die "Scan failed\n";
+# Linking scanner
+$command = "$LD $stdout -o $MODULE-scan $o_file $LDFLAGS";
+system($command) == 0 or die "Linking of scanner failed: $!\n";
 
-unlink "./$MODULE-scan.c", "./$MODULE-scan.o", "./$MODULE-scan.lo", "./$MODULE-scan";
+# Running scanner $MODULE-scan ";
+system("sh -c ./$MODULE-scan") == 0 or die "Scan failed: $!\n";
 
-&UpdateFileIfChanged ($old_signals_filename, $new_signals_filename, 0);
-&UpdateFileIfChanged ($old_hierarchy_filename, $new_hierarchy_filename, 0);
-&UpdateFileIfChanged ($old_interfaces_filename, $new_interfaces_filename, 0);
-&UpdateFileIfChanged ($old_prerequisites_filename, $new_prerequisites_filename, 0);
-&UpdateFileIfChanged ($old_args_filename, $new_args_filename, 0);
+if (!defined($ENV{"GTK_DOC_KEEP_INTERMEDIATE"})) {
+  unlink "./$MODULE-scan.c", "./$MODULE-scan.o", "./$MODULE-scan.lo", "./$MODULE-scan";
+}
 
+&UpdateFileIfChanged ($old_hierarchy_filename, $new_hierarchy_filename, 0);
+# we will merge these in scangobj-merge.py
+#&UpdateFileIfChanged ($old_interfaces_filename, $new_interfaces_filename, 0);
+#&UpdateFileIfChanged ($old_prerequisites_filename, $new_prerequisites_filename, 0);
+#&UpdateFileIfChanged ($old_signals_filename, $new_signals_filename, 0);
+#&UpdateFileIfChanged ($old_args_filename, $new_args_filename, 0);