From: Emil Velikov <emil.veli...@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.veli...@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

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to