summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-02 07:48:48 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-02 07:48:48 +0000
commit496bcf39c7070ad35c73610d2f2dd492cae8b94c (patch)
tree8b881cfa1e4d466e7d0f125723250ccb6d5c04d5 /utils
parent7f10b0336e9aacd4fb21269da652671ff610aa05 (diff)
downloadrockbox-496bcf39c7070ad35c73610d2f2dd492cae8b94c.tar.gz
rockbox-496bcf39c7070ad35c73610d2f2dd492cae8b94c.zip
Theme Editor: Fixed parsing and code generation for nested conditionals
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26467 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/parsetreenode.cpp7
-rw-r--r--utils/themeeditor/parsetreenode.h2
-rw-r--r--utils/themeeditor/skin_parser.c32
3 files changed, 40 insertions, 1 deletions
diff --git a/utils/themeeditor/parsetreenode.cpp b/utils/themeeditor/parsetreenode.cpp
index 7530299870..99fdbd858d 100644
--- a/utils/themeeditor/parsetreenode.cpp
+++ b/utils/themeeditor/parsetreenode.cpp
@@ -25,6 +25,8 @@
25#include "parsetreenode.h" 25#include "parsetreenode.h"
26#include "parsetreemodel.h" 26#include "parsetreemodel.h"
27 27
28int ParseTreeNode::openConditionals = 0;
29
28/* Root element constructor */ 30/* Root element constructor */
29ParseTreeNode::ParseTreeNode(struct skin_element* data) 31ParseTreeNode::ParseTreeNode(struct skin_element* data)
30 : parent(0), element(0), param(0), children() 32 : parent(0), element(0), param(0), children()
@@ -117,7 +119,8 @@ QString ParseTreeNode::genCode() const
117 buffer.append(TAGSYM); 119 buffer.append(TAGSYM);
118 buffer.append(children[i]->genCode()); 120 buffer.append(children[i]->genCode());
119 } 121 }
120 buffer.append('\n'); 122 if(openConditionals == 0)
123 buffer.append('\n');
121 break; 124 break;
122 125
123 case SUBLINES: 126 case SUBLINES:
@@ -131,6 +134,7 @@ QString ParseTreeNode::genCode() const
131 break; 134 break;
132 135
133 case CONDITIONAL: 136 case CONDITIONAL:
137 openConditionals++;
134 /* Inserts a %?, the tag renderer doesn't deal with the TAGSYM */ 138 /* Inserts a %?, the tag renderer doesn't deal with the TAGSYM */
135 buffer.append(TAGSYM); 139 buffer.append(TAGSYM);
136 buffer.append(CONDITIONSYM); 140 buffer.append(CONDITIONSYM);
@@ -145,6 +149,7 @@ QString ParseTreeNode::genCode() const
145 buffer.append(ENUMLISTSEPERATESYM); 149 buffer.append(ENUMLISTSEPERATESYM);
146 } 150 }
147 buffer.append(ENUMLISTCLOSESYM); 151 buffer.append(ENUMLISTCLOSESYM);
152 openConditionals--;
148 break; 153 break;
149 154
150 case TAG: 155 case TAG:
diff --git a/utils/themeeditor/parsetreenode.h b/utils/themeeditor/parsetreenode.h
index b07024f90e..12f1d364d9 100644
--- a/utils/themeeditor/parsetreenode.h
+++ b/utils/themeeditor/parsetreenode.h
@@ -53,6 +53,8 @@ private:
53 struct skin_tag_parameter* param; 53 struct skin_tag_parameter* param;
54 QList<ParseTreeNode*> children; 54 QList<ParseTreeNode*> children;
55 55
56 static int openConditionals;
57
56}; 58};
57 59
58#endif // PARSETREENODE_H 60#endif // PARSETREENODE_H
diff --git a/utils/themeeditor/skin_parser.c b/utils/themeeditor/skin_parser.c
index 94d059bfcc..a771fe7584 100644
--- a/utils/themeeditor/skin_parser.c
+++ b/utils/themeeditor/skin_parser.c
@@ -295,6 +295,7 @@ struct skin_element* skin_parse_sublines_optional(char** document,
295 char* cursor = *document; 295 char* cursor = *document;
296 int sublines = 1; 296 int sublines = 1;
297 int i; 297 int i;
298 int nested = 0;
298 299
299 retval = skin_alloc_element(); 300 retval = skin_alloc_element();
300 retval->type = SUBLINES; 301 retval->type = SUBLINES;
@@ -311,8 +312,24 @@ struct skin_element* skin_parse_sublines_optional(char** document,
311 && !(check_viewport(cursor) && cursor != *document)) 312 && !(check_viewport(cursor) && cursor != *document))
312 { 313 {
313 if(*cursor == COMMENTSYM) 314 if(*cursor == COMMENTSYM)
315 {
314 skip_comment(&cursor); 316 skip_comment(&cursor);
317 continue;
318 }
315 319
320 if(*cursor == ENUMLISTOPENSYM && conditional)
321 {
322 nested++;
323 cursor++;
324 while(nested)
325 {
326 if(*cursor == ENUMLISTOPENSYM)
327 nested++;
328 if(*cursor == ENUMLISTCLOSESYM)
329 nested--;
330 cursor++;
331 }
332 }
316 /* Accounting for escaped subline symbols */ 333 /* Accounting for escaped subline symbols */
317 if(*cursor == TAGSYM) 334 if(*cursor == TAGSYM)
318 { 335 {
@@ -637,6 +654,7 @@ int skin_parse_conditional(struct skin_element* element, char** document)
637 struct skin_element* tag = skin_alloc_element(); /* The tag to evaluate */ 654 struct skin_element* tag = skin_alloc_element(); /* The tag to evaluate */
638 int children = 1; 655 int children = 1;
639 int i; 656 int i;
657 int nested = 0;
640 658
641 element->type = CONDITIONAL; 659 element->type = CONDITIONAL;
642 element->line = skin_line; 660 element->line = skin_line;
@@ -660,6 +678,20 @@ int skin_parse_conditional(struct skin_element* element, char** document)
660 continue; 678 continue;
661 } 679 }
662 680
681 if(*cursor == ENUMLISTOPENSYM)
682 {
683 nested++;
684 cursor++;
685 while(nested)
686 {
687 if(*cursor == ENUMLISTOPENSYM)
688 nested++;
689 if(*cursor == ENUMLISTCLOSESYM)
690 nested--;
691 cursor++;
692 }
693 }
694
663 if(*cursor == TAGSYM) 695 if(*cursor == TAGSYM)
664 { 696 {
665 cursor++; 697 cursor++;