X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/6bec711e14babb0d6388754f41834036f22a3ef1..d52e64e92557f0b6d7704077ec175c88fa7ca243:/src/main.c diff --git a/src/main.c b/src/main.c index 734efa4..b4d1b27 100644 --- a/src/main.c +++ b/src/main.c @@ -578,11 +578,13 @@ put_priv_method_prot(const Method *m) m->cbuf)) { /* add unique ID */ char *s = g_strdup_printf("___%x_", (guint)m->unique_id); - out_addline_infile(out, m->line_no); + if (m->line_no > 0) + out_addline_infile(out, m->line_no); print_method(out, "static ", s, "", " ", "", no_gnu?";\n":" G_GNUC_UNUSED;\n", m, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE); - out_addline_outfile(out); + if (m->line_no > 0) + out_addline_outfile(out); g_free(s); } else if(m->scope == PRIVATE_SCOPE || m->method == INIT_METHOD || @@ -590,11 +592,13 @@ put_priv_method_prot(const Method *m) m->method == CONSTRUCTOR_METHOD || m->method == DISPOSE_METHOD || m->method == FINALIZE_METHOD) { - out_addline_infile(out, m->line_no); + if (m->line_no > 0) + out_addline_infile(out, m->line_no); print_method(out, "static ", "", "", " ", "", no_gnu?";\n":" G_GNUC_UNUSED;\n", m, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE); - out_addline_outfile(out); + if (m->line_no > 0) + out_addline_outfile(out); } } @@ -2162,7 +2166,7 @@ print_destructor (Variable *v) if(v->destructor_line > 0) out_addline_outfile(out); - out_printf(out, "\tmemset(&%s, 0, sizeof(%s));\n", + out_printf(out, "\tmemset(&(%s), 0, sizeof(%s));\n", v->id, v->id); out_printf(out, "#undef VAR\n"); out_printf(out, "#undef %s\n", v->id); @@ -2196,6 +2200,22 @@ add_constructor (Class *c) "#undef __GOB_FUNCTION__\n\n"); } +static void +print_unreftors (Class *c) +{ + GList *li; + for(li = ((Class *)class)->nodes; + li != NULL; + li = li->next) { + Node *n = li->data; + Variable *v = (Variable *)n; + if (n->type == VARIABLE_NODE && + v->scope != CLASS_SCOPE && + v->destructor_unref) + print_destructor (v); + } +} + static void add_dispose (Class *c) { @@ -2214,6 +2234,10 @@ add_dispose (Class *c) } if (dispose_handler != NULL) { + if (unreftors > 0) { + print_unreftors (c); + } + /* so we get possible bad argument warning */ if (dispose_handler->line_no > 0) out_addline_infile (out, dispose_handler->line_no); @@ -2230,29 +2254,35 @@ add_dispose (Class *c) out_addline_outfile (out); } + if (unreftors > 0) { + print_unreftors (c); + } + out_printf (out, "\tif (G_OBJECT_CLASS (parent_class)->dispose) \\\n" "\t\t(* G_OBJECT_CLASS (parent_class)->dispose) (obj_self);\n"); } - if (unreftors > 0) { - GList *li; - for(li = ((Class *)class)->nodes; - li != NULL; - li = li->next) { - Node *n = li->data; - Variable *v = (Variable *)n; - if (n->type == VARIABLE_NODE && - v->scope != CLASS_SCOPE && - v->destructor_unref) - print_destructor (v); - } - } - out_printf(out, "}\n" "#undef __GOB_FUNCTION__\n\n"); } +static void +print_destructors (Class *c) +{ + GList *li; + for (li = ((Class *)class)->nodes; + li != NULL; + li = li->next) { + Node *n = li->data; + Variable *v = (Variable *)n; + if (n->type == VARIABLE_NODE && + v->scope != CLASS_SCOPE && + ! v->destructor_unref) + print_destructor (v); + } +} + static void add_finalize (Class *c) { @@ -2282,6 +2312,10 @@ add_finalize (Class *c) } if(finalize_handler) { + if (destructors > 0) { + print_destructors (c); + } + /* so we get possible bad argument warning */ if(finalize_handler->line_no > 0) out_addline_infile(out, finalize_handler->line_no); @@ -2298,25 +2332,15 @@ add_finalize (Class *c) out_addline_outfile (out); } + if (destructors > 0) { + print_destructors (c); + } + out_printf(out, "\tif(G_OBJECT_CLASS(parent_class)->finalize) \\\n" "\t\t(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);\n"); } - if (destructors > 0) { - GList *li; - for (li = ((Class *)class)->nodes; - li != NULL; - li = li->next) { - Node *n = li->data; - Variable *v = (Variable *)n; - if (n->type == VARIABLE_NODE && - v->scope != CLASS_SCOPE && - ! v->destructor_unref) - print_destructor (v); - } - } - out_printf(out, "}\n" "#undef __GOB_FUNCTION__\n\n"); } @@ -3860,9 +3884,9 @@ print_includes(void) p = g_strconcat(filebase, sep, "private.h", NULL); if( ! g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) { - out_printf(out, "#include \"%s%cprivate.h\"\n\n", + out_printf(out, "#include \"%s%sprivate.h\"\n\n", filebase, - file_sep); + sep); if(found_header) error_printf(GOB_WARN, 0, "Implicit private header include "