+ if(arguments<0)
+ return;
+
+ for(li=c->nodes;li;li=g_list_next(li)) {
+ Node *n = li->data;
+ Argument *a = (Argument *)n;
+ char *s;
+ char *cast;
+ if(n->type != ARGUMENT_NODE)
+ continue;
+ s = g_strdup(a->name);
+ g_strup(s);
+ if(a->atype)
+ cast = get_type(a->atype,TRUE);
+ else
+ cast = g_strdup(get_cast(a->gtktype,TRUE));
+
+ if(cast) {
+ if(a->set)
+ out_printf(outh, "#define %s_ARG_%s(arg) \t"
+ "\"%s\",(%s)(arg)\n",
+ macrobase, s, a->name, cast);
+ if(a->get)
+ out_printf(outh, "#define %s_GET_ARG_%s(arg)\t"
+ "\"%s\",(%s*)(arg)\n",
+ macrobase, s, a->name, cast);
+ } else {
+ if(a->set)
+ out_printf(outh, "#define %s_ARG_%s(arg) \t"
+ "\"%s\",(arg)\n",
+ macrobase, s, a->name);
+ if(a->get)
+ out_printf(outh, "#define %s_GET_ARG_%s(arg)\t"
+ "\"%s\",(arg)\n",
+ macrobase, s, a->name);
+ }
+ g_free(cast);
+ g_free(s);
+ }
+}
+
+static void
+put_argument_gnu_wrappers(Class *c)
+{
+ GList *li;
+
+ if(arguments<0)
+ return;
+
+ for(li=c->nodes;li;li=g_list_next(li)) {
+ Node *n = li->data;
+ Argument *a = (Argument *)n;
+ char *s;
+ char *cast;
+ if(n->type != ARGUMENT_NODE)
+ continue;
+ s = g_strdup(a->name);
+ g_strup(s);
+ if(a->atype)
+ cast = get_type(a->atype,TRUE);
+ else
+ cast = g_strdup(get_cast(a->gtktype,TRUE));
+ if(cast) {
+ if(a->set)
+ out_printf(outh, "#define %s_ARG_%s(arg) \t"
+ "\"%s\",({%sz = (arg); z;})\n",
+ macrobase, s, a->name, cast);
+ if(a->get)
+ out_printf(outh, "#define %s_GET_ARG_%s(arg)\t"
+ "\"%s\",({%s*z = (arg); z;})\n",
+ macrobase, s, a->name, cast);
+ } else {
+ if(a->set)
+ out_printf(outh, "#define %s_ARG_%s(arg) \t"
+ "\"%s\",(arg)\n",
+ macrobase, s, a->name);
+ if(a->get)
+ out_printf(outh, "#define %s_GET_ARG_%s(arg)\t"
+ "\"%s\",(arg)\n",
+ macrobase, s, a->name);
+ }
+ g_free(cast);
+ g_free(s);
+ }
+}
+
+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;
+ default:
+ 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 == PH_CCODE)
+ out_addline_outfile(fp);
+}
+
+static void
+print_class_block(Class *c)
+{
+ GList *l;
+ char *s;
+
+ out_printf(out,"/* utility types we may need */\n");
+ out_printf(out,"typedef struct { "
+ "gpointer a; gpointer b; "
+ "} ___twopointertype;\n");
+ out_printf(out,"typedef struct { "
+ "gpointer a; gpointer b; "
+ "gpointer c; "
+ "} ___threepointertype;\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_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);
+
+ if(privates>0) {
+ out_printf(outh, "\n/* Private structure type */\n");
+ out_printf(outh,"typedef struct _%sPrivate %sPrivate;\n",
+ typebase,typebase);
+ }
+
+ 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)) {
+ Node *n = l->data;
+ Variable *v = (Variable *)n;
+ if(n->type == VARIABLE_NODE &&
+ v->scope == PUBLIC_SCOPE)
+ 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)
+ put_variable((Variable *)n,outh);
+ }
+ if(privates>0)
+ 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;l=g_list_next(l)) {
+ Node *n = l->data;
+ if(n->type == METHOD_NODE)
+ put_vs_method((Method *)n);
+ }
+ out_printf(outh,"};\n\n");
+
+ out_printf(out,"/* here are local prototypes */\n");
+ if(arguments>0) {
+ out_printf(out,"static void ___object_set_arg "
+ "(GtkObject *object, GtkArg *arg, "
+ "guint arg_id);\n"
+ "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,"guint\t%s_get_type\t(void);\n",funcbase);
+ for(l=c->nodes;l;l=g_list_next(l)) {
+ Node *n = l->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 0
+ if(!no_signal_connect) {
+ if(signals>0) {
+ out_printf(outh, "\n/*\n"
+ " * Signal connection methods\n"
+ " */\n");
+ }
+
+ for(l=c->nodes;l;l=g_list_next(l)) {
+ Node *n = l->data;
+ if(n->type == METHOD_NODE)
+ put_signal_connect((Method *)n);
+ }
+ }
+#endif
+
+
+ /* argument wrapping macros */
+ if(arguments>0 && !no_gnu) {
+ out_printf(outh, "\n/*\n"
+ " * Argument wrapping macros\n"
+ " */\n");
+ out_printf(outh,"#ifdef __GNUC__\n");
+ put_argument_gnu_wrappers(c);
+ out_printf(outh,"#else /* __GNUC__ */\n");
+ put_argument_nongnu_wrappers(c);
+ out_printf(outh,"#endif /* __GNUC__ */\n\n");
+ } else if(arguments>0 && no_gnu) {
+ out_printf(outh, "\n/*\n"
+ " * Argument wrapping macros\n"
+ " */\n");
+ put_argument_nongnu_wrappers(c);
+ }
+
+ if(signals>0) {
+ for(l=c->nodes;l;l=g_list_next(l)) {
+ Node *n = l->data;
+ if(n->type == METHOD_NODE)
+ add_signal_prots((Method *)n);
+ }
+ }
+
+ add_enums(c);
+
+ add_get_type();
+
+ if(no_gnu)
+ make_method_nongnu_aliases(c);
+ else {
+ out_printf(out,"\n#ifdef __GNUC__\n");
+ make_method_gnu_aliases(c);
+ out_printf(out,"#else /* __GNUC__ */\n");
+ make_method_nongnu_aliases(c);
+ out_printf(out,"#endif /* __GNUC__ */\n\n");
+ }
+
+ out_printf(out,"#define GET_NEW (gtk_type_new(%s_get_type()))\n",
+ funcbase);
+
+ add_inits(c);
+
+ if(arguments>0) {
+ add_getset_arg(c, TRUE);
+ add_getset_arg(c, FALSE);
+ }
+
+ for(l=c->nodes;l;l=g_list_next(l)) {
+ Node *n = l->data;
+ if(n->type == METHOD_NODE) {
+ put_method((Method *)n);
+ }
+ }
+
+ out_printf(out,"#undef GET_NEW\n");
+
+ add_bad_hack_to_avoid_unused_warnings(c);
+}
+
+static void
+print_version_macros(void)
+{
+ int major=0,minor=0,pl=0;
+ 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);
+}
+
+static void
+print_file_comments(void)
+{
+ time_t curtime;