summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2013-06-27 20:09:19 -0500
committerKristian Høgsberg <krh@bitplanet.net>2013-07-02 15:52:47 -0400
commitd35b6278c0a4b731fcd2464c848a1c3ab5ec93a4 (patch)
treeecc7640fa2b7490c9223aee851659e6b9d185a80
parentd94a8722cb29d8b897672be66ff3c9ff79eab6fe (diff)
Add version information to wl_message signatures.
This commit adds version information to wl_message signatures and a wl_message_get_since function to retrieve. The since version comes in the form of a (possible) integer at the begining of the message. If the message starts with an integer, then it specifies the "since" version of that message. Messages present in version one do not get this "since" information. In this way we can run-time detect the version information for a structure on a per-message basis. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
-rw-r--r--src/connection.c55
-rw-r--r--src/scanner.c4
-rw-r--r--src/wayland-private.h3
3 files changed, 50 insertions, 12 deletions
diff --git a/src/connection.c b/src/connection.c
index 95edd6e..2ca9bce 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -402,28 +402,59 @@ wl_connection_put_fd(struct wl_connection *connection, int32_t fd)
const char *
get_next_argument(const char *signature, struct argument_details *details)
{
- if (*signature == '?') {
- details->nullable = 1;
- signature++;
- } else
- details->nullable = 0;
-
- details->type = *signature;
- return signature + 1;
+ details->nullable = 0;
+ for(; *signature; ++signature) {
+ switch(*signature) {
+ case 'i':
+ case 'u':
+ case 'f':
+ case 's':
+ case 'o':
+ case 'n':
+ case 'a':
+ case 'h':
+ details->type = *signature;
+ return signature + 1;
+ case '?':
+ details->nullable = 1;
+ }
+ }
+ return signature;
}
int
arg_count_for_signature(const char *signature)
{
int count = 0;
- while (*signature) {
- if (*signature != '?')
- count++;
- signature++;
+ for(; *signature; ++signature) {
+ switch(*signature) {
+ case 'i':
+ case 'u':
+ case 'f':
+ case 's':
+ case 'o':
+ case 'n':
+ case 'a':
+ case 'h':
+ ++count;
+ }
}
return count;
}
+int
+wl_message_get_since(const struct wl_message *message)
+{
+ int since;
+
+ since = atoi(message->signature);
+
+ if (since == 0)
+ since = 1;
+
+ return since;
+}
+
void
wl_argument_from_va_list(const char *signature, union wl_argument *args,
int count, va_list ap)
diff --git a/src/scanner.c b/src/scanner.c
index c63c908..cc3a745 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -1033,6 +1033,10 @@ emit_messages(struct wl_list *message_list,
wl_list_for_each(m, message_list, link) {
printf("\t{ \"%s\", \"", m->name);
+
+ if (m->since > 1)
+ printf("%d", m->since);
+
wl_list_for_each(a, &m->arg_list, link) {
if (is_nullable_type(a) && a->nullable)
printf("?");
diff --git a/src/wayland-private.h b/src/wayland-private.h
index b53cc40..a7d68c1 100644
--- a/src/wayland-private.h
+++ b/src/wayland-private.h
@@ -130,6 +130,9 @@ get_next_argument(const char *signature, struct argument_details *details);
int
arg_count_for_signature(const char *signature);
+int
+wl_message_get_since(const struct wl_message *message);
+
void
wl_argument_from_va_list(const char *signature, union wl_argument *args,
int count, va_list ap);