+open_files(void)
+{
+ char *outfile, *outfileh, *outfileph;
+
+ outfilebase = g_strconcat (fullfilebase, for_cpp ? ".cc" : ".c", NULL);
+ outfile = g_strconcat(outfilebase, no_touch ? "#gob#" : "", NULL);
+
+ outfilehbase = g_strconcat (fullfilebase, ".h", NULL);
+ outfileh = g_strconcat(outfilehbase, no_touch_headers ? "#gob#" : "", NULL);
+
+ if ((privates > 0 || protecteds > 0 ||
+ private_header == PRIVATE_HEADER_ALWAYS) &&
+ private_header != PRIVATE_HEADER_NEVER) {
+ char sep[2] = {0,0};
+ if (file_sep != 0)
+ sep[0] = file_sep;
+ outfilephbase = g_strconcat (fullfilebase, sep, "private.h", NULL);
+ outfileph = g_strconcat (outfilephbase, no_touch_headers ? "#gob#" : "", NULL);
+ } else {
+ outfilephbase = NULL;
+ outfileph = NULL;
+ }
+
+
+ if ( ! no_write) {
+ out = fopen (outfile, "w");
+ if (out == NULL) {
+ error_printf (GOB_ERROR, 0,
+ "Cannot open outfile: %s", outfile);
+ }
+ outh = fopen (outfileh, "w");
+ if (outh == NULL) {
+ error_printf (GOB_ERROR, 0,
+ "Cannot open outfile: %s", outfileh);
+ }
+ if (outfileph != NULL) {
+ outph = fopen (outfileph, "w");
+ if (outph == NULL) {
+ error_printf (GOB_ERROR, 0,
+ "Cannot open outfile: %s",
+ outfileph);
+ }
+ }
+ }
+}
+
+static void
+put_argument_nongnu_wrappers (Class *c)
+{
+ GList *li;
+
+ if (get_properties < 0 && set_properties < 0)
+ return;
+
+ for (li = c->nodes; li != NULL; li = li->next) {
+ Node *n = li->data;
+ const char *name, *gtktype;
+ gboolean get, set;
+ Type *atype;
+ char *aname;
+ char *cast;
+
+ if (n->type == ARGUMENT_NODE) {
+ Argument *a = (Argument *)n;
+ name = a->name;
+ gtktype = a->gtktype;
+ atype = a->atype;
+ get = a->get != NULL;
+ set = a->set != NULL;
+ } else if (n->type == PROPERTY_NODE) {
+ Property *p = (Property *)n;
+ name = p->name;
+ gtktype = p->gtktype;
+ atype = p->ptype;
+ get = p->get != NULL;
+ set = p->set != NULL;
+ } else {
+ continue;
+ }
+
+ aname = g_strdup (name);
+ gob_strup (aname);
+
+ if (atype != NULL)
+ cast = get_type (atype, TRUE);
+ else
+ cast = g_strdup (get_cast (gtktype, TRUE));
+
+ if (cast != NULL) {
+ if (set)
+ out_printf (outh, "#define %s_PROP_%s(arg) \t"
+ "\"%s\",(%s)(arg)\n",
+ macrobase, aname, name, cast);
+ if (get)
+ out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
+ "\"%s\",(%s*)(arg)\n",
+ macrobase, aname, name, cast);
+ } else {
+ if(set)
+ out_printf (outh, "#define %s_PROP_%s(arg) \t"
+ "\"%s\",(arg)\n",
+ macrobase, aname, name);
+ if(get)
+ out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
+ "\"%s\",(arg)\n",
+ macrobase, aname, name);
+ }
+ g_free (cast);
+ g_free (aname);
+ }
+}
+
+static void
+put_argument_gnu_wrappers(Class *c)
+{
+ GList *li;
+
+ if(get_properties < 0 && set_properties < 0)
+ return;
+
+ for (li = c->nodes; li != NULL; li = li->next) {
+ Node *n = li->data;
+ const char *name, *gtktype;
+ gboolean get, set;
+ Type *atype;
+ char *aname;
+ char *cast;
+
+ if (n->type == ARGUMENT_NODE) {
+ Argument *a = (Argument *)n;
+ name = a->name;
+ gtktype = a->gtktype;
+ atype = a->atype;
+ get = a->get != NULL;
+ set = a->set != NULL;
+ } else if (n->type == PROPERTY_NODE) {
+ Property *p = (Property *)n;
+ name = p->name;
+ gtktype = p->gtktype;
+ atype = p->ptype;
+ get = p->get != NULL;
+ set = p->set != NULL;
+ } else {
+ continue;
+ }
+
+ aname = g_strdup (name);
+ gob_strup (aname);
+
+ if (atype != NULL)
+ cast = get_type (atype, TRUE);
+ else
+ cast = g_strdup (get_cast (gtktype, TRUE));
+
+ if (cast != NULL) {
+ if (set)
+ out_printf (outh, "#define %s_PROP_%s(arg) \t"
+ "\"%s\", __extension__ ({%sz = (arg); z;})\n",
+ macrobase, aname, name, cast);
+ if (get)
+ out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
+ "\"%s\", __extension__ ({%s*z = (arg); z;})\n",
+ macrobase, aname, name, cast);
+ } else {
+ if (set)
+ out_printf (outh, "#define %s_PROP_%s(arg) \t"
+ "\"%s\",(arg)\n",
+ macrobase, aname, name);
+ if (get)
+ out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
+ "\"%s\",(arg)\n",
+ macrobase, aname, name);
+ }
+ g_free (cast);
+ g_free (aname);
+ }
+}
+
+static void
+print_ccode_block(CCode *cc)
+{
+ FILE *fp;
+ switch(cc->cctype) {
+ case HT_CCODE:
+ /* HT code is printed exactly like normal header
+ code but is printed before */
+ case H_CCODE:
+ fp = outh;
+ out_printf(fp, "\n");
+ break;
+ case AT_CCODE:
+ /* AT code is printed exactly like normal 'all'
+ code but is printed before */
+ case A_CCODE:
+ if(outph) {
+ out_printf(outph, "\n");
+ out_printf(outph, "%s\n", cc->cbuf);
+ out_addline_infile(outph, cc->line_no);
+ out_addline_outfile(outph);
+ }
+ out_printf(outh, "\n");
+ out_printf(outh, "%s\n", cc->cbuf);
+ fp = out;
+ out_printf(fp, "\n");
+ out_addline_infile(fp, cc->line_no);
+ break;
+ default:
+ case CT_CCODE:
+ case C_CCODE:
+ fp = out;
+ out_printf(fp, "\n");
+ out_addline_infile(fp, cc->line_no);
+ break;
+ case PH_CCODE:
+ if(outph)
+ fp = outph;
+ else
+ fp = out;
+ out_printf(fp, "\n");
+ out_addline_infile(fp, cc->line_no);
+ break;
+ }
+ out_printf(fp, "%s\n", cc->cbuf);
+ if(cc->cctype == C_CCODE ||
+ cc->cctype == AD_CCODE ||
+ cc->cctype == A_CCODE ||
+ cc->cctype == AT_CCODE ||
+ cc->cctype == PH_CCODE)
+ out_addline_outfile(fp);
+}
+
+static void
+print_class_block(Class *c)
+{
+ GList *li;
+ char *s;
+ gboolean printed_private = FALSE;
+
+ if (c->glade_xml)
+ {
+ out_printf(outph ? outph : outh, "#include <gtk/gtk.h>\n");
+ out_printf(outph ? outph : outh, "#include <glade/glade-xml.h>\n\n");
+ }
+
+ if(any_special) {
+ out_printf(out, "/* utility types we may need */\n");
+ if(special_array[SPECIAL_2POINTER])
+ out_printf(out, "typedef struct { "
+ "gpointer a; gpointer b; "
+ "} ___twopointertype;\n");
+ if(special_array[SPECIAL_3POINTER])
+ out_printf(out, "typedef struct { "
+ "gpointer a; gpointer b; "
+ "gpointer c; "
+ "} ___threepointertype;\n");
+ if(special_array[SPECIAL_INT_POINTER])
+ out_printf(out, "typedef struct { "
+ "gint a; gpointer b; "
+ "} ___intpointertype;\n");
+ out_printf(out, "\n");
+ }
+
+ out_printf(outh, "\n/*\n"
+ " * Type checking and casting macros\n"
+ " */\n");
+ out_printf(outh, "#define %s\t"
+ "(%s_get_type())\n",
+ macrotype, funcbase);
+ out_printf(outh, "#define %s(obj)\t"
+ "G_TYPE_CHECK_INSTANCE_CAST((obj), %s_get_type(), %s)\n",
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#define %s_CONST(obj)\t"
+ "G_TYPE_CHECK_INSTANCE_CAST((obj), %s_get_type(), %s const)\n",
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#define %s_CLASS(klass)\t"
+ "G_TYPE_CHECK_CLASS_CAST((klass), %s_get_type(), %sClass)\n",
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#define %s(obj)\t"
+ "G_TYPE_CHECK_INSTANCE_TYPE((obj), %s_get_type ())\n\n",
+ macrois, funcbase);
+ out_printf(outh,
+ "#define %s_GET_CLASS(obj)\t"
+ "G_TYPE_INSTANCE_GET_CLASS((obj), %s_get_type(), %sClass)\n",
+ macrobase, funcbase, typebase);
+
+ if ( ! no_self_alias) {
+ out_printf(out, "/* self casting macros */\n");
+ out_printf(out, "#define SELF(x) %s(x)\n", macrobase);
+ out_printf(out, "#define SELF_CONST(x) %s_CONST(x)\n", macrobase);
+ out_printf(out, "#define IS_SELF(x) %s(x)\n", macrois);
+ out_printf(out, "#define TYPE_SELF %s\n", macrotype);
+ out_printf(out, "#define SELF_CLASS(x) %s_CLASS(x)\n\n",
+ macrobase);
+ out_printf(out, "#define SELF_GET_CLASS(x) %s_GET_CLASS(x)\n\n",
+ macrobase);
+
+ out_printf(out, "/* self typedefs */\n");
+ out_printf(out, "typedef %s Self;\n", typebase);
+ out_printf(out, "typedef %sClass SelfClass;\n\n", typebase);
+ }
+
+ if (privates > 0 ||
+ always_private_struct) {
+ out_printf (outh, "\n/* Private structure type */\n");
+ out_printf (outh, "typedef struct _%sPrivate %sPrivate;\n",
+ typebase, typebase);
+ if (privates == 0)
+ out_printf (outh, "/* There are no privates, this "
+ "structure is thus never defined */\n");
+ }
+
+ out_printf (outh, "\n/*\n"
+ " * Main object structure\n"
+ " */\n");
+ s = replace_sep (c->otype, '_');
+ gob_strup (s);
+ out_printf (outh, "#ifndef __TYPEDEF_%s__\n"
+ "#define __TYPEDEF_%s__\n", s, s);
+ g_free (s);
+ out_printf (outh, "typedef struct _%s %s;\n"
+ "#endif\n", typebase, typebase);
+ out_printf (outh, "struct _%s {\n\t%s __parent__;\n",
+ typebase, ptypebase);
+ for (li = c->nodes; li; li=li->next) {
+ static gboolean printed_public = FALSE;
+ Node *n = li->data;
+ Variable *v = (Variable *)n;
+ if(n->type == VARIABLE_NODE &&
+ v->scope == PUBLIC_SCOPE) {
+ if( ! printed_public) {
+ out_printf(outh, "\t/*< public >*/\n");
+ printed_public = TRUE;
+ }
+ put_variable((Variable *)n, outh);
+ }
+ }
+ /* put protecteds always AFTER publics */
+ for (li = c->nodes; li != NULL; li = li->next) {
+ Node *n = li->data;
+ Variable *v = (Variable *)n;
+ if (n->type == VARIABLE_NODE &&
+ v->scope == PROTECTED_SCOPE) {
+ if ( ! printed_private) {
+ out_printf (outh, "\t/*< private >*/\n");
+ printed_private = TRUE;
+ }
+ put_variable ((Variable *)n, outh);
+ }
+ }
+ if (privates > 0 ||
+ always_private_struct) {
+ if ( ! printed_private)
+ out_printf (outh, "\t/*< private >*/\n");
+ out_printf (outh, "\t%sPrivate *_priv;\n", typebase);
+ }
+ out_printf (outh, "};\n");
+
+ if (privates > 0) {
+ FILE *outfp;
+
+ /* if we are to stick this into the private
+ header, if not stick it directly into the
+ C file */
+ if (outph != NULL)
+ outfp = outph;
+ else
+ outfp = out;
+
+ out_printf (outfp, "struct _%sPrivate {\n",
+ typebase);
+ if (privates > 0)
+ {
+ for(li=c->nodes; li; li=li->next) {
+ Node *n = li->data;
+ Variable *v = (Variable *)n;
+ if(n->type == VARIABLE_NODE &&
+ v->scope == PRIVATE_SCOPE) {
+ out_addline_infile(outfp, v->line_no);
+ put_variable(v, outfp);
+ }
+ }
+ out_addline_outfile(outfp);
+ }
+ out_printf(outfp, "};\n");
+ }
+
+ out_printf(outh, "\n/*\n"
+ " * Class definition\n"
+ " */\n");
+ out_printf(outh, "typedef struct _%sClass %sClass;\n",
+ typebase, typebase);
+ out_printf(outh,
+ "struct _%sClass {\n\t%sClass __parent__;\n",
+ typebase, ptypebase);
+ for(li = c->nodes; li != NULL; li = li->next) {
+ Node *n = li->data;
+ if(n->type == METHOD_NODE)
+ put_vs_method((Method *)n);
+ }
+ /* If BonoboX type class put down the epv */
+ if (c->bonobo_object_class != NULL) {
+ out_printf (outh,
+ "\t/* Bonobo object epv */\n"
+ "\tPOA_%s__epv _epv;\n",
+ c->bonobo_object_class);
+ }
+ /* put class scope variables */
+ for (li = c->nodes; li != NULL; li = li->next) {
+ Node *n = li->data;
+ Variable *v = (Variable *)n;
+ if (n->type == VARIABLE_NODE &&
+ v->scope == CLASS_SCOPE)
+ put_variable ((Variable *)n, outh);
+ }
+ out_printf (outh, "};\n\n");
+
+ out_printf (out, "/* here are local prototypes */\n");
+ if (set_properties > 0) {
+ out_printf (out, "static void ___object_set_property "
+ "(GObject *object, guint property_id, "
+ "const GValue *value, GParamSpec *pspec);\n");
+ }
+ if (get_properties > 0) {
+ out_printf (out, "static void ___object_get_property "
+ "(GObject *object, guint property_id, "
+ "GValue *value, GParamSpec *pspec);\n");
+ }
+
+ out_printf (outh, "\n/*\n"
+ " * Public methods\n"
+ " */\n");
+
+ if (!overrode_get_type && !no_gnu) {
+ /*
+ * For ordinary "static" types it should be safe to mark the
+ * get_type implementation as const, since the get_type
+ * function return really is constant at the call boundary
+ * (even though there is an initial setup on the first call).
+ * But for dynamic types, since the registration is explicitly
+ * separated, we need to settle for "pure" as the results of
+ * get_type differ before and after type registration.
+ */
+ out_printf(outh, "GType\t%s_get_type\t(void) %s;\n", funcbase,
+ c->dynamic ? "G_GNUC_PURE" : "G_GNUC_CONST");
+ }
+
+ if (c->dynamic) {
+ out_printf(outh, "void\t%s_register_type\t(GTypeModule *);\n",
+ funcbase);
+ }
+
+ for(li = c->nodes; li != NULL; li = li->next) {
+ Node *n = li->data;
+ if(n->type == METHOD_NODE) {
+ put_pub_method((Method *)n);
+ put_prot_method((Method *)n);
+ put_priv_method_prot((Method *)n);
+ }
+ }
+
+ /* this idea is less and less apealing to me */
+ if (signals > 0) {
+ out_printf (outh, "\n/*\n"
+ " * Signal connection wrapper macros\n"
+ " */\n");
+ if( ! no_gnu) {
+ out_printf(outh, "#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
+ put_signal_macros (c, TRUE);
+ out_printf(outh, "#else /* __GNUC__ && !__STRICT_ANSI__ */\n");
+ put_signal_macros (c, FALSE);
+ out_printf(outh, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n");
+ } else {
+ put_signal_macros (c, FALSE);
+ out_printf(outh, "\n");
+ }
+
+ out_printf (out, "\n/*\n"
+ " * Signal connection wrapper macro shortcuts\n"
+ " */\n");
+ put_local_signal_macros (c);
+ out_printf(outh, "\n");
+ }
+
+ /* argument wrapping macros */
+ if(get_properties > 0 || set_properties > 0) {
+ out_printf(outh, "\n/*\n"
+ " * Argument wrapping macros\n"
+ " */\n");
+ if( ! no_gnu) {
+ out_printf(outh, "#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
+ put_argument_gnu_wrappers(c);
+ out_printf(outh, "#else /* __GNUC__ && !__STRICT_ANSI__ */\n");
+ put_argument_nongnu_wrappers(c);
+ out_printf(outh, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n\n");
+ } else {
+ put_argument_nongnu_wrappers(c);
+ }
+ }
+
+ if(signals > 0) {
+ for(li = c->nodes; li != NULL; li = li->next) {
+ Node *n = li->data;
+ if(n->type == METHOD_NODE)
+ add_signal_prots((Method *)n);
+ }
+ }
+
+ add_enums (c);
+
+ if(any_method_to_alias(c)) {
+ out_printf (out, "/* Short form macros */\n");
+ make_method_aliases (c);
+ }
+
+ add_interface_inits (c);
+
+ if (!overrode_get_type) {
+ if (c->bonobo_object_class != NULL)
+ add_bonobo_object_get_type();
+ else if (c->dynamic)
+ add_dynamic_get_type();
+ else
+ add_get_type();
+ }
+
+ out_printf (out, "/* a macro for creating a new object of our type */\n");
+ out_printf (out,
+ "#define GET_NEW ((%s *)g_object_new(%s_get_type(), NULL))\n\n",
+ typebase, funcbase);
+
+ out_printf (out, "/* a function for creating a new object of our type */\n");
+ out_printf (out, "#include <stdarg.h>\n");
+ out_printf (out,
+ "static %s * GET_NEW_VARG (const char *first, ...)%s;\n"
+ "static %s *\nGET_NEW_VARG (const char *first, ...)\n"
+ "{\n\t%s *ret;\n\tva_list ap;\n"
+ "\tva_start (ap, first);\n"
+ "\tret = (%s *)g_object_new_valist (%s_get_type (), "
+ "first, ap);\n"
+ "\tva_end (ap);\n"
+ "\treturn ret;\n}\n\n",
+ typebase,
+ no_gnu ? "" : " G_GNUC_UNUSED",
+ typebase, typebase, typebase, funcbase);
+
+ if (c->glade_xml)
+ {
+ out_printf (out, "/* a function to connect glade callback */\n");
+ out_printf (out,"static void\n"
+ "___glade_xml_connect_foreach(const gchar *handler_name,\n"
+ "GObject *object,\n"
+ "const gchar *signal_name,\n"
+ "const gchar *signal_data,\n"
+ "GObject *connect_object,\n"
+ "gboolean after,\n"
+ "gpointer user_data)\n"
+ "{\n"
+ "\tstatic GModule * allsymbols = NULL;\n"
+ " \n"
+ "\tif (!allsymbols) allsymbols = g_module_open(NULL, 0);\n"
+ "\tif (allsymbols) {\n"
+ "\t\tgchar * func_name = g_strdup_printf(\"%s_%%s\", handler_name);\n"
+ "\t\tGCallback func;\n"
+ "\n"
+ "\t\tif (!g_module_symbol(allsymbols, func_name, (gpointer)&func)){\n"
+ "\t\t\tif (!g_module_symbol(allsymbols, handler_name, (gpointer)&func)) {\n"
+ "\t\t\t\tg_warning(\"could not find signal handler '%%s'.\", func_name);\n"
+ "\t\t\t\tg_free(func_name);\n"
+ "\t\t\t\treturn;\n"
+ "\t\t\t}\n"
+ "\t\t}\n"
+ "\t\tif (after)\n"
+ "\t\t\tg_signal_connect_data(object, signal_name, func, user_data, NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);\n"
+ "\t\telse\n"
+ "\t\t\tg_signal_connect_data(object, signal_name, func, user_data, NULL, G_CONNECT_SWAPPED);\n"
+ "\t\tg_free(func_name);\n"
+ "\t}\n"
+ "}\n"
+ "\n",
+ funcbase);
+ }
+
+ for (li = nodes; li != NULL; li = li->next) {
+ Node *node = li->data;
+ if (node->type == CCODE_NODE) {
+ CCode *cc = (CCode *)node;
+ if (cc->cctype == AD_CCODE)
+ print_ccode_block (cc);
+ }
+ }
+
+ if (need_constructor)
+ add_constructor (c);
+
+ if (need_dispose)
+ add_dispose (c);
+
+ if (need_finalize)
+ add_finalize (c);
+
+ add_inits(c);
+
+ if(set_properties > 0) {
+ add_getset_arg(c, TRUE);
+ }
+
+ if(get_properties > 0) {
+ add_getset_arg(c, FALSE);
+ }
+
+ for(li = c->nodes; li != NULL; li = li->next) {
+ Node *n = li->data;
+ if(n->type == METHOD_NODE)
+ put_method((Method *)n);
+ }
+
+ add_bad_hack_to_avoid_unused_warnings(c);
+}
+
+static void
+print_useful_macros(void)
+{
+ int major = 0, minor = 0, pl = 0;
+
+ /* Version stuff */
+ sscanf (VERSION, "%d.%d.%d", &major, &minor, &pl);
+ out_printf (out, "#define GOB_VERSION_MAJOR %d\n", major);
+ out_printf (out, "#define GOB_VERSION_MINOR %d\n", minor);
+ out_printf (out, "#define GOB_VERSION_PATCHLEVEL %d\n\n", pl);
+
+ /* Useful priv macro thingie */
+ /* FIXME: this should be done the same way that priv is, as a var,
+ * not a define */
+ out_printf (out, "#define selfp (self->_priv)\n\n");
+}
+
+static void
+print_more_useful_macros (void)
+{
+ if (no_gnu) {
+ out_printf (out, "#define ___GOB_LIKELY(expr) (expr)\n");
+ out_printf (out, "#define ___GOB_UNLIKELY(expr) (expr)\n");
+ } else {
+ out_printf (out, "#ifdef G_LIKELY\n");
+ out_printf (out, "#define ___GOB_LIKELY(expr) G_LIKELY(expr)\n");
+ out_printf (out, "#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)\n");
+ out_printf (out, "#else /* ! G_LIKELY */\n");
+ out_printf (out, "#define ___GOB_LIKELY(expr) (expr)\n");
+ out_printf (out, "#define ___GOB_UNLIKELY(expr) (expr)\n");
+ out_printf (out, "#endif /* G_LIKELY */\n");
+ }
+}
+
+static void
+print_file_comments(void)
+{
+ out_printf(outh, "/* Generated by GOB (v%s)"
+ " (do not edit directly) */\n\n", VERSION);
+ if(outph)
+ out_printf(outph, "/* Generated by GOB (v%s)"
+ " (do not edit directly) */\n\n", VERSION);
+ out_printf(out, "/* Generated by GOB (v%s)"
+ " (do not edit directly) */\n\n", VERSION);
+
+ out_printf(out, "/* End world hunger, donate to the World Food Programme, http://www.wfp.org */\n\n");
+}
+
+static void
+print_includes(void)
+{
+ gboolean found_header;
+ char *p;
+
+ /* We may need string.h for memset */
+ if ( ! g_list_find_custom(include_files, "string.h", (GCompareFunc)strcmp)) {
+ out_printf(out, "#include <string.h> /* memset() */\n\n");
+ }
+
+ p = g_strconcat(filebase, ".h", NULL);
+ found_header = TRUE;
+ if( ! g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) {
+ out_printf(out, "#include \"%s.h\"\n\n", filebase);
+ found_header = FALSE;
+ }
+ g_free(p);
+
+ /* if we are creating a private header see if it was included */
+ if(outph) {
+ char sep[2] = {0,0};
+ if (file_sep != 0)
+ sep[0] = file_sep;
+ p = g_strconcat(filebase, sep, "private.h", NULL);
+ if( ! g_list_find_custom(include_files, p,
+ (GCompareFunc)strcmp)) {
+ out_printf(out, "#include \"%s%sprivate.h\"\n\n",
+ filebase,
+ sep);
+ if(found_header)
+ error_printf(GOB_WARN, 0,
+ "Implicit private header include "
+ "added to top of\n"
+ "\tsource file, while public "
+ "header is at a custom location, "
+ "you should\n"
+ "\texplicitly include "
+ "the private header below the "
+ "public one.");
+ }
+ g_free(p);
+ }
+}
+
+static void
+print_header_prefixes(void)
+{
+ char *p;
+
+ p = replace_sep(((Class *)class)->otype, '_');
+ gob_strup (p);
+ out_printf(outh, "#ifndef __%s_H__\n#define __%s_H__\n\n", p, p);
+ if(outph)
+ out_printf(outph, "#ifndef __%s_PRIVATE_H__\n"
+ "#define __%s_PRIVATE_H__\n\n"
+ "#include \"%s.h\"\n\n", p, p, filebase);
+ g_free(p);
+
+ if( ! no_extern_c) {
+ out_printf(outh, "#ifdef __cplusplus\n"
+ "extern \"C\" {\n"
+ "#endif /* __cplusplus */\n\n");
+ if(outph)
+ out_printf(outph, "#ifdef __cplusplus\n"
+ "extern \"C\" {\n"
+ "#endif /* __cplusplus */\n\n");
+ }
+}
+
+static void
+print_header_postfixes(void)
+{
+ if( ! no_extern_c)
+ out_printf(outh, "\n#ifdef __cplusplus\n"
+ "}\n"
+ "#endif /* __cplusplus */\n");
+ out_printf(outh, "\n#endif\n");
+ if(outph) {
+ if( ! no_extern_c)
+ out_printf(outph, "\n#ifdef __cplusplus\n"
+ "}\n"
+ "#endif /* __cplusplus */\n");
+ out_printf(outph, "\n#endif\n");
+ }
+}
+
+static void
+print_all_top(void)
+{
+ GList *li;
+
+ /* 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 ||
+ cc->cctype == CT_CCODE)
+ print_ccode_block((CCode *)node);
+ }
+ }
+}
+
+static void
+print_header_top(void)