Node *node;
Type *type;
char *c_cbuf;
+
+ g_assert(scope != CLASS_SCOPE);
if(method!=INIT_METHOD && method!=CLASS_INIT_METHOD) {
type = pop_type();
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;
node = new_method(scope, method, type, oid, gtktypes, flags,
id, funcargs, onerror, defreturn, c_cbuf, line_no,
- ccode_line, vararg);
+ ccode_line, vararg, method_unique_id++);
if(cbuf)
g_string_free(cbuf,
%token <id> TOKEN NUMBER TYPETOKEN ARRAY_DIM
%token <cbuf> CCODE HTCODE PHCODE HCODE ACODE ATCODE
-%token <line> PUBLIC PRIVATE PROTECTED ARGUMENT VIRTUAL SIGNAL OVERRIDE
+%token <line> PUBLIC PRIVATE PROTECTED CLASSWIDE ARGUMENT VIRTUAL SIGNAL OVERRIDE
%%
scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
| PRIVATE { the_scope = PRIVATE_SCOPE; }
| PROTECTED { the_scope = PROTECTED_SCOPE; }
+ | CLASSWIDE { the_scope = CLASS_SCOPE; }
;
destructor: TOKEN TOKEN {
Type *type;
char *root;
- if(strcmp($<id>5,"link")!=0 &&
- strcmp($<id>5,"stringlink")!=0 &&
- strcmp($<id>5,"objectlink")!=0) {
+ if(strcmp($<id>5, "link")!=0 &&
+ strcmp($<id>5, "stringlink")!=0 &&
+ strcmp($<id>5, "objectlink")!=0) {
g_free($<id>5); g_free($<id>3);
g_free($<id>4);
g_list_foreach($<list>2,(GFunc)g_free,NULL);
var = find_var_or_die($<id>4, $<line>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($<id>5,"link")==0) {
+ if(strcmp($<id>5, "link")==0) {
set = g_strdup_printf("%s->%s = ARG;",
root, $<id>4);
- } else if(strcmp($<id>5,"stringlink")==0) {
+ } else if(strcmp($<id>5, "stringlink")==0) {
set = g_strdup_printf("g_free(%s->%s); "
"%s->%s = g_strdup(ARG);",
root, $<id>4,
root, $<id>4);
- } else if(strcmp($<id>5,"objectlink")==0) {
+ } else if(strcmp($<id>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, $<id>4,
+ root, $<id>4,
+ root, $<id>4,
root, $<id>4,
root, $<id>4,
root, $<id>4,
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, $<sigtype>3,NULL,
$<id>5, $<cbuf>10,$<line>1,
ccode_line, vararg, $<list>2);
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, $<sigtype>4, NULL,
$<id>6, $<cbuf>11, $<line>2,
ccode_line, vararg, $<list>3);
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, $<id>4,
$<cbuf>9, $<line>1,
ccode_line, vararg, NULL);
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, $<id>4,
$<cbuf>9, $<line>2,
ccode_line, vararg, NULL);
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, $<id>3,
$<cbuf>8, $<line>1, ccode_line,
vararg, NULL);
} else {
g_free($<id>1);
g_free($<id>3);
- g_string_free($<cbuf>3,TRUE);
- yyerror(_("parse error"));
+ g_string_free($<cbuf>5,TRUE);
+ yyerror(_("parse error "
+ "(untyped blocks must be init or "
+ "class_init)"));
YYERROR;
}
}