aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2009-09-03 12:05:49 +0000
committerCedric BAIL <cedric.bail@free.fr>2009-09-03 12:05:49 +0000
commit33e754e63ef70a831ed229a9890499c132fb4529 (patch)
treee46b8ef1dd4badcd5b8c537eadcbd306f563e03d /src
parentEAPI, again :-) (diff)
downloadenlightenment-33e754e63ef70a831ed229a9890499c132fb4529.tar.gz
* e: Use new and cleaner eet API.
Note: The situation regarding string from config file could be improved. We could use the same trick as Edje and directly map the string from Eet config file. This will improve memory used by E, if string from config file are used a lot. So the question is : "Do we save a lot of string in config file ?" SVN revision: 42201
Diffstat (limited to 'src')
-rw-r--r--src/bin/e_config_data.c28
-rw-r--r--src/bin/e_config_data.h9
-rw-r--r--src/bin/e_fm_custom.c30
-rw-r--r--src/bin/e_fm_shared.h42
-rw-r--r--src/bin/e_ipc_codec.c81
5 files changed, 63 insertions, 127 deletions
diff --git a/src/bin/e_config_data.c b/src/bin/e_config_data.c
index d15699b7f..2e6010323 100644
--- a/src/bin/e_config_data.c
+++ b/src/bin/e_config_data.c
@@ -7,23 +7,15 @@ EAPI E_Config_DD *
e_config_descriptor_new(const char *name, int size)
{
Eet_Data_Descriptor_Class eddc;
-
- 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 *l, void *d)) 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 (*) (const Eina_Hash *, Eina_Bool (*) (const Eina_Hash *, const void *, void *, void *), const void *))
- eina_hash_foreach;
- eddc.func.hash_add = (Eina_Hash* (*) (Eina_Hash *, const void *, void *)) eet_eina_hash_add_alloc;
- eddc.func.hash_free = (void (*) (Eina_Hash *)) eina_hash_free;
- eddc.name = name;
- eddc.size = size;
- return (E_Config_DD *)eet_data_descriptor2_new(&eddc);
+
+ if (!eet_eina_file_data_descriptor_class_set(&eddc, name, size))
+ return NULL;
+
+ /* FIXME: We can directly map string inside an Eet_File as we
+ need to change every config destructor in E for that. */
+ eddc.func.str_direct_alloc = NULL;
+ eddc.func.str_direct_free = NULL;
+
+ return (E_Config_DD *) eet_data_descriptor_file_new(&eddc);
}
diff --git a/src/bin/e_config_data.h b/src/bin/e_config_data.h
index 0a38dea02..d27e4f826 100644
--- a/src/bin/e_config_data.h
+++ b/src/bin/e_config_data.h
@@ -29,15 +29,6 @@ typedef Eet_Data_Descriptor E_Config_DD;
#ifndef E_CONFIG_DATA_H
#define E_CONFIG_DATA_H
-static inline Eina_Hash *
-eet_eina_hash_add_alloc(Eina_Hash *hash, const void *key, void *data)
-{
- if (!hash) hash = eina_hash_string_superfast_new(NULL);
- if (!hash) return NULL;
- eina_hash_add(hash, key, data);
- return hash;
-}
-
EAPI E_Config_DD *e_config_descriptor_new(const char *name, int size);
#endif
diff --git a/src/bin/e_fm_custom.c b/src/bin/e_fm_custom.c
index 783f788c1..4af6c35d8 100644
--- a/src/bin/e_fm_custom.c
+++ b/src/bin/e_fm_custom.c
@@ -37,26 +37,15 @@ e_fm2_custom_file_init(void)
_e_fm2_custom_init++;
if (_e_fm2_custom_init > 1) return _e_fm2_custom_init;
- _e_fm2_custom_hash = eina_hash_string_superfast_new(NULL);
+ if (!eet_eina_stream_data_descriptor_class_set(&eddc, "e_fm2_custom_dir", sizeof (E_Fm2_Custom_Dir)))
+ {
+ _e_fm2_custom_init--;
+ return 0;
+ }
- 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 *l, void *d)) 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 *))
- eina_hash_foreach;
- eddc.func.hash_add = (void* (*) (void *, const char *, void *)) eet_eina_hash_add_alloc;
- eddc.func.hash_free = (void (*) (void *)) eina_hash_free;
- eddc.name = "e_fm_custom_file";
- eddc.size = sizeof(E_Fm2_Custom_File);
+ _e_fm2_custom_hash = eina_hash_string_superfast_new(NULL);
- _e_fm2_custom_dir_edd = eet_data_descriptor2_new(&eddc);
+ _e_fm2_custom_dir_edd = eet_data_descriptor_stream_new(&eddc);
#define DAT(x, y, z) EET_DATA_DESCRIPTOR_ADD_BASIC(_e_fm2_custom_dir_edd, E_Fm2_Custom_Dir, x, y, z)
DAT("pos.x", pos.x, EET_T_DOUBLE);
DAT("pos.y", pos.y, EET_T_DOUBLE);
@@ -67,7 +56,10 @@ e_fm2_custom_file_init(void)
DAT("prop.in_use", prop.in_use, EET_T_UCHAR);
#undef DAT
- _e_fm2_custom_file_edd = eet_data_descriptor2_new(&eddc);
+ eddc.size = sizeof (E_Fm2_Custom_File);
+ eddc.name = "e_fm_custom_file";
+
+ _e_fm2_custom_file_edd = eet_data_descriptor_stream_new(&eddc);
#define DAT(x, y, z) EET_DATA_DESCRIPTOR_ADD_BASIC(_e_fm2_custom_file_edd, E_Fm2_Custom_File, x, y, z)
DAT("g.x", geom.x, EET_T_INT);
DAT("g.y", geom.y, EET_T_INT);
diff --git a/src/bin/e_fm_shared.h b/src/bin/e_fm_shared.h
index 3324af384..1e1565991 100644
--- a/src/bin/e_fm_shared.h
+++ b/src/bin/e_fm_shared.h
@@ -123,23 +123,10 @@ _e_volume_edd_new(void)
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
- eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
- eddc.func.mem_alloc = NULL;
- eddc.func.mem_free = NULL;
- eddc.func.str_alloc = (char *(*)(const char *)) strdup;
- eddc.func.str_free = (void (*)(const char *)) free;
- eddc.func.list_next = (void *(*)(void *)) eina_list_next;
- eddc.func.list_append = (void *(*)(void *l, void *d)) eina_list_append;
- eddc.func.list_data = (void *(*)(void *)) eina_list_data_get;
- eddc.func.hash_foreach =
- (void (*) (void *, int (*) (void *, const char *, void *, void *), void *))
- eina_hash_foreach;
- eddc.func.hash_add = (void* (*) (void *, const char *, void *)) eet_eina_hash_add_alloc;
- eddc.func.hash_free = (void (*) (void *)) eina_hash_free;
- eddc.name = "e_volume";
- eddc.size = sizeof(E_Volume);
-
- edd = eet_data_descriptor2_new(&eddc);
+ if (!eet_eina_stream_data_descriptor_class_set(&eddc, "e_volume", sizeof (E_Volume)))
+ return NULL;
+
+ edd = eet_data_descriptor_stream_new(&eddc);
#define DAT(x, y, z) EET_DATA_DESCRIPTOR_ADD_BASIC(edd, E_Volume, x, y, z)
DAT("type", type, EET_T_INT);
DAT("udi", udi, EET_T_STRING);
@@ -164,23 +151,10 @@ _e_storage_edd_new(void)
Eet_Data_Descriptor *edd;
Eet_Data_Descriptor_Class eddc;
- eddc.version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
- eddc.func.mem_alloc = NULL;
- eddc.func.mem_free = NULL;
- eddc.func.str_alloc = (char *(*)(const char *)) strdup;
- eddc.func.str_free = (void (*)(const char *)) free;
- eddc.func.list_next = (void *(*)(void *)) eina_list_next;
- eddc.func.list_append = (void *(*)(void *l, void *d)) eina_list_append;
- eddc.func.list_data = (void *(*)(void *)) eina_list_data_get;
- eddc.func.hash_foreach =
- (void (*) (void *, int (*) (void *, const char *, void *, void *), void *))
- eina_hash_foreach;
- eddc.func.hash_add = (void* (*) (void *, const char *, void *)) eet_eina_hash_add_alloc;
- eddc.func.hash_free = (void (*) (Eina_Hash *)) eina_hash_free;
- eddc.name = "e_storage";
- eddc.size = sizeof(E_Storage);
-
- edd = eet_data_descriptor2_new(&eddc);
+ if (!eet_eina_stream_data_descriptor_class_set(&eddc, "e_storage", sizeof (E_Storage)))
+ return NULL;
+
+ edd = eet_data_descriptor_stream_new(&eddc);
#define DAT(x, y, z) EET_DATA_DESCRIPTOR_ADD_BASIC(edd, E_Storage, x, y, z)
DAT("type", type, EET_T_INT);
DAT("udi", udi, EET_T_STRING);
diff --git a/src/bin/e_ipc_codec.c b/src/bin/e_ipc_codec.c
index ade749f02..5a8f12202 100644
--- a/src/bin/e_ipc_codec.c
+++ b/src/bin/e_ipc_codec.c
@@ -28,71 +28,58 @@ static Eet_Data_Descriptor *_e_ipc_3int_3str_list_edd = NULL;
static Eet_Data_Descriptor *_e_ipc_str_4int_edd = NULL;
static Eet_Data_Descriptor *_e_ipc_str_4int_list_edd = NULL;
-static void *
-_e_ipc_codec_eina_hash_add(void *hash, const void *key, void *data)
-{
- Eina_Hash *result = hash;
-
- if (!result) result = eina_hash_string_superfast_new(NULL);
- if (!result) return NULL;
-
- eina_hash_add(result, key, data);
- return result;
-}
-
-#define E_IPC_DD_NEW(str, typ) \
- eet_data_descriptor_new(str, sizeof(typ), \
- (void *(*) (void *))eina_list_next, \
- (void *(*) (void *, void *))eina_list_append, \
- (void *(*) (void *))eina_list_data_get, \
- (void *(*) (void *))eina_list_free, \
- (void (*) (void *, int (*) (void *, const char *, void *, void *), void *))eina_hash_foreach, \
- (void *(*) (void *, const char *, void *))_e_ipc_codec_eina_hash_add, \
- (void (*) (void *))eina_hash_free)
+#define E_IPC_DD(Edd, Eddc, Name, Type) \
+ Eddc.name = Name; \
+ Eddc.size = sizeof (Type); \
+ Edd = eet_data_descriptor_stream_new(&Eddc);
/* externally accessible functions */
EAPI int
e_ipc_codec_init(void)
{
- _e_ipc_int_edd = E_IPC_DD_NEW("int", E_Ipc_Int);
+ Eet_Data_Descriptor_Class eddc;
+
+ if (!eet_eina_stream_data_descriptor_class_set(&eddc, "int", sizeof (E_Ipc_Int)))
+ return 0;
+ _e_ipc_int_edd = eet_data_descriptor_stream_new(&eddc);
E_CONFIG_VAL(_e_ipc_int_edd, E_Ipc_Int, val, INT);
- _e_ipc_double_edd = E_IPC_DD_NEW("double", E_Ipc_Double);
+ E_IPC_DD(_e_ipc_double_edd, eddc, "double", E_Ipc_Double);
E_CONFIG_VAL(_e_ipc_double_edd, E_Ipc_Double, val, DOUBLE);
-
- _e_ipc_2int_edd = E_IPC_DD_NEW("2int", E_Ipc_2Int);
+
+ E_IPC_DD(_e_ipc_2int_edd, eddc, "2int", E_Ipc_2Int);
E_CONFIG_VAL(_e_ipc_2int_edd, E_Ipc_2Int, val1, INT);
E_CONFIG_VAL(_e_ipc_2int_edd, E_Ipc_2Int, val2, INT);
- _e_ipc_str_edd = E_IPC_DD_NEW("str", E_Ipc_Str);
+ E_IPC_DD(_e_ipc_str_edd, eddc, "str", E_Ipc_Str);
E_CONFIG_VAL(_e_ipc_str_edd, E_Ipc_Str, str, STR);
- _e_ipc_str_list_edd = E_IPC_DD_NEW("str_list", E_Ipc_List);
+ E_IPC_DD(_e_ipc_str_list_edd, eddc, "str_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_str_list_edd, E_Ipc_List, list, _e_ipc_str_edd);
- _e_ipc_2str_edd = E_IPC_DD_NEW("2str", E_Ipc_2Str);
+ E_IPC_DD(_e_ipc_2str_edd, eddc, "2str", E_Ipc_2Str);
E_CONFIG_VAL(_e_ipc_2str_edd, E_Ipc_2Str, str1, STR);
E_CONFIG_VAL(_e_ipc_2str_edd, E_Ipc_2Str, str2, STR);
-
- _e_ipc_2str_list_edd = E_IPC_DD_NEW("2str_list", E_Ipc_List);
+
+ E_IPC_DD(_e_ipc_2str_list_edd, eddc, "2str_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_2str_list_edd, E_Ipc_List, list, _e_ipc_2str_edd);
- _e_ipc_str_int_edd = E_IPC_DD_NEW("str_int", E_Ipc_Str_Int);
+ E_IPC_DD(_e_ipc_str_int_edd, eddc, "str_int", E_Ipc_Str_Int);
E_CONFIG_VAL(_e_ipc_str_int_edd, E_Ipc_Str_Int, str, STR);
E_CONFIG_VAL(_e_ipc_str_int_edd, E_Ipc_Str_Int, val, INT);
-
- _e_ipc_str_int_list_edd = E_IPC_DD_NEW("str_int_list", E_Ipc_List);
+
+ E_IPC_DD(_e_ipc_str_int_list_edd, eddc, "str_int_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_str_int_list_edd, E_Ipc_List, list, _e_ipc_str_int_edd);
- _e_ipc_2str_int_edd = E_IPC_DD_NEW("2str_int", E_Ipc_2Str_Int);
+ E_IPC_DD(_e_ipc_2str_int_edd, eddc, "2str_int", E_Ipc_2Str_Int);
E_CONFIG_VAL(_e_ipc_2str_int_edd, E_Ipc_2Str_Int, str1, STR);
E_CONFIG_VAL(_e_ipc_2str_int_edd, E_Ipc_2Str_Int, str2, STR);
E_CONFIG_VAL(_e_ipc_2str_int_edd, E_Ipc_2Str_Int, val, INT);
-
- _e_ipc_2str_int_list_edd = E_IPC_DD_NEW("2str_int_list", E_Ipc_List);
+
+ E_IPC_DD(_e_ipc_2str_int_list_edd, eddc, "2str_int_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_2str_int_list_edd, E_Ipc_List, list, _e_ipc_2str_int_edd);
-
- _e_ipc_4int_2str_edd = E_IPC_DD_NEW("4int_2str", E_Ipc_4Int_2Str);
+
+ E_IPC_DD(_e_ipc_4int_2str_edd, eddc, "4int_2str", E_Ipc_4Int_2Str);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, val1, INT);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, val2, INT);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, val3, INT);
@@ -100,10 +87,10 @@ e_ipc_codec_init(void)
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, str1, STR);
E_CONFIG_VAL(_e_ipc_4int_2str_edd, E_Ipc_4Int_2Str, str2, STR);
- _e_ipc_4int_2str_list_edd = E_IPC_DD_NEW("4int_2str_list", E_Ipc_List);
+ E_IPC_DD(_e_ipc_4int_2str_list_edd, eddc, "4int_2str_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_4int_2str_list_edd, E_Ipc_List, list, _e_ipc_4int_2str_edd);
- _e_ipc_5int_2str_edd = E_IPC_DD_NEW("5int_2str", E_Ipc_5Int_2Str);
+ E_IPC_DD(_e_ipc_5int_2str_edd, eddc, "5int_2str", E_Ipc_5Int_2Str);
E_CONFIG_VAL(_e_ipc_5int_2str_edd, E_Ipc_5Int_2Str, val1, INT);
E_CONFIG_VAL(_e_ipc_5int_2str_edd, E_Ipc_5Int_2Str, val2, INT);
E_CONFIG_VAL(_e_ipc_5int_2str_edd, E_Ipc_5Int_2Str, val3, INT);
@@ -112,10 +99,10 @@ e_ipc_codec_init(void)
E_CONFIG_VAL(_e_ipc_5int_2str_edd, E_Ipc_5Int_2Str, str1, STR);
E_CONFIG_VAL(_e_ipc_5int_2str_edd, E_Ipc_5Int_2Str, str2, STR);
- _e_ipc_5int_2str_list_edd = E_IPC_DD_NEW("5int_2str_list", E_Ipc_List);
+ E_IPC_DD(_e_ipc_5int_2str_list_edd, eddc, "5int_2str_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_5int_2str_list_edd, E_Ipc_List, list, _e_ipc_5int_2str_edd);
- _e_ipc_3int_4str_edd = E_IPC_DD_NEW("3int_4str", E_Ipc_3Int_4Str);
+ E_IPC_DD(_e_ipc_3int_4str_edd, eddc, "3int_4str", E_Ipc_3Int_4Str);
E_CONFIG_VAL(_e_ipc_3int_4str_edd, E_Ipc_3Int_4Str, val1, INT);
E_CONFIG_VAL(_e_ipc_3int_4str_edd, E_Ipc_3Int_4Str, val2, INT);
E_CONFIG_VAL(_e_ipc_3int_4str_edd, E_Ipc_3Int_4Str, val3, INT);
@@ -124,10 +111,10 @@ e_ipc_codec_init(void)
E_CONFIG_VAL(_e_ipc_3int_4str_edd, E_Ipc_3Int_4Str, str3, STR);
E_CONFIG_VAL(_e_ipc_3int_4str_edd, E_Ipc_3Int_4Str, str4, STR);
- _e_ipc_3int_4str_list_edd = E_IPC_DD_NEW("3int_4str_list", E_Ipc_List);
+ E_IPC_DD(_e_ipc_3int_4str_list_edd, eddc, "3int_4str_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_3int_4str_list_edd, E_Ipc_List, list, _e_ipc_3int_4str_edd);
- _e_ipc_3int_3str_edd = E_IPC_DD_NEW("3int_3str", E_Ipc_3Int_3Str);
+ E_IPC_DD(_e_ipc_3int_3str_edd, eddc, "3int_3str", E_Ipc_3Int_3Str);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, val1, INT);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, val2, INT);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, val3, INT);
@@ -135,17 +122,17 @@ e_ipc_codec_init(void)
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, str2, STR);
E_CONFIG_VAL(_e_ipc_3int_3str_edd, E_Ipc_3Int_3Str, str3, STR);
- _e_ipc_3int_3str_list_edd = E_IPC_DD_NEW("3int_3str_list", E_Ipc_List);
+ E_IPC_DD(_e_ipc_3int_3str_list_edd, eddc, "3int_3str_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_3int_3str_list_edd, E_Ipc_List, list, _e_ipc_3int_3str_edd);
- _e_ipc_str_4int_edd = E_IPC_DD_NEW("str_4int", E_Ipc_Str_4Int);
+ E_IPC_DD(_e_ipc_str_4int_edd, eddc, "str_4int", E_Ipc_Str_4Int);
E_CONFIG_VAL(_e_ipc_str_4int_edd, E_Ipc_Str_4Int, str, STR);
E_CONFIG_VAL(_e_ipc_str_4int_edd, E_Ipc_Str_4Int, val1, INT);
E_CONFIG_VAL(_e_ipc_str_4int_edd, E_Ipc_Str_4Int, val2, INT);
E_CONFIG_VAL(_e_ipc_str_4int_edd, E_Ipc_Str_4Int, val3, INT);
E_CONFIG_VAL(_e_ipc_str_4int_edd, E_Ipc_Str_4Int, val4, INT);
- _e_ipc_str_4int_list_edd = E_IPC_DD_NEW("str_4int_list", E_Ipc_List);
+ E_IPC_DD(_e_ipc_str_4int_list_edd, eddc, "str_4int_list", E_Ipc_List);
E_CONFIG_LIST(_e_ipc_str_4int_list_edd, E_Ipc_List, list, _e_ipc_str_4int_edd);
return 1;