edje: reformat bin/ c files

a lot of this was unreadable due to mixed tabs/spaces or just random
formatting
This commit is contained in:
Mike Blumenkrantz 2018-02-26 16:15:30 -05:00
parent 645c573efb
commit 30378f26fa
18 changed files with 6282 additions and 5939 deletions

View File

@ -16,7 +16,7 @@
int _edje_cc_log_dom = -1;
static void main_help(void);
Eina_Prefix *pfx = NULL;
Eina_Prefix *pfx = NULL;
Eina_List *snd_dirs = NULL;
Eina_List *mo_dirs = NULL;
Eina_List *vibration_dirs = NULL;
@ -25,29 +25,29 @@ Eina_List *model_dirs = NULL;
Eina_List *fnt_dirs = NULL;
Eina_List *data_dirs = NULL;
Eina_List *defines = NULL;
char *file_in = NULL;
char *tmp_dir = NULL;
char *file_out = NULL;
char *watchfile = NULL;
char *depfile = NULL;
char *authors = NULL;
char *license = NULL;
char *file_in = NULL;
char *tmp_dir = NULL;
char *file_out = NULL;
char *watchfile = NULL;
char *depfile = NULL;
char *authors = NULL;
char *license = NULL;
Eina_List *licenses = NULL;
static const char *progname = NULL;
int no_lossy = 0;
int no_comp = 0;
int no_raw = 0;
int no_save = 0;
int min_quality = 0;
int max_quality = 100;
int compress_mode = EET_COMPRESSION_HI;
int threads = 0;
int annotate = 0;
int no_etc1 = 0;
int no_etc2 = 0;
int beta = 0;
int no_lossy = 0;
int no_comp = 0;
int no_raw = 0;
int no_save = 0;
int min_quality = 0;
int max_quality = 100;
int compress_mode = EET_COMPRESSION_HI;
int threads = 0;
int annotate = 0;
int no_etc1 = 0;
int no_etc2 = 0;
int beta = 0;
unsigned int max_open_files;
@ -70,16 +70,19 @@ _edje_cc_log_cb(const Eina_Log_Domain *d,
switch (level)
{
case EINA_LOG_LEVEL_CRITICAL:
prefix = "Critical. ";
break;
prefix = "Critical. ";
break;
case EINA_LOG_LEVEL_ERR:
prefix = "Error. ";
break;
prefix = "Error. ";
break;
case EINA_LOG_LEVEL_WARN:
prefix = "Warning. ";
break;
prefix = "Warning. ";
break;
default:
prefix = "";
prefix = "";
}
fprintf(stderr, "%s: %s", progname, prefix);
eina_log_console_color_set(stderr, EINA_COLOR_RESET);
@ -127,7 +130,7 @@ main_help(void)
"-threads Compile the edje file using multiple parallel threads (by default)\n"
"-nothreads Compile the edje file using only the main loop\n"
"-V [--version] show program version\n"
,progname);
, progname);
}
int
@ -147,11 +150,11 @@ main(int argc, char **argv)
return -1;
_edje_cc_log_dom = eina_log_domain_register
("edje_cc", EDJE_CC_DEFAULT_LOG_COLOR);
("edje_cc", EDJE_CC_DEFAULT_LOG_COLOR);
if (_edje_cc_log_dom < 0)
{
EINA_LOG_ERR("Enable to create a log domain.");
exit(-1);
EINA_LOG_ERR("Enable to create a log domain.");
exit(-1);
}
if (!eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_WARN))
eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_WARN);
@ -170,27 +173,27 @@ main(int argc, char **argv)
for (i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "-h"))
{
main_help();
exit(0);
}
else if ((!strcmp(argv[i], "-V")) || (!strcmp(argv[i], "--version")))
{
printf("Version: %s\n", PACKAGE_VERSION);
exit(0);
}
else if (!strcmp(argv[i], "-v"))
{
eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_INFO);
}
else if (!strcmp(argv[i], "-no-lossy"))
{
no_lossy = 1;
}
else if (!strcmp(argv[i], "-no-comp"))
{
no_comp = 1;
if (!strcmp(argv[i], "-h"))
{
main_help();
exit(0);
}
else if ((!strcmp(argv[i], "-V")) || (!strcmp(argv[i], "--version")))
{
printf("Version: %s\n", PACKAGE_VERSION);
exit(0);
}
else if (!strcmp(argv[i], "-v"))
{
eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_INFO);
}
else if (!strcmp(argv[i], "-no-lossy"))
{
no_lossy = 1;
}
else if (!strcmp(argv[i], "-no-comp"))
{
no_comp = 1;
}
else if (!strcmp(argv[i], "-no-raw"))
{
@ -204,25 +207,25 @@ main(int argc, char **argv)
{
no_etc2 = 1;
}
else if (!strcmp(argv[i], "-no-save"))
{
no_save = 1;
}
else if ((!strcmp(argv[i], "-id") || !strcmp(argv[i], "--image_dir")) && (i < (argc - 1)))
{
i++;
img_dirs = eina_list_append(img_dirs, argv[i]);
}
else if ((!strcmp(argv[i], "-mod") || !strcmp(argv[i], "--model_dir")) && (i < (argc - 1)))
{
i++;
model_dirs = eina_list_append(model_dirs, argv[i]);
}
else if ((!strcmp(argv[i], "-fd") || !strcmp(argv[i], "--font_dir")) && (i < (argc - 1)))
{
i++;
fnt_dirs = eina_list_append(fnt_dirs, argv[i]);
}
else if (!strcmp(argv[i], "-no-save"))
{
no_save = 1;
}
else if ((!strcmp(argv[i], "-id") || !strcmp(argv[i], "--image_dir")) && (i < (argc - 1)))
{
i++;
img_dirs = eina_list_append(img_dirs, argv[i]);
}
else if ((!strcmp(argv[i], "-mod") || !strcmp(argv[i], "--model_dir")) && (i < (argc - 1)))
{
i++;
model_dirs = eina_list_append(model_dirs, argv[i]);
}
else if ((!strcmp(argv[i], "-fd") || !strcmp(argv[i], "--font_dir")) && (i < (argc - 1)))
{
i++;
fnt_dirs = eina_list_append(fnt_dirs, argv[i]);
}
else if ((!strcmp(argv[i], "-sd") || !strcmp(argv[i], "--sound_dir")) && (i < (argc - 1)))
{
i++;
@ -243,12 +246,12 @@ main(int argc, char **argv)
i++;
data_dirs = eina_list_append(data_dirs, argv[i]);
}
else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1)))
{
i++;
else if ((!strcmp(argv[i], "-td") || !strcmp(argv[i], "--tmp_dir")) && (i < (argc - 1)))
{
i++;
if (!tmp_dir)
tmp_dir = argv[i];
}
}
else if ((!strcmp(argv[i], "-l") || !strcmp(argv[i], "--license")) && (i < (argc - 1)))
{
i++;
@ -263,88 +266,88 @@ main(int argc, char **argv)
if (!authors)
authors = argv[i];
}
else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
{
i++;
min_quality = atoi(argv[i]);
if (min_quality < 0) min_quality = 0;
if (min_quality > 100) min_quality = 100;
}
else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1)))
{
i++;
max_quality = atoi(argv[i]);
if (max_quality < 0) max_quality = 0;
if (max_quality > 100) max_quality = 100;
}
else if (!strcmp(argv[i], "-fastcomp"))
{
else if ((!strcmp(argv[i], "-min-quality")) && (i < (argc - 1)))
{
i++;
min_quality = atoi(argv[i]);
if (min_quality < 0) min_quality = 0;
if (min_quality > 100) min_quality = 100;
}
else if ((!strcmp(argv[i], "-max-quality")) && (i < (argc - 1)))
{
i++;
max_quality = atoi(argv[i]);
if (max_quality < 0) max_quality = 0;
if (max_quality > 100) max_quality = 100;
}
else if (!strcmp(argv[i], "-fastcomp"))
{
compress_mode = EET_COMPRESSION_SUPERFAST;
}
else if (!strcmp(argv[i], "-fastdecomp"))
{
}
else if (!strcmp(argv[i], "-fastdecomp"))
{
compress_mode = EET_COMPRESSION_VERYFAST;
}
else if (!strcmp(argv[i], "-threads"))
{
}
else if (!strcmp(argv[i], "-threads"))
{
threads = 1;
}
else if (!strcmp(argv[i], "-nothreads"))
{
}
else if (!strcmp(argv[i], "-nothreads"))
{
threads = 0;
}
else if (!strncmp(argv[i], "-D", 2))
{
defines = eina_list_append(defines, mem_strdup(argv[i]));
}
else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1)))
{
i++;
file_out = argv[i];
}
else if ((!strcmp(argv[i], "-w")) && (i < (argc - 1)))
{
}
else if (!strncmp(argv[i], "-D", 2))
{
defines = eina_list_append(defines, mem_strdup(argv[i]));
}
else if ((!strcmp(argv[i], "-o")) && (i < (argc - 1)))
{
i++;
file_out = argv[i];
}
else if ((!strcmp(argv[i], "-w")) && (i < (argc - 1)))
{
i++;
watchfile = argv[i];
unlink(watchfile);
}
else if (!strcmp(argv[i], "-annotate"))
{
}
else if (!strcmp(argv[i], "-annotate"))
{
annotate = 1;
}
else if ((!strcmp(argv[i], "-deps")) && (i < (argc - 1)))
{
i++;
depfile = argv[i];
unlink(depfile);
}
else if ((!strcmp(argv[i], "-deps")) && (i < (argc - 1)))
{
i++;
depfile = argv[i];
unlink(depfile);
}
else if (!strcmp(argv[i], "-beta"))
{
beta = 1;
}
else if (!file_in)
file_in = argv[i];
else if (!file_out)
file_out = argv[i];
else if (!file_in)
file_in = argv[i];
else if (!file_out)
file_out = argv[i];
}
if (!file_in)
{
ERR("no input file specified.");
main_help();
exit(-1);
ERR("no input file specified.");
main_help();
exit(-1);
}
pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */
main, /* an optional symbol to check path of */
"EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */
"edje", /* dir to add after "share" (PREFIX/share/DIRNAME) */
pfx = eina_prefix_new(argv[0], /* argv[0] value (optional) */
main, /* an optional symbol to check path of */
"EDJE", /* env var prefix to use (XXX_PREFIX, XXX_BIN_DIR etc. */
"edje", /* dir to add after "share" (PREFIX/share/DIRNAME) */
"include/edje.inc", /* a magic file to check for in PREFIX/share/DIRNAME for success */
PACKAGE_BIN_DIR, /* package bin dir @ compile time */
PACKAGE_LIB_DIR, /* package lib dir @ compile time */
PACKAGE_DATA_DIR, /* package data dir @ compile time */
PACKAGE_DATA_DIR /* if locale needed use LOCALE_DIR */
);
);
/* check whether file_in exists */
#ifdef HAVE_REALPATH
@ -353,41 +356,41 @@ main(int argc, char **argv)
if (stat(file_in, &st) || !S_ISREG(st.st_mode))
#endif
{
ERR("file not found: %s.", file_in);
main_help();
exit(-1);
ERR("file not found: %s.", file_in);
main_help();
exit(-1);
}
if (!file_out)
{
char *suffix;
{
char *suffix;
if ((suffix = strstr(file_in,".edc")) && (suffix[4] == 0))
{
file_out = strdup(file_in);
if (file_out)
{
suffix = strstr(file_out,".edc");
strcpy(suffix,".edj");
}
}
}
if ((suffix = strstr(file_in, ".edc")) && (suffix[4] == 0))
{
file_out = strdup(file_in);
if (file_out)
{
suffix = strstr(file_out, ".edc");
strcpy(suffix, ".edj");
}
}
}
if (!file_out)
{
ERR("no output file specified.");
main_help();
exit(-1);
ERR("no output file specified.");
main_help();
exit(-1);
}
#ifdef HAVE_REALPATH
if (realpath(file_out, rpath2) && !strcmp (rpath, rpath2))
if (realpath(file_out, rpath2) && !strcmp(rpath, rpath2))
#else
if (!strcmp (file_in, file_out))
if (!strcmp(file_in, file_out))
#endif
{
ERR("input file equals output file.");
main_help();
exit(-1);
ERR("input file equals output file.");
main_help();
exit(-1);
}
using_file(file_in, 'E');
@ -401,10 +404,10 @@ main(int argc, char **argv)
edje_file->version = EDJE_FILE_VERSION;
edje_file->minor = EDJE_FILE_MINOR;
edje_file->feature_ver = 1; /* increment this every time we add a field
* or feature to the edje file format that
* does not load nicely as a NULL or 0 value
* and needs a special fallback initialization
*/
* or feature to the edje file format that
* does not load nicely as a NULL or 0 value
* and needs a special fallback initialization
*/
/* efl_version is used for specify efl's version
* which was used for developing a edje file.
* It is useful if Edje(or other EFL libs) need to keep
@ -441,10 +444,11 @@ main(int argc, char **argv)
eina_prefix_free(pfx);
pfx = NULL;
edje_shutdown();
eina_log_domain_unregister(_edje_cc_log_dom);
eina_shutdown();
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -32,3 +32,4 @@ mem_strdup(const char *s)
exit(-1);
return NULL;
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,6 @@
# include <config.h>
#endif
#include <string.h>
#include <ctype.h>
#include <limits.h>
@ -29,55 +28,54 @@
#define EDJE_1_21_SUPPORTED " -DEFL_VERSION_1_21=1 "
#define EDJE_CC_EFL_VERSION_SUPPORTED \
EDJE_1_18_SUPPORTED \
EDJE_1_19_SUPPORTED \
EDJE_1_20_SUPPORTED \
EDJE_1_18_SUPPORTED \
EDJE_1_19_SUPPORTED \
EDJE_1_20_SUPPORTED \
EDJE_1_21_SUPPORTED
static void new_object(void);
static void new_statement(void);
static char *perform_math (char *input);
static int isdelim(char c);
static char *next_token(char *p, char *end, char **new_p, int *delim);
static void new_object(void);
static void new_statement(void);
static char *perform_math(char *input);
static int isdelim(char c);
static char *next_token(char *p, char *end, char **new_p, int *delim);
static const char *stack_id(void);
static void parse(char *data, off_t size);
static void parse(char *data, off_t size);
/* simple expression parsing protos */
static int my_atoi(const char * s);
static char * _alphai(char *s, int * val);
static char * _betai(char *s, int * val);
static char * _gammai(char *s, int * val);
static char * _deltai(char *s, int * val);
static char * _get_numi(char *s, int * val);
static int _is_numi(char c);
static int _is_op1i(char c);
static int _is_op2i(char c);
static int _calci(char op, int a, int b);
static int my_atoi(const char *s);
static char *_alphai(char *s, int *val);
static char *_betai(char *s, int *val);
static char *_gammai(char *s, int *val);
static char *_deltai(char *s, int *val);
static char *_get_numi(char *s, int *val);
static int _is_numi(char c);
static int _is_op1i(char c);
static int _is_op2i(char c);
static int _calci(char op, int a, int b);
static double my_atof(const char * s);
static char * _alphaf(char *s, double * val);
static char * _betaf(char *s, double * val);
static char * _gammaf(char *s, double * val);
static char * _deltaf(char *s, double * val);
static char * _get_numf(char *s, double * val);
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);
static double my_atof(const char *s);
static char *_alphaf(char *s, double *val);
static char *_betaf(char *s, double *val);
static char *_gammaf(char *s, double *val);
static char *_deltaf(char *s, double *val);
static char *_get_numf(char *s, double *val);
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;
int line = 0;
Eina_List *stack = NULL;
Eina_Array params;
int had_quote = 0;
int params_quote = 0;
static char file_buf[4096];
static int did_wildcard = 0;
static int verbatim = 0;
static int verbatim_line1 = 0;
static int verbatim_line2 = 0;
static char file_buf[4096];
static int did_wildcard = 0;
static int verbatim = 0;
static int verbatim_line1 = 0;
static int verbatim_line2 = 0;
static char *verbatim_str = NULL;
static Eina_Strbuf *stack_buf = NULL;
@ -102,9 +100,9 @@ err_show_params(void)
ERR("PARAMS:");
EINA_ARRAY_ITER_NEXT(&params, i, p, iterator)
{
ERR(" %s", p);
}
{
ERR(" %s", p);
}
}
static void
@ -117,7 +115,7 @@ err_show(void)
static char *
_parse_param_get(int n)
{
if (n < (int) eina_array_count(&params))
if (n < (int)eina_array_count(&params))
return eina_array_data_get(&params, n);
return NULL;
}
@ -304,7 +302,7 @@ new_statement_single(void)
}
static char *
perform_math (char *input)
perform_math(char *input)
{
char buf[256];
double res;
@ -344,9 +342,9 @@ next_token(char *p, char *end, char **new_p, int *delim)
int in_tok = 0;
int in_quote = 0;
int in_parens = 0;
int in_comment_ss = 0;
int in_comment_ss = 0;
int in_comment_cpp = 0;
int in_comment_sa = 0;
int in_comment_sa = 0;
int is_escaped = 0;
had_quote = 0;
@ -377,7 +375,7 @@ next_token(char *p, char *end, char **new_p, int *delim)
{
char *pp, fl[4096];
char *tmpstr = NULL;
int l, nm;
int l, nm;
/* handle cpp comments */
/* their line format is
@ -470,14 +468,14 @@ next_token(char *p, char *end, char **new_p, int *delim)
/* check for end-of-token */
if (
(isspace(*p)) ||
((*delim) && (!isdelim(*p))) ||
(isdelim(*p))
)
{/*the line below this is never used because it skips to
* the 'done' label which is after the return call for
* in_tok being 0. is this intentional?
*/
(isspace(*p)) ||
((*delim) && (!isdelim(*p))) ||
(isdelim(*p))
) /*the line below this is never used because it skips to
* the 'done' label which is after the return call for
* in_tok being 0. is this intentional?
*/
{
in_tok = 0;
tok_end = p - 1;
@ -497,7 +495,7 @@ next_token(char *p, char *end, char **new_p, int *delim)
if (!in_tok) return NULL;
tok_end = p - 1;
done:
done:
*new_p = p;
tok = mem_alloc(tok_end - tok_start + 2);
@ -661,7 +659,7 @@ stack_pop(void)
if (do_remove)
eina_strbuf_remove(stack_buf,
eina_strbuf_length_get(stack_buf) - tmp_length - 1,
eina_strbuf_length_get(stack_buf)); /* remove: '.tmp' */
eina_strbuf_length_get(stack_buf)); /* remove: '.tmp' */
}
else
{
@ -698,8 +696,8 @@ stack_pop_quick(Eina_Bool check_last, Eina_Bool do_free)
tmp = end + 1;
}
eina_strbuf_remove(stack_buf,
eina_strbuf_length_get(stack_buf) - strlen(tmp) - 1,
eina_strbuf_length_get(stack_buf)); /* remove: '.tmp' */
eina_strbuf_length_get(stack_buf) - strlen(tmp) - 1,
eina_strbuf_length_get(stack_buf)); /* remove: '.tmp' */
stack = eina_list_remove_list(stack, eina_list_last(stack));
if (do_free)
{
@ -785,7 +783,8 @@ parse(char *data, off_t size)
err_show();
exit(-1);
}
else if (*token == ',' || *token == ':') do_params = 1;
else if (*token == ',' || *token == ':')
do_params = 1;
else if (*token == '}')
{
if (do_params)
@ -921,8 +920,9 @@ parse(char *data, off_t size)
}
else if ((!inquotes) && (!insquotes))
{
if (p[0] == '{') squigglie++;
else if (p[0] == '}') squigglie--;
if (p[0] == '{') squigglie++;
else if (p[0] == '}')
squigglie--;
if (squigglie == 0)
{
verbatim_2 = p - 1;
@ -1046,7 +1046,7 @@ compile(void)
len = 0;
EINA_LIST_FOREACH(defines, l, define)
len += strlen(define) + 1;
len += strlen(define) + 1;
def = mem_alloc(len + 1);
def[0] = 0;
EINA_LIST_FOREACH(defines, l, define)
@ -1083,24 +1083,24 @@ compile(void)
inc = ecore_file_dir_get(file_in);
if (depfile)
snprintf(buf, sizeof(buf), "\"%s\" -MMD \"%s\" -MT \"%s\" \"%s\""
" -I\"%s\" %s -o \"%s\""
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
" -I\"%s\" %s -o \"%s\""
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
EDJE_CC_EFL_VERSION_SUPPORTED,
buf2, depfile, file_out, file_in,
inc ? inc : "./", def, clean_file,
EINA_VERSION_MAJOR, EINA_VERSION_MINOR);
else if (annotate)
snprintf(buf, sizeof(buf), "\"%s\" -annotate -a \"%s\" \"%s\""
" -I\"%s\" %s -o \"%s\""
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
" -I\"%s\" %s -o \"%s\""
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
EDJE_CC_EFL_VERSION_SUPPORTED,
buf2, watchfile ? watchfile : "/dev/null", file_in,
inc ? inc : "./", def, clean_file,
EINA_VERSION_MAJOR, EINA_VERSION_MINOR);
else
snprintf(buf, sizeof(buf), "\"%s\" -a \"%s\" \"%s\" -I\"%s\" %s"
" -o \"%s\""
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
" -o \"%s\""
" -DEFL_VERSION_MAJOR=%d -DEFL_VERSION_MINOR=%d"
EDJE_CC_EFL_VERSION_SUPPORTED,
buf2, watchfile ? watchfile : "/dev/null", file_in,
inc ? inc : "./", def, clean_file,
@ -1247,10 +1247,10 @@ _parse_enum(char *str, va_list va)
va_list va2;
va_copy(va2, va); /* iterator for the error message */
for (;;)
for (;; )
{
char *s;
int v;
int v;
s = va_arg(va, char *);
@ -1328,7 +1328,7 @@ parse_flags(int n, ...)
va_list va;
va_start(va, n);
while (n < (int) eina_array_count(&params))
while (n < (int)eina_array_count(&params))
{
result |= _parse_enum(eina_array_data_get(&params, n), va);
n++;
@ -1665,7 +1665,7 @@ _get_numi(char *s, int *val)
}
buf[pos] = '\0';
(*val) = atoi(buf);
return (s + pos);
return s + pos;
}
int
@ -1682,10 +1682,13 @@ _is_op1i(char c)
{
switch (c)
{
case '*':;
case '%':;
case '/': return 1;
default: break;
case '*':;
case '%':;
case '/': return 1;
default: break;
}
return 0;
}
@ -1695,9 +1698,11 @@ _is_op2i(char c)
{
switch (c)
{
case '+':;
case '-': return 1;
default: break;
case '+':;
case '-': return 1;
default: break;
}
return 0;
}
@ -1705,29 +1710,34 @@ _is_op2i(char c)
int
_calci(char op, int a, int b)
{
switch(op)
switch (op)
{
case '+':
a += b;
return a;
a += b;
return a;
case '-':
a -= b;
return a;
a -= b;
return a;
case '/':
if (0 != b) a /= b;
else
ERR("%s:%i divide by zero", file_in, line - 1);
return a;
if (0 != b) a /= b;
else
ERR("%s:%i divide by zero", file_in, line - 1);
return a;
case '*':
a *= b;
return a;
a *= b;
return a;
case '%':
if (0 != b) a = a % b;
else
ERR("%s:%i modula by zero", file_in, line - 1);
return a;
if (0 != b) a = a % b;
else
ERR("%s:%i modula by zero", file_in, line - 1);
return a;
default:
ERR("%s:%i unexpected character '%c'", file_in, line - 1, op);
ERR("%s:%i unexpected character '%c'", file_in, line - 1, op);
}
return a;
}
@ -1818,7 +1828,7 @@ _gammaf(char *s, double *val)
static char *
_betaf(char *s, double *val)
{
double a1=0, a2=0;
double a1 = 0, a2 = 0;
char op;
if (!val) return NULL;
@ -1837,7 +1847,7 @@ _betaf(char *s, double *val)
static char *
_alphaf(char *s, double *val)
{
double a1=0, a2=0;
double a1 = 0, a2 = 0;
char op;
if (!val) return NULL;
@ -1870,7 +1880,7 @@ _get_numf(char *s, double *val)
}
buf[pos] = '\0';
(*val) = atof(buf);
return (s+pos);
return s + pos;
}
static int
@ -1887,11 +1897,14 @@ _is_numf(char c)
static int
_is_op1f(char c)
{
switch(c)
switch (c)
{
case '*':;
case '%':;
case '/': return 1;
default: break;
}
return 0;
@ -1900,10 +1913,12 @@ _is_op1f(char c)
static int
_is_op2f(char c)
{
switch(c)
switch (c)
{
case '+':;
case '-': return 1;
default: break;
}
return 0;
@ -1912,29 +1927,34 @@ _is_op2f(char c)
static double
_calcf(char op, double a, double b)
{
switch(op)
switch (op)
{
case '+':
a += b;
return a;
a += b;
return a;
case '-':
a -= b;
return a;
a -= b;
return a;
case '/':
if (b != 0) a /= b;
else
ERR("%s:%i divide by zero", file_in, line - 1);
return a;
if (b != 0) a /= b;
else
ERR("%s:%i divide by zero", file_in, line - 1);
return a;
case '*':
a *= b;
return a;
a *= b;
return a;
case '%':
if (0 != b) a = (double)((int)a % (int)b);
else
ERR("%s:%i modula by zero", file_in, line - 1);
return a;
if (0 != b) a = (double)((int)a % (int)b);
else
ERR("%s:%i modula by zero", file_in, line - 1);
return a;
default:
ERR("%s:%i unexpected character '%c'", file_in, line - 1, op);
ERR("%s:%i unexpected character '%c'", file_in, line - 1, op);
}
return a;
}
@ -1942,7 +1962,7 @@ _calcf(char op, double a, double b)
static int
strstrip(const char *in, char *out, size_t size)
{
if ((size -1 ) < strlen(in))
if ((size - 1) < strlen(in))
{
ERR("%s:%i expression is too long", file_in, line - 1);
return 0;
@ -1967,7 +1987,7 @@ get_param_index(char *str)
int index;
char *p;
for(index = 0; index < get_arg_count(); index++)
for (index = 0; index < get_arg_count(); index++)
{
p = _parse_param_get(index);
if (!p) continue;
@ -1982,5 +2002,6 @@ get_param_index(char *str)
int
param_had_quote(int n)
{
return (params_quote & (1 << n));
return params_quote & (1 << n);
}

View File

@ -19,19 +19,19 @@ typedef enum
{
TOKEN_TYPE_INVALID = -1,
TOKEN_TYPE_EOF,
TOKEN_TYPE_COLON = (1 << 0),
TOKEN_TYPE_SEMICOLON = (1 << 1),
TOKEN_TYPE_COMMA = (1 << 2),
TOKEN_TYPE_PARENS = (1 << 3),
TOKEN_TYPE_BRACES = (1 << 4),
TOKEN_TYPE_COLON = (1 << 0),
TOKEN_TYPE_SEMICOLON = (1 << 1),
TOKEN_TYPE_COMMA = (1 << 2),
TOKEN_TYPE_PARENS = (1 << 3),
TOKEN_TYPE_BRACES = (1 << 4),
TOKEN_TYPE_EQUAL_MARK = (1 << 5),
TOKEN_TYPE_PUBLIC = (1 << 6),
TOKEN_TYPE_PUBLIC = (1 << 6),
TOKEN_TYPE_IDENTIFIER = (1 << 7)
} Token_Type;
typedef struct _Token
{
char *str;
char *str;
Token_Type type;
} Token;
@ -102,6 +102,7 @@ code_parse_internal(Code *code)
sym = mem_alloc(SZ(Code_Symbol));
sym->tag = eina_array_pop(name_stack);
break;
case TOKEN_TYPE_SEMICOLON:
if (eina_array_count(name_stack))
{
@ -114,6 +115,7 @@ code_parse_internal(Code *code)
}
is_public = EINA_FALSE;
break;
case TOKEN_TYPE_COMMA:
if (!sym)
sym = mem_alloc(SZ(Code_Symbol));
@ -127,6 +129,7 @@ code_parse_internal(Code *code)
}
sym = NULL;
break;
case TOKEN_TYPE_PARENS:
is_args = !is_args;
if (is_args)
@ -152,6 +155,7 @@ code_parse_internal(Code *code)
sym = func;
}
break;
case TOKEN_TYPE_BRACES:
depth = 1;
body = begin;
@ -164,6 +168,7 @@ code_parse_internal(Code *code)
case '{':
depth++;
break;
case '}':
depth--;
break;
@ -182,13 +187,16 @@ code_parse_internal(Code *code)
sym = NULL;
is_public = EINA_FALSE;
break;
case TOKEN_TYPE_PUBLIC:
is_public = EINA_TRUE;
break;
case TOKEN_TYPE_IDENTIFIER:
eina_array_push(name_stack, token->str);
token->str = NULL;
break;
default:
break;
}
@ -228,9 +236,10 @@ next_token(char **begin, char *end)
case ' ':
case '\t':
case '\n':
if (index > 0)
parsed = EINA_TRUE;
break;
if (index > 0)
parsed = EINA_TRUE;
break;
case ':':
case ';':
case ',':
@ -239,46 +248,53 @@ next_token(char **begin, char *end)
case '{':
case '}':
case '=':
if (!index)
{
buf[index++] = ch;
src++;
}
goto exit;
if (!index)
{
buf[index++] = ch;
src++;
}
goto exit;
default:
if (parsed)
goto exit;
buf[index++] = ch;
break;
if (parsed)
goto exit;
buf[index++] = ch;
break;
}
}
exit:
switch (buf[0])
{
case ':':
token->type = TOKEN_TYPE_COLON;
break;
case ';':
token->type = TOKEN_TYPE_SEMICOLON;
break;
case ',':
token->type = TOKEN_TYPE_COMMA;
break;
case '(':
case ')':
token->type = TOKEN_TYPE_PARENS;
break;
case '{':
case '}':
token->type = TOKEN_TYPE_BRACES;
break;
case '=':
token->type = TOKEN_TYPE_EQUAL_MARK;
break;
case '\0':
token->type = TOKEN_TYPE_EOF;
break;
case ':':
token->type = TOKEN_TYPE_COLON;
break;
case ';':
token->type = TOKEN_TYPE_SEMICOLON;
break;
case ',':
token->type = TOKEN_TYPE_COMMA;
break;
case '(':
case ')':
token->type = TOKEN_TYPE_PARENS;
break;
case '{':
case '}':
token->type = TOKEN_TYPE_BRACES;
break;
case '=':
token->type = TOKEN_TYPE_EQUAL_MARK;
break;
case '\0':
token->type = TOKEN_TYPE_EOF;
break;
}
if (token->type < 0)
@ -448,3 +464,4 @@ script_rewrite(Code *code)
code->vars = vars;
code->func = func;
}

View File

@ -59,8 +59,8 @@ source_fetch_file(const char *fil, const char *filname)
f = fopen(fil, "rb");
if (!f)
{
ERR("Cannot open file '%s'", fil);
exit(-1);
ERR("Cannot open file '%s'", fil);
exit(-1);
}
fseek(f, 0, SEEK_END);
@ -71,12 +71,12 @@ source_fetch_file(const char *fil, const char *filname)
sf->file = mem_alloc(sz + 1);
if (sz > 0)
{
tmp = fread(sf->file, sz, 1, f);
if (tmp != 1)
{
ERR("file length for (%s) doesn't match!", filname);
exit(-1);
}
tmp = fread(sf->file, sz, 1, f);
if (tmp != 1)
{
ERR("file length for (%s) doesn't match!", filname);
exit(-1);
}
}
sf->file[sz] = '\0';
@ -85,14 +85,14 @@ source_fetch_file(const char *fil, const char *filname)
while (fgets(buf, sizeof(buf), f))
{
char *p, *pp;
int forgetit = 0;
int haveinclude = 0;
char *file = NULL, *fname = NULL;
char *p, *pp;
int forgetit = 0;
int haveinclude = 0;
char *file = NULL, *fname = NULL;
p = buf;
while ((!forgetit) && (*p))
{
p = buf;
while ((!forgetit) && (*p))
{
if (!isspace(*p))
{
if (*p != '#')
@ -100,87 +100,87 @@ source_fetch_file(const char *fil, const char *filname)
}
p++;
if (!haveinclude)
{
if (!isspace(*p))
{
if (!strncmp(p, "include", 7))
{
haveinclude = 1;
p += 7;
}
/* HACK! the logic above should be fixed so
* preprocessor statements don't have to begin
* in column 0.
* otoh, edje_cc should print a warning in that case,
* since according to the standard, preprocessor
* statements need to be put in column 0.
*/
else if (!strncmp(p, "#include", 8))
{
haveinclude = 1;
p += 8;
}
else
forgetit = 1;
}
}
else
{
if (!isspace(*p))
{
char end = '\0';
if (*p == '"') end = '"';
else if (*p == '<') end = '>';
if (end)
{
pp = strchr(p + 1, end);
if (!pp)
forgetit = 1;
else
{
ssize_t l = 0;
/* get the directory of the current file
* if we haven't already done so
*/
if (!dir)
{
dir = ecore_file_dir_get(fil);
if (dir) dir_len = strlen(dir);
}
l = pp - p + dir_len + 1;
file = mem_alloc(l);
if (!dir_len)
{
snprintf(file, l - 1, "%s", p + 1);
file[l - 2] = 0;
}
else
{
snprintf(file, l, "%s/%s", dir, p + 1);
file[l - 1] = 0;
}
fname = strdup(p + 1);
pp = strrchr(fname, end);
if (pp) *pp = 0;
forgetit = 1;
}
}
else
forgetit = 1;
}
else
p++;
if (!haveinclude)
{
if (!isspace(*p))
{
if (!strncmp(p, "include", 7))
{
haveinclude = 1;
p += 7;
}
/* HACK! the logic above should be fixed so
* preprocessor statements don't have to begin
* in column 0.
* otoh, edje_cc should print a warning in that case,
* since according to the standard, preprocessor
* statements need to be put in column 0.
*/
else if (!strncmp(p, "#include", 8))
{
haveinclude = 1;
p += 8;
}
else
forgetit = 1;
}
}
}
if ((file) && (fname))
else
{
if (!isspace(*p))
{
char end = '\0';
if (*p == '"') end = '"';
else if (*p == '<')
end = '>';
if (end)
{
pp = strchr(p + 1, end);
if (!pp)
forgetit = 1;
else
{
ssize_t l = 0;
/* get the directory of the current file
* if we haven't already done so
*/
if (!dir)
{
dir = ecore_file_dir_get(fil);
if (dir) dir_len = strlen(dir);
}
l = pp - p + dir_len + 1;
file = mem_alloc(l);
if (!dir_len)
{
snprintf(file, l - 1, "%s", p + 1);
file[l - 2] = 0;
}
else
{
snprintf(file, l, "%s/%s", dir, p + 1);
file[l - 1] = 0;
}
fname = strdup(p + 1);
pp = strrchr(fname, end);
if (pp) *pp = 0;
forgetit = 1;
}
}
else
forgetit = 1;
}
else
p++;
}
}
if ((file) && (fname))
source_fetch_file(file, fname);
if (file) free(file);
@ -230,3 +230,4 @@ source_fontmap_load(Eet_File *ef)
fl = eet_data_read(ef, _font_list_edd, "edje_source_fontmap");
return fl;
}

File diff suppressed because it is too large Load Diff

View File

@ -37,8 +37,8 @@ _edje_file_convert_external(Edje_File *edf, Old_Edje_File *oedf)
EINA_LIST_FREE(oedf->external_dir->entries, ede)
{
edf->external_dir->entries[i++].entry = ede->entry;
free(ede);
edf->external_dir->entries[i++].entry = ede->entry;
free(ede);
}
free(oedf->external_dir);
@ -72,10 +72,10 @@ _edje_file_convert_images(Edje_File *edf, Old_Edje_File *oedf)
EINA_LIST_FREE(oedf->image_dir->entries, de)
{
memcpy(edf->image_dir->entries + de->id,
de,
sizeof (Edje_Image_Directory_Entry));
free(de);
memcpy(edf->image_dir->entries + de->id,
de,
sizeof (Edje_Image_Directory_Entry));
free(de);
}
max = -1;
@ -88,17 +88,17 @@ _edje_file_convert_images(Edje_File *edf, Old_Edje_File *oedf)
if (!edf->image_dir->sets && edf->image_dir->sets_count)
{
free(edf->image_dir->entries);
edf->image_dir->entries = NULL;
return EINA_FALSE;
free(edf->image_dir->entries);
edf->image_dir->entries = NULL;
return EINA_FALSE;
}
EINA_LIST_FREE(oedf->image_dir->sets, ds)
{
memcpy(edf->image_dir->sets + ds->id,
ds,
sizeof (Edje_Image_Directory_Set));
free(ds);
memcpy(edf->image_dir->sets + ds->id,
ds,
sizeof (Edje_Image_Directory_Set));
free(ds);
}
return EINA_TRUE;
@ -129,15 +129,15 @@ _edje_file_convert(Eet_File *ef, Old_Edje_File *oedf)
EINA_LIST_FREE(oedf->data, ed)
{
Edje_String *es;
Edje_String *es;
es = calloc(1, sizeof (Edje_String));
if (!es) continue;
es = calloc(1, sizeof (Edje_String));
if (!es) continue;
es->str = ed->value;
es->str = ed->value;
eina_hash_direct_add(edf->data, ed->key, es);
free(ed);
eina_hash_direct_add(edf->data, ed->key, es);
free(ed);
}
EINA_LIST_FOREACH(oedf->collection_dir->entries, l, ce)
@ -148,7 +148,7 @@ _edje_file_convert(Eet_File *ef, Old_Edje_File *oedf)
if (oedf->font_dir)
EINA_LIST_FOREACH(oedf->font_dir->entries, l, fnt)
eina_hash_direct_add(edf->fonts, fnt->entry, fnt);
eina_hash_direct_add(edf->fonts, fnt->entry, fnt);
if (!_edje_file_convert_images(edf, oedf))
goto on_error;
@ -174,7 +174,7 @@ _edje_file_convert(Eet_File *ef, Old_Edje_File *oedf)
return edf;
on_error:
on_error:
eina_hash_free(edf->fonts);
eina_hash_free(edf->collection);
eina_hash_free(edf->data);
@ -186,12 +186,12 @@ _edje_file_convert(Eet_File *ef, Old_Edje_File *oedf)
static void
_edje_collection_program_add(Edje_Program ***array,
unsigned int *count,
Edje_Program *add)
unsigned int *count,
Edje_Program *add)
{
Edje_Program **tmp;
tmp = realloc(*array, sizeof (Edje_Program*) * (*count + 1));
tmp = realloc(*array, sizeof (Edje_Program *) * (*count + 1));
if (!tmp)
{
error_and_abort(ef, "Not enough memory");
@ -218,40 +218,40 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce,
/* Count each type part and their respective state */
EINA_LIST_FOREACH(oedc->parts, l, part)
{
int *count;
int dummy = 0;
int *count;
int dummy = 0;
switch (part->type)
{
#define CSP(Tp, Ce) \
case EDJE_PART_TYPE_##Tp: \
count = &Ce->count.Tp; \
break;
switch (part->type)
{
#define CSP(Tp, Ce) \
case EDJE_PART_TYPE_##Tp : \
count = &Ce->count.Tp; \
break;
CSP(RECTANGLE, ce);
CSP(TEXT, ce);
CSP(IMAGE, ce);
CSP(SWALLOW, ce);
CSP(TEXTBLOCK, ce);
CSP(GROUP, ce);
CSP(BOX, ce);
CSP(TABLE, ce);
CSP(EXTERNAL, ce);
CSP(VECTOR, ce);
CSP(RECTANGLE, ce);
CSP(TEXT, ce);
CSP(IMAGE, ce);
CSP(SWALLOW, ce);
CSP(TEXTBLOCK, ce);
CSP(GROUP, ce);
CSP(BOX, ce);
CSP(TABLE, ce);
CSP(EXTERNAL, ce);
CSP(VECTOR, ce);
default:
count = &dummy;
break;
}
default:
count = &dummy;
break;
}
*count += eina_list_count(part->other_desc) + 1;
*count += eina_list_count(part->other_desc) + 1;
}
ce->count.part = eina_list_count(oedc->parts);
#define CONVERT_EMN(Tp, Sz, Ce) \
buffer = alloca(strlen(ce->entry) + strlen(#Tp) + 2); \
sprintf(buffer, "%s/%s", ce->entry, #Tp); \
Ce->mp.Tp = eina_mempool_add("one_big", buffer, NULL, sizeof (Sz), Ce->count.Tp);
#define CONVERT_EMN(Tp, Sz, Ce) \
buffer = alloca(strlen(ce->entry) + strlen(#Tp) + 2); \
sprintf(buffer, "%s/%s", ce->entry, #Tp); \
Ce->mp.Tp = eina_mempool_add("one_big", buffer, NULL, sizeof (Sz), Ce->count.Tp);
CONVERT_EMN(RECTANGLE, Edje_Part_Description_Common, ce);
CONVERT_EMN(TEXT, Edje_Part_Description_Text, ce);
@ -272,43 +272,43 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce,
EINA_LIST_FREE(oedc->programs, pg)
{
if (!pg->signal && !pg->source)
_edje_collection_program_add(&edc->programs.nocmp,
&edc->programs.nocmp_count,
pg);
else if (pg->signal && !strpbrk(pg->signal, "*?[\\")
&& pg->source && !strpbrk(pg->source, "*?[\\"))
_edje_collection_program_add(&edc->programs.strcmp,
&edc->programs.strcmp_count,
pg);
else if (pg->signal && edje_program_is_strncmp(pg->signal)
&& pg->source && edje_program_is_strncmp(pg->source))
_edje_collection_program_add(&edc->programs.strncmp,
&edc->programs.strncmp_count,
pg);
else if (pg->signal && edje_program_is_strrncmp(pg->signal)
&& pg->source && edje_program_is_strrncmp(pg->source))
_edje_collection_program_add(&edc->programs.strrncmp,
&edc->programs.strrncmp_count,
pg);
else
_edje_collection_program_add(&edc->programs.fnmatch,
&edc->programs.fnmatch_count,
pg);
if (!pg->signal && !pg->source)
_edje_collection_program_add(&edc->programs.nocmp,
&edc->programs.nocmp_count,
pg);
else if (pg->signal && !strpbrk(pg->signal, "*?[\\")
&& pg->source && !strpbrk(pg->source, "*?[\\"))
_edje_collection_program_add(&edc->programs.strcmp,
&edc->programs.strcmp_count,
pg);
else if (pg->signal && edje_program_is_strncmp(pg->signal)
&& pg->source && edje_program_is_strncmp(pg->source))
_edje_collection_program_add(&edc->programs.strncmp,
&edc->programs.strncmp_count,
pg);
else if (pg->signal && edje_program_is_strrncmp(pg->signal)
&& pg->source && edje_program_is_strrncmp(pg->source))
_edje_collection_program_add(&edc->programs.strrncmp,
&edc->programs.strrncmp_count,
pg);
else
_edje_collection_program_add(&edc->programs.fnmatch,
&edc->programs.fnmatch_count,
pg);
}
edc->data = eina_hash_string_small_new(NULL);
EINA_LIST_FREE(oedc->data, di)
{
Edje_String *es;
Edje_String *es;
es = calloc(1, sizeof (Edje_String));
if (!es) continue ;
es = calloc(1, sizeof (Edje_String));
if (!es) continue;
es->str = di->value;
es->str = di->value;
eina_hash_direct_add(edc->data, di->key, es);
free(di);
eina_hash_direct_add(edc->data, di->key, es);
free(di);
}
edc->parts_count = eina_list_count(oedc->parts);
@ -319,60 +319,60 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce,
EINA_LIST_FREE(oedc->parts, part)
{
Old_Edje_Part_Description *oepd;
Edje_Pack_Element *elm;
Edje_Part *replacement;
unsigned int i;
Old_Edje_Part_Description *oepd;
Edje_Pack_Element *elm;
Edje_Part *replacement;
unsigned int i;
replacement = eina_mempool_malloc(ce->mp.part, sizeof (Edje_Part));
if (!replacement)
error_and_abort(ef, "Not enough memory");
replacement = eina_mempool_malloc(ce->mp.part, sizeof (Edje_Part));
if (!replacement)
error_and_abort(ef, "Not enough memory");
replacement->name = part->name;
replacement->default_desc = _edje_description_convert(part->type, ce, part->default_desc);
replacement->name = part->name;
replacement->default_desc = _edje_description_convert(part->type, ce, part->default_desc);
replacement->other.desc_count = eina_list_count(part->other_desc);
replacement->other.desc = calloc(replacement->other.desc_count, sizeof (Edje_Part_Description_Common*));
replacement->other.desc_count = eina_list_count(part->other_desc);
replacement->other.desc = calloc(replacement->other.desc_count, sizeof (Edje_Part_Description_Common *));
i = 0;
EINA_LIST_FREE(part->other_desc, oepd)
replacement->other.desc[i++] = _edje_description_convert(part->type, ce, oepd);
i = 0;
EINA_LIST_FREE(part->other_desc, oepd)
replacement->other.desc[i++] = _edje_description_convert(part->type, ce, oepd);
replacement->source = part->source;
replacement->source2 = part->source2;
replacement->source3 = part->source3;
replacement->source4 = part->source4;
replacement->source5 = part->source5;
replacement->source6 = part->source6;
replacement->id = part->id;
replacement->clip_to_id = part->clip_to_id;
replacement->dragable = part->dragable;
replacement->items_count = eina_list_count(part->items);
replacement->items = calloc(replacement->items_count, sizeof (Edje_Pack_Element*));
replacement->source = part->source;
replacement->source2 = part->source2;
replacement->source3 = part->source3;
replacement->source4 = part->source4;
replacement->source5 = part->source5;
replacement->source6 = part->source6;
replacement->id = part->id;
replacement->clip_to_id = part->clip_to_id;
replacement->dragable = part->dragable;
replacement->items_count = eina_list_count(part->items);
replacement->items = calloc(replacement->items_count, sizeof (Edje_Pack_Element *));
i = 0;
EINA_LIST_FREE(part->items, elm)
replacement->items[i++] = elm;
i = 0;
EINA_LIST_FREE(part->items, elm)
replacement->items[i++] = elm;
replacement->type = part->type;
replacement->effect = part->effect;
replacement->mouse_events = part->mouse_events;
replacement->repeat_events = part->repeat_events;
replacement->ignore_flags = part->ignore_flags;
replacement->mask_flags = part->mask_flags;
replacement->scale = part->scale;
replacement->precise_is_inside = part->precise_is_inside;
replacement->use_alternate_font_metrics = part->use_alternate_font_metrics;
replacement->pointer_mode = part->pointer_mode;
replacement->entry_mode = part->entry_mode;
replacement->select_mode = part->select_mode;
replacement->multiline = part->multiline;
replacement->api = part->api;
replacement->required = part->required;
replacement->type = part->type;
replacement->effect = part->effect;
replacement->mouse_events = part->mouse_events;
replacement->repeat_events = part->repeat_events;
replacement->ignore_flags = part->ignore_flags;
replacement->mask_flags = part->mask_flags;
replacement->scale = part->scale;
replacement->precise_is_inside = part->precise_is_inside;
replacement->use_alternate_font_metrics = part->use_alternate_font_metrics;
replacement->pointer_mode = part->pointer_mode;
replacement->entry_mode = part->entry_mode;
replacement->select_mode = part->select_mode;
replacement->multiline = part->multiline;
replacement->api = part->api;
replacement->required = part->required;
edc->parts[k++] = replacement;
edc->parts[k++] = replacement;
free(part);
free(part);
}
edc->id = oedc->id;
@ -389,76 +389,78 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce,
return edc;
}
Edje_Part_Description_Common*
Edje_Part_Description_Common *
_edje_description_convert(int type,
Edje_Part_Collection_Directory_Entry *ce,
Old_Edje_Part_Description *oed)
Edje_Part_Collection_Directory_Entry *ce,
Old_Edje_Part_Description *oed)
{
Edje_Part_Description_Common *result = NULL;
switch (type)
{
case EDJE_PART_TYPE_RECTANGLE:
result = eina_mempool_malloc(ce->mp.RECTANGLE,
sizeof (Edje_Part_Description_Common));
break;
result = eina_mempool_malloc(ce->mp.RECTANGLE,
sizeof (Edje_Part_Description_Common));
break;
case EDJE_PART_TYPE_SWALLOW:
result = eina_mempool_malloc(ce->mp.SWALLOW,
sizeof (Edje_Part_Description_Common));
break;
result = eina_mempool_malloc(ce->mp.SWALLOW,
sizeof (Edje_Part_Description_Common));
break;
case EDJE_PART_TYPE_GROUP:
result = eina_mempool_malloc(ce->mp.GROUP,
sizeof (Edje_Part_Description_Common));
break;
result = eina_mempool_malloc(ce->mp.GROUP,
sizeof (Edje_Part_Description_Common));
break;
case EDJE_PART_TYPE_IMAGE:
{
Edje_Part_Description_Image *img;
Edje_Part_Image_Id *id;
unsigned int i = 0;
{
Edje_Part_Description_Image *img;
Edje_Part_Image_Id *id;
unsigned int i = 0;
img = eina_mempool_malloc(ce->mp.IMAGE, sizeof (Edje_Part_Description_Image));
img = eina_mempool_malloc(ce->mp.IMAGE, sizeof (Edje_Part_Description_Image));
img->image.tweens_count = eina_list_count(oed->image.tween_list);
img->image.tweens = calloc(img->image.tweens_count,
sizeof (Edje_Part_Image_Id*));
if (img->image.tweens_count > 0 && !img->image.tweens)
{
eina_mempool_free(ce->mp.IMAGE, img);
return NULL;
}
img->image.tweens_count = eina_list_count(oed->image.tween_list);
img->image.tweens = calloc(img->image.tweens_count,
sizeof (Edje_Part_Image_Id *));
if (img->image.tweens_count > 0 && !img->image.tweens)
{
eina_mempool_free(ce->mp.IMAGE, img);
return NULL;
}
EINA_LIST_FREE(oed->image.tween_list, id)
img->image.tweens[i++] = id;
EINA_LIST_FREE(oed->image.tween_list, id)
img->image.tweens[i++] = id;
img->image.id = oed->image.id;
img->image.scale_hint = oed->image.scale_hint;
img->image.set = oed->image.set;
img->image.id = oed->image.id;
img->image.scale_hint = oed->image.scale_hint;
img->image.set = oed->image.set;
img->image.border = oed->image.border;
img->image.fill = oed->image.fill;
img->image.border = oed->image.border;
img->image.fill = oed->image.fill;
result = &img->common;
break;
}
result = &img->common;
break;
}
#define CONVERT_ALLOC_POOL(Short, Type, Name) \
case EDJE_PART_TYPE_##Short: \
{ \
Edje_Part_Description_##Type *Name; \
\
Name = eina_mempool_malloc(ce->mp.Short, sizeof (Edje_Part_Description_##Type)); \
Name->Name = oed->Name; \
result = &Name->common; \
break; \
}
#define CONVERT_ALLOC_POOL(Short, Type, Name) \
case EDJE_PART_TYPE_##Short: \
{ \
Edje_Part_Description_##Type * Name; \
\
Name = eina_mempool_malloc(ce->mp.Short, sizeof (Edje_Part_Description_##Type)); \
Name->Name = oed->Name; \
result = &Name->common; \
break; \
}
CONVERT_ALLOC_POOL(TEXT, Text, text);
CONVERT_ALLOC_POOL(TEXTBLOCK, Text, text);
CONVERT_ALLOC_POOL(BOX, Box, box);
CONVERT_ALLOC_POOL(TABLE, Table, table);
CONVERT_ALLOC_POOL(EXTERNAL, External, external_params);
CONVERT_ALLOC_POOL(VECTOR, Vector, vector);
CONVERT_ALLOC_POOL(TEXT, Text, text);
CONVERT_ALLOC_POOL(TEXTBLOCK, Text, text);
CONVERT_ALLOC_POOL(BOX, Box, box);
CONVERT_ALLOC_POOL(TABLE, Table, table);
CONVERT_ALLOC_POOL(EXTERNAL, External, external_params);
CONVERT_ALLOC_POOL(VECTOR, Vector, vector);
}
if (result)
@ -467,3 +469,4 @@ _edje_description_convert(int type,
free(oed);
return result;
}

View File

@ -39,7 +39,7 @@ main_help(void)
("Usage:\n"
"\t%s file.edj\n"
"\n"
,progname);
, progname);
}
static void
@ -57,17 +57,17 @@ _edje_alias_int(const char *target, Eet_File *ef, const char *base, const char *
strcat(buf, "%i");
for (i = 0; i < count && match; ++i)
{
char name[1024];
int id;
char name[1024];
int id;
if (sscanf(match[i], buf, &id) != 1)
{
EINA_LOG_ERR("Wrong fonts section `%s' in `%s'. Discarding it.", match[i], target);
continue ;
}
if (sscanf(match[i], buf, &id) != 1)
{
EINA_LOG_ERR("Wrong fonts section `%s' in `%s'. Discarding it.", match[i], target);
continue;
}
snprintf(name, sizeof (name), "%s/%i", to, id);
eet_alias(ef, name, match[i], 1);
snprintf(name, sizeof (name), "%s/%i", to, id);
eet_alias(ef, name, match[i], 1);
}
free(match);
}
@ -87,17 +87,17 @@ _edje_alias_string(const char *target, Eet_File *ef, const char *base, const cha
strcat(buf, "%s");
for (i = 0; i < count && match; ++i)
{
char name[1024];
char id[1024];
char name[1024];
char id[1024];
if (sscanf(match[i], buf, &id) != 1)
{
EINA_LOG_ERR("Wrong fonts section `%s' in `%s'. Discarding it.", match[i], target);
continue ;
}
if (sscanf(match[i], buf, &id) != 1)
{
EINA_LOG_ERR("Wrong fonts section `%s' in `%s'. Discarding it.", match[i], target);
continue;
}
snprintf(name, sizeof (name), "%s/%s", to, id);
eet_alias(ef, name, match[i], 1);
snprintf(name, sizeof (name), "%s/%s", to, id);
eet_alias(ef, name, match[i], 1);
}
free(match);
}
@ -119,11 +119,11 @@ main(int argc, char **argv)
return -1;
_edje_cc_log_dom = eina_log_domain_register
("edje_convert", EDJE_CC_DEFAULT_LOG_COLOR);
("edje_convert", EDJE_CC_DEFAULT_LOG_COLOR);
if (_edje_cc_log_dom < 0)
{
EINA_LOG_ERR("Enable to create a log domain.");
exit(-1);
EINA_LOG_ERR("Enable to create a log domain.");
exit(-1);
}
eet_init();
@ -131,8 +131,8 @@ main(int argc, char **argv)
progname = argv[0];
if (argc > 2 || argc < 2 || !strcmp(argv[1], "-h"))
{
main_help();
return 0;
main_help();
return 0;
}
_edje_edd_old_init();
@ -141,15 +141,15 @@ main(int argc, char **argv)
ef = eet_open(argv[1], EET_FILE_MODE_READ_WRITE);
if (!ef)
{
EINA_LOG_ERR("Unable to open `%s'.", argv[1]);
return -1;
EINA_LOG_ERR("Unable to open `%s'.", argv[1]);
return -1;
}
oef = eet_data_read(ef, _edje_edd_old_edje_file, "edje_file");
if (!oef)
{
EINA_LOG_ERR("Unable to get edje_file section from old file format, are you sure it's an old file ?");
return -1;
EINA_LOG_ERR("Unable to get edje_file section from old file format, are you sure it's an old file ?");
return -1;
}
nef = _edje_file_convert(ef, oef);
@ -160,34 +160,34 @@ main(int argc, char **argv)
EINA_ITERATOR_FOREACH(it, ce)
{
Old_Edje_Part_Collection *opc;
Edje_Part_Collection *npc;
char buf[1024];
int bytes = 0;
Old_Edje_Part_Collection *opc;
Edje_Part_Collection *npc;
char buf[1024];
int bytes = 0;
snprintf(buf, sizeof (buf), "collections/%i", ce->id);
opc = eet_data_read(ef, _edje_edd_old_edje_part_collection, buf);
if (!opc)
{
EINA_LOG_ERR("Unable to find collection `%s'[%i] in `%s'.", ce->entry, ce->id, argv[1]);
return -1;
}
snprintf(buf, sizeof (buf), "collections/%i", ce->id);
opc = eet_data_read(ef, _edje_edd_old_edje_part_collection, buf);
if (!opc)
{
EINA_LOG_ERR("Unable to find collection `%s'[%i] in `%s'.", ce->entry, ce->id, argv[1]);
return -1;
}
npc = _edje_collection_convert(ef, ce, opc);
npc = _edje_collection_convert(ef, ce, opc);
snprintf(buf, sizeof (buf), "edje/collections/%i", ce->id);
bytes = eet_data_write(ef, _edje_edd_edje_part_collection, buf, npc, 1);
if (bytes <= 0)
{
EINA_LOG_ERR("Unable to save `%s' in section `%s' of `%s'.", ce->entry, buf, argv[1]);
return -1;
}
snprintf(buf, sizeof (buf), "edje/collections/%i", ce->id);
bytes = eet_data_write(ef, _edje_edd_edje_part_collection, buf, npc, 1);
if (bytes <= 0)
{
EINA_LOG_ERR("Unable to save `%s' in section `%s' of `%s'.", ce->entry, buf, argv[1]);
return -1;
}
}
if (eet_data_write(ef, _edje_edd_edje_file, "edje/file", nef, 1) <= 0)
{
EINA_LOG_ERR("Unable to save main section of `%s'.", argv[1]);
return -1;
EINA_LOG_ERR("Unable to save main section of `%s'.", argv[1]);
return -1;
}
_edje_alias_string(argv[1], ef, "fonts", "edje/fonts");
@ -205,3 +205,4 @@ main(int argc, char **argv)
return 0;
}

View File

@ -26,12 +26,12 @@ Eet_Data_Descriptor *_edje_edd_old_edje_part_description = NULL;
Eet_Data_Descriptor *_edje_edd_old_edje_part_image_id = NULL;
Eet_Data_Descriptor *_edje_edd_old_edje_external_param = NULL;
#define FREED(eed) \
if (eed) \
{ \
eet_data_descriptor_free((eed)); \
(eed) = NULL; \
}
#define FREED(eed) \
if (eed) \
{ \
eet_data_descriptor_free((eed)); \
(eed) = NULL; \
}
void
_edje_edd_old_shutdown(void)
@ -74,8 +74,8 @@ _edje_edd_old_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_external_directory_entry, Edje_External_Directory_Entry, "entry", entry, EET_T_STRING);
eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
"Edje_External_Directory",
sizeof (Old_Edje_External_Directory));
"Edje_External_Directory",
sizeof (Old_Edje_External_Directory));
_edje_edd_old_edje_external_directory =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_external_directory, Edje_External_Directory, "entries", entries, _edje_edd_old_edje_external_directory_entry);
@ -88,8 +88,8 @@ _edje_edd_old_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_font_directory_entry, Edje_Font_Directory_Entry, "file", file, EET_T_STRING);
eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
"Edje_Font_Directory",
sizeof (Old_Edje_Font_Directory));
"Edje_Font_Directory",
sizeof (Old_Edje_Font_Directory));
_edje_edd_old_edje_font_directory =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_font_directory, Old_Edje_Font_Directory, "entries", entries, _edje_edd_old_edje_font_directory_entry);
@ -117,12 +117,12 @@ _edje_edd_old_init(void)
_edje_edd_old_edje_image_directory_set =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set, Edje_Image_Directory_Set, "name", name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set, Edje_Image_Directory_Set, "id", id, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_image_directory_set, Edje_Image_Directory_Set, "id", id, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_image_directory_set, Edje_Image_Directory_Set, "entries", entries, _edje_edd_old_edje_image_directory_set_entry);
eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
"Edje_Image_Directory",
sizeof (Old_Edje_Image_Directory));
"Edje_Image_Directory",
sizeof (Old_Edje_Image_Directory));
_edje_edd_old_edje_image_directory =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_image_directory, Old_Edje_Image_Directory, "entries", entries, _edje_edd_old_edje_image_directory_entry);
@ -136,15 +136,15 @@ _edje_edd_old_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part_collection_directory_entry, Edje_Part_Collection_Directory_Entry, "id", id, EET_T_INT);
eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
"Edje_Part_Collection_Directory",
sizeof (Old_Edje_Part_Collection_Directory));
"Edje_Part_Collection_Directory",
sizeof (Old_Edje_Part_Collection_Directory));
_edje_edd_old_edje_part_collection_directory =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection_directory, Old_Edje_Part_Collection_Directory, "entries", entries, _edje_edd_old_edje_part_collection_directory_entry);
/* generic data attachment */
eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
"Edje_Data", sizeof (Old_Edje_Data));
"Edje_Data", sizeof (Old_Edje_Data));
_edje_edd_old_edje_data =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_data, Old_Edje_Data, "key", key, EET_T_STRING);
@ -181,7 +181,7 @@ _edje_edd_old_init(void)
/* the main file directory */
eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc),
"Edje_File", sizeof (Old_Edje_File));
"Edje_File", sizeof (Old_Edje_File));
_edje_edd_old_edje_file =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_file, Old_Edje_File, "compiler", compiler, EET_T_STRING);
@ -364,7 +364,7 @@ _edje_edd_old_init(void)
EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Pack_Element);
_edje_edd_old_edje_pack_element =
eet_data_descriptor_file_new(&eddc);
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "type", type, EET_T_UCHAR);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "name", name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_pack_element, Edje_Pack_Element, "source", source, EET_T_STRING);
@ -433,7 +433,7 @@ _edje_edd_old_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "required", required, EET_T_UCHAR);
eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Edje_Part_Collection", sizeof (Old_Edje_Part_Collection));
_edje_edd_old_edje_part_collection =
_edje_edd_old_edje_part_collection =
eet_data_descriptor_file_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "programs", programs, _edje_edd_old_edje_program);
EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_old_edje_part_collection, Old_Edje_Part_Collection, "parts", parts, _edje_edd_old_edje_part);
@ -449,8 +449,9 @@ _edje_edd_old_init(void)
Old_Edje_Part_Collection epc;
eet_data_descriptor_element_add(_edje_edd_old_edje_part_collection,
"alias", EET_T_STRING, EET_G_HASH,
(char *)(&(epc.alias)) - (char *)(&(epc)),
0, /* 0, */NULL, NULL);
"alias", EET_T_STRING, EET_G_HASH,
(char *)(&(epc.alias)) - (char *)(&(epc)),
0, /* 0, */ NULL, NULL);
}
}

