forked from enlightenment/efl
efl - key/data/value/obj attach to eo objects - make these properties
the key data now is a property so they come out in bindings really nicely like: obj.key_data["blah"] = x; x = obj.key_data["blah"]; etc.
This commit is contained in:
parent
7782c0bcb9
commit
43661180f7
|
@ -87,7 +87,7 @@ base_data_get(const Eo *obj, const char *key)
|
||||||
inline void
|
inline void
|
||||||
base_data_del(Eo *obj, const char *key)
|
base_data_del(Eo *obj, const char *key)
|
||||||
{
|
{
|
||||||
eo_key_del(obj, key);
|
eo_key_data_set(obj, key, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
|
|
|
@ -101,7 +101,6 @@ ffi.cdef [[
|
||||||
void eo_key_data_set(const char *key, const void *data,
|
void eo_key_data_set(const char *key, const void *data,
|
||||||
eo_key_data_free_func free_func);
|
eo_key_data_free_func free_func);
|
||||||
void *eo_key_data_get(const char *key);
|
void *eo_key_data_get(const char *key);
|
||||||
void eo_key_del(const char *key);
|
|
||||||
|
|
||||||
Eina_Iterator *eo_children_iterator_new(void);
|
Eina_Iterator *eo_children_iterator_new(void);
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,7 @@ class Ecore.Audio.In.Tone (Ecore.Audio.In)
|
||||||
eo_prefix: ecore_audio_obj_in_tone;
|
eo_prefix: ecore_audio_obj_in_tone;
|
||||||
implements {
|
implements {
|
||||||
Eo.Base.constructor;
|
Eo.Base.constructor;
|
||||||
Eo.Base.key_data_set;
|
Eo.Base.key_data;
|
||||||
Eo.Base.key_data_get;
|
|
||||||
Ecore.Audio.In.length.set;
|
Ecore.Audio.In.length.set;
|
||||||
Ecore.Audio.In.seek;
|
Ecore.Audio.In.seek;
|
||||||
Ecore.Audio.In.read_internal;
|
Ecore.Audio.In.read_internal;
|
||||||
|
|
|
@ -96,7 +96,7 @@ _ecore_audio_in_tone_eo_base_key_data_set(Eo *eo_obj, Ecore_Audio_In_Tone_Data *
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void *
|
EOLIAN static void *
|
||||||
_ecore_audio_in_tone_eo_base_key_data_get(const Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key)
|
_ecore_audio_in_tone_eo_base_key_data_get(Eo *eo_obj, Ecore_Audio_In_Tone_Data *obj, const char *key)
|
||||||
{
|
{
|
||||||
if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) {
|
if (!strcmp(key, ECORE_AUDIO_ATTR_TONE_FREQ)) {
|
||||||
return (void *) (intptr_t) obj->freq;
|
return (void *) (intptr_t) obj->freq;
|
||||||
|
|
|
@ -575,7 +575,7 @@ end:
|
||||||
pd->items = (Grid_Item *)
|
pd->items = (Grid_Item *)
|
||||||
eina_inlist_remove(EINA_INLIST_GET(pd->items), EINA_INLIST_GET(gi));
|
eina_inlist_remove(EINA_INLIST_GET(pd->items), EINA_INLIST_GET(gi));
|
||||||
pd->count--;
|
pd->count--;
|
||||||
eo_key_del(subobj, GRID_ITEM_KEY);
|
eo_key_data_set(subobj, GRID_ITEM_KEY, NULL);
|
||||||
free(gi);
|
free(gi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4382,7 +4382,7 @@ _local_elm_drop_target_del(Evas_Object *obj, Elm_Sel_Format format,
|
||||||
if (!dropable->cbs_list)
|
if (!dropable->cbs_list)
|
||||||
{
|
{
|
||||||
drops = eina_list_remove(drops, dropable);
|
drops = eina_list_remove(drops, dropable);
|
||||||
eo_key_del(obj, "__elm_dropable");
|
eo_key_data_set(obj, "__elm_dropable", NULL);
|
||||||
free(dropable);
|
free(dropable);
|
||||||
dropable = NULL;
|
dropable = NULL;
|
||||||
evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
|
evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
|
||||||
|
|
|
@ -91,7 +91,7 @@ _efl_ui_layout_internal_box_eo_base_finalize(Eo *obj, Efl_Ui_Layout_Box_Data *pd
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_efl_ui_layout_internal_box_eo_base_destructor(Eo *obj, Efl_Ui_Layout_Box_Data *pd)
|
_efl_ui_layout_internal_box_eo_base_destructor(Eo *obj, Efl_Ui_Layout_Box_Data *pd)
|
||||||
{
|
{
|
||||||
eo_key_del(pd->pack, DATA_KEY);
|
eo_key_data_set(pd->pack, DATA_KEY, NULL);
|
||||||
eo_destructor(eo_super(obj, BOX_CLASS));
|
eo_destructor(eo_super(obj, BOX_CLASS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ _efl_ui_layout_internal_table_eo_base_finalize(Eo *obj EINA_UNUSED, Efl_Ui_Layou
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_efl_ui_layout_internal_table_eo_base_destructor(Eo *obj, Efl_Ui_Layout_Box_Data *pd)
|
_efl_ui_layout_internal_table_eo_base_destructor(Eo *obj, Efl_Ui_Layout_Box_Data *pd)
|
||||||
{
|
{
|
||||||
eo_key_del(pd->pack, DATA_KEY);
|
eo_key_data_set(pd->pack, DATA_KEY, NULL);
|
||||||
eina_stringshare_del(pd->part);
|
eina_stringshare_del(pd->part);
|
||||||
eo_destructor(eo_super(obj, TABLE_CLASS));
|
eo_destructor(eo_super(obj, TABLE_CLASS));
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,73 +200,66 @@ abstract Eo.Base ()
|
||||||
@in wref: Eo.Base **;
|
@in wref: Eo.Base **;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
key_data_set {
|
@property key_data {
|
||||||
[[Set generic data to object.
|
[[Generic data with string key on an object.
|
||||||
|
|
||||||
The user is in change to free the data.
|
The user is in charge of freeing the data.
|
||||||
]]
|
]]
|
||||||
params {
|
keys {
|
||||||
@in key: const(char)*; [[the key associated with the data]]
|
key: const(char) *; [[the key associated with the data]]
|
||||||
@in data: const(void)*; [[the data to set]]
|
}
|
||||||
|
set {
|
||||||
|
values {
|
||||||
|
data: const(void) *; [[the data to set]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
key_data_get @const {
|
get {
|
||||||
[[Get generic data from object.]]
|
values {
|
||||||
params {
|
data: void *; [[the data to set]]
|
||||||
@in key: const(char)*; [[the key associated with the data]]
|
|
||||||
}
|
|
||||||
return: void *; [[the data for the key]]
|
|
||||||
}
|
|
||||||
key_del {
|
|
||||||
[[Del generic data from object.]]
|
|
||||||
params {
|
|
||||||
@in key: const(char)*; [[the key associated with the data]]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
key_obj_set {
|
}
|
||||||
[[Set generic object reference to object.
|
@property key_obj {
|
||||||
|
[[Generic object reference with string key to object.
|
||||||
|
|
||||||
The object will be automatically ref'd when set and unref'd
|
The object will be automatically ref'd when set and unref'd
|
||||||
when replaced or deleted or referring object is deleted. If
|
when replaced or deleted or referring object is deleted. If
|
||||||
the referenced object is deleted then the key is deleted
|
the referenced object is deleted then the key is deleted
|
||||||
automatically.
|
automatically.
|
||||||
|
|
||||||
This is the same key store used by key_data_set etc. so keys
|
This is the same key store used by key_data and key_value so keys
|
||||||
are shared and can store only one thing
|
are shared and can store only one thing
|
||||||
]]
|
]]
|
||||||
params {
|
keys {
|
||||||
@in key: const(char)*; [[the key associated with the object ref]]
|
key: const(char) *; [[the key associated with the object ref]]
|
||||||
@in objdata: Eo.Base *; [[the object to set]]
|
}
|
||||||
|
set {
|
||||||
|
values {
|
||||||
|
objdata: const(Eo.Base) *; [[the object to set]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
key_obj_get @const {
|
get {
|
||||||
[[Get generic object reference from object.]]
|
values {
|
||||||
params {
|
objdata: Eo.Base *; [[the object to set]]
|
||||||
@in key: const(char)*; [[the key associated with the object ref]]
|
|
||||||
}
|
}
|
||||||
return: Eo.Base *; [[the object reference for the key]]
|
|
||||||
}
|
}
|
||||||
key_value_set {
|
}
|
||||||
[[Set value on the object.
|
@property key_value {
|
||||||
|
[[Value on with string key on the object.
|
||||||
|
|
||||||
This stores the value with the given string key on the object
|
This stores the value with the given string key on the object
|
||||||
and it will be freed when replaced or deleted or the referring
|
and it will be freed when replaced or deleted or the referring
|
||||||
object is deleted.
|
object is deleted.
|
||||||
|
|
||||||
This is the same key store used by key_data_set and key_obj_set
|
This is the same key store used by key_data and key_obj so keys
|
||||||
etc. so keys are shared and can store only one thing
|
are shared and can store only one thing
|
||||||
]]
|
]]
|
||||||
params {
|
keys {
|
||||||
@in key: const(char)*; [[the key associated with the value]]
|
key: const(char)*; [[the key associated with the value]]
|
||||||
@in value: Eina.Value *; [[the value to set]]
|
|
||||||
}
|
}
|
||||||
|
values {
|
||||||
|
value: Eina.Value *; [[the value to set]]
|
||||||
}
|
}
|
||||||
key_value_get @const {
|
|
||||||
[[Get generic value from object.]]
|
|
||||||
params {
|
|
||||||
@in key: const(char)*; [[the key associated with the value]]
|
|
||||||
}
|
|
||||||
return: Eina.Value *; [[the value for the key]]
|
|
||||||
}
|
}
|
||||||
event_thaw {
|
event_thaw {
|
||||||
[[thaw events of object.
|
[[thaw events of object.
|
||||||
|
|
|
@ -126,14 +126,12 @@ _eo_generic_data_del_all(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
static void
|
||||||
_eo_base_key_del(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key)
|
_eo_key_generic_del(const Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key)
|
||||||
{
|
{
|
||||||
Eo_Generic_Data_Node *node;
|
Eo_Generic_Data_Node *node;
|
||||||
Eo_Base_Extension *ext = pd->ext;
|
Eo_Base_Extension *ext = pd->ext;
|
||||||
|
|
||||||
if (!key) return;
|
|
||||||
if (!ext) return;
|
|
||||||
EINA_INLIST_FOREACH(ext->generic_data, node)
|
EINA_INLIST_FOREACH(ext->generic_data, node)
|
||||||
{
|
{
|
||||||
if (!strcmp(node->key, key))
|
if (!strcmp(node->key, key))
|
||||||
|
@ -148,7 +146,7 @@ _eo_base_key_del(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key)
|
||||||
|
|
||||||
/* Return TRUE if the object was newly added. */
|
/* Return TRUE if the object was newly added. */
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_key_generic_set(const Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, const void *data, Eo_Generic_Data_Node_Type d_type)
|
_key_generic_set(const Eo *obj, Eo_Base_Data *pd, const char *key, const void *data, Eo_Generic_Data_Node_Type d_type)
|
||||||
{
|
{
|
||||||
Eo_Generic_Data_Node *node;
|
Eo_Generic_Data_Node *node;
|
||||||
Eo_Base_Extension *ext = pd->ext;
|
Eo_Base_Extension *ext = pd->ext;
|
||||||
|
@ -156,6 +154,11 @@ _key_generic_set(const Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, c
|
||||||
if (!key) return EINA_FALSE;
|
if (!key) return EINA_FALSE;
|
||||||
if (ext)
|
if (ext)
|
||||||
{
|
{
|
||||||
|
if (!data)
|
||||||
|
{
|
||||||
|
_eo_key_generic_del(obj, pd, key);
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
EINA_INLIST_FOREACH(ext->generic_data, node)
|
EINA_INLIST_FOREACH(ext->generic_data, node)
|
||||||
{
|
{
|
||||||
if (!strcmp(node->key, key))
|
if (!strcmp(node->key, key))
|
||||||
|
@ -223,20 +226,20 @@ _eo_base_key_data_set(Eo *obj, Eo_Base_Data *pd, const char *key, const void *da
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void *
|
EOLIAN static void *
|
||||||
_eo_base_key_data_get(const Eo *obj, Eo_Base_Data *pd, const char *key)
|
_eo_base_key_data_get(Eo *obj, Eo_Base_Data *pd, const char *key)
|
||||||
{
|
{
|
||||||
return _key_generic_get(obj, pd, key, DATA_PTR);
|
return _key_generic_get(obj, pd, key, DATA_PTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_eo_base_key_obj_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, Eo *objdata)
|
_eo_base_key_obj_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, const Eo *objdata)
|
||||||
{
|
{
|
||||||
if (_key_generic_set(obj, pd, key, objdata, DATA_OBJ))
|
if (_key_generic_set(obj, pd, key, objdata, DATA_OBJ))
|
||||||
eo_ref(objdata);
|
eo_ref(objdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eo *
|
EOLIAN static Eo *
|
||||||
_eo_base_key_obj_get(const Eo *obj, Eo_Base_Data *pd, const char *key)
|
_eo_base_key_obj_get(Eo *obj, Eo_Base_Data *pd, const char *key)
|
||||||
{
|
{
|
||||||
return _key_generic_get(obj, pd, key, DATA_OBJ);
|
return _key_generic_get(obj, pd, key, DATA_OBJ);
|
||||||
}
|
}
|
||||||
|
@ -248,7 +251,7 @@ _eo_base_key_value_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, E
|
||||||
}
|
}
|
||||||
|
|
||||||
EOLIAN static Eina_Value *
|
EOLIAN static Eina_Value *
|
||||||
_eo_base_key_value_get(const Eo *obj, Eo_Base_Data *pd, const char *key)
|
_eo_base_key_value_get(Eo *obj, Eo_Base_Data *pd, const char *key)
|
||||||
{
|
{
|
||||||
return _key_generic_get(obj, pd, key, DATA_VAL);
|
return _key_generic_get(obj, pd, key, DATA_VAL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,6 @@ evas_object_data_del(Evas_Object *obj, const char *key)
|
||||||
MAGIC_CHECK_END();
|
MAGIC_CHECK_END();
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
data = eo_key_data_get(obj, key);
|
data = eo_key_data_get(obj, key);
|
||||||
eo_key_del(obj, key);
|
eo_key_data_set(obj, key, NULL);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -620,7 +620,7 @@ START_TEST(eo_generic_data)
|
||||||
eo_key_data_set(obj, "test1", (void *) 1);
|
eo_key_data_set(obj, "test1", (void *) 1);
|
||||||
data = eo_key_data_get(obj, "test1");
|
data = eo_key_data_get(obj, "test1");
|
||||||
fail_if(1 != (intptr_t) data);
|
fail_if(1 != (intptr_t) data);
|
||||||
eo_key_del(obj, "test1");
|
eo_key_data_set(obj, "test1", NULL);
|
||||||
data = eo_key_data_get(obj, "test1");
|
data = eo_key_data_get(obj, "test1");
|
||||||
fail_if(data);
|
fail_if(data);
|
||||||
|
|
||||||
|
@ -633,13 +633,13 @@ START_TEST(eo_generic_data)
|
||||||
|
|
||||||
data = eo_key_data_get(obj, "test2");
|
data = eo_key_data_get(obj, "test2");
|
||||||
fail_if(2 != (intptr_t) data);
|
fail_if(2 != (intptr_t) data);
|
||||||
eo_key_del(obj, "test2");
|
eo_key_data_set(obj, "test2", NULL);
|
||||||
data = eo_key_data_get(obj, "test2");
|
data = eo_key_data_get(obj, "test2");
|
||||||
fail_if(data);
|
fail_if(data);
|
||||||
|
|
||||||
data = eo_key_data_get(obj, "test1");
|
data = eo_key_data_get(obj, "test1");
|
||||||
fail_if(1 != (intptr_t) data);
|
fail_if(1 != (intptr_t) data);
|
||||||
eo_key_del(obj, "test1");
|
eo_key_data_set(obj, "test1", NULL);
|
||||||
data = eo_key_data_get(obj, "test1");
|
data = eo_key_data_get(obj, "test1");
|
||||||
fail_if(data);
|
fail_if(data);
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ START_TEST(eo_generic_data)
|
||||||
eo_key_obj_set(obj, "test1", obj2);
|
eo_key_obj_set(obj, "test1", obj2);
|
||||||
objtmp = eo_key_obj_get(obj, "test1");
|
objtmp = eo_key_obj_get(obj, "test1");
|
||||||
fail_if(obj2 != objtmp);
|
fail_if(obj2 != objtmp);
|
||||||
eo_key_del(obj, "test1");
|
eo_key_obj_set(obj, "test1", NULL);
|
||||||
objtmp = eo_key_obj_get(obj, "test1");
|
objtmp = eo_key_obj_get(obj, "test1");
|
||||||
fail_if(objtmp);
|
fail_if(objtmp);
|
||||||
|
|
||||||
|
@ -661,13 +661,13 @@ START_TEST(eo_generic_data)
|
||||||
|
|
||||||
data = eo_key_obj_get(obj, "test2");
|
data = eo_key_obj_get(obj, "test2");
|
||||||
fail_if(obj3 != objtmp);
|
fail_if(obj3 != objtmp);
|
||||||
eo_key_del(obj, "test2");
|
eo_key_obj_set(obj, "test2", NULL);
|
||||||
objtmp = eo_key_obj_get(obj, "test2");
|
objtmp = eo_key_obj_get(obj, "test2");
|
||||||
fail_if(objtmp);
|
fail_if(objtmp);
|
||||||
|
|
||||||
objtmp = eo_key_obj_get(obj, "test1");
|
objtmp = eo_key_obj_get(obj, "test1");
|
||||||
fail_if(obj2 != objtmp);
|
fail_if(obj2 != objtmp);
|
||||||
eo_key_del(obj, "test1");
|
eo_key_obj_set(obj, "test1", NULL);
|
||||||
objtmp = eo_key_obj_get(obj, "test1");
|
objtmp = eo_key_obj_get(obj, "test1");
|
||||||
fail_if(objtmp);
|
fail_if(objtmp);
|
||||||
|
|
||||||
|
@ -680,10 +680,10 @@ START_TEST(eo_generic_data)
|
||||||
value2 = eo_key_value_get(obj, "value1");
|
value2 = eo_key_value_get(obj, "value1");
|
||||||
fail_if(value != value2);
|
fail_if(value != value2);
|
||||||
|
|
||||||
eo_key_del(obj, "value1");
|
eo_key_value_set(obj, "value1", NULL);
|
||||||
value2 = eo_key_value_get(obj, "value1");
|
value2 = eo_key_value_get(obj, "value1");
|
||||||
fail_if(value2 != NULL);
|
fail_if(value2 != NULL);
|
||||||
eo_key_del(obj, "value1");
|
eo_key_value_set(obj, "value1", NULL);
|
||||||
|
|
||||||
eo_unref(obj);
|
eo_unref(obj);
|
||||||
eo_unref(obj2);
|
eo_unref(obj2);
|
||||||
|
|
Loading…
Reference in New Issue