+static void
+print_destructor(char *self_id, Variable *v)
+{
+ char *root;
+
+ if(v->destructor == NULL)
+ return;
+
+ if(v->scope == PRIVATE_SCOPE)
+ root = g_strconcat(self_id, "->_priv", NULL);
+ else
+ root = g_strdup(self_id);
+
+ if(v->destructor_simple) {
+ if(v->destructor_line > 0)
+ out_addline_infile(out, v->destructor_line);
+
+ 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);
+}
+