boolean values can now be specified in the following ways: 0, false, off resp 1, true, on (case insensitive)

SVN revision: 11864
This commit is contained in:
tsauerbeck 2004-10-13 18:07:56 +00:00 committed by tsauerbeck
parent def151b8d6
commit 5a4030f762
3 changed files with 80 additions and 43 deletions

View File

@ -104,6 +104,7 @@ char *parse_str(int n);
int parse_enum(int n, ...);
int parse_int(int n);
int parse_int_range(int n, int f, int t);
int parse_bool(int n);
double parse_float(int n);
double parse_float_range(int n, double f, double t);

View File

@ -607,7 +607,7 @@ st_collections_group_parts_part_mouse_events(void)
pc = evas_list_data(evas_list_last(edje_collections));
ep = evas_list_data(evas_list_last(pc->parts));
ep->mouse_events = parse_int_range(0, 0, 1);
ep->mouse_events = parse_bool(0);
}
static void
@ -618,7 +618,7 @@ st_collections_group_parts_part_repeat_events(void)
pc = evas_list_data(evas_list_last(edje_collections));
ep = evas_list_data(evas_list_last(pc->parts));
ep->repeat_events = parse_int_range(0, 0, 1);
ep->repeat_events = parse_bool(0);
}
static void
@ -769,7 +769,7 @@ st_collections_group_parts_part_description_visible(void)
ep = evas_list_data(evas_list_last(pc->parts));
ed = ep->default_desc;
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
ed->visible = parse_int_range(0, 0, 1);
ed->visible = parse_bool(0);
}
static void
@ -1119,7 +1119,7 @@ st_collections_group_parts_part_description_fill_smooth(void)
ep = evas_list_data(evas_list_last(pc->parts));
ed = ep->default_desc;
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
ed->fill.smooth = parse_int_range(0, 0, 1);
ed->fill.smooth = parse_bool(0);
}
static void
@ -1334,8 +1334,8 @@ st_collections_group_parts_part_description_text_fit(void)
ep = evas_list_data(evas_list_last(pc->parts));
ed = ep->default_desc;
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
ed->text.fit_x = parse_int_range(0, 0, 1);
ed->text.fit_y = parse_int_range(1, 0, 1);
ed->text.fit_x = parse_bool(0);
ed->text.fit_y = parse_bool(1);
}
static void
@ -1349,8 +1349,8 @@ st_collections_group_parts_part_description_text_min(void)
ep = evas_list_data(evas_list_last(pc->parts));
ed = ep->default_desc;
if (ep->other_desc) ed = evas_list_data(evas_list_last(ep->other_desc));
ed->text.min_x = parse_int_range(0, 0, 1);
ed->text.min_y = parse_int_range(1, 0, 1);
ed->text.min_x = parse_bool(0);
ed->text.min_y = parse_bool(1);
}
static void

View File

@ -1,3 +1,7 @@
/*
* vim:ts=8:sw=3:sts=3:noexpandtab
*/
#include "edje_cc.h"
static void new_object(void);
@ -30,6 +34,7 @@ static int _is_numf(char c);
static int _is_op1f(char c);
static int _is_op2f(char c);
static double _calcf(char op, double a, double b);
static int strstrip(const char *in, char *out, size_t size);
int line = 0;
@ -716,6 +721,42 @@ parse_int_range(int n, int f, int t)
return i;
}
int
parse_bool(int n)
{
char *str, buf[4096];
int i;
str = evas_list_nth(params, n);
if (!str)
{
fprintf(stderr, "%s: Error. %s:%i no parameter supplied as argument %i\n",
progname, file_in, line, n + 1);
exit(-1);
}
if (!strstrip(str, buf, sizeof (buf)))
{
fprintf(stderr, "%s: Error. %s:%i expression is too long\n",
progname, file_in, line);
return 0;
}
if (!strcasecmp(buf, "false") || !strcasecmp(buf, "off"))
return 0;
if (!strcasecmp(buf, "true") || !strcasecmp(buf, "on"))
return 1;
i = my_atoi(str);
if ((i < 0) || (i > 1))
{
fprintf(stderr, "%s: Error. %s:%i integer %i out of range of 0 to 1 inclusive\n",
progname, file_in, line, i);
exit(-1);
}
return i;
}
double
parse_float(int n)
{
@ -772,34 +813,19 @@ static int
my_atoi(const char * s)
{
int res = 0;
char *p, *p_in, *p_out;
char buf[4096];
if (!s)
return 0;
if (4095 < strlen(s))
if (!strstrip(s, buf, sizeof (buf)))
{
fprintf(stderr, "%s: Error. %s:%i expression is too long\n",
progname, file_in, line);
return 0;
}
/* remove spaces and tabs */
p_in = (char *)s;
p_out = buf;
while (*p_in)
{
if ((0x20 != *p_in) && (0x09 != *p_in))
{
*p_out = *p_in;
p_out++;
}
p_in++;
}
*p_out = '\0';
p = _alphai(buf, &res);
_alphai(buf, &res);
return res;
}
@ -983,35 +1009,19 @@ double
my_atof(const char * s)
{
double res = 0;
char *p, *p_in, *p_out;
char buf[4096];
if (!s)
return 0;
if (4095 < strlen(s))
if (!strstrip(s, buf, sizeof (buf)))
{
fprintf(stderr, "%s: Error. %s:%i expression is too long\n",
progname, file_in, line);
return 0;
}
/* remove spaces and tabs */
p_in = (char *)s;
p_out = buf;
while (*p_in)
{
if ((0x20 != *p_in) && (0x09 != *p_in))
{
*p_out = *p_in;
p_out++;
}
p_in++;
}
*p_out = '\0';
p = _alphaf(buf, &res);
_alphaf(buf, &res);
return res;
}
@ -1192,3 +1202,29 @@ _calcf(char op, double a, double b)
return a;
}
}
static int
strstrip(const char *in, char *out, size_t size)
{
if ((size -1 ) < strlen(in))
{
fprintf(stderr, "%s: Error. %s:%i expression is too long\n",
progname, file_in, line);
return 0;
}
/* remove spaces and tabs */
while (*in)
{
if ((0x20 != *in) && (0x09 != *in))
{
*out = *in;
out++;
}
in++;
}
*out = '\0';
return 1;
}