View File

@ -12,7 +12,6 @@
#include <sys/stat.h>
#include <errno.h>
#include <Ecore_File.h>
#include <Ecore_Evas.h>
@ -38,7 +37,6 @@ void output(void);
static int compiler_cmd_is_sane(void);
static int root_filename_is_sane(void);
static void
_edje_cc_log_cb(const Eina_Log_Domain *d,
Eina_Log_Level level,
@ -64,22 +62,27 @@ _edje_cc_log_cb(const Eina_Log_Domain *d,
switch (level)
{
case EINA_LOG_LEVEL_CRITICAL:
color = FOREGROUND_RED | FOREGROUND_INTENSITY;
break;
color = FOREGROUND_RED | FOREGROUND_INTENSITY;
break;
case EINA_LOG_LEVEL_ERR:
color = FOREGROUND_RED;
break;
color = FOREGROUND_RED;
break;
case EINA_LOG_LEVEL_WARN:
color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
case EINA_LOG_LEVEL_INFO:
color = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
color = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
break;
case EINA_LOG_LEVEL_DBG:
color = FOREGROUND_BLUE | FOREGROUND_INTENSITY;
break;
color = FOREGROUND_BLUE | FOREGROUND_INTENSITY;
break;
default:
color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);
#endif
@ -88,16 +91,19 @@ _edje_cc_log_cb(const Eina_Log_Domain *d,
switch (level)
{
case EINA_LOG_LEVEL_CRITICAL:
prefix = "Critical. ";
break;
prefix = "Critical. ";
break;
case EINA_LOG_LEVEL_ERR:
prefix = "Error. ";
break;
prefix = "Error. ";
break;
case EINA_LOG_LEVEL_WARN:
prefix = "Warning. ";
break;
prefix = "Warning. ";
break;
default:
prefix = "";
prefix = "";
}
fprintf(stderr, "%s: %s", progname, prefix);
@ -111,7 +117,6 @@ _edje_cc_log_cb(const Eina_Log_Domain *d,
#endif
}
vfprintf(stderr, fmt, args);
putc('\n', stderr);
}
@ -132,7 +137,7 @@ main_help(void)
" -current-dir\tOutput to current directory \n"
" -quiet\t\tProduce less output\n"
"\n"
,progname);
, progname);
}
Eet_File *ef;
@ -150,12 +155,12 @@ main(int argc, char **argv)
if (!eina_init())
exit(-1);
_edje_cc_log_dom = eina_log_domain_register
("edje_decc", EDJE_CC_DEFAULT_LOG_COLOR);
("edje_decc", EDJE_CC_DEFAULT_LOG_COLOR);
if (_edje_cc_log_dom < 0)
{
EINA_LOG_ERR("Impossible to create a log domain.");
eina_shutdown();
exit(-1);
EINA_LOG_ERR("Impossible to create a log domain.");
eina_shutdown();
exit(-1);
}
progname = ecore_file_file_get(argv[0]);
eina_log_print_cb_set(_edje_cc_log_cb, NULL);
@ -163,37 +168,37 @@ main(int argc, char **argv)
for (i = 1; i < argc; i++)
{
if (!strcmp(argv[i], "-h"))
{
main_help();
exit(0);
}
if (!file_in)
file_in = argv[i];
else if ((!strcmp(argv[i], "-main-out")) && (i < (argc - 1)))
{
i++;
if (!strcmp(argv[i], "-h"))
{
main_help();
exit(0);
}
if (!file_in)
file_in = argv[i];
else if ((!strcmp(argv[i], "-main-out")) && (i < (argc - 1)))
{
i++;
#ifndef _WIN32
file_out = argv[i];
file_out = argv[i];
#endif
}
else if (!strcmp(argv[i], "-no-build-sh"))
build_sh = 0;
else if (!strcmp(argv[i], "-current-dir"))
new_dir = 0;
}
else if (!strcmp(argv[i], "-no-build-sh"))
build_sh = 0;
else if (!strcmp(argv[i], "-current-dir"))
new_dir = 0;
else if (!strcmp(argv[i], "-quiet"))
eina_log_domain_level_set("edje_decc", EINA_LOG_LEVEL_WARN);
else if ((!strcmp(argv[i], "-o") || !strcmp(argv[i], "-output")) && (i < (argc - 1)))
{
i++;
outdir = strdup(argv[i]);
}
{
i++;
outdir = strdup(argv[i]);
}
}
if (!file_in)
{
ERR("no input file specified.");
main_help();
exit(-1);
ERR("no input file specified.");
main_help();
exit(-1);
}
if (!edje_init())
@ -220,41 +225,41 @@ decomp(void)
ef = eet_open(file_in, EET_FILE_MODE_READ);
if (!ef)
{
ERR("cannot open %s", file_in);
return 0;
ERR("cannot open %s", file_in);
return 0;
}
srcfiles = source_load(ef);
if (!srcfiles || !srcfiles->list)
{
ERR("%s has no decompile information", file_in);
eet_close(ef);
return 0;
ERR("%s has no decompile information", file_in);
eet_close(ef);
return 0;
}
if (!eina_list_data_get(srcfiles->list) || !root_filename_is_sane())
{
ERR("Invalid root filename: '%s'", (char *) eina_list_data_get(srcfiles->list));
eet_close(ef);
return 0;
ERR("Invalid root filename: '%s'", (char *)eina_list_data_get(srcfiles->list));
eet_close(ef);
return 0;
}
edje_file = eet_data_read(ef, _edje_edd_edje_file, "edje/file");
if (!edje_file)
{
ERR("%s does not appear to be an edje file", file_in);
eet_close(ef);
return 0;
eet_close(ef);
return 0;
}
/* force compiler to be edje_cc */
edje_file->compiler = strdup("edje_cc");
if (!edje_file->compiler)
{
edje_file->compiler = strdup("edje_cc");
edje_file->compiler = strdup("edje_cc");
}
else if (!compiler_cmd_is_sane())
{
ERR("invalid compiler executable: '%s'", edje_file->compiler);
eet_close(ef);
return 0;
ERR("invalid compiler executable: '%s'", edje_file->compiler);
eet_close(ef);
return 0;
}
fontlist = source_fontmap_load(ef);
return 1;
@ -270,122 +275,121 @@ output(void)
if (!outdir)
{
if (!new_dir)
outdir = strdup(".");
else
{
p = strrchr(file_in, '/');
if (p)
outdir = strdup(p + 1);
else
outdir = strdup(file_in);
p = strrchr(outdir, '.');
if (p) *p = 0;
ecore_file_mkpath(outdir);
}
if (!new_dir)
outdir = strdup(".");
else
{
p = strrchr(file_in, '/');
if (p)
outdir = strdup(p + 1);
else
outdir = strdup(file_in);
p = strrchr(outdir, '.');
if (p) *p = 0;
ecore_file_mkpath(outdir);
}
}
tef = eet_open(file_in, EET_FILE_MODE_READ);
if (edje_file->image_dir)
{
Edje_Image_Directory_Entry *ei;
unsigned int i;
unsigned int i;
for (i = 0; i < edje_file->image_dir->entries_count; ++i)
{
ei = &edje_file->image_dir->entries[i];
for (i = 0; i < edje_file->image_dir->entries_count; ++i)
{
ei = &edje_file->image_dir->entries[i];
if ((ei->source_type > EDJE_IMAGE_SOURCE_TYPE_NONE) &&
(ei->source_type < EDJE_IMAGE_SOURCE_TYPE_LAST) &&
(ei->source_type != EDJE_IMAGE_SOURCE_TYPE_USER) &&
(ei->entry))
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *im;
char buf[4096];
char out[4096];
char *pp;
if ((ei->source_type > EDJE_IMAGE_SOURCE_TYPE_NONE) &&
(ei->source_type < EDJE_IMAGE_SOURCE_TYPE_LAST) &&
(ei->source_type != EDJE_IMAGE_SOURCE_TYPE_USER) &&
(ei->entry))
{
Ecore_Evas *ee;
Evas *evas;
Evas_Object *im;
char buf[4096];
char out[4096];
char *pp;
ecore_init();
ecore_evas_init();
ee = ecore_evas_buffer_new(1, 1);
if (!ee)
{
ERR("Cannot create buffer engine canvas for image save.");
exit(-1);
}
evas = ecore_evas_get(ee);
im = evas_object_image_add(evas);
if (!im)
{
ERR("Cannot create image object for save.");
exit(-1);
}
snprintf(buf, sizeof(buf), "edje/images/%i", ei->id);
evas_object_image_file_set(im, file_in, buf);
snprintf(out, sizeof(out), "%s/%s", outdir, ei->entry);
INF("Output Image: %s", out);
pp = strdup(out);
p = strrchr(pp, '/');
if (p) *p = 0;
if (strstr(pp, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit(-1);
}
ecore_file_mkpath(pp);
free(pp);
ecore_init();
ecore_evas_init();
ee = ecore_evas_buffer_new(1, 1);
if (!ee)
{
ERR("Cannot create buffer engine canvas for image save.");
exit(-1);
}
evas = ecore_evas_get(ee);
im = evas_object_image_add(evas);
if (!im)
{
ERR("Cannot create image object for save.");
exit(-1);
}
snprintf(buf, sizeof(buf), "edje/images/%i", ei->id);
evas_object_image_file_set(im, file_in, buf);
snprintf(out, sizeof(out), "%s/%s", outdir, ei->entry);
INF("Output Image: %s", out);
pp = strdup(out);
p = strrchr(pp, '/');
if (p) *p = 0;
if (strstr(pp, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit(-1);
}
ecore_file_mkpath(pp);
free(pp);
if (!evas_object_image_save(im, out, NULL, "quality=100 compress=9 encoding=auto"))
{
ERR("Cannot write file %s. Perhaps missing JPEG or PNG saver modules for Evas.", out);
exit(-1);
}
evas_object_del(im);
ecore_evas_free(ee);
ecore_evas_shutdown();
ecore_shutdown();
}
}
{
ERR("Cannot write file %s. Perhaps missing JPEG or PNG saver modules for Evas.", out);
exit(-1);
}
evas_object_del(im);
ecore_evas_free(ee);
ecore_evas_shutdown();
ecore_shutdown();
}
}
}
EINA_LIST_FOREACH(srcfiles->list, l, sf)
{
char out[4096];
FILE *f;
char *pp;
char out[4096];
FILE *f;
char *pp;
snprintf(out, sizeof(out), "%s/%s", outdir, sf->name);
INF("Output Source File: %s", out);
pp = strdup(out);
p = strrchr(pp, '/');
if (p) *p = 0;
if (strstr(pp, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit (-1);
}
ecore_file_mkpath(pp);
free(pp);
if (strstr(out, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit (-1);
}
f = fopen(out, "wb");
if (!f)
{
ERR("Unable to write file (%s).", out);
exit (-1);
}
snprintf(out, sizeof(out), "%s/%s", outdir, sf->name);
INF("Output Source File: %s", out);
pp = strdup(out);
p = strrchr(pp, '/');
if (p) *p = 0;
if (strstr(pp, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit(-1);
}
ecore_file_mkpath(pp);
free(pp);
if (strstr(out, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit(-1);
}
f = fopen(out, "wb");
if (!f)
{
ERR("Unable to write file (%s).", out);
exit(-1);
}
/* if the file is empty, sf->file will be NULL.
* note that that's not an error
*/
if (sf->file) fputs(sf->file, f);
fclose(f);
/* if the file is empty, sf->file will be NULL.
* note that that's not an error
*/
if (sf->file) fputs(sf->file, f);
fclose(f);
}
if (edje_file->fonts)
{
@ -393,93 +397,91 @@ output(void)
Eina_Iterator *it;
it = eina_hash_iterator_data_new(edje_file->fonts);
EINA_ITERATOR_FOREACH(it, fn)
{
void *font;
int fontsize;
char out[4096];
EINA_ITERATOR_FOREACH(it, fn)
{
void *font;
int fontsize;
char out[4096];
/* FIXME!!!! */
/* should be fn->entry -v */
snprintf(out, sizeof(out), "edje/fonts/%s", fn->file);
font = eet_read(tef, out, &fontsize);
if (font)
{
FILE *f;
char *pp;
/* should be fn->entry -v */
snprintf(out, sizeof(out), "edje/fonts/%s", fn->file);
font = eet_read(tef, out, &fontsize);
if (font)
{
FILE *f;
char *pp;
/* should be fn->file -v */
snprintf(out, sizeof(out), "%s/%s", outdir, fn->entry);
INF("Output Font: %s", out);
pp = strdup(out);
p = strrchr(pp, '/');
if (p) *p = 0;
if (strstr(pp, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit (-1);
}
ecore_file_mkpath(pp);
free(pp);
if (strstr(out, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit (-1);
}
if (!(f = fopen(out, "wb")))
/* should be fn->file -v */
snprintf(out, sizeof(out), "%s/%s", outdir, fn->entry);
INF("Output Font: %s", out);
pp = strdup(out);
p = strrchr(pp, '/');
if (p) *p = 0;
if (strstr(pp, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit(-1);
}
ecore_file_mkpath(pp);
free(pp);
if (strstr(out, "../"))
{
ERR("Potential security violation. attempt to write in parent dir.");
exit(-1);
}
if (!(f = fopen(out, "wb")))
{
ERR("Could not open file: %s", out);
exit (-1);
exit(-1);
}
if (fwrite(font, fontsize, 1, f) != 1)
ERR("Could not write font: %s", strerror(errno));
if (f) fclose(f);
free(font);
}
}
if (fwrite(font, fontsize, 1, f) != 1)
ERR("Could not write font: %s", strerror(errno));
if (f) fclose(f);
free(font);
}
}
eina_iterator_free(it);
}
{
char out[4096];
FILE *f;
sf = eina_list_data_get(srcfiles->list);
{
char out[4096];
FILE *f;
sf = eina_list_data_get(srcfiles->list);
if (build_sh)
{
snprintf(out, sizeof(out), "%s/build.sh", outdir);
INF("Output Build Script: %s", out);
if (strstr(out, "../"))
{
ERR("potential security violation. attempt to write in parent dir.");
exit(-1);
}
if ((f = fopen(out, "wb")))
{
fprintf(f, "#!/bin/sh\n");
fprintf(f, "%s $@ -id . -fd . %s -o %s.edj\n",
edje_file->compiler, sf->name, outdir);
fclose(f);
if (chmod(out,
S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IWGRP | S_IXGRP) < 0)
ERR("chmod on %s failed", out);
}
if (build_sh)
{
snprintf(out, sizeof(out), "%s/build.sh", outdir);
INF("Output Build Script: %s", out);
if (strstr(out, "../"))
{
ERR("potential security violation. attempt to write in parent dir.");
exit (-1);
}
if ((f = fopen(out, "wb")))
{
fprintf(f, "#!/bin/sh\n");
fprintf(f, "%s $@ -id . -fd . %s -o %s.edj\n",
edje_file->compiler, sf->name, outdir);
fclose(f);
if (chmod(out,
S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IWGRP | S_IXGRP) < 0)
ERR("chmod on %s failed", out);
}
WRN("*** CAUTION ***\n"
"Please check the build script for anything malicious "
"before running it!\n\n");
}
WRN("*** CAUTION ***\n"
"Please check the build script for anything malicious "
"before running it!\n\n");
}
if (file_out)
{
snprintf(out, sizeof(out), "%s/%s", outdir, file_out);
if (ecore_file_symlink(sf->name, out) != EINA_TRUE)
{
ERR("symlink %s -> %s failed", sf->name, out);
}
}
}
if (file_out)
{
snprintf(out, sizeof(out), "%s/%s", outdir, file_out);
if (ecore_file_symlink(sf->name, out) != EINA_TRUE)
{
ERR("symlink %s -> %s failed", sf->name, out);
}
}
}
if (edje_file->sound_dir)
{
@ -524,9 +526,8 @@ output(void)
fclose(f);
}
else ERR("Could not open for writing sound: %s: %s", out1, strerror(errno));
}
}
}
}
if (edje_file->vibration_dir)
{
@ -571,7 +572,7 @@ output(void)
fclose(f);
}
else ERR("Could not open for writing sound: %s: %s", out1, strerror(errno));
}
}
}
}
@ -586,16 +587,16 @@ compiler_cmd_is_sane()
if ((!c) || (!*c))
{
return 0;
return 0;
}
for (ptr = c; ptr && *ptr; ptr++)
{
/* only allow [a-z][A-Z][0-9]_- */
if ((!isalnum(*ptr)) && (*ptr != '_') && (*ptr != '-'))
{
return 0;
}
/* only allow [a-z][A-Z][0-9]_- */
if ((!isalnum(*ptr)) && (*ptr != '_') && (*ptr != '-'))
{
return 0;
}
}
return 1;
@ -609,22 +610,27 @@ root_filename_is_sane()
if (!f || !*f)
{
return 0;
return 0;
}
for (ptr = f; ptr && *ptr; ptr++)
{
/* only allow [a-z][A-Z][0-9]_-./ */
switch (*ptr)
{
case '_': case '-': case '.': case '/':
break;
default:
if (!isalnum(*ptr))
{
return 0;
}
}
/* only allow [a-z][A-Z][0-9]_-./ */
switch (*ptr)
{
case '_':
case '-':
case '.':
case '/':
break;
default:
if (!isalnum(*ptr))
{
return 0;
}
}
}
return 1;
}

View File

@ -17,7 +17,7 @@ static int _log_dom;
#define ERR(...) EINA_LOG_DOM_ERR(_log_dom, __VA_ARGS__)
#define CRI(...) EINA_LOG_DOM_CRIT(_log_dom, __VA_ARGS__)
#define INDENT " "
#define INDENT " "
#define INDENT2 INDENT INDENT
#define INDENT3 INDENT2 INDENT
#define INDENT4 INDENT3 INDENT
@ -27,15 +27,14 @@ static char *module_patterns_str = NULL;
static int detail = 1;
static Eina_Bool machine = EINA_FALSE;
static char *type_glob = NULL;
static char * const *module_patterns;
static char *const *module_patterns;
static const Eina_List *modules;
static char *
_module_patterns_str_new(void)
{
Eina_Strbuf *buf;
char * const *itr;
char *const *itr;
char *ret;
if (!module_patterns) return strdup("*");
@ -53,7 +52,7 @@ _module_patterns_str_new(void)
static Eina_Bool
module_matches(const char *name)
{
char * const *itr;
char *const *itr;
if (!module_patterns) return EINA_TRUE;
for (itr = module_patterns; *itr != NULL; itr++)
@ -93,13 +92,18 @@ _param_type_str_get(const Edje_External_Param_Info *param)
switch (param->type)
{
case EDJE_EXTERNAL_PARAM_TYPE_INT: return "int";
case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: return "double";
case EDJE_EXTERNAL_PARAM_TYPE_STRING: return "string";
case EDJE_EXTERNAL_PARAM_TYPE_BOOL: return "bool";
case EDJE_EXTERNAL_PARAM_TYPE_CHOICE: return "choice";
default:
ERR("Unknown parameter type %d", param->type);
return "???";
ERR("Unknown parameter type %d", param->type);
return "???";
}
}
@ -109,38 +113,39 @@ _param_value_str_get(const Edje_External_Type *type, const Edje_External_Param_I
switch (param->type)
{
case EDJE_EXTERNAL_PARAM_TYPE_INT:
if (param->info.i.def == EDJE_EXTERNAL_INT_UNSET) return NULL;
snprintf(buf, buflen, "%d", param->info.i.def);
return buf;
if (param->info.i.def == EDJE_EXTERNAL_INT_UNSET) return NULL;
snprintf(buf, buflen, "%d", param->info.i.def);
return buf;
case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
if (EINA_DBL_EQ(param->info.d.def, EDJE_EXTERNAL_DOUBLE_UNSET)) return NULL;
snprintf(buf, buflen, "%g", param->info.d.def);
return buf;
if (EINA_DBL_EQ(param->info.d.def, EDJE_EXTERNAL_DOUBLE_UNSET)) return NULL;
snprintf(buf, buflen, "%g", param->info.d.def);
return buf;
case EDJE_EXTERNAL_PARAM_TYPE_STRING:
return param->info.s.def;
return param->info.s.def;
case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
if (param->info.b.def == 0) return "0";
else if (param->info.b.def == 1) return "1";
return NULL;
if (param->info.b.def == 0) return "0";
else if (param->info.b.def == 1)
return "1";
return NULL;
case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
{
char *def;
if (param->info.c.def) return param->info.c.def;
if (!param->info.c.def_get) return NULL;
def = param->info.c.def_get(type->data, param);
if (!def) return NULL;
eina_strlcpy(buf, def, buflen);
free(def);
return buf;
}
{
char *def;
if (param->info.c.def) return param->info.c.def;
if (!param->info.c.def_get) return NULL;
def = param->info.c.def_get(type->data, param);
if (!def) return NULL;
eina_strlcpy(buf, def, buflen);
free(def);
return buf;
}
default:
ERR("Unknown parameter type %d", param->type);
return NULL;
ERR("Unknown parameter type %d", param->type);
return NULL;
}
}
@ -179,7 +184,7 @@ _param_flags_str_get(const Edje_External_Param_Info *param)
}
static void
_param_choices_print(const char * const *choices)
_param_choices_print(const char *const *choices)
{
if (machine) puts("CHOICES-BEGIN");
else fputs(", choices:", stdout);
@ -201,90 +206,91 @@ _param_extra_details(const Edje_External_Type *type, const Edje_External_Param_I
switch (param->type)
{
case EDJE_EXTERNAL_PARAM_TYPE_INT:
if (param->info.i.min != EDJE_EXTERNAL_INT_UNSET)
{
if (machine) printf("MIN: %d\n", param->info.i.min);
else printf(", min: %d", param->info.i.min);
}
if (param->info.i.max != EDJE_EXTERNAL_INT_UNSET)
{
if (machine) printf("MAX: %d\n", param->info.i.max);
else printf(", max: %d", param->info.i.max);
}
if (param->info.i.step != EDJE_EXTERNAL_INT_UNSET)
{
if (machine) printf("STEP: %d\n", param->info.i.step);
else printf(", step: %d", param->info.i.step);
}
break;
case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
if (EINA_DBL_EQ(param->info.d.min, EDJE_EXTERNAL_DOUBLE_UNSET))
{
if (machine) printf("MIN: %g\n", param->info.d.min);
else printf(", min: %g", param->info.d.min);
}
if (EINA_DBL_EQ(param->info.d.max, EDJE_EXTERNAL_DOUBLE_UNSET))
{
if (machine) printf("MAX: %g\n", param->info.d.max);
else printf(", max: %g", param->info.d.max);
}
if (EINA_DBL_EQ(param->info.d.step, EDJE_EXTERNAL_DOUBLE_UNSET))
{
if (machine) printf("STEP: %g\n", param->info.d.step);
else printf(", step: %g", param->info.d.step);
}
break;
case EDJE_EXTERNAL_PARAM_TYPE_STRING:
if (param->info.s.accept_fmt)
{
if (machine) printf("ACCEPT_FMT: %s\n", param->info.s.accept_fmt);
else printf(", accept_fmt: \"%s\"", param->info.s.accept_fmt);
}
if (param->info.s.deny_fmt)
{
if (machine) printf("DENY_FMT: %s\n", param->info.s.deny_fmt);
else printf(", deny_fmt: \"%s\"", param->info.s.deny_fmt);
}
break;
case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
if (param->info.b.false_str)
{
if (machine) printf("FALSE_STR: %s\n", param->info.b.false_str);
else printf(", false_str: \"%s\"", param->info.b.false_str);
}
if (param->info.b.true_str)
{
if (machine) printf("TRUE_STR: %s\n", param->info.b.true_str);
else printf(", true_str: \"%s\"", param->info.b.true_str);
}
break;
case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
{
if (param->info.c.choices)
_param_choices_print(param->info.c.choices);
else if (param->info.c.query)
{
char **choices = param->info.c.query(type->data, param);
if (choices)
{
char **itr;
_param_choices_print((const char * const*)choices);
for (itr = choices; *itr; itr++) free(*itr);
free(choices);
}
}
}
if (param->info.i.min != EDJE_EXTERNAL_INT_UNSET)
{
if (machine) printf("MIN: %d\n", param->info.i.min);
else printf(", min: %d", param->info.i.min);
}
if (param->info.i.max != EDJE_EXTERNAL_INT_UNSET)
{
if (machine) printf("MAX: %d\n", param->info.i.max);
else printf(", max: %d", param->info.i.max);
}
if (param->info.i.step != EDJE_EXTERNAL_INT_UNSET)
{
if (machine) printf("STEP: %d\n", param->info.i.step);
else printf(", step: %d", param->info.i.step);
}
break;
case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE:
if (EINA_DBL_EQ(param->info.d.min, EDJE_EXTERNAL_DOUBLE_UNSET))
{
if (machine) printf("MIN: %g\n", param->info.d.min);
else printf(", min: %g", param->info.d.min);
}
if (EINA_DBL_EQ(param->info.d.max, EDJE_EXTERNAL_DOUBLE_UNSET))
{
if (machine) printf("MAX: %g\n", param->info.d.max);
else printf(", max: %g", param->info.d.max);
}
if (EINA_DBL_EQ(param->info.d.step, EDJE_EXTERNAL_DOUBLE_UNSET))
{
if (machine) printf("STEP: %g\n", param->info.d.step);
else printf(", step: %g", param->info.d.step);
}
break;
case EDJE_EXTERNAL_PARAM_TYPE_STRING:
if (param->info.s.accept_fmt)
{
if (machine) printf("ACCEPT_FMT: %s\n", param->info.s.accept_fmt);
else printf(", accept_fmt: \"%s\"", param->info.s.accept_fmt);
}
if (param->info.s.deny_fmt)
{
if (machine) printf("DENY_FMT: %s\n", param->info.s.deny_fmt);
else printf(", deny_fmt: \"%s\"", param->info.s.deny_fmt);
}
break;
case EDJE_EXTERNAL_PARAM_TYPE_BOOL:
if (param->info.b.false_str)
{
if (machine) printf("FALSE_STR: %s\n", param->info.b.false_str);
else printf(", false_str: \"%s\"", param->info.b.false_str);
}
if (param->info.b.true_str)
{
if (machine) printf("TRUE_STR: %s\n", param->info.b.true_str);
else printf(", true_str: \"%s\"", param->info.b.true_str);
}
break;
case EDJE_EXTERNAL_PARAM_TYPE_CHOICE:
{
if (param->info.c.choices)
_param_choices_print(param->info.c.choices);
else if (param->info.c.query)
{
char **choices = param->info.c.query(type->data, param);
if (choices)
{
char **itr;
_param_choices_print((const char *const *)choices);
for (itr = choices; *itr; itr++)
free(*itr);
free(choices);
}
}
}
break;
default:
ERR("Unknown parameter type %d", param->type);
ERR("Unknown parameter type %d", param->type);
}
if (!machine) fputs(" */", stdout); /* \n not desired */
if (!machine) fputs(" */", stdout); /* \n not desired */
}
static int
@ -397,12 +403,14 @@ _info_list(void)
if (!type->label_get) str = NULL;
else str = type->label_get(type->data);
if (machine) printf("LABEL: %s\n", str ? str : "");
else if (str) printf(INDENT3 "label: \"%s\";\n", str);
else if (str)
printf(INDENT3 "label: \"%s\";\n", str);
if (!type->description_get) str = NULL;
else str = type->description_get(type->data);
if (machine) printf("DESCRIPTION: %s\n", str ? str : "");
else if (str) printf(INDENT3 "description: \"%s\";\n", str);
else if (str)
printf(INDENT3 "description: \"%s\";\n", str);
}
if (machine) puts("PARAMS-BEGIN");
@ -420,9 +428,10 @@ _info_list(void)
if (detail > 0)
{
const char *str = _param_value_str_get
(type, param, buf, sizeof(buf));
(type, param, buf, sizeof(buf));
if (machine) printf("DEFAULT: %s\n", str ? str : "");
else if (str) printf(" \"%s\"", str);
else if (str)
printf(" \"%s\"", str);
if (detail > 1)
{
@ -432,7 +441,8 @@ _info_list(void)
}
if (machine) puts("PARAM-END");
else if (detail > 1) putchar('\n');
else if (detail > 1)
putchar('\n');
else puts(";");
}
@ -544,40 +554,40 @@ _modules_names_list(void)
}
static const char *mode_choices[] = {
"info",
"modules-names",
"types-names",
NULL,
"info",
"modules-names",
"types-names",
NULL,
};
static const char *detail_choices[] = {
"none",
"terse",
"all",
NULL
"none",
"terse",
"all",
NULL
};
const Ecore_Getopt optdesc = {
"edje_external_inspector",
"%prog [options] [module|module-glob] ... [module|module-glob]",
PACKAGE_VERSION,
"(C) 2010 - The Enlightenment Project",
"BSD",
"Edje external module inspector.",
0,
{
ECORE_GETOPT_CHOICE('m', "mode", "Choose which mode to operate.",
mode_choices),
ECORE_GETOPT_STORE_STR('t', "type", "Limit output to type (or glob)."),
ECORE_GETOPT_CHOICE('d', "detail", "Choose detail level (default=terse)",
detail_choices),
ECORE_GETOPT_STORE_TRUE('M', "machine", "Produce machine readable output."),
ECORE_GETOPT_LICENSE('L', "license"),
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
ECORE_GETOPT_VERSION('V', "version"),
ECORE_GETOPT_HELP('h', "help"),
ECORE_GETOPT_SENTINEL
}
"edje_external_inspector",
"%prog [options] [module|module-glob] ... [module|module-glob]",
PACKAGE_VERSION,
"(C) 2010 - The Enlightenment Project",
"BSD",
"Edje external module inspector.",
0,
{
ECORE_GETOPT_CHOICE('m', "mode", "Choose which mode to operate.",
mode_choices),
ECORE_GETOPT_STORE_STR('t', "type", "Limit output to type (or glob)."),
ECORE_GETOPT_CHOICE('d', "detail", "Choose detail level (default=terse)",
detail_choices),
ECORE_GETOPT_STORE_TRUE('M', "machine", "Produce machine readable output."),
ECORE_GETOPT_LICENSE('L', "license"),
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
ECORE_GETOPT_VERSION('V', "version"),
ECORE_GETOPT_HELP('h', "help"),
ECORE_GETOPT_SENTINEL
}
};
int
@ -589,15 +599,15 @@ main(int argc, char **argv)
int arg_index;
int ret = 0;
Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_STR(mode),
ECORE_GETOPT_VALUE_STR(type_glob),
ECORE_GETOPT_VALUE_STR(detail_name),
ECORE_GETOPT_VALUE_BOOL(machine),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_NONE
ECORE_GETOPT_VALUE_STR(mode),
ECORE_GETOPT_VALUE_STR(type_glob),
ECORE_GETOPT_VALUE_STR(detail_name),
ECORE_GETOPT_VALUE_BOOL(machine),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_NONE
};
setlocale(LC_NUMERIC, "C");
@ -609,7 +619,7 @@ main(int argc, char **argv)
edje_init();
_log_dom = eina_log_domain_register
("edje_external_inspector", EINA_COLOR_YELLOW);
("edje_external_inspector", EINA_COLOR_YELLOW);
if (_log_dom < 0)
{
EINA_LOG_CRIT
@ -625,27 +635,32 @@ main(int argc, char **argv)
ret = 1;
goto error_getopt;
}
else if (quit_option) goto error_getopt;
else if (quit_option)
goto error_getopt;
if (!mode) mode = (char *)mode_choices[0];
if (detail_name)
{
if (!strcmp(detail_name, "none")) detail = 0;
else if (!strcmp(detail_name, "terse")) detail = 1;
else if (!strcmp(detail_name, "all")) detail = 2;
else if (!strcmp(detail_name, "terse"))
detail = 1;
else if (!strcmp(detail_name, "all"))
detail = 2;
else ERR("Unknown detail level: '%s'", detail_name);
}
if (arg_index < argc) module_patterns = argv + arg_index;
else module_patterns = NULL;
else module_patterns = NULL;
modules = edje_available_modules_get();
module_patterns_str = _module_patterns_str_new();
if (!strcmp(mode, "info")) ret = _info_list();
else if (!strcmp(mode, "modules-names")) ret = _modules_names_list();
else if (!strcmp(mode, "types-names")) ret = _types_names_list();
else if (!strcmp(mode, "modules-names"))
ret = _modules_names_list();
else if (!strcmp(mode, "types-names"))
ret = _types_names_list();
else
{
ERR("Unknown mode: %s", mode);
@ -654,12 +669,13 @@ main(int argc, char **argv)
free(module_patterns_str);
error_getopt:
error_getopt:
eina_log_domain_unregister(_log_dom);
error_log:
error_log:
edje_shutdown();
ecore_shutdown();
eina_shutdown();
return ret;
}

