mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-31 22:25:25 -04:00
scanner: Add location to elements so we can give better errors/warnings
This commit is contained in:
parent
5a4dd76495
commit
a71cf48ce0
1 changed files with 25 additions and 7 deletions
|
|
@ -64,6 +64,7 @@ struct protocol {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct interface {
|
struct interface {
|
||||||
|
struct location loc;
|
||||||
char *name;
|
char *name;
|
||||||
char *uppercase_name;
|
char *uppercase_name;
|
||||||
int version;
|
int version;
|
||||||
|
|
@ -76,6 +77,7 @@ struct interface {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct message {
|
struct message {
|
||||||
|
struct location loc;
|
||||||
char *name;
|
char *name;
|
||||||
char *uppercase_name;
|
char *uppercase_name;
|
||||||
struct wl_list arg_list;
|
struct wl_list arg_list;
|
||||||
|
|
@ -268,6 +270,19 @@ fail(struct location *loc, const char *msg, ...)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
warn(struct location *loc, const char *msg, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, msg);
|
||||||
|
fprintf(stderr, "%s:%d: warning: ",
|
||||||
|
loc->filename, loc->line_number);
|
||||||
|
vfprintf(stderr, msg, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
is_nullable_type(struct arg *arg)
|
is_nullable_type(struct arg *arg)
|
||||||
{
|
{
|
||||||
|
|
@ -345,6 +360,7 @@ start_element(void *data, const char *element_name, const char **atts)
|
||||||
fail(&ctx->loc, "no interface version given");
|
fail(&ctx->loc, "no interface version given");
|
||||||
|
|
||||||
interface = xmalloc(sizeof *interface);
|
interface = xmalloc(sizeof *interface);
|
||||||
|
interface->loc = ctx->loc;
|
||||||
interface->name = xstrdup(name);
|
interface->name = xstrdup(name);
|
||||||
interface->uppercase_name = uppercase_dup(name);
|
interface->uppercase_name = uppercase_dup(name);
|
||||||
interface->version = version;
|
interface->version = version;
|
||||||
|
|
@ -362,6 +378,7 @@ start_element(void *data, const char *element_name, const char **atts)
|
||||||
fail(&ctx->loc, "no request name given");
|
fail(&ctx->loc, "no request name given");
|
||||||
|
|
||||||
message = xmalloc(sizeof *message);
|
message = xmalloc(sizeof *message);
|
||||||
|
message->loc = ctx->loc;
|
||||||
message->name = xstrdup(name);
|
message->name = xstrdup(name);
|
||||||
message->uppercase_name = uppercase_dup(name);
|
message->uppercase_name = uppercase_dup(name);
|
||||||
wl_list_init(&message->arg_list);
|
wl_list_init(&message->arg_list);
|
||||||
|
|
@ -619,9 +636,10 @@ emit_stubs(struct wl_list *message_list, struct interface *interface)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!has_destructor && has_destroy) {
|
if (!has_destructor && has_destroy) {
|
||||||
fprintf(stderr,
|
fail(&interface->loc,
|
||||||
"interface %s has method named destroy but"
|
"interface '%s' has method named destroy "
|
||||||
"no destructor", interface->name);
|
"but no destructor",
|
||||||
|
interface->name);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -640,10 +658,10 @@ emit_stubs(struct wl_list *message_list, struct interface *interface)
|
||||||
|
|
||||||
wl_list_for_each(m, message_list, link) {
|
wl_list_for_each(m, message_list, link) {
|
||||||
if (m->new_id_count > 1) {
|
if (m->new_id_count > 1) {
|
||||||
fprintf(stderr,
|
warn(&m->loc,
|
||||||
"warning: %s::%s has more than "
|
"request '%s::%s' has more than "
|
||||||
"one new_id arg, not emitting stub\n",
|
"one new_id arg, not emitting stub\n",
|
||||||
interface->name, m->name);
|
interface->name, m->name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue