+ char *s;
+ gboolean printed_private = FALSE;
+
+ 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"
+ "GTK_CHECK_CAST((obj), %s_get_type(), %s)\n",
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#define %s_CONST(obj)\t"
+ "GTK_CHECK_CAST((obj), %s_get_type(), %s const)\n",
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#define %s_CLASS(klass)\t"
+ "GTK_CHECK_CLASS_CAST((klass), %s_get_type(), %sClass)\n",
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#define %s(obj)\t"
+ "GTK_CHECK_TYPE((obj), %s_get_type ())\n\n",
+ macrois, funcbase);
+ out_printf(outh, "#ifdef GTK_CHECK_GET_CLASS\n"
+ "#define %s_GET_CLASS(obj)\t"
+ "GTK_CHECK_GET_CLASS((obj), %s_get_type(), %sClass)\n",
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#else /* !GTK_CHECK_GET_CLASS */\n"
+ "#define %s_GET_CLASS(obj)\t"
+ "((%sClass *)GTK_OBJECT(obj)->klass)\n"
+ "#endif /* GTK_CHECK_GET_CLASS */\n",
+ macrobase, 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 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);
+ }
+
+ out_printf(out, "/* GTK_CLASS_TYPE for 1.2<->1.3/2.0 GTK+ compatibility */\n");
+ out_printf(out,
+ "#ifndef GTK_CLASS_TYPE\n"
+ "#define GTK_CLASS_TYPE(x) (GTK_OBJECT_CLASS(x)->type)\n"
+ "#endif /* GTK_CLASS_TYPE */\n\n");
+
+ 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, '_');
+ g_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(l=c->nodes; l; l=g_list_next(l)) {
+ static gboolean printed_public = FALSE;
+ Node *n = l->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(l=c->nodes; l; l=g_list_next(l)) {
+ Node *n = l->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)
+ outfp = outph;
+ else
+ outfp = out;
+
+ out_printf(outfp, "struct _%sPrivate {\n",
+ typebase);
+ for(l=c->nodes; l; l=l->next) {
+ Node *n = l->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(l = c->nodes; l != NULL; l = l->next) {
+ Node *n = l->data;
+ if(n->type == METHOD_NODE)
+ put_vs_method((Method *)n);
+ }
+ /* put class scope variables */
+ for(l = c->nodes; l != NULL; l = l->next) {
+ Node *n = l->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_arguments > 0) {
+ out_printf(out, "static void ___object_set_arg "
+ "(GtkObject *object, GtkArg *arg, "
+ "guint arg_id);\n");
+ }
+ if(get_arguments > 0) {
+ out_printf(out, "static void ___object_get_arg "
+ "(GtkObject *object, GtkArg *arg, "
+ "guint arg_id);\n");
+ }
+
+ out_printf(outh, "\n/*\n"
+ " * Public methods\n"
+ " */\n");
+
+ out_printf(outh, "GtkType\t%s_get_type\t(void)", funcbase);
+ if ( ! no_gnu) {
+ out_printf(outh, " G_GNUC_CONST;\n");
+ } else {
+ out_printf(outh, ";\n");
+ }
+
+ for(l = c->nodes; l != NULL; l = l->next) {