+Sun Jul 23 18:51:45 2000 George Lebl <jirka@5z.com>
+
+ * src/util.[ch], src/main.c, src/checks.c, src/lexer.l, src/parse.y:
+ make new cleaner error print routines including a printfstyle one.
+ Use the get_real_id on all method ids even for overrides. When a
+ signal is added there is also a sizeof check for the signature vs.
+ argument list with a g_error if it fails. Fix %at{ %} to not
+ appear twice in all files.
+
+ * src/main.c: Apply patch from Arturo Tena to make things compile
+ nicely with gcc's -ansi -pedantic
+
+ * src/out.[ch]: constize correctly and use G_GNUC_PRINTF macro for
+ warnings.
+
+Fri Jul 21 15:38:10 2000 George Lebl <jirka@5z.com>
+
+ * src/main.c: store the private structure pointer so that we
+ don't look inside the freed object structureafter finalize
+
Thu Jul 06 02:32:29 2000 George Lebl <jirka@5z.com>
* Release 1.0.3
+1.0.4
+ * Fix segfault in finalize
+ * Minor fixes and improvements
+
+ NOTE: Everyone should update due to the segfault fix!
+
1.0.3
* Add "const self", and a _CONST cast macro (Bas van der Linden)
* Objects should compile with Glib/GTK+ 1.3 (to become 2.0)
PACKAGE=gob
-VERSION=1.0.3
+VERSION=1.0.4
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; }
AC_PREREQ(2.2)
AC_INIT(src/treefuncs.h)
AM_CONFIG_HEADER(config.h)
-AM_INIT_AUTOMAKE(gob,1.0.3)
+AM_INIT_AUTOMAKE(gob,1.0.4)
if test -f ../NOINST_GOB ; then
DOINSTGOB=
-%define ver 1.0.3
+%define ver 1.0.4
%define rel 1
%define prefix /usr
char *nid;
int nline_no;
gboolean here_underscore = FALSE;
- char *s;
if(n->type == METHOD_NODE) {
Method *m = (Method *)n;
continue;
/* this can only happen if the things were methods and
* one had an underscore and the other one didn't */
- if(!no_kill_underscores && underscore != here_underscore)
- s = g_strdup_printf("symbol '%s' ('_%s') redefined, "
- "first defined on line %d. "
- "Note that '%s' and '_%s' are "
- "eqivalent.",
- id, id, line_no, id, id);
+ if( ! no_kill_underscores && underscore != here_underscore)
+ error_printf(GOB_ERROR, nline_no,
+ "symbol '%s' ('_%s') redefined, "
+ "first defined on line %d. "
+ "Note that '%s' and '_%s' are "
+ "eqivalent.",
+ id, id, line_no, id, id);
else
- s = g_strdup_printf("symbol '%s' redefined, "
- "first defined on line %d",
- id, line_no);
- print_error(FALSE, s, nline_no);
- g_free(s);
+ error_printf(GOB_ERROR, nline_no,
+ "symbol '%s' redefined, "
+ "first defined on line %d",
+ id, line_no);
}
}
for(l = c->nodes; l != NULL; l = g_list_next(l)) {
Node *n = l->data;
Method *m = (Method *)n;
- char *s;
if(n->type != METHOD_NODE ||
m->method != OVERRIDE_METHOD)
continue;
if(method == m ||
method->line_no > m->line_no ||
- strcmp(m->id, method->id) != 0 ||
+ strcmp(get_real_id(m->id), get_real_id(method->id)) != 0 ||
strcmp(m->otype, method->otype) != 0)
continue;
- s = g_strdup_printf("override '%s(%s)' redefined, "
- "first defined on line %d",
- m->id, m->otype, method->line_no);
- print_error(FALSE, s, m->line_no);
- g_free(s);
+ error_printf(GOB_ERROR, m->line_no,
+ "override '%s(%s)' redefined, "
+ "first defined on line %d",
+ get_real_id(m->id), m->otype, method->line_no);
}
}
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 "
- "identifier of signal "
- "or virtual methods",
- m->id);
- print_error(FALSE,s,m->line_no);
- g_free(s);
+ (strcmp(m->id, "__parent__")==0 ||
+ strcmp(m->id, "___parent__")==0)) {
+ error_printf(GOB_ERROR, m->line_no,
+ "'%s' not allowed as an "
+ "identifier of signal "
+ "or virtual methods",
+ m->id);
}
if(m->method != INIT_METHOD &&
m->method != CLASS_INIT_METHOD &&
- (strcmp(m->id, "init")==0 ||
- strcmp(m->id, "class_init")==0)) {
- print_error(FALSE,"init, or class_init not "
+ (strcmp(get_real_id(m->id), "init")==0 ||
+ strcmp(get_real_id(m->id), "class_init")==0)) {
+ error_print(GOB_ERROR, m->line_no,
+ "init, or class_init not "
"allowed as an "
"identifier of non-"
- "constructor methods", m->line_no);
+ "constructor methods");
}
} else if(n->type == VARIABLE_NODE) {
Variable *v = (Variable *)n;
if(strcmp(v->id, "_priv")==0 ||
strcmp(v->id, "__parent__")==0) {
- char *s;
- s = g_strdup_printf("'%s' not allowed as a "
- "data member name", v->id);
- print_error(FALSE, s, v->line_no);
- g_free(s);
+ error_printf(GOB_ERROR, v->line_no,
+ "'%s' not allowed as a "
+ "data member name", v->id);
}
}
}
Node *n = l->data;
char *nid;
int nline_no;
- char *s;
if(n->type == METHOD_NODE) {
Method *m = (Method *)n;
if(m->method == SIGNAL_LAST_METHOD ||
m->method == SIGNAL_FIRST_METHOD) {
- nid = m->id;
+ nid = get_real_id(m->id);
nline_no = m->line_no;
} else
continue;
nline_no = a->line_no;
} else
continue;
- if(n==node ||
- line_no>=nline_no ||
- g_strcasecmp(nid,id)!=0)
+ if(n == node ||
+ line_no >= nline_no ||
+ g_strcasecmp(nid, id)!=0)
continue;
- s = g_strdup_printf("named symbol (argument or signal) '%s' "
- "redefined, first defined on line %d "
- "(case insensitive)",
- id,line_no);
- print_error(FALSE,s,nline_no);
+ error_printf(GOB_ERROR, nline_no,
+ "named symbol (argument or signal) '%s' "
+ "redefined, first defined on line %d "
+ "(case insensitive)",
+ id, line_no);
}
}
Method *m = (Method *)n;
if(m->method == SIGNAL_LAST_METHOD ||
m->method == SIGNAL_FIRST_METHOD)
- check_duplicate_named(c,n,m->id,m->line_no);
+ check_duplicate_named(c, n, get_real_id(m->id),
+ m->line_no);
} else if(n->type == ARGUMENT_NODE) {
Argument *a = (Argument *)n;
- check_duplicate_named(c,n,a->name,a->line_no);
+ check_duplicate_named(c, n, a->name, a->line_no);
}
}
}
Node *n = l->data;
if(n->type == METHOD_NODE) {
Method *m = (Method *)n;
- if((strcmp(m->id,"new")==0) &&
+ if((strcmp(get_real_id(m->id), "new")==0) &&
(m->method != REGULAR_METHOD ||
m->scope != PUBLIC_SCOPE))
- print_error(TRUE,
+ error_print(GOB_WARN, m->line_no,
"'new' should be a regular\n"
- "public method",
- m->line_no);
+ "public method");
}
}
}
Node *n = l->data;
if(n->type == METHOD_NODE) {
Method *m = (Method *)n;
- if(!m->vararg)
+ if( ! m->vararg)
continue;
if(m->method == OVERRIDE_METHOD ||
m->method == SIGNAL_LAST_METHOD ||
m->method == SIGNAL_FIRST_METHOD ||
m->method == VIRTUAL_METHOD) {
- print_error(FALSE,
+ error_print(GOB_ERROR, m->line_no,
"signals, overrides and virtuals, "
"can't have variable argument "
- "lists",
- m->line_no);
+ "lists");
}
}
}
m->method == SIGNAL_LAST_METHOD ||
m->method == SIGNAL_FIRST_METHOD ||
m->method == VIRTUAL_METHOD) {
- print_error(FALSE,
+ error_print(GOB_ERROR, m->line_no,
"signals, overrides and virtuals, "
- "can't have no arguments",
- m->line_no);
+ "can't have no arguments");
}
}
}
if(!(strcmp(m->mtype->name, "void")==0 &&
m->mtype->pointer == NULL) &&
!m->cbuf) {
- print_error(TRUE,
+ error_print(GOB_WARN, m->line_no,
"non-void empty method found, "
"regular non-void function should "
- "not be empty.",
- m->line_no);
+ "not be empty.");
/* 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
continue;
for(l=m->gtktypes;l;l=l->next) {
- char *s;
if(get_cast(l->data, FALSE))
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);
+ error_printf(GOB_ERROR, m->line_no,
+ "Unknown GTK+ type '%s' "
+ "among signal types",
+ (char *)l->data);
}
}
}
Node *n = l->data;
if(n->type == ARGUMENT_NODE) {
Argument *a = (Argument *)n;
- char *s;
if(get_cast(a->gtktype, FALSE))
continue;
- s = g_strdup_printf("Unknown GTK+ type '%s' "
- "as argument type",
- a->gtktype);
/* this could perhaps be a warning, but
can there really be a type beyond the
fundementals? */
- print_error(FALSE, s, a->line_no);
- g_free(s);
+ error_printf(GOB_ERROR, a->line_no,
+ "Unknown GTK+ type '%s' "
+ "as argument type",
+ a->gtktype);
}
}
}
if(strcmp(fa->atype->name, "void") == 0 &&
fa->atype->pointer == NULL) {
- print_error(FALSE, "Running checks on a void function "
- "argument", m->line_no);
+ error_print(GOB_ERROR, m->line_no,
+ "Running checks on a void function argument");
return;
}
type_check_error:
if(fa->atype->pointer)
- s = g_strdup_printf("Cannot check the type of '%s %s'",
- fa->atype->name, fa->atype->pointer);
+ error_printf(GOB_ERROR, m->line_no,
+ "Cannot check the type of '%s %s'",
+ fa->atype->name, fa->atype->pointer);
else
- s = g_strdup_printf("Cannot check the type of '%s'",
- fa->atype->name);
- print_error(FALSE, s, m->line_no);
- g_free(s);
+ error_printf(GOB_ERROR, m->line_no,
+ "Cannot check the type of '%s'",
+ fa->atype->name);
}
static void
}
int
-count_arguments(Class *c)
+count_set_arguments(Class *c)
+{
+ int num = 0;
+ GList *li;
+ for(li = c->nodes; li != NULL; li = g_list_next(li)) {
+ Node *n = li->data;
+ Argument *a = li->data;
+ if(n->type == ARGUMENT_NODE &&
+ a->set)
+ num ++;
+ }
+ return num;
+}
+
+int
+count_get_arguments(Class *c)
{
int num = 0;
GList *li;
for(li = c->nodes; li != NULL; li = g_list_next(li)) {
Node *n = li->data;
- if(n->type == ARGUMENT_NODE)
+ Argument *a = li->data;
+ if(n->type == ARGUMENT_NODE &&
+ a->get)
num ++;
}
return num;
void check_func_arg_checks(Class *c);
int count_signals(Class *c);
-int count_arguments(Class *c);
+int count_set_arguments(Class *c);
+int count_get_arguments(Class *c);
int count_overrides(Class *c);
int count_privates(Class *c);
int count_protecteds(Class *c);
BEGIN(CLASS_CODE);
if(++found_classes > 1) {
- print_error(FALSE,
- "Only one class per file allowed",
- line_no);
+ error_print(GOB_ERROR, line_no,
+ "Only one class per file allowed");
}
return CLASS;
yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 345 "lexer.l"
+#line 344 "lexer.l"
{
int maj = 0,min = 0,pl = 0;
int rmaj = 0,rmin = 0,rpl = 0;
if(rmaj < maj ||
(rmaj == maj && rmin < min) ||
(rmaj == maj && rmin == min && rpl < pl)) {
- char *s;
- s = g_strdup_printf(
- "GOB version %d.%d.%d required "
- "(this is %s)\n"
- "To upgrade your gob, see: "
- "http://www.5z.com/jirka/gob.html",
- maj,min,pl,VERSION);
- print_error(FALSE, s, line_no);
- g_free(s);
+ error_printf(GOB_ERROR, line_no,
+ "GOB version %d.%d.%d required "
+ "(this is %s)\n"
+ "To upgrade your gob, see: "
+ "http://www.5z.com/jirka/gob.html",
+ maj, min, pl, VERSION);
}
}
YY_BREAK
case 53:
YY_RULE_SETUP
-#line 369 "lexer.l"
+#line 365 "lexer.l"
{
if(for_cpp) {
- char *s;
- s = g_strdup_printf("'%s' keyword should not "
- "be used when generating "
- "C++ code", yytext);
- print_error(TRUE, s, line_no);
- g_free(s);
+ error_printf(GOB_WARN, line_no,
+ "'%s' keyword should not "
+ "be used when generating "
+ "C++ code", yytext);
}
REJECT;
}
YY_BREAK
case 54:
YY_RULE_SETUP
-#line 381 "lexer.l"
+#line 375 "lexer.l"
{return FROM;}
YY_BREAK
case 55:
YY_RULE_SETUP
-#line 383 "lexer.l"
+#line 377 "lexer.l"
{return VOID;}
YY_BREAK
case 56:
YY_RULE_SETUP
-#line 384 "lexer.l"
+#line 378 "lexer.l"
{return STRUCT;}
YY_BREAK
case 57:
YY_RULE_SETUP
-#line 385 "lexer.l"
+#line 379 "lexer.l"
{return UNION;}
YY_BREAK
case 58:
YY_RULE_SETUP
-#line 386 "lexer.l"
+#line 380 "lexer.l"
{return ENUM;}
YY_BREAK
case 59:
YY_RULE_SETUP
-#line 387 "lexer.l"
+#line 381 "lexer.l"
{return SIGNED;}
YY_BREAK
case 60:
YY_RULE_SETUP
-#line 388 "lexer.l"
+#line 382 "lexer.l"
{return UNSIGNED;}
YY_BREAK
case 61:
YY_RULE_SETUP
-#line 389 "lexer.l"
+#line 383 "lexer.l"
{return LONG;}
YY_BREAK
case 62:
YY_RULE_SETUP
-#line 390 "lexer.l"
+#line 384 "lexer.l"
{return SHORT;}
YY_BREAK
case 63:
YY_RULE_SETUP
-#line 391 "lexer.l"
+#line 385 "lexer.l"
{return INT;}
YY_BREAK
case 64:
YY_RULE_SETUP
-#line 392 "lexer.l"
+#line 386 "lexer.l"
{return FLOAT;}
YY_BREAK
case 65:
YY_RULE_SETUP
-#line 393 "lexer.l"
+#line 387 "lexer.l"
{return DOUBLE;}
YY_BREAK
case 66:
YY_RULE_SETUP
-#line 394 "lexer.l"
+#line 388 "lexer.l"
{return CHAR;}
YY_BREAK
case 67:
YY_RULE_SETUP
-#line 395 "lexer.l"
+#line 389 "lexer.l"
{return CONST;}
YY_BREAK
case 68:
YY_RULE_SETUP
-#line 397 "lexer.l"
+#line 391 "lexer.l"
{return THREEDOTS;}
YY_BREAK
case 69:
YY_RULE_SETUP
-#line 399 "lexer.l"
+#line 393 "lexer.l"
{yylval.line = line_no; return PUBLIC;}
YY_BREAK
case 70:
YY_RULE_SETUP
-#line 400 "lexer.l"
+#line 394 "lexer.l"
{yylval.line = line_no; return PRIVATE;}
YY_BREAK
case 71:
YY_RULE_SETUP
-#line 401 "lexer.l"
+#line 395 "lexer.l"
{yylval.line = line_no; return PROTECTED;}
YY_BREAK
case 72:
YY_RULE_SETUP
-#line 402 "lexer.l"
+#line 396 "lexer.l"
{yylval.line = line_no; return CLASSWIDE;}
YY_BREAK
case 73:
YY_RULE_SETUP
-#line 403 "lexer.l"
+#line 397 "lexer.l"
{yylval.line = line_no; return ARGUMENT;}
YY_BREAK
case 74:
YY_RULE_SETUP
-#line 404 "lexer.l"
+#line 398 "lexer.l"
{yylval.line = line_no; return VIRTUAL;}
YY_BREAK
case 75:
YY_RULE_SETUP
-#line 405 "lexer.l"
+#line 399 "lexer.l"
{yylval.line = line_no; return SIGNAL;}
YY_BREAK
case 76:
YY_RULE_SETUP
-#line 406 "lexer.l"
+#line 400 "lexer.l"
{yylval.line = line_no; return OVERRIDE;}
YY_BREAK
case 77:
YY_RULE_SETUP
-#line 407 "lexer.l"
+#line 401 "lexer.l"
{
yylval.id = g_strdup(yytext);
return NUMBER;
YY_BREAK
case 78:
YY_RULE_SETUP
-#line 411 "lexer.l"
+#line 405 "lexer.l"
{
/* this one is for a classname with a namespace */
yylval.id = g_strdup(yytext);
YY_BREAK
case 79:
YY_RULE_SETUP
-#line 416 "lexer.l"
+#line 410 "lexer.l"
{
/* this is for a classname with an empty namespace */
yylval.id = g_strdup(yytext);
YY_BREAK
case 80:
YY_RULE_SETUP
-#line 421 "lexer.l"
+#line 415 "lexer.l"
{
yylval.id = g_strdup(yytext);
return TOKEN;
YY_BREAK
case 81:
YY_RULE_SETUP
-#line 426 "lexer.l"
+#line 420 "lexer.l"
{
yylval.id = g_strdup(yytext);
return ARRAY_DIM;
YY_BREAK
case 82:
YY_RULE_SETUP
-#line 431 "lexer.l"
+#line 425 "lexer.l"
{
BEGIN(CLASS_CODE_I);
return '{';
YY_BREAK
case 83:
YY_RULE_SETUP
-#line 435 "lexer.l"
+#line 429 "lexer.l"
{
BEGIN(C_CODE);
parenth_depth=1;
YY_BREAK
case 84:
YY_RULE_SETUP
-#line 444 "lexer.l"
+#line 438 "lexer.l"
{
BEGIN(INITIAL);
return '}';
YY_BREAK
case 85:
YY_RULE_SETUP
-#line 449 "lexer.l"
+#line 443 "lexer.l"
; /*ignore*/
YY_BREAK
case 86:
YY_RULE_SETUP
-#line 451 "lexer.l"
+#line 445 "lexer.l"
{
yylval.line = line_no;
return yytext[0];
YY_BREAK
case 87:
YY_RULE_SETUP
-#line 456 "lexer.l"
+#line 450 "lexer.l"
; /*ignore*/
YY_BREAK
case 88:
YY_RULE_SETUP
-#line 458 "lexer.l"
+#line 452 "lexer.l"
ECHO;
YY_BREAK
-#line 1802 "lex.yy.c"
+#line 1796 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT):
case YY_STATE_EOF(C_CODE):
return 0;
}
#endif
-#line 458 "lexer.l"
+#line 452 "lexer.l"
/* Ugly warning avoiding */
BEGIN(CLASS_CODE);
if(++found_classes > 1) {
- print_error(FALSE,
- "Only one class per file allowed",
- line_no);
+ error_print(GOB_ERROR, line_no,
+ "Only one class per file allowed");
}
return CLASS;
if(rmaj < maj ||
(rmaj == maj && rmin < min) ||
(rmaj == maj && rmin == min && rpl < pl)) {
- char *s;
- s = g_strdup_printf(
- "GOB version %d.%d.%d required "
- "(this is %s)\n"
- "To upgrade your gob, see: "
- "http://www.5z.com/jirka/gob.html",
- maj,min,pl,VERSION);
- print_error(FALSE, s, line_no);
- g_free(s);
+ error_printf(GOB_ERROR, line_no,
+ "GOB version %d.%d.%d required "
+ "(this is %s)\n"
+ "To upgrade your gob, see: "
+ "http://www.5z.com/jirka/gob.html",
+ maj, min, pl, VERSION);
}
}
<CLASS_CODE,CLASS_CODE_I>class|this {
if(for_cpp) {
- char *s;
- s = g_strdup_printf("'%s' keyword should not "
- "be used when generating "
- "C++ code", yytext);
- print_error(TRUE, s, line_no);
- g_free(s);
+ error_printf(GOB_WARN, line_no,
+ "'%s' keyword should not "
+ "be used when generating "
+ "C++ code", yytext);
}
REJECT;
}
static char *ptypebase;
static int signals = 0; /* number of signals */
-static int arguments = 0; /* number of named arguments */
+static int set_arguments = 0; /* number of named (set) arguments */
+static int get_arguments = 0; /* number of named (get) arguments */
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 char *
get_gtk_doc(char *id)
{
- char *val, *s;
+ char *val;
if(!gtk_doc_hash)
return NULL;
if(val)
return g_strdup_printf("/**\n * %s_%s:\n%s **/\n",
funcbase, get_real_id(id), val);
- s = g_strconcat(funcbase, "_", get_real_id(id), NULL);
- val = g_hash_table_lookup(gtk_doc_hash, s);
- g_free(s);
+ val = g_hash_table_lookup(gtk_doc_hash, get_real_id(id));
if(val)
return g_strdup_printf("/**\n * %s_%s:\n%s **/\n",
funcbase, get_real_id(id), val);
return;
if(!no_gnu)
- out_printf(out, "\n\n#ifndef __GNUC__\n");
+ out_printf(out, "\n\n#if (!defined __GNUC__) || (defined __GNUC__ && defined __STRICT_ANSI__)\n");
out_printf(out,
"/*REALLY BAD HACK\n"
" This is to avoid unused warnings if you don't call\n"
out_printf(out, "\t___%s_really_bad_hack_to_avoid_warnings();\n",
funcbase);
if(!no_gnu)
- out_printf(out, "}\n#endif /* __GNUC__ */\n\n");
+ out_printf(out, "}\n#endif /* !__GNUC__ || (__GNUC__ && __STRICT_ANSI__) */\n\n");
else
out_printf(out, "}\n\n");
}
m, FALSE, FALSE, FALSE);
g_free(s);
} else if(m->scope == PRIVATE_SCOPE ||
- m->method == INIT_METHOD ||
- m->method == CLASS_INIT_METHOD)
+ m->method == INIT_METHOD ||
+ m->method == CLASS_INIT_METHOD)
print_method(out, "static ", "", "", " ",
no_gnu?";\n":" G_GNUC_UNUSED;\n",
m, FALSE, FALSE, TRUE);
Method *m = (Method *)n;
if(m->method == INIT_METHOD) {
if(got_init)
- print_error(FALSE, "init defined more then once", m->line_no);
+ error_print(GOB_ERROR, m->line_no, "init defined more then once");
got_init = TRUE;
} else if(m->method == CLASS_INIT_METHOD) {
if(got_class_init)
- print_error(FALSE, "class_init defined more then once", m->line_no);
+ error_print(GOB_ERROR, m->line_no, "class_init defined more then once");
got_class_init = TRUE;
}
}
if(m->method == OVERRIDE_METHOD &&
strcmp(m->id, "destroy")==0) {
if(strcmp(m->otype, "Gtk:Object") != 0) {
- print_error(FALSE,
+ error_print(GOB_ERROR, m->line_no,
"destroy method override "
"of class other then "
- "Gtk:Object",
- m->line_no);
+ "Gtk:Object");
}
if(g_list_length(m->args) != 1) {
- print_error(FALSE,
+ error_print(GOB_ERROR, m->line_no,
"destroy method override "
"with more then one "
- "parameter",
- m->line_no);
+ "parameter");
}
destroy_handler = m;
break;
Method *m = (Method *)n;
if(m->method == OVERRIDE_METHOD &&
strcmp(m->id, "finalize")==0) {
- if(strcmp(m->otype, "Gtk:Object") != 0) {
- print_error(FALSE,
+ if(strcmp(m->otype, "Gtk:Object") != 0 &&
+ strcmp(m->otype, "G:Object") != 0) {
+ error_print(GOB_ERROR, m->line_no,
"finalize method override "
"of class other then "
- "Gtk:Object",
- m->line_no);
+ "Gtk:Object (or G:Object"
+ "for GTK+ 2.0)");
}
if(g_list_length(m->args) != 1) {
- print_error(FALSE,
+ error_print(GOB_ERROR, m->line_no,
"finalize method override "
"with more then one "
- "parameter",
- m->line_no);
+ "parameter");
}
finalize_handler = m;
break;
}
out_printf(out, "\tLAST_SIGNAL\n};\n\n");
}
- if(arguments>0) {
+ if(set_arguments > 0 || get_arguments > 0) {
out_printf(out, "enum {\n\tARG_0");
for(li=c->nodes;li;li=g_list_next(li)) {
Node *n = li->data;
break;
}
/* if we haven't found it in our list */
- if(!flags[i]) {
- char *s;
- s = g_strdup_printf("Unknown flag '%s' used, "
- "perhaps it was misspelled",
- flag);
- print_error(TRUE, s, m->line_no);
- g_free(s);
+ if( ! flags[i]) {
+ error_printf(GOB_WARN, m->line_no,
+ "Unknown flag '%s' used, "
+ "perhaps it was misspelled",
+ flag);
}
g_string_sprintfa(gs, " | GTK_RUN_%s", flag);
}
flags,
typebase, get_real_id(m->id), mar,
(char *)m->gtktypes->data,
- is_none?0:g_list_length(m->gtktypes->next));
+ is_none ? 0 : g_list_length(m->gtktypes->next));
g_free(mar);
g_free(sig);
g_free(flags);
- if(!is_none) {
+ if( ! is_none) {
GList *l;
- for(l=m->gtktypes->next;l;l=g_list_next(l))
+ for(l = m->gtktypes->next; l != NULL; l = l->next)
out_printf(out, ",\n\t\t\tGTK_TYPE_%s",
(char *)l->data);
}
out_printf(out, ");\n");
+
+ if(strcmp(m->gtktypes->data, "NONE") != 0 ||
+ ! is_none) {
+ GList *gl, *al;
+ char *sep = "";
+ out_printf(out, "\tif(");
+ if(strcmp(m->gtktypes->data, "NONE") != 0) {
+ out_printf(out, "%s sizeof(", sep);
+ print_type(out, m->mtype, FALSE);
+ out_printf(out, "%s",
+ m->mtype->postfix ?
+ m->mtype->postfix : "");
+ out_printf(out, ") != sizeof(%s)",
+ get_cast(m->gtktypes->data, FALSE));
+
+ sep = " || ";
+ }
+
+ for(al = m->args->next, gl = m->gtktypes->next;
+ al != NULL && gl != NULL;
+ al = al->next, gl = gl->next) {
+ FuncArg *arg = al->data;
+ char *gtkarg = gl->data;
+
+ out_printf(out, "%ssizeof(", sep);
+ print_type(out, arg->atype, FALSE);
+ out_printf(out, "%s",
+ arg->atype->postfix ?
+ arg->atype->postfix : "");
+ out_printf(out, ") != sizeof(%s)",
+ get_cast(gtkarg, FALSE));
+
+ sep = " || ";
+ }
+ out_printf(out, ") {\n"
+ "\t\tg_error(\"%s line %d: Type mismatch "
+ "of \\\"%s\\\" signal signature\");\n"
+ "\t}\n",
+ filename, m->line_no, get_real_id(m->id));
+
+ }
}
out_printf(out, "\tgtk_object_class_add_signals (gtk_object_class,\n"
"\t\tobject_signals, LAST_SIGNAL);\n\n");
if(need_destroy &&
destroy_handler &&
- strcmp(m->id, "destroy") == 0)
+ strcmp(get_real_id(m->id), "destroy") == 0)
out_printf(out, "\tgtk_object_class->destroy "
"= ___destroy;\n");
else if(need_finalize &&
finalize_handler &&
- strcmp(m->id, "finalize") == 0)
+ strcmp(get_real_id(m->id), "finalize") == 0)
out_printf(out,
"#ifdef G_OBJECT_CLASS\n"
"\tg_object_class->finalize = ___finalize;\n"
else if(m->cbuf)
out_printf(out,
"\t%s_class->%s = ___%x_%s_%s;\n",
- s, m->id, (guint)m->unique_id,
- funcbase, m->id);
+ s, get_real_id(m->id), (guint)m->unique_id,
+ funcbase, get_real_id(m->id));
else
out_printf(out, "\t%s_class->%s = NULL;\n",
- s, m->id);
+ s, get_real_id(m->id));
} else {
if(m->cbuf)
out_printf(out, "\t%s->%s = ___real_%s_%s;\n",
flags = g_string_new("GTK_ARG_READABLE");
else
flags = g_string_new("GTK_ARG_WRITABLE");
+
+ g_assert(a->get || a->set);
for(l=a->flags;l;l=g_list_next(l)) {
char *flag = l->data;
if(strcmp(flag, "READWRITE")==0 ||
strcmp(flag, "READABLE")==0 ||
strcmp(flag, "WRITABLE")==0) {
- print_error(TRUE, "READWRITE, READABLE and "
+ error_print(GOB_WARN, a->line_no,
+ "READWRITE, READABLE and "
"WRITABLE argument flags are "
- "set automatically", a->line_no);
+ "set automatically");
continue;
}
- for(i=0;argflags[i];i++) {
+ for(i = 0; argflags[i]; i++) {
if(strcmp(argflags[i], flag)==0)
break;
}
/* if we haven't found it in our list */
- if(!argflags[i]) {
- char *s;
- s = g_strdup_printf("Unknown flag '%s' used, "
- "perhaps it was misspelled",
- flag);
- print_error(TRUE, s, a->line_no);
- g_free(s);
+ if( ! argflags[i]) {
+ error_printf(GOB_WARN, a->line_no,
+ "Unknown flag '%s' used, "
+ "perhaps it was misspelled", flag);
}
g_string_sprintfa(flags, " | GTK_ARG_%s", flag);
}
g_string_free(flags, TRUE);
}
- out_printf(out,
- "\n\tgtk_object_class->set_arg = ___object_set_arg;\n"
- "\tgtk_object_class->get_arg = ___object_get_arg;\n");
+ out_printf(out, "\n");
+ if(get_arguments > 0)
+ out_printf(out, "\tgtk_object_class->get_arg = ___object_get_arg;\n");
+ if(set_arguments > 0)
+ out_printf(out, "\tgtk_object_class->set_arg = ___object_set_arg;\n");
}
static void
c->otype);
if(destructors > 0) {
- out_printf(out, "\t%s *self G_GNUC_UNUSED = %s (obj_self);\n",
+ out_printf(out, "\t%s *self = %s (obj_self);\n",
typebase, macrobase);
}
}
}
+ out_printf(out, "\treturn;\n");
+ if(destructors > 0)
+ out_printf(out, "\tself = NULL;\n");
out_printf(out, "}\n"
"#undef __GOB_FUNCTION__\n\n");
}
if(privates > 0) {
out_printf(out, "\t%s *self = %s (obj_self);\n",
typebase, macrobase);
+ out_printf(out, "\tgpointer priv = self->_priv;\n");
}
if(finalize_handler) {
}
if(privates > 0) {
- out_printf(out, "\tg_free (self->_priv);\n"
- "\tself->_priv = NULL;\n");
+ out_printf(out, "\tg_free(priv);\n");
}
out_printf(out, "}\n"
for(li=c->nodes;li;li=g_list_next(li)) {
Node *n = li->data;
Method *m;
+
+ gboolean add_unused_class = FALSE;
+
if(n->type != METHOD_NODE)
continue;
m = (Method *)n;
"#define __GOB_FUNCTION__ \"%s::class_init\"\n",
c->otype);
if(signals > 0 ||
- arguments > 0 ||
+ set_arguments > 0 ||
+ get_arguments > 0 ||
need_destroy ||
need_finalize) {
+ add_unused_class = TRUE;
out_printf(out,
"\tGtkObjectClass *"
- "gtk_object_class G_GNUC_UNUSED = "
+ "gtk_object_class = "
"(GtkObjectClass*) %s;\n",
((FuncArg *)m->args->data)->name);
out_printf(out,
"#ifdef G_OBJECT_CLASS\n"
"\tGObjectClass *"
- "g_object_class G_GNUC_UNUSED = "
+ "g_object_class = "
"(GObjectClass*) %s;\n"
"#endif /* G_OBJECT_CLASS */\n",
((FuncArg *)m->args->data)->name);
li = li->next) {
Node *n = li->data;
Variable *v = (Variable *)n;
- if(n->type != VARIABLE_NODE ||
- v->scope != CLASS_SCOPE)
- continue;
- print_initializer(m, v);
+ if(n->type == VARIABLE_NODE &&
+ v->scope == CLASS_SCOPE)
+ print_initializer(m, v);
}
}
"\tgtk_object_class->finalize = ___finalize;\n"
"#endif /* G_OBJECT_CLASS */\n");
- if(arguments > 0)
+ if(get_arguments > 0 || set_arguments > 0)
make_arguments(c);
} else
out_printf(out, "%s\n", m->cbuf);
out_addline_outfile(out);
out_printf(out, " }\n");
- } else {
- out_printf(out, "return;\n");
+ }
+ out_printf(out, "\treturn;\n");
+ out_printf(out,
+ "\t%s = NULL;\n",
+ ((FuncArg *)m->args->data)->name);
+ if(add_unused_class) {
+ out_printf(out,
+ "\tgtk_object_class = NULL;\n"
+ "#ifdef G_OBJECT_CLASS\n"
+ "\tg_object_class = NULL;\n"
+ "#endif /* G_OBJECT_CLASS */\n");
}
out_printf(out, "}\n"
"#undef __GOB_FUNCTION__\n");
"((%s)GTK_VALUE_%s(*arg))\n",
cast, a->gtktype);
} else {
- out_printf(out, "#ifdef __GNUC__\n");
+ out_printf(out, "#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
if(strcmp(a->gtktype, "OBJECT")==0) {
out_printf(out, "#define ARG "
"({%s foo = "
"foo; })\n",
cast, a->gtktype);
}
- out_printf(out, "#else /* __GNUC__ */\n");
+ out_printf(out, "#else /* __GNUC__ && !__STRICT_ANSI__ */\n");
out_printf(out, "#define ARG "
"((%s)GTK_VALUE_%s(*arg))\n",
cast, a->gtktype);
- out_printf(out, "#endif /* __GNUC__ */\n\n");
+ out_printf(out, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n\n");
}
out_printf(out, "\t\t{\n");
g_free(cast);
out_printf(out, "\t\t}\n\t\tbreak;\n"
"#undef ARG\n");
}
- out_printf(out, "\tdefault:\n\t\tbreak;\n\t}\n}\n"
+ out_printf(out, "\tdefault:\n\t\tbreak;\n\t}\n"
+ "\treturn;\n\tself = NULL;\n\targ = NULL;\n}\n"
"#undef __GOB_FUNCTION__\n");
}
out_printf(out, "#define PARENT_HANDLER(%s) \\\n"
"\t{ if(%s_CLASS(parent_class)->%s) \\\n"
"\t\t(* %s_CLASS(parent_class)->%s)(%s); }\n",
- args, s, m->id, s, m->id, args);
+ args, s, get_real_id(m->id), s, get_real_id(m->id), args);
} else {
out_printf(out, "#define PARENT_HANDLER(%s) \\\n"
"\t((%s_CLASS(parent_class)->%s)? \\\n"
"\t\t(* %s_CLASS(parent_class)->%s)(%s): \\\n"
"\t\t(",
- args, s, m->id, s, m->id, args);
+ args, s, get_real_id(m->id), s, get_real_id(m->id), args);
out_printf(out, "(");
print_type(out, m->mtype, TRUE);
out_printf(out, ")%s))\n",
{
GList *li;
- if(arguments<0)
+ if(get_arguments < 0 && set_arguments < 0)
return;
for(li=c->nodes;li;li=g_list_next(li)) {
{
GList *li;
- if(arguments<0)
+ if(get_arguments < 0 && set_arguments < 0)
return;
for(li=c->nodes;li;li=g_list_next(li)) {
out_printf(outh, "};\n\n");
out_printf(out, "/* here are local prototypes */\n");
- if(arguments > 0) {
+ if(set_arguments > 0) {
out_printf(out, "static void ___object_set_arg "
"(GtkObject *object, GtkArg *arg, "
- "guint arg_id);\n"
- "static void ___object_get_arg "
+ "guint arg_id);\n");
+ }
+ if(get_arguments > 0) {
+ out_printf(out, "static void ___object_get_arg "
"(GtkObject *object, GtkArg *arg, "
"guint arg_id);\n");
}
/* argument wrapping macros */
- if(arguments > 0 && ! no_gnu) {
- out_printf(outh, "\n/*\n"
- " * Argument wrapping macros\n"
- " */\n");
- out_printf(outh, "#ifdef __GNUC__\n");
- put_argument_gnu_wrappers(c);
- out_printf(outh, "#else /* __GNUC__ */\n");
- put_argument_nongnu_wrappers(c);
- out_printf(outh, "#endif /* __GNUC__ */\n\n");
- } else if(arguments > 0 && no_gnu) {
- out_printf(outh, "\n/*\n"
- " * Argument wrapping macros\n"
- " */\n");
- put_argument_nongnu_wrappers(c);
+ if(get_arguments > 0 || set_arguments > 0) {
+ if( ! no_gnu) {
+ out_printf(outh, "\n/*\n"
+ " * Argument wrapping macros\n"
+ " */\n");
+ out_printf(outh, "#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
+ put_argument_gnu_wrappers(c);
+ out_printf(outh, "#else /* __GNUC__ && !__STRICT_ANSI__ */\n");
+ put_argument_nongnu_wrappers(c);
+ out_printf(outh, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n\n");
+ } else {
+ out_printf(outh, "\n/*\n"
+ " * Argument wrapping macros\n"
+ " */\n");
+ put_argument_nongnu_wrappers(c);
+ }
}
if(signals > 0) {
if(no_gnu)
make_method_nongnu_aliases(c);
else {
- out_printf(out, "\n#ifdef __GNUC__\n");
+ out_printf(out, "\n#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
make_method_gnu_aliases(c);
- out_printf(out, "#else /* __GNUC__ */\n");
+ out_printf(out, "#else /* __GNUC__ && !__STRICT_ANSI__ */\n");
make_method_nongnu_aliases(c);
- out_printf(out, "#endif /* __GNUC__ */\n\n");
+ out_printf(out, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n\n");
}
}
add_inits(c);
- if(arguments > 0) {
+ if(set_arguments > 0) {
add_getset_arg(c, TRUE);
+ }
+
+ if(get_arguments > 0) {
add_getset_arg(c, FALSE);
}
char *p;
/* We may need string.h for memset */
- if(destructors > 0)
+ if(destructors > 0 &&
+ ! g_list_find_custom(include_files, "string.h", (GCompareFunc)strcmp)) {
out_printf(out, "#include <string.h> /* memset() */\n\n");
+ }
p = g_strconcat(filebase, ".h", NULL);
found_header = TRUE;
- if(!g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) {
+ if( ! g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) {
out_printf(out, "#include \"%s.h\"\n\n", filebase);
found_header = FALSE;
}
/* if we are creating a private header see if it was included */
if(outph) {
p = g_strconcat(filebase, "-private.h", NULL);
- if(!g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) {
+ if( ! g_list_find_custom(include_files, p,
+ (GCompareFunc)strcmp)) {
out_printf(out, "#include \"%s-private.h\"\n\n",
filebase);
if(found_header)
- print_error(TRUE,
+ error_printf(GOB_WARN, 0,
"Implicit private header include "
"added to top of\n"
"\tsource file, while public "
"you should\n"
"\texplicitly include "
"the private header below the "
- "public one.", 0);
+ "public one.");
}
g_free(p);
}
"#include \"%s.h\"\n\n", p, p, filebase);
g_free(p);
- if(!no_extern_c) {
+ if( ! no_extern_c) {
out_printf(outh, "#ifdef __cplusplus\n"
"extern \"C\" {\n"
"#endif /* __cplusplus */\n\n");
static void
print_header_postfixes(void)
{
- if(!no_extern_c)
+ if( ! no_extern_c)
out_printf(outh, "\n#ifdef __cplusplus\n"
"}\n"
"#endif /* __cplusplus */\n");
out_printf(outh, "\n#endif\n");
if(outph) {
- if(!no_extern_c)
+ if( ! no_extern_c)
out_printf(outph, "\n#ifdef __cplusplus\n"
"}\n"
"#endif /* __cplusplus */\n");
GList *li;
/* print the AT_CCODE blocks */
- for(li=nodes;li;li=g_list_next(li)) {
+ for(li = nodes; li != NULL; li = li->next) {
Node *node = li->data;
if(node->type == CCODE_NODE) {
CCode *cc = (CCode *)node;
- if(cc->cctype==AT_CCODE)
+ if(cc->cctype == AT_CCODE)
print_ccode_block((CCode *)node);
}
}
Node *node = li->data;
if(node->type == CCODE_NODE) {
CCode *cc = (CCode *)node;
- if(cc->cctype==HT_CCODE)
+ if(cc->cctype == HT_CCODE)
print_ccode_block((CCode *)node);
}
}
Node *node = li->data;
if(node->type == CCODE_NODE) {
CCode *cc = (CCode *)node;
- if(cc->cctype!=HT_CCODE)
+ if(cc->cctype != HT_CCODE &&
+ cc->cctype != AT_CCODE)
print_ccode_block((CCode *)node);
} else if(node->type == CLASS_NODE) {
print_class_block((Class *)node);
filename = NULL;
- for(i=1;i<argc;i++) {
- if(no_opts || argv[i][0]!='-') {
+ for(i = 1 ; i < argc; i++) {
+ if(no_opts ||
+ argv[i][0] != '-') {
/*must be a file*/
if(got_file) {
fprintf(stderr, "Specify only one file!\n");
} else {
/*by now we know we have a string starting with
- which is a short option string*/
- char *p = argv[i]+1;
- for(p=argv[i]+1; *p; p++) {
+ char *p;
+ for(p = argv[i] + 1; *p; p++) {
switch(*p) {
case 'w':
exit_on_warn=TRUE;
char *hfnew = g_strconcat("#gob#", filebase, ".h#gob#", NULL);
char *hf = g_strconcat(filebase, ".h", NULL);
struct stat s;
- if(stat(hf, &s)==0) {
+ if(stat(hf, &s) == 0) {
char *s;
s = g_strdup_printf("cmp '%s' '%s' > /dev/null", hf, hfnew);
- if(system(s)==0) {
- if(unlink(hfnew)!=0)
- print_error(FALSE,
- "Can't remove new header file", 0);
+ if(system(s) == 0) {
+ if(unlink(hfnew) != 0)
+ error_printf(GOB_ERROR, 0,
+ "Can't remove new header file");
g_free(hfnew);
g_free(hf);
g_free(s);
return;
}
g_free(s);
- if(unlink(hf)!=0)
- print_error(FALSE, "Can't remove old header file", 0);
+ if(unlink(hf) != 0)
+ error_printf(GOB_ERROR, 0,
+ "Can't remove old header file");
}
- if(rename(hfnew, hf)!=0)
- print_error(FALSE, "Can't rename new header file", 0);
+ if(rename(hfnew, hf) != 0)
+ error_printf(GOB_ERROR, 0,
+ "Can't rename new header file");
g_free(hfnew);
g_free(hf);
}
} else
filename = "stdin";
+ /* This is where parsing is done */
/*yydebug = 1;*/
- if(yyparse()!=0)
+ if(yyparse() != 0)
g_error("Parsing errors, quitting");
- if(!class)
- print_error(FALSE, " no class defined", 0);
+
+ if( ! class)
+ error_print(GOB_ERROR, 0, " no class defined");
exit_on_error = FALSE;
signals = count_signals((Class *)class);
- arguments = count_arguments((Class *)class);
+ set_arguments = count_set_arguments((Class *)class);
+ get_arguments = count_get_arguments((Class *)class);
overrides = count_overrides((Class *)class);
privates = count_privates((Class *)class);
protecteds = count_protecteds((Class *)class);
fclose(outph);
}
- if(no_touch_headers && !no_write)
+ if(no_touch_headers &&
+ ! no_write)
compare_and_move_header();
return 0;
}
void
-out_printf(FILE *fp, char *format,...)
+out_printf(FILE *fp, const char *format,...)
{
va_list ap;
char *s;
#include <stdio.h>
-void out_printf(FILE *fp,char *format,...);
-void out_addline_infile(FILE *fp, int line);
-void out_addline_outfile(FILE *fp);
+void out_printf (FILE *fp, const char *format, ...) G_GNUC_PRINTF (2, 3);
+void out_addline_infile (FILE *fp, int line);
+void out_addline_outfile (FILE *fp);
#endif
!(g_list_length(funcargs) == 1 &&
g_list_length(gtktypes) == 2 &&
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);
+ error_print(GOB_WARN, line_no,
+ _("The number of GTK arguments and "
+ "function arguments for a signal "
+ "don't seem to match"));
}
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,
+ error_print(GOB_ERROR, line_no,
_("NONE can only appear in an "
- "argument list by itself"),
- line_no);
+ "argument list by itself"));
}
}
}
find_var_or_die(const char *id, int line)
{
GList *li;
- char *s;
for(li = class_nodes; li != NULL; li = li->next) {
Variable *var;
return var;
}
- s = g_strdup_printf(_("Variable %s not defined here"), id);
- print_error(FALSE, s, line);
+ error_printf(GOB_ERROR, line, _("Variable %s not defined here"), id);
g_assert_not_reached();
return NULL;
}
-#line 295 "parse.y"
+#line 293 "parse.y"
typedef union {
char *id;
GString *cbuf;
#if YYDEBUG != 0
static const short yyrline[] = { 0,
- 313, 314, 315, 316, 319, 325, 331, 337, 343, 349,
- 357, 358, 361, 366, 373, 378, 379, 387, 398, 399,
- 402, 403, 404, 405, 408, 409, 410, 411, 414, 427,
- 443, 447, 455, 456, 457, 458, 459, 465, 468, 472,
- 508, 537, 612, 621, 627, 628, 631, 634, 640, 644,
- 651, 654, 657, 661, 665, 669, 674, 682, 686, 691,
- 695, 698, 702, 705, 710, 711, 712, 713, 714, 715,
- 716, 717, 718, 721, 722, 723, 726, 727, 728, 732,
- 739, 751, 757, 769, 781, 784, 790, 795, 798, 803,
- 804, 808, 824, 840, 856, 872, 883, 889, 899, 922,
- 933, 952, 958, 959, 965, 966, 977, 988, 999, 1009,
- 1019, 1029, 1032, 1033, 1036, 1037, 1040, 1043, 1046, 1054,
- 1064, 1065, 1068, 1081, 1085, 1089, 1093, 1097, 1101, 1107,
- 1108, 1112
+ 311, 312, 313, 314, 317, 323, 329, 335, 341, 347,
+ 355, 356, 359, 364, 371, 376, 377, 385, 396, 397,
+ 400, 401, 402, 403, 406, 407, 408, 409, 412, 425,
+ 441, 445, 453, 454, 455, 456, 457, 463, 466, 470,
+ 506, 535, 609, 618, 624, 625, 628, 631, 637, 641,
+ 648, 651, 654, 658, 662, 666, 671, 679, 683, 688,
+ 692, 695, 699, 702, 707, 708, 709, 710, 711, 712,
+ 713, 714, 715, 718, 719, 720, 723, 724, 725, 729,
+ 736, 748, 754, 766, 778, 781, 787, 792, 795, 800,
+ 801, 805, 821, 837, 853, 869, 880, 886, 896, 919,
+ 930, 949, 955, 956, 962, 963, 974, 985, 996, 1006,
+ 1016, 1026, 1029, 1030, 1033, 1034, 1037, 1040, 1043, 1051,
+ 1061, 1062, 1065, 1078, 1082, 1086, 1090, 1094, 1098, 1104,
+ 1105, 1109
};
#endif
switch (yyn) {
case 1:
-#line 313 "parse.y"
+#line 311 "parse.y"
{ ; ;
break;}
case 2:
-#line 314 "parse.y"
+#line 312 "parse.y"
{ ; ;
break;}
case 3:
-#line 315 "parse.y"
+#line 313 "parse.y"
{ ; ;
break;}
case 4:
-#line 316 "parse.y"
+#line 314 "parse.y"
{ ; ;
break;}
case 5:
-#line 319 "parse.y"
+#line 317 "parse.y"
{
Node *node = new_ccode(C_CCODE,(yyvsp[0].cbuf)->str,
ccode_line);
;
break;}
case 6:
-#line 325 "parse.y"
+#line 323 "parse.y"
{
Node *node = new_ccode(H_CCODE,(yyvsp[0].cbuf)->str,
ccode_line);
;
break;}
case 7:
-#line 331 "parse.y"
+#line 329 "parse.y"
{
Node *node = new_ccode(HT_CCODE,(yyvsp[0].cbuf)->str,
ccode_line);
;
break;}
case 8:
-#line 337 "parse.y"
+#line 335 "parse.y"
{
Node *node = new_ccode(PH_CCODE,(yyvsp[0].cbuf)->str,
ccode_line);
;
break;}
case 9:
-#line 343 "parse.y"
+#line 341 "parse.y"
{
Node *node = new_ccode(A_CCODE,(yyvsp[0].cbuf)->str,
ccode_line);
;
break;}
case 10:
-#line 349 "parse.y"
+#line 347 "parse.y"
{
Node *node = new_ccode(AT_CCODE,(yyvsp[0].cbuf)->str,
ccode_line);
;
break;}
case 11:
-#line 357 "parse.y"
+#line 355 "parse.y"
{ ; ;
break;}
case 12:
-#line 358 "parse.y"
+#line 356 "parse.y"
{ ; ;
break;}
case 13:
-#line 361 "parse.y"
+#line 359 "parse.y"
{
((Class *)class)->nodes = class_nodes;
class_nodes = NULL;
;
break;}
case 14:
-#line 366 "parse.y"
+#line 364 "parse.y"
{
((Class *)class)->nodes = NULL;
class_nodes = NULL;
;
break;}
case 15:
-#line 373 "parse.y"
+#line 371 "parse.y"
{
class = new_class(yyvsp[-3].id,yyvsp[-1].id,chunk_size,NULL);
;
break;}
case 17:
-#line 379 "parse.y"
+#line 377 "parse.y"
{
if(strcmp(yyvsp[-2].id,"chunks") == 0) {
chunk_size = g_strdup(yyvsp[0].id);
;
break;}
case 18:
-#line 387 "parse.y"
+#line 385 "parse.y"
{
if(strcmp(yyvsp[-2].id,"chunks") == 0) {
if(atoi(yyvsp[0].id) != 0)
;
break;}
case 19:
-#line 398 "parse.y"
+#line 396 "parse.y"
{ ; ;
break;}
case 20:
-#line 399 "parse.y"
+#line 397 "parse.y"
{ ; ;
break;}
case 21:
-#line 402 "parse.y"
+#line 400 "parse.y"
{ ; ;
break;}
case 22:
-#line 403 "parse.y"
+#line 401 "parse.y"
{ ; ;
break;}
case 23:
-#line 404 "parse.y"
+#line 402 "parse.y"
{ ; ;
break;}
case 24:
-#line 405 "parse.y"
+#line 403 "parse.y"
{ ; ;
break;}
case 25:
-#line 408 "parse.y"
+#line 406 "parse.y"
{ the_scope = PUBLIC_SCOPE; ;
break;}
case 26:
-#line 409 "parse.y"
+#line 407 "parse.y"
{ the_scope = PRIVATE_SCOPE; ;
break;}
case 27:
-#line 410 "parse.y"
+#line 408 "parse.y"
{ the_scope = PROTECTED_SCOPE; ;
break;}
case 28:
-#line 411 "parse.y"
+#line 409 "parse.y"
{ the_scope = CLASS_SCOPE; ;
break;}
case 29:
-#line 414 "parse.y"
+#line 412 "parse.y"
{
if(strcmp(yyvsp[-1].id, "destroywith")==0) {
g_free(yyvsp[-1].id);
;
break;}
case 30:
-#line 427 "parse.y"
+#line 425 "parse.y"
{
if(strcmp(yyvsp[-2].id, "destroy")==0) {
g_free(yyvsp[-2].id);
;
break;}
case 31:
-#line 443 "parse.y"
+#line 441 "parse.y"
{
initializer = yyvsp[0].id;
initializer_line = ccode_line;
;
break;}
case 32:
-#line 447 "parse.y"
+#line 445 "parse.y"
{
initializer = (yyvsp[0].cbuf)->str;
initializer_line = ccode_line;
;
break;}
case 33:
-#line 455 "parse.y"
+#line 453 "parse.y"
{ ; ;
break;}
case 34:
-#line 456 "parse.y"
+#line 454 "parse.y"
{ ; ;
break;}
case 35:
-#line 457 "parse.y"
+#line 455 "parse.y"
{ destructor = NULL; ;
break;}
case 36:
-#line 458 "parse.y"
+#line 456 "parse.y"
{ initializer = NULL; ;
break;}
case 37:
-#line 459 "parse.y"
+#line 457 "parse.y"
{
destructor = NULL;
initializer = NULL;
;
break;}
case 38:
-#line 465 "parse.y"
+#line 463 "parse.y"
{
push_variable(yyvsp[-2].id, the_scope,yyvsp[-4].line, NULL);
;
break;}
case 39:
-#line 468 "parse.y"
+#line 466 "parse.y"
{
push_variable(yyvsp[-3].id, the_scope, yyvsp[-5].line, yyvsp[-2].id);
;
break;}
case 40:
-#line 472 "parse.y"
+#line 470 "parse.y"
{
if(strcmp(yyvsp[-6].id,"get")==0 &&
strcmp(yyvsp[-3].id,"set")==0) {
;
break;}
case 41:
-#line 508 "parse.y"
+#line 506 "parse.y"
{
if(strcmp(yyvsp[-3].id, "get") == 0) {
Node *node;
;
break;}
case 42:
-#line 537 "parse.y"
+#line 535 "parse.y"
{
Node *node;
char *get, *set = NULL;
else if(var->scope == CLASS_SCOPE) {
root = "SELF_GET_CLASS(self)";
if(no_self_alias)
- print_error(FALSE,
- _("Self aliases needed when autolinking to a classwide member"),
- yyvsp[-4].line);
+ error_print(GOB_ERROR, yyvsp[-4].line,
+ _("Self aliases needed when autolinking to a classwide member"));
} else
root = "self";
;
break;}
case 43:
-#line 612 "parse.y"
+#line 609 "parse.y"
{
if(strcmp(yyvsp[-2].id,"type")!=0) {
g_free(yyvsp[-4].id);
;
break;}
case 44:
-#line 621 "parse.y"
+#line 618 "parse.y"
{
yyval.id = yyvsp[0].id;
typestack = g_list_prepend(typestack,NULL);
;
break;}
case 45:
-#line 627 "parse.y"
+#line 624 "parse.y"
{ yyval.list = yyvsp[-1].list; ;
break;}
case 46:
-#line 628 "parse.y"
+#line 625 "parse.y"
{ yyval.list = NULL; ;
break;}
case 47:
-#line 631 "parse.y"
+#line 628 "parse.y"
{
yyval.list = g_list_append(yyvsp[0].list,yyvsp[-2].id);
;
break;}
case 48:
-#line 634 "parse.y"
+#line 631 "parse.y"
{
yyval.list = g_list_append(NULL,yyvsp[0].id);
;
break;}
case 49:
-#line 640 "parse.y"
+#line 637 "parse.y"
{
Node *node = new_type(yyvsp[-1].id, yyvsp[0].id, NULL);
typestack = g_list_prepend(typestack,node);
;
break;}
case 50:
-#line 644 "parse.y"
+#line 641 "parse.y"
{
Node *node = new_type(yyvsp[0].id, NULL, NULL);
typestack = g_list_prepend(typestack,node);
;
break;}
case 51:
-#line 651 "parse.y"
+#line 648 "parse.y"
{
yyval.id = yyvsp[0].id;
;
break;}
case 52:
-#line 654 "parse.y"
+#line 651 "parse.y"
{
yyval.id = yyvsp[0].id;
;
break;}
case 53:
-#line 657 "parse.y"
+#line 654 "parse.y"
{
yyval.id = g_strconcat("const ", yyvsp[0].id, NULL);
g_free(yyvsp[0].id);
;
break;}
case 54:
-#line 661 "parse.y"
+#line 658 "parse.y"
{
yyval.id = g_strconcat(yyvsp[-1].id, " const", NULL);
g_free(yyvsp[-1].id);
;
break;}
case 55:
-#line 665 "parse.y"
+#line 662 "parse.y"
{
yyval.id = g_strconcat(yyvsp[-1].id, " ", yyvsp[0].id, NULL);
g_free(yyvsp[0].id);
;
break;}
case 56:
-#line 669 "parse.y"
+#line 666 "parse.y"
{
yyval.id = g_strconcat("const ", yyvsp[-1].id, " ",
yyvsp[0].id, NULL);
;
break;}
case 57:
-#line 674 "parse.y"
+#line 671 "parse.y"
{
yyval.id = g_strconcat(yyvsp[-2].id, " ",
yyvsp[-1].id, " const", NULL);
;
break;}
case 58:
-#line 682 "parse.y"
+#line 679 "parse.y"
{
yyval.id = g_strconcat(yyvsp[-1].id, " ", yyvsp[0].id, NULL);
g_free(yyvsp[0].id);
;
break;}
case 59:
-#line 686 "parse.y"
+#line 683 "parse.y"
{
yyval.id = g_strconcat(yyvsp[-1].id, " ", yyvsp[0].id, NULL);
g_free(yyvsp[-1].id);
;
break;}
case 60:
-#line 691 "parse.y"
+#line 688 "parse.y"
{
yyval.id = g_strconcat("const ", yyvsp[0].id, NULL);
g_free(yyvsp[0].id);
;
break;}
case 61:
-#line 695 "parse.y"
+#line 692 "parse.y"
{
yyval.id = yyvsp[0].id;
;
break;}
case 62:
-#line 698 "parse.y"
+#line 695 "parse.y"
{
yyval.id = g_strconcat(yyvsp[-1].id, " const", NULL);
g_free(yyvsp[-1].id);
;
break;}
case 63:
-#line 702 "parse.y"
+#line 699 "parse.y"
{
yyval.id = g_strdup(yyvsp[0].id);
;
break;}
case 64:
-#line 705 "parse.y"
+#line 702 "parse.y"
{
yyval.id = g_strconcat(yyvsp[-1].id, " const", NULL);
;
break;}
case 65:
-#line 710 "parse.y"
+#line 707 "parse.y"
{ yyval.id = "void"; ;
break;}
case 66:
-#line 711 "parse.y"
+#line 708 "parse.y"
{ yyval.id = "char"; ;
break;}
case 67:
-#line 712 "parse.y"
+#line 709 "parse.y"
{ yyval.id = "short"; ;
break;}
case 68:
-#line 713 "parse.y"
+#line 710 "parse.y"
{ yyval.id = "int"; ;
break;}
case 69:
-#line 714 "parse.y"
+#line 711 "parse.y"
{ yyval.id = "long"; ;
break;}
case 70:
-#line 715 "parse.y"
+#line 712 "parse.y"
{ yyval.id = "float"; ;
break;}
case 71:
-#line 716 "parse.y"
+#line 713 "parse.y"
{ yyval.id = "double"; ;
break;}
case 72:
-#line 717 "parse.y"
+#line 714 "parse.y"
{ yyval.id = "signed"; ;
break;}
case 73:
-#line 718 "parse.y"
+#line 715 "parse.y"
{ yyval.id = "unsigned"; ;
break;}
case 74:
-#line 721 "parse.y"
+#line 718 "parse.y"
{ yyval.id = "struct"; ;
break;}
case 75:
-#line 722 "parse.y"
+#line 719 "parse.y"
{ yyval.id = "union"; ;
break;}
case 76:
-#line 723 "parse.y"
+#line 720 "parse.y"
{ yyval.id = "enum"; ;
break;}
case 77:
-#line 726 "parse.y"
+#line 723 "parse.y"
{ yyval.id = g_strdup("*"); ;
break;}
case 78:
-#line 727 "parse.y"
+#line 724 "parse.y"
{ yyval.id = g_strdup("* const"); ;
break;}
case 79:
-#line 728 "parse.y"
+#line 725 "parse.y"
{
yyval.id = g_strconcat("*", yyvsp[0].id, NULL);
g_free(yyvsp[0].id);
;
break;}
case 80:
-#line 732 "parse.y"
+#line 729 "parse.y"
{
yyval.id = g_strconcat("* const", yyvsp[0].id, NULL);
g_free(yyvsp[0].id);
;
break;}
case 81:
-#line 739 "parse.y"
+#line 736 "parse.y"
{
if(strcmp(yyvsp[-1].id, "first")==0)
yyval.sigtype = SIGNAL_FIRST_METHOD;
;
break;}
case 82:
-#line 751 "parse.y"
+#line 748 "parse.y"
{
yyval.sigtype = SIGNAL_LAST_METHOD;
;
break;}
case 83:
-#line 757 "parse.y"
+#line 754 "parse.y"
{
if(strcmp(yyvsp[-1].id,"first")==0)
yyval.sigtype = SIGNAL_FIRST_METHOD;
;
break;}
case 84:
-#line 769 "parse.y"
+#line 766 "parse.y"
{
if(strcmp(yyvsp[-2].id,"first")==0)
yyval.sigtype = SIGNAL_FIRST_METHOD;
;
break;}
case 85:
-#line 781 "parse.y"
+#line 778 "parse.y"
{
yyval.sigtype = SIGNAL_LAST_METHOD;
;
break;}
case 86:
-#line 784 "parse.y"
+#line 781 "parse.y"
{
/* the_scope was default thus public */
the_scope = PUBLIC_SCOPE;
;
break;}
case 87:
-#line 790 "parse.y"
+#line 787 "parse.y"
{
gtktypes = g_list_prepend(gtktypes, yyvsp[-3].id);
;
break;}
case 88:
-#line 795 "parse.y"
+#line 792 "parse.y"
{
gtktypes = g_list_append(gtktypes, yyvsp[0].id);
;
break;}
case 89:
-#line 798 "parse.y"
+#line 795 "parse.y"
{
gtktypes = g_list_append(gtktypes, yyvsp[0].id);
;
break;}
case 90:
-#line 803 "parse.y"
+#line 800 "parse.y"
{ yyval.cbuf = yyvsp[0].cbuf; ;
break;}
case 91:
-#line 804 "parse.y"
+#line 801 "parse.y"
{ yyval.cbuf = NULL; ;
break;}
case 92:
-#line 808 "parse.y"
+#line 805 "parse.y"
{
if(!has_self) {
yyerror(_("signal without 'self' as "
;
break;}
case 93:
-#line 824 "parse.y"
+#line 821 "parse.y"
{
if(!has_self) {
yyerror(_("signal without 'self' as "
;
break;}
case 94:
-#line 840 "parse.y"
+#line 837 "parse.y"
{
if(!has_self) {
yyerror(_("virtual method without 'self' as "
;
break;}
case 95:
-#line 856 "parse.y"
+#line 853 "parse.y"
{
if(!has_self) {
yyerror(_("virtual method without 'self' as "
;
break;}
case 96:
-#line 872 "parse.y"
+#line 869 "parse.y"
{
if(!has_self) {
yyerror(_("virtual method without 'self' as "
;
break;}
case 97:
-#line 883 "parse.y"
+#line 880 "parse.y"
{
push_function(NO_SCOPE, OVERRIDE_METHOD, yyvsp[-8].id,
yyvsp[-5].id, yyvsp[0].cbuf,
;
break;}
case 98:
-#line 889 "parse.y"
+#line 886 "parse.y"
{
if(the_scope == CLASS_SCOPE) {
yyerror(_("a method cannot be of class scope"));
;
break;}
case 99:
-#line 899 "parse.y"
+#line 896 "parse.y"
{
if(strcmp(yyvsp[-4].id, "init")==0) {
push_init_arg(yyvsp[-2].id,FALSE);
;
break;}
case 100:
-#line 922 "parse.y"
+#line 919 "parse.y"
{
g_free(onerror); onerror = NULL;
g_free(defreturn); defreturn = NULL;
;
break;}
case 101:
-#line 933 "parse.y"
+#line 930 "parse.y"
{
g_free(onerror); onerror = NULL;
g_free(defreturn); defreturn = NULL;
;
break;}
case 102:
-#line 952 "parse.y"
+#line 949 "parse.y"
{
g_free(onerror); onerror = NULL;
g_free(defreturn); defreturn = NULL;
;
break;}
case 103:
-#line 958 "parse.y"
+#line 955 "parse.y"
{ yyval.id = yyvsp[0].id; ;
break;}
case 104:
-#line 959 "parse.y"
+#line 956 "parse.y"
{
yyval.id = (yyvsp[1].cbuf)->str;
g_string_free(yyvsp[1].cbuf, FALSE);
;
break;}
case 105:
-#line 965 "parse.y"
+#line 962 "parse.y"
{ vararg = FALSE; has_self = FALSE; ;
break;}
case 106:
-#line 966 "parse.y"
+#line 963 "parse.y"
{
vararg = FALSE;
has_self = TRUE;
;
break;}
case 107:
-#line 977 "parse.y"
+#line 974 "parse.y"
{
vararg = FALSE;
has_self = TRUE;
;
break;}
case 108:
-#line 988 "parse.y"
+#line 985 "parse.y"
{
vararg = FALSE;
has_self = TRUE;
;
break;}
case 109:
-#line 999 "parse.y"
+#line 996 "parse.y"
{
has_self = TRUE;
if(strcmp(yyvsp[-2].id,"self")==0)
;
break;}
case 110:
-#line 1009 "parse.y"
+#line 1006 "parse.y"
{
has_self = TRUE;
if(strcmp(yyvsp[-3].id,"self")==0)
;
break;}
case 111:
-#line 1019 "parse.y"
+#line 1016 "parse.y"
{
has_self = TRUE;
if(strcmp(yyvsp[-2].id,"self")==0)
;
break;}
case 112:
-#line 1029 "parse.y"
+#line 1026 "parse.y"
{ has_self = FALSE; ;
break;}
case 113:
-#line 1032 "parse.y"
+#line 1029 "parse.y"
{ vararg = TRUE; ;
break;}
case 114:
-#line 1033 "parse.y"
+#line 1030 "parse.y"
{ vararg = FALSE; ;
break;}
case 115:
-#line 1036 "parse.y"
+#line 1033 "parse.y"
{ ; ;
break;}
case 116:
-#line 1037 "parse.y"
+#line 1034 "parse.y"
{ ; ;
break;}
case 117:
-#line 1040 "parse.y"
+#line 1037 "parse.y"
{
push_funcarg(yyvsp[0].id,NULL);
;
break;}
case 118:
-#line 1043 "parse.y"
+#line 1040 "parse.y"
{
push_funcarg(yyvsp[-1].id,yyvsp[0].id);
;
break;}
case 119:
-#line 1046 "parse.y"
+#line 1043 "parse.y"
{
if(strcmp(yyvsp[-2].id,"check")!=0) {
yyerror(_("parse error"));
;
break;}
case 120:
-#line 1054 "parse.y"
+#line 1051 "parse.y"
{
if(strcmp(yyvsp[-2].id,"check")!=0) {
yyerror(_("parse error"));
;
break;}
case 121:
-#line 1064 "parse.y"
+#line 1061 "parse.y"
{ ; ;
break;}
case 122:
-#line 1065 "parse.y"
+#line 1062 "parse.y"
{ ; ;
break;}
case 123:
-#line 1068 "parse.y"
+#line 1065 "parse.y"
{
if(strcmp(yyvsp[0].id,"type")==0) {
Node *node = new_check(TYPE_CHECK,NULL);
;
break;}
case 124:
-#line 1081 "parse.y"
+#line 1078 "parse.y"
{
Node *node = new_check(GT_CHECK,yyvsp[0].id);
checks = g_list_append(checks,node);
;
break;}
case 125:
-#line 1085 "parse.y"
+#line 1082 "parse.y"
{
Node *node = new_check(LT_CHECK,yyvsp[0].id);
checks = g_list_append(checks,node);
;
break;}
case 126:
-#line 1089 "parse.y"
+#line 1086 "parse.y"
{
Node *node = new_check(GE_CHECK,yyvsp[0].id);
checks = g_list_append(checks,node);
;
break;}
case 127:
-#line 1093 "parse.y"
+#line 1090 "parse.y"
{
Node *node = new_check(LE_CHECK,yyvsp[0].id);
checks = g_list_append(checks,node);
;
break;}
case 128:
-#line 1097 "parse.y"
+#line 1094 "parse.y"
{
Node *node = new_check(EQ_CHECK,yyvsp[0].id);
checks = g_list_append(checks,node);
;
break;}
case 129:
-#line 1101 "parse.y"
+#line 1098 "parse.y"
{
Node *node = new_check(NE_CHECK,yyvsp[0].id);
checks = g_list_append(checks,node);
;
break;}
case 130:
-#line 1107 "parse.y"
+#line 1104 "parse.y"
{ yyval.id = yyvsp[0].id; ;
break;}
case 131:
-#line 1108 "parse.y"
+#line 1105 "parse.y"
{
yyval.id = g_strconcat("-",yyvsp[0].id,NULL);
g_free(yyvsp[0].id);
;
break;}
case 132:
-#line 1112 "parse.y"
+#line 1109 "parse.y"
{ yyval.id = yyvsp[0].id; ;
break;}
}
}
return 1;
}
-#line 1115 "parse.y"
+#line 1112 "parse.y"
!(g_list_length(funcargs) == 1 &&
g_list_length(gtktypes) == 2 &&
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);
+ error_print(GOB_WARN, line_no,
+ _("The number of GTK arguments and "
+ "function arguments for a signal "
+ "don't seem to match"));
}
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,
+ error_print(GOB_ERROR, line_no,
_("NONE can only appear in an "
- "argument list by itself"),
- line_no);
+ "argument list by itself"));
}
}
}
find_var_or_die(const char *id, int line)
{
GList *li;
- char *s;
for(li = class_nodes; li != NULL; li = li->next) {
Variable *var;
return var;
}
- s = g_strdup_printf(_("Variable %s not defined here"), id);
- print_error(FALSE, s, line);
+ error_printf(GOB_ERROR, line, _("Variable %s not defined here"), id);
g_assert_not_reached();
return NULL;
else if(var->scope == CLASS_SCOPE) {
root = "SELF_GET_CLASS(self)";
if(no_self_alias)
- print_error(FALSE,
- _("Self aliases needed when autolinking to a classwide member"),
- $<line>1);
+ error_print(GOB_ERROR, $<line>1,
+ _("Self aliases needed when autolinking to a classwide member"));
} else
root = "self";
requires 0.93.0
+%at{
+/* ALL TOP */
+%}
+
%headertop{
/* this should go on the very top of the header */
#include "util.h"
void
-print_error(gboolean is_warn, char *error, int line)
+error_print(int type, int line, const char *error)
{
- char *w;
- if(is_warn)
+ char *w = NULL;
+
+ switch(type) {
+ case GOB_WARN:
w = "Warning:";
- else {
+ break;
+ case GOB_ERROR:
w = "Error:";
got_error = TRUE;
+ break;
+ default:
+ g_assert_not_reached();
}
- if(line>0)
+ if(line > 0)
fprintf(stderr, "%s:%d: %s %s\n", filename, line, w, error);
else
fprintf(stderr, "%s: %s %s\n", filename, w, error);
- if((!is_warn || exit_on_warn) && exit_on_error)
+ if(exit_on_error &&
+ (type == GOB_ERROR ||
+ (type == GOB_WARN && exit_on_warn)))
exit(1);
}
+void
+error_printf(int type, int line, const char *error, ...)
+{
+ va_list ap;
+ char *s;
+
+ va_start(ap, error);
+ s = g_strdup_vprintf(error, ap);
+ va_end(ap);
+
+ error_print(type, line, s);
+
+ g_free(s);
+}
+
char *
remove_sep(char *base)
{
char *p;
char *s = g_strdup(base);
while((p = strchr(s, ':')))
- strcpy(p,p+1);
+ strcpy(p, p+1);
return s;
}
#ifndef _UTIL_H_
#define _UTIL_H_
-/* print an error, or warning (if 'is_warn') referring to 'line' */
-void print_error(gboolean is_warn, char *error, int line);
+enum {
+ GOB_WARN,
+ GOB_ERROR
+};
+
+/* print an error, or warning referring to 'line'
+ * (line can be 0 or negative for no line) */
+void error_print(int type, int line, const char *error);
+void error_printf(int type, int line, const char *error, ...) G_GNUC_PRINTF (3, 4);
/* remove the : separator from a typename */
char * remove_sep(char *base);