summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-08-04 07:42:23 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-08-04 07:42:23 +0000
commit2db08d41536b875f35b055f8e0bb3845b47a7ba3 (patch)
tree04545c559174cba9f6cdf5ae295d58c0d729a40b
parent594110e962831b0d8ae2ded7efc49d48e4a6c3eb (diff)
downloadrockbox-2db08d41536b875f35b055f8e0bb3845b47a7ba3.tar.gz
rockbox-2db08d41536b875f35b055f8e0bb3845b47a7ba3.zip
remove old test code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27690 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/newparser/Makefile3
-rw-r--r--utils/newparser/cabbiev2.220x176x16.wps42
-rw-r--r--utils/newparser/handle_tags.c192
-rw-r--r--utils/newparser/newparser.c81
-rw-r--r--utils/newparser/skin_render.c185
-rw-r--r--utils/newparser/skin_structs.h70
6 files changed, 0 insertions, 573 deletions
diff --git a/utils/newparser/Makefile b/utils/newparser/Makefile
deleted file mode 100644
index 581a18f66a..0000000000
--- a/utils/newparser/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
1all:
2 gcc -I. -I../themeeditor -g -Wall -o newparser newparser.c handle_tags.c skin_render.c ../themeeditor/skin_parser.c ../themeeditor/skin_scan.c ../themeeditor/skin_debug.c ../themeeditor/tag_table.c
3
diff --git a/utils/newparser/cabbiev2.220x176x16.wps b/utils/newparser/cabbiev2.220x176x16.wps
deleted file mode 100644
index 764a506e1f..0000000000
--- a/utils/newparser/cabbiev2.220x176x16.wps
+++ /dev/null
@@ -1,42 +0,0 @@
1# cabbie 2.0 default
2# (C) 2007, Johannes Voggenthaler (Zinc Alloy)
3#derived from "cabbie" (C) Yohann Misquitta
4%wd
5%X(wpsbackdrop-220x176x16.bmp)
6%xl(A,lock-220x176x16.bmp,88,152,2)
7%xl(B,battery-220x176x16.bmp,110,153,10)
8%xl(C,volume-220x176x16.bmp,134,153,10)
9%xl(D,shuffle-220x176x16.bmp,155,153)
10%xl(E,repeat-220x176x16.bmp,182,151,4)
11%xl(F,playmode-220x176x16.bmp,200,152,5)
12%ax%Cl(15,32,75,75)
13%pb(11,121,199,8,pb-220x176x16.bmp)
14%?mh<%xd(Aa)|%xd(Ab)>
15%?bp<%?bc<%xd(Ba)|%xd(Bb)>|%?bl<|%xd(Bc)|%xd(Bd)|%xd(Be)|%xd(Bf)|%xd(Bg)|%xd(Bh)|%xd(Bi)|%xd(Bj)>>
16%?pv<%xd(Ca)|%xd(Cb)|%xd(Cc)|%xd(Cd)|%xd(Ce)|%xd(Cf)|%xd(Cg)|%xd(Ch)|%xd(Ci)|%xd(Cj)>
17%?ps<%xd(D)>
18%?mm<|%xd(Ea)|%xd(Eb)|%xd(Ec)|%xd(Ed)>
19%?mp<%xd(Fa)|%xd(Fb)|%xd(Fc)|%xd(Fd)|%xd(Fe)>
20
21#NowPlaying
22%?C<%Vd(a)%C|%Vd(b)>
23
24%ax%Vl(a,105,30,-,90,1)
25%s%al%?it<%it|%fn>
26%s%al%?ia<%ia|%?d(2)<%d(2)|%(root%)>>
27%s%al%?id<%id|%?d(1)<%d(1)|%(root%)>>
28
29%s%al%Sx(Next Track:)
30%s%al%?It<%It|%Fn>
31
32%Vl(b,0,30,-,90,1)
33%s%ac%?it<%it|%fn>
34%s%ac%?ia<%ia|%?d(2)<%d(2)|%(root%)>>
35%s%ac%?id<%id|%?d(1)<%d(1)|%(root%)>>
36
37%ac%Sx(Next Track:)
38%s%ac%?It<%It|%Fn>
39
40
41%V(11,130,199,20,1)
42%al%pc%ac%?Sr<%pe %Sx(of) %pp|%pp %Sx(of) %pe>%ar%pr
diff --git a/utils/newparser/handle_tags.c b/utils/newparser/handle_tags.c
deleted file mode 100644
index c7c1289183..0000000000
--- a/utils/newparser/handle_tags.c
+++ /dev/null
@@ -1,192 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: tag_table.c 26346 2010-05-28 02:30:27Z jdgordon $
9 *
10 * Copyright (C) 2010 Jonathan Gordon
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <stdbool.h>
25#include <stdint.h>
26#include <string.h>
27#include <ctype.h>
28
29#include "symbols.h"
30#include "skin_parser.h"
31#include "tag_table.h"
32#include "skin_structs.h"
33
34typedef int (tag_handler)(struct skin *skin, struct skin_element* element, bool size_only);
35
36
37
38int handle_translate_string(struct skin *skin, struct skin_element* element, bool size_only)
39{
40 return 0;
41}
42
43int handle_this_or_next_track(struct skin *skin, struct skin_element* element, bool size_only)
44{
45 if (element->tag->type == SKIN_TOKEN_FILE_DIRECTORY)
46 {
47 if (element->params_count != 1 || element->params[0].type_code != NUMERIC)
48 return -1;
49 //token->value.i = element->params[0].data.numeric;
50 }
51 return 0;
52}
53
54int handle_bar(struct skin *skin, struct skin_element* element, bool size_only)
55{
56 struct progressbar bar;
57 /* %bar with no params is different for each one so handle that! */
58 if (element->params_count == 0)
59 {
60 if (size_only)
61 {
62 if (element->tag->type == SKIN_TOKEN_PROGRESSBAR)
63 return sizeof(struct progressbar);
64 else
65 return 0;
66 }
67 }
68 else
69 {
70 if (size_only)
71 return sizeof(struct progressbar);
72 }
73
74 return 0;
75}
76
77struct tag_handler_table {
78 enum skin_token_type type;
79 int flags;
80 tag_handler *func;
81};
82#define EAT_LINE_ENDING 0x01
83
84struct tag_handler_table table[] = {
85 { SKIN_TOKEN_ENABLE_THEME, EAT_LINE_ENDING, NULL },
86 { SKIN_TOKEN_DISABLE_THEME, EAT_LINE_ENDING, NULL },
87 /* file tags */
88 { SKIN_TOKEN_FILE_BITRATE , 0, handle_this_or_next_track },
89 { SKIN_TOKEN_FILE_CODEC , 0, handle_this_or_next_track },
90 { SKIN_TOKEN_FILE_FREQUENCY , 0, handle_this_or_next_track },
91 { SKIN_TOKEN_FILE_FREQUENCY_KHZ , 0, handle_this_or_next_track },
92 { SKIN_TOKEN_FILE_NAME_WITH_EXTENSION , 0, handle_this_or_next_track },
93 { SKIN_TOKEN_FILE_NAME , 0, handle_this_or_next_track },
94 { SKIN_TOKEN_FILE_PATH , 0, handle_this_or_next_track },
95 { SKIN_TOKEN_FILE_SIZE , 0, handle_this_or_next_track },
96 { SKIN_TOKEN_FILE_VBR , 0, handle_this_or_next_track },
97 { SKIN_TOKEN_FILE_DIRECTORY , 0, handle_this_or_next_track },
98 /* track metadata */
99 { SKIN_TOKEN_METADATA_ARTIST , 0, handle_this_or_next_track },
100 { SKIN_TOKEN_METADATA_COMPOSER , 0, handle_this_or_next_track },
101 { SKIN_TOKEN_METADATA_ALBUM , 0, handle_this_or_next_track },
102 { SKIN_TOKEN_METADATA_ALBUM_ARTIST , 0, handle_this_or_next_track },
103 { SKIN_TOKEN_METADATA_GROUPING , 0, handle_this_or_next_track },
104 { SKIN_TOKEN_METADATA_GENRE , 0, handle_this_or_next_track },
105 { SKIN_TOKEN_METADATA_DISC_NUMBER , 0, handle_this_or_next_track },
106 { SKIN_TOKEN_METADATA_TRACK_NUMBER , 0, handle_this_or_next_track },
107 { SKIN_TOKEN_METADATA_TRACK_TITLE , 0, handle_this_or_next_track },
108 { SKIN_TOKEN_METADATA_VERSION , 0, handle_this_or_next_track },
109 { SKIN_TOKEN_METADATA_YEAR , 0, handle_this_or_next_track },
110 { SKIN_TOKEN_METADATA_COMMENT , 0, handle_this_or_next_track },
111 /* misc */
112 { SKIN_TOKEN_TRANSLATEDSTRING, 0, handle_translate_string},
113};
114
115int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line)
116{
117 /* for later.. do this in two steps
118 * 1) count how much skin buffer is needed
119 * 2) do the actual tree->skin conversion
120 */
121 struct skin_element* element = tree;
122 struct line *current_line = line;
123 int counter;
124 while (element)
125 {
126 if (element->type == VIEWPORT)
127 {
128 struct skin_element *next;
129 /* parse the viewport */
130 /* if the next element is a LINE we need to set it to eat the line ending */
131 next = element->children[0];
132 if (element->tag && next->type == LINE &&
133 element->line == next->line)
134 {
135 struct line *newline = (struct line*)skin_alloc(sizeof(struct line));
136 newline->update_mode = 0;
137 newline->eat_line_ending = true;
138 next->data = newline;
139 }
140 }
141 else if (element->type == LINE && !element->data)
142 {
143 struct line *line = (struct line*)skin_alloc(sizeof(struct line));
144 line->update_mode = 0;
145 line->eat_line_ending = false;
146 element->data = line;
147 current_line = line;
148 }
149 else if (element->type == SUBLINES)
150 {
151 struct subline *subline = skin_alloc(sizeof(struct subline));
152 subline->current_line = -1;
153 subline->last_change_tick = 0;
154 element->data = subline;
155 }
156 else if (element->type == CONDITIONAL)
157 {
158 struct conditional *cond = skin_alloc(sizeof(struct conditional));
159 cond->last_value = element->children_count;
160 element->data = cond;
161 }
162 else if (element->type == TAG)
163 {
164 int i;
165 for(i=0;i<sizeof(table)/sizeof(*table);i++)
166 {
167 if (table[i].type == element->tag->type)
168 {
169 if (table[i].func)
170 table[i].func(skin, element, false);
171 if (table[i].flags&EAT_LINE_ENDING)
172 line->eat_line_ending = true;
173 break;
174 }
175 }
176 }
177 else if (element->type == TEXT)
178 {
179 /* handle */
180 }
181
182 counter = 0;
183 while (counter < element->children_count)
184 {
185 int ret = handle_tree(skin, element->children[counter], current_line);
186 counter++;
187 }
188 /* *probably* set current_line to NULL here */
189 element = element->next;
190 }
191 return 0;
192}
diff --git a/utils/newparser/newparser.c b/utils/newparser/newparser.c
deleted file mode 100644
index f56fe6db84..0000000000
--- a/utils/newparser/newparser.c
+++ /dev/null
@@ -1,81 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: tag_table.c 26346 2010-05-28 02:30:27Z jdgordon $
9 *
10 * Copyright (C) 2010 Jonathan Gordon
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <stdbool.h>
25#include <string.h>
26#include <ctype.h>
27
28#include "skin_parser.h"
29#include "tag_table.h"
30#include "skin_structs.h"
31
32int handle_tree(struct skin *skin, struct skin_element* tree, struct line* line);
33void skin_render(struct skin_element* root);
34
35int main(int argc, char* argv[])
36{
37 char buffer[10*1024], temp[512];
38 FILE *in;
39 int filearg = 1, i=0;
40 if( (argc < 2) ||
41 strcmp(argv[1],"-h") == 0 ||
42 strcmp(argv[1],"--help") == 0 )
43 {
44 printf("Usage: %s infile \n", argv[0]);
45 return 0;
46 }
47
48 while ((argc > filearg) && argv[filearg][0] == '-')
49 {
50 i=1;
51 while (argv[filearg][i])
52 {
53 switch(argv[filearg][i])
54 {
55 }
56 i++;
57 }
58 filearg++;
59 }
60 if (argc == filearg)
61 {
62 printf("Missing input filename\n");
63 return 1;
64 }
65
66 in = fopen(argv[filearg], "r");
67 if (!in)
68 return 1;
69 while (fgets(temp, 512, in))
70 strcat(buffer, temp);
71 fclose(in);
72 filearg++;
73
74 struct skin_element* tree = skin_parse(buffer);
75 struct skin skin;
76 handle_tree(&skin, tree, NULL);
77 skin_render(tree);
78
79 skin_free_tree(tree);
80 return 0;
81}
diff --git a/utils/newparser/skin_render.c b/utils/newparser/skin_render.c
deleted file mode 100644
index 09c9ca1355..0000000000
--- a/utils/newparser/skin_render.c
+++ /dev/null
@@ -1,185 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: skin_parser.c 26752 2010-06-10 21:22:16Z bieber $
9 *
10 * Copyright (C) 2010 Jonathan Gordon
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdlib.h>
23#include <stdio.h>
24#include <string.h>
25#include <stdbool.h>
26#include <ctype.h>
27
28#include "skin_parser.h"
29#include "skin_debug.h"
30#include "tag_table.h"
31#include "symbols.h"
32#include "skin_scan.h"
33#include "skin_structs.h"
34
35#define MAX_LINE 1024
36
37typedef void (*skin_render_func)(struct skin_element* alternator,
38 char* buf, size_t buf_size, int line_number);
39void skin_render_alternator(struct skin_element* alternator,
40 char* buf, size_t buf_size, int line_number);
41
42static void do_tags_in_hidden_conditional(struct skin_element* branch)
43{
44 /* Tags here are ones which need to be "turned off" or cleared
45 * if they are in a conditional branch which isnt being used */
46 if (branch->type == LINE_ALTERNATOR)
47 {
48 int i;
49 for (i=0; i<branch->children_count; i++)
50 {
51 do_tags_in_hidden_conditional(branch->children[i]);
52 }
53 }
54 else if (branch->type == LINE)
55 {
56 struct skin_element *child = branch->children[0];
57 while (child)
58 {
59 if (child->type != TAG)
60 {
61 child = child->next;
62 continue;
63 }
64 switch (child->tag->type)
65 {
66 case SKIN_TOKEN_PEAKMETER:
67 /* stop the peak meter */
68 break;
69 case SKIN_TOKEN_ALBUMART_DISPLAY:
70 /* clear the AA image */
71 break;
72 case SKIN_TOKEN_IMAGE_DISPLAY:
73 case SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY:
74 /* clear images */
75 break;
76 default:
77 break;
78 }
79 child = child->next;
80 }
81 }
82}
83
84
85/* Draw a LINE element onto the display */
86void skin_render_line(struct skin_element* line,
87 char* buf, size_t buf_size, int line_number)
88{
89 int last_value, value;
90 if (line->children_count == 0)
91 return; /* empty line, do nothing */
92 struct skin_element *child = line->children[0];
93 skin_render_func func = skin_render_line;
94 char tempbuf[128];
95 while (child)
96 {
97 tempbuf[0] = '\0';
98 switch (child->type)
99 {
100 case CONDITIONAL:
101 last_value = ((struct conditional*)(child->data))->last_value;
102 value = 0; /* actually get it from the token :p */
103 if (value >= child->children_count)
104 value = child->children_count-1;
105
106 /* some tags need handling if they are being disabled */
107 if (value != last_value && last_value < child->children_count)
108 do_tags_in_hidden_conditional(child->children[last_value]);
109 last_value = value;
110
111 if (child->children[value]->type == LINE_ALTERNATOR)
112 func = skin_render_alternator;
113 else if (child->children[value]->type == LINE)
114 func = skin_render_line;
115 func(child->children[value], buf, buf_size, line_number);
116 break;
117 case TAG:
118 snprintf(tempbuf, sizeof(tempbuf), "%%%s", child->tag->name);
119 break;
120 case TEXT:
121 snprintf(tempbuf, sizeof(tempbuf), "%s", (char*)(child->data));
122 break;
123 case COMMENT:
124 default:
125 break;
126 }
127 strcat(buf, tempbuf);
128 child = child->next;
129 }
130}
131#define TIME_AFTER(a,b) 1
132void skin_render_alternator(struct skin_element* alternator,
133 char* buf, size_t buf_size, int line_number)
134{
135 struct subline *subline = (struct subline*)alternator->data;
136 if (TIME_AFTER(subline->last_change_tick + subline->timeout, 0/*FIXME*/))
137 {
138 subline->current_line++;
139 if (subline->current_line >= alternator->children_count)
140 subline->current_line = 0;
141 }
142 skin_render_line(alternator->children[subline->current_line],
143 buf, buf_size, line_number);
144}
145
146void skin_render_viewport(struct skin_element* viewport, bool draw_tags)
147{
148 int line_number = 0;
149 char linebuf[MAX_LINE];
150 skin_render_func func = skin_render_line;
151 struct skin_element* line = viewport;
152 while (line)
153 {
154 linebuf[0] = '\0';
155 if (line->type == SUBLINES)
156 func = skin_render_alternator;
157 else if (line->type == LINE)
158 func = skin_render_line;
159
160 func(line, linebuf, sizeof(linebuf), line_number);
161 if (draw_tags)
162 {
163 printf("[%d]%s", line_number, linebuf);
164 if (!((struct line*)line->data)->eat_line_ending)
165 {
166 printf("\n");
167 }
168 }
169 if (!((struct line*)line->data)->eat_line_ending)
170 line_number++;
171 line = line->next;
172 }
173}
174
175void skin_render(struct skin_element* root)
176{
177 struct skin_element* viewport = root;
178 bool draw_tags = viewport->next ? false : true;
179 while (viewport)
180 {
181 skin_render_viewport(viewport->children[0], draw_tags);
182 draw_tags = true;
183 viewport = viewport->next;
184 }
185}
diff --git a/utils/newparser/skin_structs.h b/utils/newparser/skin_structs.h
deleted file mode 100644
index 4fc333c500..0000000000
--- a/utils/newparser/skin_structs.h
+++ /dev/null
@@ -1,70 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: tag_table.c 26346 2010-05-28 02:30:27Z jdgordon $
9 *
10 * Copyright (C) 2010 Jonathan Gordon
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdio.h>
23#include <stdlib.h>
24#include <stdbool.h>
25#include <string.h>
26#include <ctype.h>
27
28#include "skin_parser.h"
29#include "tag_table.h"
30#ifndef SKIN_STRUCTS_H_
31#define SKIN_STRUCTS_H_
32struct skin
33{
34};
35
36
37struct progressbar {
38 enum skin_token_type type;
39 struct viewport *vp;
40 /* regular pb */
41 short x;
42 /* >=0: explicitly set in the tag -> y-coord within the viewport
43 <0 : not set in the tag -> negated 1-based line number within
44 the viewport. y-coord will be computed based on the font height */
45 short y;
46 short width;
47 short height;
48 bool follow_lang_direction;
49 /*progressbar image*/
50 // struct bitmap bm;
51 bool have_bitmap_pb;
52};
53
54struct line {
55 unsigned update_mode;
56 bool eat_line_ending;
57};
58
59struct subline {
60 int timeout;
61 int current_line;
62 unsigned long last_change_tick;
63};
64
65struct conditional {
66 int last_value;
67};
68
69
70#endif