summaryrefslogtreecommitdiffstats
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.tar.bz2
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 @@
#include "parsetreenode.h"
#include "parsetreemodel.h"
+int ParseTreeNode::openConditionals = 0;
+
/* Root element constructor */
ParseTreeNode::ParseTreeNode(struct skin_element* data)
: parent(0), element(0), param(0), children()
@@ -117,7 +119,8 @@ QString ParseTreeNode::genCode() const
buffer.append(TAGSYM);
buffer.append(children[i]->genCode());
}
- buffer.append('\n');
+ if(openConditionals == 0)
+ buffer.append('\n');
break;
case SUBLINES:
@@ -131,6 +134,7 @@ QString ParseTreeNode::genCode() const
break;
case CONDITIONAL:
+ openConditionals++;
/* Inserts a %?, the tag renderer doesn't deal with the TAGSYM */
buffer.append(TAGSYM);
buffer.append(CONDITIONSYM);
@@ -145,6 +149,7 @@ QString ParseTreeNode::genCode() const
buffer.append(ENUMLISTSEPERATESYM);
}
buffer.append(ENUMLISTCLOSESYM);
+ openConditionals--;
break;
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:
struct skin_tag_parameter* param;
QList<ParseTreeNode*> children;
+ static int openConditionals;
+
};
#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,
char* cursor = *document;
int sublines = 1;
int i;
+ int nested = 0;
retval = skin_alloc_element();
retval->type = SUBLINES;
@@ -311,8 +312,24 @@ struct skin_element* skin_parse_sublines_optional(char** document,
&& !(check_viewport(cursor) && cursor != *document))
{
if(*cursor == COMMENTSYM)
+ {
skip_comment(&cursor);
+ continue;
+ }
+ if(*cursor == ENUMLISTOPENSYM && conditional)
+ {
+ nested++;
+ cursor++;
+ while(nested)
+ {
+ if(*cursor == ENUMLISTOPENSYM)
+ nested++;
+ if(*cursor == ENUMLISTCLOSESYM)
+ nested--;
+ cursor++;
+ }
+ }
/* Accounting for escaped subline symbols */
if(*cursor == TAGSYM)
{
@@ -637,6 +654,7 @@ int skin_parse_conditional(struct skin_element* element, char** document)
struct skin_element* tag = skin_alloc_element(); /* The tag to evaluate */
int children = 1;
int i;
+ int nested = 0;
element->type = CONDITIONAL;
element->line = skin_line;
@@ -660,6 +678,20 @@ int skin_parse_conditional(struct skin_element* element, char** document)
continue;
}
+ if(*cursor == ENUMLISTOPENSYM)
+ {
+ nested++;
+ cursor++;
+ while(nested)
+ {
+ if(*cursor == ENUMLISTOPENSYM)
+ nested++;
+ if(*cursor == ENUMLISTCLOSESYM)
+ nested--;
+ cursor++;
+ }
+ }
+
if(*cursor == TAGSYM)
{
cursor++;