From 6af85271177f41a07d59b14759236c9f4a5bd1de Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Wed, 26 Apr 2017 16:18:49 +0200 Subject: [PATCH] eo: move all the key_ properties to C --- src/lib/ecore_audio/ecore_audio_in_tone.eo | 1 - src/lib/ecore_audio/ecore_audio_obj_in_tone.c | 4 + src/lib/eo/Eo.h | 111 ++++++++++++++++++ src/lib/eo/efl_object.eo | 84 ------------- src/lib/eo/eo_base_class.c | 34 +++++- 5 files changed, 148 insertions(+), 86 deletions(-) diff --git a/src/lib/ecore_audio/ecore_audio_in_tone.eo b/src/lib/ecore_audio/ecore_audio_in_tone.eo index a08eef3eb9..8cdd935753 100644 --- a/src/lib/ecore_audio/ecore_audio_in_tone.eo +++ b/src/lib/ecore_audio/ecore_audio_in_tone.eo @@ -4,7 +4,6 @@ class Ecore.Audio.In.Tone (Ecore.Audio.In) eo_prefix: ecore_audio_obj_in_tone; implements { Efl.Object.constructor; - Efl.Object.key_data { get; set; } Ecore.Audio.In.length { set; } Ecore.Audio.In.seek; Ecore.Audio.In.read_internal; diff --git a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c index 0c22edb90e..258483a984 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_in_tone.c +++ b/src/lib/ecore_audio/ecore_audio_obj_in_tone.c @@ -122,4 +122,8 @@ _ecore_audio_in_tone_efl_object_constructor(Eo *eo_obj, Ecore_Audio_In_Tone_Data return eo_obj; } +#define ECORE_AUDIO_IN_TONE_EXTRA_OPS \ + EFL_OBJECT_OP_FUNC(efl_key_data_set, _ecore_audio_in_tone_efl_object_key_data_set), \ + EFL_OBJECT_OP_FUNC(efl_key_data_get, _ecore_audio_in_tone_efl_object_key_data_get) + #include "ecore_audio_in_tone.eo.c" diff --git a/src/lib/eo/Eo.h b/src/lib/eo/Eo.h index a89dec6fc1..dd7ecabe1d 100644 --- a/src/lib/eo/Eo.h +++ b/src/lib/eo/Eo.h @@ -1441,6 +1441,117 @@ EOAPI void efl_wref_add(Eo *obj, Efl_Object **wref); */ EOAPI void efl_wref_del(Eo *obj, Efl_Object **wref); + +/** + * @brief Generic data with string key on an object. + * + * The user is in charge of freeing the data. + * + * @param[in] key The key associated with the data + * @param[in] data The data to set + */ +EOAPI void efl_key_data_set(Eo *obj, const char * key, const void *data); + +/** + * @brief Generic data with string key on an object. + * + * The user is in charge of freeing the data. + * + * @param[in] key The key associated with the data + * + * @return The data to set + */ +EOAPI void *efl_key_data_get(const Eo *obj, const char * key); + +/** + * @brief Generic object reference with string key to object. + * + * The object will be automatically ref'd when set and unref'd when replaced or + * deleted or referring object is deleted. If the referenced object is deleted + * then the key is deleted automatically. + * + * This is the same key store used by key_data and key_value so keys are shared + * and can store only one thing + * + * @param[in] key The key associated with the object ref + * @param[in] objdata The object to set + */ +EOAPI void efl_key_ref_set(Eo *obj, const char * key, const Efl_Object *objdata); + +/** + * @brief Generic object reference with string key to object. + * + * The object will be automatically ref'd when set and unref'd when replaced or + * deleted or referring object is deleted. If the referenced object is deleted + * then the key is deleted automatically. + * + * This is the same key store used by key_data and key_value so keys are shared + * and can store only one thing + * + * @param[in] key The key associated with the object ref + * + * @return The object to set + */ +EOAPI Efl_Object *efl_key_ref_get(const Eo *obj, const char * key); + +/** + * @brief Generic weak object reference with string key to object. + * + * The object key will be removed if the object is removed, but will not take + * or removed references like key_obj. + * + * This is the same key store used by key_data and key_value so keys are shared + * and can store only one thing + * + * @param[in] key The key associated with the object ref + * @param[in] objdata The object to set + */ +EOAPI void efl_key_wref_set(Eo *obj, const char * key, const Efl_Object *objdata); + +/** + * @brief Generic weak object reference with string key to object. + * + * The object key will be removed if the object is removed, but will not take + * or removed references like key_obj. + * + * This is the same key store used by key_data and key_value so keys are shared + * and can store only one thing + * + * @param[in] key The key associated with the object ref + * + * @return The object to set + */ +EOAPI Efl_Object *efl_key_wref_get(const Eo *obj, const char * key); + +/** + * @brief Value on with 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 object is deleted. + * + * This is the same key store used by key_data and key_obj so keys are shared + * and can store only one thing + * + * @param[in] key The key associated with the value + * @param[in] value The value to set + */ +EOAPI void efl_key_value_set(Eo *obj, const char * key, Eina_Value *value); + +/** + * @brief Value on with 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 object is deleted. + * + * This is the same key store used by key_data and key_obj so keys are shared + * and can store only one thing + * + * @param[in] key The key associated with the value + * + * @return The value to set + */ +EOAPI Eina_Value *efl_key_value_get(const Eo *obj, const char * key); + /** * @brief Enable or disable the manual free feature. * @param obj the object to work on. diff --git a/src/lib/eo/efl_object.eo b/src/lib/eo/efl_object.eo index 8430b8aec7..33188756f5 100644 --- a/src/lib/eo/efl_object.eo +++ b/src/lib/eo/efl_object.eo @@ -156,90 +156,6 @@ abstract Efl.Object () } return: Efl.Object; [[The first object found]] } - @property key_data { - [[Generic data with string key on an object. - - The user is in charge of freeing the data. - ]] - keys { - key: string; [[The key associated with the data]] - } - set { - values { - data: const(void_ptr); [[The data to set]] - } - } - get { - values { - data: void_ptr; [[The data to set]] - } - } - } - @property key_ref { - [[Generic object reference with string key to object. - - The object will be automatically ref'd when set and unref'd - when replaced or deleted or referring object is deleted. If - the referenced object is deleted then the key is deleted - automatically. - - This is the same key store used by key_data and key_value so keys - are shared and can store only one thing - ]] - keys { - key: string; [[The key associated with the object ref]] - } - set { - values { - objdata: const(Efl.Object); [[The object to set]] - } - } - get { - values { - objdata: Efl.Object; [[The object to set]] - } - } - } - @property key_wref { - [[Generic weak object reference with string key to object. - - The object key will be removed if the object is removed, but - will not take or removed references like key_obj. - - This is the same key store used by key_data and key_value so keys - are shared and can store only one thing - ]] - keys { - key: string; [[The key associated with the object ref]] - } - set { - values { - objdata: const(Efl.Object); [[The object to set]] - } - } - get { - values { - objdata: Efl.Object; [[The object to set]] - } - } - } - @property key_value { - [[Value on with 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 - object is deleted. - - This is the same key store used by key_data and key_obj so keys - are shared and can store only one thing - ]] - keys { - key: string; [[The key associated with the value]] - } - values { - value: ptr(generic_value); [[The value to set]] - } - } event_thaw { [[Thaw events of object. diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index 964a8c10c9..18c25bfc4d 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -283,12 +283,18 @@ _efl_object_key_data_set(Eo *obj, Efl_Object_Data *pd, const char *key, const vo _key_generic_set(obj, pd, key, data, DATA_PTR, EINA_TRUE); } +EOAPI EFL_VOID_FUNC_BODYV(efl_key_data_set, EFL_FUNC_CALL(key, data), + const char *key, const void *data); + EOLIAN static void * _efl_object_key_data_get(Eo *obj, Efl_Object_Data *pd, const char *key) { return _key_generic_get(obj, pd, key, DATA_PTR); } +EOAPI EFL_FUNC_BODYV_CONST(efl_key_data_get, void *, NULL, EFL_FUNC_CALL(key), + const char *key); + EOLIAN static void _efl_object_key_ref_set(Eo *obj EINA_UNUSED, Efl_Object_Data *pd, const char *key, const Eo *objdata) { @@ -303,12 +309,18 @@ _efl_object_key_ref_set(Eo *obj EINA_UNUSED, Efl_Object_Data *pd, const char *ke } } +EOAPI EFL_VOID_FUNC_BODYV(efl_key_ref_set, EFL_FUNC_CALL(key, objdata), + const char *key, const Efl_Object *objdata); + EOLIAN static Eo * _efl_object_key_ref_get(Eo *obj, Efl_Object_Data *pd, const char *key) { return _key_generic_get(obj, pd, key, DATA_OBJ); } +EOAPI EFL_FUNC_BODYV_CONST(efl_key_ref_get, Efl_Object *, NULL, + EFL_FUNC_CALL(key), const char *key); + EOLIAN static void _efl_object_key_wref_set(Eo *obj, Efl_Object_Data *pd, const char * key, const Efl_Object *objdata) { @@ -322,24 +334,36 @@ _efl_object_key_wref_set(Eo *obj, Efl_Object_Data *pd, const char * key, const E } } +EOAPI EFL_VOID_FUNC_BODYV(efl_key_wref_set, EFL_FUNC_CALL(key, objdata), + const char *key, const Efl_Object *objdata); + EOLIAN static Eo * _efl_object_key_wref_get(Eo *obj, Efl_Object_Data *pd, const char * key) { return _key_generic_get(obj, pd, key, DATA_OBJ_WEAK); } +EOAPI EFL_FUNC_BODYV_CONST(efl_key_wref_get, Efl_Object *, NULL, + EFL_FUNC_CALL(key), const char *key); + EOLIAN static void _efl_object_key_value_set(Eo *obj EINA_UNUSED, Efl_Object_Data *pd, const char *key, Eina_Value *value) { _key_generic_set(obj, pd, key, value, DATA_VAL, EINA_TRUE); } +EOAPI EFL_VOID_FUNC_BODYV(efl_key_value_set, EFL_FUNC_CALL(key, value), + const char *key, Eina_Value *value); + EOLIAN static Eina_Value * _efl_object_key_value_get(Eo *obj, Efl_Object_Data *pd, const char *key) { return _key_generic_get(obj, pd, key, DATA_VAL); } +EOAPI EFL_FUNC_BODYV_CONST(efl_key_value_get, Eina_Value *, NULL, + EFL_FUNC_CALL(key), const char *key); + EOLIAN static void _efl_object_name_set(Eo *obj EINA_UNUSED, Efl_Object_Data *pd, const char *name) { @@ -1980,6 +2004,14 @@ _efl_object_future_link(Eo *obj EINA_UNUSED, Efl_Object_Data *pd, Efl_Future *li EFL_OBJECT_OP_FUNC(efl_dbg_info_get, _efl_object_dbg_info_get), \ EFL_OBJECT_OP_FUNC(efl_future_link, _efl_object_future_link), \ EFL_OBJECT_OP_FUNC(efl_wref_add, _efl_object_wref_add), \ - EFL_OBJECT_OP_FUNC(efl_wref_del, _efl_object_wref_del) + EFL_OBJECT_OP_FUNC(efl_wref_del, _efl_object_wref_del), \ + EFL_OBJECT_OP_FUNC(efl_key_data_set, _efl_object_key_data_set), \ + EFL_OBJECT_OP_FUNC(efl_key_data_get, _efl_object_key_data_get), \ + EFL_OBJECT_OP_FUNC(efl_key_ref_set, _efl_object_key_ref_set), \ + EFL_OBJECT_OP_FUNC(efl_key_ref_get, _efl_object_key_ref_get), \ + EFL_OBJECT_OP_FUNC(efl_key_wref_set, _efl_object_key_wref_set), \ + EFL_OBJECT_OP_FUNC(efl_key_wref_get, _efl_object_key_wref_get), \ + EFL_OBJECT_OP_FUNC(efl_key_value_set, _efl_object_key_value_set), \ + EFL_OBJECT_OP_FUNC(efl_key_value_get, _efl_object_key_value_get) \ #include "efl_object.eo.c"