]> git.draconx.ca Git - gob-dx.git/blobdiff - src/main.c
Release 0.0.4
[gob-dx.git] / src / main.c
index be842c647cafe1e18729812dc07fb769b08585e5..e418b4e2814ea101a5a585fbc3a4574163da8d8b 100644 (file)
@@ -49,6 +49,7 @@ static char *ptypebase;
 
 static int signals = 0;
 static int arguments = 0;
+static int overrides = 0;
 
 FILE *out;
 FILE *outh;
@@ -699,12 +700,19 @@ add_inits(Class *c)
                        print_method(out,"static ","\n"," ","",m);
                        if(m->line_no>0)
                                out_addline_outfile(out);
-                       out_printf(out,"{\n"
-                               "\tGtkObjectClass *gtk_object_class = "
-                               "(GtkObjectClass*) %s;\n",
-                               ((FuncArg *)m->args->data)->name);
+                       out_printf(out,"{\n");
+                       if(signals>0 ||
+                          arguments>0 ||
+                          overrides>0)
+                               out_printf(out,
+                                          "\tGtkObjectClass *"
+                                          "gtk_object_class = "
+                                          "(GtkObjectClass*) %s;\n",
+                                          ((FuncArg *)m->args->data)->name);
                        
-                       add_overrides(c, ((FuncArg *)m->args->data)->name);
+                       if(overrides>0)
+                               add_overrides(c,
+                                             ((FuncArg *)m->args->data)->name);
                        
                        out_printf(out,"\n\tparent_class = "
                                "gtk_type_class (%s_get_type ());\n",
@@ -1003,6 +1011,21 @@ count_arguments(Class *c)
        return num;
 }
 
+static int
+count_overrides(Class *c)
+{
+       int num = 0;
+       GList *l;
+       for(l=c->nodes;l;l=g_list_next(l)) {
+               Node *n = l->data;
+               if(n->type == METHOD_NODE) {
+                       Method *m = (Method *)n;
+                       if(m->scope == OVERRIDE_METHOD)
+                               num++;
+               }
+       }
+       return num;
+}
 
 
 static void
@@ -1069,6 +1092,7 @@ generate_outfiles(void)
 
                        signals = count_signals(c);
                        arguments = count_arguments(c);
+                       overrides = count_overrides(c);
                        
                        out_printf(outh,"\n#define %s(obj)\t"
                                "GTK_CHECK_CAST((obj),%s_get_type(),%s)\n",