From dab7e161767f951a55d6fbc0988fae5f3d9df474 Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Tue, 18 Aug 2009 07:17:51 +0000 Subject: store the image label instead of a number so debug output is actually useful when %xd is used witout a coresponding %xl git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22404 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/skin_engine/skin_display.c | 6 +++--- apps/gui/skin_engine/skin_parser.c | 24 +++++++++--------------- apps/gui/skin_engine/wps_debug.c | 4 ++-- apps/gui/skin_engine/wps_internals.h | 4 ++-- 4 files changed, 16 insertions(+), 22 deletions(-) diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 1e88863307..6b86a8bc0e 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -478,13 +478,13 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index) return true; } #ifdef HAVE_LCD_BITMAP -struct gui_img* find_image(int n, struct wps_data *data) +struct gui_img* find_image(char label, struct wps_data *data) { struct skin_token_list *list = data->images; while (list) { struct gui_img *img = (struct gui_img *)list->token->value.data; - if (img->id == n) + if (img->label == label) return img; list = list->next; } @@ -555,7 +555,7 @@ static bool get_line(struct gui_wps *gwps, #ifdef HAVE_LCD_BITMAP case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY: { - int n = data->tokens[i].value.i & 0xFF; + char n = data->tokens[i].value.i & 0xFF; int subimage = data->tokens[i].value.i >> 8; struct gui_img *img = find_image(n, data); diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index 82083e8922..b7f2ec3091 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -482,19 +482,17 @@ static int parse_image_display(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data) { - int n = get_image_id(wps_bufptr[0]); + char label = wps_bufptr[0]; int subimage; struct gui_img *img;; - if (n == -1) - { - /* invalid picture display tag */ - return WPS_ERROR_INVALID_PARAM; - } /* sanity check */ - img = find_image(n, wps_data); + img = find_image(label, wps_data); if (!img) + { + token->value.i = label; /* do debug works */ return WPS_ERROR_INVALID_PARAM; + } if ((subimage = get_image_id(wps_bufptr[1])) != -1) { @@ -502,10 +500,10 @@ static int parse_image_display(const char *wps_bufptr, return WPS_ERROR_INVALID_PARAM; /* Store sub-image number to display in high bits */ - token->value.i = n | (subimage << 8); + token->value.i = label | (subimage << 8); return 2; /* We have consumed 2 bytes */ } else { - token->value.i = n; + token->value.i = label; return 1; /* We have consumed 1 byte */ } } @@ -514,7 +512,6 @@ static int parse_image_load(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data) { - int n; const char *ptr = wps_bufptr; const char *pos; const char* filename; @@ -540,11 +537,8 @@ static int parse_image_load(const char *wps_bufptr, if (*ptr != '|') return WPS_ERROR_INVALID_PARAM; - /* get the image ID */ - n = get_image_id(*id); - /* check the image number and load state */ - if(n < 0 || find_image(n, wps_data)) + if(find_image(*id, wps_data)) { /* Invalid image ID */ return WPS_ERROR_INVALID_PARAM; @@ -554,7 +548,7 @@ static int parse_image_load(const char *wps_bufptr, return WPS_ERROR_INVALID_PARAM; /* save a pointer to the filename */ img->bm.data = (char*)filename; - img->id = n; + img->label = *id; img->x = x; img->y = y; img->num_subimages = 1; diff --git a/apps/gui/skin_engine/wps_debug.c b/apps/gui/skin_engine/wps_debug.c index e3e6e960e6..60f53b83f4 100644 --- a/apps/gui/skin_engine/wps_debug.c +++ b/apps/gui/skin_engine/wps_debug.c @@ -113,8 +113,8 @@ static char *get_token_desc(struct wps_token *token, struct wps_data *data, break; case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY: - snprintf(buf, bufsize, "display preloaded image %d", - token->value.i); + snprintf(buf, bufsize, "display preloaded image '%c'", + token->value.i&0xFF); break; case WPS_TOKEN_IMAGE_DISPLAY: diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 4136347a7b..0adae04c42 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h @@ -77,7 +77,7 @@ #ifdef HAVE_LCD_BITMAP struct gui_img { - short int id; + char label; struct bitmap bm; struct viewport* vp; /* The viewport to display this image in */ short int x; /* x-pos */ @@ -346,7 +346,7 @@ const char *get_token_value(struct gui_wps *gwps, -struct gui_img* find_image(int n, struct wps_data *data); +struct gui_img* find_image(char label, struct wps_data *data); struct skin_viewport* find_viewport(char label, struct wps_data *data); #endif -- cgit v1.2.3