20
#include <Ecore_Evas.h>
23
#include "edje_convert.h"
24
#include "edje_multisense_convert.h"
29
typedef struct _External_Lookup External_Lookup;
30
typedef struct _Part_Lookup Part_Lookup;
31
typedef struct _Part_Lookup_Key Part_Lookup_Key;
32
typedef struct _Program_Lookup Program_Lookup;
33
typedef struct _Group_Lookup Group_Lookup;
34
typedef struct _Image_Lookup Image_Lookup;
35
typedef struct _Code_Lookup Code_Lookup;
37
struct _External_Lookup
42
struct _Part_Lookup_Key
44
Edje_Part_Collection *pc;
68
Edje_Part_Collection *pc;
78
Eina_Bool anonymous : 1;
108
typedef struct _Script_Lua_Writer Script_Lua_Writer;
110
struct _Script_Lua_Writer
116
typedef struct _Script_Write Script_Write;
117
typedef struct _Head_Write Head_Write;
118
typedef struct _Fonts_Write Fonts_Write;
119
typedef struct _Image_Write Image_Write;
120
typedef struct _Sound_Write Sound_Write;
121
typedef struct _Mo_Write Mo_Write;
122
typedef struct _Vibration_Write Vibration_Write;
123
typedef struct _Group_Write Group_Write;
124
typedef struct _License_Write License_Write;
154
Edje_Image_Directory_Entry *img;
156
Emile_Image_Property prop;
169
Edje_Sound_Sample *sample;
182
struct _Vibration_Write
185
Edje_Vibration_Sample *sample;
192
Edje_Part_Collection *pc;
203
struct _Image_Unused_Ids
209
typedef struct _Image_Unused_Ids Image_Unused_Ids;
211
static int pending_threads = 0;
212
static int pending_image_threads = 0;
214
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));
216
extern Eina_List *po_files;
218
Edje_File *edje_file = NULL;
219
Eina_List *edje_collections = NULL;
220
Eina_Hash *edje_collections_lookup = NULL;
221
Eina_List *externals = NULL;
222
Eina_List *fonts = NULL;
223
Eina_List *codes = NULL;
224
Eina_List *code_lookups = NULL;
225
Eina_List *aliases = NULL;
226
Eina_List *color_tree_root = NULL;
227
Eina_Hash *color_class_reg = NULL;
229
static Eet_Data_Descriptor *edd_edje_file = NULL;
230
static Eet_Data_Descriptor *edd_edje_part_collection = NULL;
232
static Eina_List *program_lookups = NULL;
233
static Eina_List *group_lookups = NULL;
234
static Eina_List *face_group_lookups = NULL;
235
static Eina_List *image_lookups = NULL;
237
static Eina_Hash *part_dest_lookup = NULL;
238
static Eina_Hash *part_pc_dest_lookup = NULL;
239
static Eina_Hash *groups_sourced = NULL;
241
static Eet_File *cur_ef;
243
static Ecore_Evas *buffer_ee;
244
static int cur_image_entry;
246
static void data_write_images(void);
249
error_and_abort(Eet_File *ef EINA_UNUSED, const char *fmt, ...)
254
eina_log_vprint(_edje_cc_log_dom, EINA_LOG_LEVEL_CRITICAL,
255
"unknown", "unknown", 0, fmt, ap);
258
if (watchfile) unlink(watchfile);
263
thread_end(Eina_Bool img)
266
pending_image_threads--;
271
if ((pending_image_threads + pending_threads) < (int)max_open_files - 2)
274
if (pending_threads + pending_image_threads <= 0) ecore_main_loop_quit();
278
_part_lookup_key_length(const void *key EINA_UNUSED)
280
return sizeof (Part_Lookup_Key);
284
_part_lookup_key_pc_cmp(const void *key1, int key1_length EINA_UNUSED,
285
const void *key2, int key2_length EINA_UNUSED)
287
const Part_Lookup_Key *a = key1;
288
const Part_Lookup_Key *b = key2;
291
delta = a->pc - b->pc;
292
if (delta) return delta;
294
if (a->stable) return a->mem.dest - b->mem.dest;
296
delta = a->mem.reallocated.base - b->mem.reallocated.base;
297
if (delta) return delta;
298
return a->mem.reallocated.offset - b->mem.reallocated.offset;
302
_part_lookup_key_pc_hash(const void *key, int key_length EINA_UNUSED)
304
const Part_Lookup_Key *a = key;
309
return eina_hash_int64((unsigned long long int *)&a->pc, sizeof (void *)) ^
310
eina_hash_int64((unsigned long long int *)&a->mem.dest, sizeof (void *));
312
return eina_hash_int32((uintptr_t *)&a->pc, sizeof (void *)) ^
313
eina_hash_int32((uintptr_t *)&a->mem.dest, sizeof (void *));
319
return eina_hash_int64((unsigned long long int *)&a->pc, sizeof (void *)) ^
320
eina_hash_int64((unsigned long long int *)&a->mem.reallocated.base, sizeof (void *)) ^
321
eina_hash_int32((unsigned int *)&a->mem.reallocated.offset, sizeof (int));
323
return eina_hash_int32((uintptr_t *)&a->pc, sizeof (void *)) ^
324
eina_hash_int32((uintptr_t *)&a->mem.reallocated.base, sizeof (void *)) ^
325
eina_hash_int32((unsigned int *)&a->mem.reallocated.offset, sizeof (int));
331
_part_lookup_key_cmp(const void *key1, int key1_length EINA_UNUSED,
332
const void *key2, int key2_length EINA_UNUSED)
334
const Part_Lookup_Key *a = key1;
335
const Part_Lookup_Key *b = key2;
338
if (a->stable) return a->mem.dest - b->mem.dest;
340
delta = a->mem.reallocated.base - b->mem.reallocated.base;
341
if (delta) return delta;
342
return a->mem.reallocated.offset - b->mem.reallocated.offset;
346
_part_lookup_key_hash(const void *key, int key_length EINA_UNUSED)
348
const Part_Lookup_Key *a = key;
353
return eina_hash_int64((unsigned long long int *)&a->mem.dest, sizeof (void *));
355
return eina_hash_int32((uintptr_t *)&a->mem.dest, sizeof (void *));
361
return eina_hash_int64((unsigned long long int *)&a->mem.reallocated.base, sizeof (void *)) ^
362
eina_hash_int32((unsigned int *)&a->mem.reallocated.offset, sizeof (int));
364
return eina_hash_int32((uintptr_t *)&a->mem.reallocated.base, sizeof (void *)) ^
365
eina_hash_int32((unsigned int *)&a->mem.reallocated.offset, sizeof (int));
371
data_part_lookup_free(Part_Lookup *pl)
380
eina_list_free(list);
386
edd_edje_file = _edje_edd_edje_file;
387
edd_edje_part_collection = _edje_edd_edje_part_collection;
389
part_dest_lookup = eina_hash_new(EINA_KEY_LENGTH(_part_lookup_key_length),
390
EINA_KEY_CMP(_part_lookup_key_cmp),
391
EINA_KEY_HASH(_part_lookup_key_hash),
392
EINA_FREE_CB(list_free),
394
part_pc_dest_lookup = eina_hash_new(EINA_KEY_LENGTH(_part_lookup_key_length),
395
EINA_KEY_CMP(_part_lookup_key_pc_cmp),
396
EINA_KEY_HASH(_part_lookup_key_pc_hash),
397
EINA_FREE_CB(data_part_lookup_free),
402
check_image_part_desc(Edje_Part_Collection *pc, Edje_Part *ep,
403
Edje_Part_Description_Image *epd, Eet_File *ef)
406
Edje_Part_Collection_Parser *pcp = (Edje_Part_Collection_Parser *)pc;
408
if (pcp->inherit_only) return;
410
if (epd->image.id == -1 && epd->common.visible)
411
WRN("Collection %s(%i): image attributes missing for "
412
"part \"%s\", description \"%s\" %f",
413
pc->part, pc->id, ep->name, epd->common.state.name, epd->common.state.value);
415
for (i = 0; i < epd->image.tweens_count; ++i)
417
if (epd->image.tweens[i]->id == -1)
418
error_and_abort(ef, "Collection %i: tween image id missing for "
419
"part \"%s\", description \"%s\" %f",
420
pc->id, ep->name, epd->common.state.name, epd->common.state.value);
424
static Edje_Part_Collection *
425
_source_group_find(const char *source)
427
Edje_Part_Collection *pc2;
429
if (!source) return NULL;
430
EINA_LIST_FOREACH(edje_collections, l, pc2)
432
if (!strcmp(pc2->part, source))
439
_aliased_text_part_find(Edje_Part_Collection *pc,
440
int id_source, const char *id_source_part)
442
Edje_Part_Collection *group;
445
if (!pc->parts[id_source]->source)
448
group = _source_group_find(pc->parts[id_source]->source);
449
if (!group) return NULL;
451
for (i = 0; i < group->parts_count; i++)
453
if (!strcmp(group->parts[i]->name, id_source_part))
454
return group->parts[i];
460
check_text_part_desc(Edje_Part_Collection *pc, Edje_Part *ep,
461
Edje_Part_Description_Text *epd, Eet_File *ef)
465
if (epd->text.id_source != -1)
467
if ((pc->parts[epd->text.id_source]->type == EDJE_PART_TYPE_TEXT) ||
468
(pc->parts[epd->text.id_source]->type == EDJE_PART_TYPE_TEXTBLOCK))
471
if (epd->text.id_source_part)
473
ep2 = _aliased_text_part_find(pc, epd->text.id_source, epd->text.id_source_part);
474
if (ep2 && ((ep2->type == EDJE_PART_TYPE_TEXT) ||
475
(ep2->type == EDJE_PART_TYPE_TEXTBLOCK)))
479
error_and_abort(ef, "Collection \"%s\" Part \"%s\" Description \"%s\" [%.3f]: "
480
"text.source point to a non TEXT part \"%s\"!",
481
pc->part, ep->name, epd->common.state.name,
482
epd->common.state.value, pc->parts[epd->text.id_source]->name);
485
if (epd->text.id_text_source != -1)
487
if ((pc->parts[epd->text.id_text_source]->type == EDJE_PART_TYPE_TEXT) ||
488
(pc->parts[epd->text.id_text_source]->type == EDJE_PART_TYPE_TEXTBLOCK))
491
if (epd->text.id_text_source_part)
493
ep2 = _aliased_text_part_find(pc, epd->text.id_text_source, epd->text.id_text_source_part);
494
if (ep2 && ((ep2->type == EDJE_PART_TYPE_TEXT) ||
495
(ep2->type == EDJE_PART_TYPE_TEXTBLOCK)))
499
error_and_abort(ef, "Collection \"%s\" Part \"%s\" Description \"%s\" [%.3f]: "
500
"text.text_source point to a non TEXT part \"%s\"!",
501
pc->part, ep->name, epd->common.state.name,
502
epd->common.state.value, pc->parts[epd->text.id_text_source]->name);
506
/* This function check loops between groups.
508
> part in group A. It's source is B.
509
> part in group B. It's source is C.
510
> part in group C. It's source is A <- here is error.
511
It's loop that we need to avoid! */
513
check_source_links(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef, Eina_List *group_path)
517
Edje_Part_Collection *pc_source;
520
EINA_LIST_FOREACH(edje_collections, l, pc_source)
522
/* Find sourced group */
523
if (ep->source && pc_source->part && strcmp(ep->source, pc_source->part) == 0)
525
/* Go through every part to find parts with type GROUP */
526
for (i = 0; i < pc_source->parts_count; ++i)
528
if ((pc_source->parts[i]->type == EDJE_PART_TYPE_GROUP) &&
529
(pc_source->parts[i]->source))
531
/* Make sure that this group isn't already in the tree of parents */
532
EINA_LIST_FOREACH(group_path, l, data)
534
if (data == pc_source->parts[i]->source)
536
error_and_abort(ef, "Recursive loop group '%s' "
537
"already included inside "
538
"part '%s' of group '%s'",
539
data, pc_source->parts[i]->name,
543
group_path = eina_list_append(group_path, ep->source);
544
check_source_links(pc, pc_source->parts[i], ef, group_path);
552
check_packed_items(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
556
for (i = 0; i < ep->items_count; ++i)
558
if (ep->items[i]->type == EDJE_PART_TYPE_GROUP && !ep->items[i]->source)
559
error_and_abort(ef, "Collection %i: missing source on packed item "
560
"of type GROUP in part \"%s\"",
562
if (ep->type == EDJE_PART_TYPE_TABLE && (ep->items[i]->col < 0 || ep->items[i]->row < 0))
563
error_and_abort(ef, "Collection %i: missing col/row on packed item "
564
"for part \"%s\" of type TABLE",
570
check_nameless_state(Edje_Part_Collection *pc, Edje_Part *ep, Edje_Part_Description_Common *ed, Eet_File *ef)
572
Edje_Part_Collection_Directory_Entry *de;
574
if (ed->state.name) return;
576
de = eina_hash_find(edje_collections_lookup, &pc->id);
577
error_and_abort(ef, "Group '%s': part \"%s\" has description with missing state",
578
de->entry, ep->name);
582
check_state(Edje_Part_Collection *pc, Edje_Part *ep, Edje_Part_Description_Common *ed, Eet_File *ef)
584
check_nameless_state(pc, ep, ed, ef);
588
_part_namespace_verify(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef, Eina_Bool ns_required)
592
Edje_Part_Collection_Directory_Entry *de;
594
if (!namespace_verify) return;
595
/* this is from a group used as a source, either GROUP or TEXTBLOCK
596
* namespacing not required
598
if (eina_hash_find(groups_sourced, pc->part)) return;
600
de = eina_hash_find(edje_collections_lookup, &pc->id);
602
p = strchr(de->entry, '/');
606
if (eina_strlcpy(buf, de->entry, len + 1) >= sizeof(buf)) return;
608
p = strchr(ep->name, '.');
609
/* ignore part types without required namespacing or without '.' in name */
610
if ((!ns_required) && (!p)) return;
612
if (strncmp(ep->name, buf, len))
613
error_and_abort(ef, "Part '%s' from group %s is not properly namespaced (should begin with '%s.')!", ep->name, de->entry, buf);
617
check_part(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
619
Edje_Part_Collection_Parser *pcp = (Edje_Part_Collection_Parser*)pc;
621
Eina_List *group_path = NULL;
622
/* FIXME: check image set and sort them. */
623
if (!ep->default_desc)
624
error_and_abort(ef, "Collection %i: default description missing "
625
"for part \"%s\"", pc->id, ep->name);
627
check_state(pc, ep, ep->default_desc, ef);
628
for (i = 0; i < ep->other.desc_count; ++i)
629
check_state(pc, ep, ep->other.desc[i], ef);
631
if (ep->type == EDJE_PART_TYPE_IMAGE)
633
check_image_part_desc(pc, ep, (Edje_Part_Description_Image *)ep->default_desc, ef);
635
for (i = 0; i < ep->other.desc_count; ++i)
636
check_image_part_desc(pc, ep, (Edje_Part_Description_Image *)ep->other.desc[i], ef);
638
else if ((ep->type == EDJE_PART_TYPE_BOX) ||
639
(ep->type == EDJE_PART_TYPE_TABLE))
640
check_packed_items(pc, ep, ef);
641
else if (ep->type == EDJE_PART_TYPE_GROUP)
642
check_source_links(pc, ep, ef, group_path);
643
else if (ep->type == EDJE_PART_TYPE_TEXT)
645
check_text_part_desc(pc, ep, (Edje_Part_Description_Text *)ep->default_desc, ef);
647
for (i = 0; i < ep->other.desc_count; ++i)
648
check_text_part_desc(pc, ep, (Edje_Part_Description_Text *)ep->other.desc[i], ef);
651
if (!pcp->skip_namespace_validation)
655
case EDJE_PART_TYPE_BOX:
656
case EDJE_PART_TYPE_TABLE:
657
case EDJE_PART_TYPE_SWALLOW:
658
_part_namespace_verify(pc, ep, ef, 1);
660
case EDJE_PART_TYPE_TEXT:
661
case EDJE_PART_TYPE_TEXTBLOCK:
662
case EDJE_PART_TYPE_SPACER:
663
_part_namespace_verify(pc, ep, ef, 0);
671
_program_signal_namespace_verify(Edje_Part_Collection *pc, Eet_File *ef, const char *sig, const char *src)
675
Edje_Part_Collection_Directory_Entry *de;
677
if (!namespace_verify) return;
678
/* this is from a group used as a source, either GROUP or TEXTBLOCK
679
* namespacing not required
681
if (eina_hash_find(groups_sourced, pc->part)) return;
683
/* ignore propagation to GROUP parts */
684
if (strchr(sig, ':')) return;
686
de = eina_hash_find(edje_collections_lookup, &pc->id);
688
p = strchr(de->entry, '/');
691
if (eina_strlcpy(buf, de->entry, len + 1) >= sizeof(buf)) return;
693
if (strncmp(sig, buf, len))
694
error_and_abort(ef, "SIGNAL_EMIT (%s:%s) does not match group namespace (%s)!", sig, src, de->entry);
698
check_program(Edje_Part_Collection *pc, Edje_Program *ep, Eet_File *ef)
700
Edje_Part_Collection_Parser *pcp = (Edje_Part_Collection_Parser*)pc;
703
case EDJE_ACTION_TYPE_STATE_SET:
704
case EDJE_ACTION_TYPE_ACTION_STOP:
705
case EDJE_ACTION_TYPE_DRAG_VAL_SET:
706
case EDJE_ACTION_TYPE_DRAG_VAL_STEP:
707
case EDJE_ACTION_TYPE_DRAG_VAL_PAGE:
709
error_and_abort(ef, "Collection %i: target missing in program "
710
"\"%s\"", pc->id, ep->name);
716
Edje_Program_Target *et;
720
if ((!ep->targets) && (ep->action == EDJE_ACTION_TYPE_SIGNAL_EMIT))
722
if (!pcp->skip_namespace_validation)
723
_program_signal_namespace_verify(pc, ef, ep->state, ep->state2);
726
EINA_LIST_FOREACH(ep->targets, l, et)
731
* we are accessing part with an id,
732
* if actions is ACTION_STOP or ACTION_TYPE_SCRIPT, then id is NOT from the parts array.
733
* In order to not crash here, we should continue here.
735
if (ep->action == EDJE_ACTION_TYPE_ACTION_STOP || ep->action == EDJE_ACTION_TYPE_SCRIPT)
738
if (et->id >= (int) pc->parts_count)
740
ERR("In group '%s' program '%s', target id '%d' greater than possible index '%d'.",
741
pc->part ? pc->part : "", ep->name ? ep->name : "", et->id, (int) pc->parts_count - 1);
745
part = pc->parts[et->id];
746
/* verify existence of description in part */
747
if (ep->action == EDJE_ACTION_TYPE_STATE_SET)
749
if ((!eina_streq(ep->state, "custom")) &&
750
((!eina_streq(ep->state, "default")) || (!EINA_DBL_EQ(ep->value, 0.0))))
752
Edje_Part_Collection_Directory_Entry *de;
753
Eina_Bool found = EINA_FALSE;
754
for (i = 0; i < part->other.desc_count; i++)
756
Edje_Part_Description_Common *ed = part->other.desc[i];
757
if (eina_streq(ed->state.name, ep->state) && EINA_DBL_EQ(ep->value, ed->state.value))
765
de = eina_hash_find(edje_collections_lookup, &pc->id);
766
error_and_abort(NULL, "GROUP %s - state '%s:%g' does not exist for part '%s'; set in program '%s'",
767
de->entry, ep->state, ep->value, part->name, ep->name);
774
/* reset part counters for alias */
776
_alias_clean(Edje_Part_Collection_Directory_Entry *ce)
780
ce->count.RECTANGLE = 0;
783
ce->count.SWALLOW = 0;
784
ce->count.TEXTBLOCK = 0;
788
ce->count.EXTERNAL = 0;
790
ce->count.SPACER = 0;
791
ce->count.VECTOR = 0;
797
data_thread_head(void *data, Ecore_Thread *thread EINA_UNUSED)
799
Head_Write *hw = data;
801
char buf[EINA_PATH_MAX];
805
if (edje_file->collection)
807
Edje_Part_Collection_Directory_Entry *ce;
809
EINA_LIST_FREE(aliases, ce)
811
Edje_Part_Collection_Directory_Entry *sce;
815
snprintf(buf, sizeof(buf),
816
"Collection %i: name missing.", ce->id);
817
hw->errstr = strdup(buf);
821
sce = eina_hash_find(edje_collections_lookup, &ce->id);
824
memcpy(&ce->count, &sce->count, sizeof (ce->count));
828
snprintf(buf, sizeof(buf),
829
"Collection %s (%i) can't find an correct alias.",
831
hw->errstr = strdup(buf);
836
eina_hash_direct_add(edje_file->collection, ce->entry, ce);
839
bytes = eet_data_write(hw->ef, edd_edje_file, "edje/file", edje_file,
843
snprintf(buf, sizeof(buf),
844
"Unable to write \"edje_file\" entry to \"%s\"",
846
hw->errstr = strdup(buf);
851
INF("Wrote %9i bytes (%4iKb) for \"edje_file\" header",
852
bytes, (bytes + 512) / 1024);
856
data_thread_head_end(void *data, Ecore_Thread *thread EINA_UNUSED)
858
Head_Write *hw = data;
862
error_and_abort(hw->ef, hw->errstr);
870
data_write_header(Eet_File *ef)
874
hw = calloc(1, sizeof(Head_Write));
878
ecore_thread_run(data_thread_head, data_thread_head_end, NULL, hw);
881
data_thread_head(hw, NULL);
882
data_thread_head_end(hw, NULL);
887
data_thread_fonts(void *data, Ecore_Thread *thread EINA_UNUSED)
889
Fonts_Write *fc = data;
894
char buf[EINA_PATH_MAX];
895
char buf2[EINA_PATH_MAX + EINA_PATH_MAX + 128];
898
f = eina_file_open(fc->fn->file, 0);
901
using_file(fc->fn->file, 'F');
902
m = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
908
EINA_LIST_FOREACH(fnt_dirs, ll, dat)
910
snprintf(buf, sizeof(buf), "%s/%s", dat, fc->fn->file);
911
f = eina_file_open(buf, 0);
914
using_file(buf, 'F');
915
m = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
924
if (f) eina_file_close(f);
925
snprintf(buf, sizeof(buf),
926
"Unable to load font part \"%s\" entry to %s",
927
fc->fn->file, file_out);
928
fc->errstr = strdup(buf);
932
snprintf(buf, sizeof(buf), "edje/fonts/%s", fc->fn->name);
933
bytes = eet_write(fc->ef, buf, m, eina_file_size_get(f), compress_mode);
935
if ((bytes <= 0) || eina_file_map_faulted(f, m))
937
eina_file_map_free(f, m);
939
snprintf(buf2, sizeof(buf2),
940
"Unable to write font part \"%s\" as \"%s\" "
941
"part entry to %s", fc->fn->file, buf, file_out);
942
fc->errstr = strdup(buf2);
946
size = eina_file_size_get(f);
947
INF("Wrote %9i bytes (%4iKb) for \"%s\" font entry \"%s\" compress: [real: %2.1f%%]",
948
bytes, (bytes + 512) / 1024, buf, fc->fn->file,
949
100 - (100 * (double)bytes) / ((double)((size > 0) ? size : 1))
951
eina_file_map_free(f, m);
956
data_thread_fonts_end(void *data, Ecore_Thread *thread EINA_UNUSED)
958
Fonts_Write *fc = data;
961
error_and_abort(fc->ef, fc->errstr);
969
data_write_fonts(Eet_File *ef, int *font_num)
974
if (!edje_file->fonts) return;
976
it = eina_hash_iterator_data_new(edje_file->fonts);
977
EINA_ITERATOR_FOREACH(it, fn)
981
fc = calloc(1, sizeof(Fonts_Write));
987
ecore_thread_run(data_thread_fonts, data_thread_fonts_end, NULL, fc);
990
data_thread_fonts(fc, NULL);
991
data_thread_fonts_end(fc, NULL);
995
eina_iterator_free(it);
999
error_and_abort_image_load_error(Eet_File *ef, const char *file, int error)
1001
const char *errmsg = evas_load_error_str(error);
1002
char hint[1024] = "";
1004
if (error == EVAS_LOAD_ERROR_DOES_NOT_EXIST)
1007
(hint, sizeof(hint),
1008
" Check if path to file \"%s\" is correct "
1009
"(both directory and file name).",
1012
else if (error == EVAS_LOAD_ERROR_CORRUPT_FILE)
1015
(hint, sizeof(hint),
1016
" Check if file \"%s\" is consistent.",
1019
else if (error == EVAS_LOAD_ERROR_UNKNOWN_FORMAT)
1021
const char *ext = strrchr(file, '.');
1022
const char **itr, *known_loaders[] = {
1023
/* list from evas_image_load.c */
1052
(hint, sizeof(hint),
1053
" File \"%s\" does not have an extension, "
1060
for (itr = known_loaders; *itr; itr++)
1062
if (strcasecmp(ext, *itr) == 0)
1065
(hint, sizeof(hint),
1066
" Check if Evas was compiled with %s module enabled and "
1067
"all required dependencies exist.",
1073
snprintf(hint, sizeof(hint),
1074
" Check if Evas supports loading files of type \"%s\" (%s) "
1075
"and this module was compiled and all its dependencies exist.",
1080
(ef, "Unable to load image \"%s\" used by file \"%s\": %s.%s",
1081
file, file_out, errmsg, hint);
1085
data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED)
1087
Image_Write *iw = data;
1088
char buf[PATH_MAX], buf2[EINA_PATH_MAX];
1089
unsigned int *start, *end;
1090
Eina_Bool opaque = EINA_TRUE;
1093
if ((iw->data) && (iw->w > 0) && (iw->h > 0))
1095
Eet_Image_Encoding lossy = EET_IMAGE_LOSSLESS;
1096
int mode, qual, comp = 0;
1098
snprintf(buf, sizeof(buf), "edje/images/%i", iw->img->id);
1100
if ((iw->img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) &&
1101
(iw->img->source_param == 0))
1103
else if ((iw->img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT) &&
1104
(iw->img->source_param == 1))
1105
mode = 1; /* COMPRESS */
1106
else if (iw->img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1)
1107
mode = 3; /* LOSSY_ETC1 */
1108
else if (iw->img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2)
1109
mode = 4; /* LOSSY_ETC2 */
1111
mode = 2; /* LOSSY */
1112
if ((mode == 0) && (no_raw))
1114
mode = 1; /* promote compression */
1115
iw->img->source_param = 95;
1117
if ((mode == 4) && (no_etc2)) mode = 2; /* demote etc2 to jpeg */
1118
if ((mode == 3) && (no_etc1)) mode = 2; /* demote etc1 to jpeg */
1119
if ((mode == 2) && (no_lossy)) mode = 1; /* demote compression */
1120
if ((mode == 1) && (no_comp))
1122
if (no_lossy) mode = 0; /* demote compression */
1125
iw->img->source_param = 90;
1126
mode = 2; /* no choice. lossy */
1131
qual = iw->img->source_param;
1132
if (qual < min_quality) qual = min_quality;
1133
if (qual > max_quality) qual = max_quality;
1134
lossy = EET_IMAGE_JPEG;
1138
start = (unsigned int *)iw->data;
1139
end = start + (iw->w * iw->h);
1142
if ((*start & 0xff000000) != 0xff000000)
1144
opaque = EINA_FALSE;
1149
if (opaque) iw->alpha = 0;
1153
qual = iw->img->source_param;
1154
if (qual < min_quality) qual = min_quality;
1155
if (qual > max_quality) qual = max_quality;
1156
// Enable TGV with LZ4. A bit redundant with EET compression.
1158
lossy = opaque ? EET_IMAGE_ETC1 : EET_IMAGE_ETC1_ALPHA;
1162
qual = iw->img->source_param;
1163
if (qual < min_quality) qual = min_quality;
1164
if (qual > max_quality) qual = max_quality;
1165
lossy = opaque ? EET_IMAGE_ETC2_RGB : EET_IMAGE_ETC2_RGBA;
1168
bytes = eet_data_image_write(iw->ef, buf,
1169
iw->data, iw->w, iw->h,
1173
bytes = eet_data_image_write(iw->ef, buf,
1174
iw->data, iw->w, iw->h,
1179
bytes = eet_data_image_write(iw->ef, buf,
1180
iw->data, iw->w, iw->h,
1185
snprintf(buf2, sizeof(buf2),
1186
"Unable to write image part "
1187
"\"%s\" as \"%s\" part entry to "
1188
"%s", iw->img->entry, buf, file_out);
1189
iw->errstr = strdup(buf2);
1195
snprintf(buf, sizeof(buf), "edje/images/%i", iw->img->id);
1196
snprintf(buf2, sizeof(buf2),
1197
"Unable to load image part "
1198
"\"%s\" as \"%s\" part entry to "
1199
"%s", iw->img->entry, buf, file_out);
1200
iw->errstr = strdup(buf2);
1204
if (eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_INFO))
1208
if (!iw->path || (stat(iw->path, &st))) st.st_size = 0;
1211
INF("Wrote %9i bytes (%4iKb) for \"%s\" image entry \"%s\" compress: [raw: %2.1f%%] [real: %2.1f%%]",
1212
bytes, (bytes + 512) / 1024, buf, iw->img->entry,
1213
100 - (100 * (double)bytes) / ((double)(iw->w * iw->h * 4)),
1214
100 - (100 * (double)bytes) / ((double)(st.st_size))
1221
data_thread_image_end(void *data, Ecore_Thread *thread EINA_UNUSED)
1223
Image_Write *iw = data;
1227
error_and_abort(iw->ef, iw->errstr);
1231
evas_object_del(iw->im);
1237
data_image_preload_done(void *data, Evas *e EINA_UNUSED, Evas_Object *o, void *event_info EINA_UNUSED)
1239
Image_Write *iw = data;
1241
evas_object_image_size_get(o, &iw->w, &iw->h);
1242
iw->alpha = evas_object_image_alpha_get(o);
1243
iw->data = evas_object_image_data_get(o, 0);
1245
ecore_thread_run(data_thread_image, data_thread_image_end, NULL, iw);
1248
data_thread_image(iw, NULL);
1249
data_thread_image_end(iw, NULL);
1254
tgv_file_thread(void *data, Ecore_Thread *thread EINA_UNUSED)
1256
Image_Write *iw = data;
1260
snprintf(buf, sizeof(buf), "edje/images/%i", iw->img->id);
1262
len = eina_file_size_get(iw->f);
1263
eet_write_cipher(iw->ef, buf, iw->data, len, EINA_FALSE /*!no_comp*/, NULL);
1267
tgv_file_thread_end(void *data, Ecore_Thread *thread EINA_UNUSED)
1269
Image_Write *iw = data;
1273
error_and_abort(iw->ef, iw->errstr);
1277
emile_image_close(iw->emi);
1278
eina_file_map_free(iw->f, iw->data);
1279
eina_file_close(iw->f);
1285
tgv_file_check_and_add(Eet_File *ef, Edje_Image_Directory_Entry *img)
1287
Emile_Image_Load_Error err;
1288
Emile_Image *emi = NULL;
1289
Image_Write *iw = NULL;
1292
Eina_File *f = NULL;
1295
EINA_LIST_FOREACH(img_dirs, li, s)
1298
snprintf(buf, sizeof(buf), "%s/%s", s, img->entry);
1299
f = eina_file_open(buf, EINA_FALSE);
1302
if (!f) return EINA_FALSE;
1304
data = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
1305
if (!data) goto on_error;
1307
using_file(img->entry, 'I');
1309
emi = emile_image_tgv_file_open(f, NULL, NULL, &err);
1310
if (!emi || (err != EMILE_IMAGE_LOAD_ERROR_NONE)) goto on_error;
1312
iw = calloc(1, sizeof(*iw));
1314
if (!emile_image_head(emi, &iw->prop, sizeof(iw->prop), &err) ||
1315
(err != EMILE_IMAGE_LOAD_ERROR_NONE))
1318
if (!iw->prop.cspaces || !iw->prop.w || !iw->prop.h)
1325
iw->data = (unsigned int *)data;
1329
iw->prop.cspace = iw->prop.cspaces[0];
1330
if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1)
1332
if (no_etc1) goto on_error;
1333
if (iw->prop.cspace == EMILE_COLORSPACE_ETC1)
1335
else if (iw->prop.cspace == EMILE_COLORSPACE_ETC1_ALPHA)
1340
else if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2)
1342
if (no_etc2) goto on_error;
1343
if (iw->prop.cspace == EMILE_COLORSPACE_RGB8_ETC2)
1345
else if (iw->prop.cspace == EMILE_COLORSPACE_RGBA8_ETC2_EAC)
1352
iw->path = strdup(img->entry);
1354
pending_image_threads++;
1356
ecore_thread_run(tgv_file_thread, tgv_file_thread_end, NULL, iw);
1359
tgv_file_thread(iw, NULL);
1360
tgv_file_thread_end(iw, NULL);
1367
emile_image_close(emi);
1368
if (data) eina_file_map_free(f, data);
1374
data_write_vectors(Eet_File *ef, int *vector_num)
1379
Eina_File *f = NULL;
1380
Edje_Vector_Directory_Entry *vector;
1382
Eina_Bool found = EINA_FALSE;
1386
if (!((edje_file) && (edje_file->image_dir))) return;
1389
buffer_ee = ecore_evas_buffer_new(1, 1);
1391
error_and_abort(ef, "Cannot create buffer engine canvas for image load.");
1392
evas = ecore_evas_get(buffer_ee);
1393
vg = evas_object_vg_add(evas);
1394
buf = eina_strbuf_new();
1395
for (i = 0; i < edje_file->image_dir->vectors_count; i++)
1397
vector = &edje_file->image_dir->vectors[i];
1398
EINA_LIST_FOREACH(img_dirs, ll, s)
1400
eina_strbuf_reset(buf);
1401
eina_strbuf_append_printf(buf, "%s" EINA_PATH_SEP_S "%s", s, vector->entry);
1402
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
1406
if (vector->type == EDJE_VECTOR_FILE_TYPE_LOTTIE)
1408
char *lottie_data = NULL;
1409
int lottie_data_len = 0;
1411
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
1414
lottie_data_len = (int) eina_file_size_get(f);
1415
lottie_data = eina_file_map_all(f, EINA_FILE_POPULATE);
1417
eina_strbuf_reset(buf);
1418
eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id);
1419
eet_write(ef, eina_strbuf_string_get(buf), lottie_data, lottie_data_len, EET_COMPRESSION_NONE);
1421
eina_file_map_free(f, lottie_data);
1430
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
1434
if (efl_file_set(vg, eina_strbuf_string_get(buf)))
1435
error_and_abort(ef, "Failed to parse svg : %s", vector->entry);
1436
if (efl_file_load(vg))
1437
error_and_abort(ef, "Failed to parse svg : %s", vector->entry);
1439
eina_strbuf_reset(buf);
1440
eina_strbuf_append_printf(buf, "edje/vectors/%i", vector->id);
1441
if (!efl_file_save(vg, eet_file_get(ef), eina_strbuf_string_get(buf), NULL))
1442
error_and_abort(ef, "Failed to write data in Eet for svg :%s", vector->entry);
1450
error_and_abort(ef, "Unable to find the svg :%s", vector->entry);
1453
eina_strbuf_free(buf);
1457
data_image_sets_init(void)
1461
if (!((edje_file) && (edje_file->image_dir))) return;
1462
for (i = 0; i < (int)edje_file->image_dir->sets_count; i++)
1464
Edje_Image_Directory_Set *set;
1465
Edje_Image_Directory_Set_Entry *set_entry;
1466
Edje_Image_Directory_Entry *img;
1467
Eina_List *ll = NULL;
1469
set = edje_file->image_dir->sets + i;
1470
if (!set->entries) continue;
1471
EINA_LIST_FOREACH(set->entries, ll, set_entry)
1473
if (set_entry->id < (int)edje_file->image_dir->entries_count)
1475
img = &edje_file->image_dir->entries[set_entry->id];
1476
set_entry->name = img->entry;
1480
ERR("set %i / %i, entry %i / %i\n",
1481
i, edje_file->image_dir->sets_count,
1482
set_entry->id, edje_file->image_dir->entries_count);
1490
data_write_images(void)
1493
const char *ext = NULL;
1495
if (!((edje_file) && (edje_file->image_dir))) return;
1498
buffer_ee = ecore_evas_buffer_new(1, 1);
1500
error_and_abort(cur_ef, "Cannot create buffer engine canvas for image load.");
1501
evas = ecore_evas_get(buffer_ee);
1503
for (; cur_image_entry < (int)edje_file->image_dir->entries_count; cur_image_entry++)
1505
Edje_Image_Directory_Entry *img;
1509
int load_err = EVAS_LOAD_ERROR_NONE;
1512
img = &edje_file->image_dir->entries[cur_image_entry];
1513
if ((img->source_type >= EDJE_IMAGE_SOURCE_TYPE_USER) || !img->entry)
1516
if (img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1 ||
1517
img->source_type == EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC2)
1519
ext = strrchr(img->entry, '.');
1520
if (ext && !strcasecmp(ext, ".tgv"))
1522
if (tgv_file_check_and_add(cur_ef, img))
1524
DBG("Directly copying data from TGV file into EDJ");
1528
ERR("Source '%s' has incompatible ETC format.", img->entry);
1532
iw = calloc(1, sizeof(Image_Write));
1535
iw->im = im = evas_object_image_add(evas);
1537
evas_object_event_callback_add(im,
1538
EVAS_CALLBACK_IMAGE_PRELOADED,
1539
data_image_preload_done,
1541
EINA_LIST_FOREACH(img_dirs, ll, s)
1545
snprintf(buf, sizeof(buf), "%s/%s", s, img->entry);
1546
evas_object_image_file_set(im, buf, NULL);
1547
load_err = evas_object_image_load_error_get(im);
1548
if (load_err == EVAS_LOAD_ERROR_NONE)
1551
iw->path = strdup(buf);
1552
pending_image_threads++;
1554
evas_object_image_preload(im, 0);
1555
using_file(buf, 'I');
1557
data_image_preload_done(iw, evas, im, NULL);
1561
if (!img_dirs || (load_err != EVAS_LOAD_ERROR_NONE))
1563
evas_object_image_file_set(im, img->entry, NULL);
1564
load_err = evas_object_image_load_error_get(im);
1565
if (load_err == EVAS_LOAD_ERROR_NONE)
1568
iw->path = strdup(img->entry);
1569
pending_image_threads++;
1571
evas_object_image_preload(im, 0);
1572
using_file(img->entry, 'I');
1574
data_image_preload_done(iw, evas, im, NULL);
1579
error_and_abort_image_load_error(cur_ef, img->entry, load_err);
1580
exit(1); // ensure static analysis tools know we exit
1584
if (img->source_type < EDJE_IMAGE_SOURCE_TYPE_USER)
1586
ext = strrchr(img->entry, '.');
1587
if (ext && (!strcasecmp(ext, ".svg") || !strcasecmp(ext, ".svgz")))
1589
int size = strlen(img->entry) + strlen(".png") + 1;
1590
char *tmp = malloc(size);
1591
snprintf(tmp, size, "%s.png", img->entry);
1592
INF("Vector '%s' used as image, convert to bitmap '%s'", img->entry, tmp);
1593
free((void *)img->entry);
1599
if (pending_threads + pending_image_threads > (int)max_open_files - 2) break;
1605
data_thread_sounds(void *data, Ecore_Thread *thread EINA_UNUSED)
1607
Sound_Write *sw = data;
1609
#ifdef HAVE_LIBSNDFILE
1610
Edje_Sound_Encode *enc_info;
1612
char *dir_path = NULL;
1613
char snd_path[PATH_MAX];
1615
Eina_File *f = NULL;
1619
// Search the Sound file in all the -sd ( sound directory )
1620
EINA_LIST_FOREACH(snd_dirs, ll, dir_path)
1622
snprintf((char *)snd_path, sizeof(snd_path), "%s/%s", dir_path,
1623
sw->sample->snd_src);
1624
f = eina_file_open(snd_path, 0);
1629
snprintf((char *)snd_path, sizeof(snd_path), "%s",
1630
sw->sample->snd_src);
1631
f = eina_file_open(snd_path, 0);
1633
#ifdef HAVE_LIBSNDFILE
1634
if (f) eina_file_close(f);
1635
enc_info = _edje_multisense_encode(snd_path, sw->sample,
1636
sw->sample->quality);
1637
f = eina_file_open(enc_info->file, 0);
1638
if (f) using_file(enc_info->file, 'S');
1640
if (f) using_file(snd_path, 'S');
1644
ERR("Unable to load sound data of: %s", sw->sample->name);
1648
snprintf(sndid_str, sizeof(sndid_str), "edje/sounds/%i", sw->sample->id);
1649
m = eina_file_map_all(f, EINA_FILE_WILLNEED);
1652
bytes = eet_write(sw->ef, sndid_str, m, eina_file_size_get(f),
1653
EET_COMPRESSION_NONE);
1654
if (eina_file_map_faulted(f, m))
1656
ERR("File access error when reading '%s'",
1657
eina_file_filename_get(f));
1660
eina_file_map_free(f, m);
1664
#ifdef HAVE_LIBSNDFILE
1665
//If encoded temporary file, delete it.
1666
if (enc_info->encoded) unlink(enc_info->file);
1668
#ifdef HAVE_LIBSNDFILE
1669
INF("Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry \"%s\"",
1670
bytes, (bytes + 512) / 1024,
1671
sndid_str, enc_info->comp_type, sw->sample->name);
1673
INF("Wrote %9i bytes (%4iKb) for \"%s\" %s sound entry \"%s\"",
1674
bytes, (bytes + 512) / 1024,
1675
sndid_str, "RAW PCM", sw->sample->name);
1678
#ifdef HAVE_LIBSNDFILE
1679
if ((enc_info->file) && (!enc_info->encoded))
1680
eina_stringshare_del(enc_info->file);
1687
data_thread_sounds_end(void *data, Ecore_Thread *thread EINA_UNUSED)
1689
Sound_Write *sw = data;
1695
data_write_sounds(Eet_File *ef, int *sound_num)
1697
if ((edje_file) && (edje_file->sound_dir))
1701
for (i = 0; i < (int)edje_file->sound_dir->samples_count; i++)
1705
sw = calloc(1, sizeof(Sound_Write));
1708
sw->sample = &edje_file->sound_dir->samples[i];
1713
ecore_thread_run(data_thread_sounds, data_thread_sounds_end, NULL, sw);
1716
data_thread_sounds(sw, NULL);
1717
data_thread_sounds_end(sw, NULL);
1724
data_thread_mo(void *data, Ecore_Thread *thread EINA_UNUSED)
1726
Mo_Write *mw = data;
1727
char buf[EINA_PATH_MAX];
1730
char *dir_path = NULL;
1731
char mo_path[PATH_MAX] = {0};
1733
Eina_File *f = NULL;
1738
f = eina_file_open(mw->mo_path, 0);
1741
// Search the mo file in all the -md ( mo directory )
1742
EINA_LIST_FOREACH(mo_dirs, ll, dir_path)
1744
snprintf((char *)mo_path, sizeof(mo_path), "%s/%s/%s", dir_path, mw->mo_entry->locale, mw->mo_entry->mo_src);
1745
f = eina_file_open(mo_path, 0);
1751
snprintf((char *)mo_path, sizeof(mo_path), "%s", mw->mo_entry->mo_src);
1752
f = eina_file_open(mo_path, 0);
1755
if (f) using_file(mo_path, 'S');
1759
snprintf(buf, sizeof(buf), "Unable to load mo data of: %s", mo_path);
1761
mw->errstr = strdup(buf);
1765
snprintf(moid_str, sizeof(moid_str), "edje/mo/%i/%s/LC_MESSAGES", mw->mo_entry->id, mw->mo_entry->locale);
1766
m = eina_file_map_all(f, EINA_FILE_WILLNEED);
1769
bytes = eet_write(mw->ef, moid_str, m, eina_file_size_get(f), EET_COMPRESSION_NONE);
1770
if (eina_file_map_faulted(f, m))
1772
snprintf(buf, sizeof(buf), "File access error when reading '%s'",
1773
eina_file_filename_get(f));
1775
mw->errstr = strdup(buf);
1779
eina_file_map_free(f, m);
1783
ecore_file_remove(mo_path);
1785
INF("Wrote %9i bytes (%4iKb) for \"%s\" %s mo entry \"%s\"",
1786
bytes, (bytes + 512) / 1024, moid_str, "RAW PCM", mw->mo_entry->locale);
1790
data_thread_mo_end(void *data, Ecore_Thread *thread EINA_UNUSED)
1792
Mo_Write *mw = data;
1795
error_and_abort(mw->ef, mw->errstr);
1805
_exe_del_cb(void *data EINA_UNUSED, int evtype EINA_UNUSED, void *evinfo)
1807
Mo_Write *mw = data;
1808
Ecore_Exe_Event_Del *ev = evinfo;
1809
if (!ev->exe) return ECORE_CALLBACK_RENEW;
1810
if (ecore_exe_data_get(ev->exe) != mw) return ECORE_CALLBACK_RENEW;
1811
if (ev->exit_code != 0)
1813
error_and_abort(mw->ef, "Creation of .mo from .po failed.");
1814
return ECORE_CALLBACK_CANCEL;
1816
if (ecore_file_exists(mw->mo_path))
1819
ecore_thread_run(data_thread_mo, data_thread_mo_end, NULL, mw);
1822
data_thread_mo(mw, NULL);
1823
data_thread_mo_end(mw, NULL);
1827
return ECORE_CALLBACK_RENEW;
1828
if (pending_threads + pending_image_threads <= 0) ecore_main_loop_quit();
1829
return ECORE_CALLBACK_CANCEL;
1833
data_write_mo(Eet_File *ef, int *mo_num)
1835
if ((edje_file) && (edje_file->mo_dir))
1840
char buf[EINA_PATH_MAX + PATH_MAX + PATH_MAX + 128];
1842
char *dir_path = NULL;
1843
char mo_path[PATH_MAX];
1844
char po_path[PATH_MAX];
1846
for (i = 0; i < (int)edje_file->mo_dir->mo_entries_count; i++)
1849
mw = calloc(1, sizeof(Mo_Write));
1852
mw->mo_entry = &edje_file->mo_dir->mo_entries[i];
1856
po_entry = strdup(mw->mo_entry->mo_src);
1857
sub_str = strstr(mw->mo_entry->mo_src, ".po");
1862
EINA_LIST_FOREACH(mo_dirs, ll, dir_path)
1864
snprintf((char *)po_path, sizeof(po_path), "%s/%s/%s", dir_path, mw->mo_entry->locale, po_entry);
1865
if (ecore_file_exists(po_path))
1867
char *mo_dir = ecore_file_dir_get(eet_file_get(ef));
1868
snprintf((char *)mo_path, sizeof(mo_path), "%s/%s", mo_dir, mw->mo_entry->locale);
1869
ecore_file_mkpath(mo_path);
1870
snprintf((char *)mo_path, sizeof(mo_path), "%s/%s/%s", mo_dir, mw->mo_entry->locale, mw->mo_entry->mo_src);
1871
snprintf(buf, sizeof(buf), "msgfmt -o %s %s", mo_path, po_path);
1872
mw2 = malloc(sizeof(Mo_Write));
1875
memcpy(mw2, mw, sizeof(Mo_Write));
1876
mw2->mo_path = strdup(mo_path);
1877
mw2->exe = ecore_exe_run(buf, mw2);
1878
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
1884
error_and_abort(mw->ef, "Non-existent .po file specified: \"%s\".", po_path);
1891
ecore_thread_run(data_thread_mo, data_thread_mo_end, NULL, mw);
1894
data_thread_mo(mw, NULL);
1895
data_thread_mo_end(mw, NULL);
1904
data_thread_vibrations(void *data, Ecore_Thread *thread EINA_UNUSED)
1906
Vibration_Write *vw = data;
1908
char *dir_path = NULL;
1909
char path[PATH_MAX];
1911
Eina_File *f = NULL;
1915
EINA_LIST_FOREACH(vibration_dirs, ll, dir_path)
1917
snprintf((char *)path, sizeof(path), "%s/%s", dir_path,
1919
f = eina_file_open(path, 0);
1924
snprintf((char *)path, sizeof(path), "%s",
1926
f = eina_file_open(path, 0);
1928
if (f) using_file(path, 'S');
1931
ERR("Unable to load vibration data of: %s", vw->sample->src);
1935
snprintf(id_str, sizeof(id_str), "edje/vibrations/%i", vw->sample->id);
1936
m = eina_file_map_all(f, EINA_FILE_WILLNEED);
1939
bytes = eet_write(vw->ef, id_str, m, eina_file_size_get(f),
1940
EET_COMPRESSION_NONE);
1941
if (eina_file_map_faulted(f, m))
1943
ERR("File access error when reading '%s'",
1944
eina_file_filename_get(f));
1947
eina_file_map_free(f, m);
1951
INF("Wrote %9i bytes (%4iKb) for \"%s\" %s vibration entry \"%s\"",
1952
bytes, (bytes + 512) / 1024,
1953
id_str, "RAW", vw->sample->name);
1957
data_thread_vibrations_end(void *data, Ecore_Thread *thread EINA_UNUSED)
1959
Vibration_Write *sw = data;
1965
data_write_vibrations(Eet_File *ef, int *num)
1967
if ((edje_file) && (edje_file->vibration_dir))
1971
for (i = 0; i < (int)edje_file->vibration_dir->samples_count; i++)
1973
Vibration_Write *vw;
1975
vw = calloc(1, sizeof(Vibration_Write));
1978
vw->sample = &edje_file->vibration_dir->samples[i];
1983
ecore_thread_run(data_thread_vibrations, data_thread_vibrations_end, NULL, vw);
1986
data_thread_vibrations(vw, NULL);
1987
data_thread_vibrations_end(vw, NULL);
1994
check_groups(Eet_File *ef)
1996
Edje_Part_Collection *pc;
1999
/* sanity checks for parts and programs */
2000
EINA_LIST_FOREACH(edje_collections, l, pc)
2004
for (i = 0; i < pc->parts_count; ++i)
2005
check_part(pc, pc->parts[i], ef);
2007
#define CHECK_PROGRAM(Type, Pc, It) \
2008
for (It = 0; It < Pc->programs.Type ## _count; ++It) \
2009
check_program(Pc, Pc->programs.Type[i], ef); \
2011
CHECK_PROGRAM(fnmatch, pc, i);
2012
CHECK_PROGRAM(strcmp, pc, i);
2013
CHECK_PROGRAM(strncmp, pc, i);
2014
CHECK_PROGRAM(strrncmp, pc, i);
2015
CHECK_PROGRAM(nocmp, pc, i);
2020
data_thread_group(void *data, Ecore_Thread *thread EINA_UNUSED)
2022
Group_Write *gw = data;
2025
snprintf(buf, sizeof(buf), "edje/collections/%i", gw->pc->id);
2026
eet_data_write(gw->ef, edd_edje_part_collection, buf, gw->pc,
2032
data_thread_group_end(void *data, Ecore_Thread *thread EINA_UNUSED)
2034
Group_Write *gw = data;
2037
error_and_abort(gw->ef, gw->errstr);
2045
data_write_groups(Eet_File *ef, int *collection_num)
2048
Edje_Part_Collection *pc;
2050
EINA_LIST_FOREACH(edje_collections, l, pc)
2054
gw = calloc(1, sizeof(Group_Write));
2057
error_and_abort(ef, "Cannot allocate memory for group writer");
2064
ecore_thread_run(data_thread_group, data_thread_group_end, NULL, gw);
2067
data_thread_group(gw, NULL);
2068
data_thread_group_end(gw, NULL);
2070
*collection_num += 1;
2075
create_script_file(Eet_File *ef, const char *filename, const Code *cd, int fd)
2077
FILE *f = fdopen(fd, "wb");
2079
error_and_abort(ef, "Unable to open temp file \"%s\" for script "
2080
"compilation.", filename);
2085
fprintf(f, "#include <edje>\n");
2090
while (ln < (cd->l1 - 1))
2100
for (sp = cd->shared; *sp; sp++)
2102
if ((sp[0] == '#') && (newlined))
2107
if (sp[0] == '\n') newlined = 1;
2108
if (!hash) fputc(sp[0], f);
2109
else if (sp[0] == '\n')
2114
ln += cd->l2 - cd->l1 + 1;
2116
EINA_LIST_FOREACH(cd->programs, ll, cp)
2120
while (ln < (cp->l1 - 1))
2125
/* FIXME: this prototype needs to be */
2126
/* formalised and set in stone */
2127
fprintf(f, "public _p%i(sig[], src[]) {", cp->id);
2133
for (sp = cp->script; *sp; sp++)
2135
if ((sp[0] == '#') && (newlined))
2140
if (sp[0] == '\n') newlined = 1;
2141
if (!hash) fputc(sp[0], f);
2142
else if (sp[0] == '\n')
2147
ln += cp->l2 - cp->l1 + 1;
2155
data_thread_script(void *data, Ecore_Thread *thread EINA_UNUSED)
2157
Script_Write *sc = data;
2162
f = fopen(sc->tmpo, "rb");
2165
snprintf(buf, sizeof(buf),
2166
"Unable to open script object \"%s\" for reading.",
2168
sc->errstr = strdup(buf);
2172
if (fseek(f, 0, SEEK_END) < 0)
2173
ERR("Error seeking");
2179
void *dat = malloc(size);
2183
if (fread(dat, size, 1, f) != 1)
2185
snprintf(buf, sizeof(buf),
2186
"Unable to read all of script object \"%s\"",
2188
sc->errstr = strdup(buf);
2193
snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i",
2195
eet_write(sc->ef, buf, dat, size, compress_mode);
2200
snprintf(buf, sizeof(buf),
2201
"Alloc failed for %lu bytes", (unsigned long)size);
2202
sc->errstr = strdup(buf);
2209
WRN("You are removing the source from this Edje file. This may break some use cases.\nBe aware of your choice and the poor kitten you are harming with it!");
2215
if (sc->cd->original)
2217
snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i", sc->i);
2218
eet_write(sc->ef, buf, sc->cd->original,
2219
strlen(sc->cd->original) + 1, compress_mode);
2221
EINA_LIST_FOREACH(sc->cd->programs, ll, cp)
2223
if (!cp->original) continue;
2224
snprintf(buf, PATH_MAX, "edje/scripts/embryo/source/%i/%i",
2226
eet_write(sc->ef, buf, cp->original,
2227
strlen(cp->original) + 1, compress_mode);
2234
eina_tmpstr_del(sc->tmpn);
2235
eina_tmpstr_del(sc->tmpo);
2236
// closed by fclose(f) in create_script_file()
2237
// close(sc->tmpn_fd);
2244
} Pending_Script_Write;
2246
#define PENDING_COMMANDS_MAX 8
2248
static int pending_write_commands = 0;
2249
static Eina_List *pending_script_writes = NULL;
2251
static void data_write_script_queue(Script_Write *sc, const char *exeline);
2254
data_thread_script_end(void *data, Ecore_Thread *thread EINA_UNUSED)
2256
Script_Write *sc = data;
2259
error_and_abort(sc->ef, sc->errstr);
2267
data_scripts_exe_del_cb(void *data EINA_UNUSED, int evtype EINA_UNUSED, void *evinfo)
2269
Script_Write *sc = data;
2270
Ecore_Exe_Event_Del *ev = evinfo;
2272
if (!ev->exe) return ECORE_CALLBACK_RENEW;
2273
if (ecore_exe_data_get(ev->exe) != sc) return ECORE_CALLBACK_RENEW;
2274
pending_write_commands--;
2275
if (pending_write_commands < PENDING_COMMANDS_MAX)
2277
if (pending_script_writes)
2279
Pending_Script_Write *pend = pending_script_writes->data;
2281
pending_script_writes = eina_list_remove_list
2282
(pending_script_writes, pending_script_writes);
2283
data_write_script_queue(pend->sc, pend->exe);
2288
if (ev->exit_code != 0)
2290
error_and_abort(sc->ef, "Compiling script code not clean.");
2291
return ECORE_CALLBACK_CANCEL;
2295
ecore_thread_run(data_thread_script, data_thread_script_end, NULL, sc);
2299
data_thread_script(sc, NULL);
2300
data_thread_script_end(sc, NULL);
2302
if (pending_threads + pending_image_threads <= 0) ecore_main_loop_quit();
2303
return ECORE_CALLBACK_CANCEL;
2307
data_write_script_queue(Script_Write *sc, const char *exeline)
2309
if (pending_write_commands >= PENDING_COMMANDS_MAX)
2311
Pending_Script_Write *pend = malloc(sizeof(Pending_Script_Write));
2315
pend->exe = strdup(exeline);
2318
error_and_abort(sc->ef,
2319
"Unable to allocate mem pending string.");
2323
pending_script_writes = eina_list_append(pending_script_writes,
2327
error_and_abort(sc->ef,
2328
"Unable to allocate mem for pending script.");
2333
sc->exe = ecore_exe_run(exeline, sc);
2334
if (!sc->exe) error_and_abort(sc->ef, "Unable to fork off embryo_cc.");
2335
ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
2336
data_scripts_exe_del_cb, sc);
2337
pending_write_commands++;
2342
data_write_scripts(Eet_File *ef)
2345
char embryo_cc_path[PATH_MAX] = "";
2346
char inc_path[PATH_MAX] = "";
2350
# define BIN_EXT ".exe"
2354
#ifdef NEED_RUN_IN_TREE
2355
if (getenv("EFL_RUN_IN_TREE"))
2357
snprintf(embryo_cc_path, sizeof(embryo_cc_path),
2358
"%s/src/bin/embryo/embryo_cc" BIN_EXT,
2360
snprintf(inc_path, sizeof(inc_path),
2361
"%s/data/edje/include", PACKAGE_SRC_DIR);
2362
if (!ecore_file_exists(embryo_cc_path))
2363
embryo_cc_path[0] = '\0';
2367
if (embryo_cc_path[0] == '\0')
2369
snprintf(embryo_cc_path, sizeof(embryo_cc_path),
2370
"%s/embryo_cc" BIN_EXT,
2371
eina_prefix_bin_get(pfx));
2372
snprintf(inc_path, sizeof(inc_path),
2374
eina_prefix_data_get(pfx));
2378
for (i = 0, l = codes; l; l = eina_list_next(l), i++)
2380
Code *cd = eina_list_data_get(l);
2383
char buf[EINA_PATH_MAX + PATH_MAX + PATH_MAX + 128];
2387
if ((!cd->shared) && (!cd->programs))
2389
sc = calloc(1, sizeof(Script_Write));
2393
sc->tmpn_fd = eina_file_mkstemp("edje_cc.sma-tmp-XXXXXX", &sc->tmpn);
2394
if (sc->tmpn_fd < 0)
2395
error_and_abort(ef, "Unable to open temp file \"%s\" for script "
2396
"compilation.", sc->tmpn);
2397
fd = eina_file_mkstemp("edje_cc.amx-tmp-XXXXXX", &sc->tmpo);
2401
eina_tmpstr_del(sc->tmpn);
2402
error_and_abort(ef, "Unable to open temp file \"%s\" for script "
2403
"compilation.", sc->tmpo);
2405
//do not carry the fd over the time
2406
//we should not unnesseserrily carry filedescriptors over time as this could excede system limits
2407
//which have been fetched earlier
2409
create_script_file(ef, sc->tmpn, cd, sc->tmpn_fd);
2410
snprintf(buf, sizeof(buf),
2411
"%s -i %s -o %s %s", embryo_cc_path, inc_path,
2412
sc->tmpo, sc->tmpn);
2413
data_write_script_queue(sc, buf);
2419
_edje_lua_script_writer(lua_State *L EINA_UNUSED, const void *chunk_buf, size_t chunk_size, void *_data)
2421
Script_Lua_Writer *data;
2424
data = (Script_Lua_Writer *)_data;
2426
data->buf = realloc(data->buf, data->size + chunk_size);
2429
memcpy(&((data->buf)[data->size]), chunk_buf, chunk_size);
2430
data->size += chunk_size;
2434
ERR("Failed to copy chunk buffer.\n");
2444
_edje_lua_error_and_abort(lua_State *L, int err_code, Script_Write *sc)
2452
err_type = "runtime";
2456
err_type = "syntax";
2460
err_type = "memory allocation";
2464
err_type = "error handler";
2468
err_type = "unknown";
2471
snprintf(buf, sizeof(buf),
2472
"Lua %s error: %s", err_type, lua_tostring(L, -1));
2473
sc->errstr = strdup(buf);
2477
data_thread_lua_script(void *data, Ecore_Thread *thread EINA_UNUSED)
2479
Script_Write *sc = data;
2484
Script_Lua_Writer dat;
2491
L = luaL_newstate();
2494
snprintf(buf, sizeof(buf),
2495
"Lua error: Lua state could not be initialized");
2496
sc->errstr = strdup(buf);
2500
luaL_buffinit(L, &b);
2506
while (ln < (sc->cd->l1 - 1))
2508
luaL_addchar(&b, '\n');
2511
luaL_addstring(&b, sc->cd->shared);
2512
ln += sc->cd->l2 - sc->cd->l1;
2515
EINA_LIST_FOREACH(sc->cd->programs, ll, cp)
2519
while (ln < (cp->l1 - 1))
2521
luaL_addchar(&b, '\n');
2524
luaL_addstring(&b, "_G[");
2525
lua_pushnumber(L, cp->id);
2527
luaL_addstring(&b, "] = function (ed, signal, source)");
2528
luaL_addstring(&b, cp->script);
2529
luaL_addstring(&b, "end\n");
2530
ln += cp->l2 - cp->l1 + 1;
2533
luaL_pushresult(&b);
2535
if (err_code = luaL_loadstring(L, lua_tostring(L, -1)))
2537
_edje_lua_error_and_abort(L, err_code, sc);
2540
lua_dump(L, _edje_lua_script_writer, &dat);
2541
#else // LUA_PLAIN_TEXT
2542
dat.buf = (char *)lua_tostring(L, -1);
2543
dat.size = strlen(dat.buf);
2545
//printf("lua chunk size: %d\n", dat.size);
2548
* TODO load and test Lua chunk
2552
if (luaL_loadbuffer(L, globbuf, globbufsize, "edje_lua_script"))
2553
printf("lua load error: %s\n", lua_tostring (L, -1));
2554
if (lua_pcall(L, 0, 0, 0))
2555
printf("lua call error: %s\n", lua_tostring (L, -1));
2558
snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", sc->i);
2559
if (eet_write(sc->ef, buf, dat.buf, dat.size, compress_mode) <= 0)
2561
snprintf(buf, sizeof(buf),
2562
"Unable to write script %i", sc->i);
2563
sc->errstr = strdup(buf);
2573
data_thread_lua_script_end(void *data, Ecore_Thread *thread EINA_UNUSED)
2575
Script_Write *sc = data;
2578
error_and_abort(sc->ef, sc->errstr);
2586
data_write_lua_scripts(Eet_File *ef)
2591
for (i = 0, l = codes; l; l = eina_list_next(l), i++)
2596
cd = (Code *)eina_list_data_get(l);
2599
if ((!cd->shared) && (!cd->programs))
2602
sc = calloc(1, sizeof(Script_Write));
2608
ecore_thread_run(data_thread_lua_script, data_thread_lua_script_end, NULL, sc);
2611
data_thread_lua_script(sc, NULL);
2612
data_thread_lua_script_end(sc, NULL);
2618
data_thread_source(void *data, Ecore_Thread *thread EINA_UNUSED)
2620
Eet_File *ef = data;
2625
data_thread_source_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
2631
data_thread_license(void *data, Ecore_Thread *thread EINA_UNUSED)
2633
License_Write *lw = data;
2634
Eet_File *ef = lw->ef;
2639
f = eina_file_open(lw->file, 0);
2642
m = eina_file_map_all(f, EINA_FILE_WILLNEED);
2643
if (!m) goto on_error;
2647
bytes = eet_write(ef, "edje/license", m, eina_file_size_get(f), compress_mode);
2651
char *s = alloca(strlen(lw->file) + 1 + 13);
2653
strcpy(s, lw->file);
2654
sprintf(s, "edje/license/%s", basename(s));
2656
bytes = eet_write(ef, s, m, eina_file_size_get(f), compress_mode);
2659
if ((bytes <= 0) || eina_file_map_faulted(f, m))
2661
ERR("Unable to write license part \"%s\".", lw->file);
2665
double fsize = eina_file_size_get(f);
2667
if (fsize <= 0.0) fsize = 1.0;
2668
INF("Wrote %9i bytes (%4iKb) for \"%s\" license entry compress: [real: %2.1f%%]",
2669
bytes, (bytes + 512) / 1024, license,
2670
100.0 - ((100.0 * (double)bytes) / fsize));
2673
eina_file_map_free(f, m);
2680
data_thread_license_end(void *data, Ecore_Thread *thread EINA_UNUSED)
2687
data_write_license(Eet_File *ef)
2693
if (!license) return;
2695
lw = calloc(1, sizeof (License_Write));
2700
lw->master = EINA_TRUE;
2704
ecore_thread_run(data_thread_license, data_thread_license_end, NULL, lw);
2707
data_thread_license(lw, NULL);
2708
data_thread_license_end(lw, NULL);
2711
EINA_LIST_FOREACH(licenses, l, file)
2713
lw = calloc(1, sizeof (License_Write));
2718
lw->master = EINA_FALSE;
2722
ecore_thread_run(data_thread_license, data_thread_license_end, NULL, lw);
2725
data_thread_license(lw, NULL);
2726
data_thread_license_end(lw, NULL);
2732
data_thread_authors(void *data, Ecore_Thread *thread EINA_UNUSED)
2734
Eet_File *ef = data;
2739
f = eina_file_open(authors, 0);
2742
m = eina_file_map_all(f, EINA_FILE_WILLNEED);
2743
if (!m) goto on_error;
2745
bytes = eet_write(ef, "edje/authors", m, eina_file_size_get(f), compress_mode);
2746
if ((bytes <= 0) || eina_file_map_faulted(f, m))
2748
ERR("Unable to write authors part \"%s\".", authors);
2752
double fsize = eina_file_size_get(f);
2754
if (fsize <= 0.0) fsize = 1.0;
2755
INF("Wrote %9i bytes (%4iKb) for \"%s\" authors entry compress: [real: %2.1f%%]",
2756
bytes, (bytes + 512) / 1024, license,
2757
100.0 - ((100.0 * (double)bytes) / fsize));
2760
eina_file_map_free(f, m);
2767
data_thread_authors_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
2773
data_thread_fontmap(void *data, Ecore_Thread *thread EINA_UNUSED)
2775
Eet_File *ef = data;
2776
source_fontmap_save(ef, fonts);
2780
data_thread_fontmap_end(void *data EINA_UNUSED, Ecore_Thread *thread EINA_UNUSED)
2786
data_write_color_class_register_each_cb(const Eina_Hash *hash EINA_UNUSED,
2788
void *data EINA_UNUSED,
2791
Edje_Color_Class_Info *cc_info = fdata;
2792
cc_info->colors = eina_list_append(cc_info->colors,
2793
eina_stringshare_add(key));
2798
data_write_color_class_register(Eet_File *ef)
2800
Edje_Color_Class_Info *cc_info;
2803
if (!color_class_reg) return;
2804
cc_info = calloc(1, sizeof(Edje_Color_Class_Info));
2807
ERR("Out of Memory");
2810
eina_hash_foreach(color_class_reg,
2811
data_write_color_class_register_each_cb,
2814
eet_data_write(ef, _edje_edd_edje_color_class_info,
2815
"edje/color_class_info", cc_info, compress_mode);
2817
eina_hash_free(color_class_reg);
2818
color_class_reg = NULL;
2819
EINA_LIST_FREE(cc_info->colors, s) eina_stringshare_del(s);
2830
int vibration_num = 0;
2832
int collection_num = 0;
2838
ERR("No data to put in \"%s\"", file_out);
2842
cur_ef = ef = eet_open(file_out, EET_FILE_MODE_WRITE);
2845
ERR("Unable to open \"%s\" for writing output", file_out);
2849
if ((edje_file->efl_version.major <= 1) && (edje_file->efl_version.minor <= 18)
2850
&& edje_file->has_textblock_min_max)
2852
WRN("This EDC file was designed for EFL 1.18. Until 1.19, EFL used an "
2853
"invalid calculation mechanism for textblock parts, where the value "
2854
"of text min/max was not properly taken into account. You might "
2855
"want to consider adding \"efl_version: %d %d;\" in your EDC "
2856
"file (before the \"collections\" block), and then check the sizing "
2857
"for all textblock parts that specify text min/max values (the bool "
2858
"defined as description.text.{min,max}).",
2859
EFL_VERSION_MAJOR, EFL_VERSION_MINOR);
2862
if (eina_array_count(requires))
2866
edje_file->requires_count = eina_array_count(requires);
2867
edje_file->requires = mem_alloc(edje_file->requires_count * sizeof(void*));
2870
edje_file->requires[i] = eina_array_pop(requires);
2872
} while (eina_array_count(requires));
2873
eina_array_free(requires);
2878
ecore_thread_max_set(ecore_thread_max_get() * 2);
2881
t = ecore_time_get();
2883
INF("header: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2884
data_write_groups(ef, &collection_num);
2885
INF("groups: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2886
data_write_scripts(ef);
2887
INF("scripts: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2888
data_write_lua_scripts(ef);
2889
INF("lua scripts: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2895
ecore_thread_run(data_thread_source, data_thread_source_end, NULL, ef);
2898
data_thread_source(ef, NULL);
2899
data_thread_source_end(ef, NULL);
2902
INF("source: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2905
ecore_thread_run(data_thread_fontmap, data_thread_fontmap_end, NULL, ef);
2908
data_thread_fontmap(ef, NULL);
2909
data_thread_fontmap_end(ef, NULL);
2911
INF("fontmap: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2912
data_write_vectors(ef, &vector_num);
2913
INF("vectors: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2914
data_write_fonts(ef, &font_num);
2915
INF("fonts: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2916
data_write_sounds(ef, &sound_num);
2917
INF("sounds: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2918
data_write_mo(ef, &mo_num);
2919
INF("mo: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2920
data_write_vibrations(ef, &vibration_num);
2921
INF("vibrations: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2922
data_write_license(ef);
2923
INF("license: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2928
ecore_thread_run(data_thread_authors, data_thread_authors_end, NULL, ef);
2931
data_thread_authors(ef, NULL);
2932
data_thread_authors_end(ef, NULL);
2935
data_write_color_class_register(ef);
2936
data_write_images();
2937
data_image_sets_init();
2938
INF("images: %3.5f", ecore_time_get() - t); t = ecore_time_get();
2940
if (pending_threads + pending_image_threads > 0) ecore_main_loop_begin();
2941
INF("THREADS: %3.5f", ecore_time_get() - t);
2942
data_write_header(ef);
2943
if (pending_threads + pending_image_threads > 0) ecore_main_loop_begin();
2944
INF("THREADS: %3.5f", ecore_time_get() - t);
2948
/* probably caught signal, exit immediately to avoid crash */
2949
if (pending_threads + pending_image_threads > 0) exit(-1);
2952
err = eet_close(ef);
2955
ERR("Couldn't write file: \"%s\"", file_out);
2959
if (eina_log_domain_level_check(_edje_cc_log_dom, EINA_LOG_LEVEL_INFO))
2962
" Wrote %i collections\n"
2963
" Wrote %i images\n"
2964
" Wrote %i sounds\n"
2977
Edje_Part_Collection *pc;
2979
Edje_Part_Parser *ep, *ep2;
2982
/* sanity checks for parts and programs */
2983
EINA_LIST_FOREACH(edje_collections, l, pc)
2985
unsigned int i, j, k;
2986
Eina_Bool found = EINA_FALSE;
2988
for (i = 0; i < pc->parts_count; i++)
2990
ep = (Edje_Part_Parser *)pc->parts[i];
2991
if (ep->reorder.insert_before && ep->reorder.insert_after)
2992
error_and_abort(NULL, "In group \"%s\": Unable to use together insert_before and insert_after in part \"%s\".",
2993
pc->part, pc->parts[i]->name);
2995
if (ep->reorder.done)
2999
if (ep->reorder.insert_before || ep->reorder.insert_after)
3002
for (j = 0; j < pc->parts_count; j++)
3004
if (ep->reorder.insert_before &&
3005
!strcmp(ep->reorder.insert_before, pc->parts[j]->name))
3007
ep2 = (Edje_Part_Parser *)pc->parts[j];
3008
if (ep2->reorder.after)
3009
error_and_abort(NULL, "In group \"%s\": The part \"%s\" is ambiguous ordered part.",
3010
pc->part, pc->parts[i]->name);
3011
if (ep2->reorder.linked_prev)
3012
error_and_abort(NULL, "In group \"%s\": Unable to insert two or more parts in same part \"%s\".",
3013
pc->part, pc->parts[j]->name);
3014
/* Need it to be able to insert an element before the first */
3018
ep2->reorder.linked_prev += ep->reorder.linked_prev + 1;
3019
ep->reorder.before = (Edje_Part_Parser *)pc->parts[j];
3020
while (ep2->reorder.before)
3022
ep2->reorder.before->reorder.linked_prev = ep2->reorder.linked_prev + 1;
3023
ep2 = ep2->reorder.before;
3027
else if (ep->reorder.insert_after &&
3028
!strcmp(ep->reorder.insert_after, pc->parts[j]->name))
3030
ep2 = (Edje_Part_Parser *)pc->parts[j];
3031
if (ep2->reorder.before)
3032
error_and_abort(NULL, "In group \"%s\": The part \"%s\" is ambiguous ordered part.",
3033
pc->part, pc->parts[i]->name);
3034
if (ep2->reorder.linked_next)
3035
error_and_abort(NULL, "In group \"%s\": Unable to insert two or more parts in same part \"%s\".",
3036
pc->part, pc->parts[j]->name);
3039
ep2->reorder.linked_next += ep->reorder.linked_next + 1;
3040
ep->reorder.after = (Edje_Part_Parser *)pc->parts[j];
3041
while (ep2->reorder.after)
3043
ep2->reorder.after->reorder.linked_next = ep2->reorder.linked_next + 1;
3044
ep2 = ep2->reorder.after;
3051
unsigned int amount, linked;
3053
if (((i > k) && ((i - ep->reorder.linked_prev) <= k))
3054
|| ((i < k) && ((i + ep->reorder.linked_next) >= k)))
3055
error_and_abort(NULL, "In group \"%s\": The part order is wrong. It has circular dependency.", pc->part);
3057
amount = ep->reorder.linked_prev + ep->reorder.linked_next + 1;
3058
linked = i - ep->reorder.linked_prev;
3059
parts = malloc(amount * sizeof(Edje_Part *));
3060
for (j = 0; j < amount; j++)
3062
parts[j] = pc->parts[linked];
3067
for (j = i - ep->reorder.linked_prev; j > k; j--)
3069
pc->parts[j + amount - 1] = pc->parts[j - 1];
3070
pc->parts[j + amount - 1]->id = j + amount - 1;
3072
for (j = 0; j < amount; j++)
3074
pc->parts[j + k] = parts[j];
3075
pc->parts[j + k]->id = j + k;
3080
for (j = i + ep->reorder.linked_next + 1; j <= k; j++)
3082
pc->parts[j - amount] = pc->parts[j];
3083
pc->parts[j - amount]->id = j - amount;
3085
for (j = 0; j < amount; j++)
3087
pc->parts[j + k - amount + 1] = parts[j];
3088
pc->parts[j + k - amount + 1]->id = j + k - amount + 1;
3092
ep->reorder.done = EINA_TRUE;
3097
if (ep->reorder.insert_before)
3098
error_and_abort(NULL, "In group \"%s\": Unable to find part \"%s\" for insert_before in part \"%s\".",
3099
pc->part, ep->reorder.insert_before, pc->parts[i]->name);
3101
error_and_abort(NULL, "In group \"%s\": Unable to find part \"%s\" for insert_after in part \"%s\".",
3102
pc->part, ep->reorder.insert_after, pc->parts[i]->name);
3110
data_queue_group_lookup(const char *name, Edje_Part *part)
3114
if (!name || !name[0]) return;
3116
gl = mem_alloc(SZ(Group_Lookup));
3117
group_lookups = eina_list_append(group_lookups, gl);
3118
gl->name = mem_strdup(name);
3123
data_queue_face_group_lookup(const char *name)
3127
if (!name || !name[0]) return;
3129
group_name = mem_strdup(name);
3130
face_group_lookups = eina_list_append(face_group_lookups, group_name);
3134
data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest)
3136
data_queue_part_nest_lookup(pc, name, dest, NULL);
3140
data_queue_part_nest_lookup(Edje_Part_Collection *pc, const char *name, int *dest, char **dest2)
3142
Part_Lookup_Key key;
3143
Part_Lookup *pl = NULL;
3146
key.mem.dest = dest;
3147
key.stable = EINA_TRUE;
3149
pl = eina_hash_find(part_pc_dest_lookup, &key);
3155
pl->name = mem_strdup(name);
3159
list = eina_hash_find(part_dest_lookup, &pl->key);
3160
list = eina_list_remove(list, pl);
3161
eina_hash_set(part_dest_lookup, &pl->key, list);
3162
eina_hash_del(part_pc_dest_lookup, &key, pl);
3167
if (!name[0]) return;
3169
pl = mem_alloc(SZ(Part_Lookup));
3170
pl->name = mem_strdup(name);
3172
pl->key.mem.dest = dest;
3173
pl->key.dest2 = dest2;
3174
pl->key.stable = EINA_TRUE;
3176
eina_hash_add(part_pc_dest_lookup, &key, pl);
3178
list = eina_hash_find(part_dest_lookup, &pl->key);
3179
list = eina_list_prepend(list, pl);
3180
eina_hash_set(part_dest_lookup, &pl->key, list);
3184
data_queue_part_reallocated_lookup(Edje_Part_Collection *pc, const char *name,
3185
unsigned char **base, int offset)
3187
Part_Lookup_Key key;
3188
Part_Lookup *pl = NULL;
3191
key.mem.reallocated.base = base;
3192
key.mem.reallocated.offset = offset;
3193
key.stable = EINA_FALSE;
3195
pl = eina_hash_find(part_pc_dest_lookup, &key);
3201
pl->name = mem_strdup(name);
3205
list = eina_hash_find(part_dest_lookup, &pl->key);
3206
list = eina_list_remove(list, pl);
3207
eina_hash_set(part_dest_lookup, &pl->key, list);
3208
eina_hash_del(part_pc_dest_lookup, &key, pl);
3213
if (!name[0]) return;
3215
pl = mem_alloc(SZ(Part_Lookup));
3216
pl->name = mem_strdup(name);
3218
pl->key.mem.reallocated.base = base;
3219
pl->key.mem.reallocated.offset = offset;
3220
pl->key.stable = EINA_FALSE;
3222
eina_hash_add(part_pc_dest_lookup, &key, pl);
3224
list = eina_hash_find(part_dest_lookup, &pl->key);
3225
list = eina_list_prepend(list, pl);
3226
eina_hash_set(part_dest_lookup, &pl->key, list);
3230
part_lookup_del(Edje_Part_Collection *pc, int *dest)
3232
Part_Lookup_Key key;
3233
Part_Lookup *pl = NULL;
3236
key.mem.dest = dest;
3237
key.stable = EINA_TRUE;
3239
pl = eina_hash_find(part_pc_dest_lookup, &key);
3241
list = eina_hash_find(part_dest_lookup, &pl->key);
3243
eina_hash_del(part_dest_lookup, &pl->key, list);
3244
eina_hash_del(part_pc_dest_lookup, &key, pl);
3248
part_lookup_delete(Edje_Part_Collection *pc, const char *name, int *dest, char **dest2)
3250
Part_Lookup_Key key;
3251
Part_Lookup *pl = NULL;
3253
Eina_List *list, *l, *ll;
3255
key.mem.dest = dest;
3256
key.stable = EINA_TRUE;
3258
pl = eina_hash_find(part_pc_dest_lookup, &key);
3260
list = eina_hash_find(part_dest_lookup, &pl->key);
3261
EINA_LIST_FOREACH_SAFE(list, l, ll, lpl)
3263
if (strcmp(lpl->name, name) || (lpl->key.dest2 != dest2)) continue;
3265
list = eina_list_remove_list(list, l);
3268
eina_hash_set(part_dest_lookup, &pl->key, list);
3272
data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest)
3274
data_queue_copied_part_nest_lookup(pc, src, dest, NULL);
3278
data_queue_copied_part_nest_lookup(Edje_Part_Collection *pc, int *src, int *dest, char **dest2)
3283
Part_Lookup_Key key;
3287
key.stable = EINA_TRUE;
3289
list = eina_hash_find(part_dest_lookup, &key);
3290
EINA_LIST_FOREACH(list, l, pl)
3292
data_queue_part_nest_lookup(pc, pl->name, dest, dest2);
3296
data_queue_anonymous_lookup(Edje_Part_Collection *pc, Edje_Program *ep, int *dest)
3298
Eina_List *l, *l1, *l2, *l3;
3301
if (!ep) return; /* FIXME: should we stop compiling ? */
3303
EINA_LIST_FOREACH_SAFE(program_lookups, l, l1, pl)
3310
cd = eina_list_data_get(eina_list_last(codes));
3312
EINA_LIST_FOREACH_SAFE(cd->programs, l2, l3, cp)
3314
if (&(cp->id) == pl->dest)
3316
cd->programs = eina_list_remove_list(cd->programs, l2);
3321
program_lookups = eina_list_remove_list(program_lookups, l);
3328
pl = mem_alloc(SZ(Program_Lookup));
3329
program_lookups = eina_list_append(program_lookups, pl);
3333
pl->anonymous = EINA_TRUE;
3338
copied_program_anonymous_lookup_delete(Edje_Part_Collection *pc, int *dest)
3343
EINA_LIST_FOREACH_SAFE(program_lookups, l, ll, pl)
3345
if ((!pl->anonymous) || (pl->pc != pc) || (dest != &pl->u.ep->id)) continue;
3346
program_lookups = eina_list_remove_list(program_lookups, l);
3350
Edje_Part_Collection_Directory_Entry *de;
3351
Eina_List *l2, *ll2;
3353
de = eina_hash_find(edje_file->collection, pl->pc->part);
3354
cd = eina_list_nth(codes, de->id);
3356
EINA_LIST_FOREACH_SAFE(cd->programs, l2, ll2, cp)
3358
if (pl->dest == &cp->id)
3360
cd->programs = eina_list_remove_list(cd->programs, l2);
3371
data_queue_copied_anonymous_lookup(Edje_Part_Collection *pc, int *src, int *dest)
3377
EINA_LIST_FOREACH(program_lookups, l, pl)
3379
if (pl->dest == src && pl->u.ep->name)
3381
for (i = 0; i < pc->programs.fnmatch_count; i++)
3383
if (pc->programs.fnmatch[i]->name &&
3384
!strcmp(pl->u.ep->name, pc->programs.fnmatch[i]->name))
3385
data_queue_anonymous_lookup(pc, pc->programs.fnmatch[i], dest);
3387
for (i = 0; i < pc->programs.strcmp_count; i++)
3389
if (pc->programs.strcmp[i]->name &&
3390
!strcmp(pl->u.ep->name, pc->programs.strcmp[i]->name))
3391
data_queue_anonymous_lookup(pc, pc->programs.strcmp[i], dest);
3393
for (i = 0; i < pc->programs.strncmp_count; i++)
3395
if (pc->programs.strncmp[i]->name &&
3396
!strcmp(pl->u.ep->name, pc->programs.strncmp[i]->name))
3397
data_queue_anonymous_lookup(pc, pc->programs.strncmp[i], dest);
3399
for (i = 0; i < pc->programs.strrncmp_count; i++)
3401
if (pc->programs.strrncmp[i]->name &&
3402
!strcmp(pl->u.ep->name, pc->programs.strrncmp[i]->name))
3403
data_queue_anonymous_lookup(pc, pc->programs.strrncmp[i], dest);
3405
for (i = 0; i < pc->programs.nocmp_count; i++)
3407
if (pc->programs.nocmp[i]->name &&
3408
!strcmp(pl->u.ep->name, pc->programs.nocmp[i]->name))
3409
data_queue_anonymous_lookup(pc, pc->programs.nocmp[i], dest);
3416
data_queue_program_lookup(Edje_Part_Collection *pc, const char *name, int *dest)
3419
Edje_Part_Collection_Parser *pcp = (Edje_Part_Collection_Parser *)pc;
3421
if (pcp->inherit_only && (!current_group_inherit)) return NULL;
3423
if (!name) return NULL; /* FIXME: should we stop compiling ? */
3425
pl = mem_alloc(SZ(Program_Lookup));
3426
program_lookups = eina_list_append(program_lookups, pl);
3428
pl->u.name = mem_strdup(name);
3430
pl->anonymous = EINA_FALSE;
3435
program_lookup_rename(void *p, const char *name)
3437
Program_Lookup *pl = p;
3440
pl->u.name = strdup(name);
3444
copied_program_lookup_delete(Edje_Part_Collection *pc, const char *name)
3449
EINA_LIST_FOREACH_SAFE(program_lookups, l, ll, pl)
3451
if (pl->anonymous || (pl->pc != pc) || strcmp(pl->u.name, name)) continue;
3453
program_lookups = eina_list_remove_list(program_lookups, l);
3459
data_queue_copied_program_lookup(Edje_Part_Collection *pc, int *src, int *dest)
3464
EINA_LIST_FOREACH(program_lookups, l, pl)
3466
if (pl->dest == src)
3468
data_queue_program_lookup(pc, pl->u.name, dest);
3476
data_queue_image_lookup(char *name, int *dest, Eina_Bool *set)
3480
il = mem_alloc(SZ(Image_Lookup));
3481
image_lookups = eina_list_append(image_lookups, il);
3482
il->name = mem_strdup(name);
3488
data_queue_image_remove(int *dest, Eina_Bool *set)
3493
EINA_LIST_FOREACH(image_lookups, l, il)
3495
if (il->dest == dest && il->set == set)
3497
image_lookups = eina_list_remove_list(image_lookups, l);
3506
data_queue_copied_image_lookup(int *src, int *dest, Eina_Bool *set)
3511
EINA_LIST_FOREACH(image_lookups, l, il)
3513
if (il->dest == src)
3514
data_queue_image_lookup(il->name, dest, set);
3519
data_process_part_set(Part_Lookup *target, int value)
3521
if (target->key.stable)
3523
*(target->key.mem.dest) = value;
3524
if (target->key.dest2) return EINA_TRUE;
3528
*((int *)(*target->key.mem.reallocated.base +
3529
target->key.mem.reallocated.offset)) = value;
3535
_data_image_w_size_compare_cb(const void *data1, const void *data2)
3537
const Edje_Image_Directory_Set_Entry *img1 = data1;
3538
const Edje_Image_Directory_Set_Entry *img2 = data2;
3540
if (img1->size.w < img2->size.w) return -1;
3541
if (img1->size.w > img2->size.w) return 1;
3547
_data_image_h_size_compare_cb(const void *data1, const void *data2)
3549
const Edje_Image_Directory_Set_Entry *img1 = data1;
3550
const Edje_Image_Directory_Set_Entry *img2 = data2;
3552
if (img1->size.h < img2->size.h) return -1;
3553
if (img1->size.h > img2->size.h) return 1;
3559
_data_image_sets_size_set(void)
3562
Edje_Image_Directory_Set *set;
3563
Edje_Image_Directory_Set_Entry *simg, *preimg;
3564
Eina_List *l, *entries;
3568
buffer_ee = ecore_evas_buffer_new(1, 1);
3571
ERR("Cannot create buffer engine canvas for image load.");
3574
evas = ecore_evas_get(buffer_ee);
3576
for (i = 0; i < edje_file->image_dir->sets_count; i++)
3578
set = edje_file->image_dir->sets + i;
3580
if (!set->entries) continue;
3581
EINA_LIST_FOREACH(set->entries, l, simg)
3587
im = evas_object_image_add(evas);
3588
EINA_LIST_FOREACH(img_dirs, ll, s)
3591
int load_err = EVAS_LOAD_ERROR_NONE;
3593
snprintf(buf, sizeof(buf), "%s/%s", s, simg->name);
3594
evas_object_image_file_set(im, buf, NULL);
3595
load_err = evas_object_image_load_error_get(im);
3596
if (load_err == EVAS_LOAD_ERROR_NONE)
3598
evas_object_image_size_get(im, &simg->size.w, &simg->size.h);
3602
evas_object_del(im);
3605
entries = eina_list_clone(set->entries);
3607
entries = eina_list_sort(entries, 0, _data_image_w_size_compare_cb);
3608
preimg = eina_list_data_get(entries);
3609
EINA_LIST_FOREACH(entries, l, simg)
3611
if (simg == preimg) continue;
3612
if (!(preimg->size.max.w) && !(simg->size.min.w))
3614
preimg->size.max.w = (preimg->size.w + simg->size.w) / 2;
3615
simg->size.min.w = preimg->size.max.w + 1;
3616
if (simg->size.min.w <= (simg->border.l + simg->border.r))
3618
preimg->size.max.w = simg->border.l + simg->border.r;
3619
simg->size.min.w = preimg->size.max.w + 1;
3622
else if (preimg->size.max.w && !(simg->size.min.w))
3623
simg->size.min.w = preimg->size.max.w + 1;
3624
else if (!(preimg->size.max.w) && simg->size.min.w)
3625
preimg->size.max.w = simg->size.min.w - 1;
3628
simg = eina_list_data_get(eina_list_last(entries));
3629
if (!(simg->size.max.w)) simg->size.max.w = 99999;
3631
entries = eina_list_sort(entries, 0, _data_image_h_size_compare_cb);
3632
preimg = eina_list_data_get(entries);
3633
EINA_LIST_FOREACH(entries, l, simg)
3635
if (simg == preimg) continue;
3636
if (!(preimg->size.max.h) && !(simg->size.min.h))
3638
preimg->size.max.h = (preimg->size.h + simg->size.h) / 2;
3639
simg->size.min.h = preimg->size.max.h + 1;
3640
if (simg->size.min.h <= (simg->border.t + simg->border.b))
3642
preimg->size.max.h = simg->border.t + simg->border.b;
3643
simg->size.min.h = preimg->size.max.h + 1;
3646
else if (preimg->size.max.h && !(simg->size.min.h))
3647
simg->size.min.h = preimg->size.max.h + 1;
3648
else if (!(preimg->size.max.h) && simg->size.min.h)
3649
preimg->size.max.h = simg->size.min.h - 1;
3652
simg = eina_list_data_get(eina_list_last(entries));
3653
if (!(simg->size.max.h)) simg->size.max.h = 99999;
3655
eina_list_free(entries);
3661
_data_image_id_update(Eina_List *images_unused_list)
3663
Image_Unused_Ids *iui;
3664
Edje_Part_Collection *pc;
3666
Edje_Part_Description_Image *part_desc_image;
3667
Edje_Part_Image_Id *tween_id;
3668
unsigned int i, j, desc_it;
3669
Eina_List *l, *l2, *l3;
3671
#define PART_DESC_IMAGE_ID_UPDATE \
3672
EINA_LIST_FOREACH(images_unused_list, l3, iui) \
3674
if ((iui) && (part_desc_image->image.id == iui->old_id)) \
3676
part_desc_image->image.id = iui->new_id; \
3680
for (desc_it = 0; desc_it < part_desc_image->image.tweens_count; desc_it++) \
3682
tween_id = part_desc_image->image.tweens[desc_it]; \
3683
EINA_LIST_FOREACH(images_unused_list, l3, iui) \
3685
if ((iui) && (tween_id->id == iui->old_id)) \
3687
tween_id->id = iui->new_id; \
3693
EINA_LIST_FOREACH_SAFE(edje_collections, l, l2, pc)
3695
for (i = 0; i < pc->parts_count; i++)
3697
part = pc->parts[i];
3698
if (part->type == EDJE_PART_TYPE_IMAGE)
3700
part_desc_image = (Edje_Part_Description_Image *)part->default_desc;
3701
if (!part_desc_image) continue;
3702
PART_DESC_IMAGE_ID_UPDATE
3703
for (j = 0; j < part->other.desc_count; j++)
3705
part_desc_image = (Edje_Part_Description_Image *)part->other.desc[j];
3706
PART_DESC_IMAGE_ID_UPDATE
3711
for (i = 0; i < edje_file->image_dir->sets_count; i++)
3713
Eina_List *entries, *list;
3714
Edje_Image_Directory_Set_Entry *entry;
3716
entries = edje_file->image_dir->sets[i].entries;
3717
EINA_LIST_FOREACH(entries, list, entry)
3719
EINA_LIST_FOREACH(images_unused_list, l3, iui)
3721
if ((iui) && (entry->id == iui->old_id))
3723
entry->id = iui->new_id;
3733
data_process_lookups(void)
3735
Edje_Part_Collection *pc;
3738
Program_Lookup *program;
3739
Group_Lookup *group;
3740
Image_Lookup *image;
3743
Eina_Hash *images_in_use;
3745
Eina_Bool is_lua = EINA_FALSE;
3746
// Image_Unused_Ids *iui;
3748
/* remove all unreferenced Edje_Part_Collection */
3749
EINA_LIST_FOREACH_SAFE(edje_collections, l, l2, pc)
3751
Edje_Part_Collection_Directory_Entry *alias;
3752
Edje_Part_Collection_Directory_Entry *find;
3754
unsigned int id = 0;
3759
ERR("A collection without a name was detected, that's not allowed.");
3763
find = eina_hash_find(edje_file->collection, pc->part);
3764
if (find && find->id == pc->id)
3766
if (((Edje_Part_Collection_Parser *)pc)->inherit_only)
3767
eina_hash_del_by_data(edje_file->collection, find);
3772
EINA_LIST_FOREACH(aliases, l3, alias)
3773
if (alias->id == pc->id)
3776
/* This Edje_Part_Collection is not used at all */
3777
edje_collections = eina_list_remove_list(edje_collections, l);
3778
l3 = eina_list_nth_list(codes, pc->id);
3779
codes = eina_list_remove_list(codes, l3);
3781
/* Unref all image used by that group */
3782
for (i = 0; i < pc->parts_count; ++i)
3783
part_description_image_cleanup(pc->parts[i]);
3785
/* Correct all id */
3786
EINA_LIST_FOREACH(edje_collections, l3, pc)
3789
Edje_Part_Collection_Directory_Entry *de;
3791
/* Some group could be removed from the collection, but still be referenced by alias */
3792
/* Update all matching alias */
3793
EINA_LIST_FOREACH(aliases, l4, alias)
3794
if (pc->id == alias->id)
3797
find = eina_hash_find(edje_file->collection, pc->part);
3798
if (pc->id != find->id) find = NULL;
3800
de = eina_hash_find(edje_collections_lookup, &pc->id);
3801
eina_hash_set(edje_collections_lookup, &pc->id, NULL);
3802
de->id = pc->id = id++;
3803
eina_hash_set(edje_collections_lookup, &pc->id, de);
3804
if (find) find->id = pc->id;
3808
EINA_LIST_FOREACH(edje_collections, l, pc)
3810
unsigned int count = 0;
3813
if (pc->lua_script_only)
3815
#define PROGRAM_ID_SET(Type, Pc, It, Count) \
3816
for (It = 0; It < Pc->programs.Type ## _count; ++It) \
3818
Pc->programs.Type[It]->id = Count++; \
3821
PROGRAM_ID_SET(fnmatch, pc, i, count);
3822
PROGRAM_ID_SET(strcmp, pc, i, count);
3823
PROGRAM_ID_SET(strncmp, pc, i, count);
3824
PROGRAM_ID_SET(strrncmp, pc, i, count);
3825
PROGRAM_ID_SET(nocmp, pc, i, count);
3827
#undef PROGRAM_ID_SET
3830
it = eina_hash_iterator_data_new(part_pc_dest_lookup);
3831
EINA_ITERATOR_FOREACH(it, part)
3836
if (!strcmp(part->name, "-"))
3838
data_process_part_set(part, -1);
3844
alias = eina_hash_find(part->key.pc->alias, part->name);
3847
ap = strchr(alias, EDJE_PART_PATH_SEPARATOR);
3852
tmp = alloca(strlen(alias) + 1);
3853
memcpy(tmp, alias, ap - alias);
3854
tmp[ap - alias] = 0;
3858
for (i = 0; i < part->key.pc->parts_count; ++i)
3860
ep = part->key.pc->parts[i];
3862
if ((ep->name) && (!strcmp(ep->name, alias)))
3864
if (data_process_part_set(part, ep->id))
3865
*part->key.dest2 = ap;
3870
if ((i == part->key.pc->parts_count) && (!((Edje_Part_Collection_Parser *)part->key.pc)->inherit_only))
3872
ERR("Unable to find part name \"%s\" needed in group '%s'.",
3873
alias, part->key.pc->part);
3878
eina_iterator_free(it);
3879
eina_hash_free(part_dest_lookup);
3880
eina_hash_free(part_pc_dest_lookup);
3882
EINA_LIST_FREE(program_lookups, program)
3885
Eina_Bool find = EINA_FALSE;
3887
#define PROGRAM_MATCH(Type, Pl, It) \
3888
for (It = 0; It < Pl->pc->programs.Type ## _count; ++It) \
3892
ep = Pl->pc->programs.Type[It]; \
3894
if ((Pl->anonymous && ep == Pl->u.ep) || \
3895
((!Pl->anonymous) && (ep->name) && (!strcmp(ep->name, Pl->u.name)))) \
3897
*(Pl->dest) = ep->id; \
3903
PROGRAM_MATCH(fnmatch, program, i);
3904
PROGRAM_MATCH(strcmp, program, i);
3905
PROGRAM_MATCH(strncmp, program, i);
3906
PROGRAM_MATCH(strrncmp, program, i);
3907
PROGRAM_MATCH(nocmp, program, i);
3913
if (!program->anonymous)
3914
ERR("Unable to find program name \"%s\".",
3917
ERR("Unable to find anonymous program.");
3921
if (!program->anonymous)
3922
free(program->u.name);
3926
groups_sourced = eina_hash_string_superfast_new(NULL);
3927
EINA_LIST_FREE(group_lookups, group)
3929
Edje_Part_Collection_Directory_Entry *de;
3933
if (group->part->type != EDJE_PART_TYPE_GROUP
3934
&& group->part->type != EDJE_PART_TYPE_TEXTBLOCK
3935
&& group->part->type != EDJE_PART_TYPE_BOX
3936
&& group->part->type != EDJE_PART_TYPE_TABLE)
3940
de = eina_hash_find(edje_file->collection, group->name);
3944
Eina_Bool found = EINA_FALSE;
3946
EINA_LIST_FOREACH(aliases, l, de)
3947
if (strcmp(de->entry, group->name) == 0)
3952
if (!found) de = NULL;
3957
ERR("Unable to find group name \"%s\".", group->name);
3961
eina_hash_add(groups_sourced, group->name, (void*)1);
3967
EINA_LIST_FREE(face_group_lookups, group_name)
3969
Edje_Part_Collection_Directory_Entry *de;
3971
de = eina_hash_find(edje_file->collection, group_name);
3975
Eina_Bool found = EINA_FALSE;
3977
EINA_LIST_FOREACH(aliases, l, de)
3978
if (strcmp(de->entry, group_name) == 0)
3983
if (!found) de = NULL;
3988
ERR("Unable to find group name \"%s\".", group_name);
3995
images_in_use = eina_hash_string_superfast_new(NULL);
3997
EINA_LIST_FREE(image_lookups, image)
3999
Eina_Bool find = EINA_FALSE;
4001
if (edje_file->image_dir)
4003
Edje_Image_Directory_Entry *de;
4006
for (i = 0; i < edje_file->image_dir->entries_count; ++i)
4008
de = edje_file->image_dir->entries + i;
4010
if ((de->entry) && (!strcmp(de->entry, image->name)))
4012
if (de->source_type >= EDJE_IMAGE_SOURCE_TYPE_USER)
4013
*(image->dest) = -de->id - 1;
4015
*(image->dest) = de->id;
4016
*(image->set) = EINA_FALSE;
4019
if (!eina_hash_find(images_in_use, image->name))
4020
eina_hash_direct_add(images_in_use, de->entry, de);
4027
Edje_Image_Directory_Set *set;
4029
for (i = 0; i < edje_file->image_dir->sets_count; ++i)
4031
set = edje_file->image_dir->sets + i;
4033
if ((set->name) && (!strcmp(set->name, image->name)))
4035
Edje_Image_Directory_Set_Entry *child;
4038
*(image->dest) = set->id;
4039
*(image->set) = EINA_TRUE;
4042
EINA_LIST_FOREACH(set->entries, lc, child)
4043
if (!eina_hash_find(images_in_use, child->name))
4044
eina_hash_direct_add(images_in_use, child->name, child);
4046
if (!eina_hash_find(images_in_use, image->name))
4047
eina_hash_direct_add(images_in_use, set->name, set);
4051
*(image->set) = EINA_FALSE;
4058
ERR("Unable to find image name \"%s\".", image->name);
4066
if (edje_file->image_dir && !is_lua)
4068
Edje_Image_Directory_Entry *de/*, *de_last, *img*/;
4069
Edje_Image_Directory_Set *set;
4070
Edje_Image_Directory_Set_Entry *set_e;
4071
// Eina_List *images_unused_list = NULL;
4074
for (i = 0; i < edje_file->image_dir->entries_count; ++i)
4076
de = edje_file->image_dir->entries + i;
4078
if (de->entry && eina_hash_find(images_in_use, de->entry))
4081
if (!no_warn_unused_images)
4082
printf("Warning: Image '%s' not used\n", de->entry);
4083
// INF("Image '%s' in resource 'edje/image/%i' will not be included as it is unused.",
4084
// de->entry, de->id);
4086
// so as not to write the unused images, moved last image in the
4087
// list to unused image position and check it
4089
free((void *)de->entry);
4091
de_last = edje_file->image_dir->entries + edje_file->image_dir->entries_count - 1;
4092
iui = mem_alloc(SZ(Image_Unused_Ids));
4093
iui->old_id = de_last->id;
4094
images_unused_list = eina_list_append(images_unused_list, iui);
4097
memcpy(de, de_last, sizeof(Edje_Image_Directory_Entry));
4098
--i; // need to check a moved image on this index
4099
edje_file->image_dir->entries_count--;
4100
img = realloc(edje_file->image_dir->entries,
4101
sizeof (Edje_Image_Directory_Entry) * edje_file->image_dir->entries_count);
4102
edje_file->image_dir->entries = img;
4106
for (i = 0; i < edje_file->image_dir->sets_count; ++i)
4108
set = edje_file->image_dir->sets + i;
4110
if (set->name && eina_hash_find(images_in_use, set->name))
4113
if (!no_warn_unused_images)
4115
printf("Warning: Image set '%s' not used\n", set->name);
4116
EINA_LIST_FOREACH(set->entries, l, set_e)
4118
printf(" Contains '%s' size %ix%i -> %ix%i\n",
4120
set_e->size.min.w, set_e->size.min.h,
4121
set_e->size.max.w, set_e->size.max.h);
4124
/* No need to redo id's - we will warn of unused images - fix in src
4125
* Also .. this is broken and messes up id's ... so easyer - complain
4126
* to develoepr to clean up the theme...
4127
INF("Set '%s' will not be included as it is unused.", set->name);
4129
free((void *)set->name);
4130
EINA_LIST_FREE(set->entries, set_e)
4132
free((void *)set_e->name);
4135
set->entries = NULL;
4136
set_last = edje_file->image_dir->sets + edje_file->image_dir->sets_count - 1;
4137
iui = mem_alloc(SZ(Image_Unused_Ids));
4138
iui->old_id = set_last->id;
4139
images_unused_list = eina_list_append(images_unused_list, iui);
4142
memcpy(set, set_last, sizeof(Edje_Image_Directory_Set));
4144
edje_file->image_dir->sets_count--;
4145
set_realloc = realloc(edje_file->image_dir->sets,
4146
sizeof(Edje_Image_Directory_Set) * edje_file->image_dir->sets_count);
4147
edje_file->image_dir->sets = set_realloc;
4151
/* update image id in parts */
4152
// if (images_unused_list) _data_image_id_update(images_unused_list);
4153
// EINA_LIST_FREE(images_unused_list, iui)
4156
_data_image_sets_size_set();
4159
eina_hash_free(images_in_use);
4163
data_process_string(Edje_Part_Collection *pc, const char *prefix, char *s, void (*func)(Edje_Part_Collection *pc, char *name, char *ptr, int len))
4170
keyl = strlen(prefix) + 2;
4171
key = alloca(keyl + 1);
4173
strcpy(key, prefix);
4177
for (p = s; (p) && (*p); p++)
4189
if (!strncmp(p, key, keyl))
4202
if (*p == '\\') inesc = 1;
4203
else if (*p == '\"')
4205
/* string concatenation, see below */
4206
if (*(p + 1) != '\"')
4231
if (*pp == '\\') inesc = 1;
4232
else if (*pp == '\"')
4234
/* concat strings like "foo""bar" to "foobar" */
4235
if (*(pp + 1) == '\"')
4254
func(pc, name, ptr, len);
4262
if (*p == '\"') quote = 0;
4263
else if (*p == '\\')
4275
_data_queue_part_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len)
4279
cl = mem_alloc(SZ(Code_Lookup));
4283
data_queue_part_lookup(pc, name, &(cl->val));
4285
code_lookups = eina_list_append(code_lookups, cl);
4289
_data_queue_program_lookup(Edje_Part_Collection *pc, char *name, char *ptr, int len)
4293
cl = mem_alloc(SZ(Code_Lookup));
4297
data_queue_program_lookup(pc, name, &(cl->val));
4299
code_lookups = eina_list_append(code_lookups, cl);
4303
_data_queue_group_lookup(Edje_Part_Collection *pc EINA_UNUSED, char *name, char *ptr EINA_UNUSED, int len EINA_UNUSED)
4305
data_queue_group_lookup(name, NULL);
4309
_data_queue_image_pc_lookup(Edje_Part_Collection *pc EINA_UNUSED, char *name, char *ptr, int len)
4313
cl = mem_alloc(SZ(Code_Lookup));
4317
data_queue_image_lookup(name, &(cl->val), &(cl->set));
4319
code_lookups = eina_list_append(code_lookups, cl);
4323
data_process_scripts(void)
4327
for (l = codes, l2 = edje_collections; (l) && (l2); l = eina_list_next(l), l2 = eina_list_next(l2))
4329
Edje_Part_Collection *pc;
4332
cd = eina_list_data_get(l);
4333
pc = eina_list_data_get(l2);
4335
if ((cd->shared) && (!cd->is_lua))
4337
data_process_string(pc, "PART", cd->shared, _data_queue_part_lookup);
4338
data_process_string(pc, "PROGRAM", cd->shared, _data_queue_program_lookup);
4339
data_process_string(pc, "IMAGE", cd->shared, _data_queue_image_pc_lookup);
4340
data_process_string(pc, "GROUP", cd->shared, _data_queue_group_lookup);
4348
EINA_LIST_FOREACH(cd->programs, ll, cp)
4352
data_process_string(pc, "PART", cp->script, _data_queue_part_lookup);
4353
data_process_string(pc, "PROGRAM", cp->script, _data_queue_program_lookup);
4354
data_process_string(pc, "IMAGE", cp->script, _data_queue_image_pc_lookup);
4355
data_process_string(pc, "GROUP", cp->script, _data_queue_group_lookup);
4363
data_process_script_lookups(void)
4368
EINA_LIST_FOREACH(code_lookups, l, cl)
4373
/* FIXME !! Handle set in program */
4374
n = eina_convert_itoa(cl->val, buf);
4377
ERR("The unexpected happened. A numeric replacement string was larger than the original!");
4380
memset(cl->ptr, ' ', cl->len);
4381
strncpy(cl->ptr, buf, n);
4386
using_file(const char *filename, const char type)
4392
f = fopen(depfile, "ab");
4396
fprintf(f, " \\\n %s", filename);
4402
f = fopen(watchfile, "ab");
4406
fprintf(f, "%c: %s\n", type, filename);
4418
color_tree_root_free(void)
4422
EINA_LIST_FREE(color_tree_root, name)
4427
color_tree_token_next(char *dst, char *src, int *ln)
4429
Eina_Bool begin = EINA_FALSE, next = EINA_FALSE;
4433
if (*src == '\0') break;
4437
if (!begin) begin = EINA_TRUE;
4438
else next = EINA_TRUE;
4440
else if ((!begin) && ((*src == '{') || (*src == '}') || (*src == ';')))
4445
else if ((!begin) && (*src == '\n'))
4459
Edje_Color_Tree_Node *
4460
color_tree_parent_node_get(const char *color_class)
4462
Edje_Color_Tree_Node *ctn;
4466
EINA_LIST_FOREACH(edje_file->color_tree, l, ctn)
4467
if (ctn->color_classes)
4468
EINA_LIST_FOREACH(ctn->color_classes, ll, name)
4469
if (!strcmp(name, color_class))
4476
process_color_tree(char *s, const char *f_in, int ln)
4478
char token[2][1024];
4481
Edje_Color_Tree_Node *ctn;
4487
array = eina_array_new(4);
4491
s = color_tree_token_next(token[id], s, &ln);
4493
if (!strcmp(token[id], "{"))
4496
error_and_abort(NULL, "parse error %s:%i. color class is not set to newly opened node block.",
4499
ctn = mem_alloc(SZ(Edje_Color_Tree_Node));
4500
ctn->name = strdup(token[!id]);
4501
color_class_register(ctn->name);
4502
ctn->color_classes = NULL;
4504
edje_file->color_tree = eina_list_append(edje_file->color_tree, ctn);
4506
eina_array_push(array, ctn);
4507
token[id][0] = '\0';
4509
else if (!strcmp(token[id], "}"))
4511
eina_array_pop(array);
4512
token[id][0] = '\0';
4514
else if (!strcmp(token[id], ";"))
4516
token[id][0] = '\0';
4518
else if (*s != '\0')
4520
if (eina_array_count(array))
4522
if (color_tree_root)
4523
EINA_LIST_FOREACH(color_tree_root, l, name)
4524
if (!strcmp(name, token[id]))
4526
error_and_abort(NULL, "parse error %s:%i. The color class \"%s\" already belongs to the root node.",
4527
f_in, ln - 1, token[id]);
4530
if ((ctn = color_tree_parent_node_get(token[id])))
4531
error_and_abort(NULL, "parse error %s:%i. The color class \"%s\" already belongs to the \"%s\" node.",
4532
f_in, ln - 1, token[id], ctn->name);
4534
ctn = eina_array_data_get(array, eina_array_count(array) - 1);
4535
ctn->color_classes = eina_list_append(ctn->color_classes, strdup(token[id]));
4539
if ((ctn = color_tree_parent_node_get(token[id])))
4540
error_and_abort(NULL, "parse error %s:%i. The color class \"%s\" already belongs to the \"%s\" node.",
4541
f_in, ln - 1, token[id], ctn->name);
4543
color_tree_root = eina_list_append(color_tree_root, strdup(token[id]));
4550
if (eina_array_count(array))
4551
error_and_abort(NULL, "parse error %s:%i. check pair of parens.", f_in, ln - 1);
4553
eina_array_clean(array);
4554
eina_array_free(array);
4558
validate_hex_digit(char c)
4560
if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f'))
4563
ERR("%s:%i. invalid character '%c' is used in color code.",
4564
file_in, line - 1, c);
4569
convert_color_code(char *str, int *r, int *g, int *b, int *a)
4576
if ((str[0] != '#') || (len != 4 && len != 5 && len != 7 && len != 9))
4578
ERR("%s:%i color code should start with '#' and have 4 or 8 digit hex number. (3 or 6 digits are allowed to omit alpha value of 255)",
4587
if ((len == 4) || (len == 5))
4589
buf[0] = validate_hex_digit(str[1]);
4590
buf[1] = validate_hex_digit(str[1]);
4594
buf[0] = validate_hex_digit(str[1]);
4595
buf[1] = validate_hex_digit(str[2]);
4598
*r = (int)strtol(buf, NULL, 16);
4602
if ((len == 4) || (len == 5))
4604
buf[0] = validate_hex_digit(str[2]);
4605
buf[1] = validate_hex_digit(str[2]);
4609
buf[0] = validate_hex_digit(str[3]);
4610
buf[1] = validate_hex_digit(str[4]);
4613
*g = (int)strtol(buf, NULL, 16);
4617
if ((len == 4) || (len == 5))
4619
buf[0] = validate_hex_digit(str[3]);
4620
buf[1] = validate_hex_digit(str[3]);
4624
buf[0] = validate_hex_digit(str[5]);
4625
buf[1] = validate_hex_digit(str[6]);
4628
*b = (int)strtol(buf, NULL, 16);
4632
if ((len == 5) || (len == 9))
4636
buf[0] = validate_hex_digit(str[4]);
4637
buf[1] = validate_hex_digit(str[4]);
4641
buf[0] = validate_hex_digit(str[7]);
4642
buf[1] = validate_hex_digit(str[8]);
4645
*a = (int)strtol(buf, NULL, 16);