From dd11885aadcfaafae2d6268c381b0aac94cbc149 Mon Sep 17 00:00:00 2001 From: George Lebl Date: Sun, 16 Apr 2000 08:16:00 -0800 Subject: [PATCH] Release 0.93.3 --- ChangeLog | 38 ++++++ NEWS | 4 + configure | 2 +- configure.in | 2 +- examples/Makefile.am | 4 +- examples/Makefile.in | 3 +- examples/my-person2.gob | 73 +++++++++++ gob.spec | 2 +- src/lexer.c | 4 +- src/lexer.l | 4 +- src/main.c | 92 +++++++------ src/parse.c | 277 +++++++++++++++++++++------------------- src/parse.y | 13 +- src/test.gob | 8 ++ 14 files changed, 345 insertions(+), 181 deletions(-) create mode 100644 examples/my-person2.gob diff --git a/ChangeLog b/ChangeLog index 822145e..da67a18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,41 @@ +Sat Apr 15 23:07:30 2000 George Lebl + + * Released 0.93.3 + +Sat Apr 15 22:42:20 2000 George Lebl + + * src/main.c: fixes for ANSI C and C++. Just use GTK_VALUE_POINTER + instead of GTK_VALUE_OBJECT so that we don't have to cast and don't + cast lvalues. + +Sat Apr 15 22:09:49 2000 George Lebl + + * src/main.c: use the generic return type in signal marshallers + rather then the specific one as the marshallers are truly generic + +Sat Apr 15 21:52:52 2000 George Lebl + + * src/main.c: fix some typesafety braindamages with OBJECT types + in arguments by casting GTK_VALUE_OBJECT to gpointer. Also + for seting arguments cast the ARG to atype if it exists + +Wed Apr 05 13:42:28 2000 George Lebl + + * src/parse.y: never allow NONE to be used as one of many arguments, + always only by itself in the argument list + + * src/main.c: When printing out the signal marshaller prototype, + don't print out the NONE (void) into the argument list, thanks + to Soeren Sandmann for reporting that + +Mon Apr 03 13:07:33 2000 George Lebl + + * examples/Makefile.am: add my-person2.gob to EXTRA_DIST + +Sun Apr 02 18:09:40 2000 George Lebl + + * Release 0.93.2 + Sun Apr 02 17:38:12 2000 George Lebl * src/Makefile.am: ass the .pl and .def file to EXTRA_DIST diff --git a/NEWS b/NEWS index 08f942e..0dc8c75 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +0.93.3 + * fix signals with return values but no arguments + * more input file checking + 0.93.2 * defreturn for default return values on signals/virtuals * code reorganisation diff --git a/configure b/configure index 0038bea..f303b3f 100755 --- a/configure +++ b/configure @@ -703,7 +703,7 @@ fi PACKAGE=gob -VERSION=0.93.2 +VERSION=0.93.3 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff --git a/configure.in b/configure.in index 53c48c8..b897cfc 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.2) AC_INIT(src/treefuncs.h) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(gob,0.93.2) +AM_INIT_AUTOMAKE(gob,0.93.3) if test -f ../NOINST_GOB ; then DOINSTGOB= diff --git a/examples/Makefile.am b/examples/Makefile.am index 1cbbd04..9197fa7 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,5 +1,7 @@ EXTRA_DIST = \ README \ gtk-button-count.gob \ - my-person.gob + my-person.gob \ + my-person2.gob + SUBDIRS = diff --git a/examples/Makefile.in b/examples/Makefile.in index dd245f4..3695c56 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -77,7 +77,8 @@ TAR = @TAR@ VERSION = @VERSION@ YACC = @YACC@ -EXTRA_DIST = README gtk-button-count.gob my-person.gob +EXTRA_DIST = README gtk-button-count.gob my-person.gob my-person2.gob + SUBDIRS = mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs diff --git a/examples/my-person2.gob b/examples/my-person2.gob new file mode 100644 index 0000000..749bfb0 --- /dev/null +++ b/examples/my-person2.gob @@ -0,0 +1,73 @@ +requires 0.93.0 + +/* this file requires 0.93.0 as it uses some of the new features to reduce + * typing and generally make it easier to read I think. Of course they're + * optional to use so use the my-person.gob as an example of not using them. + * These include data member initialization, automatic destructor calling + * and automatic argument<->data member linking */ + +%{ +#include +#include "my-person2.h" +#include "my-person2-private.h" +%} + +class My:Person2 from Gtk:Object { + /* the name of the person */ + public char *name = {g_strdup("Nobody")} + destroywith g_free; + argument POINTER name stringlink; + + /* date of birth as a time_t */ + public long dob = 0; + argument LONG dob link; + + /* date of death as a time_t */ + public long dod = 0; + argument LONG dod link; + + /* number of rounds in our shotgun */ + private int rounds_in_shotgun = 0; + + /* when the person gets born, sends out a signal, the caller + of the signal should provide the date of birth */ + signal last NONE (LONG) + void + birth(self, long dob) + { + self->dob = dob; + } + + /* when the person dies, sends out a signal, the caller + of the signal should provide the date of death */ + signal last NONE (LONG) + void + death(self, long dod) + { + self->dod = dod; + } + + public + void + load_shotgun(self) + { + /* add a round to our shotgun */ + self->_priv->rounds_in_shotgun++; + } + + public + void + shoot_oneself_in_the_head(self) + { + if(self->_priv->rounds_in_shotgun==0) { + g_warning("No rounds in the shotgun!"); + return; + } + + /* one round was fired */ + self->_priv->rounds_in_shotgun--; + + /* death is imminent if we shoot oneself in the head */ + death(self, (long)time(NULL)); + } +} diff --git a/gob.spec b/gob.spec index 59c7c88..cb14cd5 100644 --- a/gob.spec +++ b/gob.spec @@ -1,4 +1,4 @@ -%define ver 0.93.2 +%define ver 0.93.3 %define rel 1 %define prefix /usr diff --git a/src/lexer.c b/src/lexer.c index 958dd4d..f9fb3e8 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -771,9 +771,9 @@ static void clear_cbuf(void) { if(!cbuf) { - cbuf = g_string_new(""); + cbuf = g_string_new(NULL); } else { - cbuf = g_string_assign(cbuf,""); + cbuf = g_string_assign(cbuf, ""); } } diff --git a/src/lexer.l b/src/lexer.l index b155aa7..941a460 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -51,9 +51,9 @@ static void clear_cbuf(void) { if(!cbuf) { - cbuf = g_string_new(""); + cbuf = g_string_new(NULL); } else { - cbuf = g_string_assign(cbuf,""); + cbuf = g_string_assign(cbuf, ""); } } diff --git a/src/main.c b/src/main.c index ab2dd21..09f59c2 100644 --- a/src/main.c +++ b/src/main.c @@ -586,7 +586,7 @@ find_same_type_signal(Method *m) static void print_signal_marsal_args(Method *m) { - if(strcmp(m->gtktypes->next->data,"NONE")!=0) { + if(strcmp(m->gtktypes->next->data, "NONE")!=0) { GList *li; int i; for(i=0,li=m->gtktypes->next;li; @@ -621,8 +621,8 @@ add_signal_prots(Method *m) if(!marsh) marsh = g_hash_table_new(NULL,NULL); - if(strcmp(m->gtktypes->data,"NONE")==0 && - strcmp(m->gtktypes->next->data,"NONE")==0) + if(strcmp(m->gtktypes->data, "NONE")==0 && + strcmp(m->gtktypes->next->data, "NONE")==0) return; /* if we already did a signal prototype just use that */ @@ -635,16 +635,18 @@ add_signal_prots(Method *m) s = g_strdup_printf("Sig%d",sig++); - g_hash_table_insert(marsh,m,s); - eq_signal_methods = g_list_prepend(eq_signal_methods,m); + g_hash_table_insert(marsh, m, s); + eq_signal_methods = g_list_prepend(eq_signal_methods, m); /* we know that we'll know all the gtktypes (so get_cast can't fail) */ - out_printf(out,"\ntypedef %s (*___%s) (%s *, ", + out_printf(out, "\ntypedef %s (*___%s) (%s *, ", get_cast(m->gtktypes->data, FALSE), s, typebase); - for(li=m->gtktypes->next;li;li=g_list_next(li)) - out_printf(out, "%s, ", get_cast(li->data, FALSE)); - out_printf(out,"gpointer);\n"); + if(strcmp(m->gtktypes->next->data, "NONE")!=0) { + for(li=m->gtktypes->next; li; li=g_list_next(li)) + out_printf(out, "%s, ", get_cast(li->data, FALSE)); + } + out_printf(out, "gpointer);\n"); out_printf(out,"\nstatic void\n" "___marshal_%s (GtkObject * object,\n" @@ -653,19 +655,20 @@ add_signal_prots(Method *m) "\tGtkArg * args)\n" "{\n",s); - if(strcmp(m->gtktypes->data,"NONE")==0) { + if(strcmp(m->gtktypes->data, "NONE")==0) { out_printf(out, "\t___%s rfunc;\n\n" "\trfunc = (___%s)func;\n\n" - "\t(*rfunc)((%s *)object",s,s,typebase); + "\t(*rfunc)((%s *)object", s, s, typebase); } else { - out_printf(out, "\t___%s rfunc;\n\t",s); - print_type(out,m->mtype,TRUE); - out_printf(out, " *retval;\n\n" - "\trfunc = (___%s)func;\n\n" - "\tretval = GTK_RETLOC_%s(args[%d]);\n\n" - "\t*retval = (*rfunc)((%s *)object", - s,(char *)m->gtktypes->data, - g_list_length(m->gtktypes)-1,typebase); + const char *retcast = get_cast(m->gtktypes->data, FALSE); + out_printf(out, + "\t___%s rfunc;\n\t" + "%s *retval;\n\n" + "\trfunc = (___%s)func;\n\n" + "\tretval = GTK_RETLOC_%s(args[%d]);\n\n" + "\t*retval = (*rfunc)((%s *)object", + s, retcast, s, (char *)m->gtktypes->data, + g_list_length(m->gtktypes)-1, typebase); } print_signal_marsal_args(m); @@ -1164,19 +1167,28 @@ add_getset_arg(Class *c, gboolean is_set) continue; s = g_strdup(a->name); g_strup(s); + out_printf(out, "\tcase ARG_%s:\n", s); if(is_set && a->atype) { char *cast = get_type(a->atype, TRUE); - out_printf(out, "\tcase ARG_%s:\n", s); if(no_gnu || for_cpp) { out_printf(out, "#define ARG " "((%s)GTK_VALUE_%s(*arg))\n", cast, a->gtktype); } else { out_printf(out, "#ifdef __GNUC__\n"); - out_printf(out, "#define ARG " - "({%s foo = GTK_VALUE_%s(*arg); " - "foo; })\n", - cast, a->gtktype); + if(strcmp(a->gtktype, "OBJECT")==0) { + out_printf(out, "#define ARG " + "({%s foo = " + "GTK_VALUE_POINTER(*arg); " + "foo; })\n", + cast); + } else { + out_printf(out, "#define ARG " + "({%s foo = " + "GTK_VALUE_%s(*arg); " + "foo; })\n", + cast, a->gtktype); + } out_printf(out,"#else /* __GNUC__ */\n"); out_printf(out, "#define ARG " "((%s)GTK_VALUE_%s(*arg))\n", @@ -1185,11 +1197,15 @@ add_getset_arg(Class *c, gboolean is_set) } out_printf(out, "\t\t{\n"); g_free(cast); + } else if(!is_set && strcmp(a->gtktype, "OBJECT")==0) { + out_printf(out, + "#define ARG (GTK_VALUE_POINTER(*arg))\n" + "\t\t{\n"); } else { - out_printf(out, "\tcase ARG_%s:\n" + out_printf(out, "#define ARG (GTK_VALUE_%s(*arg))\n" "\t\t{\n", - s, a->gtktype); + a->gtktype); } g_free(s); if(line_no > 0) @@ -1209,7 +1225,7 @@ print_checks(Method *m, FuncArg *fa) GList *li; gboolean is_void; gboolean checked_null = FALSE; - is_void = (strcmp(m->mtype->name,"void")==0 && + is_void = (strcmp(m->mtype->name, "void")==0 && m->mtype->stars == 0); for(li=fa->checks;li;li=g_list_next(li)) { @@ -1219,22 +1235,22 @@ print_checks(Method *m, FuncArg *fa) if(m->line_no > 0) out_addline_infile(out,m->line_no); if(is_void) - out_printf(out,"\tg_return_if_fail ("); + out_printf(out, "\tg_return_if_fail ("); else - out_printf(out,"\tg_return_val_if_fail ("); + out_printf(out, "\tg_return_val_if_fail ("); switch(ch->chtype) { case NULL_CHECK: - out_printf(out,"%s != NULL",fa->name); + out_printf(out, "%s != NULL", fa->name); checked_null = TRUE; break; case TYPE_CHECK: - s = make_pre_macro(fa->atype->name,"IS"); + s = make_pre_macro(fa->atype->name, "IS"); if(checked_null) - out_printf(out,"%s (%s)",s,fa->name); + out_printf(out, "%s (%s)", s, fa->name); else /* if not check null, null may be valid */ - out_printf(out,"!(%s) || %s (%s)",fa->name,s, - fa->name); + out_printf(out, "!(%s) || %s (%s)", fa->name, + s, fa->name); g_free(s); break; case LT_CHECK: @@ -2103,16 +2119,16 @@ static void print_header_postfixes(void) { if(!no_extern_c) - out_printf(outh,"\n#ifdef __cplusplus\n" + out_printf(outh, "\n#ifdef __cplusplus\n" "}\n" "#endif /* __cplusplus */\n"); - out_printf(outh,"\n#endif"); + out_printf(outh, "\n#endif\n"); if(outph) { if(!no_extern_c) - out_printf(outph,"\n#ifdef __cplusplus\n" + out_printf(outph, "\n#ifdef __cplusplus\n" "}\n" "#endif /* __cplusplus */\n"); - out_printf(outph,"\n#endif"); + out_printf(outph, "\n#endif\n"); } } diff --git a/src/parse.c b/src/parse.c index 480d236..7b6e9eb 100644 --- a/src/parse.c +++ b/src/parse.c @@ -158,11 +158,22 @@ push_function(int scope, int method, char *oid, char *id, g_list_length(gtktypes) != g_list_length(funcargs) && !(g_list_length(funcargs) == 1 && g_list_length(gtktypes) == 2 && - strcmp(gtktypes->next->data,"NONE")==0)) { + strcmp(gtktypes->next->data, "NONE")==0)) { print_error(TRUE, _("The number of GTK arguments and " "function arguments for a signal " "don't seem to match"), line_no); } + if(g_list_length(gtktypes) > 2) { + GList *li; + for(li = gtktypes->next; li; li = li->next) { + if(strcmp(li->data, "NONE")==0) { + print_error(FALSE, + _("NONE can only appear in an " + "argument list by itself"), + line_no); + } + } + } if(cbuf) { char *p; c_cbuf = p = cbuf->str; @@ -294,7 +305,7 @@ set_return_value(char *type, char *val) } -#line 277 "parse.y" +#line 288 "parse.y" typedef union { char *id; GString *cbuf; @@ -419,18 +430,18 @@ static const short yyrhs[] = { 51, #if YYDEBUG != 0 static const short yyrline[] = { 0, - 295, 296, 297, 298, 301, 307, 313, 319, 325, 331, - 339, 340, 343, 348, 355, 360, 361, 364, 365, 366, - 367, 370, 371, 372, 375, 388, 404, 408, 416, 417, - 418, 419, 420, 426, 429, 433, 468, 496, 561, 570, - 576, 577, 580, 583, 589, 590, 598, 602, 609, 612, - 615, 618, 621, 624, 627, 630, 633, 636, 640, 643, - 648, 651, 654, 657, 660, 665, 668, 671, 676, 677, - 681, 693, 699, 711, 723, 726, 732, 737, 740, 745, - 746, 750, 761, 772, 783, 794, 805, 811, 816, 837, - 848, 867, 873, 874, 880, 881, 892, 902, 905, 906, - 909, 910, 913, 916, 919, 927, 937, 938, 941, 954, - 958, 962, 966, 970, 974, 980, 981, 985 + 306, 307, 308, 309, 312, 318, 324, 330, 336, 342, + 350, 351, 354, 359, 366, 371, 372, 375, 376, 377, + 378, 381, 382, 383, 386, 399, 415, 419, 427, 428, + 429, 430, 431, 437, 440, 444, 479, 507, 572, 581, + 587, 588, 591, 594, 600, 601, 609, 613, 620, 623, + 626, 629, 632, 635, 638, 641, 644, 647, 651, 654, + 659, 662, 665, 668, 671, 676, 679, 682, 687, 688, + 692, 704, 710, 722, 734, 737, 743, 748, 751, 756, + 757, 761, 772, 783, 794, 805, 816, 822, 827, 848, + 859, 878, 884, 885, 891, 892, 903, 913, 916, 917, + 920, 921, 924, 927, 930, 938, 948, 949, 952, 965, + 969, 973, 977, 981, 985, 991, 992, 996 }; #endif @@ -1174,23 +1185,23 @@ yyreduce: switch (yyn) { case 1: -#line 295 "parse.y" +#line 306 "parse.y" { ; ; break;} case 2: -#line 296 "parse.y" +#line 307 "parse.y" { ; ; break;} case 3: -#line 297 "parse.y" +#line 308 "parse.y" { ; ; break;} case 4: -#line 298 "parse.y" +#line 309 "parse.y" { ; ; break;} case 5: -#line 301 "parse.y" +#line 312 "parse.y" { Node *node = new_ccode(C_CCODE,(yyvsp[0].cbuf)->str, ccode_line); @@ -1199,7 +1210,7 @@ case 5: ; break;} case 6: -#line 307 "parse.y" +#line 318 "parse.y" { Node *node = new_ccode(H_CCODE,(yyvsp[0].cbuf)->str, ccode_line); @@ -1208,7 +1219,7 @@ case 6: ; break;} case 7: -#line 313 "parse.y" +#line 324 "parse.y" { Node *node = new_ccode(HT_CCODE,(yyvsp[0].cbuf)->str, ccode_line); @@ -1217,7 +1228,7 @@ case 7: ; break;} case 8: -#line 319 "parse.y" +#line 330 "parse.y" { Node *node = new_ccode(PH_CCODE,(yyvsp[0].cbuf)->str, ccode_line); @@ -1226,7 +1237,7 @@ case 8: ; break;} case 9: -#line 325 "parse.y" +#line 336 "parse.y" { Node *node = new_ccode(A_CCODE,(yyvsp[0].cbuf)->str, ccode_line); @@ -1235,7 +1246,7 @@ case 9: ; break;} case 10: -#line 331 "parse.y" +#line 342 "parse.y" { Node *node = new_ccode(AT_CCODE,(yyvsp[0].cbuf)->str, ccode_line); @@ -1244,15 +1255,15 @@ case 10: ; break;} case 11: -#line 339 "parse.y" +#line 350 "parse.y" { ; ; break;} case 12: -#line 340 "parse.y" +#line 351 "parse.y" { ; ; break;} case 13: -#line 343 "parse.y" +#line 354 "parse.y" { ((Class *)class)->nodes = class_nodes; class_nodes = NULL; @@ -1260,7 +1271,7 @@ case 13: ; break;} case 14: -#line 348 "parse.y" +#line 359 "parse.y" { ((Class *)class)->nodes = NULL; class_nodes = NULL; @@ -1268,49 +1279,49 @@ case 14: ; break;} case 15: -#line 355 "parse.y" +#line 366 "parse.y" { class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL); ; break;} case 16: -#line 360 "parse.y" +#line 371 "parse.y" { ; ; break;} case 17: -#line 361 "parse.y" +#line 372 "parse.y" { ; ; break;} case 18: -#line 364 "parse.y" +#line 375 "parse.y" { ; ; break;} case 19: -#line 365 "parse.y" +#line 376 "parse.y" { ; ; break;} case 20: -#line 366 "parse.y" +#line 377 "parse.y" { ; ; break;} case 21: -#line 367 "parse.y" +#line 378 "parse.y" { ; ; break;} case 22: -#line 370 "parse.y" +#line 381 "parse.y" { the_scope = PUBLIC_SCOPE; ; break;} case 23: -#line 371 "parse.y" +#line 382 "parse.y" { the_scope = PRIVATE_SCOPE; ; break;} case 24: -#line 372 "parse.y" +#line 383 "parse.y" { the_scope = PROTECTED_SCOPE; ; break;} case 25: -#line 375 "parse.y" +#line 386 "parse.y" { if(strcmp(yyvsp[-1].id, "destroywith")==0) { g_free(yyvsp[-1].id); @@ -1326,7 +1337,7 @@ case 25: ; break;} case 26: -#line 388 "parse.y" +#line 399 "parse.y" { if(strcmp(yyvsp[-2].id, "destroy")==0) { g_free(yyvsp[-2].id); @@ -1343,14 +1354,14 @@ case 26: ; break;} case 27: -#line 404 "parse.y" +#line 415 "parse.y" { initializer = yyvsp[0].id; initializer_line = ccode_line; ; break;} case 28: -#line 408 "parse.y" +#line 419 "parse.y" { initializer = (yyvsp[0].cbuf)->str; initializer_line = ccode_line; @@ -1358,42 +1369,42 @@ case 28: ; break;} case 29: -#line 416 "parse.y" +#line 427 "parse.y" { ; ; break;} case 30: -#line 417 "parse.y" +#line 428 "parse.y" { ; ; break;} case 31: -#line 418 "parse.y" +#line 429 "parse.y" { destructor = NULL; ; break;} case 32: -#line 419 "parse.y" +#line 430 "parse.y" { initializer = NULL; ; break;} case 33: -#line 420 "parse.y" +#line 431 "parse.y" { destructor = NULL; initializer = NULL; ; break;} case 34: -#line 426 "parse.y" +#line 437 "parse.y" { push_variable(yyvsp[-2].id, the_scope,yyvsp[-4].line, NULL); ; break;} case 35: -#line 429 "parse.y" +#line 440 "parse.y" { push_variable(yyvsp[-3].id, the_scope, yyvsp[-5].line, yyvsp[-2].id); ; break;} case 36: -#line 433 "parse.y" +#line 444 "parse.y" { if(strcmp(yyvsp[-6].id,"get")==0 && strcmp(yyvsp[-3].id,"set")==0) { @@ -1431,7 +1442,7 @@ case 36: ; break;} case 37: -#line 468 "parse.y" +#line 479 "parse.y" { if(strcmp(yyvsp[-3].id,"get")==0) { Node *node; @@ -1462,7 +1473,7 @@ case 37: ; break;} case 38: -#line 496 "parse.y" +#line 507 "parse.y" { Node *node; char *get, *set = NULL; @@ -1528,7 +1539,7 @@ case 38: ; break;} case 39: -#line 561 "parse.y" +#line 572 "parse.y" { if(strcmp(yyvsp[-2].id,"type")!=0) { g_free(yyvsp[-4].id); @@ -1540,38 +1551,38 @@ case 39: ; break;} case 40: -#line 570 "parse.y" +#line 581 "parse.y" { yyval.id = yyvsp[0].id; typestack = g_list_prepend(typestack,NULL); ; break;} case 41: -#line 576 "parse.y" +#line 587 "parse.y" { yyval.list = yyvsp[-1].list; ; break;} case 42: -#line 577 "parse.y" +#line 588 "parse.y" { yyval.list = NULL; ; break;} case 43: -#line 580 "parse.y" +#line 591 "parse.y" { yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id); ; break;} case 44: -#line 583 "parse.y" +#line 594 "parse.y" { yyval.list = g_list_append(NULL,yyvsp[0].id); ; break;} case 45: -#line 589 "parse.y" +#line 600 "parse.y" { ; ; break;} case 46: -#line 590 "parse.y" +#line 601 "parse.y" { Type *type = typestack->data; char *oldname = type->name; @@ -1580,14 +1591,14 @@ case 46: ; break;} case 47: -#line 598 "parse.y" +#line 609 "parse.y" { Node *node = new_type(0,yyvsp[0].id,NULL); typestack = g_list_prepend(typestack,node); ; break;} case 48: -#line 602 "parse.y" +#line 613 "parse.y" { Node *node = new_type(stars,yyvsp[-1].id,NULL); stars = 0; @@ -1595,136 +1606,136 @@ case 48: ; break;} case 49: -#line 609 "parse.y" +#line 620 "parse.y" { yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL); ; break;} case 50: -#line 612 "parse.y" +#line 623 "parse.y" { yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL); ; break;} case 51: -#line 615 "parse.y" +#line 626 "parse.y" { yyval.id = g_strdup(yyvsp[0].id); ; break;} case 52: -#line 618 "parse.y" +#line 629 "parse.y" { yyval.id = g_strdup("unsigned char"); ; break;} case 53: -#line 621 "parse.y" +#line 632 "parse.y" { yyval.id = g_strdup("signed char"); ; break;} case 54: -#line 624 "parse.y" +#line 635 "parse.y" { yyval.id = g_strdup("char"); ; break;} case 55: -#line 627 "parse.y" +#line 638 "parse.y" { yyval.id = g_strdup("double"); ; break;} case 56: -#line 630 "parse.y" +#line 641 "parse.y" { yyval.id = g_strdup("float"); ; break;} case 57: -#line 633 "parse.y" +#line 644 "parse.y" { yyval.id = yyvsp[0].id; ; break;} case 58: -#line 636 "parse.y" +#line 647 "parse.y" { yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL); g_free(yyvsp[0].id); ; break;} case 59: -#line 640 "parse.y" +#line 651 "parse.y" { yyval.id = yyvsp[0].id; ; break;} case 60: -#line 643 "parse.y" +#line 654 "parse.y" { yyval.id = g_strdup("void"); ; break;} case 61: -#line 648 "parse.y" +#line 659 "parse.y" { yyval.id = "long int"; ; break;} case 62: -#line 651 "parse.y" +#line 662 "parse.y" { yyval.id = "long"; ; break;} case 63: -#line 654 "parse.y" +#line 665 "parse.y" { yyval.id = "short int"; ; break;} case 64: -#line 657 "parse.y" +#line 668 "parse.y" { yyval.id = "short"; ; break;} case 65: -#line 660 "parse.y" +#line 671 "parse.y" { yyval.id = "int"; ; break;} case 66: -#line 665 "parse.y" +#line 676 "parse.y" { yyval.id = "enum "; ; break;} case 67: -#line 668 "parse.y" +#line 679 "parse.y" { yyval.id = "union "; ; break;} case 68: -#line 671 "parse.y" +#line 682 "parse.y" { yyval.id = "struct "; ; break;} case 69: -#line 676 "parse.y" +#line 687 "parse.y" { stars++; ; break;} case 70: -#line 677 "parse.y" +#line 688 "parse.y" { stars++; ; break;} case 71: -#line 681 "parse.y" +#line 692 "parse.y" { if(strcmp(yyvsp[-1].id, "first")==0) yyval.sigtype = SIGNAL_FIRST_METHOD; @@ -1739,13 +1750,13 @@ case 71: ; break;} case 72: -#line 693 "parse.y" +#line 704 "parse.y" { yyval.sigtype = SIGNAL_LAST_METHOD; ; break;} case 73: -#line 699 "parse.y" +#line 710 "parse.y" { if(strcmp(yyvsp[-1].id,"first")==0) yyval.sigtype = SIGNAL_FIRST_METHOD; @@ -1760,7 +1771,7 @@ case 73: ; break;} case 74: -#line 711 "parse.y" +#line 722 "parse.y" { if(strcmp(yyvsp[-2].id,"first")==0) yyval.sigtype = SIGNAL_FIRST_METHOD; @@ -1775,46 +1786,46 @@ case 74: ; break;} case 75: -#line 723 "parse.y" +#line 734 "parse.y" { yyval.sigtype = SIGNAL_LAST_METHOD; ; break;} case 76: -#line 726 "parse.y" +#line 737 "parse.y" { /* the_scope was default thus public */ the_scope = PUBLIC_SCOPE; ; break;} case 77: -#line 732 "parse.y" +#line 743 "parse.y" { gtktypes = g_list_prepend(gtktypes, yyvsp[-3].id); ; break;} case 78: -#line 737 "parse.y" +#line 748 "parse.y" { gtktypes = g_list_append(gtktypes, yyvsp[0].id); ; break;} case 79: -#line 740 "parse.y" +#line 751 "parse.y" { gtktypes = g_list_append(gtktypes, yyvsp[0].id); ; break;} case 80: -#line 745 "parse.y" +#line 756 "parse.y" { yyval.cbuf = yyvsp[0].cbuf; ; break;} case 81: -#line 746 "parse.y" +#line 757 "parse.y" { yyval.cbuf = NULL; ; break;} case 82: -#line 750 "parse.y" +#line 761 "parse.y" { if(!has_self) { yyerror(_("signal without 'self' as " @@ -1828,7 +1839,7 @@ case 82: ; break;} case 83: -#line 761 "parse.y" +#line 772 "parse.y" { if(!has_self) { yyerror(_("signal without 'self' as " @@ -1842,7 +1853,7 @@ case 83: ; break;} case 84: -#line 772 "parse.y" +#line 783 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " @@ -1856,7 +1867,7 @@ case 84: ; break;} case 85: -#line 783 "parse.y" +#line 794 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " @@ -1870,7 +1881,7 @@ case 85: ; break;} case 86: -#line 794 "parse.y" +#line 805 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " @@ -1884,7 +1895,7 @@ case 86: ; break;} case 87: -#line 805 "parse.y" +#line 816 "parse.y" { push_function(NO_SCOPE, OVERRIDE_METHOD, yyvsp[-8].id, yyvsp[-5].id, yyvsp[0].cbuf, @@ -1893,7 +1904,7 @@ case 87: ; break;} case 88: -#line 811 "parse.y" +#line 822 "parse.y" { push_function(the_scope, REGULAR_METHOD, NULL, yyvsp[-5].id, yyvsp[0].cbuf, yyvsp[-7].line, ccode_line, @@ -1901,7 +1912,7 @@ case 88: ; break;} case 89: -#line 816 "parse.y" +#line 827 "parse.y" { if(strcmp(yyvsp[-4].id, "init")==0) { push_init_arg(yyvsp[-2].id,FALSE); @@ -1923,7 +1934,7 @@ case 89: ; break;} case 90: -#line 837 "parse.y" +#line 848 "parse.y" { g_free(onerror); onerror = NULL; g_free(defreturn); defreturn = NULL; @@ -1937,7 +1948,7 @@ case 90: ; break;} case 91: -#line 848 "parse.y" +#line 859 "parse.y" { g_free(onerror); onerror = NULL; g_free(defreturn); defreturn = NULL; @@ -1959,29 +1970,29 @@ case 91: ; break;} case 92: -#line 867 "parse.y" +#line 878 "parse.y" { g_free(onerror); onerror = NULL; g_free(defreturn); defreturn = NULL; ; break;} case 93: -#line 873 "parse.y" +#line 884 "parse.y" { yyval.id = yyvsp[0].id; ; break;} case 94: -#line 874 "parse.y" +#line 885 "parse.y" { yyval.id = (yyvsp[1].cbuf)->str; g_string_free(yyvsp[1].cbuf, FALSE); ; break;} case 95: -#line 880 "parse.y" +#line 891 "parse.y" { vararg = FALSE; has_self = FALSE; ; break;} case 96: -#line 881 "parse.y" +#line 892 "parse.y" { vararg = FALSE; has_self = TRUE; @@ -1995,7 +2006,7 @@ case 96: ; break;} case 97: -#line 892 "parse.y" +#line 903 "parse.y" { has_self = TRUE; if(strcmp(yyvsp[-2].id,"self")==0) @@ -2008,39 +2019,39 @@ case 97: ; break;} case 98: -#line 902 "parse.y" +#line 913 "parse.y" { has_self = FALSE; ; break;} case 99: -#line 905 "parse.y" +#line 916 "parse.y" { vararg = TRUE; ; break;} case 100: -#line 906 "parse.y" +#line 917 "parse.y" { vararg = FALSE; ; break;} case 101: -#line 909 "parse.y" +#line 920 "parse.y" { ; ; break;} case 102: -#line 910 "parse.y" +#line 921 "parse.y" { ; ; break;} case 103: -#line 913 "parse.y" +#line 924 "parse.y" { push_funcarg(yyvsp[0].id,NULL); ; break;} case 104: -#line 916 "parse.y" +#line 927 "parse.y" { push_funcarg(yyvsp[-1].id,yyvsp[0].id); ; break;} case 105: -#line 919 "parse.y" +#line 930 "parse.y" { if(strcmp(yyvsp[-2].id,"check")!=0) { yyerror(_("parse error")); @@ -2051,7 +2062,7 @@ case 105: ; break;} case 106: -#line 927 "parse.y" +#line 938 "parse.y" { if(strcmp(yyvsp[-2].id,"check")!=0) { yyerror(_("parse error")); @@ -2062,15 +2073,15 @@ case 106: ; break;} case 107: -#line 937 "parse.y" +#line 948 "parse.y" { ; ; break;} case 108: -#line 938 "parse.y" +#line 949 "parse.y" { ; ; break;} case 109: -#line 941 "parse.y" +#line 952 "parse.y" { if(strcmp(yyvsp[0].id,"type")==0) { Node *node = new_check(TYPE_CHECK,NULL); @@ -2086,60 +2097,60 @@ case 109: ; break;} case 110: -#line 954 "parse.y" +#line 965 "parse.y" { Node *node = new_check(GT_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} case 111: -#line 958 "parse.y" +#line 969 "parse.y" { Node *node = new_check(LT_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} case 112: -#line 962 "parse.y" +#line 973 "parse.y" { Node *node = new_check(GE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} case 113: -#line 966 "parse.y" +#line 977 "parse.y" { Node *node = new_check(LE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} case 114: -#line 970 "parse.y" +#line 981 "parse.y" { Node *node = new_check(EQ_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} case 115: -#line 974 "parse.y" +#line 985 "parse.y" { Node *node = new_check(NE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} case 116: -#line 980 "parse.y" +#line 991 "parse.y" { yyval.id = yyvsp[0].id; ; break;} case 117: -#line 981 "parse.y" +#line 992 "parse.y" { yyval.id = g_strconcat("-",yyvsp[0].id,NULL); g_free(yyvsp[0].id); ; break;} case 118: -#line 985 "parse.y" +#line 996 "parse.y" { yyval.id = yyvsp[0].id; ; break;} } @@ -2364,5 +2375,5 @@ yyerrhandle: } return 1; } -#line 988 "parse.y" +#line 999 "parse.y" diff --git a/src/parse.y b/src/parse.y index 192e4c4..0161aea 100644 --- a/src/parse.y +++ b/src/parse.y @@ -137,11 +137,22 @@ push_function(int scope, int method, char *oid, char *id, g_list_length(gtktypes) != g_list_length(funcargs) && !(g_list_length(funcargs) == 1 && g_list_length(gtktypes) == 2 && - strcmp(gtktypes->next->data,"NONE")==0)) { + strcmp(gtktypes->next->data, "NONE")==0)) { print_error(TRUE, _("The number of GTK arguments and " "function arguments for a signal " "don't seem to match"), line_no); } + if(g_list_length(gtktypes) > 2) { + GList *li; + for(li = gtktypes->next; li; li = li->next) { + if(strcmp(li->data, "NONE")==0) { + print_error(FALSE, + _("NONE can only appear in an " + "argument list by itself"), + line_no); + } + } + } if(cbuf) { char *p; c_cbuf = p = cbuf->str; diff --git a/src/test.gob b/src/test.gob index edf2249..98d8614 100644 --- a/src/test.gob +++ b/src/test.gob @@ -277,6 +277,14 @@ class Gtk:Weird:Button from Gtk:Button { /*foo*/ return w; } + + /* testing NONE */ + signal BOOL (NONE) + gboolean + test_none_thing (self) + { + return FALSE; + } /* testing empty statements */ ; ; -- 2.43.0