scanner: Warn about requests with more than one new-id and don't generate stubs

The generated code only support one new-id per request, since the stubs
return the new proxy.  It's still possible to send requests with multiple
new-id arguments, but it must be done with
wl_proxy_marshal_array_constructor().
This commit is contained in:
Kristian Høgsberg 2013-11-15 13:26:03 -08:00
parent b583b54560
commit 3470fa17b5

View file

@ -76,6 +76,7 @@ struct message {
struct wl_list arg_list; struct wl_list arg_list;
struct wl_list link; struct wl_list link;
int arg_count; int arg_count;
int new_id_count;
int type_index; int type_index;
int all_null; int all_null;
int destructor; int destructor;
@ -353,6 +354,7 @@ start_element(void *data, const char *element_name, const char **atts)
message->uppercase_name = uppercase_dup(name); message->uppercase_name = uppercase_dup(name);
wl_list_init(&message->arg_list); wl_list_init(&message->arg_list);
message->arg_count = 0; message->arg_count = 0;
message->new_id_count = 0;
message->description = NULL; message->description = NULL;
if (strcmp(element_name, "request") == 0) if (strcmp(element_name, "request") == 0)
@ -411,6 +413,10 @@ start_element(void *data, const char *element_name, const char **atts)
switch (arg->type) { switch (arg->type) {
case NEW_ID: case NEW_ID:
ctx->message->new_id_count++;
/* Fall through to OBJECT case. */
case OBJECT: case OBJECT:
if (interface_name) if (interface_name)
arg->interface_name = xstrdup(interface_name); arg->interface_name = xstrdup(interface_name);
@ -620,6 +626,14 @@ emit_stubs(struct wl_list *message_list, struct interface *interface)
return; return;
wl_list_for_each(m, message_list, link) { wl_list_for_each(m, message_list, link) {
if (m->new_id_count > 1) {
fprintf(stderr,
"warning: %s::%s has more than "
"one new_id arg, not emitting stub\n",
interface->name, m->name);
continue;
}
ret = NULL; ret = NULL;
wl_list_for_each(a, &m->arg_list, link) { wl_list_for_each(a, &m->arg_list, link) {
if (a->type == NEW_ID) if (a->type == NEW_ID)