[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

wayland: Changes to 'upstream-ubuntu'



 protocol/screenshooter.xml |    7 -
 protocol/wayland.xml       |   36 +++++++-
 wayland/Makefile.am        |    4 
 wayland/connection.c       |   20 +++-
 wayland/connection.h       |    2 
 wayland/scanner.c          |  199 +++++++++++++++++++++++++++++++++++++--------
 wayland/wayland-client.c   |   14 ++-
 wayland/wayland-server.c   |   11 +-
 wayland/wayland-util.h     |    2 
 9 files changed, 231 insertions(+), 64 deletions(-)

New commits:
commit eb13ae17b41dea24000e8ff78b762b20c1fdf23b
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Wed Jul 27 05:50:41 2011 -0700

    scanner: Initialize protocol.copyright to NULL

diff --git a/wayland/scanner.c b/wayland/scanner.c
index 9248edb..dff63de 100644
--- a/wayland/scanner.c
+++ b/wayland/scanner.c
@@ -824,6 +824,7 @@ int main(int argc, char *argv[])
 	wl_list_init(&protocol.interface_list);
 	protocol.type_index = 0;
 	protocol.null_run_length = 0;
+	protocol.copyright = NULL;
 	ctx.protocol = &protocol;
 
 	ctx.filename = "<stdin>";

commit 7a291117e7ff1c8f817242b9b223e600a0a9e3c8
Author: Tiago Vignatti <tiago.vignatti@intel.com>
Date:   Tue Jul 26 11:43:19 2011 +0300

    protocol: Delete screenshooter.xml
    
    The protocol interface is on compositor's side now.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>

diff --git a/protocol/screenshooter.xml b/protocol/screenshooter.xml
deleted file mode 100644
index f8d993d..0000000
--- a/protocol/screenshooter.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<protocol name="screenshooter">
-
-  <interface name="screenshooter" version="1">
-    <request name="shoot"/>
-  </interface>
-
-</protocol>

commit 986703ac7365bc87a5501714adb9fc73157c62b7
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Mon Jul 25 18:14:20 2011 -0700

    scanner: Take copyright notice from xml file

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 79bb3ea..92377c4 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -1,6 +1,32 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <protocol name="wayland">
 
+  <copyright>
+    Copyright © 2008-2011 Kristian Høgsberg
+    Copyright © 2010-2011 Intel Corporation
+
+    Permission to use, copy, modify, distribute, and sell this
+    software and its documentation for any purpose is hereby granted
+    without fee, provided that\n the above copyright notice appear in
+    all copies and that both that copyright notice and this permission
+    notice appear in supporting documentation, and that the name of
+    the copyright holders not be used in advertising or publicity
+    pertaining to distribution of the software without specific,
+    written prior permission.  The copyright holders make no
+    representations about the suitability of this software for any
+    purpose.  It is provided "as is" without express or implied
+    warranty.
+
+    THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+    FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+    SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+    THIS SOFTWARE.
+  </copyright>
+
   <!-- The core global object. This is a special singleton object.
        It is used for internal wayland protocol features. -->
   <interface name="wl_display" version="1">
diff --git a/wayland/scanner.c b/wayland/scanner.c
index 300e39d..9248edb 100644
--- a/wayland/scanner.c
+++ b/wayland/scanner.c
@@ -24,29 +24,6 @@
 
 #include "wayland-util.h"
 
-static const char copyright[] =
-	"/*\n"
-	" * Copyright © 2010 Kristian Høgsberg\n"
-	" *\n"
-	" * Permission to use, copy, modify, distribute, and sell this software and its\n"
-	" * documentation for any purpose is hereby granted without fee, provided that\n"
-	" * the above copyright notice appear in all copies and that both that copyright\n"
-	" * notice and this permission notice appear in supporting documentation, and\n"
-	" * that the name of the copyright holders not be used in advertising or\n"
-	" * publicity pertaining to distribution of the software without specific,\n"
-	" * written prior permission.  The copyright holders make no representations\n"
-	" * about the suitability of this software for any purpose.  It is provided \"as\n"
-	" * is\" without express or implied warranty.\n"
-	" *\n"
-	" * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\n"
-	" * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO\n"
-	" * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR\n"
-	" * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,\n"
-	" * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER\n"
-	" * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE\n"
-	" * OF THIS SOFTWARE.\n"
-	" */\n";
-
 static int
 usage(int ret)
 {
@@ -62,6 +39,7 @@ struct protocol {
 	struct wl_list interface_list;
 	int type_index;
 	int null_run_length;
+	char *copyright;
 };
 
 struct interface {
@@ -123,6 +101,8 @@ struct parse_context {
 	struct interface *interface;
 	struct message *message;
 	struct enumeration *enumeration;
+	char character_data[8192];
+	int character_data_length;
 };
 
 static char *
@@ -177,12 +157,15 @@ start_element(void *data, const char *element_name, const char **atts)
 			interface_name = atts[i + 1];
 	}
 
+	ctx->character_data_length = 0;
 	if (strcmp(element_name, "protocol") == 0) {
 		if (name == NULL)
 			fail(ctx, "no protocol name given");
 
 		ctx->protocol->name = strdup(name);
 		ctx->protocol->uppercase_name = uppercase_dup(name);
+	} else if (strcmp(element_name, "copyright") == 0) {
+		
 	} else if (strcmp(element_name, "interface") == 0) {
 		if (name == NULL)
 			fail(ctx, "no interface name given");
@@ -281,6 +264,32 @@ start_element(void *data, const char *element_name, const char **atts)
 }
 
 static void
+end_element(void *data, const XML_Char *name)
+{
+	struct parse_context *ctx = data;
+
+	if (strcmp(name, "copyright") == 0) {
+		ctx->protocol->copyright =
+			strndup(ctx->character_data,
+				ctx->character_data_length);
+	}
+}
+
+static void
+character_data(void *data, const XML_Char *s, int len)
+{
+	struct parse_context *ctx = data;
+
+	if (ctx->character_data_length + len > sizeof (ctx->character_data)) {
+		fprintf(stderr, "too much character data");
+		exit(EXIT_FAILURE);
+	    }
+
+	memcpy(ctx->character_data + ctx->character_data_length, s, len);
+	ctx->character_data_length += len;
+}
+
+static void
 emit_opcodes(struct wl_list *message_list, struct interface *interface)
 {
 	struct message *m;
@@ -550,6 +559,28 @@ emit_structs(struct wl_list *message_list, struct interface *interface)
 	}
 }
 
+static void
+format_copyright(const char *copyright)
+{
+	int bol = 1, start, i;
+
+	for (i = 0; copyright[i]; i++) {
+		if (bol && (copyright[i] == ' ' || copyright[i] == '\t')) {
+			continue;
+		} else if (bol) {
+			bol = 0;
+			start = i;
+		}
+
+		if (copyright[i] == '\n' || copyright[i] == '\0') {
+			printf("%s %.*s\n",
+			       i == 0 ? "/*" : " *",
+			       i - start, copyright + start);
+			bol = 1;
+		}
+	}
+	printf(" */\n\n");
+}
 
 static void
 emit_header(struct protocol *protocol, int server)
@@ -557,8 +588,10 @@ emit_header(struct protocol *protocol, int server)
 	struct interface *i;
 	const char *s = server ? "SERVER" : "CLIENT";
 
-	printf("%s\n\n"
-	       "#ifndef %s_%s_PROTOCOL_H\n"
+	if (protocol->copyright)
+		format_copyright(protocol->copyright);
+
+	printf("#ifndef %s_%s_PROTOCOL_H\n"
 	       "#define %s_%s_PROTOCOL_H\n"
 	       "\n"
 	       "#ifdef  __cplusplus\n"
@@ -569,7 +602,6 @@ emit_header(struct protocol *protocol, int server)
 	       "#include <stddef.h>\n"
 	       "#include \"wayland-util.h\"\n\n"
 	       "struct wl_client;\n\n",
-	       copyright,
 	       protocol->uppercase_name, s,
 	       protocol->uppercase_name, s);
 
@@ -732,11 +764,12 @@ emit_code(struct protocol *protocol)
 {
 	struct interface *i;
 
-	printf("%s\n\n"
-	       "#include <stdlib.h>\n"
+	if (protocol->copyright)
+		format_copyright(protocol->copyright);
+
+	printf("#include <stdlib.h>\n"
 	       "#include <stdint.h>\n"
-	       "#include \"wayland-util.h\"\n\n",
-	       copyright);
+	       "#include \"wayland-util.h\"\n\n");
 
 	wl_list_for_each(i, &protocol->interface_list, link) {
 		emit_types_forward_declarations(protocol, &i->request_list);
@@ -801,7 +834,9 @@ int main(int argc, char *argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	XML_SetElementHandler(ctx.parser, start_element, NULL);
+	XML_SetElementHandler(ctx.parser, start_element, end_element);
+	XML_SetCharacterDataHandler(ctx.parser, character_data);
+
 	do {
 		buf = XML_GetBuffer(ctx.parser, XML_BUFFER_SIZE);
 		len = fread(buf, 1, XML_BUFFER_SIZE, stdin);

commit 64732b01e4e9720eaef181c631d94a509a73dc65
Author: Kristian Høgsberg <krh@localhost.localdomain>
Date:   Tue Jul 19 10:01:46 2011 -0700

    connection: Use static strings instead of sprintf and buffer overflow
    
    Spotted by Samuel Rødal <samuel.rodal@nokia.com>

diff --git a/wayland/connection.c b/wayland/connection.c
index af9a90e..467a2d0 100644
--- a/wayland/connection.c
+++ b/wayland/connection.c
@@ -692,20 +692,16 @@ void
 wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send)
 {
 	union wl_value *value;
-	char buffer[4] = "\0";
 	int i;
 	struct timespec tp;
 	unsigned int time;
 
-	if (send)
-		sprintf(buffer, " -> ");
-
 	clock_gettime(CLOCK_REALTIME, &tp);
 	time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
 
 	fprintf(stderr, "[%10.3f] %s%s@%d.%s(",
 		time / 1000.0,
-		buffer,
+		send ? " -> " : "",
 		target->interface->name, target->id,
 		closure->message->name);
 

commit f9b3c151459c1627ea971d6539f706e868b89ef4
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Mon Jul 18 13:35:18 2011 -0400

    Link to -lrt for clock_gettime()

diff --git a/wayland/Makefile.am b/wayland/Makefile.am
index fd79eb3..8a73cd3 100644
--- a/wayland/Makefile.am
+++ b/wayland/Makefile.am
@@ -16,14 +16,14 @@ libwayland_util_la_SOURCES =			\
 	wayland-util.h				\
 	wayland-hash.c
 
-libwayland_server_la_LIBADD = $(FFI_LIBS) libwayland-util.la
+libwayland_server_la_LIBADD = $(FFI_LIBS) libwayland-util.la -lrt
 libwayland_server_la_SOURCES =			\
 	wayland-protocol.c			\
 	wayland-server.c			\
 	wayland-shm.c				\
 	event-loop.c
 
-libwayland_client_la_LIBADD = $(FFI_LIBS) libwayland-util.la
+libwayland_client_la_LIBADD = $(FFI_LIBS) libwayland-util.la -lrt
 libwayland_client_la_SOURCES =			\
 	wayland-protocol.c			\
 	wayland-client.c

commit c86ba825c474bbbd9e95bcdbc2b8b577d24322fe
Author: Casey Dahlin <cdahlin@redhat.com>
Date:   Mon Jul 18 02:00:25 2011 -0400

    Pass object ID not pointer when sending a global announce event
    
    When the type for the first argument of the global event changed from new_id to
    uint, wl_connection_vmarshal started expecting an integer argument rather than
    an object argument. As a result we were sending the client a chunk of pointer
    rather than a useful global identifier.

diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
index d4fdfc7..2019cb4 100644
--- a/wayland/wayland-server.c
+++ b/wayland/wayland-server.c
@@ -313,7 +313,7 @@ wl_client_post_global(struct wl_client *client, struct wl_object *object)
 	wl_client_post_event(client,
 			     &client->display->object,
 			     WL_DISPLAY_GLOBAL,
-			     object,
+			     object->id,
 			     object->interface->name,
 			     object->interface->version);
 }

commit a8db57befa3263c6de24fd9762a4aec3b564d4d3
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Mon Jul 18 13:10:49 2011 -0400

    conection: Handle demarshal errors a little less dramatically

diff --git a/wayland/connection.c b/wayland/connection.c
index 4f6a845..af9a90e 100644
--- a/wayland/connection.c
+++ b/wayland/connection.c
@@ -509,13 +509,17 @@ wl_connection_demarshal(struct wl_connection *connection,
 	count = strlen(message->signature) + 2;
 	if (count > ARRAY_LENGTH(closure->types)) {
 		printf("too many args (%d)\n", count);
-		assert(0);
+		errno = EINVAL;
+		wl_connection_consume(connection, size);
+		return NULL;
 	}
 
 	extra_space = wl_message_size_extra(message);
 	if (sizeof closure->buffer < size + extra_space) {
 		printf("request too big, should malloc tmp buffer here\n");
-		assert(0);
+		errno = ENOMEM;
+		wl_connection_consume(connection, size);
+		return NULL;
 	}
 
 	closure->message = message;

commit 728d09936f76ce60090e0fd0505b0522d03dd535
Author: Casey Dahlin <cdahlin@redhat.com>
Date:   Mon Jul 18 02:00:24 2011 -0400

    Fix segfault in client when demarshalling fails

diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c
index ce27a90..9d1f66b 100644
--- a/wayland/wayland-client.c
+++ b/wayland/wayland-client.c
@@ -521,6 +521,11 @@ handle_event(struct wl_display *display,
 	closure = wl_connection_demarshal(display->connection,
 					  size, display->objects, message);
 
+	if (closure == NULL) {
+		fprintf(stderr, "Error demarshalling event: %m\n");
+		abort();
+	}
+
 	if (wl_debug)
 		wl_closure_print(closure, &proxy->object, false);
 

commit 068ba750caebb62aaef20ac3452ce23e066c7239
Author: Tiago Vignatti <tiago.vignatti@intel.com>
Date:   Thu Jul 14 18:56:51 2011 +0300

    protocol: fix key event and related comments

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index fec9135..79bb3ea 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -10,9 +10,9 @@
       <arg name="version" type="uint"/>
     </request>
 
-    <!-- sync is an just an echo, which will reply with a sync event.
+    <!-- sync is an just an echo, which will reply with a key event.
          Since requests are handled in-order, this can be used as a
-         barrier to ensure all previous requests have ben handled.
+         barrier to ensure all previous requests have been handled.
          The key argument can be used to correlate between multiple
          sync invocations. -->
     <request name="sync">
@@ -70,7 +70,7 @@
     <!-- A reply to the frame or sync request.  The key is the one
          used in the request.  time is in millisecond units, and
          denotes the time when the frame was posted on the
-         display. time can be used to estimaate frame rate, determine
+         display. time can be used to estimate frame rate, determine
          how much to advance animations and compensate for jitter. -->
     <event name="key">
       <arg name="key" type="uint"/>

commit a9ef785cf83731b82334b22894dd01ee6ada66c8
Author: Tiago Vignatti <tiago.vignatti@intel.com>
Date:   Thu Jul 14 18:56:40 2011 +0300

    debug: add timestamps when logging
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>

diff --git a/wayland/connection.c b/wayland/connection.c
index 0f2051a..4f6a845 100644
--- a/wayland/connection.c
+++ b/wayland/connection.c
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <time.h>
 
 #include "wayland-util.h"
 #include "connection.h"
@@ -684,12 +685,23 @@ wl_closure_send(struct wl_closure *closure, struct wl_connection *connection)
 }
 
 void
-wl_closure_print(struct wl_closure *closure, struct wl_object *target)
+wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send)
 {
 	union wl_value *value;
+	char buffer[4] = "\0";
 	int i;
+	struct timespec tp;
+	unsigned int time;
 
-	fprintf(stderr, "%s@%d.%s(",
+	if (send)
+		sprintf(buffer, " -> ");
+
+	clock_gettime(CLOCK_REALTIME, &tp);
+	time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
+
+	fprintf(stderr, "[%10.3f] %s%s@%d.%s(",
+		time / 1000.0,
+		buffer,
 		target->interface->name, target->id,
 		closure->message->name);
 
diff --git a/wayland/connection.h b/wayland/connection.h
index 413977d..5f4588b 100644
--- a/wayland/connection.h
+++ b/wayland/connection.h
@@ -61,7 +61,7 @@ wl_closure_invoke(struct wl_closure *closure,
 void
 wl_closure_send(struct wl_closure *closure, struct wl_connection *connection);
 void
-wl_closure_print(struct wl_closure *closure, struct wl_object *target);
+wl_closure_print(struct wl_closure *closure, struct wl_object *target, int send);
 void
 wl_closure_destroy(struct wl_closure *closure);
 
diff --git a/wayland/wayland-client.c b/wayland/wayland-client.c
index e8266e1..ce27a90 100644
--- a/wayland/wayland-client.c
+++ b/wayland/wayland-client.c
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <stddef.h>
 #include <stdio.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
@@ -201,10 +202,8 @@ wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...)
 
 	wl_closure_send(closure, proxy->display->connection);
 
-	if (wl_debug) {
-		fprintf(stderr, " -> ");
-		wl_closure_print(closure, &proxy->object);
-	}
+	if (wl_debug)
+		wl_closure_print(closure, &proxy->object, true);
 
 	wl_closure_destroy(closure);
 }
@@ -523,7 +522,7 @@ handle_event(struct wl_display *display,
 					  size, display->objects, message);
 
 	if (wl_debug)
-		wl_closure_print(closure, &proxy->object);
+		wl_closure_print(closure, &proxy->object, false);
 
 	wl_closure_invoke(closure, &proxy->object,
 			  proxy->object.implementation[opcode],
diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
index 176859b..d4fdfc7 100644
--- a/wayland/wayland-server.c
+++ b/wayland/wayland-server.c
@@ -27,6 +27,7 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <stdarg.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
@@ -108,10 +109,8 @@ wl_client_post_event(struct wl_client *client, struct wl_object *sender,
 
 	wl_closure_send(closure, client->connection);
 
-	if (wl_debug) {
-		fprintf(stderr, " -> ");
-		wl_closure_print(closure, sender);
-	}
+	if (wl_debug)
+		wl_closure_print(closure, sender, true);
 
 	wl_closure_destroy(closure);
 }
@@ -202,7 +201,7 @@ wl_client_connection_data(int fd, uint32_t mask, void *data)
 
 
 		if (wl_debug)
-			wl_closure_print(closure, object);
+			wl_closure_print(closure, object, false);
 
 		wl_closure_invoke(closure, object,
 				  object->implementation[opcode], client);

commit 98da0a7b982310992e3af1b376c4b05ea4f2c71a
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 12 13:22:59 2011 -0400

    protocol: Fix type of visual arg in token_visual event

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 45c29ca..fec9135 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -96,7 +96,7 @@
     </enum>
 
     <event name="token_visual">
-      <arg name="id" type="new_id" interface="wl_object"/>
+      <arg name="visual" type="new_id" interface="wl_visual"/>
       <arg name="token" type="uint"/>
     </event>
   </interface>

commit f6bf070aee4527e9793681b42ac57a587d239f4c
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Tue Jul 12 13:22:25 2011 -0400

    scanner: Output type info for new_id arguments

diff --git a/wayland/scanner.c b/wayland/scanner.c
index 6df9df8..300e39d 100644
--- a/wayland/scanner.c
+++ b/wayland/scanner.c
@@ -60,6 +60,8 @@ struct protocol {
 	char *name;
 	char *uppercase_name;
 	struct wl_list interface_list;
+	int type_index;
+	int null_run_length;
 };
 
 struct interface {
@@ -77,6 +79,9 @@ struct message {
 	char *uppercase_name;
 	struct wl_list arg_list;
 	struct wl_list link;
+	int arg_count;
+	int type_index;
+	int all_null;
 	int destructor;
 };
 
@@ -204,6 +209,7 @@ start_element(void *data, const char *element_name, const char **atts)
 		message->name = strdup(name);
 		message->uppercase_name = uppercase_dup(name);
 		wl_list_init(&message->arg_list);
+		message->arg_count = 0;
 
 		if (strcmp(element_name, "request") == 0)
 			wl_list_insert(ctx->interface->request_list.prev,
@@ -250,6 +256,7 @@ start_element(void *data, const char *element_name, const char **atts)
 		}
 
 		wl_list_insert(ctx->message->arg_list.prev, &arg->link);
+		ctx->message->arg_count++;
 	} else if (strcmp(element_name, "enum") == 0) {
 		if (name == NULL)
 			fail(ctx, "no enum name given");
@@ -599,6 +606,80 @@ emit_header(struct protocol *protocol, int server)
 }
 
 static void
+emit_types_forward_declarations(struct protocol *protocol,
+				struct wl_list *message_list)
+{
+	struct message *m;
+	struct arg *a;
+	int length;
+
+	wl_list_for_each(m, message_list, link) {
+		length = 0;
+		m->all_null = 1;
+		wl_list_for_each(a, &m->arg_list, link) {
+			length++;
+			switch (a->type) {
+			case NEW_ID:
+			case OBJECT:
+				m->all_null = 0;
+				printf("extern const struct wl_interface %s_interface;\n",
+				       a->interface_name);
+				break;
+			default:
+				break;
+			}
+		}
+
+		if (m->all_null && length > protocol->null_run_length)
+			protocol->null_run_length = length;
+	}
+}
+
+static void
+emit_null_run(struct protocol *protocol)
+{
+	int i;
+
+	for (i = 0; i < protocol->null_run_length; i++)
+		printf("\tNULL,\n");
+}
+
+static void
+emit_types(struct protocol *protocol, struct wl_list *message_list)
+{
+	struct message *m;
+	struct arg *a;
+
+	wl_list_for_each(m, message_list, link) {
+		if (m->all_null) {
+			m->type_index = 0;
+			continue;
+		}
+
+		m->type_index =
+			protocol->null_run_length + protocol->type_index;
+		protocol->type_index += m->arg_count;
+
+		wl_list_for_each(a, &m->arg_list, link) {
+			switch (a->type) {
+			case NEW_ID:
+			case OBJECT:
+				if (strcmp(a->interface_name,
+					   "wl_object") != 0)
+					printf("\t&%s_interface,\n",
+					       a->interface_name);
+				else
+					printf("\tNULL,\n");
+				break;
+			default:
+				printf("\tNULL,\n");
+				break;
+			}
+		}
+	}
+}
+
+static void
 emit_messages(struct wl_list *message_list,
 	      struct interface *interface, const char *suffix)
 {
@@ -640,7 +721,7 @@ emit_messages(struct wl_list *message_list,
 				break;
 			}
 		}
-		printf("\", NULL },\n");
+		printf("\", types + %d },\n", m->type_index);
 	}
 
 	printf("};\n\n");
@@ -658,6 +739,20 @@ emit_code(struct protocol *protocol)
 	       copyright);
 
 	wl_list_for_each(i, &protocol->interface_list, link) {
+		emit_types_forward_declarations(protocol, &i->request_list);
+		emit_types_forward_declarations(protocol, &i->event_list);
+	}
+	printf("\n");
+
+	printf("static const struct wl_interface *types[] = {\n");
+	emit_null_run(protocol);
+	wl_list_for_each(i, &protocol->interface_list, link) {
+		emit_types(protocol, &i->request_list);
+		emit_types(protocol, &i->event_list);
+	}
+	printf("};\n\n");
+
+	wl_list_for_each(i, &protocol->interface_list, link) {
 
 		emit_messages(&i->request_list, i, "requests");
 		emit_messages(&i->event_list, i, "events");
@@ -694,6 +789,8 @@ int main(int argc, char *argv[])
 		usage(EXIT_FAILURE);
 
 	wl_list_init(&protocol.interface_list);
+	protocol.type_index = 0;
+	protocol.null_run_length = 0;
 	ctx.protocol = &protocol;
 
 	ctx.filename = "<stdin>";
diff --git a/wayland/wayland-util.h b/wayland/wayland-util.h
index 7808081..a9f869a 100644
--- a/wayland/wayland-util.h
+++ b/wayland/wayland-util.h
@@ -47,7 +47,7 @@ extern "C" {
 struct wl_message {
 	const char *name;
 	const char *signature;
-	const void **types;
+	const struct wl_interface **types;
 };
 
 struct wl_interface {

commit 671a62cb968b6793f0504770888b23b79e6fb81e
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Mon Jul 11 11:15:00 2011 -0400

    protocol: Make id arg of display.global event be just a uint
    
    Global names are different from object IDs.

diff --git a/protocol/wayland.xml b/protocol/wayland.xml
index 8d8afa4..45c29ca 100644
--- a/protocol/wayland.xml
+++ b/protocol/wayland.xml
@@ -48,7 +48,7 @@
          server will always announce an object before the object sends
          out events. -->
     <event name="global">
-      <arg name="id" type="new_id" interface="wl_object"/>
+      <arg name="id" type="uint" interface="wl_object"/>
       <arg name="name" type="string"/>
       <arg name="version" type="uint"/>
     </event>

commit ff1a06c03abfa18c18986d42683d69aa47f7d841
Author: Kristian Høgsberg <krh@bitplanet.net>
Date:   Thu Jul 7 13:39:08 2011 -0400

    scanner: map 'int' to int32_t.

diff --git a/wayland/scanner.c b/wayland/scanner.c
index b6aebdb..6df9df8 100644
--- a/wayland/scanner.c
+++ b/wayland/scanner.c
@@ -297,7 +297,7 @@ emit_type(struct arg *a)
 	default:
 	case INT:
 	case FD:
-		printf("int ");
+		printf("int32_t ");
 		break;
 	case NEW_ID:
 	case UNSIGNED:


Reply to: