diff options
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/Makefile.am | 38 | ||||
-rw-r--r-- | src/bin/edje_cc.c | 134 | ||||
-rw-r--r-- | src/bin/edje_cc.h | 18 | ||||
-rw-r--r-- | src/bin/edje_cc_handlers.c | 690 | ||||
-rw-r--r-- | src/bin/edje_cc_mem.c | 8 | ||||
-rw-r--r-- | src/bin/edje_cc_out.c | 1764 | ||||
-rw-r--r-- | src/bin/edje_cc_parse.c | 275 | ||||
-rw-r--r-- | src/bin/edje_cc_sources.c | 12 | ||||
-rw-r--r-- | src/bin/edje_convert.c | 6 | ||||
-rw-r--r-- | src/bin/edje_convert_main.c | 5 | ||||
-rw-r--r-- | src/bin/edje_decc.c | 122 | ||||
-rw-r--r-- | src/bin/edje_decc.h | 9 | ||||
-rw-r--r-- | src/bin/edje_inspector.c | 2 | ||||
-rw-r--r-- | src/bin/edje_multisense_convert.c | 6 | ||||
-rw-r--r-- | src/bin/edje_player.c | 14 | ||||
-rw-r--r-- | src/bin/edje_watch.c | 137 | ||||
-rw-r--r-- | src/bin/epp/cpplib.c | 36 | ||||
-rw-r--r-- | src/bin/epp/cpplib.h | 5 |
18 files changed, 2111 insertions, 1170 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index a936d5a..ccb6580 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -8,8 +8,16 @@ bin_SCRIPTS = @EDJE_RECC_PRG@ bin_PROGRAMS = @EDJE_CC_PRG@ @EDJE_DECC_PRG@ @EDJE_PLAYER_PRG@ @EDJE_INSPECTOR_PRG@ @EDJE_EXTERNAL_INSPECTOR_PRG@ +if BUILD_EDJE_WATCH +bin_PROGRAMS += @EDJE_WATCH_PRG@ +endif + EXTRA_PROGRAMS = edje_cc edje_decc edje_player edje_inspector edje_external_inspector +if BUILD_EDJE_WATCH +EXTRA_PROGRAMS += edje_watch +endif + edje_cc_SOURCES = \ edje_cc.c \ edje_cc_out.c \ @@ -26,10 +34,20 @@ edje_cc_CPPFLAGS = \ -DPACKAGE_LIB_DIR=\"$(libdir)\" \ -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \ -DEPP_DIR=\"$(libdir)/$(PACKAGE)/utils\" \ -@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EVIL_CFLAGS@ @SNDFILE_CFLAGS@ -edje_cc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_CC_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ -lm +@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EIO_CFLAGS@ @EVIL_CFLAGS@ @SNDFILE_CFLAGS@ +edje_cc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_CC_LIBS@ @EDJE_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ -lm edje_cc_LDFLAGS = @lt_enable_auto_import@ +edje_watch_SOURCES = \ +edje_watch.c + +edje_watch_CPPFLAGS = \ +-I$(top_srcdir)/src/bin \ +-I$(top_srcdir)/src/lib \ +-DPACKAGE_BIN_DIR=\"$(bindir)\" \ +@EDJE_CFLAGS@ @EDJE_CC_CFLAGS@ @EIO_CFLAGS@ @EVIL_CFLAGS@ @EDJE_WATCH_CFLAGS@ +edje_watch_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_WATCH_LIBS@ @EDJE_LIBS@ +edje_watch_LDFLAGS = @lt_enable_auto_import@ edje_decc_SOURCES = \ edje_decc.c \ @@ -40,32 +58,32 @@ edje_cc_sources.c edje_decc_CPPFLAGS = \ -I$(top_srcdir)/src/bin \ -I$(top_srcdir)/src/lib \ -@EDJE_CFLAGS@ @EDJE_DECC_CFLAGS@ @EVIL_CFLAGS@ -edje_decc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_DECC_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ +@EDJE_CFLAGS@ @EDJE_DECC_CFLAGS@ @EIO_CFLAGS@ @EVIL_CFLAGS@ +edje_decc_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_DECC_LIBS@ @EDJE_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ edje_decc_LDFLAGS = @lt_enable_auto_import@ edje_player_SOURCES = edje_player.c edje_player_CPPFLAGS = \ -I$(top_srcdir)/src/bin \ -I$(top_srcdir)/src/lib \ -@EDJE_PLAYER_CFLAGS@ @EVIL_CFLAGS@ -edje_player_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_PLAYER_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ +@EDJE_PLAYER_CFLAGS@ @EVIL_CFLAGS@ @EIO_CFLAGS@ +edje_player_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_PLAYER_LIBS@ @EDJE_LIBS@ @EVIL_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ edje_player_LDFLAGS = @lt_enable_auto_import@ edje_inspector_SOURCES = edje_inspector.c edje_inspector_CPPFLAGS = \ -I$(top_srcdir)/src/bin \ -I$(top_srcdir)/src/lib \ -@EDJE_INSPECTOR_CFLAGS@ -edje_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ +@EDJE_INSPECTOR_CFLAGS@ @EIO_CFLAGS@ +edje_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_INSPECTOR_LIBS@ @EDJE_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ edje_inspector_LDFLAGS = @lt_enable_auto_import@ edje_external_inspector_SOURCES = edje_external_inspector.c edje_external_inspector_CPPFLAGS = \ -I$(top_srcdir)/src/bin \ -I$(top_srcdir)/src/lib \ -@EDJE_EXTERNAL_INSPECTOR_CFLAGS@ -edje_external_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_EXTERNAL_INSPECTOR_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ +@EDJE_EXTERNAL_INSPECTOR_CFLAGS@ @EIO_CFLAGS@ +edje_external_inspector_LDADD = $(top_builddir)/src/lib/libedje.la @EDJE_EXTERNAL_INSPECTOR_LIBS@ @EDJE_LIBS@ @VORBISENC_LIBS@ @FLAC_LIBS@ @SNDFILE_LIBS@ edje_external_inspector_LDFLAGS = @lt_enable_auto_import@ EXTRA_DIST = @EDJE_RECC_PRG@ edje_cc.h edje_convert.h edje_convert.c edje_multisense_convert.h edje_data_convert.c diff --git a/src/bin/edje_cc.c b/src/bin/edje_cc.c index 63cb173..ce42f2c 100644 --- a/src/bin/edje_cc.c +++ b/src/bin/edje_cc.c @@ -19,8 +19,9 @@ Eina_List *defines = NULL; char *file_in = NULL; char *tmp_dir = NULL; char *file_out = NULL; -char *progname = NULL; -int verbose = 0; +char *watchfile = NULL; + +static const char *progname = NULL; int no_lossy = 0; int no_comp = 0; @@ -28,6 +29,88 @@ int no_raw = 0; int no_save = 0; int min_quality = 0; int max_quality = 100; +int compress_mode = EET_COMPRESSION_DEFAULT; +int threads = 0; + +static void +_edje_cc_log_cb(const Eina_Log_Domain *d, + Eina_Log_Level level, + const char *file, + const char *fnc, + int line, + const char *fmt, + __UNUSED__ void *data, + va_list args) +{ + if ((d->name) && (d->namelen == sizeof("edje_cc") - 1) && + (memcmp(d->name, "edje_cc", sizeof("edje_cc") - 1) == 0)) + { + const char *prefix; + Eina_Bool use_color = !eina_log_color_disable_get(); + + if (use_color) + { +#ifndef _WIN32 + fputs(eina_log_level_color_get(level), stderr); +#else + int color; + switch (level) + { + case EINA_LOG_LEVEL_CRITICAL: + color = FOREGROUND_RED | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_ERR: + color = FOREGROUND_RED; + break; + case EINA_LOG_LEVEL_WARN: + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_INFO: + color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_DBG: + color = FOREGROUND_BLUE | FOREGROUND_INTENSITY; + break; + default: + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; + } + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); +#endif + } + + switch (level) + { + case EINA_LOG_LEVEL_CRITICAL: + prefix = "Critical. "; + break; + case EINA_LOG_LEVEL_ERR: + prefix = "Error. "; + break; + case EINA_LOG_LEVEL_WARN: + prefix = "Warning. "; + break; + default: + prefix = ""; + } + fprintf(stderr, "%s: %s", progname, prefix); + + if (use_color) + { +#ifndef _WIN32 + fputs(EINA_COLOR_RESET, stderr); +#else + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); +#endif + } + + + vfprintf(stderr, fmt, args); + putc('\n', stderr); + } + else + eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args); +} static void main_help(void) @@ -38,6 +121,7 @@ main_help(void) "\n" "Where OPTIONS is one or more of:\n" "\n" + "-w files.txt Dump all sources files path into files.txt\n" "-id image/directory Add a directory to look in for relative path images\n" "-fd font/directory Add a directory to look in for relative path fonts\n" "-sd sound/directory Add a directory to look in for relative path sounds samples\n" @@ -50,6 +134,10 @@ main_help(void) "-min-quality VAL Do NOT allow lossy images with quality < VAL (0-100)\n" "-max-quality VAL Do NOT allow lossy images with quality > VAL (0-100)\n" "-Ddefine_val=to CPP style define to define input macro definitions to the .edc source\n" + "-fastcomp Use a faster compression algorithm (LZ4) (mutually exclusive with -fastdecomp)\n" + "-fastdecomp Use a faster decompression algorithm (LZ4HC) (mutually exclusive with -fastcomp)\n" + "-threads Compile the edje file using multiple parallel threads (by default)\n" + "-nothreads Compile the edje file using only the main loop\n" ,progname); } @@ -72,6 +160,9 @@ main(int argc, char **argv) EINA_LOG_ERR("Enable to create a log domain."); exit(-1); } + progname = ecore_file_file_get(argv[0]); + eina_log_print_cb_set(_edje_cc_log_cb, NULL); + tmp_dir = getenv("TMPDIR"); img_dirs = eina_list_append(img_dirs, "."); @@ -79,7 +170,6 @@ main(int argc, char **argv) /* add defines to epp so edc files can detect edje_cc version */ defines = eina_list_append(defines, mem_strdup("-DEDJE_VERSION_12=12")); - progname = argv[0]; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h")) @@ -89,7 +179,7 @@ main(int argc, char **argv) } else if (!strcmp(argv[i], "-v")) { - verbose = 1; + eina_log_domain_level_set("edje_cc", EINA_LOG_LEVEL_INFO); } else if (!strcmp(argv[i], "-no-lossy")) { @@ -142,6 +232,22 @@ main(int argc, char **argv) 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")) + { + compress_mode = EET_COMPRESSION_VERYFAST; + } + else if (!strcmp(argv[i], "-threads")) + { + threads = 1; + } + else if (!strcmp(argv[i], "-nothreads")) + { + threads = 0; + } else if (!strncmp(argv[i], "-D", 2)) { defines = eina_list_append(defines, mem_strdup(argv[i])); @@ -151,18 +257,27 @@ main(int argc, char **argv) i++; file_out = argv[i]; } + else if ((!strcmp(argv[i], "-w")) && (i < (argc - 1))) + { + i++; + watchfile = argv[i]; + unlink(watchfile); + } else if (!file_in) file_in = argv[i]; else if (!file_out) file_out = argv[i]; } + if (!file_in) { - fprintf(stderr, "%s: Error: no input file specified.\n", progname); + 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. */ @@ -181,7 +296,7 @@ main(int argc, char **argv) if (stat(file_in, &st) || !S_ISREG(st.st_mode)) #endif { - fprintf(stderr, "%s: Error: file not found: %s.\n", progname, file_in); + ERR("file not found: %s.", file_in); main_help(); exit(-1); } @@ -202,7 +317,7 @@ main(int argc, char **argv) } if (!file_out) { - fprintf(stderr, "%s: Error: no output file specified.\n", progname); + ERR("no output file specified."); main_help(); exit(-1); } @@ -213,12 +328,15 @@ main(int argc, char **argv) if (!strcmp (file_in, file_out)) #endif { - fprintf(stderr, "%s: Error: input file equals output file.\n", progname); + ERR("input file equals output file."); main_help(); exit(-1); } _on_edjecc = EINA_TRUE; + + using_file(file_in); + if (!edje_init()) exit(-1); diff --git a/src/bin/edje_cc.h b/src/bin/edje_cc.h index 0291f29..d9468b6 100644 --- a/src/bin/edje_cc.h +++ b/src/bin/edje_cc.h @@ -17,6 +17,7 @@ extern Eina_Prefix *pfx; /* logging variables */ extern int _edje_cc_log_dom ; #define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN + #ifdef ERR # undef ERR #endif @@ -29,7 +30,14 @@ extern int _edje_cc_log_dom ; # undef WRN #endif #define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__) - +#ifdef CRIT +# undef CRIT +#endif +#define CRIT(...) EINA_LOG_DOM_CRIT(_edje_cc_log_dom, __VA_ARGS__) +#ifdef DBG +# undef DBG +#endif +#define DBG(...) EINA_LOG_DOM_DBG(_edje_cc_log_dom, __VA_ARGS__) /* types */ typedef struct _New_Object_Handler New_Object_Handler; @@ -194,6 +202,8 @@ void *mem_alloc(size_t size); char *mem_strdup(const char *s); #define SZ sizeof +void using_file(const char *filename); + void error_and_abort(Eet_File *ef, const char *fmt, ...); /* global vars */ @@ -204,8 +214,7 @@ extern Eina_List *snd_dirs; extern char *file_in; extern char *tmp_dir; extern char *file_out; -extern char *progname; -extern int verbose; +extern char *watchfile; extern int no_lossy; extern int no_comp; extern int no_raw; @@ -224,6 +233,7 @@ extern Eina_List *defines; extern Eina_List *aliases; extern New_Object_Handler object_handlers[]; extern New_Statement_Handler statement_handlers[]; - +extern int compress_mode; +extern int threads; #endif diff --git a/src/bin/edje_cc_handlers.c b/src/bin/edje_cc_handlers.c index eb5da0f..3799e6e 100644 --- a/src/bin/edje_cc_handlers.c +++ b/src/bin/edje_cc_handlers.c @@ -40,7 +40,7 @@ /** * @page edcref Edje Data Collection reference * An Edje Data Collection, it's a plain text file (normally identified with the - * .edc extension),consisting of instructions for the Edje Compiler. + * .edc extension), consisting of instructions for the Edje Compiler. * * The syntax for the edje data collection files follows a simple structure of * "blocks { .. }" that can contain "properties: ..", more blocks, or both. @@ -142,6 +142,7 @@ static void st_collections_group_parts_part_entry_mode(void); static void st_collections_group_parts_part_select_mode(void); static void st_collections_group_parts_part_cursor_mode(void); static void st_collections_group_parts_part_multiline(void); +static void st_collections_group_parts_part_access(void); static void st_collections_group_parts_part_dragable_x(void); static void st_collections_group_parts_part_dragable_y(void); static void st_collections_group_parts_part_dragable_confine(void); @@ -170,6 +171,7 @@ static void st_collections_group_parts_part_description_inherit(void); static void st_collections_group_parts_part_description_source(void); static void st_collections_group_parts_part_description_state(void); static void st_collections_group_parts_part_description_visible(void); +static void st_collections_group_parts_part_description_limit(void); static void st_collections_group_parts_part_description_align(void); static void st_collections_group_parts_part_description_fixed(void); static void st_collections_group_parts_part_description_min(void); @@ -386,6 +388,7 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.select_mode", st_collections_group_parts_part_select_mode}, {"collections.group.parts.part.cursor_mode", st_collections_group_parts_part_cursor_mode}, {"collections.group.parts.part.multiline", st_collections_group_parts_part_multiline}, + {"collections.group.parts.part.access", st_collections_group_parts_part_access}, {"collections.group.parts.part.image", st_images_image}, /* dup */ {"collections.group.parts.part.set.name", st_images_set_name}, {"collections.group.parts.part.set.image.image", st_images_set_image_image}, @@ -433,6 +436,7 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.source", st_collections_group_parts_part_description_source}, {"collections.group.parts.part.description.state", st_collections_group_parts_part_description_state}, {"collections.group.parts.part.description.visible", st_collections_group_parts_part_description_visible}, + {"collections.group.parts.part.description.limit", st_collections_group_parts_part_description_limit}, {"collections.group.parts.part.description.align", st_collections_group_parts_part_description_align}, {"collections.group.parts.part.description.fixed", st_collections_group_parts_part_description_fixed}, {"collections.group.parts.part.description.min", st_collections_group_parts_part_description_min}, @@ -874,6 +878,7 @@ _edje_part_description_alloc(unsigned char type, const char *collection, const c switch (type) { + case EDJE_PART_TYPE_SPACER: case EDJE_PART_TYPE_RECTANGLE: case EDJE_PART_TYPE_SWALLOW: case EDJE_PART_TYPE_GROUP: @@ -970,8 +975,9 @@ _edje_part_description_alloc(unsigned char type, const char *collection, const c if (!result) { - ERR("%s: Error. Unknown type %i of part %s in collection %s.", progname, type, part, collection); - exit(-1); + ERR("Unknown type %i of part %s in collection %s.", + type, part, collection); + exit(-1); } return result; @@ -993,8 +999,8 @@ _edje_program_check(const char *name, Edje_Program *me, Edje_Program **pgrms, un epp = (Edje_Program_Parser *)pgrms[i]; if (!epp->can_override) { - ERR("%s: Error. parse error %s:%i. There is already a program of the name %s\n", - progname, file_in, line - 1, name); + ERR("parse error %s:%i. There is already a program of the name %s", + file_in, line - 1, name); exit(-1); } else @@ -1072,9 +1078,8 @@ _edje_program_copy(Edje_Program *ep, Edje_Program *ep2) data_queue_copied_part_lookup(pc, &(et2->id), &(et->id)); else { - ERR("%s: Error. parse error %s:%i. " - "target may only be used after action", - progname, file_in, line - 1); + ERR("parse error %s:%i. target may only be used after action", + file_in, line - 1); exit(-1); } } @@ -1163,7 +1168,7 @@ st_externals_external(void) 0, sizeof (Edje_External_Directory)); if (!edje_file->external_dir->entries) { - ERR("%s: Error. not enough memory", progname); + ERR("not enough memory"); exit(-1); } @@ -1220,7 +1225,7 @@ st_externals_external(void) Compression methods: @li RAW: Uncompressed. @li COMP: Lossless compression. - @li LOSSY [0-100]: Lossy comression with quality from 0 to 100. + @li LOSSY [0-100]: Lossy compression with quality from 0 to 100. @li USER: Do not embed the file, refer to the external file instead. @endproperty */ @@ -1251,8 +1256,8 @@ st_images_image(void) 0, sizeof (Edje_Image_Directory_Entry)); if (!edje_file->image_dir->entries) { - ERR("%s: Error. No enough memory.", progname); - exit(-1); + ERR("No enough memory."); + exit(-1); } img = edje_file->image_dir->entries + edje_file->image_dir->entries_count - 1; @@ -1340,8 +1345,8 @@ ob_images_set(void) 0, sizeof (Edje_Image_Directory_Set)); if (!edje_file->image_dir->sets) { - ERR("%s: Error. Not enough memory.", progname); - exit(-1); + ERR("Not enough memory."); + exit(-1); } edje_file->image_dir->sets[edje_file->image_dir->sets_count - 1].id = edje_file->image_dir->sets_count - 1; } @@ -1365,6 +1370,16 @@ st_images_set_name(void) edje_file->image_dir->sets[edje_file->image_dir->sets_count - 1].name = parse_str(0); } +/** + @page edcref + + @block + image + @description + The "image" block inside a "set" block define the characteristic of an image. + Every block will describe one image and the size rule to use it. + @endblock +**/ static void ob_images_set_image(void) { @@ -1378,6 +1393,23 @@ ob_images_set_image(void) set->entries = eina_list_append(set->entries, entry); } +/** + @page edcref + + @property + image + @parameters + [image file] [compression method] (compression level) + @effect + Used to include each image file. The full path to the directory holding + the images can be defined later with edje_cc's "-id" option. + Compression methods: + @li RAW: Uncompressed. + @li COMP: Lossless compression. + @li LOSSY [0-100]: Lossy compression with quality from 0 to 100. + @li USER: Do not embed the file, refer to the external file instead. + @endproperty +**/ static void st_images_set_image_image(void) { @@ -1429,8 +1461,8 @@ st_images_set_image_size(void) if (entry->size.min.w > entry->size.max.w || entry->size.min.h > entry->size.max.h) { - ERR("%s: Error. parse error %s:%i. Image min and max size are not in the right order ([%i, %i] < [%i, %i])", - progname, file_in, line - 1, + ERR("parse error %s:%i. Image min and max size are not in the right order ([%i, %i] < [%i, %i])", + file_in, line - 1, entry->size.min.w, entry->size.min.h, entry->size.max.w, entry->size.max.h); exit(-1); @@ -1540,7 +1572,7 @@ st_data_item(void) @parameters [parameter name] [parameter filename] @effect - Defines a new parameter , the value will be the contents of the + Defines a new parameter, the value will be the contents of the specified file formated as a single string of text. This property only works with plain text files. @endproperty @@ -1568,23 +1600,23 @@ st_data_file(void) fd = open(filename, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR); if (fd < 0) { - ERR("%s: Error. %s:%i when opening file \"%s\": \"%s\"", - progname, file_in, line, filename, strerror(errno)); + ERR("%s:%i when opening file \"%s\": \"%s\"", + file_in, line, filename, strerror(errno)); exit(-1); } if (fstat(fd, &buf)) { - ERR("%s: Error. %s:%i when stating file \"%s\": \"%s\"", - progname, file_in, line, filename, strerror(errno)); + ERR("%s:%i when stating file \"%s\": \"%s\"", + file_in, line, filename, strerror(errno)); exit(-1); } data = mmap(NULL, buf.st_size, PROT_READ, MAP_SHARED, fd, 0); if (data == MAP_FAILED) { - ERR("%s: Error. %s:%i when mapping file \"%s\": \"%s\"", - progname, file_in, line, filename, strerror(errno)); + ERR("%s:%i when mapping file \"%s\": \"%s\"", + file_in, line, filename, strerror(errno)); exit(-1); } @@ -1592,8 +1624,7 @@ st_data_file(void) for (i = 0; i < buf.st_size; ++i, ++over) if (*over == '\0') { - ERR("%s: Error. %s:%i file \"%s\" is a binary file.", - progname, file_in, line, filename); + ERR("%s:%i file \"%s\" is a binary file.", file_in, line, filename); exit(-1); } @@ -1677,8 +1708,8 @@ st_color_class_name(void) { if ((cc != tcc) && (!strcmp(cc->name, tcc->name))) { - fprintf(stderr, "%s: Error. parse error %s:%i. There is already a color class named \"%s\"\n", - progname, file_in, line - 1, cc->name); + ERR("parse error %s:%i. There is already a color class named \"%s\"", + file_in, line - 1, cc->name); exit(-1); } } @@ -1808,8 +1839,8 @@ st_styles_style_name(void) { if (stl->name && tstl->name && (stl != tstl) && (!strcmp(stl->name, tstl->name))) { - ERR("%s: Error. parse error %s:%i. There is already a style named \"%s\"", - progname, file_in, line - 1, stl->name); + ERR("parse error %s:%i. There is already a style named \"%s\"", + file_in, line - 1, stl->name); exit(-1); } } @@ -1835,9 +1866,9 @@ st_styles_style_base(void) stl = eina_list_data_get(eina_list_last(edje_file->styles)); if (stl->tags) { - ERR("%s: Error. parse error %s:%i. There is already a basic format for the style", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. There is already a basic format for the style", + file_in, line - 1); + exit(-1); } tag = mem_alloc(SZ(Edje_Style_Tag)); tag->key = mem_strdup("DEFAULT"); @@ -1931,7 +1962,7 @@ ob_collections(void) source: "sound_file3.wav"; } sample { - name: "sound_file4" AS-IS; + name: "sound_file4" AS_IS; source: "sound_file1.wav"; } @description @@ -1946,7 +1977,7 @@ ob_collections(void) the sounds can be defined later with edje_cc's "-sd" option. @li RAW: Uncompressed. @li COMP: Lossless compression. - @li LOSSY [45.0 - 1000.0]: Lossy comression with quality from 45.0 to 1000.0. + @li LOSSY [-0.1 - 1.0]: Lossy compression with quality from 0 to 1.0. @li AS_IS: Check for re-encoding, no compression/encoding, just write the file information as it is. @endproperty @since 1.1.0 @@ -1980,7 +2011,7 @@ st_collections_group_sound_sample_name(void) if (!edje_file->sound_dir->samples) { - ERR("%s: Error. No enough memory.", progname); + ERR("No enough memory."); exit(-1); } @@ -2027,7 +2058,7 @@ st_collections_group_sound_sample_source(void) if (!edje_file->sound_dir->samples) { - ERR("%s: Error. Invalid sound sample source definition.", progname); + ERR("Invalid sound sample source definition."); exit(-1); } @@ -2037,7 +2068,7 @@ st_collections_group_sound_sample_source(void) if (!sample) { - ERR("%s: Error. Invalid sound sample source definition.", progname); + ERR("Invalid sound sample source definition."); exit(-1); } sample->snd_src = parse_str(0); @@ -2077,14 +2108,14 @@ st_collections_group_sound_tone(void) { if (!strcmp(edje_file->sound_dir->tones[i].name, tmp)) { - ERR("%s: Error. Tone name: %s already exist.", progname, tmp); + ERR("Tone name: %s already exist.", tmp); free((char *)tmp); exit(-1); } if (edje_file->sound_dir->tones[i].value == value) { - ERR("%s: Error. Tone name %s with same frequency %d exist.", - progname, edje_file->sound_dir->tones[i].name, value); + ERR("Tone name %s with same frequency %d exist.", + edje_file->sound_dir->tones[i].name, value); exit(-1); } } @@ -2096,7 +2127,7 @@ st_collections_group_sound_tone(void) if (!edje_file->sound_dir->tones) { - ERR("%s: Error. No enough memory.", progname); + ERR("No enough memory."); exit(-1); } @@ -2141,11 +2172,11 @@ ob_collections_group(void) { Edje_Part_Collection *pc; Code *cd; - + if (current_de && !current_de->entry) { - ERR("%p: Error. A collection without a name was detected, that's not allowed.", progname); - exit(-1); + ERR("A collection without a name was detected, that's not allowed."); + exit(-1); } current_de = mem_alloc(SZ(Edje_Part_Collection_Directory_Entry)); @@ -2252,7 +2283,6 @@ st_collections_group_inherit(void) Edje_Pack_Element_Parser *pitem; Edje_Part_Description_Common *ed, *ed2; Edje_List_Foreach_Data fdata; - Edje_String *es; Eina_List *l; char *parent_name; unsigned int i, j; @@ -2270,36 +2300,61 @@ st_collections_group_inherit(void) } if (!pc2) { - ERR("%s: Error. parse error %s:%i. There isn't a group with the name %s", - progname, file_in, line - 1, parent_name); + ERR("parse error %s:%i. There isn't a group with the name %s", + file_in, line - 1, parent_name); exit(-1); } if (pc2 == pc) { - ERR("%s: Error. parse error %s:%i. You are trying to inherit '%s' from itself. That's not possible." + ERR("parse error %s:%i. You are trying to inherit '%s' from itself. That's not possible." "If there is another group of the same name, you want to inherit from that group and have the" "same name as that group, there is a trick ! Just put the inherit before the directive that set" - "the name !", progname, file_in, line - 1, parent_name); + "the name !", file_in, line - 1, parent_name); exit(-1); } if (pc2->data) { - char *key; + char *key, *data; memset(&fdata, 0, sizeof(Edje_List_Foreach_Data)); eina_hash_foreach(pc2->data, _edje_data_item_list_foreach, &fdata); - if (!pc->data) - pc->data = eina_hash_string_small_new(free); + if (!pc->data) pc->data = eina_hash_string_small_new(free); + EINA_LIST_FREE(fdata.list, key) + { + data = eina_hash_find(pc2->data, key); + eina_hash_direct_add(pc->data, key, data); + } + } + + if (pc2->alias) + { + char *key, *alias; + memset(&fdata, 0, sizeof(Edje_List_Foreach_Data)); + eina_hash_foreach(pc2->alias, + _edje_data_item_list_foreach, &fdata); + if (!pc->alias) pc->alias = eina_hash_string_small_new(free); + EINA_LIST_FREE(fdata.list, key) + { + alias = eina_hash_find(pc2->alias, key); + eina_hash_direct_add(pc->alias, key, alias); + } + } + if (pc2->aliased) + { + char *key, *aliased; + memset(&fdata, 0, sizeof(Edje_List_Foreach_Data)); + eina_hash_foreach(pc2->aliased, + _edje_data_item_list_foreach, &fdata); + if (!pc->aliased) pc->aliased = eina_hash_string_small_new(free); EINA_LIST_FREE(fdata.list, key) { - es = mem_alloc(SZ(Edje_String)); - es = (Edje_String *)eina_hash_find(pc2->data, key); - eina_hash_direct_add(pc->data, key, es); + aliased = eina_hash_find(pc2->aliased, key); + eina_hash_direct_add(pc->aliased, key, aliased); } } @@ -2339,6 +2394,7 @@ st_collections_group_inherit(void) ep->select_mode = ep2->select_mode; ep->cursor_mode = ep2->cursor_mode; ep->multiline = ep2->multiline; + ep->access = ep2->access; ep->dragable.x = ep2->dragable.x; ep->dragable.step_x = ep2->dragable.step_x; ep->dragable.count_x = ep2->dragable.count_x; @@ -2644,8 +2700,8 @@ ob_collections_group_script(void) cd->l2 = get_verbatim_line2(); if (cd->shared) { - ERR("%s: Error. parse error %s:%i. There is already an existing script section for the group", - progname, file_in, line - 1); + ERR("parse error %s:%i. There is already an existing script section for the group", + file_in, line - 1); exit(-1); } cd->shared = s; @@ -2675,8 +2731,8 @@ ob_collections_group_lua_script(void) cd->l2 = get_verbatim_line2(); if (cd->shared) { - ERR("%s: Error. parse error %s:%i. There is already an existing script section for the group", - progname, file_in, line - 1); + ERR("parse error %s:%i. There is already an existing script section for the group", + file_in, line - 1); exit(-1); } cd->shared = s; @@ -2785,7 +2841,7 @@ st_collections_group_limits_vertical(void) pc->limits.vertical = realloc(pc->limits.vertical, pc->limits.vertical_count * sizeof (Edje_Limit *)); if (!pc->limits.vertical || !el) { - ERR("%s: Error. Not enough memory.", progname); + ERR("Not enough memory."); exit(-1); } @@ -2823,7 +2879,7 @@ st_collections_group_limits_horizontal(void) pc->limits.horizontal = realloc(pc->limits.horizontal, pc->limits.horizontal_count * sizeof (Edje_Limit *)); if (!pc->limits.horizontal || !el) { - ERR("%s: Error. Not enough memory.", progname); + ERR("Not enough memory."); exit(-1); } @@ -2917,8 +2973,8 @@ ob_collections_group_parts_part(void) pc->parts = realloc(pc->parts, pc->parts_count * sizeof (Edje_Part *)); if (!pc->parts) { - ERR("%s: Error. Not enough memory.", progname); - exit(-1); + ERR("Not enough memory."); + exit(-1); } current_part = pc->parts[pc->parts_count - 1] = ep; @@ -2931,6 +2987,7 @@ ob_collections_group_parts_part(void) ep->pointer_mode = EVAS_OBJECT_POINTER_MODE_AUTOGRAB; ep->precise_is_inside = 0; ep->use_alternate_font_metrics = 0; + ep->access = 0; ep->clip_to_id = -1; ep->dragable.confine_id = -1; ep->dragable.event_id = -1; @@ -2983,8 +3040,8 @@ st_collections_group_parts_part_name(void) epp = (Edje_Part_Parser *)pc->parts[i]; if (!epp->can_override) { - ERR("%s: Error. parse error %s:%i. There is already a part of the name %s", - progname, file_in, line - 1, ep->name); + ERR("parse error %s:%i. There is already a part of the name %s", + file_in, line - 1, ep->name); exit(-1); } else @@ -3020,6 +3077,7 @@ st_collections_group_parts_part_name(void) @li TABLE @li EXTERNAL @li PROXY + @li SPACER @endproperty */ static void @@ -3041,6 +3099,7 @@ st_collections_group_parts_part_type(void) "TABLE", EDJE_PART_TYPE_TABLE, "EXTERNAL", EDJE_PART_TYPE_EXTERNAL, "PROXY", EDJE_PART_TYPE_PROXY, + "SPACER", EDJE_PART_TYPE_SPACER, NULL); /* handle type change of inherited part */ @@ -3268,7 +3327,7 @@ st_collections_group_parts_part_precise_is_inside(void) @effect Only affects text and textblock parts, when enabled Edje will use different size measurement functions. Disabled by default. (note from - the author: I don't know what this is exactlu useful for?) + the author: I don't know what this is exactly useful for?) @endproperty */ static void @@ -3287,7 +3346,8 @@ st_collections_group_parts_part_use_alternate_font_metrics(void) [another part's name] @effect Only renders the area of part that coincides with another part's - container. Overflowing content will not be displayed. + container. Overflowing content will not be displayed. Note that + the part being clipped to can only be a rectangle part. @endproperty */ static void @@ -3551,7 +3611,7 @@ st_collections_group_parts_part_entry_mode(void) Sets the selection mode for a textblock part to one of: @li DEFAULT selection mode is what you would expect on any desktop. Press mouse, drag and release to end. - @li EXPLICITmode requires the application + @li EXPLICIT mode requires the application controlling the edje object has to explicitly begin and end selection modes, and the selection itself is dragable at both ends. @endproperty @@ -3614,6 +3674,25 @@ st_collections_group_parts_part_multiline(void) /** @page edcref + @property + access + @parameters + [1 or 0] + @effect + Specifies whether the part will use accessibility feature (1), + or not (0). It's set to 0 by default. + @endproperty +*/ +static void +st_collections_group_parts_part_access(void) +{ + check_arg_count(1); + + current_part->access = parse_bool(0); +} + +/** + @page edcref @block dragable @context @@ -3784,18 +3863,17 @@ static void ob_collections_group_parts_part_box_items_item(void) if ((ep->type != EDJE_PART_TYPE_BOX) && (ep->type != EDJE_PART_TYPE_TABLE)) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX or TABLE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. box attributes in non-BOX or TABLE part.", + file_in, line - 1); + exit(-1); } ep->items_count++; ep->items = realloc(ep->items, sizeof (Edje_Pack_Element*) * ep->items_count); if (!ep->items) { - ERR("%s: Error. Not enough memory.", progname); - exit(-1); + ERR("Not enough memory."); + exit(-1); } item = mem_alloc(SZ(Edje_Pack_Element_Parser)); @@ -3849,9 +3927,8 @@ static void st_collections_group_parts_part_box_items_item_type(void) s = parse_str(0); if (strcmp(s, "GROUP")) { - ERR("%s: Error. parse error %s:%i. " - "token %s not one of: GROUP.", - progname, file_in, line - 1, s); + ERR("parse error %s:%i. token %s not one of: GROUP.", + file_in, line - 1, s); exit(-1); } /* FIXME: handle the enum, once everything else is supported */ @@ -3892,8 +3969,8 @@ static void st_collections_group_parts_part_box_items_item_name(void) pitem = (Edje_Pack_Element_Parser *)ep->items[i]; if (!pitem->can_override) { - ERR("%s: Error. parse error %s:%i. There is already a item of the name %s", - progname, file_in, line - 1, item->name); + ERR("parse error %s:%i. There is already a item of the name %s", + file_in, line - 1, item->name); exit(-1); } else @@ -4111,10 +4188,9 @@ static void st_collections_group_parts_part_table_items_item_position(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); + exit(-1); } current_item->col = parse_int_range(0, 0, 0xffff); @@ -4138,10 +4214,9 @@ static void st_collections_group_parts_part_table_items_item_span(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); + exit(-1); } current_item->colspan = parse_int_range(0, 1, 0xffff); @@ -4196,17 +4271,18 @@ ob_collections_group_parts_part_description(void) if (!ep->default_desc) { - current_desc = ep->default_desc = ed; + current_desc = ep->default_desc = ed; } else { - ep->other.desc_count++; - ep->other.desc = realloc(ep->other.desc, - sizeof (Edje_Part_Description_Common*) * ep->other.desc_count); - current_desc = ep->other.desc[ep->other.desc_count - 1] = ed; + ep->other.desc_count++; + ep->other.desc = realloc(ep->other.desc, + sizeof (Edje_Part_Description_Common*) * ep->other.desc_count); + current_desc = ep->other.desc[ep->other.desc_count - 1] = ed; } ed->visible = 1; + ed->limit = 0; ed->align.x = FROM_DOUBLE(0.5); ed->align.y = FROM_DOUBLE(0.5); ed->min.w = 0; @@ -4284,29 +4360,31 @@ st_collections_group_parts_part_description_inherit(void) if (!ed->state.name) { - ERR("%s: Error. parse error %s:%i. " - "inherit may only be used after state", - progname, file_in, line - 1); + ERR("parse error %s:%i. inherit may only be used after state", + file_in, line - 1); exit(-1); } parent = parent_desc; if (!parent) { - check_arg_count(2); + check_min_arg_count(1); /* inherit may not be used in the default description */ if (!ep->other.desc_count) { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "inherit may not be used in the default description", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } /* find the description that we inherit from */ parent_name = parse_str(0); - parent_val = parse_float_range(1, 0.0, 1.0); + if (get_arg_count() == 2) + parent_val = parse_float_range(1, 0.0, 1.0); + else + parent_val = 0.0; if (!strcmp (parent_name, "default") && parent_val == 0.0) parent = ep->default_desc; @@ -4343,9 +4421,9 @@ st_collections_group_parts_part_description_inherit(void) if (!parent) { - ERR("%s: Error. parse error %s:%i. " - "cannot find referenced part state %s %lf", - ep->name, file_in, line - 1, parent_name, parent_val); + ERR("parse error %s:%i. " + "cannot find referenced part %s state %s %lf", + file_in, line - 1, ep->name, parent_name, parent_val); exit(-1); } @@ -4377,6 +4455,7 @@ st_collections_group_parts_part_description_inherit(void) ed->color_class = STRDUP(ed->color_class); switch (ep->type) { + case EDJE_PART_TYPE_SPACER: case EDJE_PART_TYPE_RECTANGLE: case EDJE_PART_TYPE_SWALLOW: case EDJE_PART_TYPE_GROUP: @@ -4503,9 +4582,8 @@ st_collections_group_parts_part_description_source(void) if (current_part->type != EDJE_PART_TYPE_PROXY) { - ERR("%s: Error. parse error %s:%i. " - "source attributes in non-PROXY part.", - progname, file_in, line - 1); + ERR("parse error %s:%i. source attributes in non-PROXY part.", + file_in, line - 1); exit(-1); } @@ -4538,7 +4616,7 @@ st_collections_group_parts_part_description_state(void) Edje_Part_Description_Common *ed; char *s; - check_arg_count(2); + check_min_arg_count(1); ep = current_part; @@ -4548,14 +4626,16 @@ st_collections_group_parts_part_description_state(void) s = parse_str(0); if (!strcmp (s, "custom")) { - ERR("%s: Error. parse error %s:%i. " - "invalid state name: '%s'.", - progname, file_in, line - 1, s); + ERR("parse error %s:%i. invalid state name: '%s'.", + file_in, line - 1, s); exit(-1); } ed->state.name = s; - ed->state.value = parse_float_range(1, 0.0, 1.0); + if (get_arg_count() == 1) + ed->state.value = 0.0; + else + ed->state.value = parse_float_range(1, 0.0, 1.0); if (ed != ep->default_desc) { @@ -4609,8 +4689,52 @@ st_collections_group_parts_part_description_visible(void) { check_arg_count(1); + if (current_part->type == EDJE_PART_TYPE_SPACER) + { + ERR("parse error %s:%i. SPACER part can't have a visibility defined", + file_in, line - 1); + exit(-1); + } + current_desc->visible = parse_bool(0); } +/** + @page edcref + @property + limit + @parameters + [NONE, WIDTH, HEIGHT or BOTH] + @effect + Emit a signal when the part size change from zero or to a zero size + ('limit,width,over', 'limit,width,zero'). By default no signal are + emitted. + @endproperty + @since 1.7.0 +*/ +static void +st_collections_group_parts_part_description_limit(void) +{ + check_arg_count(1); + + current_desc->limit = parse_enum(0, + "NONE", 0, + "WIDTH", 1, + "HEIGHT", 2, + "BOTH", 3); + + if (current_desc->limit) + { + Edje_Part_Collection *pc; + int count; + + pc = eina_list_data_get(eina_list_last(edje_collections)); + count = pc->limits.parts_count++; + pc->limits.parts = realloc(pc->limits.parts, + pc->limits.parts_count * sizeof (Edje_Part_Limit)); + data_queue_part_lookup(pc, current_part->name, + &(pc->limits.parts[count].part)); + } +} /** @page edcref @@ -4685,9 +4809,9 @@ st_collections_group_parts_part_description_min(void) if ((current_part->type != EDJE_PART_TYPE_IMAGE && current_part->type != EDJE_PART_TYPE_GROUP) || !tmp || strcmp(tmp, "SOURCE") != 0) { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "Only IMAGE and GROUP part can have a min: SOURCE; defined", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } @@ -4745,9 +4869,9 @@ st_collections_group_parts_part_description_max(void) if (current_part->type != EDJE_PART_TYPE_IMAGE || !tmp || strcmp(tmp, "SOURCE") != 0) { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "Only IMAGE part can have a max: SOURCE; defined", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } @@ -4841,6 +4965,13 @@ st_collections_group_parts_part_description_color_class(void) { check_arg_count(1); + if (current_part->type == EDJE_PART_TYPE_SPACER) + { + ERR("parse error %s:%i. SPACER part can't have a color defined", + file_in, line - 1); + exit(-1); + } + current_desc->color_class = parse_str(0); } @@ -4859,6 +4990,13 @@ st_collections_group_parts_part_description_color(void) { check_arg_count(4); + if (current_part->type == EDJE_PART_TYPE_SPACER) + { + ERR("parse error %s:%i. SPACER part can't have a color defined", + file_in, line - 1); + exit(-1); + } + current_desc->color.r = parse_int_range(0, 0, 255); current_desc->color.g = parse_int_range(1, 0, 255); current_desc->color.b = parse_int_range(2, 0, 255); @@ -4880,6 +5018,13 @@ st_collections_group_parts_part_description_color2(void) { check_arg_count(4); + if (current_part->type == EDJE_PART_TYPE_SPACER) + { + ERR("parse error %s:%i. SPACER part can't have a color defined", + file_in, line - 1); + exit(-1); + } + current_desc->color2.r = parse_int_range(0, 0, 255); current_desc->color2.g = parse_int_range(1, 0, 255); current_desc->color2.b = parse_int_range(2, 0, 255); @@ -4909,8 +5054,9 @@ st_collections_group_parts_part_description_color3(void) if (current_part->type != EDJE_PART_TYPE_TEXT && current_part->type != EDJE_PART_TYPE_TEXTBLOCK) { - ERR("%s: Error. Setting color3 in part %s from %s not of type TEXT or TEXTBLOCK.", progname, current_part->name, pc->part); - exit(-1); + ERR("Setting color3 in part %s from %s not of type TEXT or TEXTBLOCK.", + current_part->name, pc->part); + exit(-1); } ed = (Edje_Part_Description_Text*)current_desc; @@ -5190,10 +5336,10 @@ st_collections_group_parts_part_description_image_normal(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. " + "image attributes in non-IMAGE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Image*) current_desc; @@ -5217,7 +5363,8 @@ st_collections_group_parts_part_description_image_normal(void) @effect Name of an image to be used in an animation loop, an image block can have none, one or multiple tween declarations. Images are displayed in - the order they are listed. + the order they are listed, during the transition to the state they are + declared in; the "normal" image is the final state. @endproperty */ static void @@ -5229,10 +5376,9 @@ st_collections_group_parts_part_description_image_tween(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Image*) current_desc; @@ -5274,10 +5420,9 @@ st_collections_group_parts_part_description_image_border(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Image*) current_desc; @@ -5309,10 +5454,9 @@ st_collections_group_parts_part_description_image_middle(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Image*) current_desc; @@ -5352,10 +5496,9 @@ st_collections_group_parts_part_description_image_border_scale_by(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Image*) current_desc; @@ -5383,10 +5526,9 @@ st_collections_group_parts_part_description_image_border_scale(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Image*) current_desc; @@ -5417,10 +5559,9 @@ st_collections_group_parts_part_description_image_scale_hint(void) if (current_part->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Image*) current_desc; @@ -5455,7 +5596,10 @@ st_collections_group_parts_part_description_image_scale_hint(void) } @description The fill method is an optional block that defines the way an IMAGE part - is going to be displayed inside its container. + is going to be displayed inside its container. + It can be used for tiling (repeating the image) or displaying only + part of an image. See @ref evas_object_image_fill_set() documentation + for more details. @endblock @property @@ -5496,9 +5640,9 @@ st_collections_group_parts_part_description_fill_smooth(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY `%s` part (%i).", - progname, file_in, line - 1, current_part->name, current_part->type); + file_in, line - 1, current_part->name, current_part->type); exit(-1); } } @@ -5530,9 +5674,8 @@ st_collections_group_parts_part_description_fill_spread(void) /* XXX this will need to include IMAGES when spread support is added to evas images */ { - ERR("%s: Error. parse error %s:%i. " - "fill.spread not supported yet.", - progname, file_in, line - 1); + ERR("parse error %s:%i. fill.spread not supported yet.", + file_in, line - 1); exit(-1); } @@ -5543,10 +5686,9 @@ st_collections_group_parts_part_description_fill_spread(void) if (ep->type != EDJE_PART_TYPE_IMAGE) { - ERR("%s: Error. parse error %s:%i. " - "image attributes in non-IMAGE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. image attributes in non-IMAGE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Image*) ep->default_desc; @@ -5596,9 +5738,9 @@ st_collections_group_parts_part_description_fill_type(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -5669,9 +5811,9 @@ st_collections_group_parts_part_description_fill_origin_relative(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -5719,9 +5861,9 @@ st_collections_group_parts_part_description_fill_origin_offset(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -5757,7 +5899,7 @@ st_collections_group_parts_part_description_fill_origin_offset(void) @parameters [width] [height] @effect - Takes a pair of decimal values that represent the a percentual value + Takes a pair of decimal values that represent the percentual value of the original size of the element. For example, "0.5 0.5" represents half the size, while "2.0 2.0" represents the double. The default value is "1.0 1.0". @@ -5792,9 +5934,9 @@ st_collections_group_parts_part_description_fill_size_relative(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -5842,9 +5984,9 @@ st_collections_group_parts_part_description_fill_size_offset(void) } default: { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "image and proxy attributes in non-IMAGE, non-PROXY part.", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } } @@ -5906,10 +6048,9 @@ st_collections_group_parts_part_description_text_text(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -5953,10 +6094,9 @@ st_collections_group_parts_part_description_text_text_class(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -5986,10 +6126,9 @@ st_collections_group_parts_part_description_text_font(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6019,10 +6158,9 @@ st_collections_group_parts_part_description_text_style(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6053,10 +6191,9 @@ st_collections_group_parts_part_description_text_repch(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6086,10 +6223,9 @@ st_collections_group_parts_part_description_text_size(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*)current_desc; @@ -6120,10 +6256,9 @@ st_collections_group_parts_part_description_text_size_range(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6132,10 +6267,9 @@ st_collections_group_parts_part_description_text_size_range(void) ed->text.size_range_max = parse_int_range(1, 0, 255); if (ed->text.size_range_min > ed->text.size_range_max) { - ERR("%s: Error. parse error %s:%i. " - "min size is bigger than max size.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. min size is bigger than max size.", + file_in, line - 1); + exit(-1); } } @@ -6161,10 +6295,9 @@ st_collections_group_parts_part_description_text_fit(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6196,10 +6329,9 @@ st_collections_group_parts_part_description_text_min(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*)current_desc; @@ -6231,10 +6363,9 @@ st_collections_group_parts_part_description_text_max(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6265,10 +6396,9 @@ st_collections_group_parts_part_description_text_align(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6302,10 +6432,9 @@ st_collections_group_parts_part_description_text_source(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6344,10 +6473,9 @@ st_collections_group_parts_part_description_text_text_source(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6384,10 +6512,9 @@ st_collections_group_parts_part_description_text_elipsis(void) if ((current_part->type != EDJE_PART_TYPE_TEXT) && (current_part->type != EDJE_PART_TYPE_TEXTBLOCK)) { - ERR("%s: Error. parse error %s:%i. " - "text attributes in non-TEXT part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. text attributes in non-TEXT part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Text*) current_desc; @@ -6480,10 +6607,9 @@ static void st_collections_group_parts_part_description_box_layout(void) if (current_part->type != EDJE_PART_TYPE_BOX) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. box attributes in non-BOX part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Box*) current_desc; @@ -6501,10 +6627,9 @@ static void st_collections_group_parts_part_description_box_align(void) if (current_part->type != EDJE_PART_TYPE_BOX) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. box attributes in non-BOX part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Box*) current_desc; @@ -6521,10 +6646,9 @@ static void st_collections_group_parts_part_description_box_padding(void) if (current_part->type != EDJE_PART_TYPE_BOX) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. box attributes in non-BOX part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Box*) current_desc; @@ -6542,10 +6666,9 @@ st_collections_group_parts_part_description_box_min(void) if (current_part->type != EDJE_PART_TYPE_BOX) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-BOX part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. box attributes in non-BOX part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Box*) current_desc; @@ -6629,10 +6752,9 @@ static void st_collections_group_parts_part_description_table_homogeneous(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Table*) current_desc; @@ -6652,10 +6774,9 @@ static void st_collections_group_parts_part_description_table_align(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Table*) current_desc; @@ -6672,10 +6793,9 @@ static void st_collections_group_parts_part_description_table_padding(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "table attributes in non-TABLE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. table attributes in non-TABLE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Table*) current_desc; @@ -6693,10 +6813,9 @@ st_collections_group_parts_part_description_table_min(void) if (current_part->type != EDJE_PART_TYPE_TABLE) { - ERR("%s: Error. parse error %s:%i. " - "box attributes in non-TABLE part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. box attributes in non-TABLE part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_Table*) current_desc; @@ -6977,7 +7096,7 @@ st_collections_group_parts_part_description_map_rotation_x(void) @parameters [Y degrees] @effect - This sets the rotation around the u axis of the part considering + This sets the rotation around the y axis of the part considering the center set. In degrees. @endproperty */ @@ -7102,10 +7221,9 @@ _st_collections_group_parts_part_description_params(Edje_External_Param_Type typ if (current_part->type != EDJE_PART_TYPE_EXTERNAL) { - ERR("%s: Error. parse error %s:%i. " - "params in non-EXTERNAL part.", - progname, file_in, line - 1); - exit(-1); + ERR("parse error %s:%i. params in non-EXTERNAL part.", + file_in, line - 1); + exit(-1); } ed = (Edje_Part_Description_External*) current_desc; @@ -7147,8 +7265,8 @@ _st_collections_group_parts_part_description_params(Edje_External_Param_Type typ param->s = parse_str(1); break; default: - ERR("%s: Error. parse error %s:%i. Invalid param type.\n", - progname, file_in, line - 1); + ERR("parse error %s:%i. Invalid param type.", + file_in, line - 1); break; } @@ -7471,7 +7589,10 @@ st_collections_group_programs_program_action(void) if (ep->action == EDJE_ACTION_TYPE_STATE_SET) { ep->state = parse_str(1); - ep->value = parse_float_range(2, 0.0, 1.0); + if (get_arg_count() == 1) + ep->value = 0.0; + else + ep->value = parse_float_range(2, 0.0, 1.0); } else if (ep->action == EDJE_ACTION_TYPE_SIGNAL_EMIT) { @@ -7489,8 +7610,7 @@ st_collections_group_programs_program_action(void) break; if (i == (int)(edje_file->sound_dir->samples_count - 1)) { - ERR("%s: Error. No Sample name %s exist.", progname, - ep->sample_name); + ERR("No Sample name %s exist.", ep->sample_name); exit(-1); } } @@ -7507,8 +7627,7 @@ st_collections_group_programs_program_action(void) break; if (i == (int)(edje_file->sound_dir->tones_count - 1)) { - ERR("%s: Error. No Tone name %s exist.", progname, - ep->tone_name); + ERR("No Tone name %s exist.", ep->tone_name); exit(-1); } } @@ -7605,13 +7724,13 @@ st_collections_group_programs_program_action(void) ACCEL_FAC, DECEL_FAC and SIN_FAC need the extra optional "interp val 1" to determine the "factor" of curviness. 1.0 is the same as their non-factor counterparts, where 0.0 is equal to linear. - numbers higher than one make the curve angles steeper with a more - prnounced curve point. + Numbers higher than one make the curve angles steeper with a more + pronounced curve point. DIVIS, BOUNCE and SPRING also require "interp val 2" in addition to "interp val 1". - DIVIS uses val 1 as the initial graident start + DIVIS uses val 1 as the initial gradient start (0.0 is horizontal, 1.0 is diagonal (linear), 2.0 is twice the gradient of linear etc.). val 2 is interpreted as an integer factor defining how much the value swings "outside" the gradient only to come @@ -7619,7 +7738,7 @@ st_collections_group_programs_program_action(void) to linear interpolation. Note that DIVIS can exceed 1.0 BOUNCE uses val 2 as the number of bounces (so its rounded down to - the nearest integer value), with val 2 determining how much the + the nearest integer value), with val 1 determining how much the bounce decays, with 0.0 giving linear decay per bounce, and higher values giving much more decay. @@ -7672,9 +7791,8 @@ st_collections_group_programs_program_transition(void) current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT; else if (get_arg_count() != 2) { - ERR("%s: Error. parse error %s:%i. " - "Need 2rd parameter to set time", - progname, file_in, line - 1); + ERR("parse error %s:%i. Need 2rd parameter to set time", + file_in, line - 1); exit(-1); } } @@ -7690,9 +7808,8 @@ st_collections_group_programs_program_transition(void) current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT; else if (get_arg_count() != 3) { - ERR("%s: Error. parse error %s:%i. " - "Need 3rd parameter to set factor", - progname, file_in, line - 1); + ERR("parse error %s:%i. Need 3rd parameter to set factor", + file_in, line - 1); exit(-1); } current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0)); @@ -7709,9 +7826,9 @@ st_collections_group_programs_program_transition(void) current_program->tween.mode |= EDJE_TWEEN_MODE_OPT_FROM_CURRENT; else if (get_arg_count() != 4) { - ERR("%s: Error. parse error %s:%i. " + ERR("parse error %s:%i. " "Need 3rd and 4th parameters to set factor and counts", - progname, file_in, line - 1); + file_in, line - 1); exit(-1); } current_program->tween.v1 = FROM_DOUBLE(parse_float_range(2, 0.0, 999999999.0)); @@ -7781,9 +7898,8 @@ st_collections_group_programs_program_target(void) data_queue_part_lookup(pc, name, &(et->id)); else { - ERR("%s: Error. parse error %s:%i. " - "target may only be used after action", - progname, file_in, line - 1); + ERR("parse error %s:%i. target may only be used after action", + file_in, line - 1); exit(-1); } free(name); @@ -7896,8 +8012,8 @@ ob_collections_group_programs_program_script(void) cp->original = strdup(s); if (cd->shared && cd->is_lua) { - ERR("%s: Error. parse error %s:%i. You're trying to mix Embryo and Lua scripting in the same group", - progname, file_in, line - 1); + ERR("parse error %s:%i. You're trying to mix Embryo and Lua scripting in the same group", + file_in, line - 1); exit(-1); } cd->is_lua = 0; diff --git a/src/bin/edje_cc_mem.c b/src/bin/edje_cc_mem.c index d2d4ae0..e1fa239 100644 --- a/src/bin/edje_cc_mem.c +++ b/src/bin/edje_cc_mem.c @@ -14,8 +14,8 @@ mem_alloc(size_t size) mem = calloc(1, size); if (mem) return mem; - ERR("%s: Error. %s:%i memory allocation of %zu bytes failed. %s", - progname, file_in, line, size, strerror(errno)); + ERR("%s:%i memory allocation of %zu bytes failed. %s", + file_in, line, size, strerror(errno)); exit(-1); return NULL; } @@ -27,8 +27,8 @@ mem_strdup(const char *s) str = strdup(s); if (str) return str; - ERR("%s: Error. %s:%i memory allocation of %zu bytes failed. %s. string being duplicated: \"%s\"", - progname, file_in, line, strlen(s) + 1, strerror(errno), s); + ERR("%s:%i memory allocation of %zu bytes failed. %s. string being duplicated: \"%s\"", + file_in, line, strlen(s) + 1, strerror(errno), s); exit(-1); return NULL; } diff --git a/src/bin/edje_cc_out.c b/src/bin/edje_cc_out.c index d195d78..1c22637 100644 --- a/src/bin/edje_cc_out.c +++ b/src/bin/edje_cc_out.c @@ -111,6 +111,74 @@ struct _Code_Lookup Eina_Bool set; }; +typedef struct _Script_Lua_Writer Script_Lua_Writer; + +struct _Script_Lua_Writer +{ + char *buf; + int size; +}; + +typedef struct _Script_Write Script_Write;; +typedef struct _Head_Write Head_Write; +typedef struct _Fonts_Write Fonts_Write; +typedef struct _Image_Write Image_Write; +typedef struct _Sound_Write Sound_Write; +typedef struct _Group_Write Group_Write; + +struct _Script_Write +{ + Eet_File *ef; + Code *cd; + int i; + Ecore_Exe *exe; + int tmpn_fd, tmpo_fd; + char tmpn[PATH_MAX]; + char tmpo[PATH_MAX]; + char *errstr; +}; + +struct _Head_Write +{ + Eet_File *ef; + char *errstr; +}; + +struct _Fonts_Write +{ + Eet_File *ef; + Font *fn; + char *errstr; +}; + +struct _Image_Write +{ + Eet_File *ef; + Edje_Image_Directory_Entry *img; + Evas_Object *im; + int w, h; + int alpha; + unsigned int *data; + char *path; + char *errstr; +}; + +struct _Sound_Write +{ + Eet_File *ef; + Edje_Sound_Sample *sample; + int i; +}; + +struct _Group_Write +{ + Eet_File *ef; + Edje_Part_Collection *pc; + char *errstr; +}; + +static int pending_threads = 0; + static void data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char* ptr, int len)); Edje_File *edje_file = NULL; @@ -131,22 +199,17 @@ static Eina_List *image_lookups = NULL; static Eina_List *part_slave_lookups = NULL; static Eina_List *image_slave_lookups= NULL; -#define ABORT_WRITE(eet_file, file) \ - eet_close(eet_file); \ - unlink(file); \ - exit(-1); - void -error_and_abort(Eet_File *ef, const char *fmt, ...) +error_and_abort(Eet_File *ef __UNUSED__, const char *fmt, ...) { va_list ap; - fprintf(stderr, "%s: Error. ", progname); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + eina_log_vprint(_edje_cc_log_dom, EINA_LOG_LEVEL_CRITICAL, + "unknown", "unknown", 0, fmt, ap); va_end(ap); - ABORT_WRITE(ef, file_out); + unlink(file_out); + exit(-1); } void @@ -157,23 +220,22 @@ data_setup(void) } static void -check_image_part_desc (Edje_Part_Collection *pc, Edje_Part *ep, - Edje_Part_Description_Image *epd, Eet_File *ef) +check_image_part_desc(Edje_Part_Collection *pc, Edje_Part *ep, + Edje_Part_Description_Image *epd, Eet_File *ef) { unsigned int i; - -#if 0 /* FIXME: This check sounds like not a useful one */ - if (epd->image.id == -1) - ERR(ef, "Collection %s(%i): image attributes missing for " - "part \"%s\", description \"%s\" %f\n", + + /* FIXME: This check sounds like not a useful one */ + if (epd->image.id == -1 && epd->common.visible) + WRN("Collection %s(%i): image attributes missing for " + "part \"%s\", description \"%s\" %f", pc->part, pc->id, ep->name, epd->common.state.name, epd->common.state.value); -#endif for (i = 0; i < epd->image.tweens_count; ++i) { if (epd->image.tweens[i]->id == -1) error_and_abort(ef, "Collection %i: tween image id missing for " - "part \"%s\", description \"%s\" %f\n", + "part \"%s\", description \"%s\" %f", pc->id, ep->name, epd->common.state.name, epd->common.state.value); } } @@ -187,11 +249,11 @@ check_packed_items(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) { if (ep->items[i]->type == EDJE_PART_TYPE_GROUP && !ep->items[i]->source) error_and_abort(ef, "Collection %i: missing source on packed item " - "of type GROUP in part \"%s\"\n", + "of type GROUP in part \"%s\"", pc->id, ep->name); if (ep->type == EDJE_PART_TYPE_TABLE && (ep->items[i]->col < 0 || ep->items[i]->row < 0)) error_and_abort(ef, "Collection %i: missing col/row on packed item " - "for part \"%s\" of type TABLE\n", + "for part \"%s\" of type TABLE", pc->id, ep->name); } } @@ -200,18 +262,18 @@ static void check_nameless_state(Edje_Part_Collection *pc, Edje_Part *ep, Edje_Part_Description_Common *ed, Eet_File *ef) { if (!ed->state.name) - error_and_abort(ef, "Collection %i: description with state missing on part \"%s\"\n", + error_and_abort(ef, "Collection %i: description with state missing on part \"%s\"", pc->id, ep->name); } static void -check_part (Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) +check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) { unsigned int i; /* FIXME: check image set and sort them. */ if (!ep->default_desc) error_and_abort(ef, "Collection %i: default description missing " - "for part \"%s\"\n", pc->id, ep->name); + "for part \"%s\"", pc->id, ep->name); for (i = 0; i < ep->other.desc_count; ++i) check_nameless_state(pc, ep, ep->other.desc[i], ef); @@ -226,10 +288,16 @@ check_part (Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) else if ((ep->type == EDJE_PART_TYPE_BOX) || (ep->type == EDJE_PART_TYPE_TABLE)) check_packed_items(pc, ep, ef); + + /* FIXME: When mask are supported remove this check */ + if (ep->clip_to_id != -1 && + pc->parts[ep->clip_to_id]->type != EDJE_PART_TYPE_RECTANGLE) + error_and_abort(ef, "Collection %i: clip_to point to a non RECT part '%s' !", + pc->id, pc->parts[ep->clip_to_id]->name); } static void -check_program (Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef) +check_program(Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef) { switch (ep->action) { @@ -240,17 +308,19 @@ check_program (Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef) case EDJE_ACTION_TYPE_DRAG_VAL_PAGE: if (!ep->targets) error_and_abort(ef, "Collection %i: target missing in program " - "\"%s\"\n", pc->id, ep->name); + "\"%s\"", pc->id, ep->name); break; default: break; } } -static int -data_write_header(Eet_File *ef) +static void +data_thread_head(void *data, Ecore_Thread *thread __UNUSED__) { + Head_Write *hw = data; int bytes = 0; + char buf[PATH_MAX]; if (edje_file) { @@ -258,147 +328,199 @@ data_write_header(Eet_File *ef) { Edje_Part_Collection_Directory_Entry *ce; - /* copy aliases into collection directory */ EINA_LIST_FREE(aliases, ce) { Edje_Part_Collection_Directory_Entry *sce; Eina_Iterator *it; if (!ce->entry) - error_and_abort(ef, "Collection %i: name missing.\n", ce->id); + { + snprintf(buf, sizeof(buf), + "Collection %i: name missing.", ce->id); + hw->errstr = strdup(buf); + return; + } it = eina_hash_iterator_data_new(edje_file->collection); EINA_ITERATOR_FOREACH(it, sce) - if (ce->id == sce->id) - { - memcpy(&ce->count, &sce->count, sizeof (ce->count)); - break; - } + { + if (ce->id == sce->id) + { + memcpy(&ce->count, &sce->count, sizeof (ce->count)); + break; + } + } if (!sce) - error_and_abort(ef, "Collection %s (%i) can't find an correct alias.\n", ce->entry, ce->id); - + { + snprintf(buf, sizeof(buf), + "Collection %s (%i) can't find an correct alias.", + ce->entry, ce->id); + hw->errstr = strdup(buf); + return; + } eina_iterator_free(it); - eina_hash_direct_add(edje_file->collection, ce->entry, ce); } } - bytes = eet_data_write(ef, edd_edje_file, "edje/file", edje_file, 1); + bytes = eet_data_write(hw->ef, edd_edje_file, "edje/file", edje_file, + compress_mode); if (bytes <= 0) - error_and_abort(ef, "Unable to write \"edje_file\" entry to \"%s\" \n", - file_out); + { + snprintf(buf, sizeof(buf), + "Unable to write \"edje_file\" entry to \"%s\"", + file_out); + hw->errstr = strdup(buf); + return; + } } - if (verbose) + INF("Wrote %9i bytes (%4iKb) for \"edje_file\" header", + bytes, (bytes + 512) / 1024); +} + +static void +data_thread_head_end(void *data, Ecore_Thread *thread __UNUSED__) +{ + Head_Write *hw = data; + + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); + if (hw->errstr) { - printf("%s: Wrote %9i bytes (%4iKb) for \"edje_file\" header\n", - progname, bytes, (bytes + 512) / 1024); + error_and_abort(hw->ef, hw->errstr); + free(hw->errstr); } + free(hw); +} - return bytes; +static void +data_write_header(Eet_File *ef) +{ + Head_Write *hw; + + hw = calloc(1, sizeof(Head_Write)); + hw->ef = ef; + pending_threads++; + if (threads) + ecore_thread_run(data_thread_head, data_thread_head_end, NULL, hw); + else + { + data_thread_head(hw, NULL); + data_thread_head_end(hw, NULL); + } } -static int -data_write_fonts(Eet_File *ef, int *font_num, int *input_bytes, int *input_raw_bytes) +static void +data_thread_fonts(void *data, Ecore_Thread *thread __UNUSED__) { - Eina_Iterator *it; + Fonts_Write *fc = data; + Eina_List *ll; + Eina_File *f = NULL; + void *m = NULL; int bytes = 0; - int total_bytes = 0; - Font *fn; + char buf[PATH_MAX]; + char buf2[PATH_MAX]; - if (!edje_file->fonts) - return 0; + f = eina_file_open(fc->fn->file, 0); + if (f) + { + using_file(fc->fn->file); + m = eina_file_map_all(f, EINA_FILE_SEQUENTIAL); + } + else + { + char *dat; - it = eina_hash_iterator_data_new(edje_file->fonts); - EINA_ITERATOR_FOREACH(it, fn) + EINA_LIST_FOREACH(fnt_dirs, ll, dat) + { + snprintf(buf, sizeof(buf), "%s/%s", dat, fc->fn->file); + f = eina_file_open(buf, 0); + if (f) + { + using_file(buf); + m = eina_file_map_all(f, EINA_FILE_SEQUENTIAL); + if (m) break; + eina_file_close(f); + f = NULL; + } + } + } + if (!m) { - void *fdata = NULL; - int fsize = 0; - Eina_List *ll; - FILE *f; + if (f) eina_file_close(f); + snprintf(buf, sizeof(buf), + "Unable to load font part \"%s\" entry to %s", + fc->fn->file, file_out); + fc->errstr = strdup(buf); + return; + } - f = fopen(fn->file, "rb"); - if (f) - { - long pos; + snprintf(buf, sizeof(buf), "edje/fonts/%s", fc->fn->name); + bytes = eet_write(fc->ef, buf, m, eina_file_size_get(f), compress_mode); - fseek(f, 0, SEEK_END); - pos = ftell(f); - rewind(f); - fdata = malloc(pos); - if (fdata) - { - if (fread(fdata, pos, 1, f) != 1) - error_and_abort(ef, "Unable to read all of font " - "file \"%s\"\n", fn->file); - fsize = pos; - } - fclose(f); - } - else - { - char *data; + if ((bytes <= 0) || eina_file_map_faulted(f, m)) + { + eina_file_map_free(f, m); + eina_file_close(f); + snprintf(buf2, sizeof(buf2), + "Unable to write font part \"%s\" as \"%s\" " + "part entry to %s", fc->fn->file, buf, file_out); + fc->errstr = strdup(buf2); + return; + } - EINA_LIST_FOREACH(fnt_dirs, ll, data) - { - char buf[4096]; + INF("Wrote %9i bytes (%4iKb) for \"%s\" font entry \"%s\" compress: [real: %2.1f%%]", + bytes, (bytes + 512) / 1024, buf, fc->fn->file, + 100 - (100 * (double)bytes) / ((double)(eina_file_size_get(f))) + ); + eina_file_map_free(f, m); + eina_file_close(f); +} - snprintf(buf, sizeof(buf), "%s/%s", data, fn->file); - f = fopen(buf, "rb"); - if (f) - { - long pos; - - fseek(f, 0, SEEK_END); - pos = ftell(f); - rewind(f); - fdata = malloc(pos); - if (fdata) - { - if (fread(fdata, pos, 1, f) != 1) - error_and_abort(ef, "Unable to read all of font " - "file \"%s\"\n", buf); - fsize = pos; - } - fclose(f); - if (fdata) break; - } - } - } - if (!fdata) - { - error_and_abort(ef, "Unable to load font part \"%s\" entry " - "to %s \n", fn->file, file_out); - } - else - { - char buf[4096]; +static void +data_thread_fonts_end(void *data, Ecore_Thread *thread __UNUSED__) +{ + Fonts_Write *fc = data; + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); + if (fc->errstr) + { + error_and_abort(fc->ef, fc->errstr); + free(fc->errstr); + } + free(fc); +} - snprintf(buf, sizeof(buf), "edje/fonts/%s", fn->name); - bytes = eet_write(ef, buf, fdata, fsize, 1); - if (bytes <= 0) - error_and_abort(ef, "Unable to write font part \"%s\" as \"%s\" " - "part entry to %s \n", fn->file, buf, file_out); +static void +data_write_fonts(Eet_File *ef, int *font_num) +{ + Eina_Iterator *it; + Font *fn; - *font_num += 1; - total_bytes += bytes; - *input_bytes += fsize; - *input_raw_bytes += fsize; + if (!edje_file->fonts) return; - if (verbose) - { - printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" font entry \"%s\" compress: [real: %2.1f%%]\n", - progname, bytes, (bytes + 512) / 1024, buf, fn->file, - 100 - (100 * (double)bytes) / ((double)(fsize)) - ); - } - free(fdata); - } + it = eina_hash_iterator_data_new(edje_file->fonts); + EINA_ITERATOR_FOREACH(it, fn) + { + Fonts_Write *fc; + + fc = calloc(1, sizeof(Fonts_Write)); + if (!fc) continue; + fc->ef = ef; + fc->fn = fn; + pending_threads++; + if (threads) + ecore_thread_run(data_thread_fonts, data_thread_fonts_end, NULL, fc); + else + { + data_thread_fonts(fc, NULL); + data_thread_fonts_end(fc, NULL); + } + *font_num += 1; } eina_iterator_free(it); - - return total_bytes; } static void @@ -445,6 +567,9 @@ error_and_abort_image_load_error(Eet_File *ef, const char *file, int error) "pgm", "ppm", "pnm", + "bmp", + "ico", + "tga", NULL }; @@ -479,295 +604,354 @@ error_and_abort_image_load_error(Eet_File *ef, const char *file, int error) } show_err: error_and_abort - (ef, "Unable to load image \"%s\" used by file \"%s\": %s.%s\n", + (ef, "Unable to load image \"%s\" used by file \"%s\": %s.%s", file, file_out, errmsg, hint); } -static int -data_write_images(Eet_File *ef, int *image_num, int *input_bytes, int *input_raw_bytes) +static void +data_thread_image(void *data, Ecore_Thread *thread __UNUSED__) { - unsigned int i; + Image_Write *iw = data; + char buf[PATH_MAX], buf2[PATH_MAX]; + unsigned int *start, *end; + Eina_Bool opaque = EINA_TRUE; int bytes = 0; - int total_bytes = 0; - if ((edje_file) && (edje_file->image_dir)) + if ((iw->data) && (iw->w > 0) && (iw->h > 0)) { - Ecore_Evas *ee; - Evas *evas; - Edje_Image_Directory_Entry *img; - - ecore_init(); - ecore_evas_init(); - - ee = ecore_evas_buffer_new(1, 1); - if (!ee) - error_and_abort(ef, "Cannot create buffer engine canvas for image " - "load.\n"); - - evas = ecore_evas_get(ee); - for (i = 0; i < edje_file->image_dir->entries_count; i++) - { - img = &edje_file->image_dir->entries[i]; + int mode, qual; + + snprintf(buf, sizeof(buf), "edje/images/%i", iw->img->id); + qual = 80; + if ((iw->img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) && + (iw->img->source_param == 0)) + mode = 0; /* RAW */ + else if ((iw->img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) && + (iw->img->source_param == 1)) + mode = 1; /* COMPRESS */ + else + mode = 2; /* LOSSY */ + if ((mode == 0) && (no_raw)) + { + mode = 1; /* promote compression */ + iw->img->source_param = 95; + } + if ((mode == 2) && (no_lossy)) mode = 1; /* demote compression */ + if ((mode == 1) && (no_comp)) + { + if (no_lossy) mode = 0; /* demote compression */ + else if (no_raw) + { + iw->img->source_param = 90; + mode = 2; /* no choice. lossy */ + } + } + if (mode == 2) + { + qual = iw->img->source_param; + if (qual < min_quality) qual = min_quality; + if (qual > max_quality) qual = max_quality; + } + if (iw->alpha) + { + start = (unsigned int *) iw->data; + end = start + (iw->w * iw->h); + while (start < end) + { + if ((*start & 0xff000000) != 0xff000000) + { + opaque = EINA_FALSE; + break; + } + start++; + } + if (opaque) iw->alpha = 0; + } + if (mode == 0) + bytes = eet_data_image_write(iw->ef, buf, + iw->data, iw->w, iw->h, + iw->alpha, + 0, 0, 0); + else if (mode == 1) + bytes = eet_data_image_write(iw->ef, buf, + iw->data, iw->w, iw->h, + iw->alpha, + compress_mode, + 0, 0); + else if (mode == 2) + bytes = eet_data_image_write(iw->ef, buf, + iw->data, iw->w, iw->h, + iw->alpha, + 0, qual, 1); + if (bytes <= 0) + { + snprintf(buf2, sizeof(buf2), + "Unable to write image part " + "\"%s\" as \"%s\" part entry to " + "%s", iw->img->entry, buf, file_out); + iw->errstr = strdup(buf2); + return; + } + } + else + { + snprintf(buf2, sizeof(buf2), + "Unable to load image part " + "\"%s\" as \"%s\" part entry to " + "%s", iw->img->entry, buf, file_out); + iw->errstr = strdup(buf2); + return; + } - if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL - || img->entry == NULL) - { - } - else - { - Evas_Object *im; - Eina_List *ll; - char *data; - int load_err = EVAS_LOAD_ERROR_NONE; + if (eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_INFO)) + { + struct stat st; - im = NULL; - EINA_LIST_FOREACH(img_dirs, ll, data) - { - char buf[4096]; - - snprintf(buf, sizeof(buf), "%s/%s", - data, img->entry); - im = evas_object_image_add(evas); - if (im) - { - evas_object_image_file_set(im, buf, NULL); - load_err = evas_object_image_load_error_get(im); - if (load_err == EVAS_LOAD_ERROR_NONE) - break; - evas_object_del(im); - im = NULL; - if (load_err != EVAS_LOAD_ERROR_DOES_NOT_EXIST) - break; - } - } - if ((!im) && (load_err == EVAS_LOAD_ERROR_DOES_NOT_EXIST)) - { - im = evas_object_image_add(evas); - if (im) - { - evas_object_image_file_set(im, img->entry, NULL); - load_err = evas_object_image_load_error_get(im); - if (load_err != EVAS_LOAD_ERROR_NONE) - { - evas_object_del(im); - im = NULL; - } - } - } - if (im) - { - void *im_data; - int im_w, im_h; - int im_alpha; - char buf[256]; - - evas_object_image_size_get(im, &im_w, &im_h); - im_alpha = evas_object_image_alpha_get(im); - im_data = evas_object_image_data_get(im, 0); - if ((im_data) && (im_w > 0) && (im_h > 0)) - { - int mode, qual; - - snprintf(buf, sizeof(buf), "edje/images/%i", img->id); - qual = 80; - if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) && - (img->source_param == 0)) - mode = 0; /* RAW */ - else if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) && - (img->source_param == 1)) - mode = 1; /* COMPRESS */ - else - mode = 2; /* LOSSY */ - if ((mode == 0) && (no_raw)) - { - mode = 1; /* promote compression */ - img->source_param = 95; - } - if ((mode == 2) && (no_lossy)) mode = 1; /* demote compression */ - if ((mode == 1) && (no_comp)) - { - if (no_lossy) mode = 0; /* demote compression */ - else if (no_raw) - { - img->source_param = 90; - mode = 2; /* no choice. lossy */ - } - } - if (mode == 2) - { - qual = img->source_param; - if (qual < min_quality) qual = min_quality; - if (qual > max_quality) qual = max_quality; - } - if (mode == 0) - bytes = eet_data_image_write(ef, buf, - im_data, im_w, im_h, - im_alpha, - 0, 0, 0); - else if (mode == 1) - bytes = eet_data_image_write(ef, buf, - im_data, im_w, im_h, - im_alpha, - 1, 0, 0); - else if (mode == 2) - bytes = eet_data_image_write(ef, buf, - im_data, im_w, im_h, - im_alpha, - 0, qual, 1); - if (bytes <= 0) - error_and_abort(ef, "Unable to write image part " - "\"%s\" as \"%s\" part entry to " - "%s\n", img->entry, buf, - file_out); - - *image_num += 1; - total_bytes += bytes; - } - else - { - error_and_abort_image_load_error - (ef, img->entry, load_err); - } + if (!iw->path || (stat(iw->path, &st))) st.st_size = 0; + INF("Wrote %9i bytes (%4iKb) for \"%s\" image entry \"%s\" compress: [raw: %2.1f%%] [real: %2.1f%%]", + bytes, (bytes + 512) / 1024, buf, iw->img->entry, + 100 - (100 * (double)bytes) / ((double)(iw->w * iw->h * 4)), + 100 - (100 * (double)bytes) / ((double)(st.st_size)) + ); + } +} - if (verbose) - { - struct stat st; - const char *file = NULL; - - evas_object_image_file_get(im, &file, NULL); - if (!file || (stat(file, &st) != 0)) - st.st_size = 0; - *input_bytes += st.st_size; - *input_raw_bytes += im_w * im_h * 4; - printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" image entry \"%s\" compress: [raw: %2.1f%%] [real: %2.1f%%]\n", - progname, bytes, (bytes + 512) / 1024, buf, img->entry, - 100 - (100 * (double)bytes) / ((double)(im_w * im_h * 4)), - 100 - (100 * (double)bytes) / ((double)(st.st_size)) - ); - } - evas_object_del(im); - } - else - { - error_and_abort_image_load_error - (ef, img->entry, load_err); - } - } - } - ecore_evas_free(ee); - ecore_evas_shutdown(); - ecore_shutdown(); +static void +data_thread_image_end(void *data, Ecore_Thread *thread __UNUSED__) +{ + Image_Write *iw = data; + + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); + if (iw->errstr) + { + error_and_abort(iw->ef, iw->errstr); + free(iw->errstr); } + if (iw->path) free(iw->path); + evas_object_del(iw->im); + free(iw); +} - return total_bytes; +static void +data_image_preload_done(void *data, Evas *e __UNUSED__, Evas_Object *o, void *event_info __UNUSED__) +{ + Image_Write *iw = data; + + evas_object_image_size_get(o, &iw->w, &iw->h); + iw->alpha = evas_object_image_alpha_get(o); + iw->data = evas_object_image_data_get(o, 0); + if (threads) + ecore_thread_run(data_thread_image, data_thread_image_end, NULL, iw); + else + { + data_thread_image(iw, NULL); + data_thread_image_end(iw, NULL); + } } -static int -data_write_sounds(Eet_File * ef, int *sound_num, int *input_bytes, int *input_raw_bytes) +static void +data_write_images(Eet_File *ef, int *image_num) { - int bytes = 0; - int total_bytes = 0; + int i; + Ecore_Evas *ee; + Evas *evas; - if ((edje_file) && (edje_file->sound_dir)) - { - Eina_List *ll; - Edje_Sound_Sample *sample; -#ifdef HAVE_LIBSNDFILE - Edje_Sound_Encode *enc_info; -#endif - char *dir_path = NULL; - char snd_path[PATH_MAX]; - char sndid_str[15]; - void *fdata; - FILE *fp = NULL; - struct stat st; - int size = 0; - int i; + if (!((edje_file) && (edje_file->image_dir))) return; - for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++) + ecore_evas_init(); + ee = ecore_evas_buffer_new(1, 1); + if (!ee) + error_and_abort(ef, "Cannot create buffer engine canvas for image load."); + evas = ecore_evas_get(ee); + + for (i = 0; i < (int)edje_file->image_dir->entries_count; i++) + { + Edje_Image_Directory_Entry *img; + + img = &edje_file->image_dir->entries[i]; + if ((img->source_type == EDJE_IMAGE_SOURCE_TYPE_EXTERNAL) || + (img->entry == NULL)) { - sample = &edje_file->sound_dir->samples[i]; - memset(&st, 0, sizeof(struct stat)); + } + else + { + Evas_Object *im; + Eina_List *ll; + char *s; + int load_err = EVAS_LOAD_ERROR_NONE; + Image_Write *iw; - // Search the Sound file in all the -sd ( sound directory ) - EINA_LIST_FOREACH(snd_dirs, ll, dir_path) + iw = calloc(1, sizeof(Image_Write)); + iw->ef = ef; + iw->img = img; + iw->im = im = evas_object_image_add(evas); + if (threads) + evas_object_event_callback_add(im, + EVAS_CALLBACK_IMAGE_PRELOADED, + data_image_preload_done, + iw); + EINA_LIST_FOREACH(img_dirs, ll, s) { - snprintf((char *)snd_path, sizeof(snd_path), "%s/%s", dir_path, - sample->snd_src); - stat(snd_path, &st); - if (st.st_size) break; - } - if (!st.st_size) - { - snprintf((char *)snd_path, sizeof(snd_path), "%s", - sample->snd_src); - stat(snd_path, &st); + char buf[PATH_MAX]; + + snprintf(buf, sizeof(buf), "%s/%s", s, img->entry); + evas_object_image_file_set(im, buf, NULL); + load_err = evas_object_image_load_error_get(im); + if (load_err == EVAS_LOAD_ERROR_NONE) + { + *image_num += 1; + iw->path = strdup(buf); + pending_threads++; + if (threads) + evas_object_image_preload(im, 0); + using_file(buf); + if (!threads) + data_image_preload_done(iw, evas, im, NULL); + break; + } } - size = st.st_size; - if (!size) + if (load_err != EVAS_LOAD_ERROR_NONE) { - ERR("%s: Error. Unable to load sound source file : %s", - progname, sample->snd_src); - exit(-1); + evas_object_image_file_set(im, img->entry, NULL); + load_err = evas_object_image_load_error_get(im); + if (load_err == EVAS_LOAD_ERROR_NONE) + { + *image_num += 1; + iw->path = strdup(img->entry); + pending_threads++; + if (threads) + evas_object_image_preload(im, 0); + using_file(img->entry); + if (!threads) + data_image_preload_done(iw, evas, im, NULL); + } + else + error_and_abort_image_load_error + (ef, img->entry, load_err); } + } + } +} + +static void +data_thread_sounds(void *data, Ecore_Thread *thread __UNUSED__) +{ + Sound_Write *sw = data; + Eina_List *ll; #ifdef HAVE_LIBSNDFILE - enc_info = _edje_multisense_encode(snd_path, sample, sample->quality); - - stat(enc_info->file, &st); - size = st.st_size; - fp = fopen(enc_info->file, "rb"); -#else - fp = fopen(snd_path, "rb"); + Edje_Sound_Encode *enc_info; #endif - if (!fp) - { - ERR("%s: Error: Unable to load sound data of: %s", - progname, sample->name); - exit(-1); - } - - snprintf(sndid_str, sizeof(sndid_str), "edje/sounds/%i", sample->id); - fdata = malloc(size); - if (!fdata) - { - ERR("%s: Error. %s:%i while allocating memory to load file \"%s\"", - progname, file_in, line, snd_path); - exit(-1); - } - if (fread(fdata, size, 1, fp)) - bytes = eet_write(ef, sndid_str, fdata, size, EINA_FALSE); - free(fdata); - fclose(fp); - + char *dir_path = NULL; + char snd_path[PATH_MAX]; + char sndid_str[15]; + Eina_File *f = NULL; + void *m = NULL; + int bytes = 0; + + // Search the Sound file in all the -sd ( sound directory ) + EINA_LIST_FOREACH(snd_dirs, ll, dir_path) + { + snprintf((char *)snd_path, sizeof(snd_path), "%s/%s", dir_path, + sw->sample->snd_src); + f = eina_file_open(snd_path, 0); + if (f) break; + } + if (!f) + { + snprintf((char *)snd_path, sizeof(snd_path), "%s", + sw->sample->snd_src); + f = eina_file_open(snd_path, 0); + } #ifdef HAVE_LIBSNDFILE - //If encoded temporary file, delete it. - if (enc_info->encoded) unlink(enc_info->file); + if (f) eina_file_close(f); + enc_info = _edje_multisense_encode(snd_path, sw->sample, + sw->sample->quality); + f = eina_file_open(enc_info->file, 0); + if (f) using_file(enc_info->file); +#else + if (f) using_file(snd_path); #endif - *sound_num += 1; - total_bytes += bytes; - *input_bytes += size; - *input_raw_bytes += size; + if (!f) + { + ERR("Unable to load sound data of: %s", sw->sample->name); + exit(-1); + } - if (verbose) - { + snprintf(sndid_str, sizeof(sndid_str), "edje/sounds/%i", sw->sample->id); + m = eina_file_map_all(f, EINA_FILE_WILLNEED); + if (m) + { + bytes = eet_write(sw->ef, sndid_str, m, eina_file_size_get(f), + EET_COMPRESSION_NONE); + if (eina_file_map_faulted(f, m)) + { + ERR("File access error when reading '%s'", + eina_file_filename_get(f)); + exit(-1); + } + eina_file_map_free(f, m); + } + eina_file_close(f); + +#ifdef HAVE_LIBSNDFILE + //If encoded temporary file, delete it. + if (enc_info->encoded) unlink(enc_info->file); +#endif #ifdef HAVE_LIBSNDFILE - printf ("%s: Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry" - "\"%s\" \n", progname, bytes, (bytes + 512) / 1024, - sndid_str, enc_info->comp_type, sample->name); + INF("Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry \"%s\"", + bytes, (bytes + 512) / 1024, + sndid_str, enc_info->comp_type, sw->sample->name); #else - printf ("%s: Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry" - "\"%s\" \n", progname, bytes, (bytes + 512) / 1024, - sndid_str, "RAW PCM", sample->name); + INF("Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry \"%s\"", + bytes, (bytes + 512) / 1024, + sndid_str, "RAW PCM", sw->sample->name); #endif - } + #ifdef HAVE_LIBSNDFILE - if ((enc_info->file) && (!enc_info->encoded)) eina_stringshare_del(enc_info->file); - if (enc_info) free(enc_info); - enc_info = NULL; + if ((enc_info->file) && (!enc_info->encoded)) + eina_stringshare_del(enc_info->file); + if (enc_info) free(enc_info); + enc_info = NULL; #endif +} + +static void +data_thread_sounds_end(void *data, Ecore_Thread *thread __UNUSED__) +{ + Sound_Write *sw = data; + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); + free(sw); +} + +static void +data_write_sounds(Eet_File *ef, int *sound_num) +{ + if ((edje_file) && (edje_file->sound_dir)) + { + int i; + + for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++) + { + Sound_Write *sw; + + sw = calloc(1, sizeof(Sound_Write)); + if (!sw) continue; + sw->ef = ef; + sw->sample = &edje_file->sound_dir->samples[i]; + sw->i = i; + *sound_num += 1; + pending_threads++; + if (threads) + ecore_thread_run(data_thread_sounds, data_thread_sounds_end, NULL, sw); + else + { + data_thread_sounds(sw, NULL); + data_thread_sounds_end(sw, NULL); + } } } - return total_bytes; } static void @@ -796,35 +980,73 @@ check_groups(Eet_File *ef) } } -static int +static void +data_thread_group(void *data, Ecore_Thread *thread __UNUSED__) +{ + Group_Write *gw = data; + int bytes; + char buf[PATH_MAX]; + char buf2[PATH_MAX]; + + snprintf(buf, sizeof(buf), "edje/collections/%i", gw->pc->id); + bytes = eet_data_write(gw->ef, edd_edje_part_collection, buf, gw->pc, + compress_mode); + return; + if (bytes <= 0) + { + snprintf(buf2, sizeof(buf2), + "Unable to write \"%s\" part entry to %s", + buf, file_out); + gw->errstr = strdup(buf2); + return; + } + + INF("Wrote %9i bytes (%4iKb) for \"%s\" aka \"%s\" collection entry", + bytes, (bytes + 512) / 1024, buf, gw->pc->part); +} + +static void +data_thread_group_end(void *data, Ecore_Thread *thread __UNUSED__) +{ + Group_Write *gw = data; + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); + if (gw->errstr) + { + error_and_abort(gw->ef, gw->errstr); + free(gw->errstr); + } + free(gw); +} + +static void data_write_groups(Eet_File *ef, int *collection_num) { Eina_List *l; Edje_Part_Collection *pc; - int bytes = 0; - int total_bytes = 0; EINA_LIST_FOREACH(edje_collections, l, pc) { - char buf[4096]; - - snprintf(buf, sizeof(buf), "edje/collections/%i", pc->id); - bytes = eet_data_write(ef, edd_edje_part_collection, buf, pc, 1); - if (bytes <= 0) - error_and_abort(ef, "Error. Unable to write \"%s\" part entry " - "to %s\n", buf, file_out); - - *collection_num += 1; - total_bytes += bytes; + Group_Write *gw; - if (verbose) - { - printf("%s: Wrote %9i bytes (%4iKb) for \"%s\" aka \"%s\" collection entry\n", - progname, bytes, (bytes + 512) / 1024, buf, pc->part); - } + gw = calloc(1, sizeof(Group_Write)); + if (!gw) + { + error_and_abort(ef, "Cannot allocate memory for group writer"); + return; + } + gw->ef = ef; + gw->pc = pc; + pending_threads++; + if (threads) + ecore_thread_run(data_thread_group, data_thread_group_end, NULL, gw); + else + { + data_thread_group(gw, NULL); + data_thread_group_end(gw, NULL); + } + *collection_num += 1; } - - return total_bytes; } static void @@ -833,7 +1055,7 @@ create_script_file(Eet_File *ef, const char *filename, const Code *cd, int fd) FILE *f = fdopen(fd, "wb"); if (!f) error_and_abort(ef, "Unable to open temp file \"%s\" for script " - "compilation.\n", filename); + "compilation.", filename); Eina_List *ll; Code_Program *cp; @@ -906,48 +1128,124 @@ create_script_file(Eet_File *ef, const char *filename, const Code *cd, int fd) } static void -compile_script_file(Eet_File *ef, const char *source, const char *output, - int script_num, int fd) +data_thread_script(void *data, Ecore_Thread *thread __UNUSED__) { + Script_Write *sc = data; FILE *f; - char buf[4096]; - int ret; - - snprintf(buf, sizeof(buf), - "embryo_cc -i %s/include -o %s %s", - eina_prefix_data_get(pfx), output, source); - ret = system(buf); - - /* accept warnings in the embryo code */ - if (ret < 0 || ret > 1) - error_and_abort(ef, "Compiling script code not clean.\n"); + int size; + char buf[PATH_MAX]; - f = fdopen(fd, "rb"); + f = fdopen(sc->tmpo_fd, "rb"); if (!f) - error_and_abort(ef, "Unable to open script object \"%s\" for reading.\n", - output); + { + snprintf(buf, sizeof(buf), + "Unable to open script object \"%s\" for reading.", + sc->tmpo); + sc->errstr = strdup(buf); + return; + } fseek(f, 0, SEEK_END); - int size = ftell(f); + size = ftell(f); rewind(f); if (size > 0) { - void *data = malloc(size); + void *dat = malloc(size); - if (data) + if (dat) { - if (fread(data, size, 1, f) != 1) - error_and_abort(ef, "Unable to read all of script object " - "\"%s\"\n", output); - - snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i", script_num); - eet_write(ef, buf, data, size, 1); - free(data); + if (fread(dat, size, 1, f) != 1) + { + snprintf(buf, sizeof(buf), + "Unable to read all of script object \"%s\"", + sc->tmpo); + sc->errstr = strdup(buf); + return; + } + snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i", + sc->i); + eet_write(sc->ef, buf, dat, size, compress_mode); + free(dat); } + else + { + snprintf(buf, sizeof(buf), + "Alloc failed for %lu bytes", (unsigned long)size); + sc->errstr = strdup(buf); + return; + } } - fclose(f); + + if (!no_save) + { + Eina_List *ll; + Code_Program *cp; + + if (sc->cd->original) + { + snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i", sc->i); + eet_write(sc->ef, buf, sc->cd->original, + strlen(sc->cd->original) + 1, compress_mode); + } + EINA_LIST_FOREACH(sc->cd->programs, ll, cp) + { + if (!cp->original) continue; + snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i/%i", + sc->i, cp->id); + eet_write(sc->ef, buf, cp->original, + strlen(cp->original) + 1, compress_mode); + } + } + + unlink(sc->tmpn); + unlink(sc->tmpo); + close(sc->tmpn_fd); + close(sc->tmpo_fd); +} + +static void +data_thread_script_end(void *data, Ecore_Thread *thread __UNUSED__) +{ + Script_Write *sc = data; + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); + if (sc->errstr) + { + error_and_abort(sc->ef, sc->errstr); + free(sc->errstr); + } + free(sc); +} + +static Eina_Bool +data_scripts_exe_del_cb(void *data __UNUSED__, int evtype __UNUSED__, void *evinfo) +{ + Script_Write *sc = data; + Ecore_Exe_Event_Del *ev = evinfo; + + if (!ev->exe) return ECORE_CALLBACK_RENEW; + if (ecore_exe_data_get(ev->exe) != sc) return ECORE_CALLBACK_RENEW; + if (ev->exit_code != 0) + { + error_and_abort(sc->ef, "Compiling script code not clean."); + return ECORE_CALLBACK_CANCEL; + } + if (threads) + { + pending_threads++; + ecore_thread_run(data_thread_script, data_thread_script_end, NULL, sc); + } + else + { + pending_threads++; + data_thread_script(sc, NULL); + data_thread_script_end(sc, NULL); + } + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); + return ECORE_CALLBACK_CANCEL; } static void @@ -965,82 +1263,57 @@ data_write_scripts(Eet_File *ef) for (i = 0, l = codes; l; l = eina_list_next(l), i++) { - char tmpn[PATH_MAX]; - char tmpo[PATH_MAX]; - int fd; Code *cd = eina_list_data_get(l); + Script_Write *sc; + char buf[PATH_MAX]; if (cd->is_lua) continue; if ((!cd->shared) && (!cd->programs)) continue; - - snprintf(tmpn, PATH_MAX, "%s/edje_cc.sma-tmp-XXXXXX", tmp_dir); - fd = mkstemp(tmpn); - if (fd < 0) - error_and_abort(ef, "Unable to open temp file \"%s\" for script " - "compilation.\n", tmpn); - - create_script_file(ef, tmpn, cd, fd); - - snprintf(tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir); - fd = mkstemp(tmpo); - if (fd < 0) - { - unlink(tmpn); - error_and_abort(ef, "Unable to open temp file \"%s\" for script " - "compilation.\n", tmpn); - } - compile_script_file(ef, tmpn, tmpo, i, fd); - - unlink(tmpn); - unlink(tmpo); - - if (!no_save) + sc = calloc(1, sizeof(Script_Write)); + sc->ef = ef; + sc->cd = cd; + sc->i = i; + snprintf(sc->tmpn, PATH_MAX, "%s/edje_cc.sma-tmp-XXXXXX", tmp_dir); + sc->tmpn_fd = mkstemp(sc->tmpn); + if (sc->tmpn_fd < 0) + error_and_abort(ef, "Unable to open temp file \"%s\" for script " + "compilation.", sc->tmpn); + snprintf(sc->tmpo, PATH_MAX, "%s/edje_cc.amx-tmp-XXXXXX", tmp_dir); + sc->tmpo_fd = mkstemp(sc->tmpo); + if (sc->tmpo_fd < 0) { - char buf[PATH_MAX]; - Eina_List *ll; - Code_Program *cp; - - if (cd->original) - { - snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i", i); - eet_write(ef, buf, cd->original, strlen(cd->original) + 1, 1); - } - EINA_LIST_FOREACH(cd->programs, ll, cp) - { - if (!cp->original) - continue; - snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i/%i", i, - cp->id); - eet_write(ef, buf, cp->original, strlen(cp->original) + 1, 1); - } + unlink(sc->tmpn); + error_and_abort(ef, "Unable to open temp file \"%s\" for script " + "compilation.", sc->tmpn); } + create_script_file(ef, sc->tmpn, cd, sc->tmpn_fd); + snprintf(buf, sizeof(buf), + "%s/embryo_cc -i %s/include -o %s %s", + eina_prefix_bin_get(pfx), + eina_prefix_data_get(pfx), + sc->tmpo, sc->tmpn); + pending_threads++; + sc->exe = ecore_exe_run(buf, sc); + ecore_event_handler_add(ECORE_EXE_EVENT_DEL, + data_scripts_exe_del_cb, sc); } } -typedef struct _Edje_Lua_Script_Writer_Struct Edje_Lua_Script_Writer_Struct; - -struct _Edje_Lua_Script_Writer_Struct -{ - char *buf; - int size; -}; - #ifdef LUA_BINARY static int _edje_lua_script_writer(lua_State *L __UNUSED__, const void *chunk_buf, size_t chunk_size, void *_data) { - Edje_Lua_Script_Writer_Struct *data; + Script_Lua_Writer *data; void *old; - data = (Edje_Lua_Script_Writer_Struct *)_data; + data = (Script_Lua_Writer *)_data; old = data->buf; - data->buf = malloc (data->size + chunk_size); - memcpy (data->buf, old, data->size); - memcpy (&((data->buf)[data->size]), chunk_buf, chunk_size); - if (old) - free (old); + data->buf = malloc(data->size + chunk_size); + memcpy(data->buf, old, data->size); + memcpy(&((data->buf)[data->size]), chunk_buf, chunk_size); + if (old) free(old); data->size += chunk_size; return 0; @@ -1048,216 +1321,285 @@ _edje_lua_script_writer(lua_State *L __UNUSED__, const void *chunk_buf, size_t c #endif void -_edje_lua_error_and_abort(lua_State * L, int err_code, Eet_File *ef) +_edje_lua_error_and_abort(lua_State *L, int err_code, Script_Write *sc) { + char buf[PATH_MAX]; char *err_type; - + switch (err_code) { - case LUA_ERRRUN: + case LUA_ERRRUN: err_type = "runtime"; break; - case LUA_ERRSYNTAX: + case LUA_ERRSYNTAX: err_type = "syntax"; break; - case LUA_ERRMEM: + case LUA_ERRMEM: err_type = "memory allocation"; break; - case LUA_ERRERR: + case LUA_ERRERR: err_type = "error handler"; break; - default: + default: err_type = "unknown"; break; } - error_and_abort(ef, "Lua %s error: %s\n", err_type, lua_tostring(L, -1)); + snprintf(buf, sizeof(buf), + "Lua %s error: %s", err_type, lua_tostring(L, -1)); + sc->errstr = strdup(buf); } +static void +data_thread_lua_script(void *data, Ecore_Thread *thread __UNUSED__) +{ + Script_Write *sc = data; + char buf[PATH_MAX]; + lua_State *L; + int ln = 1; + luaL_Buffer b; + Script_Lua_Writer dat; + Eina_List *ll; + Code_Program *cp; +#ifdef LUA_BINARY + int err_code; +#endif + + L = luaL_newstate(); + if (!L) + { + snprintf(buf, sizeof(buf), + "Lua error: Lua state could not be initialized"); + sc->errstr = strdup(buf); + return; + } + + luaL_buffinit(L, &b); + + dat.buf = NULL; + dat.size = 0; + if (sc->cd->shared) + { + while (ln < (sc->cd->l1 - 1)) + { + luaL_addchar(&b, '\n'); + ln++; + } + luaL_addstring(&b, sc->cd->shared); + ln += sc->cd->l2 - sc->cd->l1; + } + + EINA_LIST_FOREACH(sc->cd->programs, ll, cp) + { + if (cp->script) + { + while (ln < (cp->l1 - 1)) + { + luaL_addchar(&b, '\n'); + ln++; + } + luaL_addstring(&b, "_G["); + lua_pushnumber(L, cp->id); + luaL_addvalue(&b); + luaL_addstring(&b, "] = function (ed, signal, source)"); + luaL_addstring(&b, cp->script); + luaL_addstring(&b, "end\n"); + ln += cp->l2 - cp->l1 + 1; + } + } + luaL_pushresult(&b); +#ifdef LUA_BINARY + if (err_code = luaL_loadstring(L, lua_tostring (L, -1))) + { + _edje_lua_error_and_abort(L, err_code, sc); + return; + } + lua_dump(L, _edje_lua_script_writer, &dat); +#else // LUA_PLAIN_TEXT + dat.buf = (char *)lua_tostring(L, -1); + dat.size = strlen(dat.buf); +#endif + //printf("lua chunk size: %d\n", dat.size); + + /* + * TODO load and test Lua chunk + */ + + /* + if (luaL_loadbuffer(L, globbuf, globbufsize, "edje_lua_script")) + printf("lua load error: %s\n", lua_tostring (L, -1)); + if (lua_pcall(L, 0, 0, 0)) + printf("lua call error: %s\n", lua_tostring (L, -1)); + */ + + snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", sc->i); + if (eet_write(sc->ef, buf, dat.buf, dat.size, compress_mode) <= 0) + { + snprintf(buf, sizeof(buf), + "Unable to write script %i", sc->i); + sc->errstr = strdup(buf); + return; + } +#ifdef LUA_BINARY + free(dat.buf); +#endif + lua_close(L); +} + +static void +data_thread_lua_script_end(void *data, Ecore_Thread *thread __UNUSED__) +{ + Script_Write *sc = data; + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); + if (sc->errstr) + { + error_and_abort(sc->ef, sc->errstr); + free(sc->errstr); + } + free(sc); +} static void data_write_lua_scripts(Eet_File *ef) { Eina_List *l; - Eina_List *ll; - Code_Program *cp; int i; for (i = 0, l = codes; l; l = eina_list_next(l), i++) { - char buf[4096]; - Code *cd; - lua_State *L; - int ln = 1; - luaL_Buffer b; - Edje_Lua_Script_Writer_Struct data; -#ifdef LUA_BINARY - int err_code; -#endif + Code *cd; + Script_Write *sc; + + cd = (Code *)eina_list_data_get(l); + if (!cd->is_lua) + continue; + if ((!cd->shared) && (!cd->programs)) + continue; + + sc = calloc(1, sizeof(Script_Write)); + sc->ef = ef; + sc->cd = cd; + sc->i = i; + pending_threads++; + if (threads) + ecore_thread_run(data_thread_lua_script, data_thread_lua_script_end, NULL, sc); + else + { + data_thread_lua_script(sc, NULL); + data_thread_lua_script_end(sc, NULL); + } + } +} - cd = (Code *)eina_list_data_get(l); - if (!cd->is_lua) - continue; - if ((!cd->shared) && (!cd->programs)) - continue; - - L = luaL_newstate(); - if (!L) - error_and_abort(ef, "Lua error: Lua state could not be initialized\n"); +static void +data_thread_source(void *data, Ecore_Thread *thread __UNUSED__) +{ + Eet_File *ef = data; + source_append(ef); +} - luaL_buffinit(L, &b); +static void +data_thread_source_end(void *data __UNUSED__, Ecore_Thread *thread __UNUSED__) +{ + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); +} - data.buf = NULL; - data.size = 0; - if (cd->shared) - { - while (ln < (cd->l1 - 1)) - { - luaL_addchar(&b, '\n'); - ln++; - } - luaL_addstring(&b, cd->shared); - ln += cd->l2 - cd->l1; - } +static void +data_thread_fontmap(void *data, Ecore_Thread *thread __UNUSED__) +{ + Eet_File *ef = data; + source_fontmap_save(ef, fonts); +} - EINA_LIST_FOREACH(cd->programs, ll, cp) - { - if (cp->script) - { - while (ln < (cp->l1 - 1)) - { - luaL_addchar(&b, '\n'); - ln++; - } - luaL_addstring(&b, "_G["); - lua_pushnumber(L, cp->id); - luaL_addvalue(&b); - luaL_addstring(&b, "] = function (ed, signal, source)"); - luaL_addstring(&b, cp->script); - luaL_addstring(&b, "end\n"); - ln += cp->l2 - cp->l1 + 1; - } - } - luaL_pushresult(&b); -#ifdef LUA_BINARY - if (err_code = luaL_loadstring(L, lua_tostring (L, -1))) - _edje_lua_error_and_abort(L, err_code, ef); - lua_dump(L, _edje_lua_script_writer, &data); -#else // LUA_PLAIN_TEXT - data.buf = (char *)lua_tostring(L, -1); - data.size = strlen(data.buf); -#endif - //printf("lua chunk size: %d\n", data.size); - - /* - * TODO load and test Lua chunk - */ - - /* - if (luaL_loadbuffer(L, globbuf, globbufsize, "edje_lua_script")) - printf("lua load error: %s\n", lua_tostring (L, -1)); - if (lua_pcall(L, 0, 0, 0)) - printf("lua call error: %s\n", lua_tostring (L, -1)); - */ - - snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", i); - eet_write(ef, buf, data.buf, data.size, 1); -#ifdef LUA_BINARY - free(data.buf); -#endif - lua_close(L); - } +static void +data_thread_fontmap_end(void *data __UNUSED__, Ecore_Thread *thread __UNUSED__) +{ + pending_threads--; + if (pending_threads <= 0) ecore_main_loop_quit(); } void data_write(void) { Eet_File *ef; - int input_bytes = 0; - int total_bytes = 0; - int src_bytes = 0; - int fmap_bytes = 0; - int input_raw_bytes = 0; int image_num = 0; int sound_num = 0; int font_num = 0; int collection_num = 0; + double t; if (!edje_file) { - ERR("%s: Error. No data to put in \"%s\"", - progname, file_out); + ERR("No data to put in \"%s\"", file_out); exit(-1); } ef = eet_open(file_out, EET_FILE_MODE_WRITE); if (!ef) { - ERR("%s: Error. Unable to open \"%s\" for writing output", - progname, file_out); + ERR("Unable to open \"%s\" for writing output", file_out); exit(-1); } check_groups(ef); - total_bytes += data_write_header(ef); - total_bytes += data_write_fonts(ef, &font_num, &input_bytes, - &input_raw_bytes); - total_bytes += data_write_images(ef, &image_num, &input_bytes, - &input_raw_bytes); - total_bytes += data_write_sounds(ef, &sound_num, &input_bytes, - &input_raw_bytes); + ecore_thread_max_set(ecore_thread_max_get() * 2); + + pending_threads++; + t = ecore_time_get(); + data_write_header(ef); - total_bytes += data_write_groups(ef, &collection_num); + INF("header: %3.5f", ecore_time_get() - t); t = ecore_time_get(); + data_write_groups(ef, &collection_num); + INF("groups: %3.5f", ecore_time_get() - t); t = ecore_time_get(); data_write_scripts(ef); + INF("scripts: %3.5f", ecore_time_get() - t); t = ecore_time_get(); data_write_lua_scripts(ef); + INF("lua scripts: %3.5f", ecore_time_get() - t); t = ecore_time_get(); - src_bytes = source_append(ef); - total_bytes += src_bytes; - fmap_bytes = source_fontmap_save(ef, fonts); - total_bytes += fmap_bytes; + pending_threads++; + if (threads) + ecore_thread_run(data_thread_source, data_thread_source_end, NULL, ef); + else + { + data_thread_source(ef, NULL); + data_thread_source_end(ef, NULL); + } + INF("source: %3.5f", ecore_time_get() - t); t = ecore_time_get(); + pending_threads++; + if (threads) + ecore_thread_run(data_thread_fontmap, data_thread_fontmap_end, NULL, ef); + else + { + data_thread_fontmap(ef, NULL); + data_thread_fontmap_end(ef, NULL); + } + INF("fontmap: %3.5f", ecore_time_get() - t); t = ecore_time_get(); + data_write_images(ef, &image_num); + INF("images: %3.5f", ecore_time_get() - t); t = ecore_time_get(); + data_write_fonts(ef, &font_num); + INF("fonts: %3.5f", ecore_time_get() - t); t = ecore_time_get(); + data_write_sounds(ef, &sound_num); + INF("sounds: %3.5f", ecore_time_get() - t); t = ecore_time_get(); + pending_threads--; + if (pending_threads > 0) ecore_main_loop_begin(); + INF("THREADS: %3.5f", ecore_time_get() - t); t = ecore_time_get(); eet_close(ef); - if (verbose) - { - struct stat st; - - if (stat(file_in, &st) != 0) - st.st_size = 0; - input_bytes += st.st_size; - input_raw_bytes += st.st_size; - printf("Summary:\n" - " Wrote %i collections\n" - " Wrote %i images\n" - " Wrote %i sounds\n" - " Wrote %i fonts\n" - " Wrote %i bytes (%iKb) of original source data\n" - " Wrote %i bytes (%iKb) of original source font map\n" - "Conservative compression summary:\n" - " Wrote total %i bytes (%iKb) from %i (%iKb) input data\n" - " Output file is %3.1f%% the size of the input data\n" - " Saved %i bytes (%iKb)\n" - "Raw compression summary:\n" - " Wrote total %i bytes (%iKb) from %i (%iKb) raw input data\n" - " Output file is %3.1f%% the size of the raw input data\n" - " Saved %i bytes (%iKb)\n" - , - collection_num, - image_num, - sound_num, - font_num, - src_bytes, (src_bytes + 512) / 1024, - fmap_bytes, (fmap_bytes + 512) / 1024, - total_bytes, (total_bytes + 512) / 1024, - input_bytes, (input_bytes + 512) / 1024, - (100.0 * (double)total_bytes) / (double)input_bytes, - input_bytes - total_bytes, - (input_bytes - total_bytes + 512) / 1024, - total_bytes, (total_bytes + 512) / 1024, - input_raw_bytes, (input_raw_bytes + 512) / 1024, - (100.0 * (double)total_bytes) / (double)input_raw_bytes, - input_raw_bytes - total_bytes, - (input_raw_bytes - total_bytes + 512) / 1024); + if (eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_INFO)) + { + printf("Summary:\n" + " Wrote %i collections\n" + " Wrote %i images\n" + " Wrote %i sounds\n" + " Wrote %i fonts\n" + , + collection_num, + image_num, + sound_num, + font_num); } } @@ -1279,7 +1621,7 @@ reorder_parts(void) { ep = (Edje_Part_Parser *)pc->parts[i]; if (ep->reorder.insert_before && ep->reorder.insert_after) - ERR("%s: Error. Unable to use together insert_before and insert_after in part \"%s\".", progname, pc->parts[i]->name); + ERR("Unable to use together insert_before and insert_after in part \"%s\".", pc->parts[i]->name); if (ep->reorder.done) { @@ -1295,9 +1637,11 @@ reorder_parts(void) { ep2 = (Edje_Part_Parser *)pc->parts[j]; if (ep2->reorder.after) - ERR("%s: Error. The part \"%s\" is ambiguous ordered part.", progname, pc->parts[i]->name); + ERR("The part \"%s\" is ambiguous ordered part.", + pc->parts[i]->name); if (ep2->reorder.linked_prev) - ERR("%s: Error. Unable to insert two or more parts in same part \"%s\".", progname, pc->parts[j]->name); + ERR("Unable to insert two or more parts in same part \"%s\".", + pc->parts[j]->name); k = j - 1; found = EINA_TRUE; ep2->reorder.linked_prev += ep->reorder.linked_prev + 1; @@ -1314,9 +1658,9 @@ reorder_parts(void) { ep2 = (Edje_Part_Parser *)pc->parts[j]; if (ep2->reorder.before) - ERR("%s: Error. The part \"%s\" is ambiguous ordered part.", progname, pc->parts[i]->name); + ERR("The part \"%s\" is ambiguous ordered part.", pc->parts[i]->name); if (ep2->reorder.linked_next) - ERR("%s: Error. Unable to insert two or more parts in same part \"%s\".", progname, pc->parts[j]->name); + ERR("Unable to insert two or more parts in same part \"%s\".", pc->parts[j]->name); k = j; found = EINA_TRUE; ep2->reorder.linked_next += ep->reorder.linked_next + 1; @@ -1335,8 +1679,7 @@ reorder_parts(void) if (((i > k) && ((i - ep->reorder.linked_prev) <= k)) || ((i < k) && ((i + ep->reorder.linked_next) >= k))) - ERR("%s: Error. The part order is wrong. It has circular dependency.", - progname); + ERR("The part order is wrong. It has circular dependency."); amount = ep->reorder.linked_prev + ep->reorder.linked_next + 1; linked = i - ep->reorder.linked_prev; @@ -1394,12 +1737,41 @@ data_queue_group_lookup(const char *name, Edje_Part *part) gl->part = part; } +//#define NEWPARTLOOKUP 1 +#ifdef NEWPARTLOOKUP +static Eina_Hash *_part_lookups_hash = NULL; +static Eina_Hash *_part_lookups_dest_hash = NULL; +#endif + void data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest) { + Part_Lookup *pl = NULL; Eina_List *l; - Part_Lookup *pl; +#ifdef NEWPARTLOOKUP + char buf[256]; +#endif +#ifdef NEWPARTLOOKUP + snprintf(buf, sizeof(buf), "%lu-%lu", + (unsigned long)name, (unsigned long)dest); + if (_part_lookups_hash) pl = eina_hash_find(_part_lookups_hash, buf); + if (pl) + { + free(pl->name); + if (name[0]) + pl->name = mem_strdup(name); + else + { + eina_hash_del(_part_lookups_hash, buf, pl); + snprintf(buf, sizeof(buf), "%lu", (unsigned long)dest); + eina_hash_del(_part_lookups_dest_hash, buf, pl); + part_lookups = eina_list_remove(part_lookups, pl); + free(pl); + } + return; + } +#else EINA_LIST_FOREACH(part_lookups, l, pl) { if ((pl->pc == pc) && (pl->dest == dest)) @@ -1415,13 +1787,34 @@ data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest) return; } } +#endif if (!name[0]) return; pl = mem_alloc(SZ(Part_Lookup)); - part_lookups = eina_list_append(part_lookups, pl); + part_lookups = eina_list_prepend(part_lookups, pl); pl->pc = pc; pl->name = mem_strdup(name); pl->dest = dest; +#ifdef NEWPARTLOOKUP + if (!_part_lookups_hash) + _part_lookups_hash = eina_hash_string_superfast_new(NULL); + eina_hash_add(_part_lookups_hash, buf, pl); + + snprintf(buf, sizeof(buf), "%lu", (unsigned long)dest); + if (!_part_lookups_dest_hash) + _part_lookups_dest_hash = eina_hash_string_superfast_new(NULL); + l = eina_hash_find(_part_lookups_dest_hash, buf); + if (l) + { + l = eina_list_append(l, pl); + eina_hash_modify(_part_lookups_dest_hash, buf, l); + } + else + { + l = eina_list_append(l, pl); + eina_hash_add(_part_lookups_dest_hash, buf, l); + } +#endif } void @@ -1429,12 +1822,26 @@ data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest) { Eina_List *l; Part_Lookup *pl; +#ifdef NEWPARTLOOKUP + Eina_List *list; + char buf[256]; +#endif +#ifdef NEWPARTLOOKUP + if (!_part_lookups_dest_hash) return; + snprintf(buf, sizeof(buf), "%lu", (unsigned long)src); + list = eina_hash_find(_part_lookups_dest_hash, buf); + EINA_LIST_FOREACH(list, l, pl) + { + data_queue_part_lookup(pc, pl->name, dest); + } +#else EINA_LIST_FOREACH(part_lookups, l, pl) { if (pl->dest == src) data_queue_part_lookup(pc, pl->name, dest); } +#endif } void @@ -1570,6 +1977,7 @@ data_queue_image_remove(int *dest, Eina_Bool *set) if (il->dest == dest && il->set == set) { image_lookups = eina_list_remove_list(image_lookups, l); + free(il->name); free(il); return ; } @@ -1713,11 +2121,15 @@ data_process_lookups(void) } else { + char *alias; + alias = eina_hash_find(part->pc->alias, part->name); + if (!alias) + alias = part->name; for (i = 0; i < part->pc->parts_count; ++i) { ep = part->pc->parts[i]; - if ((ep->name) && (!strcmp(ep->name, part->name))) + if ((ep->name) && (!strcmp(ep->name, alias))) { handle_slave_lookup(part_slave_lookups, part->dest, ep->id); *(part->dest) = ep->id; @@ -1727,8 +2139,8 @@ data_process_lookups(void) if (i == part->pc->parts_count) { - ERR("%s: Error. Unable to find part name \"%s\".", - progname, part->name); + ERR("Unable to find part name \"%s\" needed in group '%s'.", + alias, part->pc->part); exit(-1); } } @@ -1769,11 +2181,10 @@ data_process_lookups(void) if (!find) { if (!program->anonymous) - ERR("%s: Error. Unable to find program name \"%s\".", - progname, program->u.name); + ERR("Unable to find program name \"%s\".", + program->u.name); else - ERR("%s: Error. Unable to find anonymous program.", - progname); + ERR("Unable to find anonymous program."); exit(-1); } @@ -1812,8 +2223,7 @@ data_process_lookups(void) if (!de) { - ERR("%s: Error. Unable to find group name \"%s\".", - progname, group->name); + ERR("Unable to find group name \"%s\".", group->name); exit(-1); } @@ -1885,8 +2295,7 @@ free_group: if (!find) { - ERR("%s: Error. Unable to find image name \"%s\".", - progname, image->name); + ERR("Unable to find image name \"%s\".", image->name); exit(-1); } @@ -1907,14 +2316,8 @@ free_group: if (de->entry && eina_hash_find(images_in_use, de->entry)) continue ; - if (verbose) - { - printf("%s: Image '%s' in ressource 'edje/image/%i' will not be included as it is unused.\n", progname, de->entry, de->id); - } - else - { - INF("Image '%s' in ressource 'edje/image/%i' will not be included as it is unused.", de->entry, de->id); - } + INF("Image '%s' in resource 'edje/image/%i' will not be included as it is unused.", + de->entry, de->id); de->entry = NULL; } @@ -1926,14 +2329,7 @@ free_group: if (set->name && eina_hash_find(images_in_use, set->name)) continue ; - if (verbose) - { - printf("%s: Set '%s' will not be included as it is unused.\n", progname, set->name); - } - else - { - INF("Set '%s' will not be included as it is unused.", set->name); - } + INF("Set '%s' will not be included as it is unused.", set->name); set->name = NULL; set->entries = NULL; @@ -2159,11 +2555,23 @@ data_process_script_lookups(void) n = eina_convert_itoa(cl->val, buf); if (n > cl->len) { - ERR("%s: Error. The unexpected happened. A numeric replacement string was larger than the original!", - progname); + ERR("The unexpected happened. A numeric replacement string was larger than the original!"); exit(-1); } memset(cl->ptr, ' ', cl->len); strncpy(cl->ptr, buf, n); } } + +void +using_file(const char *filename) +{ + FILE *f; + + if (!watchfile) return; + f = fopen(watchfile, "ab"); + if (!f) return ; + fputs(filename, f); + fputc('\n', f); + fclose(f); +} diff --git a/src/bin/edje_cc_parse.c b/src/bin/edje_cc_parse.c index adc08d3..d315790 100644 --- a/src/bin/edje_cc_parse.c +++ b/src/bin/edje_cc_parse.c @@ -91,11 +91,11 @@ err_show_stack(void) s = stack_id(); if (s) { - printf("PARSE STACK:\n%s\n", s); + ERR("PARSE STACK:\n%s", s); free(s); } else - printf("NO PARSE STACK\n"); + ERR("NO PARSE STACK"); } static void @@ -104,12 +104,11 @@ err_show_params(void) Eina_List *l; char *p; - printf("PARAMS:"); + ERR("PARAMS:"); EINA_LIST_FOREACH(params, l, p) { - printf(" %s", p); + ERR(" %s", p); } - printf("\n"); } static void @@ -119,44 +118,57 @@ err_show(void) err_show_params(); } +static Eina_Hash *_new_object_hash = NULL; +static Eina_Hash *_new_statement_hash = NULL; +static void +fill_object_statement_hashes(void) +{ + int i, n; + + if (_new_object_hash) return; + + _new_object_hash = eina_hash_string_superfast_new(NULL); + _new_statement_hash = eina_hash_string_superfast_new(NULL); + + n = object_handler_num(); + for (i = 0; i < n; i++) + { + eina_hash_add(_new_object_hash, object_handlers[i].type, + &(object_handlers[i])); + } + n = statement_handler_num(); + for (i = 0; i < n; i++) + { + eina_hash_add(_new_statement_hash, statement_handlers[i].type, + &(statement_handlers[i])); + } +} + static void new_object(void) { char *id; - int i; - int handled = 0; + New_Object_Handler *oh; + New_Statement_Handler *sh; + fill_object_statement_hashes(); id = stack_id(); - for (i = 0; i < object_handler_num(); i++) + oh = eina_hash_find(_new_object_hash, id); + if (oh) { - if (!strcmp(object_handlers[i].type, id)) - { - handled = 1; - if (object_handlers[i].func) - { - object_handlers[i].func(); - } - break; - } + if (oh->func) oh->func(); } - if (!handled) - { - for (i = 0; i < statement_handler_num(); i++) - { - if (!strcmp(statement_handlers[i].type, id)) - { - free(id); - return; - } - } - } - if (!handled) + else { - ERR("%s: Error. %s:%i unhandled keyword %s", - progname, file_in, line - 1, - (char *)eina_list_data_get(eina_list_last(stack))); - err_show(); - exit(-1); + sh = eina_hash_find(_new_statement_hash, id); + if (!sh) + { + ERR("%s:%i unhandled keyword %s", + file_in, line - 1, + (char *)eina_list_data_get(eina_list_last(stack))); + err_show(); + exit(-1); + } } free(id); } @@ -165,29 +177,22 @@ static void new_statement(void) { char *id; - int i; - int handled = 0; + New_Statement_Handler *sh; + fill_object_statement_hashes(); id = stack_id(); - for (i = 0; i < statement_handler_num(); i++) + sh = eina_hash_find(_new_statement_hash, id); + if (sh) { - if (!strcmp(statement_handlers[i].type, id)) - { - handled = 1; - if (statement_handlers[i].func) - { - statement_handlers[i].func(); - } - break; - } + if (sh->func) sh->func(); } - if (!handled) + else { - ERR("%s: Error. %s:%i unhandled keyword %s", - progname, file_in, line - 1, - (char *)eina_list_data_get(eina_list_last(stack))); + ERR("%s:%i unhandled keyword %s", + file_in, line - 1, + (char *)eina_list_data_get(eina_list_last(stack))); err_show(); - exit(-1); + exit(-1); } free(id); } @@ -281,8 +286,8 @@ next_token(char *p, char *end, char **new_p, int *delim) tmpstr = alloca(l + 1); if (!tmpstr) { - ERR("%s: Error. %s:%i malloc %i bytes failed", - progname, file_in, line - 1, l + 1); + ERR("%s:%i malloc %i bytes failed", + file_in, line - 1, l + 1); exit(-1); } strncpy(tmpstr, p, l); @@ -462,8 +467,8 @@ stack_chop_top(void) } else { - ERR("%s: Error. parse error %s:%i. } marker without matching { marker", - progname, file_in, line - 1); + ERR("parse error %s:%i. } marker without matching { marker", + file_in, line - 1); err_show(); exit(-1); } @@ -476,11 +481,8 @@ parse(char *data, off_t size) int delim = 0; int do_params = 0; - if (verbose) - { - INF("%s: Parsing input file", - progname); - } + DBG("Parsing input file"); + p = data; end = data + size; line = 1; @@ -491,8 +493,8 @@ parse(char *data, off_t size) */ if (do_params && delim && *token != ';') { - ERR("%s: Error. parse error %s:%i. %c marker before ; marker", - progname, file_in, line - 1, *token); + ERR("parse error %s:%i. %c marker before ; marker", + file_in, line - 1, *token); err_show(); exit(-1); } @@ -503,9 +505,9 @@ parse(char *data, off_t size) { if (do_params) { - ERR("%s: Error. parse error %s:%i. } marker before ; marker", - progname, file_in, line - 1); - err_show(); + ERR("Parse error %s:%i. } marker before ; marker", + file_in, line - 1); + err_show(); exit(-1); } else @@ -531,8 +533,8 @@ parse(char *data, off_t size) { if (do_params) { - ERR("%s: Error. parse error %s:%i. { marker before ; marker", - progname, file_in, line - 1); + ERR("parse error %s:%i. { marker before ; marker", + file_in, line - 1); err_show(); exit(-1); } @@ -615,8 +617,8 @@ parse(char *data, off_t size) } else { - ERR("%s: Error. parse error %s:%i. { marker does not have matching } marker", - progname, file_in, line - 1); + ERR("Parse error %s:%i. { marker does not have matching } marker", + file_in, line - 1); err_show(); exit(-1); } @@ -626,11 +628,8 @@ parse(char *data, off_t size) } } } - if (verbose) - { - INF("%s: Parsing done", - progname); - } + + DBG("Parsing done"); } static char *clean_file = NULL; @@ -739,20 +738,20 @@ compile(void) eina_prefix_lib_get(pfx)); if (ecore_file_exists(buf2)) { - snprintf(buf, sizeof(buf), "%s %s -I%s %s -o %s", - buf2, file_in, inc, def, tmpn); + snprintf(buf, sizeof(buf), "%s -a %s %s -I%s %s -o %s", + buf2, watchfile ? watchfile : "/dev/null", file_in, inc, def, tmpn); ret = system(buf); } else { - ERR("Error. Cannot run epp: %s", buf2); + ERR("Cannot run epp: %s", buf2); exit(-1); } if (ret == EXIT_SUCCESS) file_in = tmpn; else { - ERR("Error. Exit code of epp not clean: %i", ret); + ERR("Exit code of epp not clean: %i", ret); exit(-1); } free(def); @@ -760,14 +759,11 @@ compile(void) fd = open(file_in, O_RDONLY | O_BINARY, S_IRUSR | S_IWUSR); if (fd < 0) { - ERR("%s: Error. cannot open file \"%s\" for input. %s", - progname, file_in, strerror(errno)); + ERR("Cannot open file \"%s\" for input. %s", + file_in, strerror(errno)); exit(-1); } - if (verbose) - { - INF("%s: Opening \"%s\" for input", progname, file_in); - } + DBG("Opening \"%s\" for input", file_in); size = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); @@ -776,8 +772,7 @@ compile(void) parse(data, size); else { - ERR("%s: Error. cannot read file \"%s\". %s", - progname, file_in, strerror(errno)); + ERR("Cannot read file \"%s\". %s", file_in, strerror(errno)); exit(-1); } free(data); @@ -787,7 +782,7 @@ compile(void) { if (!stl->name) { - ERR("%s: Error. style must have a name.", progname); + ERR("style must have a name."); exit(-1); } } @@ -813,8 +808,8 @@ is_num(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -838,8 +833,8 @@ parse_str(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -863,8 +858,7 @@ _parse_enum(char *str, va_list va) /* End of the list, nothing matched. */ if (!s) { - fprintf(stderr, "%s: Error. %s:%i token %s not one of:", - progname, file_in, line - 1, str); + ERR("%s:%i token %s not one of:", file_in, line - 1, str); s = va_arg(va2, char *); while (s) { @@ -903,8 +897,8 @@ parse_enum(int n, ...) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -941,8 +935,8 @@ parse_int(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -959,16 +953,16 @@ parse_int_range(int n, int f, int t) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } i = my_atoi(str); if ((i < f) || (i > t)) { - ERR("%s: Error. %s:%i integer %i out of range of %i to %i inclusive", - progname, file_in, line - 1, i, f, t); + ERR("%s:%i integer %i out of range of %i to %i inclusive", + file_in, line - 1, i, f, t); err_show(); exit(-1); } @@ -984,16 +978,16 @@ parse_bool(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } if (!strstrip(str, buf, sizeof (buf))) { - ERR("%s: Error. %s:%i expression is too long", - progname, file_in, line - 1); + ERR("%s:%i expression is too long", + file_in, line - 1); return 0; } @@ -1005,8 +999,8 @@ parse_bool(int n) i = my_atoi(str); if ((i < 0) || (i > 1)) { - ERR("%s: Error. %s:%i integer %i out of range of 0 to 1 inclusive", - progname, file_in, line - 1, i); + ERR("%s:%i integer %i out of range of 0 to 1 inclusive", + file_in, line - 1, i); err_show(); exit(-1); } @@ -1022,8 +1016,8 @@ parse_float(int n) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } @@ -1040,16 +1034,16 @@ parse_float_range(int n, double f, double t) str = eina_list_nth(params, n); if (!str) { - ERR("%s: Error. %s:%i no parameter supplied as argument %i", - progname, file_in, line - 1, n + 1); + ERR("%s:%i no parameter supplied as argument %i", + file_in, line - 1, n + 1); err_show(); exit(-1); } i = my_atof(str); if ((i < f) || (i > t)) { - ERR("%s: Error. %s:%i float %3.3f out of range of %3.3f to %3.3f inclusive", - progname, file_in, line - 1, i, f, t); + ERR("%s:%i float %3.3f out of range of %3.3f to %3.3f inclusive", + file_in, line - 1, i, f, t); err_show(); exit(-1); } @@ -1069,8 +1063,8 @@ check_arg_count(int required_args) if (num_args != required_args) { - ERR("%s: Error. %s:%i got %i arguments, but expected %i", - progname, file_in, line - 1, num_args, required_args); + ERR("%s:%i got %i arguments, but expected %i", + file_in, line - 1, num_args, required_args); err_show(); exit(-1); } @@ -1083,9 +1077,8 @@ check_min_arg_count(int min_required_args) if (num_args < min_required_args) { - ERR("%s: Error. %s:%i got %i arguments, " - "but expected at least %i", - progname, file_in, line - 1, num_args, min_required_args); + ERR("%s:%i got %i arguments, but expected at least %i", + file_in, line - 1, num_args, min_required_args); err_show(); exit(-1); } @@ -1112,8 +1105,8 @@ my_atoi(const char *s) if (!s) return 0; if (!strstrip(s, buf, sizeof(buf))) { - ERR("%s: Error. %s:%i expression is too long\n", - progname, file_in, line - 1); + ERR("%s:%i expression is too long", + file_in, line - 1); return 0; } _alphai(buf, &res); @@ -1126,8 +1119,8 @@ _deltai(char *s, int *val) if (!val) return NULL; if ('(' != s[0]) { - ERR("%s: Error. %s:%i unexpected character at %s\n", - progname, file_in, line - 1, s); + ERR("%s:%i unexpected character at %s", + file_in, line - 1, s); return s; } else @@ -1157,8 +1150,8 @@ _funci(char *s, int *val) } else { - ERR("%s: Error. %s:%i unexpected character at %s\n", - progname, file_in, line - 1, s); + ERR("%s:%i unexpected character at %s", + file_in, line - 1, s); } return s; } @@ -1180,7 +1173,7 @@ _gammai(char *s, int *val) else { s = _funci(s, val); -// ERR("%s: Error. %s:%i unexpected character at %s\n", +// ERR("%s:%i unexpected character at %s", // progname, file_in, line - 1, s); } return s; @@ -1290,8 +1283,7 @@ _calci(char op, int a, int b) case '/': if (0 != b) a /= b; else - ERR("%s: Error. %s:%i divide by zero\n", - progname, file_in, line - 1); + ERR("%s:%i divide by zero", file_in, line - 1); return a; case '*': a *= b; @@ -1299,12 +1291,10 @@ _calci(char op, int a, int b) case '%': if (0 != b) a = a % b; else - ERR("%s: Error. %s:%i modula by zero\n", - progname, file_in, line - 1); + ERR("%s:%i modula by zero", file_in, line - 1); return a; default: - ERR("%s: Error. %s:%i unexpected character '%c'\n", - progname, file_in, line - 1, op); + ERR("%s:%i unexpected character '%c'", file_in, line - 1, op); } return a; } @@ -1321,8 +1311,7 @@ my_atof(const char *s) if (!strstrip(s, buf, sizeof (buf))) { - ERR("%s: Error. %s:%i expression is too long", - progname, file_in, line - 1); + ERR("%s:%i expression is too long", file_in, line - 1); return 0; } _alphaf(buf, &res); @@ -1335,8 +1324,7 @@ _deltaf(char *s, double *val) if (!val) return NULL; if ('(' != s[0]) { - ERR("%s: Error. %s:%i unexpected character at %s", - progname, file_in, line - 1, s); + ERR("%s:%i unexpected character at %s", file_in, line - 1, s); return s; } else @@ -1365,8 +1353,7 @@ _funcf(char *s, double *val) } else { - ERR("%s: Error. %s:%i unexpected character at %s\n", - progname, file_in, line - 1, s); + ERR("%s:%i unexpected character at %s", file_in, line - 1, s); } return s; } @@ -1389,7 +1376,7 @@ _gammaf(char *s, double *val) else { s = _funcf(s, val); -// ERR("%s: Error. %s:%i unexpected character at %s\n", +// ERR("%s:%i unexpected character at %s", // progname, file_in, line - 1, s); } return s; @@ -1503,8 +1490,7 @@ _calcf(char op, double a, double b) case '/': if (b != 0) a /= b; else - ERR("%s: Error. %s:%i divide by zero\n", - progname, file_in, line - 1); + ERR("%s:%i divide by zero", file_in, line - 1); return a; case '*': a *= b; @@ -1512,12 +1498,10 @@ _calcf(char op, double a, double b) case '%': if (0 != b) a = (double)((int)a % (int)b); else - ERR("%s: Error. %s:%i modula by zero\n", - progname, file_in, line - 1); + ERR("%s:%i modula by zero", file_in, line - 1); return a; default: - ERR("%s: Error. %s:%i unexpected character '%c'\n", - progname, file_in, line - 1, op); + ERR("%s:%i unexpected character '%c'", file_in, line - 1, op); } return a; } @@ -1527,8 +1511,7 @@ strstrip(const char *in, char *out, size_t size) { if ((size -1 ) < strlen(in)) { - ERR("%s: Error. %s:%i expression is too long", - progname, file_in, line - 1); + ERR("%s:%i expression is too long", file_in, line - 1); return 0; } /* remove spaces and tabs */ diff --git a/src/bin/edje_cc_sources.c b/src/bin/edje_cc_sources.c index d9cd0c1..4a6be70 100644 --- a/src/bin/edje_cc_sources.c +++ b/src/bin/edje_cc_sources.c @@ -66,8 +66,7 @@ source_fetch_file(const char *fil, const char *filname) f = fopen(fil, "rb"); if (!f) { - ERR("%s: Warning. Cannot open file '%s'", - progname, fil); + ERR("Cannot open file '%s'", fil); exit(-1); } @@ -82,8 +81,7 @@ source_fetch_file(const char *fil, const char *filname) tmp = fread(sf->file, sz, 1, f); if (tmp != 1) { - ERR("%s: Warning file length for (%s) doesn't match !", - progname, filname); + ERR("file length for (%s) doesn't match!", filname); exit(-1); } } @@ -228,7 +226,8 @@ source_fetch(void) int source_append(Eet_File *ef) { - return eet_data_write(ef, _srcfile_list_edd, "edje_sources", &srcfiles, 1); + return eet_data_write(ef, _srcfile_list_edd, "edje_sources", &srcfiles, + compress_mode); } SrcFile_List * @@ -246,7 +245,8 @@ source_fontmap_save(Eet_File *ef, Eina_List *font_list) Font_List fl; fl.list = font_list; - return eet_data_write(ef, _font_list_edd, "edje_source_fontmap", &fl, 1); + return eet_data_write(ef, _font_list_edd, "edje_source_fontmap", &fl, + compress_mode); } Font_List * diff --git a/src/bin/edje_convert.c b/src/bin/edje_convert.c index 63d11ba..bd6cf31 100644 --- a/src/bin/edje_convert.c +++ b/src/bin/edje_convert.c @@ -259,7 +259,7 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce, /* Change structure layout */ edc = calloc(1, sizeof (Edje_Part_Collection)); - if (!edc) error_and_abort(ef, "Not enough memory\n"); + if (!edc) error_and_abort(ef, "Not enough memory"); ce->ref = edc; EINA_LIST_FREE(oedc->programs, pg) @@ -306,7 +306,7 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce, edc->parts_count = eina_list_count(oedc->parts); edc->parts = calloc(edc->parts_count, sizeof (Edje_Part *)); if (edc->parts_count && !edc->parts) - error_and_abort(ef, "Not enough memory\n"); + error_and_abort(ef, "Not enough memory"); k = 0; EINA_LIST_FREE(oedc->parts, part) @@ -318,7 +318,7 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce, replacement = eina_mempool_malloc(ce->mp.part, sizeof (Edje_Part)); if (!replacement) - error_and_abort(ef, "Not enough memory\n"); + error_and_abort(ef, "Not enough memory"); replacement->name = part->name; replacement->default_desc = _edje_description_convert(part->type, ce, part->default_desc); diff --git a/src/bin/edje_convert_main.c b/src/bin/edje_convert_main.c index bc3484d..e17d412 100644 --- a/src/bin/edje_convert_main.c +++ b/src/bin/edje_convert_main.c @@ -24,10 +24,9 @@ error_and_abort(Eet_File *ef, const char *fmt, ...) { va_list ap; - fprintf(stderr, "%s: Error. ", progname); - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); + eina_log_vprint(_edje_cc_log_dom, EINA_LOG_LEVEL_CRITICAL, + "unknown", "unknown", 0, fmt, ap); va_end(ap); eet_close(ef); exit(-1); diff --git a/src/bin/edje_decc.c b/src/bin/edje_decc.c index 56b81b7..01ece6a 100644 --- a/src/bin/edje_decc.c +++ b/src/bin/edje_decc.c @@ -19,9 +19,10 @@ #include "edje_decc.h" int _edje_cc_log_dom = -1; -char *progname = NULL; +static const char *progname = NULL; char *file_in = NULL; char *file_out = NULL; +int compress_mode = EET_COMPRESSION_DEFAULT; Edje_File *edje_file = NULL; SrcFile_List *srcfiles = NULL; @@ -36,6 +37,87 @@ void output(void); static int compiler_cmd_is_sane(); static int root_filename_is_sane(); + +static void +_edje_cc_log_cb(const Eina_Log_Domain *d, + Eina_Log_Level level, + const char *file, + const char *fnc, + int line, + const char *fmt, + __UNUSED__ void *data, + va_list args) +{ + if ((d->name) && (d->namelen == sizeof("edje_decc") - 1) && + (memcmp(d->name, "edje_decc", sizeof("edje_decc") - 1) == 0)) + { + const char *prefix; + Eina_Bool use_color = !eina_log_color_disable_get(); + + if (use_color) + { +#ifndef _WIN32 + fputs(eina_log_level_color_get(level), stderr); +#else + int color; + switch (level) + { + case EINA_LOG_LEVEL_CRITICAL: + color = FOREGROUND_RED | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_ERR: + color = FOREGROUND_RED; + break; + case EINA_LOG_LEVEL_WARN: + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_INFO: + color = FOREGROUND_GREEN | FOREGROUND_INTENSITY; + break; + case EINA_LOG_LEVEL_DBG: + color = FOREGROUND_BLUE | FOREGROUND_INTENSITY; + break; + default: + color = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; + } + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); +#endif + } + + switch (level) + { + case EINA_LOG_LEVEL_CRITICAL: + prefix = "Critical. "; + break; + case EINA_LOG_LEVEL_ERR: + prefix = "Error. "; + break; + case EINA_LOG_LEVEL_WARN: + prefix = "Warning. "; + break; + default: + prefix = ""; + } + fprintf(stderr, "%s: %s", progname, prefix); + + if (use_color) + { +#ifndef _WIN32 + fputs(EINA_COLOR_RESET, stderr); +#else + SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); +#endif + } + + + vfprintf(stderr, fmt, args); + putc('\n', stderr); + } + else + eina_log_print_cb_stderr(d, level, file, fnc, line, fmt, NULL, args); +} + static void main_help(void) { @@ -46,6 +128,7 @@ main_help(void) " -main-out\tCreate a symbolic link to the main edc \n" " -no-build-sh\tDon't output build.sh \n" " -current-dir\tOutput to current directory \n" + " -quiet\t\tProduce less output\n" "\n" ,progname); } @@ -69,7 +152,10 @@ main(int argc, char **argv) eina_shutdown(); exit(-1); } - progname = argv[0]; + progname = ecore_file_file_get(argv[0]); + eina_log_print_cb_set(_edje_cc_log_cb, NULL); + eina_log_domain_level_set("edje_decc", EINA_LOG_LEVEL_INFO); + for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-h")) @@ -88,10 +174,12 @@ main(int argc, char **argv) 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); } if (!file_in) { - ERR("%s: Error: no input file specified.", progname); + ERR("no input file specified."); main_help(); exit(-1); } @@ -103,9 +191,9 @@ main(int argc, char **argv) if (!decomp()) return -1; output(); - fprintf(stderr, "WARNING! If any Image or audio data was encoded in a LOSSY way, then\n" - "re-encoding will drop quality even more. You need access to the original\n" - "data to ensure no loss of quality.\n"); + WRN("If any Image or audio data was encoded in a LOSSY way, then " + "re-encoding will drop quality even more. " + "You need access to the original data to ensure no loss of quality."); eet_close(ef); edje_shutdown(); eina_log_domain_unregister(_edje_cc_log_dom); @@ -120,27 +208,27 @@ decomp(void) ef = eet_open(file_in, EET_FILE_MODE_READ); if (!ef) { - ERR("ERROR: cannot open %s", file_in); + ERR("cannot open %s", file_in); return 0; } srcfiles = source_load(ef); if (!srcfiles || !srcfiles->list) { - ERR("ERROR: %s has no decompile information", file_in); + 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("ERROR: Invalid root filename: '%s'", (char *) eina_list_data_get(srcfiles->list)); + 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("ERROR: %s does not appear to be an edje file", file_in); + ERR("%s does not appear to be an edje file", file_in); eet_close(ef); return 0; } @@ -152,7 +240,7 @@ decomp(void) } else if (!compiler_cmd_is_sane()) { - ERR("ERROR: invalid compiler executable: '%s'", edje_file->compiler); + ERR("invalid compiler executable: '%s'", edje_file->compiler); eet_close(ef); return 0; } @@ -224,7 +312,7 @@ output(void) 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); - printf("Output Image: %s\n", out); + INF("Output Image: %s", out); pp = strdup(out); p = strrchr(pp, '/'); *p = 0; @@ -255,7 +343,7 @@ output(void) char *pp; snprintf(out, sizeof(out), "%s/%s", outdir, sf->name); - INF("Output Source File: %s\n", out); + INF("Output Source File: %s", out); pp = strdup(out); p = strrchr(pp, '/'); *p = 0; @@ -344,10 +432,10 @@ output(void) if (build_sh) { snprintf(out, sizeof(out), "%s/build.sh", outdir); - printf("Output Build Script: %s\n", out); + INF("Output Build Script: %s", out); if (strstr(out, "../")) { - ERR("potential security violation. attempt to write in parent dir.\n"); + ERR("potential security violation. attempt to write in parent dir."); exit (-1); } f = fopen(out, "wb"); @@ -355,7 +443,7 @@ output(void) fprintf(f, "%s $@ -id . -fd . %s -o %s.edj\n", edje_file->compiler, sf->name, outdir); fclose(f); - WRN("\n*** CAUTION ***\n" + WRN("*** CAUTION ***\n" "Please check the build script for anything malicious " "before running it!\n\n"); } @@ -365,7 +453,7 @@ output(void) snprintf(out, sizeof(out), "%s/%s", outdir, file_out); if (ecore_file_symlink(sf->name, out) != EINA_TRUE) { - ERR("symlink %s -> %s failed\n", sf->name, out); + ERR("symlink %s -> %s failed", sf->name, out); } } diff --git a/src/bin/edje_decc.h b/src/bin/edje_decc.h index 43e988d..c562715 100644 --- a/src/bin/edje_decc.h +++ b/src/bin/edje_decc.h @@ -6,6 +6,7 @@ /* logging variables */ extern int _edje_cc_log_dom ; #define EDJE_CC_DEFAULT_LOG_COLOR EINA_COLOR_CYAN + #ifdef ERR # undef ERR #endif @@ -18,6 +19,14 @@ extern int _edje_cc_log_dom ; # undef WRN #endif #define WRN(...) EINA_LOG_DOM_WARN(_edje_cc_log_dom, __VA_ARGS__) +#ifdef CRIT +# undef CRIT +#endif +#define CRIT(...) EINA_LOG_DOM_CRIT(_edje_cc_log_dom, __VA_ARGS__) +#ifdef DBG +# undef DBG +#endif +#define DBG(...) EINA_LOG_DOM_DBG(_edje_cc_log_dom, __VA_ARGS__) /* types */ typedef struct _Font Font; diff --git a/src/bin/edje_inspector.c b/src/bin/edje_inspector.c index 676c829..9106f95 100644 --- a/src/bin/edje_inspector.c +++ b/src/bin/edje_inspector.c @@ -204,6 +204,8 @@ part_type_name_get(Edje_Part_Type t) return "TABLE"; case EDJE_PART_TYPE_EXTERNAL: return "EXTERNAL"; + case EDJE_PART_TYPE_SPACER: + return "SPACER"; case EDJE_PART_TYPE_NONE: case EDJE_PART_TYPE_LAST: diff --git a/src/bin/edje_multisense_convert.c b/src/bin/edje_multisense_convert.c index d37d218..f02e02e 100644 --- a/src/bin/edje_multisense_convert.c +++ b/src/bin/edje_multisense_convert.c @@ -21,7 +21,7 @@ _edje_multisense_encode(const char *filename, Edje_Sound_Sample *sample, double enc_info = calloc(1, sizeof(Edje_Sound_Encode)); if (!enc_info) { - ERR("Error. while allocating memory to load file "); + ERR("while allocating memory to load file "); exit(-1); } memset (&sfinfo, 0, sizeof (SF_INFO)); @@ -33,13 +33,13 @@ _edje_multisense_encode(const char *filename, Edje_Sound_Sample *sample, double sfile = sf_open (filename, SFM_READ, &sfinfo); if (!sfile) { - ERR("Error. Unable to open audio file : %s", filename); + ERR("Unable to open audio file: %s", filename); exit(-1); } if (!sf_format_check(&sfinfo)) { - ERR("Error. Unknown file, not a valid audio file"); + ERR("Unknown file, not a valid audio file"); exit(-1); } diff --git a/src/bin/edje_player.c b/src/bin/edje_player.c index 208fbb4..cac681b 100644 --- a/src/bin/edje_player.c +++ b/src/bin/edje_player.c @@ -37,6 +37,8 @@ struct opts { char *title; }; +static Eina_Bool _edje_load_or_show_error(Evas_Object *edje, const char *file, const char *group); + static Ecore_Evas *win; static void @@ -456,6 +458,17 @@ _create_bg(Evas *evas, const struct opts *opts) return bg; } +static void +_edje_reload(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__) +{ + const char *file; + const char *group; + edje_object_signal_callback_del(obj, "edje,change,file", "edje", _edje_reload); + + edje_object_file_get(obj, &file, &group); + _edje_load_or_show_error(obj, file, group); +} + static Eina_Bool _edje_load_or_show_error(Evas_Object *edje, const char *file, const char *group) { @@ -464,6 +477,7 @@ _edje_load_or_show_error(Evas_Object *edje, const char *file, const char *group) if (edje_object_file_set(edje, file, group)) { + edje_object_signal_callback_add(edje, "edje,change,file", "edje", _edje_reload, NULL);; evas_object_focus_set(edje, EINA_TRUE); return EINA_TRUE; } diff --git a/src/bin/edje_watch.c b/src/bin/edje_watch.c new file mode 100644 index 0000000..01033b6 --- /dev/null +++ b/src/bin/edje_watch.c @@ -0,0 +1,137 @@ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <Eina.h> +#include <Ecore.h> +#include <Eio.h> +#ifdef HAVE_EVIL +# include <Evil.h> +#endif + +char watchfile[PATH_MAX]; +char *edje_cc_command = NULL; +Eina_List *watching = NULL; +Ecore_Timer *timeout = NULL; + +static void +read_watch_file(const char *file) +{ + Eina_File *f; + Eina_Iterator *it; + Eina_File_Line *ln; + Eio_Monitor *mon; + Eina_List *r = NULL; + + f = eina_file_open(file, EINA_FALSE); + if (!f) return ; + + it = eina_file_map_lines(f); + if (!it) goto err; + + EINA_ITERATOR_FOREACH(it, ln) + { + const char *path; + + path = eina_stringshare_add_length(ln->start, ln->length); + r = eina_list_append(r, eio_monitor_add(path)); + eina_stringshare_del(path); + } + eina_iterator_free(it); + + EINA_LIST_FREE(watching, mon) + eio_monitor_del(mon); + watching = r; + + err: + eina_file_close(f); +} + +Eina_Bool +rebuild(void *data __UNUSED__) +{ + double start, end; + + start = ecore_time_get(); + fprintf(stderr, "SYSTEM('%s')\n", edje_cc_command); + if (system(edje_cc_command) == 0) + read_watch_file(watchfile); + end = ecore_time_get(); + fprintf(stderr, "DONE IN %f\n", end - start); + + timeout = NULL; + return EINA_FALSE; +} + +Eina_Bool +some_change(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__) +{ + Eio_Monitor_Event *ev = event; + + fprintf(stderr, "EVENT %i on [%s]\n", type, ev->filename); + if (timeout) ecore_timer_del(timeout); + timeout = ecore_timer_add(0.5, rebuild, NULL); + + return ECORE_CALLBACK_PASS_ON; +} + +int +main(int argc, char **argv) +{ + char *watchout; + Eina_Strbuf *buf; + double start, end; + int tfd; + int i; + + eina_init(); + ecore_init(); + eio_init(); + + if (argc < 2) return -1; + + ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, some_change, NULL); + ecore_event_handler_add(EIO_MONITOR_FILE_CREATED, some_change, NULL); + ecore_event_handler_add(EIO_MONITOR_FILE_DELETED, some_change, NULL); + ecore_event_handler_add(EIO_MONITOR_FILE_CLOSED, some_change, NULL); + +#ifdef HAVE_EVIL + watchout = (char *)evil_tmpdir_get(); +#else + watchout = "/tmp"; +#endif + + snprintf(watchfile, PATH_MAX, "%s/edje_watch-tmp-XXXXXX", watchout); + + tfd = mkstemp(watchfile); + if (tfd < 0) return -1; + close(tfd); + + buf = eina_strbuf_new(); + if (!buf) return -1; + + eina_strbuf_append_printf(buf, "%s/edje_cc -threads -fastcomp -w %s ", PACKAGE_BIN_DIR, watchfile); + for (i = 1; i < argc; ++i) + eina_strbuf_append_printf(buf, "%s ", argv[i]); + + edje_cc_command = eina_strbuf_string_steal(buf); + + eina_strbuf_free(buf); + + start = ecore_time_get(); + fprintf(stderr, "SYSTEM('%s')\n", edje_cc_command); + system(edje_cc_command); + read_watch_file(watchfile); + end = ecore_time_get(); + fprintf(stderr, "DONE %f\n", end - start); + + ecore_main_loop_begin(); + + unlink(watchfile); + + eio_shutdown(); + ecore_shutdown(); + eina_shutdown(); + + return 1; +} diff --git a/src/bin/epp/cpplib.c b/src/bin/epp/cpplib.c index 132d2a9..30c7f01 100644 --- a/src/bin/epp/cpplib.c +++ b/src/bin/epp/cpplib.c @@ -5489,6 +5489,7 @@ open_include_file(cpp_reader * pfile, char *filename, && !strncmp(searchptr->fname, filename, p - filename)) { /* FILENAME is in SEARCHPTR, which we've already checked. */ + using_file(filename); return open(filename, O_RDONLY | O_BINARY, 0666); } if (p == filename) @@ -5508,8 +5509,12 @@ open_include_file(cpp_reader * pfile, char *filename, } for (map = read_name_map(pfile, dir); map; map = map->map_next) if (!strcmp(map->map_from, from)) - return open(map->map_to, O_RDONLY | O_BINARY, 0666); + { + using_file(map->map_to); + return open(map->map_to, O_RDONLY | O_BINARY, 0666); + } + using_file(filename); return open(filename, O_RDONLY | O_BINARY, 0666); } @@ -5519,6 +5524,7 @@ static int open_include_file(cpp_reader * pfile __UNUSED__, char *filename, file_name_list * searchptr __UNUSED__) { + using_file(filename); return open(filename, O_RDONLY | O_BINARY, 0666); } @@ -6561,6 +6567,20 @@ cpp_handle_options(cpp_reader * pfile, int argc, char **argv) i++, push_pending(pfile, "-D", argv[i]); break; + case 'a': + { + if (!strcmp(argv[i], "-a")) + { + if (i + 1 == argc) + cpp_fatal("Filename missing after `-a` option"); + else if (strcmp(argv[++i], "/dev/null")) + { + opts->watchfile = argv[i]; + } + } + break; + } + case 'A': { char *p = NULL; @@ -7425,3 +7445,17 @@ cpp_perror_with_name(cpp_reader * pfile, const char *name) * * Support for_lint flag. */ + +extern cpp_options options; + +void +using_file(const char *filename) +{ + FILE *f; + + f = fopen(options.watchfile, "a"); + if (!f) return ; + fputs(filename, f); + fputc('\n', f); + fclose(f); +} diff --git a/src/bin/epp/cpplib.h b/src/bin/epp/cpplib.h index 5653dd2..a34a765 100644 --- a/src/bin/epp/cpplib.h +++ b/src/bin/epp/cpplib.h @@ -473,6 +473,9 @@ struct cpp_options { /* Target-name to write with the dependency information. */ char *deps_target; + + /* Target file to write all include file */ + const char *watchfile; }; #define CPP_TRADITIONAL(PFILE) (CPP_OPTIONS(PFILE)-> traditional) @@ -636,6 +639,8 @@ void *xmalloc(unsigned size); void *xrealloc(void *old, unsigned size); void *xcalloc(unsigned number, unsigned size); +void using_file(const char *filename); + #ifdef __EMX__ #define PATH_SEPARATOR ';' #endif |