diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-03-05 10:31:53 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-03-05 10:31:53 -0500 |
commit | 814a626087546387331fd197b62b343dea22907e (patch) | |
tree | fc60927275fd6f745a860933b183bcfacf41b1ee | |
parent | bb4b05bc8d0df6dc119a20bdaad30a0849a028be (diff) |
scanner: Add since attribute
This will help us document when a request or event was added to the protocol.
-rw-r--r-- | src/scanner.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/scanner.c b/src/scanner.c index 48eea25..bdb9a56 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -57,6 +57,7 @@ struct interface { char *name; char *uppercase_name; int version; + int since; struct wl_list request_list; struct wl_list event_list; struct wl_list enumeration_list; @@ -73,6 +74,7 @@ struct message { int type_index; int all_null; int destructor; + int since; struct description *description; }; @@ -189,7 +191,8 @@ start_element(void *data, const char *element_name, const char **atts) struct enumeration *enumeration; struct entry *entry; struct description *description; - const char *name, *type, *interface_name, *value, *summary; + const char *name, *type, *interface_name, *value, *summary, *since; + char *end; int i, version; name = NULL; @@ -199,6 +202,7 @@ start_element(void *data, const char *element_name, const char **atts) value = NULL; summary = NULL; description = NULL; + since = NULL; for (i = 0; atts[i]; i += 2) { if (strcmp(atts[i], "name") == 0) name = atts[i + 1]; @@ -212,6 +216,8 @@ start_element(void *data, const char *element_name, const char **atts) interface_name = atts[i + 1]; if (strcmp(atts[i], "summary") == 0) summary = atts[i + 1]; + if (strcmp(atts[i], "since") == 0) + since = atts[i + 1]; } ctx->character_data_length = 0; @@ -236,6 +242,7 @@ start_element(void *data, const char *element_name, const char **atts) interface->uppercase_name = uppercase_dup(name); interface->version = version; interface->description = NULL; + interface->since = 1; wl_list_init(&interface->request_list); wl_list_init(&interface->event_list); wl_list_init(&interface->enumeration_list); @@ -266,6 +273,17 @@ start_element(void *data, const char *element_name, const char **atts) else message->destructor = 0; + if (since != NULL) { + version = strtol(since, &end, 0); + if (errno == EINVAL || end == since || *end != '\0') + fail(ctx, "invalid integer\n"); + if (version <= ctx->interface->since) + fail(ctx, "since version not increasing\n"); + ctx->interface->since = version; + } + + message->since = ctx->interface->since; + if (strcmp(name, "destroy") == 0 && !message->destructor) fail(ctx, "destroy request should be destructor type"); @@ -704,6 +722,9 @@ emit_structs(struct wl_list *message_list, struct interface *interface) desc_dump(mdesc->text, 8); printf("\n"); } + if (m->since > 1) { + printf("\t * @since: %d\n", m->since); + } printf("\t */\n"); printf("\tvoid (*%s)(", m->name); |