[PATCH wayland 1/8] scanner: use c99 initializers for the wl_interface * array
Emil Velikov
emil.l.velikov at gmail.com
Thu Jun 14 15:49:38 UTC 2018
From: Emil Velikov <emil.velikov at collabora.com>
Makes it a bit more obvious, should you be reading through the generated
code.
We might even drop the NULL entries (at a later stage) making things
shorter and easier to read.
v2: don't alter the array size by discarding trailing NULL entries
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
src/scanner.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/scanner.c b/src/scanner.c
index 205c28a..4b49593 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1620,7 +1620,7 @@ emit_null_run(struct protocol *protocol)
int i;
for (i = 0; i < protocol->null_run_length; i++)
- printf("\tNULL,\n");
+ printf("\t[%d] = NULL,\n", i);
}
static void
@@ -1628,6 +1628,7 @@ emit_types(struct protocol *protocol, struct wl_list *message_list)
{
struct message *m;
struct arg *a;
+ int index;
wl_list_for_each(m, message_list, link) {
if (m->all_null) {
@@ -1638,21 +1639,23 @@ emit_types(struct protocol *protocol, struct wl_list *message_list)
m->type_index =
protocol->null_run_length + protocol->type_index;
protocol->type_index += m->arg_count;
+ index = m->type_index;
wl_list_for_each(a, &m->arg_list, link) {
switch (a->type) {
case NEW_ID:
case OBJECT:
if (a->interface_name)
- printf("\t&%s_interface,\n",
- a->interface_name);
+ printf("\t[%d] = &%s_interface,\n",
+ index, a->interface_name);
else
- printf("\tNULL,\n");
+ printf("\t[%d] = NULL,\n", index);
break;
default:
- printf("\tNULL,\n");
+ printf("\t[%d] = NULL,\n", index);
break;
}
+ index++;
}
}
}
--
2.16.0
More information about the wayland-devel
mailing list