[PATCH] scanner: require descriptions and summaries

Jesse Barnes jbarnes at virtuousgeek.org
Thu Jan 19 14:27:30 PST 2012


To be applied once wayland.xml has full documentation.
---
 src/scanner.c |   27 ++++++++++++++++-----------
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/src/scanner.c b/src/scanner.c
index f88fb4d..ee9af5f 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -292,6 +292,9 @@ start_element(void *data, const char *element_name, const char **atts)
 			fail(ctx, "unknown type");
 		}
 
+		if (summary == NULL)
+			fail(ctx, "no arg summary\n");
+
 		switch (arg->type) {
 		case NEW_ID:
 		case OBJECT:
@@ -305,9 +308,7 @@ start_element(void *data, const char *element_name, const char **atts)
 			break;
 		}
 
-		arg->summary = NULL;
-		if (summary)
-			arg->summary = strdup(summary);
+		arg->summary = strdup(summary);
 
 		wl_list_insert(ctx->message->arg_list.prev, &arg->link);
 		ctx->message->arg_count++;
@@ -328,15 +329,14 @@ start_element(void *data, const char *element_name, const char **atts)
 	} else if (strcmp(element_name, "entry") == 0) {
 		if (name == NULL)
 			fail(ctx, "no entry name given");
+		if (summary == NULL)
+			fail(ctx, "no entry summary given");
 
 		entry = malloc(sizeof *entry);
 		entry->name = strdup(name);
 		entry->uppercase_name = uppercase_dup(name);
 		entry->value = strdup(value);
-		if (summary)
-			entry->summary = strdup(summary);
-		else
-			entry->summary = NULL;
+		entry->summary = strdup(summary);
 		wl_list_insert(ctx->enumeration->entry_list.prev,
 			       &entry->link);
 	} else if (strcmp(element_name, "description") == 0) {
@@ -344,10 +344,7 @@ start_element(void *data, const char *element_name, const char **atts)
 			fail(ctx, "description without summary");
 
 		description = malloc(sizeof *description);
-		if (summary)
-			description->summary = strdup(summary);
-		else
-			description->summary = NULL;
+		description->summary = strdup(summary);
 
 		if (ctx->message)
 			ctx->message->description = description;
@@ -378,9 +375,17 @@ end_element(void *data, const XML_Char *name)
 		ctx->description = NULL;
 	} else if (strcmp(name, "request") == 0 ||
 		   strcmp(name, "event") == 0) {
+		if (!ctx->message->description)
+			fail(ctx, "request or event without <description>");
 		ctx->message = NULL;
 	} else if (strcmp(name, "enum") == 0) {
+		if (!ctx->enumeration->description)
+			fail(ctx, "enum without <description>");
 		ctx->enumeration = NULL;
+	} else if (strcmp(name, "interface") == 0) {
+		if (!ctx->interface->description)
+			fail(ctx, "interface without <description>");
+		ctx->interface = NULL;
 	}
 }
 
-- 
1.7.1



More information about the wayland-devel mailing list