X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/daead564b9592e78d418deb56a211cd5ea399f76..refs/tags/v0.90.2:/src/main.c diff --git a/src/main.c b/src/main.c index 54293fc..1b2b19c 100644 --- a/src/main.c +++ b/src/main.c @@ -257,6 +257,8 @@ print_method(FILE *fp, char *typeprefix, char *nameprefix, out_printf(fp,"%s",arg->name); } + if(m->vararg) + out_printf(fp,", ..."); } else { out_printf(fp,"void"); } @@ -268,7 +270,10 @@ put_vs_method(Method *m) { if(m->scope != SIGNAL_LAST_METHOD && m->scope != SIGNAL_FIRST_METHOD && - m->scope != VIRTUAL_METHOD) + m->scope != PRIVATE_SIGNAL_LAST_METHOD && + m->scope != PRIVATE_SIGNAL_FIRST_METHOD && + m->scope != VIRTUAL_METHOD && + m->scope != PRIVATE_VIRTUAL_METHOD) return; print_method(outh,"\t","(* ",") ",";",m); @@ -280,7 +285,10 @@ 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 == CLASS_INIT_METHOD || + m->scope == PRIVATE_SIGNAL_LAST_METHOD || + m->scope == PRIVATE_SIGNAL_FIRST_METHOD || + m->scope == PRIVATE_VIRTUAL_METHOD) return; print_method(outh,"","\t","\t",";",m); @@ -292,9 +300,15 @@ put_priv_method_prot(Method *m) if(m->scope == PUBLIC_SCOPE) return; - if(m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD || - m->scope == VIRTUAL_METHOD) { + if(m->scope == PRIVATE_SIGNAL_LAST_METHOD || + m->scope == PRIVATE_SIGNAL_FIRST_METHOD || + m->scope == PRIVATE_VIRTUAL_METHOD) { + if(m->cbuf) + print_method(out,"static ","_real_"," ",";",m); + print_method(out,"static ",""," ",";",m); + } else if(m->scope == SIGNAL_LAST_METHOD || + m->scope == SIGNAL_FIRST_METHOD || + m->scope == VIRTUAL_METHOD) { if(!m->cbuf) return; print_method(out,"static ","_real_"," ",";",m); @@ -347,7 +361,7 @@ make_inits(Class *cl) (Type *)new_type(0,g_strdup("void")), NULL,NULL,g_strdup("class_init"), make_init_args(cl,g_strdup("c"),TRUE), - NULL, NULL,0,0); + NULL, NULL,0,0,FALSE); cl->nodes = g_list_prepend(cl->nodes,node); } if(!got_init) { @@ -355,7 +369,7 @@ make_inits(Class *cl) (Type *)new_type(0,g_strdup("void")), NULL,NULL,g_strdup("init"), make_init_args(cl,g_strdup("o"),FALSE), - NULL, NULL,0,0); + NULL, NULL,0,0,FALSE); cl->nodes = g_list_prepend(cl->nodes,node); } } @@ -370,7 +384,9 @@ add_signal_prots(Method *m) char *s; if(m->scope != SIGNAL_LAST_METHOD && - m->scope != SIGNAL_FIRST_METHOD) + m->scope != SIGNAL_FIRST_METHOD && + m->scope != PRIVATE_SIGNAL_LAST_METHOD && + m->scope != PRIVATE_SIGNAL_FIRST_METHOD) return; if(!marsh) @@ -450,7 +466,9 @@ add_enums(Class *c) if(n->type == METHOD_NODE) { Method *m = (Method *)n; if(m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD) { + m->scope == SIGNAL_FIRST_METHOD || + m->scope == PRIVATE_SIGNAL_LAST_METHOD || + m->scope == PRIVATE_SIGNAL_FIRST_METHOD) { char *s = g_strdup(m->id); g_strup(s); out_printf(out,"\t%s_SIGNAL,\n",s); @@ -559,12 +577,21 @@ add_signals(Class *c) char *mar; char *sig; int is_none; + int last = FALSE; if(n->type != METHOD_NODE || (((Method *)n)->scope != SIGNAL_FIRST_METHOD && - ((Method *)n)->scope != SIGNAL_LAST_METHOD)) + ((Method *)n)->scope != SIGNAL_LAST_METHOD && + ((Method *)n)->scope != PRIVATE_SIGNAL_FIRST_METHOD && + ((Method *)n)->scope != PRIVATE_SIGNAL_LAST_METHOD)) continue; m = (Method *)n; + + if(m->scope == SIGNAL_FIRST_METHOD || + m->scope == PRIVATE_SIGNAL_FIRST_METHOD) + last = FALSE; + else + last = TRUE; if(g_hash_table_lookup(marsh,m)) mar = g_strconcat("marshal_", @@ -585,7 +612,7 @@ add_signals(Class *c) "\t\t\t%s,\n" "\t\t\tGTK_TYPE_%s, %d", sig,m->id, - m->scope==SIGNAL_LAST_METHOD?"LAST":"FIRST", + last?"LAST":"FIRST", typebase,m->id,mar,(char *)m->gtktypes->data, is_none?0:g_list_length(m->gtktypes->next)); g_free(mar); @@ -616,7 +643,10 @@ set_def_handlers(Class *c, char *oname) 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)) continue; @@ -882,6 +912,7 @@ static void put_method(Method *m) { char *s; + int private = FALSE; out_printf(out,"\n"); switch(m->scope) { case PUBLIC_SCOPE: @@ -894,10 +925,13 @@ put_method(Method *m) print_method(out,"static ","\n"," ","",m); 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,"","\n"," ","",m); + print_method(out,private?"static ":"","\n"," ","",m); out_addline_outfile(out); out_printf(out,"{\n"); s = g_strdup(m->id); @@ -938,9 +972,11 @@ put_method(Method *m) print_method(out,"static ","\n_real_"," ","",m); 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,"","\n"," ","",m); + print_method(out,private?"static ":"","\n"," ","",m); out_addline_outfile(out); out_printf(out,"{\n" "\t%sClass *class;\n",typebase); @@ -1048,7 +1084,9 @@ check_duplicate_named(Class *c,Node *node,char *id, int line_no) if(n->type == METHOD_NODE) { Method *m = (Method *)n; if(m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD) { + m->scope == SIGNAL_FIRST_METHOD || + m->scope == PRIVATE_SIGNAL_LAST_METHOD || + m->scope == PRIVATE_SIGNAL_FIRST_METHOD) { nid = m->id; nline_no = m->line_no; } else @@ -1079,7 +1117,9 @@ check_duplicate_signals_args(Class *c) if(n->type == METHOD_NODE) { Method *m = (Method *)n; if(m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD) + m->scope == SIGNAL_FIRST_METHOD || + m->scope == PRIVATE_SIGNAL_LAST_METHOD || + m->scope == PRIVATE_SIGNAL_FIRST_METHOD) check_duplicate_named(c,n,m->id,m->line_no); } else if(n->type == ARGUMENT_NODE) { Argument *a = (Argument *)n; @@ -1105,6 +1145,33 @@ check_public_new(Class *c) } } +static void +check_vararg(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->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) { + print_error(FALSE, + "signals, overrides and virtuals, " + "can't have variable argument " + "lists", + m->line_no); + } + } + } +} + static int count_signals(Class *c) { @@ -1115,7 +1182,9 @@ count_signals(Class *c) if(n->type == METHOD_NODE) { Method *m = (Method *)n; if(m->scope == SIGNAL_LAST_METHOD || - m->scope == SIGNAL_FIRST_METHOD) + m->scope == SIGNAL_FIRST_METHOD || + m->scope == PRIVATE_SIGNAL_LAST_METHOD || + m->scope == PRIVATE_SIGNAL_FIRST_METHOD) num++; } } @@ -1384,6 +1453,7 @@ main(int argc, char *argv[]) check_duplicate_symbols((Class *)class); check_duplicate_signals_args((Class *)class); check_public_new((Class *)class); + check_vararg((Class *)class); exit_on_error = TRUE; if(got_error)