entry may have a description according to the DTD. This is used in
some protocols including xdg-shell.

Fixes the code comment on an enum declaration using the description of
the last enum that had one, adds the descriptions to the comments on
enumerators, and avoids leaking the previously missing descriptions.

Fixes #208

Signed-off-by: James Legg <lankyle...@gmail.com>
---
 src/scanner.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/scanner.c b/src/scanner.c
index 46bdfc2..64df6e8 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -236,6 +236,7 @@ struct entry {
        char *summary;
        int since;
        struct wl_list link;
+       struct description *description;
 };
 
 struct parse_context {
@@ -245,6 +246,7 @@ struct parse_context {
        struct interface *interface;
        struct message *message;
        struct enumeration *enumeration;
+       struct entry *entry;
        struct description *description;
        char character_data[8192];
        unsigned int character_data_length;
@@ -542,6 +544,7 @@ free_entry(struct entry *entry)
        free(entry->uppercase_name);
        free(entry->value);
        free(entry->summary);
+       free_description(entry->description);
 
        free(entry);
 }
@@ -884,6 +887,7 @@ start_element(void *data, const char *element_name, const 
char **atts)
                        entry->summary = NULL;
                wl_list_insert(ctx->enumeration->entry_list.prev,
                               &entry->link);
+               ctx->entry = entry;
        } else if (strcmp(element_name, "description") == 0) {
                if (summary == NULL)
                        fail(&ctx->loc, "description without summary");
@@ -893,6 +897,8 @@ start_element(void *data, const char *element_name, const 
char **atts)
 
                if (ctx->message)
                        ctx->message->description = description;
+               else if (ctx->entry)
+                       ctx->entry->description = description;
                else if (ctx->enumeration)
                        ctx->enumeration->description = description;
                else if (ctx->interface)
@@ -1008,6 +1014,8 @@ end_element(void *data, const XML_Char *name)
                             ctx->enumeration->name);
                }
                ctx->enumeration = NULL;
+       } else if (strcmp(name, "entry") == 0) {
+               ctx->entry = NULL;
        } else if (strcmp(name, "protocol") == 0) {
                struct interface *i;
 
@@ -1364,10 +1372,17 @@ emit_enumerations(struct interface *interface)
                }
                printf("enum %s_%s {\n", interface->name, e->name);
                wl_list_for_each(entry, &e->entry_list, link) {
-                       if (entry->summary || entry->since > 1) {
+                       desc = entry->description;
+                       if (entry->summary || entry->since > 1 || desc) {
                                printf("\t/**\n");
                                if (entry->summary)
                                        printf("\t * %s\n", entry->summary);
+                               if (desc) {
+                                       printf("\t * %s\n", desc->summary);
+                                       printf("\t *\n");
+                                       if (desc->text)
+                                               desc_dump(desc->text, "\t * ");
+                               }
                                if (entry->since > 1)
                                        printf("\t * @since %d\n", 
entry->since);
                                printf("\t */\n");
-- 
2.31.1

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

Reply via email to