From 6d0fe9d5f8c513045bf064ea256c822beac19037 Mon Sep 17 00:00:00 2001 From: George Lebl Date: Tue, 28 Dec 1999 08:36:00 -0800 Subject: [PATCH] Release 0.91.2 --- ChangeLog | 39 ++- NEWS | 6 + configure | 2 +- configure.in | 2 +- doc/gob.1.in | 41 ++- gob.spec | 2 +- src/lexer.c | 17 +- src/lexer.l | 3 +- src/main.c | 45 ++- src/parse.c | 772 +++++++++++++++++++++++++++------------------------ src/parse.y | 44 ++- src/test.gob | 18 +- 12 files changed, 603 insertions(+), 388 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03252a3..184c00a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +Mon Dec 27 19:56:24 1999 George Lebl + + * Release 0.91.2 + +Mon Dec 27 03:00:25 1999 George Lebl + + * src/main.c: fixup PARENT_HANDLER to work well with non-void + functions, the macro becomes an expression if the function is + not void and returns the return of the parent or the onerror + expression if the function pointer was NULL. + +Mon Dec 27 02:25:32 1999 George Lebl + + * src/parse.y: allow completely empty classes + + * src/main.c: don't add the ugly hack function if there are no + methods + +Mon Dec 27 01:26:26 1999 George Lebl + + * src/parse.y: fixup the virtual rule as I forgot to shift the + argument numbers when adding to the expression + +Mon Dec 27 01:07:14 1999 George Lebl + + * src/parse.y: add optional public keyword to virtuals and signals, + (which doesn't do anything, only consistency). I should perhaps + rewrite and simplify this part of the parser + + * src/lexer.l: fix a bug with empty braces producing a segfault + on public and private methods + + * doc/gob.1.in: add a section about Constructor methods (init + class_init) and fix init_class -> class_init + + * configure.in: raise version to 0.91.2 + Tue Dec 14 00:06:00 1999 George Lebl * Release 0.91.1 @@ -217,7 +254,7 @@ Thu Aug 19 03:18:03 1999 George Lebl Thu Aug 19 03:08:49 1999 George Lebl - * src/parse.y: in a check, we can check not only about nubmers + * src/parse.y: in a check, we can check not only about numbers but for tokens as well Wed Aug 18 12:54:17 1999 George Lebl diff --git a/NEWS b/NEWS index 20357b1..ea6407c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +0.91.2 + * PARENT_HANDLER can now return a value for non-void overrides + * allow empty classes and empty function bodies + * allow public keyword around signals and virtuals for consistency + * small bugfixes + 0.91.1 * WARNING! slight change in the private stuff again, private structure definition (_priv) is now in a private header file, diff --git a/configure b/configure index 8253303..9eeee38 100755 --- a/configure +++ b/configure @@ -703,7 +703,7 @@ fi PACKAGE=gob -VERSION=0.91.1 +VERSION=0.91.2 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 f2ad73d..adf05d6 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/tree.h) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(gob,0.91.1) +AM_INIT_AUTOMAKE(gob,0.91.2) if test -f ../NOINST_GOB ; then DOINSTGOB= diff --git a/doc/gob.1.in b/doc/gob.1.in index 9cada9a..fa5dd9b 100644 --- a/doc/gob.1.in +++ b/doc/gob.1.in @@ -201,6 +201,8 @@ without the GTK_ARG_ prefix. For example: argument (CONSTRUCT) INT height get { ARG = self->height; }; .fi +This makes the argument settable even before the object is constructed, so +that people can pass it to gtk_object_new function. .PP Methods: .PP @@ -209,12 +211,12 @@ There is a whole array of possible methods. The two normal, normal functions with a prototype in the header file. Private methods are defined as static functions with prototypes at the top of the .c file. Then there are signal, virtual and override methods. You can also -define init and init_class methods with a special definition if you want +define init and class_init methods with a special definition if you want to add code to the constructors or you can just leave them out. .PP Argument lists: .PP -For all but the init and init_class methods, you use the +For all but the init and class_init methods, you use the following syntax for arguments. The first argument can be just "self", which gob will translate into a pointer to the object instance. The rest of the arguments are very similar to normal C arguments. If the @@ -251,7 +253,7 @@ default is 0, casted to the type of the method. If you need to return something else then you can specify an "onerror" keyword after the prototype and after that a number, a token (an identifier) or a bit of C code enclosed in braces {}. The braces will not be printed into the -output, they just delimit the string. For example +output, they just delimit the string. For example: .nf public void * get_something(self, int i (check >= 0)) onerror NULL { @@ -260,6 +262,36 @@ output, they just delimit the string. For example .fi .PP +Constructor methods: +.PP +There are two methods that handle the cosntruction of an object, init and +class_init. You define them by just using the init or class_init keyword +with an untyped argument in the argument list. The argument will be +usable in your function as a pointer to your object or class depending if +it's init or class_init. +For example: +.nf + + init(object) { + /* initialize the object here */ + object->a = 9; + object->b = 9; + } + + class_init(class) { + /* initialize the class, this is rarely needed */ + class->blah = NULL; + } + +.fi +The class_init function is very rarely needed as all standard class +initialization is taken care of for you by gob itself. The init function +should on the other hand be used whenever you need to construct or initialize +anything in the object to put it into a sane state. Sometimes you need +some arguments, for this you should either use a construct method and a +new function like many GTK+ widgets, and/or a CONSTRUCT or CONSTRUCT_ONLY +type of an argument. +.PP Virtual methods: .PP Virtual methods are basically pointers in the class structure, @@ -329,6 +361,9 @@ class, you can use the PARENT_HANDLER macro with your arguments. Example: } .fi +If the function has a return value, then PARENT_HANDLER is an expression that +you can use. It will return whatever the parent handler returned, or the +"onerror" expression if there was no parent handler. .PP Calling methods: .PP diff --git a/gob.spec b/gob.spec index 764f38a..86e0d2b 100644 --- a/gob.spec +++ b/gob.spec @@ -1,4 +1,4 @@ -%define ver 0.91.1 +%define ver 0.91.2 %define rel 1 %define prefix /usr diff --git a/src/lexer.c b/src/lexer.c index e500aae..a2c7013 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -1382,14 +1382,15 @@ YY_RULE_SETUP BEGIN(C_CODE); parenth_depth=1; class_after_c = TRUE; - ccode_line = line_no; yylval.line = line_no; + clear_cbuf(); + ccode_line = line_no; return '{'; } YY_BREAK case 64: YY_RULE_SETUP -#line 265 "lexer.l" +#line 266 "lexer.l" { BEGIN(INITIAL); return '}'; @@ -1397,12 +1398,12 @@ YY_RULE_SETUP YY_BREAK case 65: YY_RULE_SETUP -#line 270 "lexer.l" +#line 271 "lexer.l" ; /*ignore*/ YY_BREAK case 66: YY_RULE_SETUP -#line 272 "lexer.l" +#line 273 "lexer.l" { yylval.line = line_no; return yytext[0]; @@ -1410,15 +1411,15 @@ YY_RULE_SETUP YY_BREAK case 67: YY_RULE_SETUP -#line 277 "lexer.l" +#line 278 "lexer.l" ; /*ignore*/ YY_BREAK case 68: YY_RULE_SETUP -#line 278 "lexer.l" +#line 279 "lexer.l" ECHO; YY_BREAK -#line 1422 "lex.yy.c" +#line 1423 "lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(C_CODE): @@ -2305,4 +2306,4 @@ int main() return 0; } #endif -#line 278 "lexer.l" +#line 279 "lexer.l" diff --git a/src/lexer.l b/src/lexer.l index 35e42cc..448da95 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -258,8 +258,9 @@ class { BEGIN(C_CODE); parenth_depth=1; class_after_c = TRUE; - ccode_line = line_no; yylval.line = line_no; + clear_cbuf(); + ccode_line = line_no; return '{'; } \} { diff --git a/src/main.c b/src/main.c index 3a16554..751c064 100644 --- a/src/main.c +++ b/src/main.c @@ -60,6 +60,10 @@ static int arguments = 0; /* number of named arguments */ static int overrides = 0; /* number of override functions */ static int privates = 0; /* number of private data members */ +static gboolean made_aliases = FALSE; /* if we made any shorthand aliases + and need the REALLY UGLY HACK to + avoid warnings */ + FILE *out = NULL; FILE *outh = NULL; FILE *outph = NULL; @@ -269,6 +273,8 @@ make_method_pointers(Class *c) print_method(out,"static ","(* ",") ","",m,TRUE); out_printf(out," = %s_%s;\n",funcbase,m->id); + + made_aliases = TRUE; } } out_printf(out,"\n"); @@ -278,6 +284,10 @@ static void add_bad_hack_to_avoid_unused_warnings(Class *c) { GList *li; + + /* if we haven't had any methods, just return */ + if(!made_aliases) + return; out_printf(out,"\n\n/*REALLY BAD HACK\n" " This is to avoid unused warnings if you don't call\n" @@ -356,13 +366,13 @@ put_priv_method_prot(Method *m) if(m->scope == PRIVATE_SIGNAL_LAST_METHOD || m->scope == PRIVATE_SIGNAL_FIRST_METHOD || m->scope == PRIVATE_VIRTUAL_METHOD) { - if(m->cbuf) + if(m->cbuf && *m->cbuf->str) print_method(out,"static ","_real_"," ",";\n",m,FALSE); print_method(out,"static ",""," ",";\n",m,FALSE); } else if(m->scope == SIGNAL_LAST_METHOD || m->scope == SIGNAL_FIRST_METHOD || m->scope == VIRTUAL_METHOD) { - if(!m->cbuf) + if(!m->cbuf || !*m->cbuf->str) return; print_method(out,"static ","_real_"," ",";\n",m,FALSE); } else { @@ -774,7 +784,7 @@ set_def_handlers(Class *c, char *oname) out_printf(out,"\t%s_class->%s = %s_%s;\n", s,m->id,funcbase,m->id); } else { - if(m->cbuf) + if(m->cbuf && *m->cbuf->str) out_printf(out,"\t%s->%s = _real_%s_%s;\n", oname,m->id,funcbase,m->id); else @@ -887,7 +897,7 @@ add_inits(Class *c) } else continue; - if(m->cbuf) { + if(m->cbuf && *m->cbuf->str) { out_printf(out," {\n"); out_addline_infile(out,m->ccode_line); out_printf(out,"%s\n",m->cbuf->str); @@ -1055,6 +1065,9 @@ put_method(Method *m) { char *s; int private = FALSE; + int is_void; + is_void = (strcmp(m->mtype->name,"void")==0 && + m->mtype->stars == 0); out_printf(out,"\n"); switch(m->scope) { case PUBLIC_SCOPE: @@ -1108,7 +1121,7 @@ put_method(Method *m) "\treturn return_val;\n}\n"); } - if(!m->cbuf) + if(!m->cbuf || !*m->cbuf->str) break; out_addline_infile(out,m->line_no); print_method(out,"static ","\n_real_"," ","\n",m,FALSE); @@ -1152,7 +1165,7 @@ put_method(Method *m) m->onerror?m->onerror:"0"); } - if(!m->cbuf) + if(!m->cbuf || !*m->cbuf->str) break; out_addline_infile(out,m->line_no); print_method(out,"static ","\n_real_"," ","\n",m,FALSE); @@ -1163,10 +1176,22 @@ put_method(Method *m) print_method(out,"static ","\n"," ","\n",m,FALSE); s = replace_sep(m->otype,'_'); g_strup(s); - out_printf(out,"#define PARENT_HANDLER(args...) \\\n" - "\t{ if(%s_CLASS(parent_class)->%s) \\\n" - "\t\t(* %s_CLASS(parent_class)->%s)(##args); }\n", - s,m->id,s,m->id); + if(is_void) { + out_printf(out,"#define PARENT_HANDLER(args...) \\\n" + "\t{ if(%s_CLASS(parent_class)->%s) \\\n" + "\t\t(* %s_CLASS(parent_class)->%s)(##args); }\n", + s,m->id,s,m->id); + } else { + out_printf(out,"#define PARENT_HANDLER(args...) \\\n" + "\t((%s_CLASS(parent_class)->%s)? \\\n" + "\t\t(* %s_CLASS(parent_class)->%s)(##args): \\\n" + "\t\t(", + s,m->id,s,m->id); + out_printf(out,"("); + print_type(out,m->mtype,TRUE); + out_printf(out,")%s))\n", + m->onerror?m->onerror:"0"); + } g_free(s); print_method_body(m,TRUE); out_printf(out,"#undef PARENT_HANDLER\n"); diff --git a/src/parse.c b/src/parse.c index f8593b9..1d226c4 100644 --- a/src/parse.c +++ b/src/parse.c @@ -213,11 +213,11 @@ typedef union { -#define YYFINAL 207 +#define YYFINAL 216 #define YYFLAG -32768 #define YYNTBASE 46 -#define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 74) +#define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 75) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -254,70 +254,74 @@ static const char yytranslate[] = { 0, #if YYDEBUG != 0 static const short yyprhs[] = { 0, 0, 4, 7, 10, 12, 15, 18, 20, 22, 27, - 32, 35, 38, 41, 43, 45, 47, 52, 58, 63, - 69, 81, 90, 94, 95, 99, 101, 103, 106, 108, - 111, 114, 117, 119, 122, 125, 127, 129, 131, 133, - 136, 138, 140, 143, 145, 148, 150, 152, 154, 156, - 158, 161, 163, 167, 171, 174, 177, 179, 184, 188, - 190, 193, 195, 205, 215, 224, 237, 247, 257, 263, - 266, 270, 273, 274, 276, 278, 282, 284, 288, 290, - 294, 296, 299, 303, 310, 318, 321, 323, 325, 328, - 331, 335, 339, 343, 347, 349, 352 + 31, 36, 39, 42, 45, 47, 49, 51, 56, 62, + 67, 73, 85, 94, 98, 99, 103, 105, 107, 110, + 112, 115, 118, 121, 123, 126, 129, 131, 133, 135, + 137, 140, 142, 144, 147, 149, 152, 154, 156, 158, + 160, 162, 165, 167, 168, 170, 174, 178, 181, 184, + 188, 192, 195, 197, 202, 206, 208, 211, 213, 223, + 233, 243, 256, 266, 276, 282, 285, 289, 292, 293, + 295, 297, 301, 303, 307, 309, 313, 315, 318, 322, + 329, 337, 340, 342, 344, 347, 350, 354, 358, 362, + 366, 368, 371 }; static const short yyrhs[] = { 47, 48, 47, 0, 48, 47, 0, 47, 48, 0, 48, 0, 47, 24, 0, 47, 25, 0, 24, 0, 25, - 0, 49, 32, 50, 33, 0, 3, 22, 4, 22, - 0, 50, 65, 0, 50, 51, 0, 50, 52, 0, - 65, 0, 51, 0, 52, 0, 26, 55, 20, 34, - 0, 26, 55, 20, 23, 34, 0, 27, 55, 20, - 34, 0, 27, 55, 20, 23, 34, 0, 28, 53, - 20, 20, 20, 32, 24, 20, 32, 24, 34, 0, - 28, 53, 20, 20, 20, 32, 24, 34, 0, 35, - 54, 36, 0, 0, 20, 37, 54, 0, 20, 0, - 56, 0, 5, 56, 0, 57, 0, 57, 60, 0, - 12, 58, 0, 11, 58, 0, 58, 0, 12, 18, - 0, 11, 18, 0, 18, 0, 17, 0, 16, 0, - 20, 0, 59, 20, 0, 22, 0, 6, 0, 13, - 15, 0, 13, 0, 14, 15, 0, 14, 0, 15, - 0, 9, 0, 8, 0, 7, 0, 38, 60, 0, - 38, 0, 27, 20, 62, 0, 20, 27, 62, 0, - 27, 62, 0, 20, 62, 0, 62, 0, 20, 35, - 63, 36, 0, 63, 39, 20, 0, 20, 0, 32, - 24, 0, 34, 0, 30, 61, 55, 20, 35, 67, - 36, 66, 64, 0, 29, 27, 55, 20, 35, 67, - 36, 66, 64, 0, 29, 55, 20, 35, 67, 36, - 66, 64, 0, 31, 35, 22, 36, 55, 20, 35, - 67, 36, 66, 32, 24, 0, 26, 55, 20, 35, - 67, 36, 66, 32, 24, 0, 27, 55, 20, 35, - 67, 36, 66, 32, 24, 0, 20, 35, 20, 36, - 64, 0, 19, 73, 0, 19, 32, 24, 0, 40, - 41, 0, 0, 6, 0, 20, 0, 20, 39, 68, - 0, 68, 0, 69, 39, 10, 0, 69, 0, 69, - 39, 70, 0, 70, 0, 55, 20, 0, 55, 20, - 23, 0, 55, 20, 35, 20, 71, 36, 0, 55, - 20, 23, 35, 20, 71, 36, 0, 71, 72, 0, - 72, 0, 20, 0, 42, 73, 0, 43, 73, 0, - 42, 40, 73, 0, 43, 40, 73, 0, 40, 40, - 73, 0, 44, 40, 73, 0, 21, 0, 45, 21, - 0, 20, 0 + 0, 49, 32, 50, 33, 0, 49, 32, 33, 0, + 3, 22, 4, 22, 0, 50, 66, 0, 50, 51, + 0, 50, 52, 0, 66, 0, 51, 0, 52, 0, + 26, 55, 20, 34, 0, 26, 55, 20, 23, 34, + 0, 27, 55, 20, 34, 0, 27, 55, 20, 23, + 34, 0, 28, 53, 20, 20, 20, 32, 24, 20, + 32, 24, 34, 0, 28, 53, 20, 20, 20, 32, + 24, 34, 0, 35, 54, 36, 0, 0, 20, 37, + 54, 0, 20, 0, 56, 0, 5, 56, 0, 57, + 0, 57, 60, 0, 12, 58, 0, 11, 58, 0, + 58, 0, 12, 18, 0, 11, 18, 0, 18, 0, + 17, 0, 16, 0, 20, 0, 59, 20, 0, 22, + 0, 6, 0, 13, 15, 0, 13, 0, 14, 15, + 0, 14, 0, 15, 0, 9, 0, 8, 0, 7, + 0, 38, 60, 0, 38, 0, 0, 26, 0, 27, + 20, 63, 0, 20, 27, 63, 0, 27, 63, 0, + 20, 63, 0, 26, 20, 63, 0, 20, 26, 63, + 0, 26, 63, 0, 63, 0, 20, 35, 64, 36, + 0, 64, 39, 20, 0, 20, 0, 32, 24, 0, + 34, 0, 30, 62, 55, 20, 35, 68, 36, 67, + 65, 0, 29, 27, 55, 20, 35, 68, 36, 67, + 65, 0, 29, 61, 55, 20, 35, 68, 36, 67, + 65, 0, 31, 35, 22, 36, 55, 20, 35, 68, + 36, 67, 32, 24, 0, 26, 55, 20, 35, 68, + 36, 67, 32, 24, 0, 27, 55, 20, 35, 68, + 36, 67, 32, 24, 0, 20, 35, 20, 36, 65, + 0, 19, 74, 0, 19, 32, 24, 0, 40, 41, + 0, 0, 6, 0, 20, 0, 20, 39, 69, 0, + 69, 0, 70, 39, 10, 0, 70, 0, 70, 39, + 71, 0, 71, 0, 55, 20, 0, 55, 20, 23, + 0, 55, 20, 35, 20, 72, 36, 0, 55, 20, + 23, 35, 20, 72, 36, 0, 72, 73, 0, 73, + 0, 20, 0, 42, 74, 0, 43, 74, 0, 42, + 40, 74, 0, 43, 40, 74, 0, 40, 40, 74, + 0, 44, 40, 74, 0, 21, 0, 45, 21, 0, + 20, 0 }; #endif #if YYDEBUG != 0 static const short yyrline[] = { 0, - 197, 198, 199, 200, 203, 207, 211, 215, 221, 228, - 233, 234, 235, 236, 237, 238, 241, 244, 247, 250, - 254, 283, 309, 310, 313, 316, 322, 323, 331, 335, - 342, 345, 348, 351, 354, 357, 360, 363, 366, 369, - 373, 376, 381, 384, 387, 390, 393, 398, 401, 404, - 409, 410, 413, 425, 437, 440, 452, 457, 462, 465, - 470, 471, 475, 485, 495, 505, 511, 516, 521, 542, - 543, 547, 548, 551, 552, 563, 573, 576, 577, 580, - 581, 584, 587, 590, 598, 608, 609, 612, 625, 629, - 633, 637, 641, 645, 651, 652, 656 + 197, 198, 199, 200, 203, 207, 211, 215, 221, 226, + 233, 238, 239, 240, 241, 242, 243, 246, 249, 252, + 255, 259, 288, 314, 315, 318, 321, 327, 328, 336, + 340, 347, 350, 353, 356, 359, 362, 365, 368, 371, + 374, 378, 381, 386, 389, 392, 395, 398, 403, 406, + 409, 414, 415, 418, 419, 422, 434, 446, 449, 461, + 473, 485, 488, 493, 498, 501, 506, 507, 511, 521, + 531, 541, 547, 552, 557, 578, 579, 583, 584, 587, + 588, 599, 609, 612, 613, 616, 617, 620, 623, 626, + 634, 644, 645, 648, 661, 665, 669, 673, 677, 681, + 687, 688, 692 }; #endif @@ -331,161 +335,165 @@ static const char * const yytname[] = { "$","error","$undefined.","CLASS", "OVERRIDE","'{'","'}'","';'","'('","')'","'|'","'*'","','","'='","'1'","'>'", "'<'","'!'","'-'","prog","ccodes","class","classdec","classcode","variable", "argument","argflags","flaglist","type","type1","type2","integer","tspecifier", -"stars","fullsigtype","sigtype","tokenlist","codenocode","method","onerror", -"funcargs","arglist","arglist1","arg","checklist","check","numtok", NULL +"stars","optpublic","fullsigtype","sigtype","tokenlist","codenocode","method", +"onerror","funcargs","arglist","arglist1","arg","checklist","check","numtok", NULL }; #endif static const short yyr1[] = { 0, - 46, 46, 46, 46, 47, 47, 47, 47, 48, 49, - 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, - 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, - 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, - 57, 57, 58, 58, 58, 58, 58, 59, 59, 59, - 60, 60, 61, 61, 61, 61, 61, 62, 63, 63, - 64, 64, 65, 65, 65, 65, 65, 65, 65, 66, - 66, 66, 66, 67, 67, 67, 67, 68, 68, 69, - 69, 70, 70, 70, 70, 71, 71, 72, 72, 72, - 72, 72, 72, 72, 73, 73, 73 + 46, 46, 46, 46, 47, 47, 47, 47, 48, 48, + 49, 50, 50, 50, 50, 50, 50, 51, 51, 51, + 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, + 56, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 57, 57, 57, 58, 58, 58, 58, 58, 59, 59, + 59, 60, 60, 61, 61, 62, 62, 62, 62, 62, + 62, 62, 62, 63, 64, 64, 65, 65, 66, 66, + 66, 66, 66, 66, 66, 67, 67, 67, 67, 68, + 68, 68, 68, 69, 69, 70, 70, 71, 71, 71, + 71, 72, 72, 73, 73, 73, 73, 73, 73, 73, + 74, 74, 74 }; static const short yyr2[] = { 0, - 3, 2, 2, 1, 2, 2, 1, 1, 4, 4, - 2, 2, 2, 1, 1, 1, 4, 5, 4, 5, - 11, 8, 3, 0, 3, 1, 1, 2, 1, 2, - 2, 2, 1, 2, 2, 1, 1, 1, 1, 2, - 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, - 2, 1, 3, 3, 2, 2, 1, 4, 3, 1, - 2, 1, 9, 9, 8, 12, 9, 9, 5, 2, - 3, 2, 0, 1, 1, 3, 1, 3, 1, 3, - 1, 2, 3, 6, 7, 2, 1, 1, 2, 2, - 3, 3, 3, 3, 1, 2, 1 + 3, 2, 2, 1, 2, 2, 1, 1, 4, 3, + 4, 2, 2, 2, 1, 1, 1, 4, 5, 4, + 5, 11, 8, 3, 0, 3, 1, 1, 2, 1, + 2, 2, 2, 1, 2, 2, 1, 1, 1, 1, + 2, 1, 1, 2, 1, 2, 1, 1, 1, 1, + 1, 2, 1, 0, 1, 3, 3, 2, 2, 3, + 3, 2, 1, 4, 3, 1, 2, 1, 9, 9, + 9, 12, 9, 9, 5, 2, 3, 2, 0, 1, + 1, 3, 1, 3, 1, 3, 1, 2, 3, 6, + 7, 2, 1, 1, 2, 2, 3, 3, 3, 3, + 1, 2, 1 }; static const short yydefact[] = { 0, 0, 7, 8, 0, 4, 0, 0, 5, 6, 3, - 2, 0, 0, 1, 0, 0, 0, 24, 0, 0, - 0, 0, 15, 16, 14, 10, 0, 0, 42, 50, - 49, 48, 0, 0, 44, 46, 47, 38, 37, 36, - 39, 41, 0, 27, 29, 33, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 57, 0, 9, 12, 13, - 11, 0, 28, 35, 32, 34, 31, 43, 45, 0, - 52, 30, 40, 0, 26, 0, 0, 0, 0, 0, - 0, 0, 56, 0, 55, 0, 0, 0, 0, 17, - 0, 51, 0, 19, 0, 0, 23, 0, 0, 0, - 54, 60, 0, 53, 0, 0, 0, 62, 69, 18, - 42, 39, 0, 0, 77, 79, 81, 20, 0, 25, - 0, 0, 0, 58, 0, 0, 0, 61, 0, 82, - 73, 0, 73, 0, 0, 73, 59, 0, 0, 76, - 83, 0, 0, 0, 0, 78, 80, 0, 0, 73, - 0, 73, 0, 0, 0, 97, 95, 0, 0, 70, - 72, 0, 0, 0, 22, 0, 65, 0, 0, 0, - 88, 0, 0, 0, 0, 0, 87, 71, 96, 67, - 68, 0, 64, 63, 73, 0, 0, 0, 89, 0, - 90, 0, 84, 86, 0, 0, 85, 93, 91, 92, - 94, 21, 0, 66, 0, 0, 0 + 2, 0, 0, 1, 0, 0, 0, 25, 54, 0, + 0, 10, 0, 16, 17, 15, 11, 0, 0, 43, + 51, 50, 49, 0, 0, 45, 47, 48, 39, 38, + 37, 40, 42, 0, 28, 30, 34, 0, 0, 0, + 0, 55, 0, 0, 0, 0, 0, 0, 63, 0, + 9, 13, 14, 12, 0, 29, 36, 33, 35, 32, + 44, 46, 0, 53, 31, 41, 0, 27, 0, 0, + 0, 0, 0, 0, 0, 0, 59, 0, 62, 0, + 58, 0, 0, 0, 0, 18, 0, 52, 0, 20, + 0, 0, 24, 0, 0, 0, 61, 57, 66, 0, + 60, 56, 0, 0, 0, 68, 75, 19, 43, 40, + 0, 0, 83, 85, 87, 21, 0, 26, 0, 0, + 0, 64, 0, 0, 0, 67, 0, 88, 79, 0, + 79, 0, 0, 0, 65, 0, 0, 82, 89, 0, + 0, 0, 0, 84, 86, 0, 0, 79, 79, 79, + 0, 0, 0, 103, 101, 0, 0, 76, 78, 0, + 0, 0, 23, 0, 0, 0, 0, 0, 94, 0, + 0, 0, 0, 0, 93, 77, 102, 73, 74, 0, + 70, 71, 69, 79, 0, 0, 0, 95, 0, 96, + 0, 90, 92, 0, 0, 91, 99, 97, 98, 100, + 22, 0, 72, 0, 0, 0 }; -static const short yydefgoto[] = { 205, - 4, 5, 6, 22, 23, 24, 50, 76, 113, 44, - 45, 46, 47, 72, 55, 56, 103, 109, 25, 145, - 114, 115, 116, 117, 176, 177, 160 +static const short yydefgoto[] = { 214, + 4, 5, 6, 23, 24, 25, 51, 79, 121, 45, + 46, 47, 48, 75, 54, 58, 59, 110, 117, 26, + 153, 122, 123, 124, 125, 184, 185, 168 }; -static const short yypact[] = { 3, - 47,-32768,-32768, 70, 169, 94, 75,-32768,-32768, 169, - 182, 171, 79, 182, 100, 125, 125, 109, 69, 77, - 111, 159,-32768,-32768,-32768,-32768, 108, 160,-32768,-32768, --32768,-32768, 190, 196, 138, 147,-32768,-32768,-32768,-32768, --32768,-32768, 144,-32768, 132,-32768, 163, 193, 197, 198, - 125, 199, 32, 200, 125,-32768, 194,-32768,-32768,-32768, --32768, 145,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 65, - 132,-32768,-32768, 161, 184, 186, 203, 204, 191, 192, - 205, 208,-32768, 26,-32768, 209, 195, 76, 201,-32768, - 143,-32768, 202,-32768, 143, 197,-32768, 210, 206, 143, --32768,-32768, 66,-32768, 207, 125, 213,-32768,-32768,-32768, - 211, 176, 212, 214,-32768, 215,-32768,-32768, 216,-32768, - 217, 143, 219,-32768, 218, 143, 220,-32768, 125, 21, - -6, 107, -6, 221, 222, -6,-32768, 223, 225,-32768, - 226, 224, -9, 227, 230,-32768,-32768, 231, 29, -6, - 76, -6, 143, 228, 28,-32768,-32768, 229, 235,-32768, --32768, 233, 240, 234,-32768, 76,-32768, 76, 236, 28, --32768, 237, -2, 5, 238, 11,-32768,-32768,-32768,-32768, --32768, 241,-32768,-32768, -6, 22, -4, -4,-32768, -4, --32768, -4,-32768,-32768, 239, 242,-32768,-32768,-32768,-32768, --32768,-32768, 243,-32768, 246, 251,-32768 +static const short yypact[] = { 43, + 1,-32768,-32768, 56, 28, 39, 72,-32768,-32768, 28, + 177, 152, 69, 177, 61, 118, 118, 68, 181, 66, + 84,-32768, 164,-32768,-32768,-32768,-32768, 81, 153,-32768, +-32768,-32768,-32768, 185, 191, 106, 113,-32768,-32768,-32768, +-32768,-32768,-32768, 117,-32768, 101,-32768, 126, 135, 137, + 143,-32768, 118, 118, 62, 156, 169, 118,-32768, 174, +-32768,-32768,-32768,-32768, 178,-32768,-32768,-32768,-32768,-32768, +-32768,-32768, 13, 101,-32768,-32768, 60, 175, 179, 193, + 196, 197, 183, 199, 199, 200,-32768, 34,-32768, 34, +-32768, 201, 186, 26, 189,-32768, 136,-32768, 190,-32768, + 136, 137,-32768, 205, 192, 194,-32768,-32768,-32768, 51, +-32768,-32768, 195, 118, 202,-32768,-32768,-32768, 198, 138, + 208, 203,-32768, 204,-32768,-32768, 206,-32768, 209, 136, + 136,-32768, 211, 136, 212,-32768, 118, -19, -6, 100, + -6, 213, 210, 214,-32768, 215, 217,-32768, 218, 216, + -15, 207, 222,-32768,-32768, 223, -5, -6, -6, -6, + 136, 220, 35,-32768,-32768, 221, 226,-32768,-32768, 225, + 232, 227,-32768, 26, 26, 26, 224, 35,-32768, 228, + -12, 4, 229, 21,-32768,-32768,-32768,-32768,-32768, 233, +-32768,-32768,-32768, -6, 30, 6, 6,-32768, 6,-32768, + 6,-32768,-32768, 230, 231,-32768,-32768,-32768,-32768,-32768, +-32768, 234,-32768, 235, 238,-32768 }; static const short yypgoto[] = {-32768, - 93, 265,-32768,-32768, 248, 249,-32768, 137, -16, 247, --32768, -13,-32768, 168,-32768, -44,-32768, -136, 254, -128, - -93, 105,-32768, 148, 73, -172, -81 + 9, 240,-32768,-32768, 239, 242,-32768, 131, -16, 237, +-32768, 176,-32768, 187,-32768,-32768, -45,-32768, 12, 244, + -138, -99, 133,-32768, 132, 93, -177, -97 }; -#define YYLAST 280 - - -static const short yytable[] = { 43, - 48, 119, 52, 194, 148, 1, 123, 151, 83, 85, - 156, 157, 143, 194, 167, 156, 157, 156, 157, 65, - 67, 166, 158, 168, 156, 157, 2, 3, 135, 183, - 171, 184, 138, 144, 78, 159, 101, 188, 86, 104, - 159, 171, 159, 141, 190, 80, 193, 171, 164, 159, - 172, 80, 173, 174, 175, 142, 196, 197, 81, 169, - 82, 172, 165, 173, 174, 175, 82, 172, 7, 173, - 174, 175, 1, 28, 29, 30, 31, 32, 13, 33, - 34, 35, 36, 37, 38, 39, 40, 89, 41, 127, - 42, 189, 191, 8, 9, 51, 53, 11, 90, 91, - 26, 124, 14, 54, 125, 198, 199, 107, 200, 108, - 201, 28, 29, 30, 31, 32, 146, 33, 34, 35, - 36, 37, 38, 39, 40, 12, 41, 62, 42, 28, - 29, 30, 31, 32, 27, 33, 34, 35, 36, 37, - 38, 39, 40, 49, 41, 57, 42, 28, 111, 30, - 31, 32, 68, 33, 34, 35, 36, 37, 38, 39, - 40, 69, 112, 70, 42, 29, 30, 31, 32, 71, - 33, 34, 35, 36, 37, 38, 39, 40, 15, 41, - 88, 42, 73, 93, 16, 17, 18, 19, 20, 21, - 15, 58, 2, 3, 94, 95, 16, 17, 18, 19, - 20, 21, 35, 36, 37, 8, 9, 64, 35, 36, - 37, -75, 74, 66, 129, 87, 75, 77, 79, 84, - 96, 97, 98, 99, 80, 100, 82, 102, 105, 121, - 106, 130, 120, 140, 110, 118, 128, 137, 92, 139, - 122, 126, 186, 155, 149, 206, -74, 170, 134, 131, - 207, 133, 178, 132, 136, 179, 180, 150, 152, 153, - 154, 162, 163, 181, 195, 182, 204, 161, 10, 59, - 60, 185, 202, 203, 63, 61, 187, 192, 0, 147 +#define YYLAST 272 + + +static const short yytable[] = { 44, + 49, 127, 156, 149, 164, 165, 203, 164, 165, 87, + 89, 91, 151, 11, 172, 150, 166, 203, 14, 174, + 175, 176, 7, 164, 165, 164, 165, 197, 173, 167, + 143, 144, 167, 152, 146, 95, 81, 82, 107, 108, + 179, 92, 111, 199, 112, 1, 96, 97, 167, 179, + 167, 2, 3, 83, 179, 205, 202, 115, 1, 116, + 180, 177, 181, 182, 183, 206, 2, 3, 86, 180, + 12, 181, 182, 183, 180, 13, 181, 182, 183, 8, + 9, 83, 99, 198, 200, 55, 132, 84, 85, 133, + 27, 56, 57, 100, 101, 28, 86, 135, 207, 208, + 65, 209, 50, 210, 29, 30, 31, 32, 33, 154, + 34, 35, 36, 37, 38, 39, 40, 41, 60, 42, + 71, 43, 29, 30, 31, 32, 33, 72, 34, 35, + 36, 37, 38, 39, 40, 41, 73, 42, 74, 43, + 29, 119, 31, 32, 33, 76, 34, 35, 36, 37, + 38, 39, 40, 41, 77, 120, 78, 43, 30, 31, + 32, 33, 80, 34, 35, 36, 37, 38, 39, 40, + 41, 15, 42, -81, 43, 88, 137, 16, 17, 18, + 19, 20, 21, 15, 22, 191, 192, 193, 90, 16, + 17, 18, 19, 20, 21, 93, 61, 36, 37, 38, + 8, 9, 67, 36, 37, 38, 52, 53, 69, 68, + 70, 102, 104, 94, 103, 105, 106, 86, 83, 109, + 113, 114, 118, 126, 129, 136, 130, 138, 131, 134, + 145, 147, 128, -80, 215, 163, 157, 216, 139, 178, + 142, 141, 140, 10, 186, 158, 187, 169, 188, 159, + 160, 161, 162, 170, 171, 189, 204, 213, 190, 194, + 98, 62, 212, 211, 63, 66, 64, 196, 201, 148, + 195, 155 }; static const short yycheck[] = { 16, - 17, 95, 19, 176, 133, 3, 100, 136, 53, 54, - 20, 21, 19, 186, 151, 20, 21, 20, 21, 33, - 34, 150, 32, 152, 20, 21, 24, 25, 122, 166, - 20, 168, 126, 40, 51, 45, 81, 40, 55, 84, - 45, 20, 45, 23, 40, 20, 36, 20, 20, 45, - 40, 20, 42, 43, 44, 35, 185, 36, 27, 153, - 35, 40, 34, 42, 43, 44, 35, 40, 22, 42, - 43, 44, 3, 5, 6, 7, 8, 9, 4, 11, - 12, 13, 14, 15, 16, 17, 18, 23, 20, 106, - 22, 173, 174, 24, 25, 27, 20, 5, 34, 35, - 22, 36, 10, 27, 39, 187, 188, 32, 190, 34, - 192, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 32, 20, 20, 22, 5, - 6, 7, 8, 9, 35, 11, 12, 13, 14, 15, - 16, 17, 18, 35, 20, 35, 22, 5, 6, 7, - 8, 9, 15, 11, 12, 13, 14, 15, 16, 17, - 18, 15, 20, 20, 22, 6, 7, 8, 9, 38, - 11, 12, 13, 14, 15, 16, 17, 18, 20, 20, - 36, 22, 20, 23, 26, 27, 28, 29, 30, 31, - 20, 33, 24, 25, 34, 35, 26, 27, 28, 29, - 30, 31, 13, 14, 15, 24, 25, 18, 13, 14, - 15, 36, 20, 18, 39, 22, 20, 20, 20, 20, - 37, 36, 20, 20, 20, 35, 35, 20, 20, 20, - 36, 20, 96, 129, 34, 34, 24, 20, 71, 20, - 35, 35, 170, 20, 24, 0, 36, 20, 32, 36, - 0, 36, 24, 39, 36, 21, 24, 36, 36, 35, - 35, 32, 32, 24, 24, 32, 24, 41, 4, 22, - 22, 36, 34, 32, 28, 22, 40, 40, -1, 132 + 17, 101, 141, 23, 20, 21, 184, 20, 21, 55, + 56, 57, 19, 5, 20, 35, 32, 195, 10, 158, + 159, 160, 22, 20, 21, 20, 21, 40, 34, 45, + 130, 131, 45, 40, 134, 23, 53, 54, 84, 85, + 20, 58, 88, 40, 90, 3, 34, 35, 45, 20, + 45, 24, 25, 20, 20, 194, 36, 32, 3, 34, + 40, 161, 42, 43, 44, 36, 24, 25, 35, 40, + 32, 42, 43, 44, 40, 4, 42, 43, 44, 24, + 25, 20, 23, 181, 182, 20, 36, 26, 27, 39, + 22, 26, 27, 34, 35, 35, 35, 114, 196, 197, + 20, 199, 35, 201, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 35, 20, + 15, 22, 5, 6, 7, 8, 9, 15, 11, 12, + 13, 14, 15, 16, 17, 18, 20, 20, 38, 22, + 5, 6, 7, 8, 9, 20, 11, 12, 13, 14, + 15, 16, 17, 18, 20, 20, 20, 22, 6, 7, + 8, 9, 20, 11, 12, 13, 14, 15, 16, 17, + 18, 20, 20, 36, 22, 20, 39, 26, 27, 28, + 29, 30, 31, 20, 33, 174, 175, 176, 20, 26, + 27, 28, 29, 30, 31, 22, 33, 13, 14, 15, + 24, 25, 18, 13, 14, 15, 26, 27, 18, 34, + 35, 37, 20, 36, 36, 20, 20, 35, 20, 20, + 20, 36, 34, 34, 20, 24, 35, 20, 35, 35, + 20, 20, 102, 36, 0, 20, 24, 0, 36, 20, + 32, 36, 39, 4, 24, 36, 21, 41, 24, 36, + 36, 35, 35, 32, 32, 24, 24, 24, 32, 36, + 74, 23, 32, 34, 23, 29, 23, 40, 40, 137, + 178, 140 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/lib/bison.simple" @@ -1083,61 +1091,69 @@ case 9: ; break;} case 10: -#line 228 "parse.y" +#line 226 "parse.y" { - class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL); + ((Class *)class)->nodes = NULL; + class_nodes = NULL; + nodes = g_list_append(nodes,class); ; break;} case 11: #line 233 "parse.y" -{ ; ; +{ + class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL); + ; break;} case 12: -#line 234 "parse.y" +#line 238 "parse.y" { ; ; break;} case 13: -#line 235 "parse.y" +#line 239 "parse.y" { ; ; break;} case 14: -#line 236 "parse.y" +#line 240 "parse.y" { ; ; break;} case 15: -#line 237 "parse.y" +#line 241 "parse.y" { ; ; break;} case 16: -#line 238 "parse.y" +#line 242 "parse.y" { ; ; break;} case 17: -#line 241 "parse.y" +#line 243 "parse.y" +{ ; ; + break;} +case 18: +#line 246 "parse.y" { push_variable(yyvsp[-1].id,PUBLIC_SCOPE,yyvsp[-3].line,NULL); ; break;} -case 18: -#line 244 "parse.y" +case 19: +#line 249 "parse.y" { push_variable(yyvsp[-2].id,PUBLIC_SCOPE,yyvsp[-4].line,yyvsp[-1].id); ; break;} -case 19: -#line 247 "parse.y" +case 20: +#line 252 "parse.y" { push_variable(yyvsp[-1].id,PRIVATE_SCOPE,yyvsp[-3].line,NULL); ; break;} -case 20: -#line 250 "parse.y" +case 21: +#line 255 "parse.y" { push_variable(yyvsp[-2].id,PRIVATE_SCOPE,yyvsp[-4].line,yyvsp[-1].id); ; break;} -case 21: -#line 254 "parse.y" +case 22: +#line 259 "parse.y" { if(strcmp(yyvsp[-6].id,"get")==0 && strcmp(yyvsp[-3].id,"set")==0) { @@ -1168,8 +1184,8 @@ case 21: } ; break;} -case 22: -#line 283 "parse.y" +case 23: +#line 288 "parse.y" { if(strcmp(yyvsp[-3].id,"get")==0) { Node *node; @@ -1195,32 +1211,32 @@ case 22: } ; break;} -case 23: -#line 309 "parse.y" +case 24: +#line 314 "parse.y" { yyval.list = yyvsp[-1].list; ; break;} -case 24: -#line 310 "parse.y" +case 25: +#line 315 "parse.y" { yyval.list = NULL; ; break;} -case 25: -#line 313 "parse.y" +case 26: +#line 318 "parse.y" { yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id); ; break;} -case 26: -#line 316 "parse.y" +case 27: +#line 321 "parse.y" { yyval.list = g_list_append(NULL,yyvsp[0].id); ; break;} -case 27: -#line 322 "parse.y" +case 28: +#line 327 "parse.y" { ; ; break;} -case 28: -#line 323 "parse.y" +case 29: +#line 328 "parse.y" { Type *type = typestack->data; char *oldname = type->name; @@ -1228,152 +1244,160 @@ case 28: g_free(oldname); ; break;} -case 29: -#line 331 "parse.y" +case 30: +#line 336 "parse.y" { Node *node = new_type(0,yyvsp[0].id,NULL); typestack = g_list_prepend(typestack,node); ; break;} -case 30: -#line 335 "parse.y" +case 31: +#line 340 "parse.y" { Node *node = new_type(stars,yyvsp[-1].id,NULL); stars = 0; typestack = g_list_prepend(typestack,node); ; break;} -case 31: -#line 342 "parse.y" +case 32: +#line 347 "parse.y" { yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL); ; break;} -case 32: -#line 345 "parse.y" +case 33: +#line 350 "parse.y" { yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL); ; break;} -case 33: -#line 348 "parse.y" +case 34: +#line 353 "parse.y" { yyval.id = g_strdup(yyvsp[0].id); ; break;} -case 34: -#line 351 "parse.y" +case 35: +#line 356 "parse.y" { yyval.id = g_strdup("unsigned char"); ; break;} -case 35: -#line 354 "parse.y" +case 36: +#line 359 "parse.y" { yyval.id = g_strdup("signed char"); ; break;} -case 36: -#line 357 "parse.y" +case 37: +#line 362 "parse.y" { yyval.id = g_strdup("char"); ; break;} -case 37: -#line 360 "parse.y" +case 38: +#line 365 "parse.y" { yyval.id = g_strdup("double"); ; break;} -case 38: -#line 363 "parse.y" +case 39: +#line 368 "parse.y" { yyval.id = g_strdup("float"); ; break;} -case 39: -#line 366 "parse.y" +case 40: +#line 371 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 40: -#line 369 "parse.y" +case 41: +#line 374 "parse.y" { yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL); g_free(yyvsp[0].id); ; break;} -case 41: -#line 373 "parse.y" -{ - yyval.id = yyvsp[0].id; - ; - break;} case 42: -#line 376 "parse.y" +#line 378 "parse.y" { - yyval.id = g_strdup("void"); + yyval.id = yyvsp[0].id; ; break;} case 43: #line 381 "parse.y" { - yyval.id = "long int"; + yyval.id = g_strdup("void"); ; break;} case 44: -#line 384 "parse.y" +#line 386 "parse.y" { - yyval.id = "long"; + yyval.id = "long int"; ; break;} case 45: -#line 387 "parse.y" +#line 389 "parse.y" { - yyval.id = "short int"; + yyval.id = "long"; ; break;} case 46: -#line 390 "parse.y" +#line 392 "parse.y" { - yyval.id = "short"; + yyval.id = "short int"; ; break;} case 47: -#line 393 "parse.y" +#line 395 "parse.y" { - yyval.id = "int"; + yyval.id = "short"; ; break;} case 48: #line 398 "parse.y" { - yyval.id = "enum "; + yyval.id = "int"; ; break;} case 49: -#line 401 "parse.y" +#line 403 "parse.y" { - yyval.id = "union "; + yyval.id = "enum "; ; break;} case 50: -#line 404 "parse.y" +#line 406 "parse.y" { - yyval.id = "struct "; + yyval.id = "union "; ; break;} case 51: #line 409 "parse.y" -{ stars++; ; +{ + yyval.id = "struct "; + ; break;} case 52: -#line 410 "parse.y" +#line 414 "parse.y" { stars++; ; break;} case 53: -#line 413 "parse.y" +#line 415 "parse.y" +{ stars++; ; + break;} +case 54: +#line 418 "parse.y" +{ ; ; + break;} +case 55: +#line 419 "parse.y" +{ ; ; + break;} +case 56: +#line 422 "parse.y" { if(strcmp(yyvsp[-1].id,"first")==0) yyval.sigtype = PRIVATE_SIGNAL_FIRST_METHOD; @@ -1387,8 +1411,8 @@ case 53: g_free(yyvsp[-1].id); ; break;} -case 54: -#line 425 "parse.y" +case 57: +#line 434 "parse.y" { if(strcmp(yyvsp[-2].id,"first")==0) yyval.sigtype = PRIVATE_SIGNAL_FIRST_METHOD; @@ -1402,14 +1426,14 @@ case 54: g_free(yyvsp[-2].id); ; break;} -case 55: -#line 437 "parse.y" +case 58: +#line 446 "parse.y" { yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD; ; break;} -case 56: -#line 440 "parse.y" +case 59: +#line 449 "parse.y" { if(strcmp(yyvsp[-1].id,"first")==0) yyval.sigtype = SIGNAL_FIRST_METHOD; @@ -1423,40 +1447,76 @@ case 56: g_free(yyvsp[-1].id); ; break;} -case 57: -#line 452 "parse.y" +case 60: +#line 461 "parse.y" +{ + if(strcmp(yyvsp[-1].id,"first")==0) + yyval.sigtype = SIGNAL_FIRST_METHOD; + else if(strcmp(yyvsp[-1].id,"last")==0) + yyval.sigtype = SIGNAL_LAST_METHOD; + else { + yyerror(_("signal must be 'first' or 'last'")); + g_free(yyvsp[-1].id); + YYERROR; + } + g_free(yyvsp[-1].id); + ; + break;} +case 61: +#line 473 "parse.y" +{ + if(strcmp(yyvsp[-2].id,"first")==0) + yyval.sigtype = SIGNAL_FIRST_METHOD; + else if(strcmp(yyvsp[-2].id,"last")==0) + yyval.sigtype = SIGNAL_LAST_METHOD; + else { + yyerror(_("signal must be 'first' or 'last'")); + g_free(yyvsp[-2].id); + YYERROR; + } + g_free(yyvsp[-2].id); + ; + break;} +case 62: +#line 485 "parse.y" { yyval.sigtype = SIGNAL_LAST_METHOD; ; break;} -case 58: -#line 457 "parse.y" +case 63: +#line 488 "parse.y" +{ + yyval.sigtype = SIGNAL_LAST_METHOD; + ; + break;} +case 64: +#line 493 "parse.y" { gtktypes = g_list_prepend(gtktypes,yyvsp[-3].id); ; break;} -case 59: -#line 462 "parse.y" +case 65: +#line 498 "parse.y" { gtktypes = g_list_append(gtktypes,yyvsp[0].id); ; break;} -case 60: -#line 465 "parse.y" +case 66: +#line 501 "parse.y" { gtktypes = g_list_append(gtktypes,yyvsp[0].id); ; break;} -case 61: -#line 470 "parse.y" +case 67: +#line 506 "parse.y" { yyval.cbuf=yyvsp[0].cbuf; ; break;} -case 62: -#line 471 "parse.y" +case 68: +#line 507 "parse.y" { yyval.cbuf = NULL; ; break;} -case 63: -#line 475 "parse.y" +case 69: +#line 511 "parse.y" { if(!has_self) { yyerror(_("signal without 'self' as " @@ -1468,8 +1528,8 @@ case 63: ccode_line,vararg); ; break;} -case 64: -#line 485 "parse.y" +case 70: +#line 521 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " @@ -1481,8 +1541,8 @@ case 64: ccode_line,vararg); ; break;} -case 65: -#line 495 "parse.y" +case 71: +#line 531 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " @@ -1490,12 +1550,12 @@ case 65: YYERROR; } push_function(VIRTUAL_METHOD, NULL, yyvsp[-5].id, - yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-7].line, + yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line, ccode_line,vararg); ; break;} -case 66: -#line 505 "parse.y" +case 72: +#line 541 "parse.y" { push_function(OVERRIDE_METHOD, yyvsp[-9].id, yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf, @@ -1503,24 +1563,24 @@ case 66: vararg); ; break;} -case 67: -#line 511 "parse.y" +case 73: +#line 547 "parse.y" { push_function(PUBLIC_SCOPE, NULL, yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line, vararg); ; break;} -case 68: -#line 516 "parse.y" +case 74: +#line 552 "parse.y" { push_function(PRIVATE_SCOPE, NULL, yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line, vararg); ; break;} -case 69: -#line 521 "parse.y" +case 75: +#line 557 "parse.y" { if(strcmp(yyvsp[-4].id,"init")==0) { push_init_arg(yyvsp[-2].id,FALSE); @@ -1541,31 +1601,31 @@ case 69: } ; break;} -case 70: -#line 542 "parse.y" +case 76: +#line 578 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 71: -#line 543 "parse.y" +case 77: +#line 579 "parse.y" { yyval.id = (yyvsp[0].cbuf)->str; g_string_free(yyvsp[0].cbuf,FALSE); ; break;} -case 72: -#line 547 "parse.y" +case 78: +#line 583 "parse.y" { ; ; break;} -case 73: -#line 548 "parse.y" +case 79: +#line 584 "parse.y" { yyval.id = NULL; ; break;} -case 74: -#line 551 "parse.y" +case 80: +#line 587 "parse.y" { vararg = FALSE; has_self = FALSE; ; break;} -case 75: -#line 552 "parse.y" +case 81: +#line 588 "parse.y" { vararg = FALSE; has_self = TRUE; @@ -1578,8 +1638,8 @@ case 75: } ; break;} -case 76: -#line 563 "parse.y" +case 82: +#line 599 "parse.y" { has_self = TRUE; if(strcmp(yyvsp[-2].id,"self")==0) @@ -1591,40 +1651,40 @@ case 76: } ; break;} -case 77: -#line 573 "parse.y" +case 83: +#line 609 "parse.y" { has_self = FALSE; ; break;} -case 78: -#line 576 "parse.y" +case 84: +#line 612 "parse.y" { vararg = TRUE; ; break;} -case 79: -#line 577 "parse.y" +case 85: +#line 613 "parse.y" { vararg = FALSE; ; break;} -case 80: -#line 580 "parse.y" +case 86: +#line 616 "parse.y" { ; ; break;} -case 81: -#line 581 "parse.y" +case 87: +#line 617 "parse.y" { ; ; break;} -case 82: -#line 584 "parse.y" +case 88: +#line 620 "parse.y" { push_funcarg(yyvsp[0].id,NULL); ; break;} -case 83: -#line 587 "parse.y" +case 89: +#line 623 "parse.y" { push_funcarg(yyvsp[-1].id,yyvsp[0].id); ; break;} -case 84: -#line 590 "parse.y" +case 90: +#line 626 "parse.y" { if(strcmp(yyvsp[-2].id,"check")!=0) { yyerror(_("parse error")); @@ -1634,8 +1694,8 @@ case 84: push_funcarg(yyvsp[-4].id,NULL); ; break;} -case 85: -#line 598 "parse.y" +case 91: +#line 634 "parse.y" { if(strcmp(yyvsp[-2].id,"check")!=0) { yyerror(_("parse error")); @@ -1645,16 +1705,16 @@ case 85: push_funcarg(yyvsp[-5].id,yyvsp[-4].id); ; break;} -case 86: -#line 608 "parse.y" +case 92: +#line 644 "parse.y" { ; ; break;} -case 87: -#line 609 "parse.y" +case 93: +#line 645 "parse.y" { ; ; break;} -case 88: -#line 612 "parse.y" +case 94: +#line 648 "parse.y" { if(strcmp(yyvsp[0].id,"type")==0) { Node *node = new_check(TYPE_CHECK,NULL); @@ -1669,61 +1729,61 @@ case 88: g_free(yyvsp[0].id); ; break;} -case 89: -#line 625 "parse.y" +case 95: +#line 661 "parse.y" { Node *node = new_check(GT_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 90: -#line 629 "parse.y" +case 96: +#line 665 "parse.y" { Node *node = new_check(LT_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 91: -#line 633 "parse.y" +case 97: +#line 669 "parse.y" { Node *node = new_check(GE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 92: -#line 637 "parse.y" +case 98: +#line 673 "parse.y" { Node *node = new_check(LE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 93: -#line 641 "parse.y" +case 99: +#line 677 "parse.y" { Node *node = new_check(EQ_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 94: -#line 645 "parse.y" +case 100: +#line 681 "parse.y" { Node *node = new_check(NE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 95: -#line 651 "parse.y" +case 101: +#line 687 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 96: -#line 652 "parse.y" +case 102: +#line 688 "parse.y" { yyval.id = g_strconcat("-",yyvsp[0].id,NULL); g_free(yyvsp[0].id); ; break;} -case 97: -#line 656 "parse.y" +case 103: +#line 692 "parse.y" { yyval.id = yyvsp[0].id; ; break;} } @@ -1948,5 +2008,5 @@ yyerrhandle: } return 1; } -#line 659 "parse.y" +#line 695 "parse.y" diff --git a/src/parse.y b/src/parse.y index b5d9f10..4cdb6a0 100644 --- a/src/parse.y +++ b/src/parse.y @@ -223,6 +223,11 @@ class: classdec '{' classcode '}' { class_nodes = NULL; nodes = g_list_append(nodes,class); } + | classdec '{' '}' { + ((Class *)class)->nodes = NULL; + class_nodes = NULL; + nodes = g_list_append(nodes,class); + } ; classdec: CLASS TYPETOKEN FROM TYPETOKEN { @@ -410,6 +415,10 @@ stars: '*' stars { stars++; } | '*' { stars++; } ; +optpublic: { ; } + | PUBLIC { ; } + ; + fullsigtype: PRIVATE TOKEN sigtype { if(strcmp($2,"first")==0) $$ = PRIVATE_SIGNAL_FIRST_METHOD; @@ -437,7 +446,31 @@ fullsigtype: PRIVATE TOKEN sigtype { | PRIVATE sigtype { $$ = PRIVATE_SIGNAL_LAST_METHOD; } - | TOKEN sigtype { + | TOKEN sigtype { + if(strcmp($1,"first")==0) + $$ = SIGNAL_FIRST_METHOD; + else if(strcmp($1,"last")==0) + $$ = SIGNAL_LAST_METHOD; + else { + yyerror(_("signal must be 'first' or 'last'")); + g_free($1); + YYERROR; + } + g_free($1); + } + | PUBLIC TOKEN sigtype { + if(strcmp($2,"first")==0) + $$ = SIGNAL_FIRST_METHOD; + else if(strcmp($2,"last")==0) + $$ = SIGNAL_LAST_METHOD; + else { + yyerror(_("signal must be 'first' or 'last'")); + g_free($2); + YYERROR; + } + g_free($2); + } + | TOKEN PUBLIC sigtype { if(strcmp($1,"first")==0) $$ = SIGNAL_FIRST_METHOD; else if(strcmp($1,"last")==0) @@ -449,6 +482,9 @@ fullsigtype: PRIVATE TOKEN sigtype { } g_free($1); } + | PUBLIC sigtype { + $$ = SIGNAL_LAST_METHOD; + } | sigtype { $$ = SIGNAL_LAST_METHOD; } @@ -492,14 +528,14 @@ method: SIGNAL fullsigtype type TOKEN '(' funcargs ')' onerror codenocode { $8, $9,$1, ccode_line,vararg); } - | VIRTUAL type TOKEN '(' funcargs ')' onerror codenocode { + | VIRTUAL optpublic type TOKEN '(' funcargs ')' onerror codenocode { if(!has_self) { yyerror(_("virtual method without 'self' as " "first parameter")); YYERROR; } - push_function(VIRTUAL_METHOD, NULL, $3, - $7, $8,$1, + push_function(VIRTUAL_METHOD, NULL, $4, + $8, $9,$1, ccode_line,vararg); } | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' onerror '{' CCODE { diff --git a/src/test.gob b/src/test.gob index 0152a00..ac4fa0b 100644 --- a/src/test.gob +++ b/src/test.gob @@ -23,8 +23,7 @@ class Gtk:Weird:Button from Gtk:Button { public double array[23][18]; init(object) { - GtkWeirdButton *but = GTK_WEIRD_BUTTON(object); - but->i=0; + object->i=0; } class_init(klass); public GtkWidget * new(int j (check > 0)) { @@ -84,6 +83,21 @@ class Gtk:Weird:Button from Gtk:Button { { puts("TEST2"); } + + /* testing empty func */ + public void foofoofoo(self) {} + + override (Gtk:Widget) + int event(Gtk:Widget *self (check null type), + GdkEvent *event (check null)) onerror FALSE + { + int ret; + /* some code */ + ret = PARENT_HANDLER(self,event); + /* some code */ + return ret; + } + } %{ -- 2.43.2