diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-06-11 04:47:46 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-06-11 04:47:46 +0000 |
commit | b4a9564790575c645d855c23f7f2e07ae03c1c19 (patch) | |
tree | 39aa7fa77345edb78f4b4e9a9745aaf88c69f689 /utils/newparser/skin_render.c | |
parent | 45c7498f59ad2889f2120a865a51043004eddd5d (diff) | |
download | rockbox-b4a9564790575c645d855c23f7f2e07ae03c1c19.tar.gz rockbox-b4a9564790575c645d855c23f7f2e07ae03c1c19.zip |
Add my new parser playground to svn.
Currently it can load a skin, and walk the parse tree and output the tags as required. It always chooses the first value for a conditional and subline, but a good working start
there seems to be a error in the new parser if ROCKBOX is defined... need to fix that
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26757 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/newparser/skin_render.c')
-rw-r--r-- | utils/newparser/skin_render.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/utils/newparser/skin_render.c b/utils/newparser/skin_render.c new file mode 100644 index 0000000000..68dfd78949 --- /dev/null +++ b/utils/newparser/skin_render.c | |||
@@ -0,0 +1,95 @@ | |||
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 <ctype.h> | ||
26 | |||
27 | #include "skin_parser.h" | ||
28 | #include "skin_debug.h" | ||
29 | #include "tag_table.h" | ||
30 | #include "symbols.h" | ||
31 | #include "skin_scan.h" | ||
32 | |||
33 | void skin_render_alternator(struct skin_element* alternator); | ||
34 | |||
35 | /* Draw a LINE element onto the display */ | ||
36 | void skin_render_line(struct skin_element* line) | ||
37 | { | ||
38 | int i=0, value; | ||
39 | struct skin_element *child = line->children[0]; | ||
40 | while (child) | ||
41 | { | ||
42 | switch (child->type) | ||
43 | { | ||
44 | case CONDITIONAL: | ||
45 | value = 0; /* actually get it from the token :p */ | ||
46 | if (value >= child->children_count) | ||
47 | value = child->children_count-1; | ||
48 | if (child->children[value]->type == SUBLINES) | ||
49 | skin_render_alternator(child->children[value]); | ||
50 | else if (child->children[value]->type == LINE) | ||
51 | skin_render_line(child->children[value]); | ||
52 | break; | ||
53 | case TAG: | ||
54 | printf("%%%s", child->tag->name); | ||
55 | break; | ||
56 | case TEXT: | ||
57 | printf("%s", (char*)(child->data)); | ||
58 | break; | ||
59 | case COMMENT: | ||
60 | default: | ||
61 | break; | ||
62 | } | ||
63 | child = child->next; | ||
64 | } | ||
65 | printf("\n"); /* might be incorrect */ | ||
66 | } | ||
67 | |||
68 | void skin_render_alternator(struct skin_element* alternator) | ||
69 | { | ||
70 | /*TODO Choose which subline to draw */ | ||
71 | skin_render_line(alternator->children[0]); | ||
72 | } | ||
73 | |||
74 | void skin_render_viewport(struct skin_element* viewport) | ||
75 | { | ||
76 | struct skin_element *line = viewport; | ||
77 | while (line) | ||
78 | { | ||
79 | if (line->type == SUBLINES) | ||
80 | skin_render_alternator(line); | ||
81 | else if (line->type == LINE) | ||
82 | skin_render_line(line); | ||
83 | line = line->next; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | void skin_render(struct skin_element* root) | ||
88 | { | ||
89 | struct skin_element* viewport = root; | ||
90 | while (viewport) | ||
91 | { | ||
92 | skin_render_viewport(viewport->children[viewport->children_count-1]); | ||
93 | viewport = viewport->next; | ||
94 | } | ||
95 | } | ||