1
0
Fork 0
forked from len0rd/rockbox

Committing FS#11345 by JdGordon. Theme editor parser now includes full tag information in the skin_element struct

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26448 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-01 16:44:52 +00:00
parent 2267bd37b2
commit 0a054b288b
6 changed files with 19 additions and 13 deletions

View file

@ -22,6 +22,7 @@
extern "C" extern "C"
{ {
#include "symbols.h" #include "symbols.h"
#include "tag_table.h"
} }
#include "parsetreenode.h" #include "parsetreenode.h"
@ -140,7 +141,7 @@ QString ParseTreeNode::genCode() const
/* When generating code, we DO NOT insert the leading TAGSYM, leave /* When generating code, we DO NOT insert the leading TAGSYM, leave
* the calling functions to handle that * the calling functions to handle that
*/ */
buffer.append(element->name); buffer.append(element->tag->name);
if(element->params_count > 0) if(element->params_count > 0)
{ {
@ -294,7 +295,7 @@ QVariant ParseTreeNode::data(int column) const
return QString(element->text); return QString(element->text);
case TAG: case TAG:
return QString(element->name); return QString(element->tag->name);
} }
} }
else if(param) else if(param)

View file

@ -25,6 +25,7 @@
#include "skin_parser.h" #include "skin_parser.h"
#include "skin_debug.h" #include "skin_debug.h"
#include "tag_table.h"
/* Global variables for debug output */ /* Global variables for debug output */
int debug_indent_level = 0; int debug_indent_level = 0;
@ -123,7 +124,8 @@ void skin_debug_tree(struct skin_element* root)
break; break;
case TAG: case TAG:
printf("[ %s tag on line %d with %d arguments\n", current->name, printf("[ %s tag on line %d with %d arguments\n",
current->tag->name,
current->line, current->params_count); current->line, current->params_count);
debug_indent_level++; debug_indent_level++;
skin_debug_params(current->params_count, current->params); skin_debug_params(current->params_count, current->params);

View file

@ -347,6 +347,7 @@ int skin_parse_tag(struct skin_element* element, char** document)
char tag_name[3]; char tag_name[3];
char* tag_args; char* tag_args;
struct tag_info *tag;
int num_args = 1; int num_args = 1;
int i; int i;
@ -361,12 +362,12 @@ int skin_parse_tag(struct skin_element* element, char** document)
tag_name[2] = '\0'; tag_name[2] = '\0';
/* First we check the two characters after the '%', then a single char */ /* First we check the two characters after the '%', then a single char */
tag_args = find_tag(tag_name); tag = find_tag(tag_name);
if(!tag_args) if(!tag)
{ {
tag_name[1] = '\0'; tag_name[1] = '\0';
tag_args = find_tag(tag_name); tag = find_tag(tag_name);
cursor++; cursor++;
} }
else else
@ -374,7 +375,7 @@ int skin_parse_tag(struct skin_element* element, char** document)
cursor += 2; cursor += 2;
} }
if(!tag_args) if(!tag)
{ {
skin_error(ILLEGAL_TAG); skin_error(ILLEGAL_TAG);
return 0; return 0;
@ -382,7 +383,8 @@ int skin_parse_tag(struct skin_element* element, char** document)
/* Copying basic tag info */ /* Copying basic tag info */
element->type = TAG; element->type = TAG;
strcpy(element->name, tag_name); element->tag = tag;
tag_args = tag->params;
element->line = skin_line; element->line = skin_line;
/* Checking for the * flag */ /* Checking for the * flag */

View file

@ -101,7 +101,7 @@ struct skin_element
char* text; char* text;
/* The tag or conditional name */ /* The tag or conditional name */
char name[3]; struct tag_info *tag;
/* Pointer to and size of an array of parameters */ /* Pointer to and size of an array of parameters */
int params_count; int params_count;

View file

@ -206,7 +206,8 @@ struct tag_info legal_tags[] =
{ SKIN_TOKEN_REC_MINUTES, "Rn" , ""}, { SKIN_TOKEN_REC_MINUTES, "Rn" , ""},
{ SKIN_TOKEN_REC_HOURS, "Rh" , ""}, { SKIN_TOKEN_REC_HOURS, "Rh" , ""},
{ SKIN_TOKEN_UNKNOWN, "" , ""} /* Keep this here to mark the end of the table */ { SKIN_TOKEN_UNKNOWN, "" , ""}
/* Keep this here to mark the end of the table */
}; };
/* A table of legal escapable characters */ /* A table of legal escapable characters */
@ -216,7 +217,7 @@ char legal_escape_characters[] = "%(,);#<|>";
* Just does a straight search through the tag table to find one by * Just does a straight search through the tag table to find one by
* the given name * the given name
*/ */
char* find_tag(char* name) struct tag_info* find_tag(char* name)
{ {
struct tag_info* current = legal_tags; struct tag_info* current = legal_tags;
@ -233,7 +234,7 @@ char* find_tag(char* name)
if(current->name[0] == '\0') if(current->name[0] == '\0')
return NULL; return NULL;
else else
return current->params; return current;
} }

View file

@ -287,7 +287,7 @@ struct tag_info
* Finds a tag by name and returns its parameter list, or an empty * Finds a tag by name and returns its parameter list, or an empty
* string if the tag is not found in the table * string if the tag is not found in the table
*/ */
char* find_tag(char* name); struct tag_info* find_tag(char* name);
/* /*
* Determines whether a character is legal to escape or not. If * Determines whether a character is legal to escape or not. If