]> git.draconx.ca Git - gob-dx.git/blobdiff - src/main.c
Release 2.0.19
[gob-dx.git] / src / main.c
index 734efa45dd79d81ec8c9b8708a9a9063fa5f61bc..b4d1b270f4332b126da8e0c428cf6aa081742217 100644 (file)
@@ -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 "