17
#include <Ecore_File.h>
20
# define EPP_EXT ".exe"
25
#define SKIP_NAMESPACE_VALIDATION_SUPPORTED " -DSKIP_NAMESPACE_VALIDATION=1 "
27
#define EDJE_1_18_SUPPORTED " -DEFL_VERSION_1_18=1 "
28
#define EDJE_1_19_SUPPORTED " -DEFL_VERSION_1_19=1 "
29
#define EDJE_1_20_SUPPORTED " -DEFL_VERSION_1_20=1 "
30
#define EDJE_1_21_SUPPORTED " -DEFL_VERSION_1_21=1 "
31
#define EDJE_1_22_SUPPORTED " -DEFL_VERSION_1_22=1 "
32
#define EDJE_1_23_SUPPORTED " -DEFL_VERSION_1_23=1 "
33
#define EDJE_1_24_SUPPORTED " -DEFL_VERSION_1_24=1 "
34
#define EDJE_1_25_SUPPORTED " -DEFL_VERSION_1_25=1 "
35
#define EDJE_1_26_SUPPORTED " -DEFL_VERSION_1_26=1 "
37
#define EDJE_CC_EFL_VERSION_SUPPORTED \
48
static void new_object(void);
49
static void new_statement(void);
50
static char *perform_math(char *input);
51
static int isdelim(char c);
52
static char *next_token(char *p, char *end, char **new_p, int *delim);
53
static const char *stack_id(void);
54
static void parse(char *data, off_t size);
57
static int my_atoi(const char *s);
58
static char *_alphai(char *s, int *val);
59
static char *_betai(char *s, int *val);
60
static char *_gammai(char *s, int *val);
61
static char *_deltai(char *s, int *val);
62
static char *_get_numi(char *s, int *val);
63
static int _is_numi(char c);
64
static int _is_op1i(char c);
65
static int _is_op2i(char c);
66
static int _calci(char op, int a, int b);
68
static double my_atof(const char *s);
69
static char *_alphaf(char *s, double *val);
70
static char *_betaf(char *s, double *val);
71
static char *_gammaf(char *s, double *val);
72
static char *_deltaf(char *s, double *val);
73
static char *_get_numf(char *s, double *val);
74
static int _is_numf(char c);
75
static int _is_op1f(char c);
76
static int _is_op2f(char c);
77
static double _calcf(char op, double a, double b);
78
static int strstrip(const char *in, char *out, size_t size);
81
Eina_List *stack = NULL;
86
static char file_buf[4096];
87
static int did_wildcard = 0;
88
static int verbatim = 0;
89
static int verbatim_line1 = 0;
90
static int verbatim_line2 = 0;
91
static char *verbatim_str = NULL;
92
static Eina_Strbuf *stack_buf = NULL;
101
ERR("PARSE STACK:\n%s", s);
103
ERR("NO PARSE STACK");
109
Eina_Array_Iterator iterator;
114
EINA_ARRAY_ITER_NEXT(¶ms, i, p, iterator)
128
_parse_param_get(int n)
130
if (n < (int)eina_array_count(¶ms))
131
return eina_array_data_get(¶ms, n);
135
static Eina_Hash *_new_object_hash = NULL;
136
static Eina_Hash *_new_object_short_hash = NULL;
137
static Eina_Hash *_new_statement_hash = NULL;
138
static Eina_Hash *_new_statement_short_hash = NULL;
139
static Eina_Hash *_new_statement_short_single_hash = NULL;
140
static Eina_Hash *_new_nested_hash = NULL;
141
static Eina_Hash *_new_nested_short_hash = NULL;
143
fill_object_statement_hashes(void)
147
if (_new_object_hash) return;
149
_new_object_hash = eina_hash_string_superfast_new(NULL);
150
_new_object_short_hash = eina_hash_string_superfast_new(NULL);
151
_new_statement_hash = eina_hash_string_superfast_new(NULL);
152
_new_statement_short_hash = eina_hash_string_superfast_new(NULL);
153
_new_statement_short_single_hash = eina_hash_string_superfast_new(NULL);
154
_new_nested_hash = eina_hash_string_superfast_new(NULL);
155
_new_nested_short_hash = eina_hash_string_superfast_new(NULL);
157
n = object_handler_num();
158
for (i = 0; i < n; i++)
160
eina_hash_direct_add(_new_object_hash, object_handlers[i].type,
161
&(object_handlers[i]));
163
n = object_handler_short_num();
164
for (i = 0; i < n; i++)
166
eina_hash_direct_add(_new_object_short_hash, object_handlers_short[i].type,
167
&(object_handlers_short[i]));
169
n = statement_handler_num();
170
for (i = 0; i < n; i++)
172
eina_hash_direct_add(_new_statement_hash, statement_handlers[i].type,
173
&(statement_handlers[i]));
175
n = statement_handler_short_num();
176
for (i = 0; i < n; i++)
178
eina_hash_direct_add(_new_statement_short_hash, statement_handlers_short[i].type,
179
&(statement_handlers_short[i]));
181
n = statement_handler_short_single_num();
182
for (i = 0; i < n; i++)
184
eina_hash_direct_add(_new_statement_short_single_hash, statement_handlers_short_single[i].type,
185
&(statement_handlers_short_single[i]));
187
n = nested_handler_num();
188
for (i = 0; i < n; i++)
190
eina_hash_direct_add(_new_nested_hash, nested_handlers[i].type,
191
&(nested_handlers[i]));
193
n = nested_handler_short_num();
194
for (i = 0; i < n; i++)
196
eina_hash_direct_add(_new_nested_short_hash, nested_handlers_short[i].type,
197
&(nested_handlers_short[i]));
202
stack_dup_wildcard(void)
204
char buf[PATH_MAX] = { 0, };
207
strncpy(buf, stack_id(), sizeof(buf) - 1);
209
end = strrchr(buf, '.');
215
return eina_strdup(buf);
222
New_Object_Handler *oh = NULL;
223
New_Statement_Handler *sh;
225
fill_object_statement_hashes();
229
oh = eina_hash_find(_new_object_hash, id);
231
oh = eina_hash_find(_new_object_short_hash, id);
235
if (oh->func) oh->func();
239
did_wildcard = edje_cc_handlers_wildcard();
242
sh = eina_hash_find(_new_statement_hash, id);
244
sh = eina_hash_find(_new_statement_short_hash, id);
246
sh = eina_hash_find(_new_statement_short_single_hash, id);
249
char *tmp = stack_dup_wildcard();
250
sh = eina_hash_find(_new_statement_hash, tmp);
253
if ((!sh) && (!did_wildcard) && (!had_quote))
255
ERR("%s:%i unhandled keyword %s",
257
(char *)eina_list_data_get(eina_list_last(stack)));
270
New_Statement_Handler *sh = NULL;
271
fill_object_statement_hashes();
273
sh = eina_hash_find(_new_statement_hash, id);
275
sh = eina_hash_find(_new_statement_short_hash, id);
278
if (sh->func) sh->func();
282
char *tmp = stack_dup_wildcard();
283
sh = eina_hash_find(_new_statement_hash, tmp);
288
if (sh->func) sh->func();
292
ERR("%s:%i unhandled keyword %s",
294
(char *)eina_list_data_get(eina_list_last(stack)));
302
new_statement_single(void)
305
New_Statement_Handler *sh = NULL;
306
fill_object_statement_hashes();
308
sh = eina_hash_find(_new_statement_short_single_hash, id);
311
if (sh->func) sh->func();
317
perform_math(char *input)
330
res = my_atof(input);
331
snprintf(buf, sizeof (buf), "%lf", res);
338
const char *delims = "{},;:[]";
344
if (c == *d) return 1;
351
next_token(char *p, char *end, char **new_p, int *delim)
353
char *tok_start = NULL, *tok_end = NULL, *tok = NULL, *sa_start = NULL;
357
int in_comment_ss = 0;
358
int in_comment_cpp = 0;
359
int in_comment_sa = 0;
365
if (p >= end) return NULL;
374
if ((!in_comment_ss) && (!in_comment_sa))
376
if ((!in_quote) && (*p == '/') && (p < (end - 1)) && (*(p + 1) == '/'))
378
if ((!in_quote) && (*p == '#'))
380
if ((!in_quote) && (*p == '/') && (p < (end - 1)) && (*(p + 1) == '*'))
386
if ((in_comment_cpp) && (*p == '#'))
398
while ((pp < end) && (*pp != '\n'))
403
tmpstr = alloca(l + 1);
404
memcpy(tmpstr, p, l);
406
if (l >= (int)sizeof(fl))
408
ERR("Line too long: %i chars: %s", l, tmpstr);
412
l = sscanf(tmpstr, "%*s %i \"%[^\"]\"", &nm, fl);
415
strcpy(file_buf, fl);
420
else if ((!in_comment_ss) && (!in_comment_sa) && (!in_comment_cpp))
438
if (isdelim(*p)) *delim = 1;
447
is_escaped = !is_escaped;
448
else if (((*p) == '"') && (!is_escaped))
456
else if (in_parens != 0 && (!is_escaped))
462
else if (isdelim(*p))
464
ERR("check pair of parens %s:%i.", file_in, line - 1);
484
((*delim) && (!isdelim(*p))) ||
494
if (*p == '\n') line--;
502
if ((*p == '/') && (*(p - 1) == '*') && ((p - sa_start) > 2))
507
if (!in_tok) return NULL;
513
tok = mem_alloc(tok_end - tok_start + 2);
514
if (!tok) return NULL;
516
strncpy(tok, tok_start, tok_end - tok_start + 1);
517
tok[tok_end - tok_start + 1] = 0;
529
if ((*p == '\"') && (!is_escaped))
531
memmove(p, p + 1, strlen(p));
533
else if ((*p == '\\') && (*(p + 1) == 'n'))
535
memmove(p, p + 1, strlen(p));
538
else if ((*p == '\\') && (*(p + 1) == 't'))
540
memmove(p, p + 1, strlen(p));
545
memmove(p, p + 1, strlen(p));
551
if (is_escaped) is_escaped = 0;
556
else if (*tok == '(')
560
tok = perform_math(tok);
568
stack_push(char *token)
570
New_Nested_Handler *nested;
571
Eina_Bool do_append = EINA_TRUE;
573
if (eina_list_count(stack) > 1)
575
if (!strcmp(token, eina_list_data_get(eina_list_last(stack))))
580
token_length = strlen(token);
581
tmp = alloca(eina_strbuf_length_get(stack_buf));
583
eina_strbuf_string_get(stack_buf),
584
eina_strbuf_length_get(stack_buf) - token_length - 1);
585
tmp[eina_strbuf_length_get(stack_buf) - token_length - 1] = '\0';
587
nested = eina_hash_find(_new_nested_hash, tmp);
589
nested = eina_hash_find(_new_nested_short_hash, tmp);
592
if (!strcmp(token, nested->token) &&
593
stack && !strcmp(eina_list_data_get(eina_list_last(stack)), nested->token))
596
do_append = EINA_FALSE;
597
if (nested->func_push) nested->func_push();
604
if (stack) eina_strbuf_append(stack_buf, ".");
605
eina_strbuf_append(stack_buf, token);
607
stack = eina_list_append(stack, token);
615
Eina_Bool do_remove = EINA_TRUE;
619
ERR("parse error %s:%i. } marker without matching { marker",
624
tmp = eina_list_data_get(eina_list_last(stack));
625
tmp_length = strlen(tmp);
627
stack = eina_list_remove_list(stack, eina_list_last(stack));
628
if (eina_list_count(stack) > 0)
631
New_Nested_Handler *nested;
635
hierarchy = alloca(eina_strbuf_length_get(stack_buf) + 1);
637
eina_strbuf_string_get(stack_buf),
638
eina_strbuf_length_get(stack_buf) + 1);
641
lookup = strrchr(hierarchy + eina_strbuf_length_get(stack_buf) - tmp_length, '.');
644
hierarchy[lookup - hierarchy] = '\0';
645
nested = eina_hash_find(_new_nested_hash, hierarchy);
647
nested = eina_hash_find(_new_nested_short_hash, hierarchy);
648
if (nested && nested->func_pop) nested->func_pop();
649
lookup = strrchr(hierarchy + eina_strbuf_length_get(stack_buf) - tmp_length, '.');
652
hierarchy[eina_strbuf_length_get(stack_buf) - 1 - tmp_length] = '\0';
654
nested = eina_hash_find(_new_nested_hash, hierarchy);
656
nested = eina_hash_find(_new_nested_short_hash, hierarchy);
659
if (nested->func_pop) nested->func_pop();
661
prev = eina_list_data_get(eina_list_last(stack));
662
if (!strcmp(tmp, prev))
664
if (!strcmp(nested->token, tmp))
665
do_remove = EINA_FALSE;
669
edje_cc_handlers_pop_notify(tmp);
672
eina_strbuf_remove(stack_buf,
673
eina_strbuf_length_get(stack_buf) - tmp_length - 1,
674
eina_strbuf_length_get(stack_buf));
678
eina_strbuf_remove(stack_buf,
679
eina_strbuf_length_get(stack_buf) - tmp_length,
680
eina_strbuf_length_get(stack_buf));
686
stack_push_quick(const char *str)
691
stack = eina_list_append(stack, s);
692
eina_strbuf_append_char(stack_buf, '.');
693
eina_strbuf_append(stack_buf, s);
697
stack_pop_quick(Eina_Bool check_last, Eina_Bool do_free)
701
str = tmp = eina_list_last_data_get(stack);
706
end = strrchr(tmp, '.');
710
eina_strbuf_remove(stack_buf,
711
eina_strbuf_length_get(stack_buf) - strlen(tmp) - 1,
712
eina_strbuf_length_get(stack_buf));
713
stack = eina_list_remove_list(stack, eina_list_last(stack));
724
stack_replace_quick(const char *token)
728
str = stack_pop_quick(EINA_FALSE, EINA_FALSE);
729
if ((str) && strchr(str, '.'))
731
char *end, *tmp = str;
734
end = strchr(tmp, '.');
738
buf = eina_strbuf_new();
739
eina_strbuf_append(buf, str);
740
eina_strbuf_remove(buf,
741
eina_strbuf_length_get(buf) - strlen(tmp),
742
eina_strbuf_length_get(buf));
743
eina_strbuf_append(buf, token);
745
stack_push_quick(eina_strbuf_string_get(buf));
747
eina_strbuf_free(buf);
752
stack_push_quick(token);
759
return eina_strbuf_string_get(stack_buf);
763
parse(char *data, off_t size)
765
char *p, *end, *token;
770
DBG("Parsing input file");
773
edje_cc_handlers_hierarchy_alloc();
777
while ((token = next_token(p, end, &p, &delim)))
782
if (do_params && delim && *token != ';')
784
ERR("parse error %s:%i. %c marker before ; marker",
785
file_in, line - 1, *token);
791
if ((do_indexes == 2) && (*token != ']'))
793
ERR("parse error %s:%i. %c marker before ] marker",
794
file_in, line - 1, *token);
798
else if (*token == ',' || *token == ':')
800
else if (*token == '}')
804
ERR("parse error %s:%i. } marker before ; marker",
812
else if (*token == ';')
827
while ((param = eina_array_pop(¶ms)))
835
if (new_statement_single())
839
else if (*token == '{')
843
ERR("parse error %s:%i. { marker before ; marker",
849
else if (*token == '[')
853
else if (*token == ']')
860
ERR("parse error %s:%i. ] marker before [ marker",
863
ERR("parse error %s:%i. [?] empty bracket",
877
params_quote |= (1 << eina_array_count(¶ms));
878
eina_array_push(¶ms, token);
883
params_quote |= (1 << eina_array_count(¶ms));
885
eina_array_push(¶ms, token);
891
if ((verbatim == 1) && (p < (end - 2)))
902
while ((p[0] != '{') && (p < end))
904
if (*p == '\n') line++;
912
if (*p == '\n') line++;
913
if (escaped) escaped = 0;
916
if (p[0] == '\\') escaped = 1;
917
else if (p[0] == '\"')
921
if (inquotes) inquotes = 0;
925
else if (p[0] == '\'')
929
if (insquotes) insquotes = 0;
933
else if ((!inquotes) && (!insquotes))
935
if (p[0] == '{') squigglie++;
936
else if (p[0] == '}')
947
if (verbatim_2 > verbatim_1)
952
l = verbatim_2 - verbatim_1 + 1;
954
strncpy(v, verbatim_1, l);
956
set_verbatim(v, l1, l2);
960
ERR("Parse error %s:%i. { marker does not have matching } marker",
972
edje_cc_handlers_hierarchy_free();
976
static char *clean_file = NULL;
994
track_verbatim(int on)
1000
set_verbatim(char *s, int l1, int l2)
1002
verbatim_line1 = l1;
1003
verbatim_line2 = l2;
1010
return verbatim_str;
1014
get_verbatim_line1(void)
1016
return verbatim_line1;
1020
get_verbatim_line2(void)
1022
return verbatim_line2;
1028
char buf[4096 + 4096 + 4096], buf2[4096];
1036
fd = eina_file_mkstemp("edje_cc.edc-tmp-XXXXXX", &tmpn);
1039
CRI("Unable to open temp file \"%s\" for pre-processor.", tmpn);
1048
clean_file = strdup(tmpn);
1049
eina_tmpstr_del(tmpn);
1051
atexit(clean_tmp_file);
1053
def = mem_strdup("");
1060
EINA_LIST_FOREACH(defines, l, define)
1061
len += strlen(define) + 1;
1062
def = mem_alloc(len + 1);
1064
EINA_LIST_FOREACH(defines, l, define)
1066
strcat(def, define);
1076
#ifdef NEED_RUN_IN_TREE
1077
if (getenv("EFL_RUN_IN_TREE"))
1079
snprintf(buf2, sizeof(buf2),
1080
"%s/src/bin/edje/epp/epp" EPP_EXT,
1082
if (!ecore_file_exists(buf2))
1087
if (buf2[0] == '\0')
1088
snprintf(buf2, sizeof(buf2),
1089
"%s/edje/utils/" MODULE_ARCH "/epp" EPP_EXT,
1090
eina_prefix_lib_get(pfx));
1091
if (ecore_file_exists(buf2))
1095
inc = ecore_file_dir_get(file_in);
1097
snprintf(buf, sizeof(buf), "\"%s\" "SKIP_NAMESPACE_VALIDATION_SUPPORTED" -MMD \"%s\" -MT \"%s\" \"%s\""
1098
" -I\"%s\" %s -o \"%s\""
1099
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
1100
EDJE_CC_EFL_VERSION_SUPPORTED,
1101
buf2, depfile, file_out, file_in,
1102
inc ? inc : "./", def, clean_file,
1103
EINA_VERSION_MAJOR, EINA_VERSION_MINOR);
1105
snprintf(buf, sizeof(buf), "\"%s\" "SKIP_NAMESPACE_VALIDATION_SUPPORTED" -annotate -a \"%s\" \"%s\""
1106
" -I\"%s\" %s -o \"%s\""
1107
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
1108
EDJE_CC_EFL_VERSION_SUPPORTED,
1109
buf2, watchfile ? watchfile : "/dev/null", file_in,
1110
inc ? inc : "./", def, clean_file,
1111
EINA_VERSION_MAJOR, EINA_VERSION_MINOR);
1113
snprintf(buf, sizeof(buf), "\"%s\" "SKIP_NAMESPACE_VALIDATION_SUPPORTED" -a \"%s\" \"%s\" -I\"%s\" %s"
1115
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
1116
EDJE_CC_EFL_VERSION_SUPPORTED,
1117
buf2, watchfile ? watchfile : "/dev/null", file_in,
1118
inc ? inc : "./", def, clean_file,
1119
EINA_VERSION_MAJOR, EINA_VERSION_MINOR);
1130
snprintf(win_buf, sizeof(win_buf), "cmd /S /C \"%s\"", buf);
1131
ret = system(win_buf);
1140
ERR("Cannot run epp: %s", buf2);
1143
if (ret == EXIT_SUCCESS)
1144
file_in = (char *)clean_file;
1147
ERR("Exit code of epp not clean: %i", ret);
1152
fd = open(file_in, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR);
1155
ERR("Cannot open file \"%s\" for input. %s",
1156
file_in, strerror(errno));
1159
DBG("Opening \"%s\" for input", file_in);
1165
size = lseek(fd, 0, SEEK_END);
1168
ERR("Cannot read file \"%s\". %s", file_in, strerror(errno));
1172
lseek(fd, 0, SEEK_SET);
1173
data = malloc(size);
1174
if (data && (read(fd, data, size) == size))
1176
stack_buf = eina_strbuf_new();
1177
eina_array_step_set(¶ms, sizeof (Eina_Array), 8);
1179
eina_array_flush(¶ms);
1180
eina_strbuf_free(stack_buf);
1182
color_tree_root_free();
1186
ERR("Cannot read file \"%s\". %s", file_in, strerror(errno));
1192
EINA_LIST_FOREACH(edje_file->styles, l, stl)
1196
ERR("style must have a name.");
1207
str = _parse_param_get(n);
1219
str = _parse_param_get(n);
1222
ERR("%s:%i no parameter supplied as argument %i",
1223
file_in, line - 1, n + 1);
1227
if (str[0] == 0) return 0;
1229
ret = strtol(str, &end, 0);
1230
if ((ret == LONG_MIN) || (ret == LONG_MAX))
1234
if ((end != str) && (end[0] == 0)) return 1;
1244
str = _parse_param_get(n);
1247
ERR("%s:%i no parameter supplied as argument %i",
1248
file_in, line - 1, n + 1);
1252
s = mem_strdup(str);
1257
_parse_enum(char *str, va_list va)
1267
s = va_arg(va, char *);
1272
ERR("%s:%i token %s not one of:", file_in, line - 1, str);
1273
s = va_arg(va2, char *);
1277
fprintf(stderr, " %s", s);
1278
s = va_arg(va2, char *);
1281
fprintf(stderr, "\n");
1288
v = va_arg(va, int);
1289
if (!strcmp(s, str) || !strcmp(s, "*"))
1302
parse_enum(int n, ...)
1310
str = _parse_param_get(n);
1313
ERR("%s:%i no parameter supplied as argument %i",
1314
file_in, line - 1, n + 1);
1323
str = eina_list_last_data_get(stack);
1324
end = strrchr(str, '.');
1330
result = _parse_enum(str, va);
1337
parse_flags(int n, ...)
1343
while (n < (int)eina_array_count(¶ms))
1345
result |= _parse_enum(eina_array_data_get(¶ms, n), va);
1359
str = _parse_param_get(n);
1362
ERR("%s:%i no parameter supplied as argument %i",
1363
file_in, line - 1, n + 1);
1372
parse_int_range(int n, int f, int t)
1377
str = _parse_param_get(n);
1380
ERR("%s:%i no parameter supplied as argument %i",
1381
file_in, line - 1, n + 1);
1386
if ((i < f) || (i > t))
1388
ERR("%s:%i integer %i out of range of %i to %i inclusive",
1389
file_in, line - 1, i, f, t);
1399
char *str, buf[4096];
1402
str = _parse_param_get(n);
1405
ERR("%s:%i no parameter supplied as argument %i",
1406
file_in, line - 1, n + 1);
1411
if (!strstrip(str, buf, sizeof (buf)))
1413
ERR("%s:%i expression is too long",
1418
if (!strcasecmp(buf, "false") || !strcasecmp(buf, "off"))
1420
if (!strcasecmp(buf, "true") || !strcasecmp(buf, "on"))
1424
if ((i < 0) || (i > 1))
1426
ERR("%s:%i integer %i out of range of 0 to 1 inclusive",
1427
file_in, line - 1, i);
1440
str = _parse_param_get(n);
1443
ERR("%s:%i no parameter supplied as argument %i",
1444
file_in, line - 1, n + 1);
1453
parse_float_range(int n, double f, double t)
1458
str = _parse_param_get(n);
1461
ERR("%s:%i no parameter supplied as argument %i",
1462
file_in, line - 1, n + 1);
1467
if ((i < f) || (i > t))
1469
ERR("%s:%i float %3.3f out of range of %3.3f to %3.3f inclusive",
1470
file_in, line - 1, i, f, t);
1480
return eina_array_count(¶ms);
1484
check_arg_count(int required_args)
1486
int num_args = eina_array_count(¶ms);
1488
if (num_args != required_args)
1490
ERR("%s:%i got %i arguments, but expected %i",
1491
file_in, line - 1, num_args, required_args);
1498
check_min_arg_count(int min_required_args)
1500
int num_args = eina_array_count(¶ms);
1502
if (num_args < min_required_args)
1504
ERR("%s:%i got %i arguments, but expected at least %i",
1505
file_in, line - 1, num_args, min_required_args);
1512
check_range_arg_count(int min_required_args, int max_required_args)
1514
int num_args = eina_array_count(¶ms);
1516
if (num_args < min_required_args)
1518
ERR("%s:%i got %i arguments, but expected at least %i",
1519
file_in, line - 1, num_args, min_required_args);
1523
else if (num_args > max_required_args)
1525
ERR("%s:%i got %i arguments, but expected at most %i",
1526
file_in, line - 1, num_args, max_required_args);
1547
my_atoi(const char *s)
1553
if (!strstrip(s, buf, sizeof(buf)))
1555
ERR("%s:%i expression is too long",
1564
_deltai(char *s, int *val)
1566
if (!val) return NULL;
1569
ERR("%s:%i unexpected character at %s",
1570
file_in, line - 1, s);
1576
s = _alphai(s, val);
1584
_funci(char *s, int *val)
1586
if (!strncmp(s, "floor(", 6))
1589
s = _deltai(s, val);
1591
else if (!strncmp(s, "ceil(", 5))
1594
s = _deltai(s, val);
1598
ERR("%s:%i unexpected character at %s",
1599
file_in, line - 1, s);
1605
_gammai(char *s, int *val)
1607
if (!val) return NULL;
1610
s = _get_numi(s, val);
1613
else if ('(' == s[0])
1615
s = _deltai(s, val);
1628
_betai(char *s, int *val)
1633
if (!val) return NULL;
1634
s = _gammai(s, &a1);
1635
while (_is_op1i(s[0]))
1639
s = _gammai(s, &a2);
1640
a1 = _calci(op, a1, a2);
1647
_alphai(char *s, int *val)
1652
if (!val) return NULL;
1654
while (_is_op2i(s[0]))
1659
a1 = _calci(op, a1, a2);
1666
_get_numi(char *s, int *val)
1672
while ((('0' <= s[pos]) && ('9' >= s[pos])) ||
1673
((0 == pos) && ('-' == s[pos])))
1686
if (((c >= '0') && (c <= '9')) || ('-' == c) || ('+' == c))
1723
_calci(char op, int a, int b)
1738
ERR("%s:%i divide by zero", file_in, line - 1);
1746
if (0 != b) a = a % b;
1748
ERR("%s:%i modula by zero", file_in, line - 1);
1752
ERR("%s:%i unexpected character '%c'", file_in, line - 1, op);
1760
my_atof(const char *s)
1767
if (!strstrip(s, buf, sizeof (buf)))
1769
ERR("%s:%i expression is too long", file_in, line - 1);
1777
_deltaf(char *s, double *val)
1779
if (!val) return NULL;
1782
ERR("%s:%i unexpected character at %s", file_in, line - 1, s);
1788
s = _alphaf(s, val);
1795
_funcf(char *s, double *val)
1797
if (!strncmp(s, "floor(", 6))
1800
s = _deltaf(s, val);
1803
else if (!strncmp(s, "ceil(", 5))
1806
s = _deltaf(s, val);
1811
ERR("%s:%i unexpected character at %s", file_in, line - 1, s);
1817
_gammaf(char *s, double *val)
1819
if (!val) return NULL;
1823
s = _get_numf(s, val);
1826
else if ('(' == s[0])
1828
s = _deltaf(s, val);
1841
_betaf(char *s, double *val)
1843
double a1 = 0, a2 = 0;
1846
if (!val) return NULL;
1847
s = _gammaf(s, &a1);
1848
while (_is_op1f(s[0]))
1852
s = _gammaf(s, &a2);
1853
a1 = _calcf(op, a1, a2);
1860
_alphaf(char *s, double *val)
1862
double a1 = 0, a2 = 0;
1865
if (!val) return NULL;
1867
while (_is_op2f(s[0]))
1872
a1 = _calcf(op, a1, a2);
1879
_get_numf(char *s, double *val)
1886
while ((('0' <= s[pos]) && ('9' >= s[pos])) ||
1888
((0 == pos) && ('-' == s[pos])))
1901
if (((c >= '0') && (c <= '9'))
1940
_calcf(char op, double a, double b)
1953
if (EINA_DBL_NONZERO(b)) a /= b;
1955
ERR("%s:%i divide by zero", file_in, line - 1);
1963
if (EINA_DBL_NONZERO(b)) a = (double)((int)a % (int)b);
1965
ERR("%s:%i modula by zero", file_in, line - 1);
1969
ERR("%s:%i unexpected character '%c'", file_in, line - 1, op);
1975
strstrip(const char *in, char *out, size_t size)
1977
if ((size - 1) < strlen(in))
1979
ERR("%s:%i expression is too long", file_in, line - 1);
1985
if ((0x20 != *in) && (0x09 != *in))
1997
get_param_index(char *str)
2002
for (index = 0; index < get_arg_count(); index++)
2004
p = _parse_param_get(index);
2007
if (!strcmp(str, p))
2015
param_had_quote(int n)
2017
return params_quote & (1 << n);