2005-10-05 01:38:04 -07:00
|
|
|
#include "edje_private.h"
|
|
|
|
|
2009-09-28 23:13:33 -07:00
|
|
|
|
2009-06-17 04:10:32 -07:00
|
|
|
static Eina_Hash *_edje_file_hash = NULL;
|
2005-10-05 01:38:04 -07:00
|
|
|
static int _edje_file_cache_size = 16;
|
2008-10-22 04:34:42 -07:00
|
|
|
static Eina_List *_edje_file_cache = NULL;
|
2005-10-05 01:38:04 -07:00
|
|
|
|
|
|
|
static int _edje_collection_cache_size = 16;
|
|
|
|
|
2012-12-05 23:54:54 -08:00
|
|
|
EAPI void
|
|
|
|
edje_cache_emp_alloc(Edje_Part_Collection_Directory_Entry *ce)
|
|
|
|
{ /* Init Eina Mempools this is also used in edje_pick.c */
|
|
|
|
char *buffer;
|
|
|
|
#define INIT_EMP(Tp, Sz, Ce) \
|
|
|
|
buffer = alloca(strlen(ce->entry) + strlen(#Tp) + 2); \
|
|
|
|
sprintf(buffer, "%s/%s", ce->entry, #Tp); \
|
|
|
|
Ce->mp.Tp = eina_mempool_add("one_big", buffer, NULL, sizeof (Sz), Ce->count.Tp); \
|
|
|
|
_emp_##Tp = Ce->mp.Tp;
|
|
|
|
|
|
|
|
#define INIT_EMP_BOTH(Tp, Sz, Ce) \
|
|
|
|
INIT_EMP(Tp, Sz, Ce) \
|
|
|
|
Ce->mp_rtl.Tp = eina_mempool_add("one_big", buffer, NULL, \
|
|
|
|
sizeof (Sz), Ce->count.Tp);
|
|
|
|
|
|
|
|
INIT_EMP_BOTH(RECTANGLE, Edje_Part_Description_Common, ce);
|
|
|
|
INIT_EMP_BOTH(TEXT, Edje_Part_Description_Text, ce);
|
|
|
|
INIT_EMP_BOTH(IMAGE, Edje_Part_Description_Image, ce);
|
|
|
|
INIT_EMP_BOTH(PROXY, Edje_Part_Description_Proxy, ce);
|
|
|
|
INIT_EMP_BOTH(SWALLOW, Edje_Part_Description_Common, ce);
|
|
|
|
INIT_EMP_BOTH(TEXTBLOCK, Edje_Part_Description_Text, ce);
|
|
|
|
INIT_EMP_BOTH(GROUP, Edje_Part_Description_Common, ce);
|
|
|
|
INIT_EMP_BOTH(BOX, Edje_Part_Description_Box, ce);
|
|
|
|
INIT_EMP_BOTH(TABLE, Edje_Part_Description_Table, ce);
|
|
|
|
INIT_EMP_BOTH(EXTERNAL, Edje_Part_Description_External, ce);
|
|
|
|
INIT_EMP_BOTH(SPACER, Edje_Part_Description_Common, ce);
|
|
|
|
INIT_EMP(part, Edje_Part, ce);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
edje_cache_emp_free(Edje_Part_Collection_Directory_Entry *ce)
|
|
|
|
{ /* Free Eina Mempools this is also used in edje_pick.c */
|
|
|
|
/* Destroy all part and description. */
|
|
|
|
eina_mempool_del(ce->mp.RECTANGLE);
|
|
|
|
eina_mempool_del(ce->mp.TEXT);
|
|
|
|
eina_mempool_del(ce->mp.IMAGE);
|
|
|
|
eina_mempool_del(ce->mp.PROXY);
|
|
|
|
eina_mempool_del(ce->mp.SWALLOW);
|
|
|
|
eina_mempool_del(ce->mp.TEXTBLOCK);
|
|
|
|
eina_mempool_del(ce->mp.GROUP);
|
|
|
|
eina_mempool_del(ce->mp.BOX);
|
|
|
|
eina_mempool_del(ce->mp.TABLE);
|
|
|
|
eina_mempool_del(ce->mp.EXTERNAL);
|
|
|
|
eina_mempool_del(ce->mp.SPACER);
|
|
|
|
eina_mempool_del(ce->mp.part);
|
|
|
|
memset(&ce->mp, 0, sizeof (ce->mp));
|
|
|
|
|
|
|
|
eina_mempool_del(ce->mp_rtl.RECTANGLE);
|
|
|
|
eina_mempool_del(ce->mp_rtl.TEXT);
|
|
|
|
eina_mempool_del(ce->mp_rtl.IMAGE);
|
|
|
|
eina_mempool_del(ce->mp_rtl.PROXY);
|
|
|
|
eina_mempool_del(ce->mp_rtl.SWALLOW);
|
|
|
|
eina_mempool_del(ce->mp_rtl.TEXTBLOCK);
|
|
|
|
eina_mempool_del(ce->mp_rtl.GROUP);
|
|
|
|
eina_mempool_del(ce->mp_rtl.BOX);
|
|
|
|
eina_mempool_del(ce->mp_rtl.TABLE);
|
|
|
|
eina_mempool_del(ce->mp_rtl.EXTERNAL);
|
|
|
|
eina_mempool_del(ce->mp_rtl.SPACER);
|
|
|
|
memset(&ce->mp_rtl, 0, sizeof (ce->mp_rtl));
|
|
|
|
ce->ref = NULL;
|
|
|
|
}
|
|
|
|
|
2013-02-13 19:36:13 -08:00
|
|
|
|
|
|
|
void
|
|
|
|
_edje_programs_patterns_init(Edje_Part_Collection *edc)
|
|
|
|
{
|
|
|
|
Edje_Signals_Sources_Patterns *ssp = &edc->patterns.programs;
|
|
|
|
Edje_Program **all;
|
|
|
|
unsigned int i, j;
|
|
|
|
|
|
|
|
if (ssp->signals_patterns)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (getenv("EDJE_DUMP_PROGRAMS"))
|
|
|
|
{
|
|
|
|
INF("Group '%s' programs:", edc->part);
|
|
|
|
#define EDJE_DUMP_PROGRAM(Section) \
|
|
|
|
for (i = 0; i < edc->programs.Section##_count; i++) \
|
|
|
|
INF(#Section" for ('%s', '%s')", edc->programs.Section[i]->signal, edc->programs.Section[i]->source);
|
|
|
|
|
|
|
|
EDJE_DUMP_PROGRAM(strcmp);
|
|
|
|
EDJE_DUMP_PROGRAM(strncmp);
|
|
|
|
EDJE_DUMP_PROGRAM(strrncmp);
|
|
|
|
EDJE_DUMP_PROGRAM(fnmatch);
|
|
|
|
EDJE_DUMP_PROGRAM(nocmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
edje_match_program_hash_build(edc->programs.strcmp,
|
|
|
|
edc->programs.strcmp_count,
|
|
|
|
&ssp->exact_match);
|
|
|
|
|
|
|
|
j = edc->programs.strncmp_count
|
|
|
|
+ edc->programs.strrncmp_count
|
|
|
|
+ edc->programs.fnmatch_count
|
|
|
|
+ edc->programs.nocmp_count;
|
|
|
|
if (j == 0) return ;
|
|
|
|
|
|
|
|
all = malloc(sizeof (Edje_Program *) * j);
|
|
|
|
if (!all) return ;
|
|
|
|
j = 0;
|
|
|
|
|
|
|
|
/* FIXME: Build specialized data type for each case */
|
|
|
|
#define EDJE_LOAD_PROGRAMS_ADD(Array, Edc, It, Git, All) \
|
|
|
|
for (It = 0; It < Edc->programs.Array##_count; ++It, ++Git) \
|
|
|
|
All[Git] = Edc->programs.Array[It];
|
|
|
|
|
|
|
|
EDJE_LOAD_PROGRAMS_ADD(fnmatch, edc, i, j, all);
|
|
|
|
EDJE_LOAD_PROGRAMS_ADD(strncmp, edc, i, j, all);
|
|
|
|
EDJE_LOAD_PROGRAMS_ADD(strrncmp, edc, i, j, all);
|
|
|
|
/* FIXME: Do a special pass for that one */
|
|
|
|
EDJE_LOAD_PROGRAMS_ADD(nocmp, edc, i, j, all);
|
|
|
|
|
|
|
|
ssp->u.programs.globing = all;
|
|
|
|
ssp->u.programs.count = j;
|
|
|
|
ssp->signals_patterns = edje_match_programs_signal_init(all, j);
|
|
|
|
ssp->sources_patterns = edje_match_programs_source_init(all, j);
|
|
|
|
}
|
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
static Edje_Part_Collection *
|
2008-02-29 22:38:09 -08:00
|
|
|
_edje_file_coll_open(Edje_File *edf, const char *coll)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
|
|
|
Edje_Part_Collection *edc = NULL;
|
2008-10-22 04:34:42 -07:00
|
|
|
Edje_Part_Collection_Directory_Entry *ce;
|
2008-02-29 22:38:09 -08:00
|
|
|
int id = -1, size = 0;
|
2013-02-13 19:36:13 -08:00
|
|
|
unsigned int n;
|
2010-06-28 06:56:30 -07:00
|
|
|
Eina_List *l;
|
2005-10-05 01:38:04 -07:00
|
|
|
char buf[256];
|
|
|
|
void *data;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-06-28 06:56:30 -07:00
|
|
|
ce = eina_hash_find(edf->collection, coll);
|
|
|
|
if (!ce) return NULL;
|
|
|
|
|
|
|
|
if (ce->ref)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
2010-06-28 06:56:30 -07:00
|
|
|
ce->ref->references++;
|
|
|
|
return ce->ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(edf->collection_cache, l, edc)
|
|
|
|
{
|
|
|
|
if (!strcmp(edc->part, coll))
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
2010-06-28 06:56:30 -07:00
|
|
|
edc->references = 1;
|
|
|
|
ce->ref = edc;
|
|
|
|
|
|
|
|
edf->collection_cache = eina_list_remove_list(edf->collection_cache, l);
|
|
|
|
return ce->ref;
|
2005-10-05 01:38:04 -07:00
|
|
|
}
|
|
|
|
}
|
2010-06-28 06:56:30 -07:00
|
|
|
|
|
|
|
id = ce->id;
|
2005-10-05 01:38:04 -07:00
|
|
|
if (id < 0) return NULL;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2012-12-05 23:54:54 -08:00
|
|
|
edje_cache_emp_alloc(ce);
|
2010-08-09 10:34:03 -07:00
|
|
|
snprintf(buf, sizeof(buf), "edje/collections/%i", id);
|
|
|
|
edc = eet_data_read(edf->ef, _edje_edd_edje_part_collection, buf);
|
|
|
|
if (!edc) return NULL;
|
2010-07-29 05:02:36 -07:00
|
|
|
|
|
|
|
edc->references = 1;
|
2010-08-09 14:08:08 -07:00
|
|
|
edc->part = ce->entry;
|
2010-07-29 05:02:36 -07:00
|
|
|
|
2012-02-14 06:07:39 -08:00
|
|
|
/* For Edje file build with Edje 1.0 */
|
2011-04-07 05:34:18 -07:00
|
|
|
if (edf->version <= 3 && edf->minor <= 1)
|
|
|
|
{
|
|
|
|
/* This will preserve previous rendering */
|
|
|
|
unsigned int i;
|
|
|
|
|
2012-02-14 06:07:39 -08:00
|
|
|
/* people expect signal to not be broadcasted */
|
|
|
|
edc->broadcast_signal = EINA_FALSE;
|
|
|
|
|
|
|
|
/* people expect text.align to be 0.0 0.0 */
|
2011-04-07 05:34:18 -07:00
|
|
|
for (i = 0; i < edc->parts_count; ++i)
|
|
|
|
{
|
|
|
|
if (edc->parts[i]->type == EDJE_PART_TYPE_TEXTBLOCK)
|
|
|
|
{
|
|
|
|
Edje_Part_Description_Text *text;
|
|
|
|
unsigned int j;
|
|
|
|
|
|
|
|
text = (Edje_Part_Description_Text*) edc->parts[i]->default_desc;
|
|
|
|
text->text.align.x = TO_DOUBLE(0.0);
|
|
|
|
text->text.align.y = TO_DOUBLE(0.0);
|
|
|
|
|
|
|
|
for (j = 0; j < edc->parts[i]->other.desc_count; ++j)
|
|
|
|
{
|
|
|
|
text = (Edje_Part_Description_Text*) edc->parts[i]->other.desc[j];
|
|
|
|
text->text.align.x = TO_DOUBLE(0.0);
|
|
|
|
text->text.align.y = TO_DOUBLE(0.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-09 10:34:03 -07:00
|
|
|
snprintf(buf, sizeof(buf), "edje/scripts/embryo/compiled/%i", id);
|
2008-02-29 22:38:09 -08:00
|
|
|
data = eet_read(edf->ef, buf, &size);
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
if (data)
|
|
|
|
{
|
2010-07-29 05:02:36 -07:00
|
|
|
edc->script = embryo_program_new(data, size);
|
|
|
|
_edje_embryo_script_init(edc);
|
2005-10-05 01:38:04 -07:00
|
|
|
free(data);
|
|
|
|
}
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-08-09 10:34:03 -07:00
|
|
|
snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", id);
|
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
|
|
|
data = eet_read(edf->ef, buf, &size);
|
|
|
|
|
|
|
|
if (data)
|
|
|
|
{
|
2010-07-29 05:02:36 -07:00
|
|
|
_edje_lua2_script_load(edc, data, size);
|
From: "Hanspeter Portner" <ventosus@airpost.net>
This concerns Ticket #109: Add Lua support for Edje
It adds Lua as scripting facility to Edje, letting Embryo untouched.
It should be easier to use and be more flexible than Embryo, imho ;-)
---
The patch
---
Lua 5.1 is used in sandboxed mode. Lua byte code is not
platform/architecture independent, Lua code is saved as text in the Edje
container and parsed at load time, therefore.
The patch goes in two directions
1) Analogous to Embryo for scripting logic, messaging and custom states.
The same things are implemented as in Embryo:
- messaging from and to C
- manual creation of timers, animators, pollers for custom events /
animations
- manual manipulation of Edje parts by means of the public
edje_object_part_* and internal functions and custom states
-> those routines are actually implemented as Lua
bindings to
functions in Edje.h and Ecore.h
-> the implementation is done in an object oriented way, so that the
interface gives the feel of an object description language, pretty
similar to EDC itself
-> combining custom states and custom animators allows
for fancy
animations and transitions, e.g circular/spline translations or
complex/conditional transitions, etc.
-> this is just the same as Embryo does, but implemented in Lua, so
nothing new here, actually
2) Dynamic object creation and manipulation
- this interface stems from the 'script_only' objects in
Edje. Those
objects are a kind of scriptable Edje counterparts to Evas_Smart
objects. The infrastructure for Embryo is already there, but has
never been used
- I added this in Lua and added some first bindings to
experiment
with
- I thought it would be useful to allow for a limited dynamic
creation of ui parts
- We can create instances of groups from within the same Edje
container and use them just like the main Edje object as
stated in
1)
- And there are some stand-alone bindings to dynamically create
Evas_Image, Evas_Table, Evas_Line, Evas_Polygon as examples
-> this may be useful to decouple the program from the ui
even more,
to be able to do things that have to be done in the program itself
atm, but actually belong to the user interface, but need dynamic
creation of objects or complex interactions
-> those objects are manipulated manually with Lua bindings
to the
corresponding edje_object_* and evas_object_* functions
---
Discussion points
---
Both stuff in 1) & 2) is functioning, but needs testing, feedback,
improvements, ...
Stuff in 1) can already fully replace Embryo scripting with Lua
scripting. There still is space for improvements/additions, though.
Of the stuff in 2), I think it may only make sense to add the dynamic
creation of groups defined in the same Edje container. Dynamic creation
of other Evas_Objects makes not much sense, as most of them can already
be used as Edje parts and be manipulated with custom states (apart from
polygons and lines) and it would make the whole theming potentially more
programing-like and much more susceptible for errors, etc.
Would this be useful, or drop it all?
The scripting should be there just for logic, conditionals, custom
states and animations, not for a whole dynamic canvas, imho.
There is a patch around with EXTERNAL Edje parts. Seems to be a better,
faster, more secure way to extend Edje with custom objects.
There would be the possibility of precompiling Lua code at compile time
(edje_cc) for faster loading, but we would have to patch and run our own
Lua version.
The Lua parser is pretty fast, though, and using
byte-converted/endianness-swapped byte-code does only pay off for Lua
chunks of some kilo lines.
Byte code also occupies much more space than text in the final Edje
container, as it includes debug symbols.
---
Cedric and Vincent told me, that the plan was to replace Embryo totally
by Lua before the official release of Edje at the end of the year? So it
would make sense to bring Lua to svn soon and look how it fits in, test,
debug, adapt it further to the themers needs, decide on its final shape,
GATHER SOME PEOPLE TO HELP ;-)
---
The Lua enhanced Edje is in sync with svn and can be get directly here
git clone git://repo.or.cz/edje_lua.git
cd edje_lua
git checkout -b lua_patch origin/lua_patch
or apply the attached patch
There are also some examples to show the usage of the things
mentioned
above
- showcase.edj: shows usage of custom animators, custom states,
messaging and the script_only object
- test.edj: test cases of script usage and bindings (custom states,
custom transitions, tween_states, animators, timers,
object_parts),
but most of it are experimental script_only objects
http://didgmo.sourceforge.net/showcase.edj
http://didgmo.sourceforge.net/test.edj
The source of showcase.edc is attached, too, to just have a glimpse at
Lua inside of EDC
---
So, what do you guys think?
Thanks and sry for the looong mail, hehe ;-)
SVN revision: 41802
2009-08-15 19:34:02 -07:00
|
|
|
free(data);
|
|
|
|
}
|
2005-10-05 01:38:04 -07:00
|
|
|
|
2010-08-09 14:08:08 -07:00
|
|
|
ce->ref = edc;
|
|
|
|
|
2013-02-13 19:36:13 -08:00
|
|
|
_edje_programs_patterns_init(edc);
|
|
|
|
|
|
|
|
n = edc->programs.fnmatch_count +
|
|
|
|
edc->programs.strcmp_count +
|
|
|
|
edc->programs.strncmp_count +
|
|
|
|
edc->programs.strrncmp_count +
|
|
|
|
edc->programs.nocmp_count;
|
|
|
|
|
|
|
|
if (n > 0)
|
|
|
|
{
|
|
|
|
Edje_Program *pr;
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
edc->patterns.table_programs = malloc(sizeof(Edje_Program *) * n);
|
|
|
|
if (edc->patterns.table_programs)
|
|
|
|
{
|
|
|
|
edc->patterns.table_programs_size = n;
|
|
|
|
|
|
|
|
#define EDJE_LOAD_BUILD_TABLE(Array, Edc, It, Tmp) \
|
|
|
|
for (It = 0; It < Edc->programs.Array##_count; ++It) \
|
|
|
|
{ \
|
|
|
|
Tmp = Edc->programs.Array[It]; \
|
|
|
|
Edc->patterns.table_programs[Tmp->id] = Tmp; \
|
|
|
|
}
|
|
|
|
|
|
|
|
EDJE_LOAD_BUILD_TABLE(fnmatch, edc, i, pr);
|
|
|
|
EDJE_LOAD_BUILD_TABLE(strcmp, edc, i, pr);
|
|
|
|
EDJE_LOAD_BUILD_TABLE(strncmp, edc, i, pr);
|
|
|
|
EDJE_LOAD_BUILD_TABLE(strrncmp, edc, i, pr);
|
|
|
|
EDJE_LOAD_BUILD_TABLE(nocmp, edc, i, pr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-28 06:56:30 -07:00
|
|
|
return edc;
|
2007-04-04 06:25:55 -07:00
|
|
|
}
|
|
|
|
|
2012-05-09 02:16:52 -07:00
|
|
|
#ifdef HAVE_EIO
|
|
|
|
static Eina_Bool
|
|
|
|
_edje_file_warn(void *data)
|
|
|
|
{
|
|
|
|
Edje_File *edf = data;
|
|
|
|
Eina_List *l, *ll;
|
|
|
|
Edje *ed;
|
|
|
|
|
2012-05-09 03:44:02 -07:00
|
|
|
edf->references++;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(edf->edjes, l, ed)
|
|
|
|
_edje_ref(ed);
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(edf->edjes, l, ed)
|
2012-05-09 02:16:52 -07:00
|
|
|
{
|
|
|
|
_edje_emit(ed, "edje,change,file", "edje");
|
|
|
|
}
|
|
|
|
|
2012-05-09 03:44:02 -07:00
|
|
|
EINA_LIST_FOREACH_SAFE(edf->edjes, l, ll, ed)
|
|
|
|
_edje_unref(ed);
|
|
|
|
|
|
|
|
edf->references--;
|
|
|
|
|
2012-05-09 02:16:52 -07:00
|
|
|
edf->timeout = NULL;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2013-01-03 18:08:14 -08:00
|
|
|
_edje_file_change(void *data, int ev_type EINA_UNUSED, void *event)
|
2012-05-09 02:16:52 -07:00
|
|
|
{
|
|
|
|
Edje_File *edf = data;
|
|
|
|
Eio_Monitor_Event *ev = event;
|
|
|
|
|
|
|
|
if (ev->monitor == edf->monitor)
|
|
|
|
{
|
|
|
|
if (edf->timeout) ecore_timer_del(edf->timeout);
|
|
|
|
edf->timeout = ecore_timer_add(0.5, _edje_file_warn, edf);
|
|
|
|
}
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
static Edje_File *
|
2013-05-08 17:37:55 -07:00
|
|
|
_edje_file_open(Eina_File *f, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, time_t mtime)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
2012-08-09 01:27:04 -07:00
|
|
|
Edje_Color_Class *cc;
|
2005-10-05 01:38:04 -07:00
|
|
|
Edje_File *edf;
|
2012-08-09 01:27:04 -07:00
|
|
|
Eina_List *l;
|
2005-10-05 01:38:04 -07:00
|
|
|
Edje_Part_Collection *edc;
|
|
|
|
Eet_File *ef;
|
2012-05-09 02:16:52 -07:00
|
|
|
#ifdef HAVE_EIO
|
|
|
|
Ecore_Event_Handler *ev;
|
|
|
|
#endif
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
ef = eet_mmap(f);
|
2005-10-05 01:38:04 -07:00
|
|
|
if (!ef)
|
|
|
|
{
|
|
|
|
*error_ret = EDJE_LOAD_ERROR_UNKNOWN_FORMAT;
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-08-09 10:34:03 -07:00
|
|
|
edf = eet_data_read(ef, _edje_edd_edje_file, "edje/file");
|
|
|
|
if (!edf)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
|
|
|
*error_ret = EDJE_LOAD_ERROR_CORRUPT_FILE;
|
|
|
|
eet_close(ef);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-02-29 22:38:09 -08:00
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
edf->f = f;
|
2008-02-29 22:38:09 -08:00
|
|
|
edf->ef = ef;
|
2012-01-05 06:31:27 -08:00
|
|
|
edf->mtime = mtime;
|
2012-05-09 02:16:52 -07:00
|
|
|
#ifdef HAVE_EIO
|
2013-05-08 17:37:55 -07:00
|
|
|
edf->monitor = eio_monitor_add(eina_file_filename_get(f));
|
2012-05-09 02:16:52 -07:00
|
|
|
ev = ecore_event_handler_add(EIO_MONITOR_FILE_DELETED, _edje_file_change, edf);
|
|
|
|
edf->handlers = eina_list_append(edf->handlers, ev);
|
|
|
|
ev = ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, _edje_file_change, edf);
|
|
|
|
edf->handlers = eina_list_append(edf->handlers, ev);
|
|
|
|
ev = ecore_event_handler_add(EIO_MONITOR_FILE_CREATED, _edje_file_change, edf);
|
|
|
|
edf->handlers = eina_list_append(edf->handlers, ev);
|
|
|
|
ev = ecore_event_handler_add(EIO_MONITOR_SELF_DELETED, _edje_file_change, edf);
|
|
|
|
edf->handlers = eina_list_append(edf->handlers, ev);
|
|
|
|
#endif
|
2008-02-29 22:38:09 -08:00
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
if (edf->version != EDJE_FILE_VERSION)
|
|
|
|
{
|
|
|
|
*error_ret = EDJE_LOAD_ERROR_INCOMPATIBLE_FILE;
|
|
|
|
_edje_file_free(edf);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-06-28 06:56:30 -07:00
|
|
|
if (!edf->collection)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
|
|
|
*error_ret = EDJE_LOAD_ERROR_CORRUPT_FILE;
|
|
|
|
_edje_file_free(edf);
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-08-25 02:56:20 -07:00
|
|
|
if (edf->minor > EDJE_FILE_MINOR)
|
|
|
|
{
|
2013-05-08 17:37:55 -07:00
|
|
|
WRN("`%s` may use feature from a newer edje and could not show up as expected.",
|
|
|
|
eina_file_filename_get(f));
|
2010-08-25 02:56:20 -07:00
|
|
|
}
|
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
edf->path = eina_stringshare_add(eina_file_filename_get(f));
|
2005-10-05 01:38:04 -07:00
|
|
|
edf->references = 1;
|
|
|
|
|
2010-06-28 06:56:30 -07:00
|
|
|
/* This should be done at edje generation time */
|
2005-10-05 01:38:04 -07:00
|
|
|
_edje_textblock_style_parse_and_fix(edf);
|
2012-08-09 01:27:04 -07:00
|
|
|
edf->color_hash = eina_hash_string_small_new(NULL);
|
|
|
|
EINA_LIST_FOREACH(edf->color_classes, l, cc)
|
|
|
|
if (cc->name)
|
|
|
|
eina_hash_direct_add(edf->color_hash, cc->name, cc);
|
2007-03-06 04:03:34 -08:00
|
|
|
|
2007-04-04 06:25:55 -07:00
|
|
|
if (coll)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
2008-02-29 22:38:09 -08:00
|
|
|
edc = _edje_file_coll_open(edf, coll);
|
2007-04-04 06:25:55 -07:00
|
|
|
if (!edc)
|
|
|
|
{
|
|
|
|
*error_ret = EDJE_LOAD_ERROR_UNKNOWN_COLLECTION;
|
|
|
|
}
|
|
|
|
if (edc_ret) *edc_ret = edc;
|
2005-10-05 01:38:04 -07:00
|
|
|
}
|
2007-04-04 06:25:55 -07:00
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
return edf;
|
|
|
|
}
|
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
#if 0
|
|
|
|
// FIXME: find a way to remove dangling file earlier
|
2010-02-26 19:47:04 -08:00
|
|
|
static void
|
|
|
|
_edje_file_dangling(Edje_File *edf)
|
|
|
|
{
|
|
|
|
if (edf->dangling) return;
|
|
|
|
edf->dangling = EINA_TRUE;
|
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
eina_hash_del(_edje_file_hash, edf->f, edf);
|
2010-02-26 19:47:04 -08:00
|
|
|
if (!eina_hash_population(_edje_file_hash))
|
|
|
|
{
|
|
|
|
eina_hash_free(_edje_file_hash);
|
|
|
|
_edje_file_hash = NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-05-08 17:37:55 -07:00
|
|
|
#endif
|
2010-02-26 19:47:04 -08:00
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
Edje_File *
|
2012-05-09 02:16:52 -07:00
|
|
|
_edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, Edje_Part_Collection **edc_ret, Edje *ed)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
2013-05-08 17:37:55 -07:00
|
|
|
Eina_File *f;
|
2010-09-10 04:24:49 -07:00
|
|
|
Edje_File *edf;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l, *hist;
|
2005-10-05 01:38:04 -07:00
|
|
|
Edje_Part_Collection *edc;
|
2008-10-22 04:34:42 -07:00
|
|
|
Edje_Part *ep;
|
2010-02-26 19:47:04 -08:00
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
f = eina_file_open(file, EINA_FALSE);
|
|
|
|
if (!f)
|
2013-02-19 19:10:18 -08:00
|
|
|
{
|
|
|
|
*error_ret = EDJE_LOAD_ERROR_DOES_NOT_EXIST;
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-10-05 01:38:04 -07:00
|
|
|
|
2008-12-17 06:26:47 -08:00
|
|
|
if (!_edje_file_hash)
|
2010-04-05 07:05:21 -07:00
|
|
|
{
|
2013-05-08 17:37:55 -07:00
|
|
|
_edje_file_hash = eina_hash_pointer_new(NULL);
|
2013-01-29 05:48:15 -08:00
|
|
|
goto find_list;
|
2010-04-05 07:05:21 -07:00
|
|
|
}
|
2008-12-17 06:26:47 -08:00
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
edf = eina_hash_find(_edje_file_hash, f);
|
2005-10-05 01:38:04 -07:00
|
|
|
if (edf)
|
|
|
|
{
|
2013-05-08 17:37:55 -07:00
|
|
|
eina_file_close(f);
|
2010-02-26 19:47:04 -08:00
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
edf->references++;
|
2010-04-05 07:05:21 -07:00
|
|
|
goto open;
|
2005-10-05 01:38:04 -07:00
|
|
|
}
|
2013-01-29 05:48:15 -08:00
|
|
|
|
|
|
|
find_list:
|
2010-04-05 07:05:21 -07:00
|
|
|
EINA_LIST_FOREACH(_edje_file_cache, l, edf)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
2013-05-08 17:37:55 -07:00
|
|
|
if (edf->f == f)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
2013-05-08 17:37:55 -07:00
|
|
|
eina_file_close(f);
|
2010-04-05 07:05:21 -07:00
|
|
|
|
|
|
|
edf->references = 1;
|
|
|
|
_edje_file_cache = eina_list_remove_list(_edje_file_cache, l);
|
2013-05-08 17:37:55 -07:00
|
|
|
eina_hash_direct_add(_edje_file_hash, f, edf);
|
2010-09-10 04:24:49 -07:00
|
|
|
goto open;
|
2005-10-05 01:38:04 -07:00
|
|
|
}
|
|
|
|
}
|
2010-02-26 19:47:04 -08:00
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
edf = _edje_file_open(f, coll, error_ret, edc_ret, eina_file_mtime_get(f));
|
2010-09-10 04:25:05 -07:00
|
|
|
if (!edf)
|
2013-05-08 17:37:55 -07:00
|
|
|
{
|
|
|
|
eina_file_close(f);
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-09-10 04:25:05 -07:00
|
|
|
|
2012-05-09 02:16:52 -07:00
|
|
|
#ifdef HAVE_EIO
|
|
|
|
if (ed) edf->edjes = eina_list_append(edf->edjes, ed);
|
|
|
|
#else
|
|
|
|
(void) ed;
|
|
|
|
#endif
|
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
eina_hash_direct_add(_edje_file_hash, f, edf);
|
|
|
|
/* return edf; */
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-09-10 04:25:05 -07:00
|
|
|
open:
|
|
|
|
if (!coll)
|
|
|
|
return edf;
|
2009-04-26 19:41:33 -07:00
|
|
|
|
2010-06-28 06:56:30 -07:00
|
|
|
edc = _edje_file_coll_open(edf, coll);
|
|
|
|
if (!edc)
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
2010-06-28 06:56:30 -07:00
|
|
|
*error_ret = EDJE_LOAD_ERROR_UNKNOWN_COLLECTION;
|
2005-10-05 01:38:04 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-28 06:56:30 -07:00
|
|
|
if (!edc->checked)
|
2007-01-22 04:44:57 -08:00
|
|
|
{
|
2010-07-29 05:02:36 -07:00
|
|
|
unsigned int j;
|
|
|
|
|
|
|
|
for (j = 0; j < edc->parts_count; ++j)
|
2007-01-22 04:44:57 -08:00
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Edje_Part *ep2;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-07-29 05:02:36 -07:00
|
|
|
ep = edc->parts[j];
|
|
|
|
|
2007-01-22 04:44:57 -08:00
|
|
|
/* Register any color classes in this parts descriptions. */
|
|
|
|
hist = NULL;
|
2008-10-22 04:34:42 -07:00
|
|
|
hist = eina_list_append(hist, ep);
|
2007-01-22 04:44:57 -08:00
|
|
|
ep2 = ep;
|
|
|
|
while (ep2->dragable.confine_id >= 0)
|
|
|
|
{
|
2010-07-29 05:02:36 -07:00
|
|
|
if (ep2->dragable.confine_id >= (int) edc->parts_count)
|
|
|
|
{
|
|
|
|
ERR("confine_to above limit. invalidating it.");
|
|
|
|
ep2->dragable.confine_id = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ep2 = edc->parts[ep2->dragable.confine_id];
|
2008-10-22 04:34:42 -07:00
|
|
|
if (eina_list_data_find(hist, ep2))
|
2007-01-22 04:44:57 -08:00
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("confine_to loops. invalidating loop.");
|
2007-01-22 04:44:57 -08:00
|
|
|
ep2->dragable.confine_id = -1;
|
|
|
|
break;
|
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
hist = eina_list_append(hist, ep2);
|
2007-01-22 04:44:57 -08:00
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
eina_list_free(hist);
|
2007-01-22 04:44:57 -08:00
|
|
|
hist = NULL;
|
2008-10-22 04:34:42 -07:00
|
|
|
hist = eina_list_append(hist, ep);
|
2007-01-22 04:44:57 -08:00
|
|
|
ep2 = ep;
|
2010-07-16 06:58:35 -07:00
|
|
|
while (ep2->dragable.event_id >= 0)
|
2007-01-22 04:44:57 -08:00
|
|
|
{
|
|
|
|
Edje_Part* prev;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-07-29 05:02:36 -07:00
|
|
|
if (ep2->dragable.event_id >= (int) edc->parts_count)
|
|
|
|
{
|
|
|
|
ERR("event_id above limit. invalidating it.");
|
|
|
|
ep2->dragable.event_id = -1;
|
|
|
|
break;
|
|
|
|
}
|
2007-01-22 04:44:57 -08:00
|
|
|
prev = ep2;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-07-29 05:02:36 -07:00
|
|
|
ep2 = edc->parts[ep2->dragable.event_id];
|
2013-04-06 19:39:20 -07:00
|
|
|
/* events_to may be used only with dragable */
|
2007-01-22 04:44:57 -08:00
|
|
|
if (!ep2->dragable.x && !ep2->dragable.y)
|
|
|
|
{
|
2010-07-16 06:58:35 -07:00
|
|
|
prev->dragable.event_id = -1;
|
2007-01-22 04:44:57 -08:00
|
|
|
break;
|
|
|
|
}
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
if (eina_list_data_find(hist, ep2))
|
2007-01-22 04:44:57 -08:00
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("events_to loops. invalidating loop.");
|
2010-07-16 06:58:35 -07:00
|
|
|
ep2->dragable.event_id = -1;
|
2007-01-22 04:44:57 -08:00
|
|
|
break;
|
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
hist = eina_list_append(hist, ep2);
|
2007-01-22 04:44:57 -08:00
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
eina_list_free(hist);
|
2007-01-22 04:44:57 -08:00
|
|
|
hist = NULL;
|
2008-10-22 04:34:42 -07:00
|
|
|
hist = eina_list_append(hist, ep);
|
2007-01-22 04:44:57 -08:00
|
|
|
ep2 = ep;
|
|
|
|
while (ep2->clip_to_id >= 0)
|
|
|
|
{
|
2010-07-29 05:02:36 -07:00
|
|
|
if (ep2->clip_to_id >= (int) edc->parts_count)
|
|
|
|
{
|
|
|
|
ERR("clip_to_id above limit. invalidating it.");
|
|
|
|
ep2->clip_to_id = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ep2 = edc->parts[ep2->clip_to_id];
|
2008-10-22 04:34:42 -07:00
|
|
|
if (eina_list_data_find(hist, ep2))
|
2007-01-22 04:44:57 -08:00
|
|
|
{
|
2009-12-22 05:46:00 -08:00
|
|
|
ERR("clip_to loops. invalidating loop.");
|
2007-01-22 04:44:57 -08:00
|
|
|
ep2->clip_to_id = -1;
|
|
|
|
break;
|
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
hist = eina_list_append(hist, ep2);
|
2007-01-22 04:44:57 -08:00
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
eina_list_free(hist);
|
2007-01-22 04:44:57 -08:00
|
|
|
hist = NULL;
|
|
|
|
}
|
2010-06-28 06:56:30 -07:00
|
|
|
edc->checked = 1;
|
2007-01-22 04:44:57 -08:00
|
|
|
}
|
2005-10-05 01:38:04 -07:00
|
|
|
}
|
2012-05-09 02:16:52 -07:00
|
|
|
#ifdef HAVE_EIO
|
|
|
|
if (edc && ed) edf->edjes = eina_list_append(edf->edjes, ed);
|
|
|
|
#else
|
|
|
|
(void) ed;
|
|
|
|
#endif
|
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
if (edc_ret) *edc_ret = edc;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
return edf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_cache_coll_clean(Edje_File *edf)
|
|
|
|
{
|
2010-08-09 14:08:08 -07:00
|
|
|
while ((edf->collection_cache) &&
|
|
|
|
(eina_list_count(edf->collection_cache) > (unsigned int) _edje_collection_cache_size))
|
2005-10-05 01:38:04 -07:00
|
|
|
{
|
2010-07-29 05:02:36 -07:00
|
|
|
Edje_Part_Collection_Directory_Entry *ce;
|
2005-10-05 01:38:04 -07:00
|
|
|
Edje_Part_Collection *edc;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
edc = eina_list_data_get(eina_list_last(edf->collection_cache));
|
|
|
|
edf->collection_cache = eina_list_remove_list(edf->collection_cache, eina_list_last(edf->collection_cache));
|
2010-07-29 05:02:36 -07:00
|
|
|
|
|
|
|
ce = eina_hash_find(edf->collection, edc->part);
|
|
|
|
_edje_collection_free(edf, edc, ce);
|
2005-10-05 01:38:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-02 00:13:56 -08:00
|
|
|
void
|
|
|
|
_edje_cache_coll_flush(Edje_File *edf)
|
|
|
|
{
|
|
|
|
while (edf->collection_cache)
|
|
|
|
{
|
2010-07-29 05:02:36 -07:00
|
|
|
Edje_Part_Collection_Directory_Entry *ce;
|
2005-11-02 00:13:56 -08:00
|
|
|
Edje_Part_Collection *edc;
|
2010-08-09 14:08:08 -07:00
|
|
|
Eina_List *last;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-08-09 14:08:08 -07:00
|
|
|
last = eina_list_last(edf->collection_cache);
|
|
|
|
edc = eina_list_data_get(last);
|
|
|
|
edf->collection_cache = eina_list_remove_list(edf->collection_cache,
|
|
|
|
last);
|
2010-07-29 05:02:36 -07:00
|
|
|
|
|
|
|
ce = eina_hash_find(edf->collection, edc->part);
|
|
|
|
_edje_collection_free(edf, edc, ce);
|
2005-11-02 00:13:56 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
void
|
|
|
|
_edje_cache_coll_unref(Edje_File *edf, Edje_Part_Collection *edc)
|
|
|
|
{
|
2010-06-28 06:56:30 -07:00
|
|
|
Edje_Part_Collection_Directory_Entry *ce;
|
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
edc->references--;
|
|
|
|
if (edc->references != 0) return;
|
2010-06-28 06:56:30 -07:00
|
|
|
|
|
|
|
ce = eina_hash_find(edf->collection, edc->part);
|
2010-08-17 09:37:01 -07:00
|
|
|
if (!ce)
|
|
|
|
{
|
|
|
|
ERR("Something is wrong with reference count of '%s'.", edc->part);
|
|
|
|
}
|
|
|
|
else if (ce->ref)
|
2010-08-09 14:08:08 -07:00
|
|
|
{
|
|
|
|
ce->ref = NULL;
|
2010-09-08 06:45:21 -07:00
|
|
|
|
|
|
|
if (edf->dangling)
|
|
|
|
{
|
|
|
|
/* No need to keep the collection around if the file is dangling */
|
|
|
|
_edje_collection_free(edf, edc, ce);
|
|
|
|
_edje_cache_coll_flush(edf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edf->collection_cache = eina_list_prepend(edf->collection_cache, edc);
|
|
|
|
_edje_cache_coll_clean(edf);
|
|
|
|
}
|
2010-08-09 14:08:08 -07:00
|
|
|
}
|
2005-10-05 01:38:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_edje_cache_file_clean(void)
|
|
|
|
{
|
|
|
|
int count;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2008-10-22 04:34:42 -07:00
|
|
|
count = eina_list_count(_edje_file_cache);
|
2005-10-05 01:38:04 -07:00
|
|
|
while ((_edje_file_cache) && (count > _edje_file_cache_size))
|
|
|
|
{
|
2010-08-03 07:27:47 -07:00
|
|
|
Eina_List *last;
|
2005-10-05 01:38:04 -07:00
|
|
|
Edje_File *edf;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2010-08-03 07:27:47 -07:00
|
|
|
last = eina_list_last(_edje_file_cache);
|
|
|
|
edf = eina_list_data_get(last);
|
|
|
|
_edje_file_cache = eina_list_remove_list(_edje_file_cache, last);
|
2005-10-05 01:38:04 -07:00
|
|
|
_edje_file_free(edf);
|
2008-10-22 04:34:42 -07:00
|
|
|
count = eina_list_count(_edje_file_cache);
|
2005-10-05 01:38:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-16 02:43:26 -07:00
|
|
|
EAPI void
|
2005-10-05 01:38:04 -07:00
|
|
|
_edje_cache_file_unref(Edje_File *edf)
|
|
|
|
{
|
|
|
|
edf->references--;
|
|
|
|
if (edf->references != 0) return;
|
2008-12-17 06:26:47 -08:00
|
|
|
|
2010-02-26 19:47:04 -08:00
|
|
|
if (edf->dangling)
|
|
|
|
{
|
|
|
|
_edje_file_free(edf);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-08 17:37:55 -07:00
|
|
|
eina_hash_del(_edje_file_hash, edf->f, edf);
|
2008-12-17 06:26:47 -08:00
|
|
|
if (!eina_hash_population(_edje_file_hash))
|
|
|
|
{
|
|
|
|
eina_hash_free(_edje_file_hash);
|
|
|
|
_edje_file_hash = NULL;
|
|
|
|
}
|
2008-10-22 04:34:42 -07:00
|
|
|
_edje_file_cache = eina_list_prepend(_edje_file_cache, edf);
|
2005-10-05 01:38:04 -07:00
|
|
|
_edje_cache_file_clean();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_edje_file_cache_shutdown(void)
|
|
|
|
{
|
|
|
|
edje_file_cache_flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
/*============================================================================*
|
|
|
|
* Global *
|
|
|
|
*============================================================================*/
|
|
|
|
|
|
|
|
/*============================================================================*
|
|
|
|
* API *
|
|
|
|
*============================================================================*/
|
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void
|
2005-10-05 01:38:04 -07:00
|
|
|
edje_file_cache_set(int count)
|
|
|
|
{
|
|
|
|
if (count < 0) count = 0;
|
|
|
|
_edje_file_cache_size = count;
|
|
|
|
_edje_cache_file_clean();
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI int
|
2005-10-05 01:38:04 -07:00
|
|
|
edje_file_cache_get(void)
|
|
|
|
{
|
|
|
|
return _edje_file_cache_size;
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void
|
2005-10-05 01:38:04 -07:00
|
|
|
edje_file_cache_flush(void)
|
|
|
|
{
|
|
|
|
int ps;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
ps = _edje_file_cache_size;
|
|
|
|
_edje_file_cache_size = 0;
|
|
|
|
_edje_cache_file_clean();
|
|
|
|
_edje_file_cache_size = ps;
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void
|
2005-10-05 01:38:04 -07:00
|
|
|
edje_collection_cache_set(int count)
|
|
|
|
{
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Edje_File *edf;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
if (count < 0) count = 0;
|
|
|
|
_edje_collection_cache_size = count;
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(_edje_file_cache, l, edf)
|
|
|
|
_edje_cache_coll_clean(edf);
|
2005-10-05 01:38:04 -07:00
|
|
|
/* FIXME: freach in file hash too! */
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI int
|
2005-10-05 01:38:04 -07:00
|
|
|
edje_collection_cache_get(void)
|
|
|
|
{
|
|
|
|
return _edje_collection_cache_size;
|
|
|
|
}
|
|
|
|
|
2009-09-17 15:38:35 -07:00
|
|
|
|
2006-01-07 00:54:30 -08:00
|
|
|
EAPI void
|
2005-10-05 01:38:04 -07:00
|
|
|
edje_collection_cache_flush(void)
|
|
|
|
{
|
|
|
|
int ps;
|
2008-10-22 04:34:42 -07:00
|
|
|
Eina_List *l;
|
|
|
|
Edje_File *edf;
|
2007-09-08 11:31:56 -07:00
|
|
|
|
2005-10-05 01:38:04 -07:00
|
|
|
ps = _edje_collection_cache_size;
|
|
|
|
_edje_collection_cache_size = 0;
|
2008-10-22 04:34:42 -07:00
|
|
|
EINA_LIST_FOREACH(_edje_file_cache, l, edf)
|
|
|
|
_edje_cache_coll_flush(edf);
|
2005-10-05 01:38:04 -07:00
|
|
|
/* FIXME: freach in file hash too! */
|
|
|
|
_edje_collection_cache_size = ps;
|
|
|
|
}
|