[gtk-doc] gtkdoc-scangobj: cleanup the scanner code



commit 0918a071fec77127b8f4ad3d48d281e6963924b9
Author: Stefan Sauer <ensonic users sf net>
Date:   Wed Jun 17 10:08:51 2015 +0200

    gtkdoc-scangobj: cleanup the scanner code
    
    Extract some code, so that we need less breaks in the here doc.

 gtkdoc-scangobj.in |   30 +++++++++++-------------------
 1 files changed, 11 insertions(+), 19 deletions(-)
---
diff --git a/gtkdoc-scangobj.in b/gtkdoc-scangobj.in
index 6806f4c..423bd7b 100644
--- a/gtkdoc-scangobj.in
+++ b/gtkdoc-scangobj.in
@@ -125,7 +125,9 @@ my $new_args_filename = "$OUTPUT_DIR/$MODULE.args.new";
 # generate a C program to scan the types
 
 my $includes = "";
-my @types = ();
+my $forward_decls = "";
+my $get_types = "";
+my $ntypes = 1;
 
 for (<TYPES>) {
     if (/^#include/) {
@@ -139,12 +141,12 @@ for (<TYPES>) {
         next;
     } else {
         chomp;
-        push @types, $_;
+        $get_types .= "    object_types[i++] = $_ ();\n";
+        $forward_decls .= "extern GType $_ (void);\n";
+        $ntypes++;
     }
 }
 
-my $ntypes = @types + 1;
-
 print OUTPUT <<EOT;
 #include <string.h>
 #include <stdlib.h>
@@ -157,9 +159,7 @@ EOT
 if ($includes) {
     print OUTPUT $includes;
 } else {
-    for (@types) {
-        print OUTPUT "extern GType $_ (void);\n";
-    }
+    print OUTPUT $forward_decls;
 }
 
 if ($QUERY_CHILD_PROPERTIES) {
@@ -173,21 +173,16 @@ print OUTPUT <<EOT;
 #ifdef GTK_IS_WIDGET_CLASS
 #include <gtk/gtk.h>
 #endif
-GType object_types[$ntypes];
+static GType object_types[$ntypes];
 
 static GType *
 get_object_types (void)
 {
     gpointer g_object_class;
     gint i = 0;
-EOT
-
-for (@types) {
-    print OUTPUT "    object_types[i++] = $_ ();\n";
-}
-
-print OUTPUT <<EOT;
-    object_types[i] = 0;
+    
+${get_types}
+    object_types[i] = G_TYPE_INVALID;
 
     /* reference the GObjectClass to initialize the param spec pool
      * potentially needed by interfaces. See http://bugs.gnome.org/571820 */
@@ -221,7 +216,6 @@ 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_object_signals (FILE *fp,
                                    GType object_type);
@@ -262,7 +256,6 @@ main (int argc, char *argv[])
   return 0;
 }
 
-
 static void
 output_signals (void)
 {
@@ -316,7 +309,6 @@ output_object_signals (FILE *fp, GType object_type)
    }
 }
 
-
 /* This outputs one signal. */
 static void
 output_object_signal (FILE *fp,


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