X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/3379dcdfd0872947d761053c61d773add94d38c2..dd11885aadcfaafae2d6268c381b0aac94cbc149:/src/main.c diff --git a/src/main.c b/src/main.c index ab2dd21..09f59c2 100644 --- a/src/main.c +++ b/src/main.c @@ -586,7 +586,7 @@ find_same_type_signal(Method *m) static void print_signal_marsal_args(Method *m) { - if(strcmp(m->gtktypes->next->data,"NONE")!=0) { + if(strcmp(m->gtktypes->next->data, "NONE")!=0) { GList *li; int i; for(i=0,li=m->gtktypes->next;li; @@ -621,8 +621,8 @@ add_signal_prots(Method *m) if(!marsh) marsh = g_hash_table_new(NULL,NULL); - if(strcmp(m->gtktypes->data,"NONE")==0 && - strcmp(m->gtktypes->next->data,"NONE")==0) + if(strcmp(m->gtktypes->data, "NONE")==0 && + strcmp(m->gtktypes->next->data, "NONE")==0) return; /* if we already did a signal prototype just use that */ @@ -635,16 +635,18 @@ add_signal_prots(Method *m) s = g_strdup_printf("Sig%d",sig++); - g_hash_table_insert(marsh,m,s); - eq_signal_methods = g_list_prepend(eq_signal_methods,m); + g_hash_table_insert(marsh, m, s); + eq_signal_methods = g_list_prepend(eq_signal_methods, m); /* we know that we'll know all the gtktypes (so get_cast can't fail) */ - out_printf(out,"\ntypedef %s (*___%s) (%s *, ", + out_printf(out, "\ntypedef %s (*___%s) (%s *, ", get_cast(m->gtktypes->data, FALSE), s, typebase); - for(li=m->gtktypes->next;li;li=g_list_next(li)) - out_printf(out, "%s, ", get_cast(li->data, FALSE)); - out_printf(out,"gpointer);\n"); + if(strcmp(m->gtktypes->next->data, "NONE")!=0) { + for(li=m->gtktypes->next; li; li=g_list_next(li)) + out_printf(out, "%s, ", get_cast(li->data, FALSE)); + } + out_printf(out, "gpointer);\n"); out_printf(out,"\nstatic void\n" "___marshal_%s (GtkObject * object,\n" @@ -653,19 +655,20 @@ add_signal_prots(Method *m) "\tGtkArg * args)\n" "{\n",s); - if(strcmp(m->gtktypes->data,"NONE")==0) { + if(strcmp(m->gtktypes->data, "NONE")==0) { out_printf(out, "\t___%s rfunc;\n\n" "\trfunc = (___%s)func;\n\n" - "\t(*rfunc)((%s *)object",s,s,typebase); + "\t(*rfunc)((%s *)object", s, s, typebase); } else { - out_printf(out, "\t___%s rfunc;\n\t",s); - print_type(out,m->mtype,TRUE); - out_printf(out, " *retval;\n\n" - "\trfunc = (___%s)func;\n\n" - "\tretval = GTK_RETLOC_%s(args[%d]);\n\n" - "\t*retval = (*rfunc)((%s *)object", - s,(char *)m->gtktypes->data, - g_list_length(m->gtktypes)-1,typebase); + const char *retcast = get_cast(m->gtktypes->data, FALSE); + out_printf(out, + "\t___%s rfunc;\n\t" + "%s *retval;\n\n" + "\trfunc = (___%s)func;\n\n" + "\tretval = GTK_RETLOC_%s(args[%d]);\n\n" + "\t*retval = (*rfunc)((%s *)object", + s, retcast, s, (char *)m->gtktypes->data, + g_list_length(m->gtktypes)-1, typebase); } print_signal_marsal_args(m); @@ -1164,19 +1167,28 @@ add_getset_arg(Class *c, gboolean is_set) continue; s = g_strdup(a->name); g_strup(s); + out_printf(out, "\tcase ARG_%s:\n", s); if(is_set && a->atype) { char *cast = get_type(a->atype, TRUE); - out_printf(out, "\tcase ARG_%s:\n", s); if(no_gnu || for_cpp) { out_printf(out, "#define ARG " "((%s)GTK_VALUE_%s(*arg))\n", cast, a->gtktype); } else { out_printf(out, "#ifdef __GNUC__\n"); - out_printf(out, "#define ARG " - "({%s foo = GTK_VALUE_%s(*arg); " - "foo; })\n", - cast, a->gtktype); + if(strcmp(a->gtktype, "OBJECT")==0) { + out_printf(out, "#define ARG " + "({%s foo = " + "GTK_VALUE_POINTER(*arg); " + "foo; })\n", + cast); + } else { + out_printf(out, "#define ARG " + "({%s foo = " + "GTK_VALUE_%s(*arg); " + "foo; })\n", + cast, a->gtktype); + } out_printf(out,"#else /* __GNUC__ */\n"); out_printf(out, "#define ARG " "((%s)GTK_VALUE_%s(*arg))\n", @@ -1185,11 +1197,15 @@ add_getset_arg(Class *c, gboolean is_set) } out_printf(out, "\t\t{\n"); g_free(cast); + } else if(!is_set && strcmp(a->gtktype, "OBJECT")==0) { + out_printf(out, + "#define ARG (GTK_VALUE_POINTER(*arg))\n" + "\t\t{\n"); } else { - out_printf(out, "\tcase ARG_%s:\n" + out_printf(out, "#define ARG (GTK_VALUE_%s(*arg))\n" "\t\t{\n", - s, a->gtktype); + a->gtktype); } g_free(s); if(line_no > 0) @@ -1209,7 +1225,7 @@ print_checks(Method *m, FuncArg *fa) GList *li; gboolean is_void; gboolean checked_null = FALSE; - is_void = (strcmp(m->mtype->name,"void")==0 && + is_void = (strcmp(m->mtype->name, "void")==0 && m->mtype->stars == 0); for(li=fa->checks;li;li=g_list_next(li)) { @@ -1219,22 +1235,22 @@ print_checks(Method *m, FuncArg *fa) if(m->line_no > 0) out_addline_infile(out,m->line_no); if(is_void) - out_printf(out,"\tg_return_if_fail ("); + out_printf(out, "\tg_return_if_fail ("); else - out_printf(out,"\tg_return_val_if_fail ("); + out_printf(out, "\tg_return_val_if_fail ("); switch(ch->chtype) { case NULL_CHECK: - out_printf(out,"%s != NULL",fa->name); + out_printf(out, "%s != NULL", fa->name); checked_null = TRUE; break; case TYPE_CHECK: - s = make_pre_macro(fa->atype->name,"IS"); + s = make_pre_macro(fa->atype->name, "IS"); if(checked_null) - out_printf(out,"%s (%s)",s,fa->name); + out_printf(out, "%s (%s)", s, fa->name); else /* if not check null, null may be valid */ - out_printf(out,"!(%s) || %s (%s)",fa->name,s, - fa->name); + out_printf(out, "!(%s) || %s (%s)", fa->name, + s, fa->name); g_free(s); break; case LT_CHECK: @@ -2103,16 +2119,16 @@ static void print_header_postfixes(void) { if(!no_extern_c) - out_printf(outh,"\n#ifdef __cplusplus\n" + out_printf(outh, "\n#ifdef __cplusplus\n" "}\n" "#endif /* __cplusplus */\n"); - out_printf(outh,"\n#endif"); + out_printf(outh, "\n#endif\n"); if(outph) { if(!no_extern_c) - out_printf(outph,"\n#ifdef __cplusplus\n" + out_printf(outph, "\n#ifdef __cplusplus\n" "}\n" "#endif /* __cplusplus */\n"); - out_printf(outph,"\n#endif"); + out_printf(outph, "\n#endif\n"); } }