mirror of
				https://gitlab.freedesktop.org/wayland/wayland.git
				synced 2025-11-03 09:01:42 -05:00 
			
		
		
		
	Move ARRAY_LENGTH out of public headers
Exporting unprefixed symbols is a pretty bad idea so don't do that. Instea of redefining it WL_ARRAY_LENGTH, we just move the define to our private header. The scanner generates code that uses ARRAY_LENGTH, but we can just make it count the number elements and emit an integer constant instead.
This commit is contained in:
		
							parent
							
								
									56061674cd
								
							
						
					
					
						commit
						bdd272f024
					
				
					 5 changed files with 21 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -127,6 +127,18 @@ struct parse_context {
 | 
			
		|||
	unsigned int character_data_length;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
list_length(struct wl_list *list)
 | 
			
		||||
{
 | 
			
		||||
	struct wl_list *l;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	for (i = 0, l = list->next; l != list; i++, l = l->next)
 | 
			
		||||
		;
 | 
			
		||||
 | 
			
		||||
	return i;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static char *
 | 
			
		||||
uppercase_dup(const char *src)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -1106,14 +1118,14 @@ emit_code(struct protocol *protocol)
 | 
			
		|||
		       i->name, i->name, i->version);
 | 
			
		||||
 | 
			
		||||
		if (!wl_list_empty(&i->request_list))
 | 
			
		||||
			printf("\tARRAY_LENGTH(%s_requests), %s_requests,\n",
 | 
			
		||||
			       i->name, i->name);
 | 
			
		||||
			printf("\t%d, %s_requests,\n",
 | 
			
		||||
			       list_length(&i->request_list), i->name);
 | 
			
		||||
		else
 | 
			
		||||
			printf("\t0, NULL,\n");
 | 
			
		||||
 | 
			
		||||
		if (!wl_list_empty(&i->event_list))
 | 
			
		||||
			printf("\tARRAY_LENGTH(%s_events), %s_events,\n",
 | 
			
		||||
			       i->name, i->name);
 | 
			
		||||
			printf("\t%d, %s_events,\n",
 | 
			
		||||
			       list_length(&i->event_list), i->name);
 | 
			
		||||
		else
 | 
			
		||||
			printf("\t0, NULL,\n");
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue