mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	tokenize.c, parse.c: rename functions
This commit is contained in:
		
							parent
							
								
									6627a47305
								
							
						
					
					
						commit
						f199fc4779
					
				
					 5 changed files with 16 additions and 17 deletions
				
			
		| 
						 | 
					@ -17,11 +17,15 @@ struct pixmap {
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * xbm_create_pixmap - parse xbm tokens and create pixmap
 | 
					 * parse_xbm_tokens - parse xbm tokens and create pixmap
 | 
				
			||||||
 * @tokens: token vector
 | 
					 * @tokens: token vector
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct pixmap xbm_create_pixmap(struct token *tokens);
 | 
					struct pixmap parse_xbm_tokens(struct token *tokens);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pixmap xbm_create_pixmap_builtin(const char *button);
 | 
					/**
 | 
				
			||||||
 | 
					 * parse_xbm_builtin - parse builtin xbm button and create pixmap
 | 
				
			||||||
 | 
					 * @button: button byte array (xbm format)
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					struct pixmap parse_xbm_builtin(const char *button);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __LABWC_PARSE_H */
 | 
					#endif /* __LABWC_PARSE_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -28,13 +28,6 @@ struct token {
 | 
				
			||||||
 * @buffer: buffer containing xbm file
 | 
					 * @buffer: buffer containing xbm file
 | 
				
			||||||
 * return token vector
 | 
					 * return token vector
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
struct token *xbm_tokenize(char *buffer);
 | 
					struct token *tokenize_xbm(char *buffer);
 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * xbm_read_file - read file into buffer (as it's easier to tokenize that way)
 | 
					 | 
				
			||||||
 * @filename: file to be read
 | 
					 | 
				
			||||||
 * return allocated memory
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
char *xbm_read_file(const char *filename);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif /* __LABWC_TOKENIZE_H */
 | 
					#endif /* __LABWC_TOKENIZE_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,7 @@ static void process_bytes(struct pixmap *pixmap, struct token *tokens)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct pixmap xbm_create_pixmap(struct token *tokens)
 | 
					struct pixmap parse_xbm_tokens(struct token *tokens)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pixmap pixmap = { 0 };
 | 
						struct pixmap pixmap = { 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,7 +68,7 @@ out:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Assuming a 6x6 button for the time being */
 | 
					/* Assuming a 6x6 button for the time being */
 | 
				
			||||||
/* TODO: pass width, height, vargs bytes */
 | 
					/* TODO: pass width, height, vargs bytes */
 | 
				
			||||||
struct pixmap xbm_create_pixmap_builtin(const char *button)
 | 
					struct pixmap parse_xbm_builtin(const char *button)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pixmap pixmap = { 0 };
 | 
						struct pixmap pixmap = { 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,7 +78,7 @@ static void get_special_char_token()
 | 
				
			||||||
	current_buffer_position++;
 | 
						current_buffer_position++;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct token *xbm_tokenize(char *buffer)
 | 
					struct token *tokenize_xbm(char *buffer)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	tokens = NULL;
 | 
						tokens = NULL;
 | 
				
			||||||
	nr_tokens = 0;
 | 
						nr_tokens = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,7 @@ static struct wlr_texture *texture_from_pixmap(struct wlr_renderer *renderer,
 | 
				
			||||||
static struct wlr_texture *texture_from_builtin(struct wlr_renderer *renderer,
 | 
					static struct wlr_texture *texture_from_builtin(struct wlr_renderer *renderer,
 | 
				
			||||||
						const char *button)
 | 
											const char *button)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct pixmap pixmap = xbm_create_pixmap_builtin(button);
 | 
						struct pixmap pixmap = parse_xbm_builtin(button);
 | 
				
			||||||
	struct wlr_texture *texture = texture_from_pixmap(renderer, &pixmap);
 | 
						struct wlr_texture *texture = texture_from_pixmap(renderer, &pixmap);
 | 
				
			||||||
	if (pixmap.data)
 | 
						if (pixmap.data)
 | 
				
			||||||
		free(pixmap.data);
 | 
							free(pixmap.data);
 | 
				
			||||||
| 
						 | 
					@ -51,13 +51,15 @@ static char *xbm_path(const char *button)
 | 
				
			||||||
static void load_button(struct wlr_renderer *renderer, const char *filename,
 | 
					static void load_button(struct wlr_renderer *renderer, const char *filename,
 | 
				
			||||||
			struct wlr_texture **texture, char *button)
 | 
								struct wlr_texture **texture, char *button)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						/* Read file into memory as it's easier to tokenzie that way */
 | 
				
			||||||
	char *buffer = grab_file(xbm_path(filename));
 | 
						char *buffer = grab_file(xbm_path(filename));
 | 
				
			||||||
	if (!buffer)
 | 
						if (!buffer)
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
	fprintf(stderr, "loading %s\n", filename);
 | 
						fprintf(stderr, "loading %s\n", filename);
 | 
				
			||||||
	struct token *tokens = xbm_tokenize(buffer);
 | 
						struct token *tokens = tokenize_xbm(buffer);
 | 
				
			||||||
	free(buffer);
 | 
						free(buffer);
 | 
				
			||||||
	struct pixmap pixmap = xbm_create_pixmap(tokens);
 | 
					
 | 
				
			||||||
 | 
						struct pixmap pixmap = parse_xbm_tokens(tokens);
 | 
				
			||||||
	*texture = texture_from_pixmap(renderer, &pixmap);
 | 
						*texture = texture_from_pixmap(renderer, &pixmap);
 | 
				
			||||||
	if (tokens)
 | 
						if (tokens)
 | 
				
			||||||
		free(tokens);
 | 
							free(tokens);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue