forked from enlightenment/efl
Move to eina_hash. Nothing should break, but if you experience any unexpected behaviour
please ping me on #edevelop. SVN revision: 38183
This commit is contained in:
parent
05af27f999
commit
e33474c92f
|
@ -30,6 +30,19 @@ _edje_str_direct_free(const char *str)
|
|||
{
|
||||
}
|
||||
|
||||
static void *
|
||||
_edje_eina_hash_add_alloc(void *hash, const char *key, void *data)
|
||||
{
|
||||
Eina_Hash *result = hash;
|
||||
|
||||
if (!result) result = eina_hash_string_small_new(NULL);
|
||||
if (!result) return NULL;
|
||||
|
||||
eina_hash_add(result, key, data);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
source_edd(void)
|
||||
{
|
||||
|
@ -38,15 +51,15 @@ source_edd(void)
|
|||
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
|
||||
eddc.func.mem_alloc = NULL;
|
||||
eddc.func.mem_free = NULL;
|
||||
eddc.func.str_alloc = (char *(*)(const char *))eina_stringshare_add;
|
||||
eddc.func.str_free = (void (*)(const char *))eina_stringshare_del;
|
||||
eddc.func.list_next = (void *(*)(void *))eina_list_next;
|
||||
eddc.func.list_append = (void *(*)(void *, void *))eina_list_append;
|
||||
eddc.func.list_data = (void *(*)(void *))eina_list_data_get;
|
||||
eddc.func.list_free = (void *(*)(void *))eina_list_free;
|
||||
eddc.func.hash_foreach = (void (*)(void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach;
|
||||
eddc.func.hash_add = (void *(*)(void *, const char *, void *))evas_hash_add;
|
||||
eddc.func.hash_free = (void (*)(void *))evas_hash_free;
|
||||
eddc.func.str_alloc = eina_stringshare_add;
|
||||
eddc.func.str_free = eina_stringshare_del;
|
||||
eddc.func.list_next = eina_list_next;
|
||||
eddc.func.list_append = eina_list_append;
|
||||
eddc.func.list_data = eina_list_data_get;
|
||||
eddc.func.list_free = eina_list_free;
|
||||
eddc.func.hash_foreach = eina_hash_foreach;
|
||||
eddc.func.hash_add = _edje_eina_hash_add_alloc;
|
||||
eddc.func.hash_free = eina_hash_free;
|
||||
eddc.func.str_direct_alloc = _edje_str_direct_alloc;
|
||||
eddc.func.str_direct_free = _edje_str_direct_free;
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ void *alloca (size_t);
|
|||
|
||||
#include "edje_private.h"
|
||||
|
||||
static Eina_Hash *_edje_file_hash = NULL;
|
||||
static Evas_Hash *_edje_file_hash = NULL;
|
||||
static int _edje_file_cache_size = 16;
|
||||
static Eina_List *_edje_file_cache = NULL;
|
||||
|
||||
|
@ -69,7 +69,9 @@ _edje_file_coll_open(Edje_File *edf, const char *coll)
|
|||
|
||||
edc->part = eina_stringshare_add(coll);
|
||||
edc->references = 1;
|
||||
edf->collection_hash = evas_hash_add(edf->collection_hash, coll, edc);
|
||||
if (!edf->collection_hash)
|
||||
edf->collection_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(edf->collection_hash, coll, edc);
|
||||
return edc;
|
||||
}
|
||||
|
||||
|
@ -78,6 +80,9 @@ _edje_font_hash(Edje_File *edf)
|
|||
{
|
||||
int count = 0;
|
||||
|
||||
if (!edf->font_hash)
|
||||
edf->font_hash = eina_hash_string_superfast_new(NULL);
|
||||
|
||||
if (edf->font_dir)
|
||||
{
|
||||
Eina_List *l;
|
||||
|
@ -96,7 +101,7 @@ _edje_font_hash(Edje_File *edf)
|
|||
if (edf->free_strings)
|
||||
eina_stringshare_del(fnt->entry);
|
||||
fnt->entry = fnt->path + 6;
|
||||
edf->font_hash = evas_hash_direct_add(edf->font_hash, fnt->entry, fnt);
|
||||
eina_hash_direct_add(edf->font_hash, fnt->entry, fnt);
|
||||
|
||||
count++;
|
||||
}
|
||||
|
@ -156,8 +161,10 @@ _edje_file_open(const char *file, const char *coll, int *error_ret, Edje_Part_Co
|
|||
|
||||
_edje_textblock_style_parse_and_fix(edf);
|
||||
|
||||
if (!edf->data_cache)
|
||||
edf->data_cache = eina_hash_string_superfast_new(NULL);
|
||||
EINA_LIST_FOREACH(edf->data, l, di)
|
||||
edf->data_cache = evas_hash_add(edf->data_cache, eina_stringshare_add(di->key), di->value);
|
||||
eina_hash_add(edf->data_cache, di->key, di->value);
|
||||
|
||||
if (coll)
|
||||
{
|
||||
|
@ -184,10 +191,15 @@ _edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, E
|
|||
Edje_Part_Collection *edc;
|
||||
Edje_Part *ep;
|
||||
|
||||
edf = evas_hash_find(_edje_file_hash, file);
|
||||
if (!_edje_file_hash)
|
||||
_edje_file_hash = eina_hash_string_superfast_new(NULL);
|
||||
edf = eina_hash_find(_edje_file_hash, file);
|
||||
|
||||
if (edf)
|
||||
{
|
||||
edf->references++;
|
||||
if (!edf->collection_hash)
|
||||
edf->collection_hash = eina_hash_string_superfast_new(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -197,7 +209,7 @@ _edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, E
|
|||
{
|
||||
edf->references = 1;
|
||||
_edje_file_cache = eina_list_remove_list(_edje_file_cache, l);
|
||||
_edje_file_hash = evas_hash_add(_edje_file_hash, file, edf);
|
||||
eina_hash_add(_edje_file_hash, file, edf);
|
||||
break;
|
||||
}
|
||||
edf = NULL;
|
||||
|
@ -207,13 +219,13 @@ _edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, E
|
|||
{
|
||||
edf = _edje_file_open(file, coll, error_ret, edc_ret);
|
||||
if (!edf) return NULL;
|
||||
_edje_file_hash = evas_hash_add(_edje_file_hash, file, edf);
|
||||
eina_hash_add(_edje_file_hash, file, edf);
|
||||
return edf;
|
||||
}
|
||||
|
||||
if (!coll) return edf;
|
||||
|
||||
edc = evas_hash_find(edf->collection_hash, coll);
|
||||
edc = eina_hash_find(edf->collection_hash, coll);
|
||||
if (edc)
|
||||
{
|
||||
edc->references++;
|
||||
|
@ -226,7 +238,7 @@ _edje_cache_file_coll_open(const char *file, const char *coll, int *error_ret, E
|
|||
{
|
||||
edc->references = 1;
|
||||
edf->collection_cache = eina_list_remove_list(edf->collection_cache, l);
|
||||
edf->collection_hash = evas_hash_add(edf->collection_hash, coll, edc);
|
||||
eina_hash_add(edf->collection_hash, coll, edc);
|
||||
break;
|
||||
}
|
||||
edc = NULL;
|
||||
|
@ -345,7 +357,12 @@ _edje_cache_coll_unref(Edje_File *edf, Edje_Part_Collection *edc)
|
|||
{
|
||||
edc->references--;
|
||||
if (edc->references != 0) return;
|
||||
edf->collection_hash = evas_hash_del(edf->collection_hash, edc->part, edc);
|
||||
eina_hash_del(edf->collection_hash, edc->part, edc);
|
||||
if (!eina_hash_population(edf->collection_hash))
|
||||
{
|
||||
eina_hash_free(edf->collection_hash);
|
||||
edf->collection_hash = NULL;
|
||||
}
|
||||
edf->collection_cache = eina_list_prepend(edf->collection_cache, edc);
|
||||
_edje_cache_coll_clean(edf);
|
||||
}
|
||||
|
@ -372,7 +389,13 @@ _edje_cache_file_unref(Edje_File *edf)
|
|||
{
|
||||
edf->references--;
|
||||
if (edf->references != 0) return;
|
||||
_edje_file_hash = evas_hash_del(_edje_file_hash, edf->path, edf);
|
||||
|
||||
eina_hash_del(_edje_file_hash, edf->path, edf);
|
||||
if (!eina_hash_population(_edje_file_hash))
|
||||
{
|
||||
eina_hash_free(_edje_file_hash);
|
||||
_edje_file_hash = NULL;
|
||||
}
|
||||
_edje_file_cache = eina_list_prepend(_edje_file_cache, edf);
|
||||
_edje_cache_file_clean();
|
||||
}
|
||||
|
|
|
@ -777,7 +777,7 @@ _edje_part_recalc_single(Edje *ed,
|
|||
{
|
||||
Edje_Font_Directory_Entry *fnt;
|
||||
|
||||
fnt = evas_hash_find(ed->file->font_hash, font);
|
||||
fnt = eina_hash_find(ed->file->font_hash, font);
|
||||
|
||||
if (fnt)
|
||||
{
|
||||
|
|
|
@ -75,6 +75,16 @@ _edje_str_direct_free(const char *str)
|
|||
{
|
||||
}
|
||||
|
||||
static Eina_Hash *
|
||||
_edje_eina_hash_add_alloc(Eina_Hash *hash, const char *key, void *data)
|
||||
{
|
||||
if (!hash) hash = eina_hash_string_small_new(NULL);
|
||||
if (!hash) return NULL;
|
||||
|
||||
eina_hash_add(hash, key, data);
|
||||
return hash;
|
||||
}
|
||||
|
||||
void
|
||||
_edje_edd_setup(void)
|
||||
{
|
||||
|
@ -89,9 +99,9 @@ _edje_edd_setup(void)
|
|||
eddc.func.list_append = (void *(*)(void *, void *))eina_list_append;
|
||||
eddc.func.list_data = (void *(*)(void *))eina_list_data_get;
|
||||
eddc.func.list_free = (void *(*)(void *))eina_list_free;
|
||||
eddc.func.hash_foreach = (void (*)(void *, int (*)(void *, const char *, void *, void *), void *))evas_hash_foreach;
|
||||
eddc.func.hash_add = (void *(*)(void *, const char *, void *))evas_hash_add;
|
||||
eddc.func.hash_free = (void (*)(void *))evas_hash_free;
|
||||
eddc.func.hash_foreach = (void (*)(const Eina_Hash *, Eina_Bool (*)(const Eina_Hash *, const void *, void *, void *), void *))eina_hash_foreach;
|
||||
eddc.func.hash_add = (Eina_Hash* (*)(Eina_Hash *, const char *, void *)) _edje_eina_hash_add_alloc;
|
||||
eddc.func.hash_free = (void (*)(void *))eina_hash_free;
|
||||
eddc.func.str_direct_alloc = _edje_str_direct_alloc;
|
||||
eddc.func.str_direct_free = _edje_str_direct_free;
|
||||
|
||||
|
|
|
@ -716,7 +716,9 @@ edje_edit_group_add(Evas_Object *obj, const char *name)
|
|||
//cd = mem_alloc(SZ(Code));
|
||||
//codes = eina_list_append(codes, cd);
|
||||
|
||||
ed->file->collection_hash = evas_hash_add(ed->file->collection_hash, name, pc);
|
||||
if (!ed->file->collection_hash)
|
||||
ed->file->collection_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(ed->file->collection_hash, name, pc);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -828,10 +830,12 @@ edje_edit_group_name_set(Evas_Object *obj, const char *new_name)
|
|||
{
|
||||
if (pc->id == pce->id)
|
||||
{
|
||||
ed->file->collection_hash = evas_hash_del(ed->file->collection_hash,
|
||||
pce->entry, NULL);
|
||||
ed->file->collection_hash = evas_hash_add(ed->file->collection_hash,
|
||||
new_name, pc);
|
||||
eina_hash_del(ed->file->collection_hash,
|
||||
pce->entry, NULL);
|
||||
if (!ed->file->collection_hash)
|
||||
ed->file->collection_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(ed->file->collection_hash,
|
||||
new_name, pc);
|
||||
|
||||
//if (pce->entry && //TODO Also this cause segv
|
||||
// !eet_dictionary_string_check(eet_dictionary_get(ed->file->ef), pce->entry))
|
||||
|
@ -1295,7 +1299,7 @@ EAPI Eina_List *
|
|||
edje_edit_style_tags_list_get(Evas_Object * obj, const char* style)
|
||||
{
|
||||
Eina_List *tags = NULL;
|
||||
Eina_List *ll;
|
||||
Eina_List *l, *ll;
|
||||
Edje_Style *s;
|
||||
Edje_Style_Tag *t;
|
||||
|
||||
|
@ -3310,7 +3314,9 @@ edje_edit_font_add(Evas_Object *obj, const char* path)
|
|||
fnt->path = mem_strdup(buf);
|
||||
|
||||
ed->file->font_dir->entries = eina_list_append(ed->file->font_dir->entries, fnt);
|
||||
ed->file->font_hash = evas_hash_direct_add(ed->file->font_hash, fnt->entry, fnt);
|
||||
if (!ed->file->font_hash)
|
||||
ed->file->font_hash = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_direct_add(ed->file->font_hash, fnt->entry, fnt);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -5397,6 +5403,20 @@ _edje_edit_str_direct_free(const char *str)
|
|||
{
|
||||
}
|
||||
|
||||
static void *
|
||||
_edje_eina_hash_add_alloc(void *hash, const void *key, void *data)
|
||||
{
|
||||
Eina_Hash *result = hash;
|
||||
|
||||
if (!result) result = eina_hash_string_small_new(NULL);
|
||||
if (!result) return NULL;
|
||||
|
||||
eina_hash_add(result, key, data);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static Eet_Data_Descriptor *_srcfile_edd = NULL;
|
||||
static Eet_Data_Descriptor *_srcfile_list_edd = NULL;
|
||||
|
||||
|
@ -5408,15 +5428,15 @@ source_edd(void)
|
|||
eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
|
||||
eddc.func.mem_alloc = NULL;
|
||||
eddc.func.mem_free = NULL;
|
||||
eddc.func.str_alloc = (char *(*)(const char *))eina_stringshare_add;
|
||||
eddc.func.str_free = (void (*)(const char *))eina_stringshare_del;
|
||||
eddc.func.list_next = (void *(*)(void *))eina_list_next;
|
||||
eddc.func.list_append = (void *(*)(void *, void *))eina_list_append;
|
||||
eddc.func.list_data = (void *(*)(void *))eina_list_data_get;
|
||||
eddc.func.list_free = (void *(*)(void *))eina_list_free;
|
||||
eddc.func.hash_foreach = (void (*)(void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach;
|
||||
eddc.func.hash_add = (void *(*)(void *, const char *, void *))evas_hash_add;
|
||||
eddc.func.hash_free = (void (*)(void *))evas_hash_free;
|
||||
eddc.func.str_alloc = eina_stringshare_add;
|
||||
eddc.func.str_free = eina_stringshare_del;
|
||||
eddc.func.list_next = eina_list_next;
|
||||
eddc.func.list_append = eina_list_append;
|
||||
eddc.func.list_data = eina_list_data_get;
|
||||
eddc.func.list_free = eina_list_free;
|
||||
eddc.func.hash_foreach = eina_hash_foreach;
|
||||
eddc.func.hash_add = _edje_eina_hash_add_alloc;
|
||||
eddc.func.hash_free = eina_hash_free;
|
||||
eddc.func.str_direct_alloc = _edje_edit_str_direct_alloc;
|
||||
eddc.func.str_direct_free = _edje_edit_str_direct_free;
|
||||
|
||||
|
|
|
@ -855,6 +855,11 @@ _edje_file_free(Edje_File *edf)
|
|||
}
|
||||
free(edf->font_dir);
|
||||
}
|
||||
if (edf->font_hash)
|
||||
{
|
||||
eina_hash_free(edf->font_hash);
|
||||
edf->font_hash = NULL;
|
||||
}
|
||||
if (edf->image_dir)
|
||||
{
|
||||
while (edf->image_dir->entries)
|
||||
|
|
|
@ -255,10 +255,10 @@ struct _Edje_File
|
|||
int version;
|
||||
int feature_ver;
|
||||
|
||||
Evas_Hash *collection_hash;
|
||||
Evas_Hash *font_hash;
|
||||
Eina_Hash *collection_hash;
|
||||
Eina_Hash *font_hash;
|
||||
Eina_List *collection_cache;
|
||||
Evas_Hash *data_cache;
|
||||
Eina_Hash *data_cache;
|
||||
|
||||
Eet_File *ef;
|
||||
|
||||
|
@ -433,8 +433,8 @@ struct _Edje_Part_Collection
|
|||
int references;
|
||||
#ifdef EDJE_PROGRAM_CACHE
|
||||
struct {
|
||||
Evas_Hash *no_matches;
|
||||
Evas_Hash *matches;
|
||||
Eina_Hash *no_matches;
|
||||
Eina_Hash *matches;
|
||||
} prog_cache;
|
||||
#endif
|
||||
|
||||
|
@ -880,7 +880,7 @@ struct _Edje_Var_List
|
|||
|
||||
struct _Edje_Var_Hash
|
||||
{
|
||||
Evas_Hash *v;
|
||||
Eina_Hash *v;
|
||||
};
|
||||
|
||||
struct _Edje_Var_Timer
|
||||
|
|
|
@ -933,11 +933,11 @@ _edje_emit_handle(Edje *ed, const char *sig, const char *src)
|
|||
Eina_List *l;
|
||||
Edje_Program *pr;
|
||||
|
||||
if (evas_hash_find(ec->prog_cache.no_matches, tmps))
|
||||
if (eina_hash_find(ec->prog_cache.no_matches, tmps))
|
||||
{
|
||||
done = 1;
|
||||
}
|
||||
else if ((matches = evas_hash_find(ec->prog_cache.matches, tmps)))
|
||||
else if ((matches = eina_hash_find(ec->prog_cache.matches, tmps)))
|
||||
{
|
||||
EINA_LIST_FOREACH(matches, l, pr)
|
||||
{
|
||||
|
@ -988,11 +988,17 @@ _edje_emit_handle(Edje *ed, const char *sig, const char *src)
|
|||
if (tmps)
|
||||
{
|
||||
if (data.matched == 0)
|
||||
ec->prog_cache.no_matches =
|
||||
evas_hash_add(ec->prog_cache.no_matches, tmps, ed);
|
||||
{
|
||||
if (!ec->prog_cache.no_matches)
|
||||
ec->prog_cache.no_matches = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(ec->prog_cache.no_matches, tmps, ed);
|
||||
}
|
||||
else
|
||||
ec->prog_cache.matches =
|
||||
evas_hash_add(ec->prog_cache.matches, tmps, data.matches);
|
||||
{
|
||||
if (!ec->prog_cache.matches)
|
||||
ec->prog_cache.matches = eina_hash_string_superfast_new(NULL);
|
||||
eina_hash_add(ec->prog_cache.matches, tmps, data.matches);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -359,7 +359,7 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
|
|||
/* check if the font is embedded in the .eet */
|
||||
if (ed->file->font_hash)
|
||||
{
|
||||
Edje_Font_Directory_Entry *fnt = evas_hash_find(ed->file->font_hash, font);
|
||||
Edje_Font_Directory_Entry *fnt = eina_hash_find(ed->file->font_hash, font);
|
||||
|
||||
if (fnt)
|
||||
{
|
||||
|
|
|
@ -20,11 +20,11 @@ struct _Edje_Box_Layout
|
|||
typedef struct _Edje_Box_Layout Edje_Box_Layout;
|
||||
|
||||
|
||||
static Eina_Hash *_edje_color_class_hash = NULL;
|
||||
static Eina_Hash *_edje_color_class_member_hash = NULL;
|
||||
static Evas_Hash *_edje_color_class_hash = NULL;
|
||||
static Evas_Hash *_edje_color_class_member_hash = NULL;
|
||||
|
||||
static Eina_Hash *_edje_text_class_hash = NULL;
|
||||
static Eina_Hash *_edje_text_class_member_hash = NULL;
|
||||
static Evas_Hash *_edje_text_class_hash = NULL;
|
||||
static Evas_Hash *_edje_text_class_member_hash = NULL;
|
||||
|
||||
static Eina_Rbtree *_edje_box_layout_registry = NULL;
|
||||
|
||||
|
@ -40,8 +40,8 @@ struct _Edje_List_Foreach_Data
|
|||
Eina_List *list;
|
||||
};
|
||||
|
||||
static Eina_Bool _edje_color_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata);
|
||||
static Eina_Bool _edje_text_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata);
|
||||
static Evas_Bool _edje_color_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata);
|
||||
static Evas_Bool _edje_text_class_list_foreach(const Eina_Hash *hash, const void *key, void *data, void *fdata);
|
||||
|
||||
Edje_Real_Part *_edje_real_part_recursive_get_helper(Edje *ed, char **path);
|
||||
|
||||
|
|
Loading…
Reference in New Issue