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 #define VERSION "0.0.1"
35 char *filename = "stdin";
44 static char *filebase;
45 static char *funcbase;
46 static char *pfuncbase;
47 static char *macrobase;
49 static char *typebase;
50 static char *ptypebase;
55 int exit_on_warn = FALSE;
58 print_error(int is_warn, char *error,int line)
66 fprintf(stderr,"%s:%d: %s %s\n",filename,line,w,error);
68 fprintf(stderr,"%s: %s %s\n",filename,w,error);
69 if(!is_warn || exit_on_warn)
74 remove_sep(char *base)
77 char *s = g_strdup(base);
78 while((p=strchr(s,':')))
84 replace_sep(char *base, char r)
87 char *s = g_strdup(base);
88 while((p=strchr(s,':')))
98 /*separate the namespace part and then replace rest of
101 separns_replace_sep(char *base, char **ns, char **name, char r)
104 char *s = g_strdup(base);
106 if((p=strchr(s,':')) && p!=s) {
113 while((p=strchr(s,':')))
116 *name = g_strdup(s+1);
123 make_is_macro(char *base)
128 separns_replace_sep(base,&s1,&s2,'_');
130 s = g_strconcat(s1,"_IS_",s2,NULL);
132 s = g_strconcat("IS_",s2,NULL);
145 filebase = replace_sep(((Class *)class)->otype,'-');
148 funcbase = replace_sep(((Class *)class)->otype,'_');
151 pfuncbase = replace_sep(((Class *)class)->ptype,'_');
152 g_strdown(pfuncbase);
154 macrobase = replace_sep(((Class *)class)->otype,'_');
157 macrois = make_is_macro(((Class *)class)->otype);
159 typebase = remove_sep(((Class *)class)->otype);
161 ptypebase = remove_sep(((Class *)class)->ptype);
165 def_methods(Class *c)
170 for(li=c->nodes;li;li=g_list_next(li)) {
171 Node *node = li->data;
172 if(node->type == METHOD_NODE) {
173 Method *m = (Method *)node;
175 if(m->scope == INIT_METHOD ||
176 m->scope == CLASS_INIT_METHOD ||
177 m->scope == OVERRIDE_METHOD)
180 fprintf(out,"#define %s %s_%s\n",m->id,funcbase,m->id);
187 undef_methods(Class *c)
192 for(li=c->nodes;li;li=g_list_next(li)) {
193 Node *node = li->data;
194 if(node->type == METHOD_NODE) {
195 Method *m = (Method *)node;
197 if(m->scope == INIT_METHOD ||
198 m->scope == CLASS_INIT_METHOD ||
199 m->scope == OVERRIDE_METHOD)
202 fprintf(out,"#undef %s\n",m->id);
209 print_type(FILE *fp, Type *t)
213 s = remove_sep(t->name);
217 for(i=0;i<t->stars;i++)
222 put_variable(Variable *v)
225 if(v->scope == PRIVATE_SCOPE)
226 fprintf(outh,"/* private */ ");
227 print_type(outh,v->vtype);
229 fprintf(outh,"%s;\n",v->id);
233 print_method(FILE *fp, char *typeprefix, char *nameprefix,
234 char *namepostfix,char *postfix, Method *m)
238 fprintf(fp,"%s",typeprefix);
239 print_type(fp,m->mtype);
240 fprintf(fp,"%s%s_%s%s(",
241 nameprefix,funcbase,m->id,namepostfix);
243 for(li=m->args;li;li=g_list_next(li)) {
244 FuncArg *arg = li->data;
245 print_type(fp,arg->atype);
247 fprintf(fp,"%s, ",arg->name);
249 fprintf(fp,"%s",arg->name);
252 fprintf(fp,")%s\n",postfix);
256 put_vs_method(Method *m)
258 if(m->scope != SIGNAL_LAST_METHOD &&
259 m->scope != SIGNAL_FIRST_METHOD &&
260 m->scope != VIRTUAL_METHOD)
263 print_method(outh,"\t","(* ",") ",";",m);
267 put_pub_method(Method *m)
269 if(m->scope == PRIVATE_SCOPE ||
270 m->scope == OVERRIDE_METHOD ||
271 m->scope == INIT_METHOD ||
272 m->scope == CLASS_INIT_METHOD)
275 print_method(outh,"\t","","\t",";",m);
279 put_priv_method_prot(Method *m)
281 if(m->scope == PUBLIC_SCOPE)
284 if(m->scope == SIGNAL_LAST_METHOD ||
285 m->scope == SIGNAL_FIRST_METHOD ||
286 m->scope == VIRTUAL_METHOD) {
289 print_method(out,"static ","_real_"," ",";",m);
291 print_method(out,"static ",""," ",";",m);
296 make_init_args(Class *cl, char *name, int is_class)
303 tn = g_strconcat(cl->otype,":Class",NULL);
305 tn = g_strdup(cl->otype);
307 type = new_type(1,tn);
308 node = new_funcarg((Type *)type,name,NULL);
309 return g_list_prepend(NULL, node);
313 make_inits(Class *cl)
315 int got_class_init = FALSE;
316 int got_init = FALSE;
319 for(li=cl->nodes;li;li=g_list_next(li)) {
321 if(n->type == METHOD_NODE) {
322 Method *m = (Method *)n;
323 if(m->scope == INIT_METHOD) {
325 print_error(FALSE,"init defined more then once",m->line_no);
327 } else if(m->scope == CLASS_INIT_METHOD) {
329 print_error(FALSE,"class_init defined more then once",m->line_no);
330 got_class_init = TRUE;
334 if(!got_class_init) {
335 node = new_method(CLASS_INIT_METHOD,
336 (Type *)new_type(0,g_strdup("void")),
337 NULL,NULL,g_strdup("class_init"),
338 make_init_args(cl,g_strdup("c"),TRUE),
340 cl->nodes = g_list_prepend(cl->nodes,node);
343 node = new_method(INIT_METHOD,
344 (Type *)new_type(0,g_strdup("void")),
345 NULL,NULL,g_strdup("init"),
346 make_init_args(cl,g_strdup("o"),FALSE),
348 cl->nodes = g_list_prepend(cl->nodes,node);
352 static GHashTable *marsh = NULL;
355 add_signal_prots(Method *m)
361 if(m->scope != SIGNAL_LAST_METHOD &&
362 m->scope != SIGNAL_FIRST_METHOD)
366 marsh = g_hash_table_new(NULL,NULL);
368 if(strcmp(m->gtktypes->data,"NONE")==0 &&
369 strcmp(m->gtktypes->next->data,"NONE")==0)
372 s = g_strdup_printf("__Sig%d",sig++);
374 g_hash_table_insert(marsh,m,s);
376 fprintf(out,"\ntypedef ");
377 print_type(out,m->mtype);
379 fprintf(out,"(*%s) (",s);
381 for(li=m->args;li;li=g_list_next(li)) {
382 FuncArg *arg = li->data;
383 print_type(out,arg->atype);
386 fprintf(out,"gpointer);\n");
388 fprintf(out,"\nstatic void\n"
389 "marshal_%s (GtkObject * object,\n"
390 "\tGtkSignalFunc func,\n"
391 "\tgpointer func_data,\n"
395 if(strcmp(m->gtktypes->data,"NONE")==0) {
397 fprintf(out, "\t%s rfunc;\n\n"
398 "\trfunc = (%s)func;\n\n"
399 "\t(*rfunc)((%s *)object",s,s,typebase);
400 if(strcmp(m->gtktypes->next->data,"NONE")!=0) {
401 for(i=0,li=m->gtktypes->next;li;
402 i++,li=g_list_next(li)) {
403 fprintf(out, ",\n\t\tGTK_VALUE_%s(args[%d])",
407 fprintf(out, ",\n\t\tfunc_data);\n}\n\n");
410 fprintf(out, "\t%s rfunc;\n\t",s);
411 print_type(out,m->mtype);
412 fprintf(out, " *retval;\n\n"
413 "\trfunc = (%s)func;\n\n"
414 "\tretval = GTK_RETLOC_%s(args[%d]);\n\n"
415 "\t*retval = (*rfunc)((%s *)object",
416 s,(char *)m->gtktypes->data,
417 g_list_length(m->gtktypes)-1,typebase);
418 if(strcmp(m->gtktypes->next->data,"NONE")!=0) {
419 for(i=0,li=m->gtktypes->next;li;
420 i++,li=g_list_next(li)) {
421 fprintf(out, ",\n\t\tGTK_VALUE_%s(args[%d])",
425 fprintf(out, ",\n\t\tfunc_data);\n}\n\n");
434 fprintf(out,"\nenum {\n");
435 for(li=c->nodes;li;li=g_list_next(li)) {
437 if(n->type == METHOD_NODE) {
438 Method *m = (Method *)n;
439 if(m->scope == SIGNAL_LAST_METHOD ||
440 m->scope == SIGNAL_FIRST_METHOD) {
441 char *s = g_strdup(m->id);
443 fprintf(out,"\t%s_SIGNAL,\n",s);
448 fprintf(out,"\tLAST_SIGNAL\n"
452 for(li=c->nodes;li;li=g_list_next(li)) {
454 if(n->type == ARGUMENT_NODE) {
455 Argument *a = (Argument *)n;
456 char *s = g_strdup(a->name);
458 fprintf(out,"\tARG_%s,\n",s);
462 fprintf(out, "};\n\n"
463 "static guint object_signals[LAST_SIGNAL] = {0};\n\n"
464 "static %sClass *parent_class = NULL;\n\n",ptypebase);
470 fprintf(out, "guint\n"
471 "%s_get_type (void)\n"
473 "\tstatic guint type = 0;\n\n"
475 "\t\tstatic const GtkTypeInfo info = {\n"
477 "\t\t\tsizeof (%s),\n"
478 "\t\t\tsizeof (%sClass),\n"
479 "\t\t\t(GtkClassInitFunc) %s_class_init,\n"
480 "\t\t\t(GtkObjectInitFunc) %s_init,\n"
481 "\t\t\t/* reserved_1 */ NULL,\n"
482 "\t\t\t/* reserved_2 */ NULL,\n"
483 "\t\t\t(GtkClassInitFunc) NULL,\n"
485 "\t\ttype = gtk_type_unique (%s_get_type(), &info);\n"
489 funcbase,typebase,typebase,typebase,
490 funcbase,funcbase,pfuncbase);
494 add_overrides(Class *c, char *oname)
500 done = g_hash_table_new(g_str_hash,g_str_equal);
501 s = g_strdup("GtkObject"); /* This was already done */
502 g_hash_table_insert(done,s,s);
503 for(li=c->nodes;li;li=g_list_next(li)) {
507 if(n->type != METHOD_NODE ||
508 ((Method *)n)->scope != OVERRIDE_METHOD)
512 s = remove_sep(m->otype);
514 if(g_hash_table_lookup(done,s)) {
518 g_hash_table_insert(done,s,s);
520 f = replace_sep(m->otype,'_');
523 fprintf(out,"\t%sClass *%s_class = (%sClass *)%s;\n",
528 g_hash_table_foreach(done,(GHFunc)g_free,NULL);
529 g_hash_table_destroy(done);
533 add_signals(Class *c)
538 for(li=c->nodes;li;li=g_list_next(li)) {
544 if(n->type != METHOD_NODE ||
545 (((Method *)n)->scope != SIGNAL_FIRST_METHOD &&
546 ((Method *)n)->scope != SIGNAL_LAST_METHOD))
551 if(g_hash_table_lookup(marsh,m))
552 mar = g_strconcat("marshal_",
553 (char *)g_hash_table_lookup(marsh,m),
556 mar = g_strdup("gtk_signal_default_marshaller");
558 is_none = (strcmp(m->gtktypes->next->data,"NONE")==0);
560 sig = g_strdup(m->id);
562 fprintf(out,"\tobject_signals[%s_SIGNAL] =\n"
563 "\t\tgtk_signal_new (\"%s\",\n"
564 "\t\t\tGTK_RUN_%s,\n"
565 "\t\t\tgtk_object_class->type,\n"
566 "\t\t\tGTK_SIGNAL_OFFSET (%sClass, %s),\n"
568 "\t\t\tGTK_TYPE_%s, %d",
570 m->scope==SIGNAL_LAST_METHOD?"LAST":"FIRST",
571 typebase,m->id,mar,(char *)m->gtktypes->data,
572 is_none?0:g_list_length(m->gtktypes->next));
578 for(l=m->gtktypes->next;l;l=g_list_next(l))
579 fprintf(out,",\n\t\t\tGTK_TYPE_%s",
585 fprintf(out,"\tgtk_object_class_add_signals (gtk_object_class,\n"
586 "\t\tobject_signals, LAST_SIGNAL);\n\n");
590 set_def_handlers(Class *c, char *oname)
595 for(li=c->nodes;li;li=g_list_next(li)) {
598 if(n->type != METHOD_NODE ||
599 (((Method *)n)->scope != SIGNAL_FIRST_METHOD &&
600 ((Method *)n)->scope != SIGNAL_LAST_METHOD &&
601 ((Method *)n)->scope != VIRTUAL_METHOD &&
602 ((Method *)n)->scope != OVERRIDE_METHOD))
607 if(m->scope == OVERRIDE_METHOD) {
609 s = replace_sep(m->otype,'_');
611 fprintf(out,"\t%s_class->%s = %s_%s;\n",
612 s,m->id,funcbase,m->id);
615 fprintf(out,"\t%s->%s = _real_%s_%s;\n",
616 oname,m->id,funcbase,m->id);
618 fprintf(out,"\t%s->%s = NULL;\n",
625 make_arguments(Class *c)
630 for(li=c->nodes;li;li=g_list_next(li)) {
636 if(n->type != ARGUMENT_NODE)
642 flags = g_string_new("GTK_ARG_READWRITE");
644 flags = g_string_new("GTK_ARG_READABLE");
646 flags = g_string_new("GTK_ARG_WRITABLE");
648 for(l=a->flags;l;l=g_list_next(l))
649 g_string_sprintfa(flags," | GTK_ARG_%s",(char *)l->data);
651 s = g_strdup(a->name);
653 fprintf(out,"\tgtk_object_add_arg_type(\"%s::%s\",\n"
657 typebase,a->name,a->gtktype,flags->str,s);
659 g_string_free(flags,TRUE);
662 fprintf(out,"\n\tgtk_object_class->set_arg = __object_set_arg;\n"
663 "\tgtk_object_class->get_arg = __object_get_arg;\n");
670 for(li=c->nodes;li;li=g_list_next(li)) {
673 if(n->type != METHOD_NODE)
676 if(m->scope == INIT_METHOD) {
677 print_method(out,"static ","\n"," ","",m);
679 fprintf(out,"{\n%s\n}\n\n",m->cbuf->str);
681 fprintf(out,"{\n\treturn;\n}\n\n");
682 } else if(m->scope == CLASS_INIT_METHOD) {
683 print_method(out,"static ","\n"," ","",m);
685 "\tGtkObjectClass *gtk_object_class = "
686 "(GtkObjectClass*) %s;\n",
687 ((FuncArg *)m->args->data)->name);
689 add_overrides(c, ((FuncArg *)m->args->data)->name);
691 fprintf(out,"\n\tparent_class = "
692 "gtk_type_class (%s_get_type ());\n",
697 set_def_handlers(c, ((FuncArg *)m->args->data)->name);
702 fprintf(out," {\n%s\n }\n",m->cbuf->str);
709 add_getset_arg(Class *c, int is_set)
712 fprintf(out,"\nstatic void\n"
713 "__object_%s_arg (GtkObject *object,\n"
718 "\tthis = %s (object);\n\n"
719 "\tswitch (arg_id) {\n",
720 is_set?"set":"get",typebase,macrobase);
722 for(li=c->nodes;li;li=g_list_next(li)) {
726 if(n->type != ARGUMENT_NODE)
729 if((is_set && !a->set) ||
730 (!is_set && !a->get))
732 s = g_strdup(a->name);
734 fprintf(out,"\tcase ARG_%s:\n"
735 "#define ARG (GTK_VALUE_%s(*arg))\n"
736 "\t\t{\n%s\n\t\t}\n\t\tbreak;\n"
738 s,a->gtktype,a->set->str);
741 fprintf(out,"\tdefault:\n\t\tbreak;\n\t}\n}\n");
745 print_checks(Method *m, FuncArg *fa)
749 is_void = (strcmp(m->mtype->name,"void")==0 &&
750 m->mtype->stars == 0);
752 for(li=fa->checks;li;li=g_list_next(li)) {
753 Check *ch = li->data;
756 fprintf(out,"\tg_return_if_fail (");
758 fprintf(out,"\tg_return_val_if_fail (");
761 fprintf(out,"%s != NULL",fa->name);
764 s = make_is_macro(fa->atype->name);
765 fprintf(out,"%s (%s)",s,fa->name);
769 fprintf(out,"%s < %s",fa->name,ch->number);
772 fprintf(out,"%s > %s",fa->name,ch->number);
775 fprintf(out,"%s <= %s",fa->name,ch->number);
778 fprintf(out,"%s >= %s",fa->name,ch->number);
781 fprintf(out,"%s == %s",fa->name,ch->number);
784 fprintf(out,"%s != %s",fa->name,ch->number);
791 print_type(out,m->mtype);
792 fprintf(out,")%s);\n",
793 m->onerror?m->onerror:"0");
799 print_preconditions(Method *m)
803 for(li=m->args;li;li=g_list_next(li)) {
804 FuncArg *fa = li->data;
811 print_method_body(Method *m, int pre)
815 print_preconditions(m);
816 fprintf(out,"\t{\n");
819 fprintf(out,"\t\t%s\n",m->cbuf->str);
822 fprintf(out,"\t}\n");
827 put_method(Method *m)
831 if(strcmp(m->id,"new")==0) {
832 fprintf(out,"#define GET_NEW (gtk_type_new(%s_get_type()))\n",
837 print_method(out,"","\n"," ","",m);
838 print_method_body(m,TRUE);
841 print_method(out,"static ","\n"," ","",m);
842 print_method_body(m,TRUE);
844 case SIGNAL_FIRST_METHOD:
845 case SIGNAL_LAST_METHOD:
846 print_method(out,"","\n"," ","",m);
850 if(strcmp(m->mtype->name,"void")==0 &&
851 m->mtype->stars==0) {
853 print_preconditions(m);
854 fprintf(out,"\tgtk_signal_emit (GTK_OBJECT (this),\n"
855 "\t\tobject_signals[%s_SIGNAL]",s);
856 for(li=m->args->next;li;li=g_list_next(li)) {
857 FuncArg *fa = li->data;
858 fprintf(out,",\n\t\t%s",fa->name);
860 fprintf(out,");\n}\n");
864 print_type(out,m->mtype);
865 fprintf(out,"return_val;\n");
866 print_preconditions(m);
867 fprintf(out,"\tgtk_signal_emit (GTK_OBJECT (this),\n"
868 "\t\tobject_signals[%s_SIGNAL]",s);
869 for(li=m->args->next;li;li=g_list_next(li)) {
870 FuncArg *fa = li->data;
871 fprintf(out,",\n\t\t%s",fa->name);
873 fprintf(out,",\n\t\t&return_val);\n"
874 "\treturn return_val;\n}\n");
879 print_method(out,"static ","\n_real_"," ","",m);
880 print_method_body(m,FALSE);
883 print_method(out,"","\n"," ","",m);
885 "\t%sClass *class;\n",typebase);
886 print_preconditions(m);
887 fprintf(out,"\tclass = %s_CLASS(GTK_OBJECT(this)->klass);\n\n"
890 if(strcmp(m->mtype->name,"void")==0 &&
891 m->mtype->stars==0) {
893 fprintf(out,"\t\t(*class->%s)(this",m->id);
894 for(li=m->args->next;li;li=g_list_next(li)) {
895 FuncArg *fa = li->data;
896 fprintf(out,",%s",fa->name);
898 fprintf(out,");\n}\n");
901 fprintf(out,"\t\treturn (*class->%s)(this",m->id);
902 for(li=m->args->next;li;li=g_list_next(li)) {
903 FuncArg *fa = li->data;
904 fprintf(out,",%s",fa->name);
909 print_type(out,m->mtype);
910 fprintf(out,")(%s);\n}\n",
911 m->onerror?m->onerror:"0");
916 print_method(out,"static ","\n_real_"," ","",m);
917 print_method_body(m,FALSE);
919 case OVERRIDE_METHOD:
920 print_method(out,"static ","\n"," ","",m);
921 print_method_body(m,TRUE);
926 if(strcmp(m->id,"new")==0)
927 fprintf(out,"#undef GET_NEW\n");
933 char *outfile,*outfileh;
935 outfile = g_strconcat(filebase,".c",NULL);
936 outfileh = g_strconcat(filebase,".h",NULL);
938 out = fopen(outfile,"w");
940 g_error("Cannot open outfile: %s",outfile);
942 outh = fopen(outfileh,"w");
944 g_error("Cannot open outfile: %s",outfileh);
949 generate_outfiles(void)
956 fprintf(outh,"/* Generated by GOB (v%s) on %s"
957 " (do not edit directly) */\n\n",VERSION,ctime(&curtime));
958 fprintf(out,"/* Generated by GOB (v%s) on %s"
959 " (do not edit directly) */\n\n",VERSION,ctime(&curtime));
961 p = replace_sep(((Class *)class)->otype,'_');
963 fprintf(outh,"#ifndef __%s_H__\n#define __%s_H__\n\n"
964 "#include <gtk/gtk.h>\n\n",p,p);
967 fprintf(outh,"#ifdef __cplusplus\n"
969 "#endif /* __cplusplus */\n\n");
971 fprintf(out,"#include \"%s.h\"\n\n",filebase);
973 for(li=nodes;li;li=g_list_next(li)) {
974 Node *node = li->data;
975 if(node->type == CCODE_NODE) {
976 CCode *cc = (CCode *)node;
982 fprintf(fp,"\n%s\n",cc->cbuf->str);
983 } else if(node->type == CLASS_NODE) {
985 Class *c = (Class *)class;
988 fprintf(outh,"\n#define %s(obj)\t"
989 "GTK_CHECK_CAST((obj),%s_get_type(),%s)\n",
990 macrobase,funcbase,typebase);
991 fprintf(outh,"#define %s_CLASS(klass)\t"
992 "GTK_CHECK_CLASS_CAST((klass),%s_get_type(),%sClass)\n",
993 macrobase,funcbase,typebase);
994 fprintf(outh,"#define %s(obj)\t"
995 "GTK_CHECK_TYPE((obj), %s_get_type ())\n\n",
998 otype = remove_sep(c->otype);
999 ptype = remove_sep(c->ptype);
1000 fprintf(outh,"\ntypedef struct _%s %s;\n",otype,otype);
1001 fprintf(outh,"struct _%s {\n\t%s __parent__;\n",
1003 for(l=c->nodes;l;l=g_list_next(l)) {
1005 if(n->type == VARIABLE_NODE)
1006 put_variable((Variable *)n);
1008 fprintf(outh,"};\n");
1010 fprintf(outh,"\ntypedef struct _%sClass %sClass;\n",
1013 "struct _%sClass {\n\t%sClass __parent__;\n",
1015 for(l=c->nodes;l;l=g_list_next(l)) {
1017 if(n->type == METHOD_NODE)
1018 put_vs_method((Method *)n);
1020 fprintf(outh,"};\n\n");
1022 fprintf(outh,"guint\t%s_get_type\t(void);\n",funcbase);
1024 fprintf(out,"static void __object_set_arg "
1025 "(GtkObject *object, GtkArg *arg, "
1027 "static void __object_get_arg "
1028 "(GtkObject *object, GtkArg *arg, "
1029 "guint arg_id);\n");
1031 for(l=c->nodes;l;l=g_list_next(l)) {
1033 if(n->type == METHOD_NODE) {
1034 put_pub_method((Method *)n);
1035 put_priv_method_prot((Method *)n);
1039 for(l=c->nodes;l;l=g_list_next(l)) {
1041 if(n->type == METHOD_NODE) {
1042 add_signal_prots((Method *)n);
1054 add_getset_arg(c, TRUE);
1055 add_getset_arg(c, FALSE);
1057 for(l=c->nodes;l;l=g_list_next(l)) {
1059 if(n->type == METHOD_NODE) {
1060 put_method((Method *)n);
1069 g_assert_not_reached();
1072 fprintf(outh,"\n#ifdef __cplusplus\n"
1074 "#endif /* __cplusplus */\n\n"
1079 usage(poptContext optCon, int exitcode, char *error, char *addl)
1081 poptPrintUsage(optCon, stderr, 0);
1082 if (error) fprintf(stderr, "%s: %s", error, addl);
1088 main(int argc, char *argv[])
1093 struct poptOption optionsTable[] = {
1094 { "exit-on-warn", 'w', 0, &exit_on_warn, 0,
1095 "exit on warnings" },
1097 { NULL, 0, 0, NULL, 0 }
1100 optCon = poptGetContext(NULL, argc, argv, optionsTable, 0);
1101 poptSetOtherOptionHelp(optCon, "[OPTIONS]* [filename]");
1103 while ((c = poptGetNextOpt(optCon)) >= 0)
1106 filename = poptGetArg(optCon);
1107 if(!(poptPeekArg(optCon) == NULL))
1108 usage(optCon, 1, "Specify only one file",
1109 ".e.g., filename.gob");
1112 /* an error occurred during option processing */
1113 fprintf(stderr, "%s: %s\n",
1114 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
1120 yyin = fopen(filename,"r");
1122 fprintf(stderr,"Error: can't open file '%s'\n",
1131 g_error("Parsing errors, quitting");
1133 print_error(FALSE," no class defined",0);
1137 make_inits((Class *)class);
1141 generate_outfiles();
1146 poptFreeContext(optCon);