+ out_printf(out, "\tif(%s->%s) "
+ "((*(void (*)(void *))%s)) (%s->%s);\n",
+ root, v->id, v->destructor, root, v->id);
+
+ if(v->destructor_line > 0)
+ out_addline_outfile(out);
+ } else {
+ out_printf(out, "#define VAR (%s->%s)\n", root, v->id);
+ out_printf(out, "\t{\n\t%s *self G_GNUC_UNUSED = %s;\n",
+ typebase, self_id);
+ if(v->destructor_line > 0)
+ out_addline_infile(out, v->destructor_line);
+
+ out_printf(out, "\t%s}\n", v->destructor);
+
+ if(v->destructor_line > 0)
+ out_addline_outfile(out);
+ out_printf(out, "#undef VAR\n");
+ }
+
+ g_free(root);
+}
+
+/* put in code if it's needed */
+static void
+put_in_gen_code(Method *m)
+{
+ if(m->method == OVERRIDE_METHOD &&
+ strcmp(m->id, "finalize")==0) {
+ if(privates > 0 || destructors > 0) {
+ out_printf(out,"\t%s *___self = %s (%s);\n",
+ typebase, macrobase,
+ ((FuncArg *)m->args->data)->name);
+ }
+ if(destructors > 0) {
+ GList *li;
+ for(li = ((Class *)class)->nodes;
+ li != NULL;
+ li = li->next) {
+ Node *n = li->data;
+ if(n->type == VARIABLE_NODE)
+ print_destructor("___self",
+ (Variable *)n);
+ }
+ }
+ if(privates > 0) {
+ out_printf(out,"\tg_free (___self->_priv);\n"
+ "\t___self->_priv = NULL;\n",
+ macrobase,
+ ((FuncArg *)m->args->data)->name,
+ macrobase,
+ ((FuncArg *)m->args->data)->name);
+ }
+ }
+}
+
+static void
+print_method_body(Method *m, int pre)
+{
+ out_printf(out,"{\n");
+ if(pre)
+ print_preconditions(m);
+
+ put_in_gen_code(m);
+
+ /* Note: the trailing }'s are on one line, this is so
+ that we get the no return warning correctly and point to
+ the correct line in the .gob file, yes this is slightly
+ ugly in the .c file, but that is not supposed to be
+ human readable anyway. */
+ if(m->cbuf) {
+ out_printf(out, "{\n");
+ if(m->ccode_line>0)
+ out_addline_infile(out, m->ccode_line);
+ out_printf(out, "\t%s}", m->cbuf);
+ }
+
+ out_printf(out, "}\n");
+
+ if(m->cbuf)
+ out_addline_outfile(out);
+}
+
+static void
+put_signal_args(Method *m)
+{
+ GList *li;
+ GList *ali;
+ for(ali = m->gtktypes->next,li=m->args->next;
+ li && ali;
+ li=li->next, ali=ali->next) {
+ FuncArg *fa = li->data;
+ const char *cast = get_cast(ali->data,FALSE);
+ /* we should have already proved before that
+ the we know all the types */
+ g_assert(cast);
+
+ out_printf(out,",\n\t\t(%s)%s",cast,
+ fa->name);
+ }
+}
+
+static char *
+get_arg_names_for_macro(Method *m)
+{
+ char *p;
+ GList *li;
+ GString *gs = g_string_new(NULL);
+ p = "";
+ for(li=m->args;li;li=g_list_next(li)) {
+ FuncArg *arg = li->data;
+ g_string_sprintfa(gs, "%s___%s", p, arg->name);
+ p = ",";
+ }
+ p = gs->str;
+ g_string_free(gs, FALSE);
+ return p;
+}