X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/3379dcdfd0872947d761053c61d773add94d38c2..4f7cfa972623842e64e3a8468696f1f6f40fd202:/src/parse.y diff --git a/src/parse.y b/src/parse.y index 192e4c4..17ab264 100644 --- a/src/parse.y +++ b/src/parse.y @@ -123,6 +123,8 @@ push_function(int scope, int method, char *oid, char *id, Node *node; Type *type; char *c_cbuf; + + g_assert(scope != CLASS_SCOPE); if(method!=INIT_METHOD && method!=CLASS_INIT_METHOD) { type = pop_type(); @@ -137,11 +139,22 @@ push_function(int scope, int method, char *oid, char *id, g_list_length(gtktypes) != g_list_length(funcargs) && !(g_list_length(funcargs) == 1 && g_list_length(gtktypes) == 2 && - strcmp(gtktypes->next->data,"NONE")==0)) { + strcmp(gtktypes->next->data, "NONE")==0)) { print_error(TRUE, _("The number of GTK arguments and " "function arguments for a signal " "don't seem to match"), line_no); } + if(g_list_length(gtktypes) > 2) { + GList *li; + for(li = gtktypes->next; li; li = li->next) { + if(strcmp(li->data, "NONE")==0) { + print_error(FALSE, + _("NONE can only appear in an " + "argument list by itself"), + line_no); + } + } + } if(cbuf) { char *p; c_cbuf = p = cbuf->str; @@ -288,7 +301,7 @@ set_return_value(char *type, char *val) %token TOKEN NUMBER TYPETOKEN ARRAY_DIM %token CCODE HTCODE PHCODE HCODE ACODE ATCODE -%token PUBLIC PRIVATE PROTECTED ARGUMENT VIRTUAL SIGNAL OVERRIDE +%token PUBLIC PRIVATE PROTECTED CLASSWIDE ARGUMENT VIRTUAL SIGNAL OVERRIDE %% @@ -370,6 +383,7 @@ thing: method { ; } scope: PUBLIC { the_scope = PUBLIC_SCOPE; } | PRIVATE { the_scope = PRIVATE_SCOPE; } | PROTECTED { the_scope = PROTECTED_SCOPE; } + | CLASSWIDE { the_scope = CLASS_SCOPE; } ; destructor: TOKEN TOKEN { @@ -500,9 +514,9 @@ argument: ARGUMENT flags argtype TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' { Type *type; char *root; - if(strcmp($5,"link")!=0 && - strcmp($5,"stringlink")!=0 && - strcmp($5,"objectlink")!=0) { + if(strcmp($5, "link")!=0 && + strcmp($5, "stringlink")!=0 && + strcmp($5, "objectlink")!=0) { g_free($5); g_free($3); g_free($4); g_list_foreach($2,(GFunc)g_free,NULL); @@ -515,24 +529,29 @@ argument: ARGUMENT flags argtype TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' { var = find_var_or_die($4, $1); if(var->scope == PRIVATE_SCOPE) root = "self->_priv"; + else if(var->scope == CLASS_SCOPE) + root = "SELF_CLASS(GTK_OBJECT(self)->klass)"; else root = "self"; - if(strcmp($5,"link")==0) { + if(strcmp($5, "link")==0) { set = g_strdup_printf("%s->%s = ARG;", root, $4); - } else if(strcmp($5,"stringlink")==0) { + } else if(strcmp($5, "stringlink")==0) { set = g_strdup_printf("g_free(%s->%s); " "%s->%s = g_strdup(ARG);", root, $4, root, $4); - } else if(strcmp($5,"objectlink")==0) { + } else if(strcmp($5, "objectlink")==0) { set = g_strdup_printf( "if(%s->%s) " "gtk_object_unref(GTK_OBJECT(%s->%s)); " "%s->%s = ARG; " "if(%s->%s) " - "gtk_object_ref(GTK_OBJECT(%s->%s)); ", + "gtk_object_ref(GTK_OBJECT(%s->%s));", + root, $4, + root, $4, + root, $4, root, $4, root, $4, root, $4, @@ -754,6 +773,11 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc free_all_global_state(); YYERROR; } + if(the_scope == CLASS_SCOPE) { + yyerror(_("a method cannot be of class scope")); + free_all_global_state(); + YYERROR; + } push_function(the_scope, $3,NULL, $5, $10,$1, ccode_line, vararg, $2); @@ -765,6 +789,11 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc free_all_global_state(); YYERROR; } + if(the_scope == CLASS_SCOPE) { + yyerror(_("a method cannot be of class scope")); + free_all_global_state(); + YYERROR; + } push_function(the_scope, $4, NULL, $6, $11, $2, ccode_line, vararg, $3); @@ -776,6 +805,11 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc free_all_global_state(); YYERROR; } + if(the_scope == CLASS_SCOPE) { + yyerror(_("a method cannot be of class scope")); + free_all_global_state(); + YYERROR; + } push_function(the_scope, VIRTUAL_METHOD, NULL, $4, $9, $1, ccode_line, vararg, NULL); @@ -787,6 +821,11 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc free_all_global_state(); YYERROR; } + if(the_scope == CLASS_SCOPE) { + yyerror(_("a method cannot be of class scope")); + free_all_global_state(); + YYERROR; + } push_function(the_scope, VIRTUAL_METHOD, NULL, $4, $9, $2, ccode_line, vararg, NULL); @@ -809,6 +848,11 @@ method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' returnvals codenoc vararg, NULL); } | scope type TOKEN '(' funcargs ')' returnvals codenocode { + if(the_scope == CLASS_SCOPE) { + yyerror(_("a method cannot be of class scope")); + free_all_global_state(); + YYERROR; + } push_function(the_scope, REGULAR_METHOD, NULL, $3, $8, $1, ccode_line, vararg, NULL);