From 2255b3d84eeb947d4c065332f16e410ae4704c63 Mon Sep 17 00:00:00 2001 From: George Lebl Date: Sat, 1 Jan 2000 02:49:00 -0800 Subject: [PATCH] Release 0.92.0 --- ChangeLog | 65 ++++ NEWS | 7 + TODO | 5 + configure | 2 +- configure.in | 2 +- doc/gob.1.in | 74 ++-- gob.spec | 2 +- src/Makefile.am | 8 + src/Makefile.in | 8 + src/lexer.c | 486 ++++++++++++------------ src/lexer.l | 1 + src/main.c | 607 +++++++++++++++++++----------- src/parse.c | 955 ++++++++++++++++++++++++------------------------ src/parse.y | 201 +++++----- src/test.gob | 62 +++- src/tree.c | 7 +- src/tree.h | 27 +- 17 files changed, 1463 insertions(+), 1056 deletions(-) diff --git a/ChangeLog b/ChangeLog index 184c00a..2b9a5be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,68 @@ +Fri Dec 31 17:39:22 1999 George Lebl + + * Release 0.92.0 + +Thu Dec 30 20:20:36 1999 George Lebl + + * src/main.c: correctly handle the complex fundemental types, + so that we can handle ALL the fundemental types for signals + +Thu Dec 30 19:29:56 1999 George Lebl + + * src/main.c: don't use function types for casts in marshallers, + but default types we get from our GTK_TYPE_* -> C type translation, + and use this fact to check for same function types and combine + signal prototypes. This doesn't yet handle well complex types, + but I have an idea how to make complex types work. Though + I dunno if it's actually worth it. + +Thu Dec 30 17:18:27 1999 George Lebl + + * src/main.c: figure out some types from GTK types and cast properly + when emitting a signal. This catches some inconsistencies in + signal func argument lists and the GTK types of the arguments. + +Wed Dec 29 18:04:13 1999 George Lebl + + * src/parse.y: allow scope, public/private/protected, to come before + the signal or virtual keyword for consistency's sake. + +Wed Dec 29 01:39:30 1999 George Lebl + + * src/{tree.[ch],parser.y}: cleanup scope stuff + + * src/{lexer.l,parser.y,tree.h,main.c}: add protected keyword and + methods. protected methods are put into the -private files and + are real exported functions just like public. protected data + members act like pre-0.91.x private datamembers, that is they + get stuck into the public header, but marked /* protected */. + + * src/main.c: change the method body printing function so that we + can catch the no return warning properly and send us to the .gob + file instead of the .c file. + + * src/{parse.y,main.c}: handle empty publics/privates/overrides + and handle the body being set to ';' rather then '{}' + + * src/main.c: check for empty nonvoid regular methods, and error out + on finding them as that would produce warnings which we can't catch + and it is generally bad to do anyway + + * src/{parse.y,tree.[ch],main.c}: use char pointers for C buffers, + and kill leading/trailing whitespace from them to make the C files + nicer and easier to recognize empty functions. + + * src/main.c: add a --version switch + + * doc/gob.1.in: Update with the above changes + + * configure.in: raise version + +Tue Dec 28 20:49:56 1999 George Lebl + + * src/main.c: apply patch from ChiDeok Hwang + to make the hack function static so that we don't pollute namespace + Mon Dec 27 19:56:24 1999 George Lebl * Release 0.91.2 diff --git a/NEWS b/NEWS index ea6407c..2bf0cf3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +0.92.0 + * added protected methods and datamembers. + * better handeling of empty methods + * allow scope keywords before the virutal or signal keyword + * merge signal marshallers that are the same to reduce code size + * various small fixes and improvements + 0.91.2 * PARENT_HANDLER can now return a value for non-void overrides * allow empty classes and empty function bodies diff --git a/TODO b/TODO index e69de29..7a7cce2 100644 --- a/TODO +++ b/TODO @@ -0,0 +1,5 @@ +Somehow transfer comments from .gob to .h and .c files to make gtk-doc +possible. Alternatively make gob act as gtk-doc, or generate a gtk-doc +ready stub file. + +Figure out how to work with the complex types on signal prototypes diff --git a/configure b/configure index 9eeee38..f856045 100755 --- a/configure +++ b/configure @@ -703,7 +703,7 @@ fi PACKAGE=gob -VERSION=0.91.2 +VERSION=0.92.0 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 adf05d6..4445dbe 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.2) +AM_INIT_AUTOMAKE(gob,0.92.0) if test -f ../NOINST_GOB ; then DOINSTGOB= diff --git a/doc/gob.1.in b/doc/gob.1.in index fa5dd9b..1f88d7c 100644 --- a/doc/gob.1.in +++ b/doc/gob.1.in @@ -10,8 +10,8 @@ GOB \- The GTK+ Object Builder .SH SYNOPSIS .PP -.B gob [-?] [-h] [-w] [--exit-on-warn] [--no-exit-on-warn] [--for-cpp] -[--no-touch-headers] file +.B gob [-?] [-h] [--help] [--version] [-w] [--exit-on-warn] +[--no-exit-on-warn] [--for-cpp] [--no-touch-headers] file .SH DESCRIPTION .PP GTK+ Object Builder is a simple preprocessor for easily creating @@ -24,8 +24,13 @@ is in spirit similar to things like lex or yacc. .B -? .TP .B -h +.TP +.B --help Display a simple help screen. .TP +.B --version +Display version information (note, --version was not added until 0.92.0) +.TP .B -w .TP .B --exit-on-warn @@ -40,7 +45,8 @@ Generate C++ code. .B --no-touch-headers Don't touch the generated header file unless it really changed, this avoids spurious rebuilds, but can confuse some make systems (automake in particular), -so it is not enabled by default. +so it is not enabled by default. Private header is still touched even if +unchanged however. .TP .B --always-private-header Always create a \fB-private.h\fR file, even if it would be empty. @@ -141,20 +147,24 @@ For example: .PP Data members: .PP -There are three types of data members. Two of them are normal -data numbers, and one is a virtual one, usually linked to a normal public -data member. The two normal data members are public or private. They are -basically just copied into the object directly. There is only one +There are four types of data members. Three of them are normal +data numbers, and one is a virtual one, usually linked to a normal +data member. The three normal data members are public, protected and +private. Public and protected are basically just entries in the object +structure, while private has it's own dynamically allocated private +structure. Protected members are always put after the public one in the +structure and are marked protected in the header file. There is only one identifier allowed per typename unlike in normal C. Example: .nf public int i; private GtkWidget *h; + protected long k; .fi .PP -Public datamembers are accessed normally as members of the object struct. -Example where 'i' is as above a public data member: +Public and protected data members are accessed normally as members of +the object struct. Example where 'i' is as above a public data member: .nf object->i = 1; @@ -162,21 +172,24 @@ Example where 'i' is as above a public data member: .fi .PP The private data members are defined in a structure which is only available -inside the .c file. You must access them using the structure _priv. Example +inside the .c file, or by including a private header file. You must access +them using the structure _priv. Example where 'h' is the private data member (as in the above example): .nf object->_priv->h = NULL; .fi -Note that the _priv structure is defined in the \fB-private.h\fR. +The _priv structure is defined in the \fB-private.h\fR. This file is automatically included if you don't include it yourself. You should always explicitly include it if you explicitly also include the main -header file. In case you use the \fB--no-private-header\fR option, no +header file. +.PP +In case you use the \fB--no-private-header\fR option, no private header file is created and you can only access the _priv pointer below the class definition in the .gob file. .PP -The third type is an argument type. It is a named datamember which +The fourth type is an argument type. It is a named datamember which is one of the features of the GTK+ object system. You need to define a get and a set handler. They are fragments of C code that will be used to get the value or set the value of the argument. Inside them you can use the @@ -202,17 +215,27 @@ without the GTK_ARG_ prefix. For example: .fi This makes the argument settable even before the object is constructed, so -that people can pass it to gtk_object_new function. +that people can pass it to gtk_object_new function. Useful is also +CONSTRUCT_ONLY flag which makes the argument only available during +construction of the object. .PP Methods: .PP -There is a whole array of possible methods. The two normal, -"familiar" method types are private and public. Public are defined as -normal functions with a prototype in the header file. Private methods +There is a whole array of possible methods. The three normal, +"familiar" method types are private, protected and public. Public are +defined as normal functions with a prototype in the header file. +Protected methods are defined as normal methods (which you can call from other +files), but their prototype is placed in the private 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 +file. Then there are signal, virtual and override methods. More on those +later. You can also 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. +You can also not define a body for a method, by just using ';' instead of a +body. This will define an empty function. You can't do this for non-void +regular public, private or protected methods, however it is acceptable for +non-void virtual, signal and override methods. .PP Argument lists: .PP @@ -261,6 +284,9 @@ output, they just delimit the string. For example: } .fi +The onerror value is also used in overrides that have a return value, in +case there isn't a parent method, PARENT_HANDLER will return it. More about +this later. .PP Constructor methods: .PP @@ -300,8 +326,9 @@ so that one can override the method in derived methods. They can be empty which makes calling the methods he same as public methods. This type of method is just a little bit "slower" then normal functions, but not as slow as signals. You define them by using "virtual" keyword before the -prototype. If you put the keyword "private" right after the "virtual" +prototype. If you put the keyword "private" right after the "virtual" keyword, the wrapper will not be a public method, but a private one. +You can do the same with "protected" to make a protected wrapper. .PP Signals: .PP @@ -335,8 +362,9 @@ or .fi .PP If you don't want the wrapper that emits the signal to be public, you can -include the keyword "private" after the "signal" keyword. This will make -the wrapper a normal private method. +include the keyword "private" after the "signal" keyword. This will make +the wrapper a normal private method. You can also make a protected wrapper +by using "protected" instead of "private". .PP If you don't define a "first" or a "last", the default will be taken as "last". @@ -450,6 +478,10 @@ There is no real good way we can handle this without parsing C code, so we probably never will. In the future, I might add #if 0 as a comment but that's about as far as I can really take it and even that is problematic. Basically, if you use gob, just don't use the C preprocessor too extensively. +.PP +Comments will not get through to the generated files unless inside C code. +This makes using something like gtk-doc harder. However I'm planning to +fix this somehow. .SH AUTHOR .PP diff --git a/gob.spec b/gob.spec index 86e0d2b..faa5343 100644 --- a/gob.spec +++ b/gob.spec @@ -1,4 +1,4 @@ -%define ver 0.91.2 +%define ver 0.92.0 %define rel 1 %define prefix /usr diff --git a/src/Makefile.am b/src/Makefile.am index fdd0dcd..7b43ada 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,3 +42,11 @@ test: gtk-weird-button.c gtk-weird-button.h gtk-weird-button.c gtk-weird-button.h: test.gob gob ./gob test.gob + +# can't depend on the header file as that would break the above rule +# since it's just for testing, who cares +testcpp: gtk-weird-button.cc + g++ -g -Wall `gtk-config --cflags` -c gtk-weird-button.cc + +gtk-weird-button.cc: test.gob gob + ./gob --for-cpp test.gob diff --git a/src/Makefile.in b/src/Makefile.in index 1b189c6..071a0f2 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -419,6 +419,14 @@ test: gtk-weird-button.c gtk-weird-button.h gtk-weird-button.c gtk-weird-button.h: test.gob gob ./gob test.gob +# can't depend on the header file as that would break the above rule +# since it's just for testing, who cares +testcpp: gtk-weird-button.cc + g++ -g -Wall `gtk-config --cflags` -c gtk-weird-button.cc + +gtk-weird-button.cc: test.gob gob + ./gob --for-cpp test.gob + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/lexer.c b/src/lexer.c index a2c7013..fc6e1d1 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -284,51 +284,51 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 68 -#define YY_END_OF_BUFFER 69 -static yyconst short int yy_acclist[343] = +#define YY_NUM_RULES 69 +#define YY_END_OF_BUFFER 70 +static yyconst short int yy_acclist[351] = { 0, - 69, 66, 68, 65, 66, 68, 1, 67, 68, 66, - 67, 68, 66, 68, 66, 68, 66, 68, 66, 68, - 13, 66, 68, 1, 14, 67, 68, 13, 66, 67, - 68, 13, 66, 68, 13, 66, 68, 32, 66, 68, - 1, 33, 67, 68, 32, 66, 67, 68, 25, 32, - 66, 68, 32, 66, 68, 32, 66, 68, 32, 66, - 68, 32, 66, 68, 30, 32, 66, 68, 31, 32, - 66, 68, 32, 66, 68, 32, 66, 68, 28, 66, - 68, 1, 29, 67, 68, 28, 66, 67, 68, 27, - 28, 66, 68, 28, 66, 68, 28, 66, 68, 66, - - 68, 66, 68, 60, 66, 68, 60, 66, 68, 60, - 66, 68, 60, 66, 68, 60, 66, 68, 62, 66, - 68, 66, 68, 66, 68, 58, 66, 68, 58, 66, - 68, 66, 68, 60, 66, 68, 60, 66, 68, 60, - 66, 68, 60, 66, 68, 60, 66, 68, 60, 66, - 68, 60, 66, 68, 60, 66, 68, 60, 66, 68, - 60, 66, 68, 60, 66, 68, 60, 66, 68, 63, - 66, 68, 64, 66, 68, 8, 16, 12, 9, 24, - 17, 26, 10, 60, 59, 60, 60, 60, 60, 58, - 11, 58, 58, 61, 60, 60, 60, 60, 60, 60, - - 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, - 60, 60, 3, 15, 22, 18, 20, 5, 6, 59, - 60, 60, 60, 60, 50, 58, 7, 58, 58, 60, - 60, 60, 60, 60, 60, 45, 60, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, 60, 23, - 19, 21, 60, 60, 36, 60, 35, 60, 60, 48, - 60, 60, 60, 40, 60, 60, 43, 60, 60, 60, - 60, 60, 60, 60, 60, 60, 60, 60, 37, 60, - 34, 60, 60, 49, 60, 60, 46, 60, 60, 60, - 60, 60, 44, 60, 60, 60, 60, 39, 60, 60, - - 60, 60, 60, 47, 60, 60, 60, 60, 51, 60, - 55, 60, 41, 60, 38, 60, 60, 60, 60, 60, - 57, 60, 60, 52, 60, 60, 54, 60, 60, 53, - 60, 56, 60, 42, 60, 60, 60, 4, 60, 2, - 2, 60 + 70, 67, 69, 66, 67, 69, 1, 68, 69, 67, + 68, 69, 67, 69, 67, 69, 67, 69, 67, 69, + 13, 67, 69, 1, 14, 68, 69, 13, 67, 68, + 69, 13, 67, 69, 13, 67, 69, 32, 67, 69, + 1, 33, 68, 69, 32, 67, 68, 69, 25, 32, + 67, 69, 32, 67, 69, 32, 67, 69, 32, 67, + 69, 32, 67, 69, 30, 32, 67, 69, 31, 32, + 67, 69, 32, 67, 69, 32, 67, 69, 28, 67, + 69, 1, 29, 68, 69, 28, 67, 68, 69, 27, + 28, 67, 69, 28, 67, 69, 28, 67, 69, 67, + + 69, 67, 69, 61, 67, 69, 61, 67, 69, 61, + 67, 69, 61, 67, 69, 61, 67, 69, 63, 67, + 69, 67, 69, 67, 69, 59, 67, 69, 59, 67, + 69, 67, 69, 61, 67, 69, 61, 67, 69, 61, + 67, 69, 61, 67, 69, 61, 67, 69, 61, 67, + 69, 61, 67, 69, 61, 67, 69, 61, 67, 69, + 61, 67, 69, 61, 67, 69, 61, 67, 69, 64, + 67, 69, 65, 67, 69, 8, 16, 12, 9, 24, + 17, 26, 10, 61, 60, 61, 61, 61, 61, 59, + 11, 59, 59, 62, 61, 61, 61, 61, 61, 61, + + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 3, 15, 22, 18, 20, 5, 6, 60, + 61, 61, 61, 61, 50, 59, 7, 59, 59, 61, + 61, 61, 61, 61, 61, 45, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 23, 19, 21, 61, 61, 36, 61, 35, 61, 61, + 48, 61, 61, 61, 40, 61, 61, 43, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 37, 61, 34, 61, 61, 49, 61, 61, 46, 61, + 61, 61, 61, 61, 61, 44, 61, 61, 61, 61, + + 39, 61, 61, 61, 61, 61, 47, 61, 61, 61, + 61, 61, 51, 61, 56, 61, 41, 61, 38, 61, + 61, 61, 61, 61, 58, 61, 61, 52, 61, 61, + 61, 55, 61, 61, 54, 61, 57, 61, 61, 42, + 61, 61, 53, 61, 61, 4, 61, 2, 2, 61 } ; -static yyconst short int yy_accept[266] = +static yyconst short int yy_accept[273] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 7, 10, 13, 15, 17, @@ -348,17 +348,18 @@ static yyconst short int yy_accept[266] = 219, 219, 219, 220, 220, 221, 222, 223, 224, 225, 226, 227, 227, 228, 229, 230, 230, 231, 232, 233, 234, 235, 236, 238, 239, 240, 241, 242, 243, 244, - 245, 246, 247, 248, 249, 250, 250, 250, 251, 252, - 253, 253, 254, 255, 257, 259, 260, 262, 263, 264, - 266, 267, 269, 270, 271, 272, 273, 274, 275, 276, - - 277, 278, 279, 281, 281, 282, 282, 283, 284, 286, - 287, 289, 290, 291, 292, 293, 295, 296, 297, 298, - 300, 301, 302, 302, 302, 303, 304, 306, 307, 308, - 309, 311, 313, 315, 317, 318, 319, 319, 319, 320, - 321, 323, 324, 326, 327, 329, 329, 329, 330, 332, - 334, 336, 336, 336, 337, 337, 337, 338, 338, 338, - 339, 340, 341, 343, 343 + 245, 246, 247, 248, 249, 250, 251, 251, 251, 252, + 253, 254, 254, 255, 256, 258, 260, 261, 263, 264, + 265, 267, 268, 270, 271, 272, 273, 274, 275, 276, + + 277, 278, 279, 280, 281, 283, 283, 284, 284, 285, + 286, 288, 289, 291, 292, 293, 294, 295, 296, 298, + 299, 300, 301, 303, 304, 305, 305, 305, 306, 307, + 309, 310, 311, 312, 313, 315, 317, 319, 321, 322, + 323, 323, 323, 324, 325, 327, 328, 330, 331, 332, + 334, 334, 334, 335, 337, 339, 340, 342, 342, 342, + 343, 345, 345, 345, 346, 346, 346, 347, 348, 349, + 351, 351 } ; static yyconst int yy_ec[256] = @@ -403,77 +404,79 @@ static yyconst int yy_meta[55] = 6, 6, 1, 1 } ; -static yyconst short int yy_base[281] = +static yyconst short int yy_base[288] = { 0, 0, 3, 9, 12, 36, 88, 26, 45, 142, 0, - 187, 0, 572, 573, 573, 573, 573, 8, 545, 528, - 2, 573, 573, 573, 558, 542, 573, 573, 573, 573, - 15, 13, 541, 0, 573, 573, 21, 512, 573, 573, - 573, 573, 539, 0, 34, 0, 549, 37, 11, 12, - 18, 573, 61, 45, 68, 73, 52, 57, 82, 62, - 64, 73, 85, 83, 86, 88, 91, 90, 189, 573, - 573, 573, 560, 534, 528, 507, 573, 573, 551, 197, - 550, 549, 573, 553, 573, 201, 511, 573, 573, 573, - 551, 538, 537, 536, 95, 103, 94, 190, 540, 194, - - 573, 546, 197, 202, 233, 0, 242, 245, 518, 21, + 187, 0, 586, 587, 587, 587, 587, 8, 559, 542, + 2, 587, 587, 587, 572, 556, 587, 587, 587, 587, + 15, 13, 555, 0, 587, 587, 21, 526, 587, 587, + 587, 587, 553, 0, 34, 0, 563, 37, 11, 12, + 18, 587, 61, 45, 68, 73, 52, 57, 82, 62, + 64, 73, 85, 83, 86, 88, 91, 90, 189, 587, + 587, 587, 574, 548, 542, 521, 587, 587, 565, 197, + 564, 563, 587, 567, 587, 201, 525, 587, 587, 587, + 565, 552, 551, 550, 95, 103, 94, 190, 554, 194, + + 587, 560, 197, 202, 233, 0, 242, 245, 532, 21, 203, 204, 211, 212, 224, 229, 238, 96, 234, 245, - 87, 248, 249, 250, 251, 253, 255, 544, 573, 523, - 497, 573, 573, 536, 535, 534, 573, 573, 538, 573, - 505, 536, 573, 523, 522, 102, 257, 252, 258, 573, - 262, 533, 573, 267, 0, 271, 272, 274, 275, 276, - 283, 279, 520, 286, 287, 289, 292, 293, 294, 296, - 298, 299, 301, 300, 302, 514, 485, 573, 573, 573, - 490, 304, 303, 516, 515, 312, 514, 305, 314, 513, - 313, 512, 316, 317, 324, 318, 322, 332, 315, 330, - - 331, 337, 511, 498, 573, 474, 99, 338, 508, 343, - 507, 345, 351, 346, 353, 506, 352, 357, 358, 505, - 361, 363, 498, 482, 362, 364, 502, 366, 367, 369, - 501, 500, 499, 498, 374, 370, 479, 468, 371, 376, - 446, 382, 440, 384, 413, 407, 422, 97, 408, 407, - 403, 380, 393, 386, 201, 397, 401, 186, 410, 573, - 402, 573, 17, 573, 429, 435, 441, 447, 453, 459, - 461, 465, 471, 477, 483, 487, 491, 497, 501, 506 + 87, 248, 249, 250, 251, 253, 255, 558, 587, 537, + 511, 587, 587, 550, 549, 548, 587, 587, 552, 587, + 519, 550, 587, 537, 536, 102, 257, 252, 258, 587, + 262, 547, 587, 267, 0, 271, 272, 274, 276, 279, + 283, 286, 534, 289, 287, 292, 293, 294, 295, 299, + 296, 297, 300, 301, 302, 305, 528, 499, 587, 587, + 587, 504, 303, 310, 530, 529, 312, 528, 314, 315, + 527, 316, 526, 317, 320, 321, 323, 318, 333, 335, + + 334, 337, 338, 341, 525, 512, 587, 488, 99, 346, + 522, 347, 521, 351, 356, 355, 358, 359, 520, 360, + 363, 361, 519, 364, 365, 512, 496, 371, 370, 516, + 372, 373, 374, 375, 515, 514, 513, 508, 380, 385, + 491, 439, 386, 388, 455, 391, 428, 392, 390, 427, + 422, 438, 97, 424, 423, 397, 421, 410, 415, 398, + 410, 201, 413, 401, 186, 418, 587, 417, 587, 17, + 587, 444, 450, 456, 462, 468, 474, 476, 480, 486, + 492, 498, 502, 506, 512, 516, 521 } ; -static yyconst short int yy_def[281] = +static yyconst short int yy_def[288] = { 0, - 265, 265, 266, 266, 267, 267, 268, 268, 264, 9, - 9, 11, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 269, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 270, 264, 271, 272, 272, 272, 272, - 272, 264, 264, 264, 264, 264, 264, 272, 272, 272, - 272, 272, 272, 272, 272, 272, 272, 272, 272, 264, - 264, 264, 273, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 274, 264, 264, 264, 264, 264, 264, - 275, 276, 272, 277, 272, 272, 272, 272, 264, 264, - - 264, 278, 264, 264, 264, 279, 264, 264, 264, 272, - 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - 272, 272, 272, 272, 272, 272, 272, 273, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 274, 264, - 264, 275, 264, 276, 277, 272, 272, 272, 272, 264, - 264, 278, 264, 264, 279, 264, 272, 272, 272, 272, - 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - 272, 272, 272, 272, 272, 264, 264, 264, 264, 264, - 264, 272, 272, 272, 272, 272, 272, 272, 272, 272, - 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - - 272, 272, 272, 264, 264, 264, 272, 272, 272, 272, - 272, 272, 272, 272, 272, 272, 272, 272, 272, 272, - 272, 272, 264, 264, 272, 272, 272, 272, 272, 272, - 272, 272, 272, 272, 272, 272, 264, 264, 272, 272, - 272, 272, 272, 272, 272, 264, 264, 272, 272, 272, - 272, 264, 264, 272, 264, 280, 272, 264, 280, 264, - 272, 264, 272, 0, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264 + 272, 272, 273, 273, 274, 274, 275, 275, 271, 9, + 9, 11, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 276, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 277, 271, 278, 279, 279, 279, 279, + 279, 271, 271, 271, 271, 271, 271, 279, 279, 279, + 279, 279, 279, 279, 279, 279, 279, 279, 279, 271, + 271, 271, 280, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 281, 271, 271, 271, 271, 271, 271, + 282, 283, 279, 284, 279, 279, 279, 279, 271, 271, + + 271, 285, 271, 271, 271, 286, 271, 271, 271, 279, + 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + 279, 279, 279, 279, 279, 279, 279, 280, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 281, 271, + 271, 282, 271, 283, 284, 279, 279, 279, 279, 271, + 271, 285, 271, 271, 286, 271, 279, 279, 279, 279, + 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + 279, 279, 279, 279, 279, 279, 271, 271, 271, 271, + 271, 271, 279, 279, 279, 279, 279, 279, 279, 279, + 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + + 279, 279, 279, 279, 279, 271, 271, 271, 279, 279, + 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + 279, 279, 279, 279, 279, 271, 271, 279, 279, 279, + 279, 279, 279, 279, 279, 279, 279, 279, 279, 279, + 271, 271, 279, 279, 279, 279, 279, 279, 279, 279, + 271, 271, 279, 279, 279, 279, 279, 271, 271, 279, + 279, 271, 287, 279, 271, 287, 271, 279, 271, 279, + 0, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271 } ; -static yyconst short int yy_nxt[628] = +static yyconst short int yy_nxt[642] = { 0, - 264, 15, 16, 17, 15, 16, 17, 264, 264, 21, + 271, 15, 16, 17, 15, 16, 17, 271, 271, 21, 18, 23, 24, 18, 23, 24, 72, 25, 73, 79, 25, 83, 86, 84, 19, 94, 94, 19, 40, 41, 42, 94, 94, 26, 20, 94, 26, 20, 28, 29, @@ -485,8 +488,8 @@ static yyconst short int yy_nxt[628] = 28, 29, 30, 37, 38, 31, 94, 94, 32, 94, 94, 94, 94, 110, 94, 94, 113, 114, 94, 94, - 94, 94, 33, 94, 115, 254, 94, 94, 34, 106, - 168, 111, 146, 96, 182, 225, 112, 117, 116, 118, + 94, 94, 33, 94, 115, 260, 94, 94, 34, 106, + 169, 111, 146, 96, 183, 228, 112, 117, 116, 118, 122, 123, 165, 125, 120, 147, 119, 121, 148, 124, 35, 36, 14, 15, 16, 17, 14, 14, 14, 14, 14, 14, 45, 14, 14, 14, 46, 14, 14, 47, @@ -496,60 +499,62 @@ static yyconst short int yy_nxt[628] = 51, 47, 47, 47, 52, 14, 53, 54, 55, 56, 56, 134, 86, 94, 94, 151, 151, 151, 154, 154, - 154, 103, 262, 104, 104, 105, 57, 94, 94, 58, - 258, 59, 60, 61, 62, 94, 94, 63, 64, 126, + 154, 103, 269, 104, 104, 105, 57, 94, 94, 58, + 265, 59, 60, 61, 62, 94, 94, 63, 64, 126, 149, 65, 66, 127, 67, 158, 68, 69, 94, 70, 71, 87, 103, 94, 105, 105, 105, 159, 94, 135, 136, 103, 94, 107, 107, 107, 108, 108, 108, 94, 160, 161, 94, 94, 94, 94, 94, 94, 162, 94, 166, 94, 94, 151, 151, 151, 109, 163, 154, 154, - 154, 164, 108, 108, 108, 167, 94, 170, 94, 94, - 94, 172, 169, 94, 184, 175, 171, 94, 173, 174, - - 94, 94, 109, 94, 183, 185, 94, 94, 94, 189, - 94, 191, 94, 94, 94, 94, 94, 94, 94, 94, - 187, 186, 188, 207, 192, 190, 94, 94, 94, 94, - 94, 94, 94, 193, 196, 194, 94, 203, 94, 198, - 197, 201, 195, 200, 94, 94, 94, 199, 202, 219, - 185, 94, 94, 209, 208, 210, 214, 94, 215, 94, - 94, 211, 212, 213, 217, 94, 94, 94, 218, 221, - 216, 94, 94, 220, 226, 94, 94, 94, 94, 227, - 94, 94, 239, 94, 94, 94, 222, 231, 94, 228, - 94, 229, 233, 232, 230, 236, 94, 256, 94, 248, - - 94, 260, 242, 255, 235, 243, 234, 240, 256, 257, - 244, 245, 241, 260, 260, 94, 94, 94, 250, 251, - 261, 94, 94, 253, 249, 252, 260, 94, 263, 14, - 14, 14, 14, 14, 14, 22, 22, 22, 22, 22, - 22, 27, 27, 27, 27, 27, 27, 39, 39, 39, - 39, 39, 39, 85, 94, 85, 85, 85, 85, 89, - 94, 89, 89, 89, 89, 92, 92, 93, 93, 93, - 93, 128, 128, 128, 128, 128, 128, 139, 139, 139, - 139, 139, 139, 142, 142, 142, 142, 142, 142, 144, - 144, 144, 144, 145, 145, 145, 145, 152, 152, 152, - - 152, 152, 152, 155, 247, 155, 259, 246, 259, 259, - 259, 259, 94, 94, 94, 94, 94, 238, 237, 94, - 94, 94, 94, 224, 223, 94, 94, 94, 94, 94, - 94, 206, 205, 204, 94, 153, 94, 94, 143, 181, - 140, 180, 179, 178, 177, 176, 129, 156, 153, 150, - 94, 94, 94, 143, 141, 140, 138, 137, 133, 132, - 131, 130, 129, 94, 74, 88, 74, 74, 78, 75, - 74, 264, 13, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264 + 154, 164, 108, 108, 108, 167, 94, 171, 94, 168, + 94, 173, 170, 94, 185, 176, 172, 94, 174, 175, + + 94, 94, 109, 94, 184, 186, 94, 94, 94, 94, + 94, 94, 190, 94, 94, 94, 94, 94, 192, 94, + 188, 187, 209, 189, 94, 191, 94, 193, 94, 94, + 94, 94, 94, 194, 94, 94, 198, 94, 195, 200, + 205, 203, 197, 196, 202, 199, 201, 94, 94, 94, + 204, 94, 94, 216, 210, 94, 212, 186, 218, 217, + 94, 94, 211, 214, 213, 94, 215, 220, 222, 94, + 94, 221, 94, 94, 94, 94, 224, 94, 94, 94, + 223, 219, 229, 230, 94, 94, 94, 94, 94, 94, + 225, 243, 234, 235, 94, 231, 232, 240, 237, 94, + + 94, 236, 94, 233, 94, 94, 94, 239, 246, 238, + 247, 94, 94, 244, 253, 94, 249, 267, 245, 263, + 268, 264, 267, 248, 94, 257, 250, 255, 256, 267, + 263, 94, 261, 262, 267, 94, 254, 94, 94, 259, + 258, 94, 94, 270, 14, 14, 14, 14, 14, 14, + 22, 22, 22, 22, 22, 22, 27, 27, 27, 27, + 27, 27, 39, 39, 39, 39, 39, 39, 85, 94, + 85, 85, 85, 85, 89, 252, 89, 89, 89, 89, + 92, 92, 93, 93, 93, 93, 128, 128, 128, 128, + 128, 128, 139, 139, 139, 139, 139, 139, 142, 142, + + 142, 142, 142, 142, 144, 144, 144, 144, 145, 145, + 145, 145, 152, 152, 152, 152, 152, 152, 155, 251, + 155, 266, 94, 266, 266, 266, 266, 94, 94, 94, + 94, 242, 241, 94, 94, 94, 94, 227, 226, 94, + 94, 94, 94, 94, 94, 208, 207, 206, 94, 153, + 94, 94, 143, 182, 140, 181, 180, 179, 178, 177, + 129, 156, 153, 150, 94, 94, 94, 143, 141, 140, + 138, 137, 133, 132, 131, 130, 129, 94, 74, 88, + 74, 74, 78, 75, 74, 271, 13, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271 } ; -static yyconst short int yy_chk[628] = +static yyconst short int yy_chk[642] = { 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 2, 1, 3, 3, 2, 4, 4, 18, 3, 18, 31, 4, 32, 37, 32, 1, 49, 50, 2, 7, 7, - 7, 263, 51, 3, 1, 110, 4, 2, 5, 5, + 7, 270, 51, 3, 1, 110, 4, 2, 5, 5, 5, 21, 45, 5, 45, 31, 5, 8, 8, 8, 7, 48, 49, 54, 21, 54, 7, 51, 50, 110, 5, 37, 48, 57, 57, 57, 5, 31, 31, 8, @@ -558,8 +563,8 @@ static yyconst short int yy_chk[628] = 6, 6, 6, 6, 6, 6, 59, 64, 6, 63, 65, 121, 66, 58, 68, 67, 60, 61, 97, 95, - 118, 248, 6, 207, 62, 248, 146, 96, 6, 55, - 121, 59, 95, 59, 146, 207, 59, 64, 63, 65, + 118, 253, 6, 209, 62, 253, 146, 96, 6, 55, + 121, 59, 95, 59, 146, 209, 59, 64, 63, 65, 67, 67, 118, 68, 66, 96, 65, 66, 97, 67, 6, 6, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, @@ -569,52 +574,54 @@ static yyconst short int yy_chk[628] = 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 80, 86, 69, 98, 100, 100, 100, 103, 103, - 103, 104, 258, 104, 104, 104, 11, 111, 112, 11, - 255, 11, 11, 11, 11, 113, 114, 11, 11, 69, + 103, 104, 265, 104, 104, 104, 11, 111, 112, 11, + 262, 11, 11, 11, 11, 113, 114, 11, 11, 69, 98, 11, 11, 69, 11, 111, 11, 11, 115, 11, 11, 86, 105, 116, 105, 105, 105, 112, 119, 80, 80, 107, 117, 107, 107, 107, 108, 108, 108, 120, 113, 114, 122, 123, 124, 125, 148, 126, 115, 127, 119, 147, 149, 151, 151, 151, 108, 116, 154, 154, - 154, 117, 156, 156, 156, 120, 157, 123, 158, 159, - 160, 125, 122, 162, 148, 127, 124, 161, 125, 126, - - 164, 165, 156, 166, 147, 149, 167, 168, 169, 160, - 170, 162, 171, 172, 174, 173, 175, 183, 182, 188, - 158, 157, 159, 182, 164, 161, 186, 191, 189, 199, - 193, 194, 196, 165, 168, 166, 197, 175, 195, 170, - 169, 173, 167, 172, 200, 201, 198, 171, 174, 199, - 183, 202, 208, 188, 186, 189, 195, 210, 196, 212, - 214, 191, 193, 194, 198, 213, 217, 215, 198, 201, - 197, 218, 219, 200, 208, 221, 225, 222, 226, 210, - 228, 229, 225, 230, 236, 239, 202, 215, 235, 212, - 240, 213, 218, 217, 214, 222, 242, 253, 244, 239, - - 254, 256, 229, 252, 221, 230, 219, 226, 253, 254, - 235, 236, 228, 256, 259, 257, 261, 251, 242, 244, - 257, 250, 249, 247, 240, 246, 259, 245, 261, 265, - 265, 265, 265, 265, 265, 266, 266, 266, 266, 266, - 266, 267, 267, 267, 267, 267, 267, 268, 268, 268, - 268, 268, 268, 269, 243, 269, 269, 269, 269, 270, - 241, 270, 270, 270, 270, 271, 271, 272, 272, 272, - 272, 273, 273, 273, 273, 273, 273, 274, 274, 274, - 274, 274, 274, 275, 275, 275, 275, 275, 275, 276, - 276, 276, 276, 277, 277, 277, 277, 278, 278, 278, - - 278, 278, 278, 279, 238, 279, 280, 237, 280, 280, - 280, 280, 234, 233, 232, 231, 227, 224, 223, 220, - 216, 211, 209, 206, 204, 203, 192, 190, 187, 185, - 184, 181, 177, 176, 163, 152, 145, 144, 142, 141, - 139, 136, 135, 134, 131, 130, 128, 109, 102, 99, - 94, 93, 92, 91, 87, 84, 82, 81, 79, 76, - 75, 74, 73, 47, 43, 38, 33, 26, 25, 20, - 19, 13, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - 264, 264, 264, 264, 264, 264, 264 + 154, 117, 156, 156, 156, 120, 157, 123, 158, 120, + 159, 125, 122, 160, 148, 127, 124, 161, 125, 126, + + 162, 165, 156, 164, 147, 149, 166, 167, 168, 169, + 171, 172, 160, 170, 173, 174, 175, 183, 162, 176, + 158, 157, 183, 159, 184, 161, 187, 164, 189, 190, + 192, 194, 198, 165, 195, 196, 169, 197, 166, 171, + 176, 174, 168, 167, 173, 170, 172, 199, 201, 200, + 175, 202, 203, 196, 187, 204, 190, 184, 198, 197, + 210, 212, 189, 194, 192, 214, 195, 200, 201, 216, + 215, 200, 217, 218, 220, 222, 203, 221, 224, 225, + 202, 199, 210, 212, 229, 228, 231, 232, 233, 234, + 204, 228, 217, 218, 239, 214, 215, 225, 221, 240, + + 243, 220, 244, 216, 249, 246, 248, 224, 232, 222, + 233, 256, 260, 229, 243, 264, 239, 263, 231, 259, + 264, 260, 266, 234, 261, 249, 240, 246, 248, 263, + 259, 268, 256, 258, 266, 257, 244, 255, 254, 252, + 251, 250, 247, 268, 272, 272, 272, 272, 272, 272, + 273, 273, 273, 273, 273, 273, 274, 274, 274, 274, + 274, 274, 275, 275, 275, 275, 275, 275, 276, 245, + 276, 276, 276, 276, 277, 242, 277, 277, 277, 277, + 278, 278, 279, 279, 279, 279, 280, 280, 280, 280, + 280, 280, 281, 281, 281, 281, 281, 281, 282, 282, + + 282, 282, 282, 282, 283, 283, 283, 283, 284, 284, + 284, 284, 285, 285, 285, 285, 285, 285, 286, 241, + 286, 287, 238, 287, 287, 287, 287, 237, 236, 235, + 230, 227, 226, 223, 219, 213, 211, 208, 206, 205, + 193, 191, 188, 186, 185, 182, 178, 177, 163, 152, + 145, 144, 142, 141, 139, 136, 135, 134, 131, 130, + 128, 109, 102, 99, 94, 93, 92, 91, 87, 84, + 82, 81, 79, 76, 75, 74, 73, 47, 43, 38, + 33, 26, 25, 20, 19, 13, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271, 271, 271, 271, 271, 271, 271, 271, 271, 271, + 271 } ; static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr; @@ -708,7 +715,7 @@ add_to_cbuf(char *s) #define CLASS_CODE_I 5 -#line 712 "lex.yy.c" +#line 719 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -865,7 +872,7 @@ YY_DECL #line 74 "lexer.l" -#line 869 "lex.yy.c" +#line 876 "lex.yy.c" if ( yy_init ) { @@ -914,14 +921,14 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 265 ) + if ( yy_current_state >= 272 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; *yy_state_ptr++ = yy_current_state; ++yy_cp; } - while ( yy_base[yy_current_state] != 573 ); + while ( yy_base[yy_current_state] != 587 ); yy_find_action: yy_current_state = *--yy_state_ptr; @@ -1313,71 +1320,76 @@ YY_RULE_SETUP case 53: YY_RULE_SETUP #line 230 "lexer.l" -{yylval.line = line_no; return ARGUMENT;} +{yylval.line = line_no; return PROTECTED;} YY_BREAK case 54: YY_RULE_SETUP #line 231 "lexer.l" -{yylval.line = line_no; return VIRTUAL;} +{yylval.line = line_no; return ARGUMENT;} YY_BREAK case 55: YY_RULE_SETUP #line 232 "lexer.l" -{yylval.line = line_no; return SIGNAL;} +{yylval.line = line_no; return VIRTUAL;} YY_BREAK case 56: YY_RULE_SETUP #line 233 "lexer.l" -{yylval.line = line_no; return OVERRIDE;} +{yylval.line = line_no; return SIGNAL;} YY_BREAK case 57: YY_RULE_SETUP #line 234 "lexer.l" -{return ONERROR;} +{yylval.line = line_no; return OVERRIDE;} YY_BREAK case 58: YY_RULE_SETUP #line 235 "lexer.l" +{return ONERROR;} + YY_BREAK +case 59: +YY_RULE_SETUP +#line 236 "lexer.l" { yylval.id = g_strdup(yytext); return NUMBER; } YY_BREAK -case 59: +case 60: YY_RULE_SETUP -#line 239 "lexer.l" +#line 240 "lexer.l" { yylval.id = g_strdup(yytext); return TYPETOKEN; } YY_BREAK -case 60: +case 61: YY_RULE_SETUP -#line 243 "lexer.l" +#line 244 "lexer.l" { yylval.id = g_strdup(yytext); return TOKEN; } YY_BREAK -case 61: +case 62: YY_RULE_SETUP -#line 248 "lexer.l" +#line 249 "lexer.l" { yylval.id = g_strdup(yytext); return ARRAY_DIM; } YY_BREAK -case 62: +case 63: YY_RULE_SETUP -#line 253 "lexer.l" +#line 254 "lexer.l" { BEGIN(CLASS_CODE_I); return '{'; } YY_BREAK -case 63: +case 64: YY_RULE_SETUP -#line 257 "lexer.l" +#line 258 "lexer.l" { BEGIN(C_CODE); parenth_depth=1; @@ -1388,38 +1400,38 @@ YY_RULE_SETUP return '{'; } YY_BREAK -case 64: +case 65: YY_RULE_SETUP -#line 266 "lexer.l" +#line 267 "lexer.l" { BEGIN(INITIAL); return '}'; } YY_BREAK -case 65: +case 66: YY_RULE_SETUP -#line 271 "lexer.l" +#line 272 "lexer.l" ; /*ignore*/ YY_BREAK -case 66: +case 67: YY_RULE_SETUP -#line 273 "lexer.l" +#line 274 "lexer.l" { yylval.line = line_no; return yytext[0]; } YY_BREAK -case 67: +case 68: YY_RULE_SETUP -#line 278 "lexer.l" +#line 279 "lexer.l" ; /*ignore*/ YY_BREAK -case 68: +case 69: YY_RULE_SETUP -#line 279 "lexer.l" +#line 280 "lexer.l" ECHO; YY_BREAK -#line 1423 "lex.yy.c" +#line 1435 "lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(COMMENT): case YY_STATE_EOF(C_CODE): @@ -1714,7 +1726,7 @@ static yy_state_type yy_get_previous_state() while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 265 ) + if ( yy_current_state >= 272 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1744,11 +1756,11 @@ yy_state_type yy_current_state; while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 265 ) + if ( yy_current_state >= 272 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 264); + yy_is_jam = (yy_current_state == 271); if ( ! yy_is_jam ) *yy_state_ptr++ = yy_current_state; @@ -2306,4 +2318,4 @@ int main() return 0; } #endif -#line 279 "lexer.l" +#line 280 "lexer.l" diff --git a/src/lexer.l b/src/lexer.l index 448da95..d80b927 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -227,6 +227,7 @@ class { public {yylval.line = line_no; return PUBLIC;} private {yylval.line = line_no; return PRIVATE;} +protected {yylval.line = line_no; return PROTECTED;} argument {yylval.line = line_no; return ARGUMENT;} virtual {yylval.line = line_no; return VIRTUAL;} signal {yylval.line = line_no; return SIGNAL;} diff --git a/src/main.c b/src/main.c index 751c064..b429ef9 100644 --- a/src/main.c +++ b/src/main.c @@ -57,8 +57,9 @@ static char *ptypebase; static int signals = 0; /* number of signals */ static int arguments = 0; /* number of named arguments */ -static int overrides = 0; /* number of override functions */ +static int overrides = 0; /* number of override methods */ static int privates = 0; /* number of private data members */ +static int protecteds = 0; /* number of protected methods */ static gboolean made_aliases = FALSE; /* if we made any shorthand aliases and need the REALLY UGLY HACK to @@ -203,8 +204,9 @@ print_type(FILE *fp, Type *t, gboolean postfix_to_stars) if(postfix_to_stars) { char *p; /*XXX: this is ugly perhaps we can do this whole postfix thing - in a nicer way, we just count the number of '[' s and from that - we deduce the number of dimensions */ + in a nicer way, we just count the number of '[' s and from + that we deduce the number of dimensions, so that we can print + that many stars */ for(p=t->postfix; p && *p; p++) if(*p == '[') extra++; } @@ -262,9 +264,9 @@ make_method_pointers(Class *c) if(node->type == METHOD_NODE) { Method *m = (Method *)node; - if(m->scope == INIT_METHOD || - m->scope == CLASS_INIT_METHOD || - m->scope == OVERRIDE_METHOD) + if(m->method == INIT_METHOD || + m->method == CLASS_INIT_METHOD || + m->method == OVERRIDE_METHOD) continue; /* in C++ mode don't alias new */ @@ -291,21 +293,19 @@ add_bad_hack_to_avoid_unused_warnings(Class *c) out_printf(out,"\n\n/*REALLY BAD HACK\n" " This is to avoid unused warnings if you don't call\n" - " some method, it pollutes the namespace but the call\n" - " is weird enough. I need to find a better way to do\n" + " some method. I need to find a better way to do\n" " this */\n"); - out_printf(out,"void __%s_really_bad_hack_to_avoid_warnings(void);\n", - funcbase); - out_printf(out,"void\n__%s_really_bad_hack_to_avoid_warnings(void)\n" + out_printf(out,"static void\n" + "__%s_really_bad_hack_to_avoid_warnings(void)\n" "{\n",funcbase); for(li=c->nodes;li;li=g_list_next(li)) { Node *node = li->data; if(node->type == METHOD_NODE) { Method *m = (Method *)node; - if(m->scope == INIT_METHOD || - m->scope == CLASS_INIT_METHOD || - m->scope == OVERRIDE_METHOD) + if(m->method == INIT_METHOD || + m->method == CLASS_INIT_METHOD || + m->method == OVERRIDE_METHOD) continue; /* in C++ mode we don't alias new */ @@ -315,6 +315,8 @@ add_bad_hack_to_avoid_unused_warnings(Class *c) out_printf(out,"\t((void (*)(void))%s)();\n",m->id); } } + out_printf(out, "\t__%s_really_bad_hack_to_avoid_warnings();\n", + funcbase); out_printf(out,"}\n\n"); } @@ -323,20 +325,20 @@ put_variable(Variable *v, FILE *fp) { out_printf(fp,"\t"); print_type(fp,v->vtype,FALSE); - out_printf(fp,"%s%s;\n",v->id, + out_printf(fp,"%s%s;",v->id, v->vtype->postfix? v->vtype->postfix:""); + if(v->scope == PROTECTED_SCOPE) + out_printf(fp," /* protected */"); + out_printf(fp,"\n"); } static void put_vs_method(Method *m) { - if(m->scope != SIGNAL_LAST_METHOD && - m->scope != SIGNAL_FIRST_METHOD && - m->scope != PRIVATE_SIGNAL_LAST_METHOD && - m->scope != PRIVATE_SIGNAL_FIRST_METHOD && - m->scope != VIRTUAL_METHOD && - m->scope != PRIVATE_VIRTUAL_METHOD) + if(m->method != SIGNAL_LAST_METHOD && + m->method != SIGNAL_FIRST_METHOD && + m->method != VIRTUAL_METHOD) return; print_method(outh,"\t","(* ",") ",";\n",m,TRUE); @@ -345,39 +347,40 @@ put_vs_method(Method *m) static void put_pub_method(Method *m) { - if(m->scope == PRIVATE_SCOPE || - m->scope == OVERRIDE_METHOD || - m->scope == INIT_METHOD || - m->scope == CLASS_INIT_METHOD || - m->scope == PRIVATE_SIGNAL_LAST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_VIRTUAL_METHOD) + if(m->scope != PUBLIC_SCOPE) return; print_method(outh,"","\t","\t",";\n",m,FALSE); } static void -put_priv_method_prot(Method *m) +put_prot_method(Method *m) { - if(m->scope == PUBLIC_SCOPE) + if(m->scope != PROTECTED_SCOPE) return; - if(m->scope == PRIVATE_SIGNAL_LAST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_VIRTUAL_METHOD) { - if(m->cbuf && *m->cbuf->str) + if(outph) + print_method(outph,"","\t","\t",";\n",m,FALSE); + else + print_method(out,"","\t","\t",";\n",m,FALSE); +} + +static void +put_priv_method_prot(Method *m) +{ + if(m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD || + m->method == VIRTUAL_METHOD) { + if(m->cbuf) 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 || !*m->cbuf->str) - return; - print_method(out,"static ","_real_"," ",";\n",m,FALSE); - } else { - print_method(out,"static ",""," ",";\n",m,FALSE); } + + if(m->scope == PRIVATE_SCOPE || + m->method == INIT_METHOD || + m->method == CLASS_INIT_METHOD || + (m->method == OVERRIDE_METHOD && + m->cbuf)) + print_method(out,"static ",""," ",";\n",m,FALSE); } static GList * @@ -408,11 +411,11 @@ make_inits(Class *cl) Node *n = li->data; if(n->type == METHOD_NODE) { Method *m = (Method *)n; - if(m->scope == INIT_METHOD) { + if(m->method == INIT_METHOD) { if(got_init) print_error(FALSE,"init defined more then once",m->line_no); got_init = TRUE; - } else if(m->scope == CLASS_INIT_METHOD) { + } else if(m->method == CLASS_INIT_METHOD) { if(got_class_init) print_error(FALSE,"class_init defined more then once",m->line_no); got_class_init = TRUE; @@ -420,7 +423,7 @@ make_inits(Class *cl) } } if(!got_class_init) { - node = new_method(CLASS_INIT_METHOD, + node = new_method(NO_SCOPE, CLASS_INIT_METHOD, (Type *)new_type(0,g_strdup("void"),NULL), NULL,NULL,g_strdup("class_init"), make_func_arg(cl->otype,TRUE,g_strdup("c")), @@ -428,7 +431,7 @@ make_inits(Class *cl) cl->nodes = g_list_prepend(cl->nodes,node); } if(!got_init) { - node = new_method(INIT_METHOD, + node = new_method(NO_SCOPE, INIT_METHOD, (Type *)new_type(0,g_strdup("void"),NULL), NULL,NULL,g_strdup("init"), make_func_arg(cl->otype,FALSE,g_strdup("o")), @@ -447,7 +450,7 @@ make_destroy(Class *cl) Node *n = li->data; if(n->type == METHOD_NODE) { Method *m = (Method *)n; - if(m->scope == OVERRIDE_METHOD && + if(m->method == OVERRIDE_METHOD && strcmp(m->id,"destroy")==0) { if(strcmp(m->otype,"Gtk:Object")==0) { got_destroy = TRUE; @@ -462,32 +465,132 @@ make_destroy(Class *cl) } } if(!got_destroy) { - node = new_method(OVERRIDE_METHOD, + node = new_method(NO_SCOPE, OVERRIDE_METHOD, (Type *)new_type(0,g_strdup("void"),NULL), g_strdup("Gtk:Object"), NULL,g_strdup("destroy"), make_func_arg("Gtk:Object",FALSE,g_strdup("o")), NULL, - g_string_new("PARENT_HANDLER (o);\n"), + g_strdup("PARENT_HANDLER (o);\n"), 0,0,FALSE); cl->nodes = g_list_append(cl->nodes,node); overrides++; } } +/* here we will find out how inconsistent gtk really is :) */ +/* the commented out types mean that these types don't actually + exist. so we "emulate them" with an equivalent */ +const struct { + char *gtkname; + char *typename; +} our_gtk_type_table[] = { + { "NONE", "void" }, + { "CHAR", "gchar" }, + { "UCHAR", "guchar" }, + { "BOOL", "gboolean" }, + { "INT", "gint" }, + { "UINT", "guint" }, + { "LONG", "glong" }, + { "ULONG", "gulong" }, + { "FLOAT", "gfloat" }, + { "DOUBLE", "gdouble" }, + { "STRING", /*"GtkString"*/"gchar *" }, + { "ENUM", /*"GtkEnum"*/"gint" }, + { "FLAGS", /*"GtkFlags"*/"guint" }, + { "BOXED", /*"GtkBoxed"*/"gpointer" }, + { "POINTER", "gpointer" }, + { "OBJECT", "GtkObject *" }, + { "SIGNAL", /*"GtkSignal"*/"__twopointertype" }, + { "ARGS", /*"GtkArgs"*/"__twopointertype" }, + { "CALLBACK", /*"GtkCallback"*/"__threepointertype" }, + { "C_CALLBACK", /*"GtkCCallback"*/"__twopointertype" }, + { "FOREIGN", /*"GtkForeign"*/"__twopointertype" }, + + { NULL, NULL } +}; + +static const char * +get_cast(char *type) +{ + int i; + for(i=0;our_gtk_type_table[i].gtkname;i++) { + if(strcmp(our_gtk_type_table[i].gtkname,type)==0) { + return our_gtk_type_table[i].typename; + } + } + return NULL; +} + + +/* hash of method -> name of signal prototype */ static GHashTable *marsh = NULL; +/* list of methods with different signal prototypes, + we check this list if we can use a signal prototype of a + previous signal method, there are only uniques here */ +static GList *eq_signal_methods = NULL; + +/* compare a list of strings */ +static gboolean +is_list_equal(GList *a, GList *b) +{ + for(;a && b; a=a->next, b=b->next) { + if(strcmp(a->data,b->data)!=0) { + return FALSE; + } + } + /* the the lists were different length */ + if(a || b) + return FALSE; + return TRUE; +} + +static Method * +find_same_type_signal(Method *m) +{ + GList *li; + for(li=eq_signal_methods;li;li=li->next) { + Method *mm = li->data; + if(is_list_equal(mm->gtktypes,m->gtktypes)) + return mm; + } + return NULL; +} + +static void +print_signal_marsal_args(Method *m) +{ + if(strcmp(m->gtktypes->next->data,"NONE")!=0) { + GList *li; + int i; + for(i=0,li=m->gtktypes->next;li; + i++,li=g_list_next(li)) { + if(!for_cpp) + out_printf(out, ",\n\t\tGTK_VALUE_%s(args[%d])", + (char *)li->data,i); + else { + out_printf(out, ",\n\t\t(%s)" + "GTK_VALUE_%s(args[%d])", + get_cast(li->data), + (char *)li->data,i); + } + } + } + out_printf(out, ",\n\t\tfunc_data);\n}\n\n"); +} + + static void add_signal_prots(Method *m) { GList *li; static int sig = 1; char *s; + Method *mm; - if(m->scope != SIGNAL_LAST_METHOD && - m->scope != SIGNAL_FIRST_METHOD && - m->scope != PRIVATE_SIGNAL_LAST_METHOD && - m->scope != PRIVATE_SIGNAL_FIRST_METHOD) + if(m->method != SIGNAL_LAST_METHOD && + m->method != SIGNAL_FIRST_METHOD) return; if(!marsh) @@ -496,21 +599,26 @@ add_signal_prots(Method *m) 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 */ + mm = find_same_type_signal(m); + if(mm) { + s = g_hash_table_lookup(marsh,mm); + g_hash_table_insert(marsh,m,s); + return; + } s = g_strdup_printf("__Sig%d",sig++); g_hash_table_insert(marsh,m,s); + eq_signal_methods = g_list_prepend(eq_signal_methods,m); - out_printf(out,"\ntypedef "); - print_type(out,m->mtype,TRUE); - - out_printf(out,"(*%s) (",s); + /* we know that we'll know all the gtktypes (so get_cast can't fail) */ + out_printf(out,"\ntypedef %s (*%s) (%s *, ", + get_cast(m->gtktypes->data),s, typebase); - for(li=m->args;li;li=g_list_next(li)) { - FuncArg *arg = li->data; - print_type(out,arg->atype,TRUE); - out_printf(out,", "); - } + for(li=m->gtktypes->next;li;li=g_list_next(li)) + out_printf(out,"%s, ",get_cast(li->data)); out_printf(out,"gpointer);\n"); out_printf(out,"\nstatic void\n" @@ -521,31 +629,10 @@ add_signal_prots(Method *m) "{\n",s); if(strcmp(m->gtktypes->data,"NONE")==0) { - int i; out_printf(out, "\t%s rfunc;\n\n" "\trfunc = (%s)func;\n\n" "\t(*rfunc)((%s *)object",s,s,typebase); - if(strcmp(m->gtktypes->next->data,"NONE")!=0) { - GList *ali = m->args->next; - for(i=0,li=m->gtktypes->next;li; - i++,li=g_list_next(li)) { - if(!for_cpp || !ali) - out_printf(out, ",\n\t\tGTK_VALUE_%s(args[%d])", - (char *)li->data,i); - else { - FuncArg *fa = ali->data; - out_printf(out, ",\n\t\t("); - print_type(out,fa->atype,TRUE); - out_printf(out, ")GTK_VALUE_%s(args[%d])", - (char *)li->data,i); - } - - if(ali) ali = ali->next; - } - } - out_printf(out, ",\n\t\tfunc_data);\n}\n\n"); } else { - int i; out_printf(out, "\t%s rfunc;\n\t",s); print_type(out,m->mtype,TRUE); out_printf(out, " *retval;\n\n" @@ -554,26 +641,8 @@ add_signal_prots(Method *m) "\t*retval = (*rfunc)((%s *)object", s,(char *)m->gtktypes->data, g_list_length(m->gtktypes)-1,typebase); - if(strcmp(m->gtktypes->next->data,"NONE")!=0) { - GList *ali = m->args->next; - for(i=0,li=m->gtktypes->next;li; - i++,li=g_list_next(li)) { - if(!for_cpp || !ali) - out_printf(out, ",\n\t\tGTK_VALUE_%s(args[%d])", - (char *)li->data,i); - else { - FuncArg *fa = ali->data; - out_printf(out, ",\n\t\t("); - print_type(out,fa->atype,TRUE); - out_printf(out, ")GTK_VALUE_%s(args[%d])", - (char *)li->data,i); - } - - if(ali) ali = ali->next; - } - } - out_printf(out, ",\n\t\tfunc_data);\n}\n\n"); } + print_signal_marsal_args(m); } @@ -588,10 +657,8 @@ add_enums(Class *c) Node *n = li->data; if(n->type == METHOD_NODE) { Method *m = (Method *)n; - if(m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_SIGNAL_LAST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD) { + if(m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD) { char *s = g_strdup(m->id); g_strup(s); out_printf(out,"\t%s_SIGNAL,\n",s); @@ -664,11 +731,10 @@ add_overrides(Class *c, char *oname, gboolean did_gtk_obj) for(li=c->nodes;li;li=g_list_next(li)) { Node *n = li->data; char *f; - Method *m; + Method *m = (Method *)n; if(n->type != METHOD_NODE || - ((Method *)n)->scope != OVERRIDE_METHOD) + m->method != OVERRIDE_METHOD) continue; - m = (Method *)n; s = remove_sep(m->otype); @@ -698,22 +764,18 @@ add_signals(Class *c) out_printf(out,"\n"); for(li=c->nodes;li;li=g_list_next(li)) { Node *n = li->data; - Method *m; char *mar; char *sig; int is_none; int last = FALSE; + Method *m = (Method *)n; if(n->type != METHOD_NODE || - (((Method *)n)->scope != SIGNAL_FIRST_METHOD && - ((Method *)n)->scope != SIGNAL_LAST_METHOD && - ((Method *)n)->scope != PRIVATE_SIGNAL_FIRST_METHOD && - ((Method *)n)->scope != PRIVATE_SIGNAL_LAST_METHOD)) + (m->method != SIGNAL_FIRST_METHOD && + m->method != SIGNAL_LAST_METHOD)) continue; - m = (Method *)n; - if(m->scope == SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD) + if(m->method == SIGNAL_FIRST_METHOD) last = FALSE; else last = TRUE; @@ -764,27 +826,27 @@ set_def_handlers(Class *c, char *oname) out_printf(out,"\n"); for(li=c->nodes;li;li=g_list_next(li)) { Node *n = li->data; - Method *m; + Method *m = (Method *)n; if(n->type != METHOD_NODE || - (((Method *)n)->scope != SIGNAL_FIRST_METHOD && - ((Method *)n)->scope != SIGNAL_LAST_METHOD && - ((Method *)n)->scope != PRIVATE_SIGNAL_FIRST_METHOD && - ((Method *)n)->scope != PRIVATE_SIGNAL_LAST_METHOD && - ((Method *)n)->scope != VIRTUAL_METHOD && - ((Method *)n)->scope != PRIVATE_VIRTUAL_METHOD && - ((Method *)n)->scope != OVERRIDE_METHOD)) + (m->method != SIGNAL_FIRST_METHOD && + m->method != SIGNAL_LAST_METHOD && + m->method != VIRTUAL_METHOD && + m->method != OVERRIDE_METHOD)) continue; - m = (Method *)n; - if(m->scope == OVERRIDE_METHOD) { + if(m->method == OVERRIDE_METHOD) { char *s; s = replace_sep(m->otype,'_'); g_strdown(s); - out_printf(out,"\t%s_class->%s = %s_%s;\n", - s,m->id,funcbase,m->id); + if(m->cbuf) + out_printf(out,"\t%s_class->%s = %s_%s;\n", + s,m->id,funcbase,m->id); + else + out_printf(out,"\t%s_class->%s = NULL;\n", + s,m->id); } else { - if(m->cbuf && *m->cbuf->str) + if(m->cbuf) out_printf(out,"\t%s->%s = _real_%s_%s;\n", oname,m->id,funcbase,m->id); else @@ -847,7 +909,7 @@ add_inits(Class *c) if(n->type != METHOD_NODE) continue; m = (Method *)n; - if(m->scope == INIT_METHOD) { + if(m->method == INIT_METHOD) { if(m->line_no>0) out_addline_infile(out,m->line_no); print_method(out,"static ","\n"," ","\n",m,FALSE); @@ -860,7 +922,7 @@ add_inits(Class *c) ((FuncArg *)m->args->data)->name, typebase); } - } else if(m->scope == CLASS_INIT_METHOD) { + } else if(m->method == CLASS_INIT_METHOD) { if(m->line_no>0) out_addline_infile(out,m->line_no); print_method(out,"static ","\n"," ","\n",m,FALSE); @@ -897,12 +959,12 @@ add_inits(Class *c) } else continue; - if(m->cbuf && *m->cbuf->str) { + if(m->cbuf) { out_printf(out," {\n"); out_addline_infile(out,m->ccode_line); - out_printf(out,"%s\n",m->cbuf->str); + out_printf(out,"%s\n",m->cbuf); out_addline_outfile(out); - out_printf(out," }\n",m->cbuf->str); + out_printf(out," }\n"); } else { out_printf(out,"return;\n"); } @@ -928,7 +990,7 @@ add_getset_arg(Class *c, int is_set) Node *n = li->data; Argument *a; char *s; - GString *cbuf; + char *cbuf; int line_no; if(n->type != ARGUMENT_NODE) continue; @@ -950,7 +1012,7 @@ add_getset_arg(Class *c, int is_set) s,a->gtktype); g_free(s); out_addline_infile(out,line_no); - out_printf(out,"%s\n",cbuf->str); + out_printf(out,"%s\n",cbuf); out_addline_outfile(out); out_printf(out,"\t\t}\n\t\tbreak;\n" "#undef ARG\n"); @@ -962,7 +1024,7 @@ static void print_checks(Method *m, FuncArg *fa) { GList *li; - int is_void; + gboolean is_void; is_void = (strcmp(m->mtype->name,"void")==0 && m->mtype->stars == 0); @@ -1030,7 +1092,7 @@ put_in_gen_code(Method *m) { /* now we only have the freeing of the private structure */ if(privates>0 && - m->scope == OVERRIDE_METHOD && + m->method == OVERRIDE_METHOD && strcmp(m->id,"destroy")==0) { out_printf(out,"\tg_free (%s (%s)->_priv);\n" "\t%s (%s)->_priv = NULL;\n", @@ -1050,62 +1112,80 @@ print_method_body(Method *m, int pre) print_preconditions(m); put_in_gen_code(m); - out_printf(out,"\t{\n"); - - out_addline_infile(out,m->ccode_line); - out_printf(out,"\t\t%s\n",m->cbuf->str); - out_addline_outfile(out); + /* Note: the trailing }'s are on one line, this is so + that we get the no return warning correctly and point to + the correct line in the .gob file, yes this is slightly + ugly in the .c file, but that is not supposed to be + human readable anyway. */ + if(m->cbuf) { + out_printf(out,"{\n"); + out_addline_infile(out,m->ccode_line); + out_printf(out,"\t%s}",m->cbuf); + } - out_printf(out,"\t}\n"); out_printf(out,"}\n"); + + if(m->cbuf) + out_addline_outfile(out); +} + +static void +put_signal_args(Method *m) +{ + GList *li; + GList *ali; + for(ali = m->gtktypes->next,li=m->args->next; + li && ali; + li=li->next, ali=ali->next) { + FuncArg *fa = li->data; + const char *cast = get_cast(ali->data); + /* we should have already proved before that + the we know all the types */ + g_assert(cast); + + out_printf(out,",\n\t\t(%s)%s",cast, + fa->name); + } } static void put_method(Method *m) { char *s; - int private = FALSE; - int is_void; + gboolean is_void; is_void = (strcmp(m->mtype->name,"void")==0 && m->mtype->stars == 0); out_printf(out,"\n"); - switch(m->scope) { - case PUBLIC_SCOPE: - out_addline_infile(out,m->line_no); - print_method(out,"","\n"," ","\n",m,FALSE); - print_method_body(m,TRUE); - break; - case PRIVATE_SCOPE: + switch(m->method) { + case REGULAR_METHOD: out_addline_infile(out,m->line_no); - print_method(out,"static ","\n"," ","\n",m,FALSE); + if(m->scope == PRIVATE_SCOPE) + print_method(out,"static ","\n"," ","\n",m,FALSE); + else /* PUBLIC, PROTECTED */ + print_method(out,"","\n"," ","\n",m,FALSE); print_method_body(m,TRUE); break; - case PRIVATE_SIGNAL_FIRST_METHOD: - case PRIVATE_SIGNAL_LAST_METHOD: - private = TRUE; case SIGNAL_FIRST_METHOD: case SIGNAL_LAST_METHOD: out_addline_infile(out,m->line_no); - print_method(out,private?"static ":"","\n"," ","\n",m,FALSE); + if(m->scope == PRIVATE_SCOPE) + print_method(out,"static ","\n"," ","\n",m,FALSE); + else + print_method(out,"","\n"," ","\n",m,FALSE); out_addline_outfile(out); out_printf(out,"{\n"); s = g_strdup(m->id); g_strup(s); if(strcmp(m->mtype->name,"void")==0 && m->mtype->stars==0) { - GList *li; print_preconditions(m); if(((FuncArg *)m->args->data)->name) out_printf(out,"\tgtk_signal_emit (GTK_OBJECT (%s),\n" "\t\tobject_signals[%s_SIGNAL]", ((FuncArg *)m->args->data)->name,s); - for(li=m->args->next;li;li=g_list_next(li)) { - FuncArg *fa = li->data; - out_printf(out,",\n\t\t%s",fa->name); - } + put_signal_args(m); out_printf(out,");\n}\n"); } else { - GList *li; out_printf(out,"\t"); print_type(out,m->mtype,TRUE); out_printf(out,"return_val;\n"); @@ -1113,25 +1193,23 @@ put_method(Method *m) out_printf(out,"\tgtk_signal_emit (GTK_OBJECT (%s),\n" "\t\tobject_signals[%s_SIGNAL]", ((FuncArg *)m->args->data)->name,s); - for(li=m->args->next;li;li=g_list_next(li)) { - FuncArg *fa = li->data; - out_printf(out,",\n\t\t%s",fa->name); - } + put_signal_args(m); out_printf(out,",\n\t\t&return_val);\n" "\treturn return_val;\n}\n"); } - if(!m->cbuf || !*m->cbuf->str) + if(!m->cbuf) break; out_addline_infile(out,m->line_no); print_method(out,"static ","\n_real_"," ","\n",m,FALSE); print_method_body(m,FALSE); break; - case PRIVATE_VIRTUAL_METHOD: - private = TRUE; case VIRTUAL_METHOD: out_addline_infile(out,m->line_no); - print_method(out,private?"static ":"","\n"," ","\n",m,FALSE); + if(m->scope==PRIVATE_SCOPE) + print_method(out,"static ","\n"," ","\n",m,FALSE); + else + print_method(out,"","\n"," ","\n",m,FALSE); out_addline_outfile(out); out_printf(out,"{\n" "\t%sClass *klass;\n",typebase); @@ -1165,13 +1243,15 @@ put_method(Method *m) m->onerror?m->onerror:"0"); } - if(!m->cbuf || !*m->cbuf->str) + if(!m->cbuf) break; out_addline_infile(out,m->line_no); print_method(out,"static ","\n_real_"," ","\n",m,FALSE); print_method_body(m,FALSE); break; case OVERRIDE_METHOD: + if(!m->cbuf) + break; out_addline_infile(out,m->line_no); print_method(out,"static ","\n"," ","\n",m,FALSE); s = replace_sep(m->otype,'_'); @@ -1202,7 +1282,7 @@ put_method(Method *m) } static void -check_duplicate(Class *c,Node *node,char *id, int line_no) +check_duplicate(Class *c, Node *node, char *id, int line_no) { GList *l; for(l=c->nodes;l;l=g_list_next(l)) { @@ -1256,12 +1336,9 @@ check_bad_symbols(Class *c) Node *n = l->data; if(n->type == METHOD_NODE) { Method *m = (Method *)n; - if((m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_SIGNAL_LAST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD || - m->scope == VIRTUAL_METHOD || - m->scope == PRIVATE_VIRTUAL_METHOD) && + if((m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD || + m->method == VIRTUAL_METHOD) && strcmp(m->id,"__parent__")==0) { char *s; s = g_strdup_printf("'%s' not allowed as an " @@ -1297,10 +1374,8 @@ check_duplicate_named(Class *c,Node *node,char *id, int line_no) char *s; if(n->type == METHOD_NODE) { Method *m = (Method *)n; - if(m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_SIGNAL_LAST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD) { + if(m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD) { nid = m->id; nline_no = m->line_no; } else @@ -1330,10 +1405,8 @@ check_duplicate_signals_args(Class *c) Node *n = l->data; if(n->type == METHOD_NODE) { Method *m = (Method *)n; - if(m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_SIGNAL_LAST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD) + if(m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD) check_duplicate_named(c,n,m->id,m->line_no); } else if(n->type == ARGUMENT_NODE) { Argument *a = (Argument *)n; @@ -1350,10 +1423,12 @@ check_public_new(Class *c) Node *n = l->data; if(n->type == METHOD_NODE) { Method *m = (Method *)n; - if(m->scope!=PUBLIC_SCOPE && - strcmp(m->id,"new")==0) + if((strcmp(m->id,"new")==0) && + (m->method != REGULAR_METHOD || + m->scope != PUBLIC_SCOPE)) print_error(TRUE, - "'new' should be a public method", + "'new' should be a regular\n" + "public method", m->line_no); } } @@ -1369,13 +1444,10 @@ check_vararg(Class *c) Method *m = (Method *)n; if(!m->vararg) continue; - if(m->scope == OVERRIDE_METHOD || - m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_SIGNAL_LAST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD || - m->scope == VIRTUAL_METHOD || - m->scope == PRIVATE_VIRTUAL_METHOD) { + if(m->method == OVERRIDE_METHOD || + m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD || + m->method == VIRTUAL_METHOD) { print_error(FALSE, "signals, overrides and virtuals, " "can't have variable argument " @@ -1396,13 +1468,10 @@ check_firstarg(Class *c) Method *m = (Method *)n; if(m->args) continue; - if(m->scope == OVERRIDE_METHOD || - m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_SIGNAL_LAST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD || - m->scope == VIRTUAL_METHOD || - m->scope == PRIVATE_VIRTUAL_METHOD) { + if(m->method == OVERRIDE_METHOD || + m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD || + m->method == VIRTUAL_METHOD) { print_error(FALSE, "signals, overrides and virtuals, " "can't have no arguments", @@ -1412,6 +1481,62 @@ check_firstarg(Class *c) } } +static void +check_nonvoidempty(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(m->method != REGULAR_METHOD) + continue; + if(!(strcmp(m->mtype->name,"void")==0 && + m->mtype->stars == 0) && + !m->cbuf) { + print_error(TRUE, + "non-void empty method found, " + "regular non-void function should " + "not be empty.", + m->line_no); + /* add a body here, so that the user will also + get a warning from gcc, and so that it will + at least point him to the prototype of the + function in the .gob file */ + m->cbuf = g_strdup("/*empty*/"); + m->ccode_line = m->line_no; + } + } + } +} + +static void +check_signal_args(Class *c) +{ + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + GList *l; + if(m->method != SIGNAL_LAST_METHOD && + m->method != SIGNAL_FIRST_METHOD) + continue; + + for(l=m->gtktypes;l;l=l->next) { + char *s; + if(get_cast(l->data)) + continue; + s = g_strdup_printf("Unknown GTK+ type '%s' " + "among signal types", + (char *)l->data); + print_error(FALSE, s, m->line_no); + g_free(s); + } + } + } +} + static int count_signals(Class *c) { @@ -1421,10 +1546,8 @@ count_signals(Class *c) Node *n = l->data; if(n->type == METHOD_NODE) { Method *m = (Method *)n; - if(m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD || - m->scope == PRIVATE_SIGNAL_LAST_METHOD || - m->scope == PRIVATE_SIGNAL_FIRST_METHOD) + if(m->method == SIGNAL_LAST_METHOD || + m->method == SIGNAL_FIRST_METHOD) num++; } } @@ -1454,7 +1577,7 @@ count_overrides(Class *c) Node *n = l->data; if(n->type == METHOD_NODE) { Method *m = (Method *)n; - if(m->scope == OVERRIDE_METHOD) + if(m->method == OVERRIDE_METHOD) num++; } } @@ -1477,6 +1600,22 @@ count_privates(Class *c) return num; } +static int +count_protecteds(Class *c) +{ + int num = 0; + GList *l; + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + if(n->type == METHOD_NODE) { + Method *m = (Method *)n; + if(m->scope == PROTECTED_SCOPE) + num++; + } + } + return num; +} + static void open_files(void) @@ -1492,7 +1631,7 @@ open_files(void) else outfileh = g_strconcat(filebase,".h",NULL); - if((privates>0 || always_private_header) && + if((privates>0 || protecteds>0 || always_private_header) && !no_private_header) outfileph = g_strconcat(filebase,"-private.h",NULL); else @@ -1593,13 +1732,22 @@ generate_outfiles(void) out_printf(fp,"\n"); out_addline_infile(fp,cc->line_no); } - out_printf(fp,"%s\n",cc->cbuf->str); + out_printf(fp,"%s\n",cc->cbuf); if(!cc->header) out_addline_outfile(fp); } else if(node->type == CLASS_NODE) { Class *c = (Class *)class; GList *l; + out_printf(out,"/* utility types we may need */\n"); + out_printf(out,"typedef struct { " + "gpointer a; gpointer b; " + "} __twopointertype;\n"); + out_printf(out,"typedef struct { " + "gpointer a; gpointer b; " + "gpointer c; " + "} __threepointertype;\n"); + out_printf(outh,"\n#define %s\t" "(%s_get_type())\n", macrotype,funcbase); @@ -1626,6 +1774,14 @@ generate_outfiles(void) v->scope == PUBLIC_SCOPE) put_variable((Variable *)n,outh); } + /* put protecteds always AFTER publics */ + for(l=c->nodes;l;l=g_list_next(l)) { + Node *n = l->data; + Variable *v = (Variable *)n; + if(n->type == VARIABLE_NODE && + v->scope == PROTECTED_SCOPE) + put_variable((Variable *)n,outh); + } if(privates>0) out_printf(outh,"\t%sPrivate *_priv;\n",typebase); out_printf(outh,"};\n"); @@ -1634,7 +1790,7 @@ generate_outfiles(void) FILE *outfp; /* if we are to stick this into the private - header, otherwise stick it directly into the + header, if not stick it directly into the C file */ if(outph) outfp = outph; @@ -1679,10 +1835,12 @@ generate_outfiles(void) "guint arg_id);\n"); } + out_printf(out,"/* here are local prototypes */\n"); for(l=c->nodes;l;l=g_list_next(l)) { Node *n = l->data; if(n->type == METHOD_NODE) { put_pub_method((Method *)n); + put_prot_method((Method *)n); put_priv_method_prot((Method *)n); } } @@ -1690,9 +1848,8 @@ generate_outfiles(void) if(signals>0) { for(l=c->nodes;l;l=g_list_next(l)) { Node *n = l->data; - if(n->type == METHOD_NODE) { + if(n->type == METHOD_NODE) add_signal_prots((Method *)n); - } } } @@ -1756,16 +1913,19 @@ print_help(void) fprintf(stderr,"Gob version %s\n\n",VERSION); fprintf(stderr,"Options:\n" "\t--help,-h,-? Display this help\n" + "\t--version Display version\n" "\t--exit-on-warn,-w Exit with an error on warnings\n" "\t--no-exit-on-warn Don't exit on warnings [default]\n" "\t--for-cpp Create C++ files\n" "\t--no-touch-headers Don't touch headers unless they " "really changed\n" "\t--always-private-header Always create a private header " - "file, even if it would be empty\n" + "file,\n" + "\t even if it would be empty\n" "\t--no-private-header Don't create a private header, " - "put private structure inside c " - "file\n"); + "put private\n" + "\t structure and protected " + "prototypes inside c file\n"); } static void @@ -1790,6 +1950,9 @@ parse_options(int argc, char *argv[]) } else if(strcmp(argv[i],"--help")==0) { print_help(); exit(0); + } else if(strcmp(argv[i],"--version")==0) { + fprintf(stderr,"Gob version %s\n",VERSION); + exit(0); } else if(strcmp(argv[i],"--exit-on-warn")==0) { exit_on_warn = TRUE; } else if(strcmp(argv[i],"--no-exit-on-warn")==0) { @@ -1836,6 +1999,7 @@ parse_options(int argc, char *argv[]) } } +/* this is a somewhat ugly hack, but it appears to work */ static void compare_and_move_header(void) { @@ -1922,6 +2086,7 @@ main(int argc, char *argv[]) arguments = count_arguments((Class *)class); overrides = count_overrides((Class *)class); privates = count_privates((Class *)class); + protecteds = count_protecteds((Class *)class); make_bases(); make_inits((Class *)class); @@ -1933,6 +2098,8 @@ main(int argc, char *argv[]) check_public_new((Class *)class); check_vararg((Class *)class); check_firstarg((Class *)class); + check_nonvoidempty((Class *)class); + check_signal_args((Class *)class); exit_on_error = TRUE; diff --git a/src/parse.c b/src/parse.c index 1d226c4..6614f29 100644 --- a/src/parse.c +++ b/src/parse.c @@ -29,10 +29,11 @@ #define HCODE 279 #define PUBLIC 280 #define PRIVATE 281 -#define ARGUMENT 282 -#define VIRTUAL 283 -#define SIGNAL 284 -#define OVERRIDE 285 +#define PROTECTED 282 +#define ARGUMENT 283 +#define VIRTUAL 284 +#define SIGNAL 285 +#define OVERRIDE 286 #line 21 "parse.y" @@ -63,6 +64,10 @@ static int vararg = FALSE; static GList *gtktypes = NULL; +/* this can be a global as we will only do one function at a time + anyway */ +static int the_scope = NO_SCOPE; + void free(void *ptr); int yylex(void); @@ -110,13 +115,14 @@ push_variable(char *name, int scope, int line_no, char *postfix) } static void -push_function(int scope, char *oid, char *id, char *onerror, +push_function(int scope, int method, char *oid, char *id, char *onerror, GString *cbuf,int line_no, int ccode_line, int vararg) { Node *node; Type *type; + char *c_cbuf; - if(scope!=INIT_METHOD && scope!=CLASS_INIT_METHOD) { + if(method!=INIT_METHOD && method!=CLASS_INIT_METHOD) { type = typestack->data; typestack = g_list_remove(typestack,typestack->data); } else { @@ -125,10 +131,8 @@ push_function(int scope, char *oid, char *id, char *onerror, /* a complicated and ugly test to figure out if we have the wrong number of types for a signal */ - if((scope == SIGNAL_FIRST_METHOD || - scope == SIGNAL_LAST_METHOD || - scope == PRIVATE_SIGNAL_FIRST_METHOD || - scope == PRIVATE_SIGNAL_LAST_METHOD) && + if((method == SIGNAL_FIRST_METHOD || + method == SIGNAL_LAST_METHOD) && g_list_length(gtktypes) != g_list_length(funcargs) && !(g_list_length(funcargs) == 1 && g_list_length(gtktypes) == 2 && @@ -137,8 +141,24 @@ push_function(int scope, char *oid, char *id, char *onerror, "function arguments for a signal " "don't seem to match"),line_no); } - node = new_method(scope,type,oid,gtktypes,id,funcargs, - onerror,cbuf,line_no,ccode_line,vararg); + if(cbuf) { + char *p; + c_cbuf = p = cbuf->str; + while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r')) + p++; + if(!p || !*p) + c_cbuf = NULL; + } else + c_cbuf = NULL; + + node = new_method(scope,method,type,oid,gtktypes,id,funcargs, + onerror,c_cbuf,line_no,ccode_line,vararg); + + if(cbuf) + g_string_free(cbuf, + /*only free segment if we haven't passed it + above */ + c_cbuf?FALSE:TRUE); gtktypes = NULL; funcargs = NULL; @@ -191,7 +211,7 @@ push_self(char *id) } -#line 178 "parse.y" +#line 197 "parse.y" typedef union { char *id; GString *cbuf; @@ -213,26 +233,26 @@ typedef union { -#define YYFINAL 216 +#define YYFINAL 214 #define YYFLAG -32768 #define YYNTBASE 46 -#define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 75) +#define YYTRANSLATE(x) ((unsigned)(x) <= 286 ? yytranslate[x] : 76) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 44, 2, 2, 2, 2, 2, 2, 35, - 36, 38, 2, 39, 45, 2, 2, 2, 41, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 34, 43, - 40, 42, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 44, 2, 2, 2, 2, 2, 2, 36, + 37, 39, 2, 40, 45, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 35, 42, + 43, 41, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 32, 37, 33, 2, 2, 2, 2, 2, + 2, 2, 33, 38, 34, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -248,80 +268,76 @@ static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31 + 27, 28, 29, 30, 31, 32 }; #if YYDEBUG != 0 static const short yyprhs[] = { 0, 0, 4, 7, 10, 12, 15, 18, 20, 22, 27, - 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 + 31, 36, 39, 42, 45, 47, 49, 51, 53, 55, + 57, 62, 68, 80, 89, 93, 94, 98, 100, 102, + 105, 107, 110, 113, 116, 118, 121, 124, 126, 128, + 130, 132, 135, 137, 139, 142, 144, 147, 149, 151, + 153, 155, 157, 160, 162, 165, 167, 171, 175, 178, + 180, 185, 189, 191, 194, 196, 206, 217, 227, 237, + 246, 258, 267, 273, 276, 280, 281, 283, 285, 289, + 291, 295, 297, 301, 303, 306, 310, 317, 325, 328, + 330, 332, 335, 338, 342, 346, 350, 354, 356, 359 }; 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, 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 + 0, 49, 33, 50, 34, 0, 49, 33, 34, 0, + 3, 22, 4, 22, 0, 50, 67, 0, 50, 52, + 0, 50, 53, 0, 67, 0, 52, 0, 53, 0, + 26, 0, 27, 0, 28, 0, 51, 56, 20, 35, + 0, 51, 56, 20, 23, 35, 0, 29, 54, 20, + 20, 20, 33, 24, 20, 33, 24, 35, 0, 29, + 54, 20, 20, 20, 33, 24, 35, 0, 36, 55, + 37, 0, 0, 20, 38, 55, 0, 20, 0, 57, + 0, 5, 57, 0, 58, 0, 58, 61, 0, 12, + 59, 0, 11, 59, 0, 59, 0, 12, 18, 0, + 11, 18, 0, 18, 0, 17, 0, 16, 0, 20, + 0, 60, 20, 0, 22, 0, 6, 0, 13, 15, + 0, 13, 0, 14, 15, 0, 14, 0, 15, 0, + 9, 0, 8, 0, 7, 0, 39, 61, 0, 39, + 0, 20, 64, 0, 64, 0, 51, 20, 64, 0, + 20, 51, 64, 0, 51, 64, 0, 62, 0, 20, + 36, 65, 37, 0, 65, 40, 20, 0, 20, 0, + 33, 24, 0, 35, 0, 31, 63, 56, 20, 36, + 69, 37, 68, 66, 0, 51, 31, 62, 56, 20, + 36, 69, 37, 68, 66, 0, 30, 51, 56, 20, + 36, 69, 37, 68, 66, 0, 51, 30, 56, 20, + 36, 69, 37, 68, 66, 0, 30, 56, 20, 36, + 69, 37, 68, 66, 0, 32, 36, 22, 37, 56, + 20, 36, 69, 37, 68, 66, 0, 51, 56, 20, + 36, 69, 37, 68, 66, 0, 20, 36, 20, 37, + 66, 0, 19, 75, 0, 19, 33, 24, 0, 0, + 6, 0, 20, 0, 20, 40, 70, 0, 70, 0, + 71, 40, 10, 0, 71, 0, 71, 40, 72, 0, + 72, 0, 56, 20, 0, 56, 20, 23, 0, 56, + 20, 36, 20, 73, 37, 0, 56, 20, 23, 36, + 20, 73, 37, 0, 73, 74, 0, 74, 0, 20, + 0, 41, 75, 0, 42, 75, 0, 41, 43, 75, + 0, 42, 43, 75, 0, 43, 43, 75, 0, 44, + 43, 75, 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, 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 + 216, 217, 218, 219, 222, 228, 233, 239, 246, 251, + 258, 263, 264, 265, 266, 267, 268, 271, 272, 273, + 276, 279, 283, 316, 344, 345, 348, 351, 357, 358, + 366, 370, 377, 380, 383, 386, 389, 392, 395, 398, + 401, 404, 408, 411, 416, 419, 422, 425, 428, 433, + 436, 439, 444, 445, 449, 461, 467, 479, 491, 494, + 500, 505, 508, 513, 514, 518, 528, 538, 548, 558, + 568, 574, 579, 600, 601, 605, 608, 609, 620, 630, + 633, 634, 637, 638, 641, 644, 647, 655, 665, 666, + 669, 682, 686, 690, 694, 698, 702, 708, 709, 713 }; #endif @@ -331,11 +347,11 @@ static const short yyrline[] = { 0, static const char * const yytname[] = { "$","error","$undefined.","CLASS", "FROM","CONST","VOID","STRUCT","UNION","ENUM","THREEDOTS","SIGNED","UNSIGNED", "LONG","SHORT","INT","FLOAT","DOUBLE","CHAR","ONERROR","TOKEN","NUMBER","TYPETOKEN", -"ARRAY_DIM","CCODE","HCODE","PUBLIC","PRIVATE","ARGUMENT","VIRTUAL","SIGNAL", -"OVERRIDE","'{'","'}'","';'","'('","')'","'|'","'*'","','","'='","'1'","'>'", -"'<'","'!'","'-'","prog","ccodes","class","classdec","classcode","variable", +"ARRAY_DIM","CCODE","HCODE","PUBLIC","PRIVATE","PROTECTED","ARGUMENT","VIRTUAL", +"SIGNAL","OVERRIDE","'{'","'}'","';'","'('","')'","'|'","'*'","','","'>'","'<'", +"'='","'!'","'-'","prog","ccodes","class","classdec","classcode","scope","variable", "argument","argflags","flaglist","type","type1","type2","integer","tspecifier", -"stars","optpublic","fullsigtype","sigtype","tokenlist","codenocode","method", +"stars","simplesigtype","fullsigtype","sigtype","tokenlist","codenocode","method", "onerror","funcargs","arglist","arglist1","arg","checklist","check","numtok", NULL }; #endif @@ -343,157 +359,167 @@ static const char * const yytname[] = { "$","error","$undefined.","CLASS", static const short yyr1[] = { 0, 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 + 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, + 57, 57, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 58, 59, 59, 59, 59, 59, 60, + 60, 60, 61, 61, 62, 62, 63, 63, 63, 63, + 64, 65, 65, 66, 66, 67, 67, 67, 67, 67, + 67, 67, 67, 68, 68, 68, 69, 69, 69, 69, + 70, 70, 71, 71, 72, 72, 72, 72, 73, 73, + 74, 74, 74, 74, 74, 74, 74, 75, 75, 75 }; static const short yyr2[] = { 0, 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 + 4, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 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, 2, 1, 3, 3, 2, 1, + 4, 3, 1, 2, 1, 9, 10, 9, 9, 8, + 11, 8, 5, 2, 3, 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, 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 + 2, 0, 0, 1, 0, 18, 19, 20, 26, 0, + 0, 0, 10, 0, 0, 16, 17, 15, 11, 0, + 0, 0, 0, 44, 52, 51, 50, 0, 0, 46, + 48, 49, 40, 39, 38, 41, 43, 0, 0, 29, + 31, 35, 0, 0, 0, 60, 0, 56, 0, 9, + 13, 14, 12, 0, 0, 0, 0, 28, 0, 0, + 30, 37, 34, 36, 33, 45, 47, 0, 0, 54, + 32, 42, 0, 0, 0, 55, 0, 59, 0, 0, + 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, + 53, 63, 0, 58, 57, 0, 0, 0, 0, 0, + 21, 0, 0, 65, 73, 27, 0, 0, 44, 41, + 0, 0, 80, 82, 84, 61, 0, 0, 0, 0, + 0, 22, 0, 64, 0, 0, 0, 85, 76, 0, + 62, 0, 0, 0, 0, 76, 0, 76, 79, 86, + 0, 0, 0, 81, 83, 76, 0, 76, 0, 0, + 0, 24, 0, 0, 0, 100, 98, 0, 0, 74, + 70, 0, 0, 0, 76, 72, 0, 68, 0, 91, + 0, 0, 0, 0, 0, 90, 75, 99, 66, 76, + 69, 0, 0, 0, 0, 92, 0, 93, 0, 0, + 87, 89, 0, 67, 23, 88, 94, 95, 96, 97, + 71, 0, 0, 0 }; -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 yydefgoto[] = { 212, + 4, 5, 6, 24, 25, 26, 27, 32, 69, 121, + 50, 51, 52, 53, 81, 56, 57, 58, 103, 115, + 28, 153, 122, 123, 124, 125, 185, 186, 170 }; -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 yypact[] = { 77, + -16,-32768,-32768, 85, 65, 6, 51,-32768,-32768, 65, + 120, 216, 42, 120, 46,-32768,-32768,-32768, 62, 115, + 15, 89,-32768, 229, 54,-32768,-32768,-32768,-32768, 91, + 116, 131, 206,-32768,-32768,-32768,-32768, 79, 135, 125, + 140,-32768,-32768,-32768,-32768,-32768,-32768, 171, 161,-32768, + 151,-32768, 172, 205, 179,-32768, 171,-32768, 186,-32768, +-32768,-32768,-32768, 171, 190, 196, 197, 199, 198, 207, +-32768,-32768,-32768,-32768,-32768,-32768,-32768, 218, 203, 151, +-32768,-32768, 204, 231, 232,-32768, -7,-32768, 233, 217, + 242, -7, 171, 111, 139, 116,-32768, 244, 230, 189, +-32768,-32768, -30,-32768,-32768, 234, 171, 235, 245, 237, +-32768, 189, 243,-32768,-32768,-32768, 236, 189, 238, 59, + 248, 239,-32768, 240,-32768,-32768, 253, 189, 254, 189, + 241,-32768, 246,-32768, 255, 247, 171, 9, 259, 153, +-32768, 249, 251, 252, 189, 259, -5, 259,-32768, 256, + 261, 5, 139,-32768,-32768, 259, 189, 259, 257, 139, + 258,-32768, 139, 262, 75,-32768,-32768, 264, 269,-32768, +-32768, 139, 260, 139, 259,-32768, 271,-32768, 75,-32768, + 13, 32, 250, 263, 63,-32768,-32768,-32768,-32768, 259, +-32768, 139, 265, 71, 58,-32768, 58,-32768, 58, 58, +-32768,-32768, 139,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, 285, 296,-32768 }; static const short yypgoto[] = {-32768, - 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 + 76, 294,-32768,-32768, 3, 275, 277,-32768, 208, -20, + 270,-32768, 191,-32768, 222, 266,-32768, -38,-32768, -152, + 281, -144, -109, 170,-32768, 168, 130, -167, -43 }; -#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 +#define YYLAST 331 + + +static const short yytable[] = { 49, + 171, 160, 133, 163, 66, 7, 126, 176, 136, 127, + 178, 172, 83, 174, 161, 86, 88, 202, 142, 189, + 144, 191, 48, 55, 166, 167, 202, 78, 84, 162, + 192, 150, 166, 167, 54, 159, 89, 168, 12, 204, + 16, 17, 18, 91, 151, 203, 104, 173, 105, 169, + 211, 166, 167, 86, 13, 195, 85, 169, 33, 34, + 35, 36, 37, 29, 38, 39, 40, 41, 42, 43, + 44, 45, 109, 46, 197, 47, 169, 166, 167, 1, + 11, 30, 180, 64, 65, 14, 129, 1, 2, 3, + 180, 40, 41, 42, 180, -78, 72, 31, 137, 201, + 2, 3, 169, 181, 182, 183, 184, 206, 8, 9, + 67, 181, 182, 183, 184, 181, 182, 183, 184, 33, + 34, 35, 36, 37, 59, 38, 39, 40, 41, 42, + 43, 44, 45, 110, 46, 68, 47, 196, 198, 76, + 16, 17, 18, 8, 9, 111, 112, 40, 41, 42, + 70, 207, 74, 208, 77, 209, 210, 33, 34, 35, + 36, 37, 154, 38, 39, 40, 41, 42, 43, 44, + 45, 113, 46, 114, 47, 33, 34, 35, 36, 37, + 79, 38, 39, 40, 41, 42, 43, 44, 45, 80, + 46, 82, 47, 33, 119, 35, 36, 37, 87, 38, + 39, 40, 41, 42, 43, 44, 45, 90, 120, 92, + 47, 34, 35, 36, 37, 94, 38, 39, 40, 41, + 42, 43, 44, 45, 83, 46, 98, 47, 73, 75, + 16, 17, 18, 95, 97, 15, 96, 99, 100, 84, + 84, 16, 17, 18, 19, 20, 21, 22, 15, 23, + 102, 83, 106, 107, 16, 17, 18, 19, 20, 21, + 22, 108, 60, 117, 131, 118, 134, 138, 135, 128, + 130, 132, 141, 143, -77, 139, 145, 152, 147, 140, + 165, 179, 146, 148, 213, 156, 157, 187, 158, 188, + 177, 164, 199, 175, 193, 214, 190, 10, 61, 205, + 62, 101, 71, 116, 63, 200, 149, 155, 194, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 93 }; -static const short yycheck[] = { 16, - 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 +static const short yycheck[] = { 20, + 153, 146, 112, 148, 25, 22, 37, 160, 118, 40, + 163, 156, 20, 158, 20, 54, 55, 185, 128, 172, + 130, 174, 20, 21, 20, 21, 194, 48, 36, 35, + 175, 23, 20, 21, 20, 145, 57, 33, 33, 192, + 26, 27, 28, 64, 36, 190, 85, 157, 87, 45, + 203, 20, 21, 92, 4, 43, 54, 45, 5, 6, + 7, 8, 9, 22, 11, 12, 13, 14, 15, 16, + 17, 18, 93, 20, 43, 22, 45, 20, 21, 3, + 5, 36, 20, 30, 31, 10, 107, 3, 24, 25, + 20, 13, 14, 15, 20, 37, 18, 36, 40, 37, + 24, 25, 45, 41, 42, 43, 44, 37, 24, 25, + 20, 41, 42, 43, 44, 41, 42, 43, 44, 5, + 6, 7, 8, 9, 36, 11, 12, 13, 14, 15, + 16, 17, 18, 23, 20, 20, 22, 181, 182, 15, + 26, 27, 28, 24, 25, 35, 36, 13, 14, 15, + 20, 195, 18, 197, 15, 199, 200, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 33, 20, 35, 22, 5, 6, 7, 8, 9, + 20, 11, 12, 13, 14, 15, 16, 17, 18, 39, + 20, 20, 22, 5, 6, 7, 8, 9, 20, 11, + 12, 13, 14, 15, 16, 17, 18, 22, 20, 20, + 22, 6, 7, 8, 9, 20, 11, 12, 13, 14, + 15, 16, 17, 18, 20, 20, 20, 22, 38, 39, + 26, 27, 28, 37, 37, 20, 38, 20, 36, 36, + 36, 26, 27, 28, 29, 30, 31, 32, 20, 34, + 20, 20, 20, 37, 26, 27, 28, 29, 30, 31, + 32, 20, 34, 20, 20, 36, 24, 20, 33, 36, + 36, 35, 20, 20, 37, 37, 36, 19, 24, 40, + 20, 20, 37, 37, 0, 37, 36, 24, 37, 21, + 33, 36, 43, 37, 24, 0, 37, 4, 24, 35, + 24, 80, 33, 96, 24, 43, 137, 140, 179, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 65 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/lib/bison.simple" @@ -1039,51 +1065,57 @@ yyreduce: switch (yyn) { case 1: -#line 197 "parse.y" +#line 216 "parse.y" { ; ; break;} case 2: -#line 198 "parse.y" +#line 217 "parse.y" { ; ; break;} case 3: -#line 199 "parse.y" +#line 218 "parse.y" { ; ; break;} case 4: -#line 200 "parse.y" +#line 219 "parse.y" { ; ; break;} case 5: -#line 203 "parse.y" +#line 222 "parse.y" { - Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line); + Node *node = new_ccode(FALSE,(yyvsp[0].cbuf)->str, + ccode_line); nodes = g_list_append(nodes,node); + g_string_free(yyvsp[0].cbuf,FALSE); ; break;} case 6: -#line 207 "parse.y" +#line 228 "parse.y" { - Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line); + Node *node = new_ccode(TRUE,(yyvsp[0].cbuf)->str,ccode_line); nodes = g_list_append(nodes,node); + g_string_free(yyvsp[0].cbuf,FALSE); ; break;} case 7: -#line 211 "parse.y" +#line 233 "parse.y" { - Node *node = new_ccode(FALSE,yyvsp[0].cbuf,ccode_line); + Node *node = new_ccode(FALSE,(yyvsp[0].cbuf)->str, + ccode_line); nodes = g_list_append(nodes,node); + g_string_free(yyvsp[0].cbuf,FALSE); ; break;} case 8: -#line 215 "parse.y" +#line 239 "parse.y" { - Node *node = new_ccode(TRUE,yyvsp[0].cbuf,ccode_line); + Node *node = new_ccode(TRUE,(yyvsp[0].cbuf)->str,ccode_line); nodes = g_list_append(nodes,node); + g_string_free(yyvsp[0].cbuf,FALSE); ; break;} case 9: -#line 221 "parse.y" +#line 246 "parse.y" { ((Class *)class)->nodes = class_nodes; class_nodes = NULL; @@ -1091,7 +1123,7 @@ case 9: ; break;} case 10: -#line 226 "parse.y" +#line 251 "parse.y" { ((Class *)class)->nodes = NULL; class_nodes = NULL; @@ -1099,79 +1131,83 @@ case 10: ; break;} case 11: -#line 233 "parse.y" +#line 258 "parse.y" { class = new_class(yyvsp[-2].id,yyvsp[0].id,NULL); ; break;} case 12: -#line 238 "parse.y" +#line 263 "parse.y" { ; ; break;} case 13: -#line 239 "parse.y" +#line 264 "parse.y" { ; ; break;} case 14: -#line 240 "parse.y" +#line 265 "parse.y" { ; ; break;} case 15: -#line 241 "parse.y" +#line 266 "parse.y" { ; ; break;} case 16: -#line 242 "parse.y" +#line 267 "parse.y" { ; ; break;} case 17: -#line 243 "parse.y" +#line 268 "parse.y" { ; ; break;} case 18: -#line 246 "parse.y" -{ - push_variable(yyvsp[-1].id,PUBLIC_SCOPE,yyvsp[-3].line,NULL); - ; +#line 271 "parse.y" +{ the_scope = PUBLIC_SCOPE; ; break;} case 19: -#line 249 "parse.y" -{ - push_variable(yyvsp[-2].id,PUBLIC_SCOPE,yyvsp[-4].line,yyvsp[-1].id); - ; +#line 272 "parse.y" +{ the_scope = PRIVATE_SCOPE; ; break;} case 20: -#line 252 "parse.y" -{ - push_variable(yyvsp[-1].id,PRIVATE_SCOPE,yyvsp[-3].line,NULL); - ; +#line 273 "parse.y" +{ the_scope = PROTECTED_SCOPE; ; break;} case 21: -#line 255 "parse.y" +#line 276 "parse.y" { - push_variable(yyvsp[-2].id,PRIVATE_SCOPE,yyvsp[-4].line,yyvsp[-1].id); - ; + push_variable(yyvsp[-1].id,the_scope,yyvsp[-3].line,NULL); + ; break;} case 22: -#line 259 "parse.y" +#line 279 "parse.y" +{ + push_variable(yyvsp[-2].id,the_scope,yyvsp[-4].line,yyvsp[-1].id); + ; + break;} +case 23: +#line 283 "parse.y" { if(strcmp(yyvsp[-6].id,"get")==0 && strcmp(yyvsp[-3].id,"set")==0) { Node *node; g_free(yyvsp[-6].id); g_free(yyvsp[-3].id); node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id, - yyvsp[-4].cbuf,yyvsp[-5].line, - yyvsp[-1].cbuf,yyvsp[-2].line, + (yyvsp[-4].cbuf)->str,yyvsp[-5].line, + (yyvsp[-1].cbuf)->str,yyvsp[-2].line, yyvsp[-10].line); + g_string_free(yyvsp[-4].cbuf,FALSE); + g_string_free(yyvsp[-1].cbuf,FALSE); class_nodes = g_list_append(class_nodes,node); } else if(strcmp(yyvsp[-6].id,"set")==0 && strcmp(yyvsp[-3].id,"get")==0) { Node *node; g_free(yyvsp[-6].id); g_free(yyvsp[-3].id); node = new_argument(yyvsp[-8].id,yyvsp[-9].list,yyvsp[-7].id, - yyvsp[-1].cbuf,yyvsp[-2].line, - yyvsp[-4].cbuf,yyvsp[-5].line, + (yyvsp[-1].cbuf)->str,yyvsp[-2].line, + (yyvsp[-4].cbuf)->str,yyvsp[-5].line, yyvsp[-10].line); + g_string_free(yyvsp[-1].cbuf,FALSE); + g_string_free(yyvsp[-4].cbuf,FALSE); class_nodes = g_list_append(class_nodes,node); } else { g_free(yyvsp[-8].id); g_free(yyvsp[-7].id); @@ -1184,22 +1220,24 @@ case 22: } ; break;} -case 23: -#line 288 "parse.y" +case 24: +#line 316 "parse.y" { if(strcmp(yyvsp[-3].id,"get")==0) { Node *node; g_free(yyvsp[-3].id); node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id, - yyvsp[-1].cbuf,yyvsp[-2].line,NULL,0, - yyvsp[-7].line); + (yyvsp[-1].cbuf)->str,yyvsp[-2].line, + NULL,0, yyvsp[-7].line); + g_string_free(yyvsp[-1].cbuf,FALSE); class_nodes = g_list_append(class_nodes,node); } else if(strcmp(yyvsp[-3].id,"set")==0) { Node *node; g_free(yyvsp[-3].id); node = new_argument(yyvsp[-5].id,yyvsp[-6].list,yyvsp[-4].id, - NULL,0,yyvsp[-1].cbuf,yyvsp[-2].line, - yyvsp[-7].line); + NULL,0,(yyvsp[-1].cbuf)->str, + yyvsp[-2].line, yyvsp[-7].line); + g_string_free(yyvsp[-1].cbuf,FALSE); class_nodes = g_list_append(class_nodes,node); } else { g_free(yyvsp[-3].id); g_free(yyvsp[-5].id); @@ -1211,32 +1249,32 @@ case 23: } ; break;} -case 24: -#line 314 "parse.y" +case 25: +#line 344 "parse.y" { yyval.list = yyvsp[-1].list; ; break;} -case 25: -#line 315 "parse.y" +case 26: +#line 345 "parse.y" { yyval.list = NULL; ; break;} -case 26: -#line 318 "parse.y" +case 27: +#line 348 "parse.y" { yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id); ; break;} -case 27: -#line 321 "parse.y" +case 28: +#line 351 "parse.y" { yyval.list = g_list_append(NULL,yyvsp[0].id); ; break;} -case 28: -#line 327 "parse.y" +case 29: +#line 357 "parse.y" { ; ; break;} -case 29: -#line 328 "parse.y" +case 30: +#line 358 "parse.y" { Type *type = typestack->data; char *oldname = type->name; @@ -1244,195 +1282,151 @@ case 29: g_free(oldname); ; break;} -case 30: -#line 336 "parse.y" +case 31: +#line 366 "parse.y" { Node *node = new_type(0,yyvsp[0].id,NULL); typestack = g_list_prepend(typestack,node); ; break;} -case 31: -#line 340 "parse.y" +case 32: +#line 370 "parse.y" { Node *node = new_type(stars,yyvsp[-1].id,NULL); stars = 0; typestack = g_list_prepend(typestack,node); ; break;} -case 32: -#line 347 "parse.y" +case 33: +#line 377 "parse.y" { yyval.id = g_strconcat("unsigned ",yyvsp[0].id,NULL); ; break;} -case 33: -#line 350 "parse.y" +case 34: +#line 380 "parse.y" { yyval.id = g_strconcat("signed ",yyvsp[0].id,NULL); ; break;} -case 34: -#line 353 "parse.y" +case 35: +#line 383 "parse.y" { yyval.id = g_strdup(yyvsp[0].id); ; break;} -case 35: -#line 356 "parse.y" +case 36: +#line 386 "parse.y" { yyval.id = g_strdup("unsigned char"); ; break;} -case 36: -#line 359 "parse.y" +case 37: +#line 389 "parse.y" { yyval.id = g_strdup("signed char"); ; break;} -case 37: -#line 362 "parse.y" +case 38: +#line 392 "parse.y" { yyval.id = g_strdup("char"); ; break;} -case 38: -#line 365 "parse.y" +case 39: +#line 395 "parse.y" { yyval.id = g_strdup("double"); ; break;} -case 39: -#line 368 "parse.y" +case 40: +#line 398 "parse.y" { yyval.id = g_strdup("float"); ; break;} -case 40: -#line 371 "parse.y" +case 41: +#line 401 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 41: -#line 374 "parse.y" +case 42: +#line 404 "parse.y" { yyval.id = g_strconcat(yyvsp[-1].id,yyvsp[0].id,NULL); g_free(yyvsp[0].id); ; break;} -case 42: -#line 378 "parse.y" +case 43: +#line 408 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 43: -#line 381 "parse.y" +case 44: +#line 411 "parse.y" { yyval.id = g_strdup("void"); ; break;} -case 44: -#line 386 "parse.y" +case 45: +#line 416 "parse.y" { yyval.id = "long int"; ; break;} -case 45: -#line 389 "parse.y" +case 46: +#line 419 "parse.y" { yyval.id = "long"; ; break;} -case 46: -#line 392 "parse.y" +case 47: +#line 422 "parse.y" { yyval.id = "short int"; ; break;} -case 47: -#line 395 "parse.y" +case 48: +#line 425 "parse.y" { yyval.id = "short"; ; break;} -case 48: -#line 398 "parse.y" +case 49: +#line 428 "parse.y" { yyval.id = "int"; ; break;} -case 49: -#line 403 "parse.y" +case 50: +#line 433 "parse.y" { yyval.id = "enum "; ; break;} -case 50: -#line 406 "parse.y" +case 51: +#line 436 "parse.y" { yyval.id = "union "; ; break;} -case 51: -#line 409 "parse.y" +case 52: +#line 439 "parse.y" { yyval.id = "struct "; ; break;} -case 52: -#line 414 "parse.y" -{ stars++; ; - break;} case 53: -#line 415 "parse.y" +#line 444 "parse.y" { stars++; ; break;} case 54: -#line 418 "parse.y" -{ ; ; +#line 445 "parse.y" +{ stars++; ; 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; - else if(strcmp(yyvsp[-1].id,"last")==0) - yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD; - else { - yyerror(_("signal must be 'first' or 'last'")); - g_free(yyvsp[-1].id); - YYERROR; - } - g_free(yyvsp[-1].id); - ; - break;} -case 57: -#line 434 "parse.y" -{ - if(strcmp(yyvsp[-2].id,"first")==0) - yyval.sigtype = PRIVATE_SIGNAL_FIRST_METHOD; - else if(strcmp(yyvsp[-2].id,"last")==0) - yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD; - else { - yyerror(_("signal must be 'first' or 'last'")); - g_free(yyvsp[-2].id); - YYERROR; - } - g_free(yyvsp[-2].id); - ; - break;} -case 58: -#line 446 "parse.y" -{ - yyval.sigtype = PRIVATE_SIGNAL_LAST_METHOD; - ; - break;} -case 59: #line 449 "parse.y" { if(strcmp(yyvsp[-1].id,"first")==0) @@ -1447,8 +1441,14 @@ case 59: g_free(yyvsp[-1].id); ; break;} -case 60: +case 56: #line 461 "parse.y" +{ + yyval.sigtype = SIGNAL_LAST_METHOD; + ; + break;} +case 57: +#line 467 "parse.y" { if(strcmp(yyvsp[-1].id,"first")==0) yyval.sigtype = SIGNAL_FIRST_METHOD; @@ -1462,8 +1462,8 @@ case 60: g_free(yyvsp[-1].id); ; break;} -case 61: -#line 473 "parse.y" +case 58: +#line 479 "parse.y" { if(strcmp(yyvsp[-2].id,"first")==0) yyval.sigtype = SIGNAL_FIRST_METHOD; @@ -1477,119 +1477,138 @@ case 61: g_free(yyvsp[-2].id); ; break;} -case 62: -#line 485 "parse.y" +case 59: +#line 491 "parse.y" { yyval.sigtype = SIGNAL_LAST_METHOD; ; break;} -case 63: -#line 488 "parse.y" +case 60: +#line 494 "parse.y" { - yyval.sigtype = SIGNAL_LAST_METHOD; + /* the_scope was default thus public */ + the_scope = PUBLIC_SCOPE; ; break;} -case 64: -#line 493 "parse.y" +case 61: +#line 500 "parse.y" { gtktypes = g_list_prepend(gtktypes,yyvsp[-3].id); ; break;} -case 65: -#line 498 "parse.y" +case 62: +#line 505 "parse.y" { gtktypes = g_list_append(gtktypes,yyvsp[0].id); ; break;} -case 66: -#line 501 "parse.y" +case 63: +#line 508 "parse.y" { gtktypes = g_list_append(gtktypes,yyvsp[0].id); ; break;} -case 67: -#line 506 "parse.y" -{ yyval.cbuf=yyvsp[0].cbuf; ; +case 64: +#line 513 "parse.y" +{ yyval.cbuf = yyvsp[0].cbuf; ; break;} -case 68: -#line 507 "parse.y" +case 65: +#line 514 "parse.y" { yyval.cbuf = NULL; ; break;} -case 69: -#line 511 "parse.y" +case 66: +#line 518 "parse.y" { if(!has_self) { yyerror(_("signal without 'self' as " "first parameter")); YYERROR; } - push_function(yyvsp[-7].sigtype,NULL, + push_function(the_scope, yyvsp[-7].sigtype,NULL, yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line, ccode_line,vararg); ; break;} -case 70: -#line 521 "parse.y" +case 67: +#line 528 "parse.y" +{ + if(!has_self) { + yyerror(_("signal without 'self' as " + "first parameter")); + YYERROR; + } + push_function(the_scope, yyvsp[-7].sigtype,NULL, + yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line, + ccode_line,vararg); + ; + break;} +case 68: +#line 538 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " "first parameter")); YYERROR; } - push_function(PRIVATE_VIRTUAL_METHOD, NULL, yyvsp[-5].id, + push_function(the_scope, VIRTUAL_METHOD, NULL, yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line, ccode_line,vararg); ; break;} -case 71: -#line 531 "parse.y" +case 69: +#line 548 "parse.y" { if(!has_self) { yyerror(_("virtual method without 'self' as " "first parameter")); YYERROR; } - push_function(VIRTUAL_METHOD, NULL, yyvsp[-5].id, - yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-8].line, + push_function(the_scope, VIRTUAL_METHOD, NULL, yyvsp[-5].id, + yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-7].line, ccode_line,vararg); ; break;} -case 72: -#line 541 "parse.y" +case 70: +#line 558 "parse.y" { - push_function(OVERRIDE_METHOD, yyvsp[-9].id, - yyvsp[-6].id, yyvsp[-2].id, yyvsp[0].cbuf, - yyvsp[-11].line,yyvsp[-1].line, - vararg); + if(!has_self) { + yyerror(_("virtual method without 'self' as " + "first parameter")); + YYERROR; + } + push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL, + yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-7].line, + ccode_line,vararg); ; break;} -case 73: -#line 547 "parse.y" +case 71: +#line 568 "parse.y" { - push_function(PUBLIC_SCOPE, NULL, yyvsp[-6].id, - yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line, + push_function(NO_SCOPE, OVERRIDE_METHOD, yyvsp[-8].id, + yyvsp[-5].id, yyvsp[-1].id, yyvsp[0].cbuf, + yyvsp[-10].line,ccode_line, vararg); - ; + ; break;} -case 74: -#line 552 "parse.y" +case 72: +#line 574 "parse.y" { - push_function(PRIVATE_SCOPE, NULL, yyvsp[-6].id, - yyvsp[-2].id, yyvsp[0].cbuf,yyvsp[-8].line,yyvsp[-1].line, + push_function(the_scope, REGULAR_METHOD, NULL, yyvsp[-5].id, + yyvsp[-1].id, yyvsp[0].cbuf,yyvsp[-7].line,ccode_line, vararg); ; break;} -case 75: -#line 557 "parse.y" +case 73: +#line 579 "parse.y" { if(strcmp(yyvsp[-4].id,"init")==0) { push_init_arg(yyvsp[-2].id,FALSE); - push_function(INIT_METHOD, NULL, + push_function(NO_SCOPE, INIT_METHOD, NULL, yyvsp[-4].id, NULL, yyvsp[0].cbuf,yyvsp[-3].line, ccode_line,FALSE); } else if(strcmp(yyvsp[-4].id,"class_init")==0) { push_init_arg(yyvsp[-2].id,TRUE); - push_function(CLASS_INIT_METHOD, NULL, + push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL, yyvsp[-4].id, NULL, yyvsp[0].cbuf,yyvsp[-3].line, ccode_line,FALSE); } else { @@ -1601,31 +1620,27 @@ case 75: } ; break;} -case 76: -#line 578 "parse.y" +case 74: +#line 600 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 77: -#line 579 "parse.y" +case 75: +#line 601 "parse.y" { yyval.id = (yyvsp[0].cbuf)->str; g_string_free(yyvsp[0].cbuf,FALSE); ; break;} -case 78: -#line 583 "parse.y" -{ ; ; - break;} -case 79: -#line 584 "parse.y" +case 76: +#line 605 "parse.y" { yyval.id = NULL; ; break;} -case 80: -#line 587 "parse.y" +case 77: +#line 608 "parse.y" { vararg = FALSE; has_self = FALSE; ; break;} -case 81: -#line 588 "parse.y" +case 78: +#line 609 "parse.y" { vararg = FALSE; has_self = TRUE; @@ -1638,8 +1653,8 @@ case 81: } ; break;} -case 82: -#line 599 "parse.y" +case 79: +#line 620 "parse.y" { has_self = TRUE; if(strcmp(yyvsp[-2].id,"self")==0) @@ -1651,40 +1666,40 @@ case 82: } ; break;} -case 83: -#line 609 "parse.y" +case 80: +#line 630 "parse.y" { has_self = FALSE; ; break;} -case 84: -#line 612 "parse.y" +case 81: +#line 633 "parse.y" { vararg = TRUE; ; break;} -case 85: -#line 613 "parse.y" +case 82: +#line 634 "parse.y" { vararg = FALSE; ; break;} -case 86: -#line 616 "parse.y" +case 83: +#line 637 "parse.y" { ; ; break;} -case 87: -#line 617 "parse.y" +case 84: +#line 638 "parse.y" { ; ; break;} -case 88: -#line 620 "parse.y" +case 85: +#line 641 "parse.y" { push_funcarg(yyvsp[0].id,NULL); ; break;} -case 89: -#line 623 "parse.y" +case 86: +#line 644 "parse.y" { push_funcarg(yyvsp[-1].id,yyvsp[0].id); ; break;} -case 90: -#line 626 "parse.y" +case 87: +#line 647 "parse.y" { if(strcmp(yyvsp[-2].id,"check")!=0) { yyerror(_("parse error")); @@ -1694,8 +1709,8 @@ case 90: push_funcarg(yyvsp[-4].id,NULL); ; break;} -case 91: -#line 634 "parse.y" +case 88: +#line 655 "parse.y" { if(strcmp(yyvsp[-2].id,"check")!=0) { yyerror(_("parse error")); @@ -1705,16 +1720,16 @@ case 91: push_funcarg(yyvsp[-5].id,yyvsp[-4].id); ; break;} -case 92: -#line 644 "parse.y" +case 89: +#line 665 "parse.y" { ; ; break;} -case 93: -#line 645 "parse.y" +case 90: +#line 666 "parse.y" { ; ; break;} -case 94: -#line 648 "parse.y" +case 91: +#line 669 "parse.y" { if(strcmp(yyvsp[0].id,"type")==0) { Node *node = new_check(TYPE_CHECK,NULL); @@ -1729,61 +1744,61 @@ case 94: g_free(yyvsp[0].id); ; break;} -case 95: -#line 661 "parse.y" +case 92: +#line 682 "parse.y" { Node *node = new_check(GT_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 96: -#line 665 "parse.y" +case 93: +#line 686 "parse.y" { Node *node = new_check(LT_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 97: -#line 669 "parse.y" +case 94: +#line 690 "parse.y" { Node *node = new_check(GE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 98: -#line 673 "parse.y" +case 95: +#line 694 "parse.y" { Node *node = new_check(LE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 99: -#line 677 "parse.y" +case 96: +#line 698 "parse.y" { Node *node = new_check(EQ_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 100: -#line 681 "parse.y" +case 97: +#line 702 "parse.y" { Node *node = new_check(NE_CHECK,yyvsp[0].id); checks = g_list_append(checks,node); ; break;} -case 101: -#line 687 "parse.y" +case 98: +#line 708 "parse.y" { yyval.id = yyvsp[0].id; ; break;} -case 102: -#line 688 "parse.y" +case 99: +#line 709 "parse.y" { yyval.id = g_strconcat("-",yyvsp[0].id,NULL); g_free(yyvsp[0].id); ; break;} -case 103: -#line 692 "parse.y" +case 100: +#line 713 "parse.y" { yyval.id = yyvsp[0].id; ; break;} } @@ -2008,5 +2023,5 @@ yyerrhandle: } return 1; } -#line 695 "parse.y" +#line 716 "parse.y" diff --git a/src/parse.y b/src/parse.y index 4cdb6a0..f4c4a40 100644 --- a/src/parse.y +++ b/src/parse.y @@ -46,6 +46,10 @@ static int vararg = FALSE; static GList *gtktypes = NULL; +/* this can be a global as we will only do one function at a time + anyway */ +static int the_scope = NO_SCOPE; + void free(void *ptr); int yylex(void); @@ -93,13 +97,14 @@ push_variable(char *name, int scope, int line_no, char *postfix) } static void -push_function(int scope, char *oid, char *id, char *onerror, +push_function(int scope, int method, char *oid, char *id, char *onerror, GString *cbuf,int line_no, int ccode_line, int vararg) { Node *node; Type *type; + char *c_cbuf; - if(scope!=INIT_METHOD && scope!=CLASS_INIT_METHOD) { + if(method!=INIT_METHOD && method!=CLASS_INIT_METHOD) { type = typestack->data; typestack = g_list_remove(typestack,typestack->data); } else { @@ -108,10 +113,8 @@ push_function(int scope, char *oid, char *id, char *onerror, /* a complicated and ugly test to figure out if we have the wrong number of types for a signal */ - if((scope == SIGNAL_FIRST_METHOD || - scope == SIGNAL_LAST_METHOD || - scope == PRIVATE_SIGNAL_FIRST_METHOD || - scope == PRIVATE_SIGNAL_LAST_METHOD) && + if((method == SIGNAL_FIRST_METHOD || + method == SIGNAL_LAST_METHOD) && g_list_length(gtktypes) != g_list_length(funcargs) && !(g_list_length(funcargs) == 1 && g_list_length(gtktypes) == 2 && @@ -120,8 +123,24 @@ push_function(int scope, char *oid, char *id, char *onerror, "function arguments for a signal " "don't seem to match"),line_no); } - node = new_method(scope,type,oid,gtktypes,id,funcargs, - onerror,cbuf,line_no,ccode_line,vararg); + if(cbuf) { + char *p; + c_cbuf = p = cbuf->str; + while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r')) + p++; + if(!p || !*p) + c_cbuf = NULL; + } else + c_cbuf = NULL; + + node = new_method(scope,method,type,oid,gtktypes,id,funcargs, + onerror,c_cbuf,line_no,ccode_line,vararg); + + if(cbuf) + g_string_free(cbuf, + /*only free segment if we haven't passed it + above */ + c_cbuf?FALSE:TRUE); gtktypes = NULL; funcargs = NULL; @@ -190,7 +209,7 @@ push_self(char *id) %token TOKEN NUMBER TYPETOKEN ARRAY_DIM %token CCODE HCODE -%token PUBLIC PRIVATE ARGUMENT VIRTUAL SIGNAL OVERRIDE +%token PUBLIC PRIVATE PROTECTED ARGUMENT VIRTUAL SIGNAL OVERRIDE %% @@ -201,20 +220,26 @@ prog: ccodes class ccodes { ; } ; ccodes: ccodes CCODE { - Node *node = new_ccode(FALSE,$2,ccode_line); + Node *node = new_ccode(FALSE,($2)->str, + ccode_line); nodes = g_list_append(nodes,node); + g_string_free($2,FALSE); } | ccodes HCODE { - Node *node = new_ccode(TRUE,$2,ccode_line); + Node *node = new_ccode(TRUE,($2)->str,ccode_line); nodes = g_list_append(nodes,node); + g_string_free($2,FALSE); } | CCODE { - Node *node = new_ccode(FALSE,$1,ccode_line); + Node *node = new_ccode(FALSE,($1)->str, + ccode_line); nodes = g_list_append(nodes,node); + g_string_free($1,FALSE); } | HCODE { - Node *node = new_ccode(TRUE,$1,ccode_line); + Node *node = new_ccode(TRUE,($1)->str,ccode_line); nodes = g_list_append(nodes,node); + g_string_free($1,FALSE); } ; @@ -243,18 +268,17 @@ classcode: classcode method { ; } | argument { ; } ; -variable: PUBLIC type TOKEN ';' { - push_variable($3,PUBLIC_SCOPE,$1,NULL); - } - | PUBLIC type TOKEN ARRAY_DIM ';' { - push_variable($3,PUBLIC_SCOPE,$1,$4); +scope: PUBLIC { the_scope = PUBLIC_SCOPE; } + | PRIVATE { the_scope = PRIVATE_SCOPE; } + | PROTECTED { the_scope = PROTECTED_SCOPE; } + ; + +variable: scope type TOKEN ';' { + push_variable($3,the_scope,$1,NULL); } - | PRIVATE type TOKEN ';' { - push_variable($3,PRIVATE_SCOPE,$1,NULL); + | scope type TOKEN ARRAY_DIM ';' { + push_variable($3,the_scope,$1,$4); } - | PRIVATE type TOKEN ARRAY_DIM ';' { - push_variable($3,PRIVATE_SCOPE,$1,$4); - } ; argument: ARGUMENT argflags TOKEN TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' { if(strcmp($5,"get")==0 && @@ -262,18 +286,22 @@ argument: ARGUMENT argflags TOKEN TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' { Node *node; g_free($5); g_free($8); node = new_argument($3,$2,$4, - $7,$6, - $10,$9, + ($7)->str,$6, + ($10)->str,$9, $1); + g_string_free($7,FALSE); + g_string_free($10,FALSE); class_nodes = g_list_append(class_nodes,node); } else if(strcmp($5,"set")==0 && strcmp($8,"get")==0) { Node *node; g_free($5); g_free($8); node = new_argument($3,$2,$4, - $10,$9, - $7,$6, + ($10)->str,$9, + ($7)->str,$6, $1); + g_string_free($10,FALSE); + g_string_free($7,FALSE); class_nodes = g_list_append(class_nodes,node); } else { g_free($3); g_free($4); @@ -290,15 +318,17 @@ argument: ARGUMENT argflags TOKEN TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' { Node *node; g_free($5); node = new_argument($3,$2,$4, - $7,$6,NULL,0, - $1); + ($7)->str,$6, + NULL,0, $1); + g_string_free($7,FALSE); class_nodes = g_list_append(class_nodes,node); } else if(strcmp($5,"set")==0) { Node *node; g_free($5); node = new_argument($3,$2,$4, - NULL,0,$7,$6, - $1); + NULL,0,($7)->str, + $6, $1); + g_string_free($7,FALSE); class_nodes = g_list_append(class_nodes,node); } else { g_free($5); g_free($3); @@ -415,38 +445,8 @@ stars: '*' stars { stars++; } | '*' { stars++; } ; -optpublic: { ; } - | PUBLIC { ; } - ; - -fullsigtype: PRIVATE TOKEN sigtype { - if(strcmp($2,"first")==0) - $$ = PRIVATE_SIGNAL_FIRST_METHOD; - else if(strcmp($2,"last")==0) - $$ = PRIVATE_SIGNAL_LAST_METHOD; - else { - yyerror(_("signal must be 'first' or 'last'")); - g_free($2); - YYERROR; - } - g_free($2); - } - | TOKEN PRIVATE sigtype { - if(strcmp($1,"first")==0) - $$ = PRIVATE_SIGNAL_FIRST_METHOD; - else if(strcmp($1,"last")==0) - $$ = PRIVATE_SIGNAL_LAST_METHOD; - else { - yyerror(_("signal must be 'first' or 'last'")); - g_free($1); - YYERROR; - } - g_free($1); - } - | PRIVATE sigtype { - $$ = PRIVATE_SIGNAL_LAST_METHOD; - } - | TOKEN sigtype { +/* this never sets the_scope */ +simplesigtype: TOKEN sigtype { if(strcmp($1,"first")==0) $$ = SIGNAL_FIRST_METHOD; else if(strcmp($1,"last")==0) @@ -458,7 +458,13 @@ fullsigtype: PRIVATE TOKEN sigtype { } g_free($1); } - | PUBLIC TOKEN sigtype { + | sigtype { + $$ = SIGNAL_LAST_METHOD; + } + ; + +/* this always sets the_scope */ +fullsigtype: scope TOKEN sigtype { if(strcmp($2,"first")==0) $$ = SIGNAL_FIRST_METHOD; else if(strcmp($2,"last")==0) @@ -470,7 +476,7 @@ fullsigtype: PRIVATE TOKEN sigtype { } g_free($2); } - | TOKEN PUBLIC sigtype { + | TOKEN scope sigtype { if(strcmp($1,"first")==0) $$ = SIGNAL_FIRST_METHOD; else if(strcmp($1,"last")==0) @@ -482,11 +488,12 @@ fullsigtype: PRIVATE TOKEN sigtype { } g_free($1); } - | PUBLIC sigtype { + | scope sigtype { $$ = SIGNAL_LAST_METHOD; } - | sigtype { - $$ = SIGNAL_LAST_METHOD; + | simplesigtype { + /* the_scope was default thus public */ + the_scope = PUBLIC_SCOPE; } ; @@ -503,7 +510,7 @@ tokenlist: tokenlist ',' TOKEN { } ; -codenocode: '{' CCODE { $$=$2; } +codenocode: '{' CCODE { $$ = $2; } | ';' { $$ = NULL; } ; @@ -514,55 +521,70 @@ method: SIGNAL fullsigtype type TOKEN '(' funcargs ')' onerror codenocode { "first parameter")); YYERROR; } - push_function($2,NULL, + push_function(the_scope, $2,NULL, $4, $8, $9,$1, ccode_line,vararg); } - | VIRTUAL PRIVATE type TOKEN '(' funcargs ')' onerror codenocode { + | scope SIGNAL simplesigtype type TOKEN '(' funcargs ')' onerror codenocode { + if(!has_self) { + yyerror(_("signal without 'self' as " + "first parameter")); + YYERROR; + } + push_function(the_scope, $3,NULL, + $5, $9, $10,$2, + ccode_line,vararg); + } + | VIRTUAL scope type TOKEN '(' funcargs ')' onerror codenocode { if(!has_self) { yyerror(_("virtual method without 'self' as " "first parameter")); YYERROR; } - push_function(PRIVATE_VIRTUAL_METHOD, NULL, $4, + push_function(the_scope, VIRTUAL_METHOD, NULL, $4, $8, $9,$1, ccode_line,vararg); } - | VIRTUAL optpublic type TOKEN '(' funcargs ')' onerror codenocode { + | scope VIRTUAL type TOKEN '(' funcargs ')' onerror codenocode { if(!has_self) { yyerror(_("virtual method without 'self' as " "first parameter")); YYERROR; } - push_function(VIRTUAL_METHOD, NULL, $4, - $8, $9,$1, + push_function(the_scope, VIRTUAL_METHOD, NULL, $4, + $8, $9,$2, ccode_line,vararg); } - | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' onerror '{' CCODE { - push_function(OVERRIDE_METHOD, $3, - $6, $10, $12, - $1,$11, - vararg); + | VIRTUAL type TOKEN '(' funcargs ')' onerror codenocode { + if(!has_self) { + yyerror(_("virtual method without 'self' as " + "first parameter")); + YYERROR; + } + push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL, + $3, $7, $8,$1, + ccode_line,vararg); } - | PUBLIC type TOKEN '(' funcargs ')' onerror '{' CCODE { - push_function(PUBLIC_SCOPE, NULL, $3, - $7, $9,$1,$8, + | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' onerror codenocode { + push_function(NO_SCOPE, OVERRIDE_METHOD, $3, + $6, $10, $11, + $1,ccode_line, vararg); - } - | PRIVATE type TOKEN '(' funcargs ')' onerror '{' CCODE { - push_function(PRIVATE_SCOPE, NULL, $3, - $7, $9,$1,$8, + } + | scope type TOKEN '(' funcargs ')' onerror codenocode { + push_function(the_scope, REGULAR_METHOD, NULL, $3, + $7, $8,$1,ccode_line, vararg); } | TOKEN '(' TOKEN ')' codenocode { if(strcmp($1,"init")==0) { push_init_arg($3,FALSE); - push_function(INIT_METHOD, NULL, + push_function(NO_SCOPE, INIT_METHOD, NULL, $1, NULL, $5,$2, ccode_line,FALSE); } else if(strcmp($1,"class_init")==0) { push_init_arg($3,TRUE); - push_function(CLASS_INIT_METHOD, NULL, + push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL, $1, NULL, $5,$2, ccode_line,FALSE); } else { @@ -580,7 +602,6 @@ onerror: ONERROR numtok { $$ = $2; } $$ = ($3)->str; g_string_free($3,FALSE); } - | '=' '1' { ; } | { $$ = NULL; } ; diff --git a/src/test.gob b/src/test.gob index ac4fa0b..d606d62 100644 --- a/src/test.gob +++ b/src/test.gob @@ -21,6 +21,8 @@ class Gtk:Weird:Button from Gtk:Button { public GtkWidget * h; public char *bleh; public double array[23][18]; + protected unsigned long int wagawaga; + public int wagawaga_should_be_after_this_in_the_header; init(object) { object->i=0; @@ -44,6 +46,12 @@ class Gtk:Weird:Button from Gtk:Button { int h (check > 0)) { return blah(self,wid,h); } + signal last INT (POINTER, INT) + int bleh2(self, Gtk:Widget * wid (check null type), + int h (check > 0)) { + /* testing multiple marshaller support */ + return 0; + } signal first NONE (NONE) void bloh(self); virtual void * bah(self, int h (check > 0)) onerror NULL { @@ -72,20 +80,53 @@ class Gtk:Weird:Button from Gtk:Button { puts("TEST2"); testprivvirtual(self,array); } + private signal first NONE (NONE) + void googlegoogle3(self) + { + puts("TEST3"); + } + protected signal first NONE (NONE) + void googlegoogle4(self) + { + puts("TEST4"); + } virtual private void testprivvirtual(self, int some_array[5][8][9]) { puts("TEST3"); googlegoogle(self); } + private virtual + void testprivvirtual2(self, int some_array[5][8][9]) + { + /* nothing here */ + } + public virtual + void testpublicvirtual(self, int some_array[5][8][9]) + { + /* nothing here */ + } + protected virtual + void testprotectedvirtual(self, int some_array[5][8][9]) + { + /* nothing here */ + } signal first NONE (POINTER) void testarrsignal(self, long arr[8]) { - puts("TEST2"); + /* foo */ } /* testing empty func */ public void foofoofoo(self) {} + /* testing empty func 2 */ + public void foofoofoo2(self); + /* testing empty func 3 */ + public void foofoofoo3(self) { } + /* testing empty func 4 */ + public void foofoofoo4(self) + { + } override (Gtk:Widget) int event(Gtk:Widget *self (check null type), @@ -97,7 +138,26 @@ class Gtk:Weird:Button from Gtk:Button { /* some code */ return ret; } + override(Gtk:Container) + void + remove(Gtk:Container * self (check null type), + Gtk:Widget * wid (check null type)); + + protected + int foobar(self) { + /* just an empty function */ + return 5; + } + signal last NONE(CHAR,UCHAR,BOOL,INT,UINT,LONG,ULONG,FLOAT,DOUBLE, + STRING,ENUM,FLAGS,BOXED,POINTER,OBJECT) + void + testargs(self, gchar a, guchar b, gboolean c, gint d, guint e, glong f, + gulong g, gfloat h, gdouble i, gchar * j, gint k, + guint l, gpointer m, gpointer o, GtkObject *p) + { + /* ugh, testing casting */ + } } %{ diff --git a/src/tree.c b/src/tree.c index c226273..22c6a2e 100644 --- a/src/tree.c +++ b/src/tree.c @@ -24,7 +24,7 @@ #include "tree.h" Node * -new_ccode(int header, GString *cbuf, int line_no) +new_ccode(int header, char *cbuf, int line_no) { CCode *node = (CCode *)g_new(Node,1); node->type = CCODE_NODE; @@ -78,11 +78,12 @@ new_funcarg(Type *atype, char *name, GList *checks) } Node * -new_method(int scope, Type *mtype, char *otype, GList *gtktypes, char *id, GList *args, char *onerror, GString *cbuf, int line_no,int ccode_line, int vararg) +new_method(int scope, int method, Type *mtype, char *otype, GList *gtktypes, char *id, GList *args, char *onerror, char *cbuf, int line_no,int ccode_line, int vararg) { Method *node = (Method *)g_new(Node,1); node->type = METHOD_NODE; node->scope = scope; + node->method = method; node->mtype = mtype; node->otype = otype; node->gtktypes = gtktypes; @@ -97,7 +98,7 @@ new_method(int scope, Type *mtype, char *otype, GList *gtktypes, char *id, GList } Node * -new_argument(char *gtktype, GList *flags, char *name, GString *get, int get_line, GString *set, int set_line, int line_no) +new_argument(char *gtktype, GList *flags, char *name, char *get, int get_line, char *set, int set_line, int line_no) { Argument *node = (Argument *)g_new(Node,1); node->type = ARGUMENT_NODE; diff --git a/src/tree.h b/src/tree.h index c47156f..474579e 100644 --- a/src/tree.h +++ b/src/tree.h @@ -41,7 +41,7 @@ typedef struct _CCode CCode; struct _CCode { int type; int header; - GString *cbuf; + char *cbuf; int line_no; }; @@ -93,39 +93,44 @@ struct _Argument { char *gtktype; GList *flags; char *name; - GString *get; + char *get; int get_line; - GString *set; + char *set; int set_line; int line_no; }; /*scope type*/ enum { + NO_SCOPE, PUBLIC_SCOPE, PRIVATE_SCOPE, + PROTECTED_SCOPE, +}; + +/* method type */ +enum { + REGULAR_METHOD, INIT_METHOD, CLASS_INIT_METHOD, VIRTUAL_METHOD, - PRIVATE_VIRTUAL_METHOD, SIGNAL_LAST_METHOD, SIGNAL_FIRST_METHOD, - PRIVATE_SIGNAL_LAST_METHOD, - PRIVATE_SIGNAL_FIRST_METHOD, OVERRIDE_METHOD }; typedef struct _Method Method; struct _Method { int type; - int scope; + int scope; /* scope type */ + int method; /* method type */ Type *mtype; char *otype; /*for override methods*/ GList *gtktypes; /*GTK types for a signal*/ char *id; GList *args; char *onerror; - GString *cbuf; + char *cbuf; int line_no; int ccode_line; int vararg; @@ -151,13 +156,13 @@ union _Node { Variable variable; }; -Node *new_ccode(int header, GString *cbuf, int line_no); +Node *new_ccode(int header, char *cbuf, int line_no); Node *new_class(char *otype, char *ptype, GList *nodes); Node *new_type(int stars, char *name, char *postfix); Node *new_check(int chtype, char *number); Node *new_funcarg(Type *atype, char *name, GList *checks); -Node *new_method(int scope, Type *mtype, char *otype, GList *gtktypes, char *id, GList *args, char *onerror, GString *cbuf,int line_no,int ccode_line, int vararg); -Node *new_argument(char *gtktype, GList *flags, char *name, GString *get, int get_line, GString *set, int set_line, int line_no); +Node *new_method(int scope, int method, Type *mtype, char *otype, GList *gtktypes, char *id, GList *args, char *onerror, char *cbuf,int line_no,int ccode_line, int vararg); +Node *new_argument(char *gtktype, GList *flags, char *name, char *get, int get_line, char *set, int set_line, int line_no); Node *new_variable(int scope, Type *vtype, char *id,int line_no); #endif -- 2.43.0