File diff suppressed because it is too large Load Diff

View File

@ -15,22 +15,22 @@ Edje_Sound_Encode *
_edje_multisense_encode(const char *filename, Edje_Sound_Sample *sample, double quality EINA_UNUSED)
{
SF_INFO sfinfo;
SNDFILE* sfile;
SNDFILE *sfile;
Edje_Sound_Encode *enc_info;
enc_info = calloc(1, sizeof(Edje_Sound_Encode));
if (!enc_info)
{
ERR("while allocating memory to load file ");
exit(-1);
}
memset (&sfinfo, 0, sizeof (SF_INFO));
memset(&sfinfo, 0, sizeof (SF_INFO));
enc_info->encoded = EINA_FALSE;
enc_info->comp_type = "RAW PCM";
// Open wav file using sndfile
sfile = sf_open (filename, SFM_READ, &sfinfo);
sfile = sf_open(filename, SFM_READ, &sfinfo);
if (!sfile)
{
ERR("Unable to open audio file: %s", filename);
@ -82,7 +82,7 @@ _edje_multisense_encode(const char *filename, Edje_Sound_Sample *sample, double
}
#ifdef HAVE_LIBFLAC
const char*
const char *
_edje_multisense_encode_to_flac(char *snd_path, SF_INFO sfinfo)
{
unsigned int total_samples = 0; /* can use a 32-bit number due to WAVE size limitations */
@ -164,14 +164,14 @@ _edje_multisense_encode_to_flac(char *snd_path, SF_INFO sfinfo)
ok = 0;
}
}
/* read blocks of samples from WAVE file and feed to encoder */
while (ok)
{
FLAC__int32 readbuffer[READBUF * 2];
sf_count_t count;
int i;
count = sf_readf_int(sfile, readbuffer, READBUF);
if (count <= 0) break;
for (i = 0; i < (count * sfinfo.channels); i++)
@ -187,8 +187,9 @@ _edje_multisense_encode_to_flac(char *snd_path, SF_INFO sfinfo)
FLAC__stream_encoder_delete(encoder);
sf_close(sfile);
return (snd_path);
return snd_path;
}
#endif
#ifdef HAVE_VORBIS
@ -233,7 +234,7 @@ _edje_multisense_encode_to_ogg_vorbis(char *snd_path, double quality, SF_INFO sf
/********** Encode setup ************/
vorbis_info_init(&vi);
ret = vorbis_encode_init(&vi, sfinfo.channels, sfinfo.samplerate,
ret = vorbis_encode_init(&vi, sfinfo.channels, sfinfo.samplerate,
-1, (long)(quality * 1000), -1);
if (ret == OV_EFAULT) printf("OV_EFAULT\n");
if (ret == OV_EINVAL) printf("OV_EINVAL\n");
@ -280,7 +281,7 @@ _edje_multisense_encode_to_ogg_vorbis(char *snd_path, double quality, SF_INFO sf
int i, ch;
float readbuffer[READBUF * 2];
sf_count_t count;
count = sf_readf_float(sfile, readbuffer, READBUF);
if (!count)
@ -288,12 +289,12 @@ _edje_multisense_encode_to_ogg_vorbis(char *snd_path, double quality, SF_INFO sf
else
{
float **buffer = vorbis_analysis_buffer(&vd, count);
/* uninterleave samples */
for (i = 0; i < count; i++)
{
for (ch = 0; ch < sfinfo.channels; ch++)
buffer[ch][i]= readbuffer[(i * sfinfo.channels) + ch];
buffer[ch][i] = readbuffer[(i * sfinfo.channels) + ch];
}
vorbis_analysis_wrote(&vd, i);
}
@ -322,8 +323,9 @@ _edje_multisense_encode_to_ogg_vorbis(char *snd_path, double quality, SF_INFO sf
vorbis_comment_clear(&vc);
vorbis_info_clear(&vi);
sf_close(sfile);
fclose (fout);
fclose(fout);
return snd_path;
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -590,6 +590,7 @@ _slave_mode(void *data, Ecore_Fd_Handler *fd_handler)
return ECORE_CALLBACK_RENEW;
}
#endif
static void
@ -1124,9 +1125,9 @@ main(int argc, char **argv)
f = eina_file_open(opts.file, EINA_FALSE);
if (edje_mmap_3d_has(f, group))
{
Eina_List* engine_list, *n;
Eina_List *engine_list, *n;
Eina_Bool opengl_x11_has = EINA_FALSE, wayland_egl_has = EINA_FALSE;
const char* engine;
const char *engine;
engine_list = ecore_evas_engines_get();
EINA_LIST_FOREACH(engine_list, n, engine)
{

View File

@ -43,7 +43,7 @@ read_watch_file(const char *file)
const char *path;
Eina_Bool do_append = EINA_TRUE;
if (ln->length < 4) continue ;
if (ln->length < 4) continue;
if (anotate)
{
path = eina_stringshare_add_length(ln->start + 3, ln->length - 3);
@ -56,7 +56,7 @@ read_watch_file(const char *file)
path = eina_stringshare_add_length(ln->start, ln->length);
}
if (do_append)
r = eina_list_append(r, eio_monitor_add(path));
r = eina_list_append(r, eio_monitor_add(path));
eina_stringshare_del(path);
}
eina_iterator_free(it);
@ -65,7 +65,7 @@ read_watch_file(const char *file)
eio_monitor_del(mon);
watching = r;
err:
err:
eina_file_close(f);
}
@ -150,3 +150,4 @@ main(int argc, char **argv)
return 1;
}