/* GOB C Preprocessor
* Copyright (C) 1999,2000 the Free Software Foundation.
* Copyright (C) 2000 Eazel, Inc.
- * Copyright (C) 2001-2009 George (Jiri) Lebl
+ * Copyright (C) 2001-2011 George (Jiri) Lebl
*
* Author: George (Jiri) Lebl
*
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 ||
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);
}
}
if (p->override) {
if (p->flags != NULL)
error_print (GOB_WARN, p->line_no,
- "Overriden property, flags ignored");
+ "Overridden property, flags ignored");
if (p->nick != NULL)
error_print (GOB_WARN, p->line_no,
- "Overriden property, nick ignored");
+ "Overridden property, nick ignored");
if (p->blurb != NULL)
error_print (GOB_WARN, p->line_no,
- "Overriden property, blurb ignored");
+ "Overridden property, blurb ignored");
if (p->minimum != NULL)
error_print (GOB_WARN, p->line_no,
- "Overriden property, minimum ignored");
+ "Overridden property, minimum ignored");
if (p->maximum != NULL)
error_print (GOB_WARN, p->line_no,
- "Overriden property, maximum ignored");
+ "Overridden property, maximum ignored");
if (p->default_value != NULL)
error_print (GOB_WARN, p->line_no,
- "Overriden property, default_value ignored");
+ "Overridden property, default_value ignored");
s = g_strdup (p->name);
gob_strup (s);
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);
"#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)
{
}
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);
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)
{
}
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);
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");
}
out_addline_infile(fp, cc->line_no);
break;
default:
+ case CT_CCODE:
case C_CCODE:
fp = out;
out_printf(fp, "\n");
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 "
{
GList *li;
- /* print the AT_CCODE blocks */
+ /* print the AT_CCODE and CT_CCODE blocks */
for(li = nodes; li != NULL; li = li->next) {
Node *node = li->data;
if(node->type == CCODE_NODE) {
CCode *cc = (CCode *)node;
- if(cc->cctype == AT_CCODE)
+ if (cc->cctype == AT_CCODE ||
+ cc->cctype == CT_CCODE)
print_ccode_block((CCode *)node);
}
}