remove old test code

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27690 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Jonathan Gordon 2010-08-04 07:42:23 +00:00
parent 594110e962
commit 2db08d4153
6 changed files with 0 additions and 573 deletions

View file

@ -1,3 +0,0 @@
all:
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

View file

@ -1,42 +0,0 @@
# cabbie 2.0 default
# (C) 2007, Johannes Voggenthaler (Zinc Alloy)
#derived from "cabbie" (C) Yohann Misquitta
%wd
%X(wpsbackdrop-220x176x16.bmp)
%xl(A,lock-220x176x16.bmp,88,152,2)
%xl(B,battery-220x176x16.bmp,110,153,10)
%xl(C,volume-220x176x16.bmp,134,153,10)
%xl(D,shuffle-220x176x16.bmp,155,153)
%xl(E,repeat-220x176x16.bmp,182,151,4)
%xl(F,playmode-220x176x16.bmp,200,152,5)
%ax%Cl(15,32,75,75)
%pb(11,121,199,8,pb-220x176x16.bmp)
%?mh<%xd(Aa)|%xd(Ab)>
%?bp<%?bc<%xd(Ba)|%xd(Bb)>|%?bl<|%xd(Bc)|%xd(Bd)|%xd(Be)|%xd(Bf)|%xd(Bg)|%xd(Bh)|%xd(Bi)|%xd(Bj)>>
%?pv<%xd(Ca)|%xd(Cb)|%xd(Cc)|%xd(Cd)|%xd(Ce)|%xd(Cf)|%xd(Cg)|%xd(Ch)|%xd(Ci)|%xd(Cj)>
%?ps<%xd(D)>
%?mm<|%xd(Ea)|%xd(Eb)|%xd(Ec)|%xd(Ed)>
%?mp<%xd(Fa)|%xd(Fb)|%xd(Fc)|%xd(Fd)|%xd(Fe)>
#NowPlaying
%?C<%Vd(a)%C|%Vd(b)>
%ax%Vl(a,105,30,-,90,1)
%s%al%?it<%it|%fn>
%s%al%?ia<%ia|%?d(2)<%d(2)|%(root%)>>
%s%al%?id<%id|%?d(1)<%d(1)|%(root%)>>
%s%al%Sx(Next Track:)
%s%al%?It<%It|%Fn>
%Vl(b,0,30,-,90,1)
%s%ac%?it<%it|%fn>
%s%ac%?ia<%ia|%?d(2)<%d(2)|%(root%)>>
%s%ac%?id<%id|%?d(1)<%d(1)|%(root%)>>
%ac%Sx(Next Track:)
%s%ac%?It<%It|%Fn>
%V(11,130,199,20,1)
%al%pc%ac%?Sr<%pe %Sx(of) %pp|%pp %Sx(of) %pe>%ar%pr

View file

@ -1,192 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: tag_table.c 26346 2010-05-28 02:30:27Z jdgordon $
*
* Copyright (C) 2010 Jonathan Gordon
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include "symbols.h"
#include "skin_parser.h"
#include "tag_table.h"
#include "skin_structs.h"
typedef int (tag_handler)(struct skin *skin, struct skin_element* element, bool size_only);
int handle_translate_string(struct skin *skin, struct skin_element* element, bool size_only)
{
return 0;
}
int handle_this_or_next_track(struct skin *skin, struct skin_element* element, bool size_only)
{
if (element->tag->type == SKIN_TOKEN_FILE_DIRECTORY)
{
if (element->params_count != 1 || element->params[0].type_code != NUMERIC)
return -1;
//token->value.i = element->params[0].data.numeric;
}
return 0;
}
int handle_bar(struct skin *skin, struct skin_element* element, bool size_only)
{
struct progressbar bar;
/* %bar with no params is different for each one so handle that! */
if (element->params_count == 0)
{
if (size_only)
{
if (element->tag->type == SKIN_TOKEN_PROGRESSBAR)
return sizeof(struct progressbar);
else
return 0;
}
}
else
{
if (size_only)
return sizeof(struct progressbar);
}
return 0;
}
struct tag_handler_table {
enum skin_token_type type;
int flags;
tag_handler *func;
};
#define EAT_LINE_ENDING 0x01
struct tag_handler_table table[] = {
{ SKIN_TOKEN_ENABLE_THEME, EAT_LINE_ENDING, NULL },
{ SKIN_TOKEN_DISABLE_THEME, EAT_LINE_ENDING, NULL },
/* file tags */
{ SKIN_TOKEN_FILE_BITRATE , 0, handle_this_or_next_track },
{ SKIN_TOKEN_FILE_CODEC , 0, handle_this_or_next_track },
{ SKIN_TOKEN_FILE_FREQUENCY , 0, handle_this_or_next_track },
{ SKIN_TOKEN_FILE_FREQUENCY_KHZ , 0, handle_this_or_next_track },
{ SKIN_TOKEN_FILE_NAME_WITH_EXTENSION , 0, handle_this_or_next_track },
{ SKIN_TOKEN_FILE_NAME , 0, handle_this_or_next_track },
{ SKIN_TOKEN_FILE_PATH , 0, handle_this_or_next_track },
{ SKIN_TOKEN_FILE_SIZE , 0, handle_this_or_next_track },
{ SKIN_TOKEN_FILE_VBR , 0, handle_this_or_next_track },
{ SKIN_TOKEN_FILE_DIRECTORY , 0, handle_this_or_next_track },
/* track metadata */
{ SKIN_TOKEN_METADATA_ARTIST , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_COMPOSER , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_ALBUM , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_ALBUM_ARTIST , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_GROUPING , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_GENRE , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_DISC_NUMBER , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_TRACK_NUMBER , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_TRACK_TITLE , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_VERSION , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_YEAR , 0, handle_this_or_next_track },
{ SKIN_TOKEN_METADATA_COMMENT , 0, handle_this_or_next_track },
/* misc */
{ SKIN_TOKEN_TRANSLATEDSTRING, 0, handle_translate_string},
};
int handle_tree(struct skin *skin, struct skin_element* tree, struct line *line)
{
/* for later.. do this in two steps
* 1) count how much skin buffer is needed
* 2) do the actual tree->skin conversion
*/
struct skin_element* element = tree;
struct line *current_line = line;
int counter;
while (element)
{
if (element->type == VIEWPORT)
{
struct skin_element *next;
/* parse the viewport */
/* if the next element is a LINE we need to set it to eat the line ending */
next = element->children[0];
if (element->tag && next->type == LINE &&
element->line == next->line)
{
struct line *newline = (struct line*)skin_alloc(sizeof(struct line));
newline->update_mode = 0;
newline->eat_line_ending = true;
next->data = newline;
}
}
else if (element->type == LINE && !element->data)
{
struct line *line = (struct line*)skin_alloc(sizeof(struct line));
line->update_mode = 0;
line->eat_line_ending = false;
element->data = line;
current_line = line;
}
else if (element->type == SUBLINES)
{
struct subline *subline = skin_alloc(sizeof(struct subline));
subline->current_line = -1;
subline->last_change_tick = 0;
element->data = subline;
}
else if (element->type == CONDITIONAL)
{
struct conditional *cond = skin_alloc(sizeof(struct conditional));
cond->last_value = element->children_count;
element->data = cond;
}
else if (element->type == TAG)
{
int i;
for(i=0;i<sizeof(table)/sizeof(*table);i++)
{
if (table[i].type == element->tag->type)
{
if (table[i].func)
table[i].func(skin, element, false);
if (table[i].flags&EAT_LINE_ENDING)
line->eat_line_ending = true;
break;
}
}
}
else if (element->type == TEXT)
{
/* handle */
}
counter = 0;
while (counter < element->children_count)
{
int ret = handle_tree(skin, element->children[counter], current_line);
counter++;
}
/* *probably* set current_line to NULL here */
element = element->next;
}
return 0;
}

View file

@ -1,81 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: tag_table.c 26346 2010-05-28 02:30:27Z jdgordon $
*
* Copyright (C) 2010 Jonathan Gordon
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include "skin_parser.h"
#include "tag_table.h"
#include "skin_structs.h"
int handle_tree(struct skin *skin, struct skin_element* tree, struct line* line);
void skin_render(struct skin_element* root);
int main(int argc, char* argv[])
{
char buffer[10*1024], temp[512];
FILE *in;
int filearg = 1, i=0;
if( (argc < 2) ||
strcmp(argv[1],"-h") == 0 ||
strcmp(argv[1],"--help") == 0 )
{
printf("Usage: %s infile \n", argv[0]);
return 0;
}
while ((argc > filearg) && argv[filearg][0] == '-')
{
i=1;
while (argv[filearg][i])
{
switch(argv[filearg][i])
{
}
i++;
}
filearg++;
}
if (argc == filearg)
{
printf("Missing input filename\n");
return 1;
}
in = fopen(argv[filearg], "r");
if (!in)
return 1;
while (fgets(temp, 512, in))
strcat(buffer, temp);
fclose(in);
filearg++;
struct skin_element* tree = skin_parse(buffer);
struct skin skin;
handle_tree(&skin, tree, NULL);
skin_render(tree);
skin_free_tree(tree);
return 0;
}

View file

@ -1,185 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: skin_parser.c 26752 2010-06-10 21:22:16Z bieber $
*
* Copyright (C) 2010 Jonathan Gordon
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
#include "skin_parser.h"
#include "skin_debug.h"
#include "tag_table.h"
#include "symbols.h"
#include "skin_scan.h"
#include "skin_structs.h"
#define MAX_LINE 1024
typedef void (*skin_render_func)(struct skin_element* alternator,
char* buf, size_t buf_size, int line_number);
void skin_render_alternator(struct skin_element* alternator,
char* buf, size_t buf_size, int line_number);
static void do_tags_in_hidden_conditional(struct skin_element* branch)
{
/* Tags here are ones which need to be "turned off" or cleared
* if they are in a conditional branch which isnt being used */
if (branch->type == LINE_ALTERNATOR)
{
int i;
for (i=0; i<branch->children_count; i++)
{
do_tags_in_hidden_conditional(branch->children[i]);
}
}
else if (branch->type == LINE)
{
struct skin_element *child = branch->children[0];
while (child)
{
if (child->type != TAG)
{
child = child->next;
continue;
}
switch (child->tag->type)
{
case SKIN_TOKEN_PEAKMETER:
/* stop the peak meter */
break;
case SKIN_TOKEN_ALBUMART_DISPLAY:
/* clear the AA image */
break;
case SKIN_TOKEN_IMAGE_DISPLAY:
case SKIN_TOKEN_IMAGE_PRELOAD_DISPLAY:
/* clear images */
break;
default:
break;
}
child = child->next;
}
}
}
/* Draw a LINE element onto the display */
void skin_render_line(struct skin_element* line,
char* buf, size_t buf_size, int line_number)
{
int last_value, value;
if (line->children_count == 0)
return; /* empty line, do nothing */
struct skin_element *child = line->children[0];
skin_render_func func = skin_render_line;
char tempbuf[128];
while (child)
{
tempbuf[0] = '\0';
switch (child->type)
{
case CONDITIONAL:
last_value = ((struct conditional*)(child->data))->last_value;
value = 0; /* actually get it from the token :p */
if (value >= child->children_count)
value = child->children_count-1;
/* some tags need handling if they are being disabled */
if (value != last_value && last_value < child->children_count)
do_tags_in_hidden_conditional(child->children[last_value]);
last_value = value;
if (child->children[value]->type == LINE_ALTERNATOR)
func = skin_render_alternator;
else if (child->children[value]->type == LINE)
func = skin_render_line;
func(child->children[value], buf, buf_size, line_number);
break;
case TAG:
snprintf(tempbuf, sizeof(tempbuf), "%%%s", child->tag->name);
break;
case TEXT:
snprintf(tempbuf, sizeof(tempbuf), "%s", (char*)(child->data));
break;
case COMMENT:
default:
break;
}
strcat(buf, tempbuf);
child = child->next;
}
}
#define TIME_AFTER(a,b) 1
void skin_render_alternator(struct skin_element* alternator,
char* buf, size_t buf_size, int line_number)
{
struct subline *subline = (struct subline*)alternator->data;
if (TIME_AFTER(subline->last_change_tick + subline->timeout, 0/*FIXME*/))
{
subline->current_line++;
if (subline->current_line >= alternator->children_count)
subline->current_line = 0;
}
skin_render_line(alternator->children[subline->current_line],
buf, buf_size, line_number);
}
void skin_render_viewport(struct skin_element* viewport, bool draw_tags)
{
int line_number = 0;
char linebuf[MAX_LINE];
skin_render_func func = skin_render_line;
struct skin_element* line = viewport;
while (line)
{
linebuf[0] = '\0';
if (line->type == SUBLINES)
func = skin_render_alternator;
else if (line->type == LINE)
func = skin_render_line;
func(line, linebuf, sizeof(linebuf), line_number);
if (draw_tags)
{
printf("[%d]%s", line_number, linebuf);
if (!((struct line*)line->data)->eat_line_ending)
{
printf("\n");
}
}
if (!((struct line*)line->data)->eat_line_ending)
line_number++;
line = line->next;
}
}
void skin_render(struct skin_element* root)
{
struct skin_element* viewport = root;
bool draw_tags = viewport->next ? false : true;
while (viewport)
{
skin_render_viewport(viewport->children[0], draw_tags);
draw_tags = true;
viewport = viewport->next;
}
}

View file

@ -1,70 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id: tag_table.c 26346 2010-05-28 02:30:27Z jdgordon $
*
* Copyright (C) 2010 Jonathan Gordon
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include "skin_parser.h"
#include "tag_table.h"
#ifndef SKIN_STRUCTS_H_
#define SKIN_STRUCTS_H_
struct skin
{
};
struct progressbar {
enum skin_token_type type;
struct viewport *vp;
/* regular pb */
short x;
/* >=0: explicitly set in the tag -> y-coord within the viewport
<0 : not set in the tag -> negated 1-based line number within
the viewport. y-coord will be computed based on the font height */
short y;
short width;
short height;
bool follow_lang_direction;
/*progressbar image*/
// struct bitmap bm;
bool have_bitmap_pb;
};
struct line {
unsigned update_mode;
bool eat_line_ending;
};
struct subline {
int timeout;
int current_line;
unsigned long last_change_tick;
};
struct conditional {
int last_value;
};
#endif