2 * Copyright (C) 1999 the Free Software Foundation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
32 char *filename = "stdin";
41 static char *filebase;
42 static char *funcbase;
43 static char *pfuncbase;
44 static char *macrobase;
46 static char *typebase;
47 static char *ptypebase;
52 int exit_on_warn = FALSE;
55 print_error(int is_warn, char *error,int line)
63 fprintf(stderr,"%s:%d: %s %s\n",filename,line,w,error);
65 fprintf(stderr,"%s: %s %s\n",filename,w,error);
66 if(!is_warn || exit_on_warn)
71 remove_sep(char *base)
74 char *s = g_strdup(base);
75 while((p=strchr(s,':')))
81 replace_sep(char *base, char r)
84 char *s = g_strdup(base);
85 while((p=strchr(s,':')))
95 /*separate the namespace part and then replace rest of
98 separns_replace_sep(char *base, char **ns, char **name, char r)
101 char *s = g_strdup(base);
103 if((p=strchr(s,':')) && p!=s) {
110 while((p=strchr(s,':')))
113 *name = g_strdup(s+1);
120 make_is_macro(char *base)
125 separns_replace_sep(base,&s1,&s2,'_');
127 s = g_strconcat(s1,"_IS_",s2,NULL);
129 s = g_strconcat("IS_",s2,NULL);
142 filebase = replace_sep(((Class *)class)->otype,'-');
145 funcbase = replace_sep(((Class *)class)->otype,'_');
148 pfuncbase = replace_sep(((Class *)class)->ptype,'_');
149 g_strdown(pfuncbase);
151 macrobase = replace_sep(((Class *)class)->otype,'_');
154 macrois = make_is_macro(((Class *)class)->otype);
156 typebase = remove_sep(((Class *)class)->otype);
158 ptypebase = remove_sep(((Class *)class)->ptype);
162 def_methods(Class *c)
167 for(li=c->nodes;li;li=g_list_next(li)) {
168 Node *node = li->data;
169 if(node->type == METHOD_NODE) {
170 Method *m = (Method *)node;
172 if(m->scope == INIT_METHOD ||
173 m->scope == CLASS_INIT_METHOD ||
174 m->scope == OVERRIDE_METHOD)
177 fprintf(out,"#define %s %s_%s\n",m->id,funcbase,m->id);
184 undef_methods(Class *c)
189 for(li=c->nodes;li;li=g_list_next(li)) {
190 Node *node = li->data;
191 if(node->type == METHOD_NODE) {
192 Method *m = (Method *)node;
194 if(m->scope == INIT_METHOD ||
195 m->scope == CLASS_INIT_METHOD ||
196 m->scope == OVERRIDE_METHOD)
199 fprintf(out,"#undef %s\n",m->id);
206 print_type(FILE *fp, Type *t)
210 s = remove_sep(t->name);
214 for(i=0;i<t->stars;i++)
219 put_variable(Variable *v)
222 if(v->scope == PRIVATE_SCOPE)
223 fprintf(outh,"/* private */ ");
224 print_type(outh,v->vtype);
226 fprintf(outh,"%s;\n",v->id);
230 print_method(FILE *fp, char *typeprefix, char *nameprefix,
231 char *namepostfix,char *postfix, Method *m)
235 fprintf(fp,"%s",typeprefix);
236 print_type(fp,m->mtype);
237 fprintf(fp,"%s%s_%s%s(",
238 nameprefix,funcbase,m->id,namepostfix);
240 for(li=m->args;li;li=g_list_next(li)) {
241 FuncArg *arg = li->data;
242 print_type(fp,arg->atype);
244 fprintf(fp,"%s, ",arg->name);
246 fprintf(fp,"%s",arg->name);
249 fprintf(fp,")%s\n",postfix);
253 put_vs_method(Method *m)
255 if(m->scope != SIGNAL_LAST_METHOD &&
256 m->scope != SIGNAL_FIRST_METHOD &&
257 m->scope != VIRTUAL_METHOD)
260 print_method(outh,"\t","(* ",") ",";",m);
264 put_pub_method(Method *m)
266 if(m->scope == PRIVATE_SCOPE ||
267 m->scope == OVERRIDE_METHOD ||
268 m->scope == INIT_METHOD ||
269 m->scope == CLASS_INIT_METHOD)
272 print_method(outh,"","\t","\t",";",m);
276 put_priv_method_prot(Method *m)
278 if(m->scope == PUBLIC_SCOPE)
281 if(m->scope == SIGNAL_LAST_METHOD ||
282 m->scope == SIGNAL_FIRST_METHOD ||
283 m->scope == VIRTUAL_METHOD) {
286 print_method(out,"static ","_real_"," ",";",m);
288 print_method(out,"static ",""," ",";",m);
293 make_init_args(Class *cl, char *name, int is_class)
300 tn = g_strconcat(cl->otype,":Class",NULL);
302 tn = g_strdup(cl->otype);
304 type = new_type(1,tn);
305 node = new_funcarg((Type *)type,name,NULL);
306 return g_list_prepend(NULL, node);
310 make_inits(Class *cl)
312 int got_class_init = FALSE;
313 int got_init = FALSE;
316 for(li=cl->nodes;li;li=g_list_next(li)) {
318 if(n->type == METHOD_NODE) {
319 Method *m = (Method *)n;
320 if(m->scope == INIT_METHOD) {
322 print_error(FALSE,"init defined more then once",m->line_no);
324 } else if(m->scope == CLASS_INIT_METHOD) {
326 print_error(FALSE,"class_init defined more then once",m->line_no);
327 got_class_init = TRUE;
331 if(!got_class_init) {
332 node = new_method(CLASS_INIT_METHOD,
333 (Type *)new_type(0,g_strdup("void")),
334 NULL,NULL,g_strdup("class_init"),
335 make_init_args(cl,g_strdup("c"),TRUE),
337 cl->nodes = g_list_prepend(cl->nodes,node);
340 node = new_method(INIT_METHOD,
341 (Type *)new_type(0,g_strdup("void")),
342 NULL,NULL,g_strdup("init"),
343 make_init_args(cl,g_strdup("o"),FALSE),
345 cl->nodes = g_list_prepend(cl->nodes,node);
349 static GHashTable *marsh = NULL;
352 add_signal_prots(Method *m)
358 if(m->scope != SIGNAL_LAST_METHOD &&
359 m->scope != SIGNAL_FIRST_METHOD)
363 marsh = g_hash_table_new(NULL,NULL);
365 if(strcmp(m->gtktypes->data,"NONE")==0 &&
366 strcmp(m->gtktypes->next->data,"NONE")==0)
369 s = g_strdup_printf("__Sig%d",sig++);
371 g_hash_table_insert(marsh,m,s);
373 fprintf(out,"\ntypedef ");
374 print_type(out,m->mtype);
376 fprintf(out,"(*%s) (",s);
378 for(li=m->args;li;li=g_list_next(li)) {
379 FuncArg *arg = li->data;
380 print_type(out,arg->atype);
383 fprintf(out,"gpointer);\n");
385 fprintf(out,"\nstatic void\n"
386 "marshal_%s (GtkObject * object,\n"
387 "\tGtkSignalFunc func,\n"
388 "\tgpointer func_data,\n"
392 if(strcmp(m->gtktypes->data,"NONE")==0) {
394 fprintf(out, "\t%s rfunc;\n\n"
395 "\trfunc = (%s)func;\n\n"
396 "\t(*rfunc)((%s *)object",s,s,typebase);
397 if(strcmp(m->gtktypes->next->data,"NONE")!=0) {
398 for(i=0,li=m->gtktypes->next;li;
399 i++,li=g_list_next(li)) {
400 fprintf(out, ",\n\t\tGTK_VALUE_%s(args[%d])",
404 fprintf(out, ",\n\t\tfunc_data);\n}\n\n");
407 fprintf(out, "\t%s rfunc;\n\t",s);
408 print_type(out,m->mtype);
409 fprintf(out, " *retval;\n\n"
410 "\trfunc = (%s)func;\n\n"
411 "\tretval = GTK_RETLOC_%s(args[%d]);\n\n"
412 "\t*retval = (*rfunc)((%s *)object",
413 s,(char *)m->gtktypes->data,
414 g_list_length(m->gtktypes)-1,typebase);
415 if(strcmp(m->gtktypes->next->data,"NONE")!=0) {
416 for(i=0,li=m->gtktypes->next;li;
417 i++,li=g_list_next(li)) {
418 fprintf(out, ",\n\t\tGTK_VALUE_%s(args[%d])",
422 fprintf(out, ",\n\t\tfunc_data);\n}\n\n");
431 fprintf(out,"\nenum {\n");
432 for(li=c->nodes;li;li=g_list_next(li)) {
434 if(n->type == METHOD_NODE) {
435 Method *m = (Method *)n;
436 if(m->scope == SIGNAL_LAST_METHOD ||
437 m->scope == SIGNAL_FIRST_METHOD) {
438 char *s = g_strdup(m->id);
440 fprintf(out,"\t%s_SIGNAL,\n",s);
445 fprintf(out,"\tLAST_SIGNAL\n"
449 for(li=c->nodes;li;li=g_list_next(li)) {
451 if(n->type == ARGUMENT_NODE) {
452 Argument *a = (Argument *)n;
453 char *s = g_strdup(a->name);
455 fprintf(out,"\tARG_%s,\n",s);
459 fprintf(out, "};\n\n"
460 "static guint object_signals[LAST_SIGNAL] = {0};\n\n"
461 "static %sClass *parent_class = NULL;\n\n",ptypebase);
467 fprintf(out, "guint\n"
468 "%s_get_type (void)\n"
470 "\tstatic guint type = 0;\n\n"
472 "\t\tstatic const GtkTypeInfo info = {\n"
474 "\t\t\tsizeof (%s),\n"
475 "\t\t\tsizeof (%sClass),\n"
476 "\t\t\t(GtkClassInitFunc) %s_class_init,\n"
477 "\t\t\t(GtkObjectInitFunc) %s_init,\n"
478 "\t\t\t/* reserved_1 */ NULL,\n"
479 "\t\t\t/* reserved_2 */ NULL,\n"
480 "\t\t\t(GtkClassInitFunc) NULL,\n"
482 "\t\ttype = gtk_type_unique (%s_get_type(), &info);\n"
486 funcbase,typebase,typebase,typebase,
487 funcbase,funcbase,pfuncbase);
491 add_overrides(Class *c, char *oname)
497 done = g_hash_table_new(g_str_hash,g_str_equal);
498 s = g_strdup("GtkObject"); /* This was already done */
499 g_hash_table_insert(done,s,s);
500 for(li=c->nodes;li;li=g_list_next(li)) {
504 if(n->type != METHOD_NODE ||
505 ((Method *)n)->scope != OVERRIDE_METHOD)
509 s = remove_sep(m->otype);
511 if(g_hash_table_lookup(done,s)) {
515 g_hash_table_insert(done,s,s);
517 f = replace_sep(m->otype,'_');
520 fprintf(out,"\t%sClass *%s_class = (%sClass *)%s;\n",
525 g_hash_table_foreach(done,(GHFunc)g_free,NULL);
526 g_hash_table_destroy(done);
530 add_signals(Class *c)
535 for(li=c->nodes;li;li=g_list_next(li)) {
541 if(n->type != METHOD_NODE ||
542 (((Method *)n)->scope != SIGNAL_FIRST_METHOD &&
543 ((Method *)n)->scope != SIGNAL_LAST_METHOD))
548 if(g_hash_table_lookup(marsh,m))
549 mar = g_strconcat("marshal_",
550 (char *)g_hash_table_lookup(marsh,m),
553 mar = g_strdup("gtk_signal_default_marshaller");
555 is_none = (strcmp(m->gtktypes->next->data,"NONE")==0);
557 sig = g_strdup(m->id);
559 fprintf(out,"\tobject_signals[%s_SIGNAL] =\n"
560 "\t\tgtk_signal_new (\"%s\",\n"
561 "\t\t\tGTK_RUN_%s,\n"
562 "\t\t\tgtk_object_class->type,\n"
563 "\t\t\tGTK_SIGNAL_OFFSET (%sClass, %s),\n"
565 "\t\t\tGTK_TYPE_%s, %d",
567 m->scope==SIGNAL_LAST_METHOD?"LAST":"FIRST",
568 typebase,m->id,mar,(char *)m->gtktypes->data,
569 is_none?0:g_list_length(m->gtktypes->next));
575 for(l=m->gtktypes->next;l;l=g_list_next(l))
576 fprintf(out,",\n\t\t\tGTK_TYPE_%s",
582 fprintf(out,"\tgtk_object_class_add_signals (gtk_object_class,\n"
583 "\t\tobject_signals, LAST_SIGNAL);\n\n");
587 set_def_handlers(Class *c, char *oname)
592 for(li=c->nodes;li;li=g_list_next(li)) {
595 if(n->type != METHOD_NODE ||
596 (((Method *)n)->scope != SIGNAL_FIRST_METHOD &&
597 ((Method *)n)->scope != SIGNAL_LAST_METHOD &&
598 ((Method *)n)->scope != VIRTUAL_METHOD &&
599 ((Method *)n)->scope != OVERRIDE_METHOD))
604 if(m->scope == OVERRIDE_METHOD) {
606 s = replace_sep(m->otype,'_');
608 fprintf(out,"\t%s_class->%s = %s_%s;\n",
609 s,m->id,funcbase,m->id);
612 fprintf(out,"\t%s->%s = _real_%s_%s;\n",
613 oname,m->id,funcbase,m->id);
615 fprintf(out,"\t%s->%s = NULL;\n",
622 is_arguments(Class *c)
626 for(li=c->nodes;li;li=g_list_next(li)) {
628 if(n->type == ARGUMENT_NODE)
636 make_arguments(Class *c)
641 for(li=c->nodes;li;li=g_list_next(li)) {
647 if(n->type != ARGUMENT_NODE)
653 flags = g_string_new("GTK_ARG_READWRITE");
655 flags = g_string_new("GTK_ARG_READABLE");
657 flags = g_string_new("GTK_ARG_WRITABLE");
659 for(l=a->flags;l;l=g_list_next(l))
660 g_string_sprintfa(flags," | GTK_ARG_%s",(char *)l->data);
662 s = g_strdup(a->name);
664 fprintf(out,"\tgtk_object_add_arg_type(\"%s::%s\",\n"
668 typebase,a->name,a->gtktype,flags->str,s);
670 g_string_free(flags,TRUE);
673 if(is_arguments(c)) {
675 "\n\tgtk_object_class->set_arg = __object_set_arg;\n"
676 "\tgtk_object_class->get_arg = __object_get_arg;\n");
684 for(li=c->nodes;li;li=g_list_next(li)) {
687 if(n->type != METHOD_NODE)
690 if(m->scope == INIT_METHOD) {
691 print_method(out,"static ","\n"," ","",m);
693 fprintf(out,"{\n%s\n}\n\n",m->cbuf->str);
695 fprintf(out,"{\n\treturn;\n}\n\n");
696 } else if(m->scope == CLASS_INIT_METHOD) {
697 print_method(out,"static ","\n"," ","",m);
699 "\tGtkObjectClass *gtk_object_class = "
700 "(GtkObjectClass*) %s;\n",
701 ((FuncArg *)m->args->data)->name);
703 add_overrides(c, ((FuncArg *)m->args->data)->name);
705 fprintf(out,"\n\tparent_class = "
706 "gtk_type_class (%s_get_type ());\n",
711 set_def_handlers(c, ((FuncArg *)m->args->data)->name);
716 fprintf(out," {\n%s\n }\n",m->cbuf->str);
723 add_getset_arg(Class *c, int is_set)
726 fprintf(out,"\nstatic void\n"
727 "__object_%s_arg (GtkObject *object,\n"
732 "\tthis = %s (object);\n\n"
733 "\tswitch (arg_id) {\n",
734 is_set?"set":"get",typebase,macrobase);
736 for(li=c->nodes;li;li=g_list_next(li)) {
740 if(n->type != ARGUMENT_NODE)
743 if((is_set && !a->set) ||
744 (!is_set && !a->get))
746 s = g_strdup(a->name);
748 fprintf(out,"\tcase ARG_%s:\n"
749 "#define ARG (GTK_VALUE_%s(*arg))\n"
750 "\t\t{\n%s\n\t\t}\n\t\tbreak;\n"
752 s,a->gtktype,a->set->str);
755 fprintf(out,"\tdefault:\n\t\tbreak;\n\t}\n}\n");
759 print_checks(Method *m, FuncArg *fa)
763 is_void = (strcmp(m->mtype->name,"void")==0 &&
764 m->mtype->stars == 0);
766 for(li=fa->checks;li;li=g_list_next(li)) {
767 Check *ch = li->data;
770 fprintf(out,"\tg_return_if_fail (");
772 fprintf(out,"\tg_return_val_if_fail (");
775 fprintf(out,"%s != NULL",fa->name);
778 s = make_is_macro(fa->atype->name);
779 fprintf(out,"%s (%s)",s,fa->name);
783 fprintf(out,"%s < %s",fa->name,ch->number);
786 fprintf(out,"%s > %s",fa->name,ch->number);
789 fprintf(out,"%s <= %s",fa->name,ch->number);
792 fprintf(out,"%s >= %s",fa->name,ch->number);
795 fprintf(out,"%s == %s",fa->name,ch->number);
798 fprintf(out,"%s != %s",fa->name,ch->number);
805 print_type(out,m->mtype);
806 fprintf(out,")%s);\n",
807 m->onerror?m->onerror:"0");
813 print_preconditions(Method *m)
817 for(li=m->args;li;li=g_list_next(li)) {
818 FuncArg *fa = li->data;
825 print_method_body(Method *m, int pre)
829 print_preconditions(m);
830 fprintf(out,"\t{\n");
833 fprintf(out,"\t\t%s\n",m->cbuf->str);
836 fprintf(out,"\t}\n");
841 put_method(Method *m)
845 if(strcmp(m->id,"new")==0) {
846 fprintf(out,"#define GET_NEW (gtk_type_new(%s_get_type()))\n",
851 print_method(out,"","\n"," ","",m);
852 print_method_body(m,TRUE);
855 print_method(out,"static ","\n"," ","",m);
856 print_method_body(m,TRUE);
858 case SIGNAL_FIRST_METHOD:
859 case SIGNAL_LAST_METHOD:
860 print_method(out,"","\n"," ","",m);
864 if(strcmp(m->mtype->name,"void")==0 &&
865 m->mtype->stars==0) {
867 print_preconditions(m);
868 fprintf(out,"\tgtk_signal_emit (GTK_OBJECT (this),\n"
869 "\t\tobject_signals[%s_SIGNAL]",s);
870 for(li=m->args->next;li;li=g_list_next(li)) {
871 FuncArg *fa = li->data;
872 fprintf(out,",\n\t\t%s",fa->name);
874 fprintf(out,");\n}\n");
878 print_type(out,m->mtype);
879 fprintf(out,"return_val;\n");
880 print_preconditions(m);
881 fprintf(out,"\tgtk_signal_emit (GTK_OBJECT (this),\n"
882 "\t\tobject_signals[%s_SIGNAL]",s);
883 for(li=m->args->next;li;li=g_list_next(li)) {
884 FuncArg *fa = li->data;
885 fprintf(out,",\n\t\t%s",fa->name);
887 fprintf(out,",\n\t\t&return_val);\n"
888 "\treturn return_val;\n}\n");
893 print_method(out,"static ","\n_real_"," ","",m);
894 print_method_body(m,FALSE);
897 print_method(out,"","\n"," ","",m);
899 "\t%sClass *class;\n",typebase);
900 print_preconditions(m);
901 fprintf(out,"\tclass = %s_CLASS(GTK_OBJECT(this)->klass);\n\n"
904 if(strcmp(m->mtype->name,"void")==0 &&
905 m->mtype->stars==0) {
907 fprintf(out,"\t\t(*class->%s)(this",m->id);
908 for(li=m->args->next;li;li=g_list_next(li)) {
909 FuncArg *fa = li->data;
910 fprintf(out,",%s",fa->name);
912 fprintf(out,");\n}\n");
915 fprintf(out,"\t\treturn (*class->%s)(this",m->id);
916 for(li=m->args->next;li;li=g_list_next(li)) {
917 FuncArg *fa = li->data;
918 fprintf(out,",%s",fa->name);
923 print_type(out,m->mtype);
924 fprintf(out,")(%s);\n}\n",
925 m->onerror?m->onerror:"0");
930 print_method(out,"static ","\n_real_"," ","",m);
931 print_method_body(m,FALSE);
933 case OVERRIDE_METHOD:
934 print_method(out,"static ","\n"," ","",m);
935 print_method_body(m,TRUE);
940 if(strcmp(m->id,"new")==0)
941 fprintf(out,"#undef GET_NEW\n");
947 char *outfile,*outfileh;
949 outfile = g_strconcat(filebase,".c",NULL);
950 outfileh = g_strconcat(filebase,".h",NULL);
952 out = fopen(outfile,"w");
954 g_error("Cannot open outfile: %s",outfile);
956 outh = fopen(outfileh,"w");
958 g_error("Cannot open outfile: %s",outfileh);
963 generate_outfiles(void)
970 fprintf(outh,"/* Generated by GOB (v%s) on %s"
971 " (do not edit directly) */\n\n",VERSION,ctime(&curtime));
972 fprintf(out,"/* Generated by GOB (v%s) on %s"
973 " (do not edit directly) */\n\n",VERSION,ctime(&curtime));
975 p = replace_sep(((Class *)class)->otype,'_');
977 fprintf(outh,"#ifndef __%s_H__\n#define __%s_H__\n\n"
978 "#include <gtk/gtk.h>\n\n",p,p);
981 fprintf(outh,"#ifdef __cplusplus\n"
983 "#endif /* __cplusplus */\n\n");
985 fprintf(out,"#include \"%s.h\"\n\n",filebase);
987 for(li=nodes;li;li=g_list_next(li)) {
988 Node *node = li->data;
989 if(node->type == CCODE_NODE) {
990 CCode *cc = (CCode *)node;
996 fprintf(fp,"\n%s\n",cc->cbuf->str);
997 } else if(node->type == CLASS_NODE) {
999 Class *c = (Class *)class;
1002 fprintf(outh,"\n#define %s(obj)\t"
1003 "GTK_CHECK_CAST((obj),%s_get_type(),%s)\n",
1004 macrobase,funcbase,typebase);
1005 fprintf(outh,"#define %s_CLASS(klass)\t"
1006 "GTK_CHECK_CLASS_CAST((klass),%s_get_type(),%sClass)\n",
1007 macrobase,funcbase,typebase);
1008 fprintf(outh,"#define %s(obj)\t"
1009 "GTK_CHECK_TYPE((obj), %s_get_type ())\n\n",
1012 otype = remove_sep(c->otype);
1013 ptype = remove_sep(c->ptype);
1014 fprintf(outh,"\ntypedef struct _%s %s;\n",otype,otype);
1015 fprintf(outh,"struct _%s {\n\t%s __parent__;\n",
1017 for(l=c->nodes;l;l=g_list_next(l)) {
1019 if(n->type == VARIABLE_NODE)
1020 put_variable((Variable *)n);
1022 fprintf(outh,"};\n");
1024 fprintf(outh,"\ntypedef struct _%sClass %sClass;\n",
1027 "struct _%sClass {\n\t%sClass __parent__;\n",
1029 for(l=c->nodes;l;l=g_list_next(l)) {
1031 if(n->type == METHOD_NODE)
1032 put_vs_method((Method *)n);
1034 fprintf(outh,"};\n\n");
1036 fprintf(outh,"guint\t%s_get_type\t(void);\n",funcbase);
1038 if(is_arguments(c)) {
1039 fprintf(out,"static void __object_set_arg "
1040 "(GtkObject *object, GtkArg *arg, "
1042 "static void __object_get_arg "
1043 "(GtkObject *object, GtkArg *arg, "
1044 "guint arg_id);\n");
1047 for(l=c->nodes;l;l=g_list_next(l)) {
1049 if(n->type == METHOD_NODE) {
1050 put_pub_method((Method *)n);
1051 put_priv_method_prot((Method *)n);
1055 for(l=c->nodes;l;l=g_list_next(l)) {
1057 if(n->type == METHOD_NODE) {
1058 add_signal_prots((Method *)n);
1070 if(is_arguments(c)) {
1071 add_getset_arg(c, TRUE);
1072 add_getset_arg(c, FALSE);
1075 for(l=c->nodes;l;l=g_list_next(l)) {
1077 if(n->type == METHOD_NODE) {
1078 put_method((Method *)n);
1087 g_assert_not_reached();
1090 fprintf(outh,"\n#ifdef __cplusplus\n"
1092 "#endif /* __cplusplus */\n\n"
1097 usage(poptContext optCon, int exitcode, char *error, char *addl)
1099 poptPrintUsage(optCon, stderr, 0);
1100 if (error) fprintf(stderr, "%s: %s", error, addl);
1106 main(int argc, char *argv[])
1111 struct poptOption optionsTable[] = {
1112 { "exit-on-warn", 'w', 0, &exit_on_warn, 0,
1113 "exit on warnings" },
1115 { NULL, 0, 0, NULL, 0 }
1118 optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
1119 poptSetOtherOptionHelp(optCon, "[OPTIONS]* [filename]");
1121 while ((c = poptGetNextOpt(optCon)) >= 0)
1124 filename = poptGetArg(optCon);
1125 if(!(poptPeekArg(optCon) == NULL))
1126 usage(optCon, 1, "Specify only one file",
1127 ".e.g., filename.gob");
1130 /* an error occurred during option processing */
1131 fprintf(stderr, "%s: %s\n",
1132 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
1138 yyin = fopen(filename,"r");
1140 fprintf(stderr,"Error: can't open file '%s'\n",
1149 g_error("Parsing errors, quitting");
1151 print_error(FALSE," no class defined",0);
1155 make_inits((Class *)class);
1159 generate_outfiles();
1164 poptFreeContext(optCon);