X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/4c9cb9b99991c36920bd17e366e2128d1b22eb6e..f319f19a8ef9c6d076359ed4bbbc42cdecefc0f0:/src/main.c diff --git a/src/main.c b/src/main.c index be842c6..e418b4e 100644 --- a/src/main.c +++ b/src/main.c @@ -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",