mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	scanner: Add since attribute
This will help us document when a request or event was added to the protocol.
This commit is contained in:
		
							parent
							
								
									bb4b05bc8d
								
							
						
					
					
						commit
						814a626087
					
				
					 1 changed files with 22 additions and 1 deletions
				
			
		| 
						 | 
					@ -57,6 +57,7 @@ struct interface {
 | 
				
			||||||
	char *name;
 | 
						char *name;
 | 
				
			||||||
	char *uppercase_name;
 | 
						char *uppercase_name;
 | 
				
			||||||
	int version;
 | 
						int version;
 | 
				
			||||||
 | 
						int since;
 | 
				
			||||||
	struct wl_list request_list;
 | 
						struct wl_list request_list;
 | 
				
			||||||
	struct wl_list event_list;
 | 
						struct wl_list event_list;
 | 
				
			||||||
	struct wl_list enumeration_list;
 | 
						struct wl_list enumeration_list;
 | 
				
			||||||
| 
						 | 
					@ -73,6 +74,7 @@ struct message {
 | 
				
			||||||
	int type_index;
 | 
						int type_index;
 | 
				
			||||||
	int all_null;
 | 
						int all_null;
 | 
				
			||||||
	int destructor;
 | 
						int destructor;
 | 
				
			||||||
 | 
						int since;
 | 
				
			||||||
	struct description *description;
 | 
						struct description *description;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -189,7 +191,8 @@ start_element(void *data, const char *element_name, const char **atts)
 | 
				
			||||||
	struct enumeration *enumeration;
 | 
						struct enumeration *enumeration;
 | 
				
			||||||
	struct entry *entry;
 | 
						struct entry *entry;
 | 
				
			||||||
	struct description *description;
 | 
						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;
 | 
						int i, version;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	name = NULL;
 | 
						name = NULL;
 | 
				
			||||||
| 
						 | 
					@ -199,6 +202,7 @@ start_element(void *data, const char *element_name, const char **atts)
 | 
				
			||||||
	value = NULL;
 | 
						value = NULL;
 | 
				
			||||||
	summary = NULL;
 | 
						summary = NULL;
 | 
				
			||||||
	description = NULL;
 | 
						description = NULL;
 | 
				
			||||||
 | 
						since = NULL;
 | 
				
			||||||
	for (i = 0; atts[i]; i += 2) {
 | 
						for (i = 0; atts[i]; i += 2) {
 | 
				
			||||||
		if (strcmp(atts[i], "name") == 0)
 | 
							if (strcmp(atts[i], "name") == 0)
 | 
				
			||||||
			name = atts[i + 1];
 | 
								name = atts[i + 1];
 | 
				
			||||||
| 
						 | 
					@ -212,6 +216,8 @@ start_element(void *data, const char *element_name, const char **atts)
 | 
				
			||||||
			interface_name = atts[i + 1];
 | 
								interface_name = atts[i + 1];
 | 
				
			||||||
		if (strcmp(atts[i], "summary") == 0)
 | 
							if (strcmp(atts[i], "summary") == 0)
 | 
				
			||||||
			summary = atts[i + 1];
 | 
								summary = atts[i + 1];
 | 
				
			||||||
 | 
							if (strcmp(atts[i], "since") == 0)
 | 
				
			||||||
 | 
								since = atts[i + 1];
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx->character_data_length = 0;
 | 
						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->uppercase_name = uppercase_dup(name);
 | 
				
			||||||
		interface->version = version;
 | 
							interface->version = version;
 | 
				
			||||||
		interface->description = NULL;
 | 
							interface->description = NULL;
 | 
				
			||||||
 | 
							interface->since = 1;
 | 
				
			||||||
		wl_list_init(&interface->request_list);
 | 
							wl_list_init(&interface->request_list);
 | 
				
			||||||
		wl_list_init(&interface->event_list);
 | 
							wl_list_init(&interface->event_list);
 | 
				
			||||||
		wl_list_init(&interface->enumeration_list);
 | 
							wl_list_init(&interface->enumeration_list);
 | 
				
			||||||
| 
						 | 
					@ -266,6 +273,17 @@ start_element(void *data, const char *element_name, const char **atts)
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			message->destructor = 0;
 | 
								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)
 | 
							if (strcmp(name, "destroy") == 0 && !message->destructor)
 | 
				
			||||||
			fail(ctx, "destroy request should be destructor type");
 | 
								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);
 | 
								desc_dump(mdesc->text, 8);
 | 
				
			||||||
			printf("\n");
 | 
								printf("\n");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if (m->since > 1) {
 | 
				
			||||||
 | 
								printf("\t * @since: %d\n", m->since);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		printf("\t */\n");
 | 
							printf("\t */\n");
 | 
				
			||||||
		printf("\tvoid (*%s)(", m->name);
 | 
							printf("\tvoid (*%s)(", m->name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue