mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
skin_parser add empty parser callback remove guard conditionals
it appears callback is only set once in skin_parse() and then its never touched again making repeatd checks pointless anyway Change-Id: Iae4cb064b17f9c4e89a3ef772110ead17332cba2
This commit is contained in:
parent
bc1d7d77c5
commit
ca79fd039c
1 changed files with 34 additions and 47 deletions
|
@ -38,8 +38,9 @@ char* skin_start = 0;
|
||||||
static int viewport_line = 0;
|
static int viewport_line = 0;
|
||||||
|
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
static skin_callback callback = NULL;
|
static int empty_callback(struct skin_element* element, void* data);
|
||||||
static void* callback_data;
|
static skin_callback callback = &empty_callback;
|
||||||
|
static void* callback_data = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Auxiliary parsing functions (not visible at global scope) */
|
/* Auxiliary parsing functions (not visible at global scope) */
|
||||||
|
@ -71,6 +72,13 @@ static void skip_whitespace(const char** document)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
|
static int empty_callback(struct skin_element* element, void* data)
|
||||||
|
{
|
||||||
|
(void)element;
|
||||||
|
(void)data;
|
||||||
|
return CALLBACK_OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct skin_element* skin_parse(const char* document,
|
struct skin_element* skin_parse(const char* document,
|
||||||
skin_callback cb, void* cb_data)
|
skin_callback cb, void* cb_data)
|
||||||
{
|
{
|
||||||
|
@ -153,7 +161,7 @@ static struct skin_element* skin_parse_viewport(const char** document)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
else if (callback)
|
else
|
||||||
{
|
{
|
||||||
if (callback(retval, callback_data) == CALLBACK_ERROR)
|
if (callback(retval, callback_data) == CALLBACK_ERROR)
|
||||||
{
|
{
|
||||||
|
@ -331,16 +339,10 @@ static struct skin_element* skin_parse_line_optional(const char** document,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
if (callback)
|
if (callback(retval, callback_data) == CALLBACK_ERROR)
|
||||||
{
|
{
|
||||||
switch (callback(retval, callback_data))
|
skin_error(GOT_CALLBACK_ERROR, cursor);
|
||||||
{
|
return NULL;
|
||||||
case CALLBACK_ERROR:
|
|
||||||
skin_error(GOT_CALLBACK_ERROR, cursor);
|
|
||||||
return NULL;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -480,13 +482,10 @@ static struct skin_element* skin_parse_sublines_optional(const char** document,
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
if (callback)
|
if (callback(retval, callback_data) == CALLBACK_ERROR)
|
||||||
{
|
{
|
||||||
if (callback(retval, callback_data) == CALLBACK_ERROR)
|
skin_error(GOT_CALLBACK_ERROR, *document);
|
||||||
{
|
return NULL;
|
||||||
skin_error(GOT_CALLBACK_ERROR, *document);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*document = cursor;
|
*document = cursor;
|
||||||
|
@ -542,13 +541,10 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
if (callback)
|
if (callback(element, callback_data) == CALLBACK_ERROR)
|
||||||
{
|
{
|
||||||
if (callback(element, callback_data) == CALLBACK_ERROR)
|
skin_error(GOT_CALLBACK_ERROR, cursor);
|
||||||
{
|
return 0;
|
||||||
skin_error(GOT_CALLBACK_ERROR, cursor);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*document = cursor;
|
*document = cursor;
|
||||||
|
@ -826,13 +822,10 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
if (callback)
|
if (callback(element, callback_data) == CALLBACK_ERROR)
|
||||||
{
|
{
|
||||||
if (callback(element, callback_data) == CALLBACK_ERROR)
|
skin_error(GOT_CALLBACK_ERROR, *document);
|
||||||
{
|
return 0;
|
||||||
skin_error(GOT_CALLBACK_ERROR, *document);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*document = cursor;
|
*document = cursor;
|
||||||
|
@ -897,13 +890,10 @@ static int skin_parse_text(struct skin_element* element, const char** document,
|
||||||
text[length] = '\0';
|
text[length] = '\0';
|
||||||
|
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
if (callback)
|
if (callback(element, callback_data) == CALLBACK_ERROR)
|
||||||
{
|
{
|
||||||
if (callback(element, callback_data) == CALLBACK_ERROR)
|
skin_error(GOT_CALLBACK_ERROR, *document);
|
||||||
{
|
return 0;
|
||||||
skin_error(GOT_CALLBACK_ERROR, *document);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -940,18 +930,15 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc
|
||||||
|
|
||||||
element->type = CONDITIONAL;
|
element->type = CONDITIONAL;
|
||||||
#ifdef ROCKBOX
|
#ifdef ROCKBOX
|
||||||
if (callback)
|
switch (callback(element, callback_data))
|
||||||
{
|
{
|
||||||
switch (callback(element, callback_data))
|
case FEATURE_NOT_AVAILABLE:
|
||||||
{
|
feature_available = false;
|
||||||
case FEATURE_NOT_AVAILABLE:
|
break;
|
||||||
feature_available = false;
|
case CALLBACK_ERROR:
|
||||||
break;
|
return 0;
|
||||||
case CALLBACK_ERROR:
|
default:
|
||||||
return 0;
|
break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue