X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/346ae1bbcbbe87e79fe2db1f019f014ea64e2175..4f931a71edce4d7456c233487703a894410fd599:/src/parse.y diff --git a/src/parse.y b/src/parse.y index 7ad3af5..662f990 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1,6 +1,7 @@ /* GOB C Preprocessor * Copyright (C) 1999-2000 the Free Software Foundation. - * Copyright (C) 2001 George Lebl + * Copyright (C) 2000 Eazel, Inc. + * Copyright (C) 2001-2009 George (Jiri) Lebl * * Author: George Lebl * @@ -43,8 +44,11 @@ static GList *enum_vals = NULL; static GList *flag_vals = NULL; static GList *error_vals = NULL; +static gboolean abstract = FALSE; +static gboolean dynamic = FALSE; static char *chunk_size = NULL; static char *bonobo_object_class = NULL; +static int glade_xml = FALSE; static GList *interfaces = NULL; static GList *typestack = NULL; static GList *funcargs = NULL; @@ -60,11 +64,14 @@ static int destructor_line = 0; static gboolean destructor_simple = TRUE; static char *initializer = NULL; static int initializer_line = 0; +static int glade_widget = FALSE; +static char *funcattrs = NULL; static char *onerror = NULL; static char *defreturn = NULL; static GList *gtktypes = NULL; +static char *signal_name=NULL; static Property *property = NULL; @@ -77,6 +84,7 @@ int yylex(void); extern int ccode_line; extern int line_no; +extern gboolean for_cpp; extern char *yytext; @@ -86,9 +94,10 @@ yyerror(char *str) char *out=NULL; char *p; - if(strcmp(yytext,"\n")==0) { - out=g_strconcat("Error: ",str," before newline",NULL); - } else if(yytext[0]=='\0') { + if (strcmp (yytext, "\n") == 0 || + strcmp (yytext, "\r") == 0) { + out = g_strconcat ("Error: ", str, " before end of line", NULL); + } else if (yytext[0] == '\0') { out=g_strconcat("Error: ", str, " at end of input", NULL); } else { char *tmp = g_strdup(yytext); @@ -124,6 +133,7 @@ push_variable (char *name, int scope, int line_no, char *postfix) var = node_new (VARIABLE_NODE, "scope", scope, "vtype:steal", type, + "glade_widget", glade_widget, "id:steal", name, "line_no", line_no, "destructor_unref", destructor_unref, @@ -132,8 +142,10 @@ push_variable (char *name, int scope, int line_no, char *postfix) "destructor_simple", destructor_simple, "initializer:steal", initializer, "initializer_line", initializer_line, + "initializer_simple", TRUE, NULL); class_nodes = g_list_append(class_nodes, var); + glade_widget = FALSE; } static void @@ -147,7 +159,11 @@ push_function (int scope, int method, char *oid, char *id, g_assert(scope != CLASS_SCOPE); - if(method == INIT_METHOD || method == CLASS_INIT_METHOD) { + if(method == INIT_METHOD || + method == CLASS_INIT_METHOD || + method == CONSTRUCTOR_METHOD || + method == DISPOSE_METHOD || + method == FINALIZE_METHOD) { type = (Type *)node_new (TYPE_NODE, "name", "void", NULL); @@ -188,6 +204,13 @@ push_function (int scope, int method, char *oid, char *id, } else c_cbuf = NULL; + if (signal_name == NULL ) + { + GString * buffer=g_string_new(""); + g_string_printf(buffer, "\"%s\"", id); + signal_name = buffer->str; + g_string_free(buffer, FALSE); + } node = node_new (METHOD_NODE, "scope", scope, "method", method, @@ -196,7 +219,9 @@ push_function (int scope, int method, char *oid, char *id, "gtktypes:steal", gtktypes, "flags:steal", flags, "id:steal", id, + "signal_name:steal", signal_name, "args:steal", funcargs, + "funcattrs:steal", funcattrs, "onerror:steal", onerror, "defreturn:steal", defreturn, "cbuf:steal", c_cbuf, @@ -214,8 +239,9 @@ push_function (int scope, int method, char *oid, char *id, above */ c_cbuf?FALSE:TRUE); gtktypes = NULL; + signal_name = NULL; funcargs = NULL; - + funcattrs = NULL; onerror = NULL; defreturn = NULL; @@ -225,6 +251,8 @@ push_function (int scope, int method, char *oid, char *id, static void free_all_global_state(void) { + g_free(funcattrs); + funcattrs = NULL; g_free(onerror); onerror = NULL; g_free(defreturn); @@ -328,9 +356,15 @@ find_var_or_die(const char *id, int line) } static gboolean -set_return_value(char *type, char *val) +set_attr_value(char *type, char *val) { - if(strcmp(type, "onerror")==0) { + if(strcmp(type, "attr")==0) { + if(!funcattrs) { + funcattrs = val; + return TRUE; + } else + return FALSE; + } else if(strcmp(type, "onerror")==0) { if(!onerror) { onerror = val; return TRUE; @@ -438,6 +472,61 @@ export_accessors (const char *var_name, node_free ((Node *)the_type); } +static char * +get_prop_enum_flag_cast (Property *prop) +{ + char *tmp, *ret; + if (prop->extra_gtktype == NULL || + /* HACK! just in case someone made this + * work with 2.0.0 by using the TYPE + * macro directly */ + ((strstr (prop->extra_gtktype, "_TYPE_") != NULL || + strstr (prop->extra_gtktype, "TYPE_") == prop->extra_gtktype) && + strchr (prop->extra_gtktype, ':') == NULL)) { + if (prop->ptype != NULL) + return get_type (prop->ptype, TRUE); + else + return g_strdup (""); + } + tmp = remove_sep (prop->extra_gtktype); + ret = g_strdup_printf ("(%s) ", tmp); + g_free (tmp); + return ret; +} + +static void +add_construct_glade (char * file, char * root, char * domain) +{ + Node *var; + Type * type; + + type = (Type *)node_new (TYPE_NODE, + "name", "GladeXML", + "pointer", "*", + NULL); + initializer = g_strdup_printf("\t{\n" + "\tGtkWidget * root;\n" + "\t%%1$s->_priv->_glade_xml = glade_xml_new(%s, %s, %s);\n" + "\troot = glade_xml_get_widget(%%1$s->_priv->_glade_xml, %s);\n" + "\tgtk_widget_show(root);\n" + "\tgtk_container_add(GTK_CONTAINER(%%1$s), root);\n" + "\tglade_xml_signal_autoconnect_full(%%1$s->_priv->_glade_xml, (GladeXMLConnectFunc)___glade_xml_connect_foreach, (gpointer)%%1$s);\n" + "}\n", file, root, domain ? domain : "NULL", root); + + var = node_new (VARIABLE_NODE, + "scope", PRIVATE_SCOPE, + "vtype:steal", type, + "glade_widget", FALSE, + "id:steal", "_glade_xml", + "destructor_unref", FALSE, + "destructor", "g_object_unref", + "destructor_simple", TRUE, + "initializer", initializer, + "initializer_simple", FALSE, + NULL); + class_nodes = g_list_prepend(class_nodes, var); +} + static void property_link_and_export (Node *node) { @@ -475,31 +564,35 @@ property_link_and_export (Node *node) get = g_strdup_printf("g_value_set_string (VAL, %s->%s);", root, prop->name); } else if (strcmp (prop->gtktype, "OBJECT") == 0) { - set = g_strdup_printf("{ GtkObject *___old = (GtkObject *)%s->%s; " - "GtkObject *___new = (GtkObject *)gtk_value_get_object (VAL); " - "if (___new != NULL) { " - "gtk_object_ref (GTK_OBJECT (___new)); " - "%s->%s = GTK_OBJECT (___new); " - "} else { " - "%s->%s = NULL; " - "} " + char *cast; + if (prop->extra_gtktype != NULL) { + cast = remove_sep (prop->extra_gtktype); + } else { + cast = g_strdup ("void"); + } + set = g_strdup_printf("{ GObject *___old = (GObject *)%s->%s; " + "%s->%s = (%s *)g_value_dup_object (VAL); " "if (___old != NULL) { " - "gtk_object_unref (GTK_OBJECT (___old)); " + "g_object_unref (G_OBJECT (___old)); " "} " "}", root, prop->name, root, prop->name, - root, prop->name); - get = g_strdup_printf("g_value_set_object (VAL, %s->%s);", - root, prop->name); + cast); + get = g_strdup_printf ("g_value_set_object (VAL, " + "(gpointer)%s->%s);", + root, prop->name); + g_free (cast); } else if (strcmp (prop->gtktype, "BOXED") == 0) { + char *type = make_me_type (prop->extra_gtktype, + "G_TYPE_BOXED"); if (prop->extra_gtktype == NULL) { error_print (GOB_ERROR, prop->line_no, _("Property linking requested for BOXED, but " "boxed_type not set")); } set = g_strdup_printf("{ gpointer ___old = (gpointer)%s->%s; " - "gpointer ___new = (gpointer)gtk_value_get_boxed (VAL); " + "gpointer ___new = (gpointer)g_value_get_boxed (VAL); " "if (___new != ___old) { " "if (___old != NULL) g_boxed_free (%s, ___old); " "if (___new != NULL) %s->%s = g_boxed_copy (%s, ___new); " @@ -507,29 +600,53 @@ property_link_and_export (Node *node) "} " "}", root, prop->name, - prop->extra_gtktype, + type, root, prop->name, - prop->extra_gtktype, + type, root, prop->name); - get = g_strdup_printf("g_value_set_object (VAL, %s->%s);", + get = g_strdup_printf("g_value_set_boxed (VAL, %s->%s);", root, prop->name); + g_free (type); } else { char *set_func; char *get_func; + const char *getcast = ""; + const char *setcast = ""; + char *to_free = NULL; set_func = g_strdup_printf ("g_value_set_%s", prop->gtktype); g_strdown (set_func); get_func = g_strdup_printf ("g_value_get_%s", prop->gtktype); g_strdown (get_func); - set = g_strdup_printf("%s->%s = %s (VAL);", + if (for_cpp) { + if (strcmp (prop->gtktype, "FLAGS") == 0) { + setcast = "(guint) "; + getcast = to_free = + get_prop_enum_flag_cast (prop); + } else if (strcmp (prop->gtktype, "ENUM") == 0) { + setcast = "(gint) "; + getcast = to_free = + get_prop_enum_flag_cast (prop); + } else if (strcmp (prop->gtktype, "POINTER") == 0) { + setcast = "(gpointer) "; + getcast = g_strdup_printf ("(%s%s) ", + prop->ptype->name, + prop->ptype->pointer ? prop->ptype->pointer : ""); + } + } + + set = g_strdup_printf("%s->%s = %s%s (VAL);", root, prop->name, + getcast, get_func); - get = g_strdup_printf("%s (VAL, %s->%s);", + get = g_strdup_printf("%s (VAL, %s%s->%s);", set_func, + setcast, root, prop->name); g_free (get_func); g_free (set_func); + g_free (to_free); } node_set (node, @@ -586,10 +703,10 @@ ensure_property (void) %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR %token TOKEN NUMBER TYPETOKEN ARRAY_DIM SINGLE_CHAR -%token CCODE HTCODE PHCODE HCODE ACODE ATCODE STRING +%token CCODE CTCODE ADCODE HTCODE PHCODE HCODE ACODE ATCODE STRING %token PUBLIC PRIVATE PROTECTED CLASSWIDE PROPERTY ARGUMENT %token VIRTUAL SIGNAL OVERRIDE -%token NICK BLURB MAXIMUM MINIMUM DEFAULT_VALUE ERROR FLAGS TYPE +%token NAME NICK BLURB MAXIMUM MINIMUM DEFAULT_VALUE ERROR FLAGS TYPE %token FLAGS_TYPE ENUM_TYPE PARAM_TYPE BOXED_TYPE OBJECT_TYPE %% @@ -609,6 +726,15 @@ ccode: CCODE { nodes = g_list_append(nodes,node); g_string_free($1,FALSE); } + | ADCODE { + Node *node = node_new (CCODE_NODE, + "cctype", AD_CCODE, + "cbuf:steal", ($1)->str, + "line_no", ccode_line, + NULL); + nodes = g_list_append(nodes,node); + g_string_free($1,FALSE); + } | HCODE { Node *node = node_new (CCODE_NODE, "cctype", H_CCODE, @@ -654,6 +780,15 @@ ccode: CCODE { nodes = g_list_append(nodes,node); g_string_free($1,FALSE); } + | CTCODE { + Node *node = node_new (CCODE_NODE, + "cctype", CT_CCODE, + "cbuf:steal", ($1)->str, + "line_no", ccode_line, + NULL); + nodes = g_list_append(nodes,node); + g_string_free($1,FALSE); + } ; ccodes: ccodes ccode { ; } @@ -683,16 +818,30 @@ classdec: CLASS TYPETOKEN FROM TYPETOKEN classflags { "otype:steal", $2, "ptype:steal", $4, "bonobo_object_class:steal", bonobo_object_class, + "glade_xml", glade_xml, "interfaces:steal", interfaces, "chunk_size:steal", chunk_size, + "abstract", abstract, + "dynamic", dynamic, NULL); bonobo_object_class = NULL; + glade_xml = FALSE; chunk_size = NULL; interfaces = NULL; } ; classflags: + | '(' TOKEN ')' classflags { + if(strcmp($2,"abstract") == 0) { + abstract = TRUE; + } else if(strcmp($2,"dynamic") == 0) { + dynamic = TRUE; + } else { + yyerror(_("parse error")); + YYERROR; + } + } | '(' TOKEN TOKEN ')' classflags { if(strcmp($2,"chunks") == 0) { g_free (chunk_size); @@ -726,6 +875,42 @@ classflags: YYERROR; } } + | '(' TOKEN STRING STRING ')' classflags { + if (strcmp ($2, "GladeXML") == 0) { + glade_xml = TRUE; + add_construct_glade($3, $4, NULL); + } else { + yyerror(_("parse error")); + YYERROR; + } + } + | '(' TOKEN STRING STRING STRING ')' classflags { + if (strcmp ($2, "GladeXML") == 0) { + glade_xml = TRUE; + add_construct_glade($3, $4, $5); + } else { + yyerror(_("parse error")); + YYERROR; + } + } + | '(' TOKEN TOKEN STRING ')' classflags { + if (strcmp ($2, "GladeXML") == 0) { + glade_xml = TRUE; + add_construct_glade($3, $4, NULL); + } else { + yyerror(_("parse error")); + YYERROR; + } + } + | '(' TOKEN TOKEN STRING STRING ')' classflags { + if (strcmp ($2, "GladeXML") == 0) { + glade_xml = TRUE; + add_construct_glade($3, $4, $5); + } else { + yyerror(_("parse error")); + YYERROR; + } + } ; classcode: classcode thing { ; } @@ -826,6 +1011,14 @@ varoptions: destructor initializer { ; } | initializer destructor { ; } | initializer { destructor = NULL; } | destructor { initializer = NULL; } + | TOKEN { + if (strcmp ($1, "GladeXML") == 0) { + glade_widget = TRUE; + } else { + yyerror(_("parse error")); + YYERROR; + } + } | { destructor = NULL; initializer = NULL; @@ -967,7 +1160,7 @@ argument: ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE TOKEN '{' CCODE '; char *get, *set = NULL; Variable *var; Type *type; - char *root; + const char *root; if(strcmp($6, "link")!=0 && strcmp($6, "stringlink")!=0 && @@ -984,15 +1177,16 @@ argument: ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE TOKEN '{' CCODE '; type = pop_type(); var = find_var_or_die($4, $1); - if(var->scope == PRIVATE_SCOPE) + if(var->scope == PRIVATE_SCOPE) { root = "self->_priv"; - else if(var->scope == CLASS_SCOPE) { + } else if(var->scope == CLASS_SCOPE) { root = "SELF_GET_CLASS(self)"; if(no_self_alias) error_print(GOB_ERROR, $1, _("Self aliases needed when autolinking to a classwide member")); - } else + } else { root = "self"; + } if(strcmp($6, "link")==0) { set = g_strdup_printf("%s->%s = ARG;", @@ -1188,7 +1382,13 @@ anyval: numtok { $$ = $1; } | string { $$ = $1; } ; -param_spec_value: NICK '=' string { +param_spec_value: NAME '=' string { + ensure_property (); + node_set ((Node *)property, + "canonical_name:steal", gob_str_delete_quotes($3), + NULL); + } + | NICK '=' string { ensure_property (); node_set ((Node *)property, "nick:steal", $3, @@ -1231,30 +1431,60 @@ param_spec_value: NICK '=' string { "ptype:steal", type, NULL); } + | FLAGS_TYPE '=' TYPETOKEN { + ensure_property (); + node_set ((Node *)property, + "extra_gtktype:steal", $3, + NULL); + } | FLAGS_TYPE '=' TOKEN { ensure_property (); node_set ((Node *)property, "extra_gtktype:steal", $3, NULL); } + | ENUM_TYPE '=' TYPETOKEN { + ensure_property (); + node_set ((Node *)property, + "extra_gtktype:steal", $3, + NULL); + } | ENUM_TYPE '=' TOKEN { ensure_property (); node_set ((Node *)property, "extra_gtktype:steal", $3, NULL); } + | PARAM_TYPE '=' TYPETOKEN { + ensure_property (); + node_set ((Node *)property, + "extra_gtktype:steal", $3, + NULL); + } | PARAM_TYPE '=' TOKEN { ensure_property (); node_set ((Node *)property, "extra_gtktype:steal", $3, NULL); } + | BOXED_TYPE '=' TYPETOKEN { + ensure_property (); + node_set ((Node *)property, + "extra_gtktype:steal", $3, + NULL); + } | BOXED_TYPE '=' TOKEN { ensure_property (); node_set ((Node *)property, "extra_gtktype:steal", $3, NULL); } + | OBJECT_TYPE '=' TYPETOKEN { + ensure_property (); + node_set ((Node *)property, + "extra_gtktype:steal", $3, + NULL); + } | OBJECT_TYPE '=' TOKEN { ensure_property (); node_set ((Node *)property, @@ -1263,7 +1493,12 @@ param_spec_value: NICK '=' string { } | TOKEN { ensure_property (); - if (strcmp ($1, "link") == 0) { + if (strcmp ($1, "override") == 0) { + g_free($1); + node_set ((Node *)property, + "override", TRUE, + NULL); + } else if (strcmp ($1, "link") == 0) { g_free($1); node_set ((Node *)property, "link", TRUE, @@ -1467,6 +1702,10 @@ fullsigtype: scope TOKEN sigtype { sigtype: TOKEN '(' tokenlist ')' { gtktypes = g_list_prepend(gtktypes, debool ($1)); } + | TOKEN STRING '(' tokenlist ')' { + gtktypes = g_list_prepend(gtktypes, debool ($1)); + signal_name=$2; + } ; tokenlist: tokenlist ',' TOKEN { @@ -1482,7 +1721,7 @@ codenocode: '{' CCODE { $$ = $2; } ; /*here CCODE will include the ending '}' */ -method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenocode { +method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenocode { if(!has_self) { yyerror(_("signal without 'self' as " "first parameter")); @@ -1494,11 +1733,18 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc free_all_global_state(); YYERROR; } + if (funcattrs != NULL) { + char *error = g_strdup_printf + (_("function attribute macros ('%s' in this case) may not be used with signal methods"), + funcattrs); + yyerror (error); + YYERROR; + } push_function(the_scope, $3,NULL, $5, $10,$1, ccode_line, vararg, $2); } - | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' returnvals codenocode { + | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' methodmods codenocode { if(!has_self) { yyerror(_("signal without 'self' as " "first parameter")); @@ -1510,11 +1756,18 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc free_all_global_state(); YYERROR; } + if (funcattrs != NULL) { + char *error = g_strdup_printf + (_("function attribute macros ('%s' in this case) may not be used with signal methods"), + funcattrs); + yyerror (error); + YYERROR; + } push_function(the_scope, $4, NULL, $6, $11, $2, ccode_line, vararg, $3); } - | VIRTUAL scope type TOKEN '(' funcargs ')' returnvals codenocode { + | VIRTUAL scope type TOKEN '(' funcargs ')' methodmods codenocode { if(!has_self) { yyerror(_("virtual method without 'self' as " "first parameter")); @@ -1526,11 +1779,18 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc free_all_global_state(); YYERROR; } + if (funcattrs != NULL) { + char *error = g_strdup_printf + (_("function attribute macros ('%s' in this case) may not be used with virtual methods"), + funcattrs); + yyerror (error); + YYERROR; + } push_function(the_scope, VIRTUAL_METHOD, NULL, $4, $9, $1, ccode_line, vararg, NULL); } - | scope VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode { + | scope VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode { if(!has_self) { yyerror(_("virtual method without 'self' as " "first parameter")); @@ -1542,28 +1802,49 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc free_all_global_state(); YYERROR; } + if (funcattrs != NULL) { + char *error = g_strdup_printf + (_("function attribute macros ('%s' in this case) may not be used with virtual methods"), + funcattrs); + yyerror (error); + YYERROR; + } push_function(the_scope, VIRTUAL_METHOD, NULL, $4, $9, $2, ccode_line, vararg, NULL); } - | VIRTUAL type TOKEN '(' funcargs ')' returnvals codenocode { + | VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode { if(!has_self) { - yyerror(_("virtual method without 'self' as " + yyerror(_("virtual method without 'szelf' as " "first parameter")); free_all_global_state(); YYERROR; } + if (funcattrs != NULL) { + char *error = g_strdup_printf + (_("function attribute macros ('%s' in this case) may not be used with virtual methods"), + funcattrs); + yyerror (error); + YYERROR; + } push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL, $3, $8, $1, ccode_line, vararg, NULL); } - | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' returnvals codenocode { + | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' methodmods codenocode { + if (funcattrs != NULL) { + char *error = g_strdup_printf + (_("function attribute macros ('%s' in this case) may not be used with override methods"), + funcattrs); + yyerror (error); + YYERROR; + } push_function(NO_SCOPE, OVERRIDE_METHOD, $3, $6, $11, $1, ccode_line, vararg, NULL); } - | scope type TOKEN '(' funcargs ')' returnvals codenocode { + | scope type TOKEN '(' funcargs ')' methodmods codenocode { if(the_scope == CLASS_SCOPE) { yyerror(_("a method cannot be of class scope")); free_all_global_state(); @@ -1584,22 +1865,40 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL, $1, $5, $2, ccode_line, FALSE, NULL); + } else if(strcmp($1, "constructor")==0) { + push_init_arg($3, FALSE); + push_function(NO_SCOPE, CONSTRUCTOR_METHOD, NULL, + $1, $5, $2, + ccode_line, FALSE, NULL); + } else if(strcmp($1, "dispose")==0) { + push_init_arg($3, FALSE); + push_function(NO_SCOPE, DISPOSE_METHOD, NULL, + $1, $5, $2, + ccode_line, FALSE, NULL); + } else if(strcmp($1, "finalize")==0) { + push_init_arg($3, FALSE); + push_function(NO_SCOPE, FINALIZE_METHOD, NULL, + $1, $5, $2, + ccode_line, FALSE, NULL); + } else { g_free($1); g_free($3); g_string_free($5,TRUE); yyerror(_("parse error " - "(untyped blocks must be init or " - "class_init)")); + "(untyped blocks must be init, " + "class_init, constructor, dispose " + "or finalize)")); YYERROR; } } ; -returnvals: TOKEN retcode { +methodmods: TOKEN retcode { + g_free(funcattrs); funcattrs = NULL; g_free(onerror); onerror = NULL; g_free(defreturn); defreturn = NULL; - if(!set_return_value($1, $2)) { + if(!set_attr_value($1, $2)) { g_free($1); g_free($2); yyerror(_("parse error")); @@ -1608,25 +1907,58 @@ returnvals: TOKEN retcode { g_free($1); } | TOKEN retcode TOKEN retcode { + g_free(funcattrs); funcattrs = NULL; + g_free(onerror); onerror = NULL; + g_free(defreturn); defreturn = NULL; + if(!set_attr_value($1, $2)) { + g_free($1); g_free($2); + g_free($3); g_free($4); + yyerror(_("parse error")); + YYERROR; + } + if(!set_attr_value($3, $4)) { + funcattrs = onerror = defreturn = NULL; + g_free($1); g_free($2); + g_free($3); g_free($4); + yyerror(_("parse error")); + YYERROR; + } + g_free($1); + g_free($3); + } + | TOKEN retcode TOKEN retcode TOKEN retcode { + g_free(funcattrs); funcattrs = NULL; g_free(onerror); onerror = NULL; g_free(defreturn); defreturn = NULL; - if(!set_return_value($1, $2)) { + if(!set_attr_value($1, $2)) { + g_free($1); g_free($2); + g_free($3); g_free($4); + g_free($5); g_free($6); + yyerror(_("parse error")); + YYERROR; + } + if(!set_attr_value($3, $4)) { + funcattrs = onerror = defreturn = NULL; g_free($1); g_free($2); g_free($3); g_free($4); + g_free($5); g_free($6); yyerror(_("parse error")); YYERROR; } - if(!set_return_value($3, $4)) { - onerror = defreturn = NULL; + if(!set_attr_value($5, $6)) { + funcattrs = onerror = defreturn = NULL; g_free($1); g_free($2); g_free($3); g_free($4); + g_free($5); g_free($6); yyerror(_("parse error")); YYERROR; } g_free($1); g_free($3); + g_free($5); } | { + g_free(funcattrs); funcattrs = NULL; g_free(onerror); onerror = NULL; g_free(defreturn); defreturn = NULL; } @@ -1634,8 +1966,8 @@ returnvals: TOKEN retcode { retcode: numtok { $$ = $1; } | '{' CCODE { - $$ = ($3)->str; - g_string_free($3, FALSE); + $$ = ($2)->str; + g_string_free($2, FALSE); } ;