summaryrefslogtreecommitdiff
path: root/lib/skin_parser
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-15 06:24:11 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-15 06:24:11 +0000
commit15488a00eae8d10249015b88e4b7bdc47365b854 (patch)
tree62439c56fa8a926b148c7a3cc843a0c60f3aac21 /lib/skin_parser
parent387af97a26105fce79e6a8726752cf183d40939e (diff)
downloadrockbox-15488a00eae8d10249015b88e4b7bdc47365b854.tar.gz
rockbox-15488a00eae8d10249015b88e4b7bdc47365b854.zip
Theme Editor: Committed FS#11477 to add a DECIMAL parameter type in the parser and adapt the Theme Editor to accomodate the change by Johnathan Gordon. Fixed bug in the parser caused by the patch (error was thrown on zero value) and adapted tag rendering for new format
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27426 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'lib/skin_parser')
-rw-r--r--lib/skin_parser/skin_debug.c12
-rw-r--r--lib/skin_parser/skin_parser.c35
-rw-r--r--lib/skin_parser/skin_parser.h6
-rw-r--r--lib/skin_parser/tag_table.c10
-rw-r--r--lib/skin_parser/tag_table.h3
5 files changed, 54 insertions, 12 deletions
diff --git a/lib/skin_parser/skin_debug.c b/lib/skin_parser/skin_debug.c
index 00d09aea7e..4abe6252f0 100644
--- a/lib/skin_parser/skin_debug.c
+++ b/lib/skin_parser/skin_debug.c
@@ -70,6 +70,9 @@ void skin_error(enum skin_errorcode error)
70 case INT_EXPECTED: 70 case INT_EXPECTED:
71 error_message = "Expected integer"; 71 error_message = "Expected integer";
72 break; 72 break;
73 case DECIMAL_EXPECTED:
74 error_message = "Expected decimal";
75 break;
73 case SEPERATOR_EXPECTED: 76 case SEPERATOR_EXPECTED:
74 error_message = "Expected argument seperator"; 77 error_message = "Expected argument seperator";
75 break; 78 break;
@@ -236,8 +239,13 @@ void skin_debug_params(int count, struct skin_tag_parameter params[])
236 printf("[%s]", params[i].data.text); 239 printf("[%s]", params[i].data.text);
237 break; 240 break;
238 241
239 case NUMERIC: 242 case INTEGER:
240 printf("[%d]", params[i].data.numeric); 243 printf("[%d]", params[i].data.number);
244 break;
245
246 case DECIMAL:
247 printf("[%d.%d]", params[i].data.number/10,
248 params[i].data.number%10);
241 break; 249 break;
242 250
243 case CODE: 251 case CODE:
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c
index 2ce41c6d9a..5bc5984fb7 100644
--- a/lib/skin_parser/skin_parser.c
+++ b/lib/skin_parser/skin_parser.c
@@ -23,6 +23,7 @@
23#include <stdio.h> 23#include <stdio.h>
24#include <string.h> 24#include <string.h>
25#include <ctype.h> 25#include <ctype.h>
26#include <stdbool.h>
26 27
27#include "skin_buffer.h" 28#include "skin_buffer.h"
28#include "skin_parser.h" 29#include "skin_parser.h"
@@ -534,7 +535,7 @@ static int skin_parse_tag(struct skin_element* element, char** document)
534 /* Storing the type code */ 535 /* Storing the type code */
535 element->params[i].type_code = *tag_args; 536 element->params[i].type_code = *tag_args;
536 537
537 /* Checking a nullable argument for null */ 538 /* Checking a nullable argument for null. */
538 if(*cursor == DEFAULTSYM && !isdigit(cursor[1])) 539 if(*cursor == DEFAULTSYM && !isdigit(cursor[1]))
539 { 540 {
540 if(islower(*tag_args)) 541 if(islower(*tag_args))
@@ -557,8 +558,36 @@ static int skin_parse_tag(struct skin_element* element, char** document)
557 return 0; 558 return 0;
558 } 559 }
559 560
560 element->params[i].type = NUMERIC; 561 element->params[i].type = INTEGER;
561 element->params[i].data.numeric = scan_int(&cursor); 562 element->params[i].data.number = scan_int(&cursor);
563 }
564 else if(tolower(*tag_args) == 'd')
565 {
566 int val = 0;
567 bool have_point = false;
568 bool have_tenth = false;
569 while ( isdigit(*cursor) || *cursor == '.' )
570 {
571 if (*cursor != '.')
572 {
573 val *= 10;
574 val += *cursor - '0';
575 if (have_point)
576 {
577 have_tenth = true;
578 cursor++;
579 break;
580 }
581 }
582 else
583 have_point = true;
584 cursor++;
585 }
586 if (have_tenth == false)
587 val *= 10;
588
589 element->params[i].type = DECIMAL;
590 element->params[i].data.number = val;
562 } 591 }
563 else if(tolower(*tag_args) == 'n' || 592 else if(tolower(*tag_args) == 'n' ||
564 tolower(*tag_args) == 's' || tolower(*tag_args) == 'f') 593 tolower(*tag_args) == 's' || tolower(*tag_args) == 'f')
diff --git a/lib/skin_parser/skin_parser.h b/lib/skin_parser/skin_parser.h
index 126a014b5a..ad10f90125 100644
--- a/lib/skin_parser/skin_parser.h
+++ b/lib/skin_parser/skin_parser.h
@@ -56,6 +56,7 @@ enum skin_errorcode
56 UNEXPECTED_NEWLINE, 56 UNEXPECTED_NEWLINE,
57 INSUFFICIENT_ARGS, 57 INSUFFICIENT_ARGS,
58 INT_EXPECTED, 58 INT_EXPECTED,
59 DECIMAL_EXPECTED,
59 SEPERATOR_EXPECTED, 60 SEPERATOR_EXPECTED,
60 CLOSE_EXPECTED, 61 CLOSE_EXPECTED,
61 MULTILINE_EXPECTED 62 MULTILINE_EXPECTED
@@ -66,7 +67,8 @@ struct skin_tag_parameter
66{ 67{
67 enum 68 enum
68 { 69 {
69 NUMERIC, 70 INTEGER,
71 DECIMAL, /* stored in data.number as (whole*10)+part */
70 STRING, 72 STRING,
71 CODE, 73 CODE,
72 DEFAULT 74 DEFAULT
@@ -74,7 +76,7 @@ struct skin_tag_parameter
74 76
75 union 77 union
76 { 78 {
77 int numeric; 79 int number;
78 char* text; 80 char* text;
79 struct skin_element* code; 81 struct skin_element* code;
80 } data; 82 } data;
diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c
index e0247ef745..dd8df63997 100644
--- a/lib/skin_parser/tag_table.c
+++ b/lib/skin_parser/tag_table.c
@@ -120,7 +120,7 @@ struct tag_info legal_tags[] =
120 { SKIN_TOKEN_REMOTE_HOLD, "mr", "", 0 }, 120 { SKIN_TOKEN_REMOTE_HOLD, "mr", "", 0 },
121 { SKIN_TOKEN_REPEAT_MODE, "mm", "", 0 }, 121 { SKIN_TOKEN_REPEAT_MODE, "mm", "", 0 },
122 { SKIN_TOKEN_PLAYBACK_STATUS, "mp", "", 0 }, 122 { SKIN_TOKEN_PLAYBACK_STATUS, "mp", "", 0 },
123 { SKIN_TOKEN_BUTTON_VOLUME, "mv", "|S", 0 }, 123 { SKIN_TOKEN_BUTTON_VOLUME, "mv", "|D", 0 },
124 124
125 { SKIN_TOKEN_PEAKMETER, "pm", "", 0 }, 125 { SKIN_TOKEN_PEAKMETER, "pm", "", 0 },
126 { SKIN_TOKEN_PLAYER_PROGRESSBAR, "pf", "", 0 }, 126 { SKIN_TOKEN_PLAYER_PROGRESSBAR, "pf", "", 0 },
@@ -131,8 +131,8 @@ struct tag_info legal_tags[] =
131 { SKIN_TOKEN_TRACK_TIME_ELAPSED, "pc", "", 0 }, 131 { SKIN_TOKEN_TRACK_TIME_ELAPSED, "pc", "", 0 },
132 { SKIN_TOKEN_TRACK_TIME_REMAINING, "pr", "", 0 }, 132 { SKIN_TOKEN_TRACK_TIME_REMAINING, "pr", "", 0 },
133 { SKIN_TOKEN_TRACK_LENGTH, "pt", "", 0 }, 133 { SKIN_TOKEN_TRACK_LENGTH, "pt", "", 0 },
134 { SKIN_TOKEN_TRACK_STARTING, "pS" , "|S", 0 }, 134 { SKIN_TOKEN_TRACK_STARTING, "pS" , "|D", 0 },
135 { SKIN_TOKEN_TRACK_ENDING, "pE" , "|S", 0 }, 135 { SKIN_TOKEN_TRACK_ENDING, "pE" , "|D", 0 },
136 { SKIN_TOKEN_PLAYLIST_POSITION, "pp", "", 0 }, 136 { SKIN_TOKEN_PLAYLIST_POSITION, "pp", "", 0 },
137 { SKIN_TOKEN_PLAYLIST_ENTRIES, "pe", "", 0 }, 137 { SKIN_TOKEN_PLAYLIST_ENTRIES, "pe", "", 0 },
138 { SKIN_TOKEN_PLAYLIST_NAME, "pn", "", 0 }, 138 { SKIN_TOKEN_PLAYLIST_NAME, "pn", "", 0 },
@@ -161,7 +161,7 @@ struct tag_info legal_tags[] =
161 { SKIN_TOKEN_RDS_TEXT, "tz", "", 0 }, 161 { SKIN_TOKEN_RDS_TEXT, "tz", "", 0 },
162 162
163 { SKIN_TOKEN_SUBLINE_SCROLL, "s", "", 0 }, 163 { SKIN_TOKEN_SUBLINE_SCROLL, "s", "", 0 },
164 { SKIN_TOKEN_SUBLINE_TIMEOUT, "t" , "S", 0 }, 164 { SKIN_TOKEN_SUBLINE_TIMEOUT, "t" , "D", 0 },
165 165
166 { SKIN_TOKEN_ENABLE_THEME, "we", "", NOBREAK }, 166 { SKIN_TOKEN_ENABLE_THEME, "we", "", NOBREAK },
167 { SKIN_TOKEN_DISABLE_THEME, "wd", "", NOBREAK }, 167 { SKIN_TOKEN_DISABLE_THEME, "wd", "", NOBREAK },
@@ -196,7 +196,7 @@ struct tag_info legal_tags[] =
196 { SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S", 0 }, 196 { SKIN_TOKEN_TRANSLATEDSTRING, "Sx" , "S", 0 },
197 { SKIN_TOKEN_LANG_IS_RTL, "Sr" , "", 0 }, 197 { SKIN_TOKEN_LANG_IS_RTL, "Sr" , "", 0 },
198 198
199 { SKIN_TOKEN_LASTTOUCH, "Tl" , "|S", 0 }, 199 { SKIN_TOKEN_LASTTOUCH, "Tl" , "|D", 0 },
200 { SKIN_TOKEN_CURRENT_SCREEN, "cs", "", 0 }, 200 { SKIN_TOKEN_CURRENT_SCREEN, "cs", "", 0 },
201 { SKIN_TOKEN_TOUCHREGION, "T" , "IIiiS", NOBREAK }, 201 { SKIN_TOKEN_TOUCHREGION, "T" , "IIiiS", NOBREAK },
202 202
diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h
index 149f148cca..f84d4ac762 100644
--- a/lib/skin_parser/tag_table.h
+++ b/lib/skin_parser/tag_table.h
@@ -246,6 +246,9 @@ enum skin_token_type {
246 * characters for parameters are: 246 * characters for parameters are:
247 * I - Required integer 247 * I - Required integer
248 * i - Nullable integer 248 * i - Nullable integer
249 * D - Required decimal
250 * d - Nullable decimal
251 * Decimals are stored as (whole*10)+part
249 * S - Required string 252 * S - Required string
250 * s - Nullable string 253 * s - Nullable string
251 * F - Required file name 254 * F - Required file name