forked from enlightenment/efl
Eo/evas events: Move legacy events dynamic generator to eo.
This commit is contained in:
parent
cedfc6e49e
commit
c58b3401c3
|
@ -1108,6 +1108,12 @@ EAPI void eo_destructor(void);
|
|||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Don't use.
|
||||
* @internal
|
||||
*/
|
||||
EAPI const Eo_Event_Description *eo_base_legacy_only_event_description_get(const char *_event_name);
|
||||
|
||||
/**
|
||||
* @def EO_CALLBACK_PRIORITY_BEFORE
|
||||
* Slightly more prioritized than default.
|
||||
|
|
|
@ -409,6 +409,39 @@ _wref_destruct(Private_Data *pd)
|
|||
|
||||
/* Callbacks */
|
||||
|
||||
/* XXX: Legacy support, remove when legacy is dead. */
|
||||
static Eina_Hash *_legacy_events_hash = NULL;
|
||||
static const char *_legacy_event_desc = "Dynamically generated legacy event";
|
||||
|
||||
EAPI const Eo_Event_Description *
|
||||
eo_base_legacy_only_event_description_get(const char *_event_name)
|
||||
{
|
||||
Eina_Stringshare *event_name = eina_stringshare_add(_event_name);
|
||||
Eo_Event_Description *event_desc = eina_hash_find(_legacy_events_hash, event_name);
|
||||
if (!event_desc)
|
||||
{
|
||||
event_desc = calloc(1, sizeof(Eo_Event_Description));
|
||||
event_desc->name = event_name;
|
||||
event_desc->doc = _legacy_event_desc;
|
||||
}
|
||||
else
|
||||
{
|
||||
eina_stringshare_del(event_name);
|
||||
}
|
||||
|
||||
return event_desc;
|
||||
}
|
||||
|
||||
static void
|
||||
_legacy_events_hash_free_cb(void *_desc)
|
||||
{
|
||||
Eo_Event_Description *desc = _desc;
|
||||
eina_stringshare_del(desc->name);
|
||||
free(desc);
|
||||
}
|
||||
|
||||
/* EOF Legacy */
|
||||
|
||||
struct _Eo_Callback_Description
|
||||
{
|
||||
Eo_Callback_Description *next;
|
||||
|
@ -910,7 +943,6 @@ EAPI const Eina_Value_Type *EO_DBG_INFO_TYPE = &_EO_DBG_INFO_TYPE;
|
|||
|
||||
/* EOF event callbacks */
|
||||
|
||||
|
||||
/* EO_CLASS stuff */
|
||||
#define MY_CLASS EO_CLASS
|
||||
|
||||
|
@ -953,6 +985,13 @@ static void
|
|||
_class_constructor(Eo_Class *klass EINA_UNUSED)
|
||||
{
|
||||
event_freeze_count = 0;
|
||||
_legacy_events_hash = eina_hash_stringshared_new(_legacy_events_hash_free_cb);
|
||||
}
|
||||
|
||||
static void
|
||||
_class_destructor(Eo_Class *klass EINA_UNUSED)
|
||||
{
|
||||
eina_hash_free(_legacy_events_hash);
|
||||
}
|
||||
|
||||
static Eo_Op_Description op_descs [] = {
|
||||
|
@ -999,7 +1038,7 @@ static const Eo_Class_Description class_desc = {
|
|||
event_desc,
|
||||
sizeof(Private_Data),
|
||||
_class_constructor,
|
||||
NULL
|
||||
_class_destructor
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(eo_base_class_get, &class_desc, NULL, NULL)
|
||||
|
|
|
@ -1,54 +1,20 @@
|
|||
#include "evas_common_private.h"
|
||||
#include "evas_private.h"
|
||||
|
||||
Eina_Hash* signals_hash_table = NULL;
|
||||
|
||||
static const Eo_Event_Description *_evas_clickable_interface_event_desc[];
|
||||
static const Eo_Event_Description *_evas_draggable_interface_event_desc[];
|
||||
static const Eo_Event_Description *_evas_scrollable_interface_event_desc[];
|
||||
static const Eo_Event_Description *_evas_selectable_interface_event_desc[];
|
||||
static const Eo_Event_Description *_evas_zoomable_interface_event_desc[];
|
||||
|
||||
#define ADD_SIGNAL(name, event) eina_hash_add(signals_hash_table, name, event)
|
||||
#define ADD_INTERFACE_SIGNALS(events_desc) \
|
||||
do \
|
||||
{ \
|
||||
int i = 0; \
|
||||
while (events_desc[i]) { \
|
||||
_Evas_Event_Description *desc = calloc(1, sizeof(*desc)); \
|
||||
desc->eo_desc = (Eo_Event_Description *)events_desc[i]; \
|
||||
desc->is_desc_allocated = EINA_FALSE; \
|
||||
ADD_SIGNAL(events_desc[i]->name, desc); \
|
||||
i++; \
|
||||
} \
|
||||
} \
|
||||
while (0);
|
||||
|
||||
static void
|
||||
_signal_interface_del(void *data)
|
||||
{
|
||||
_Evas_Event_Description *desc = data;
|
||||
if (desc->is_desc_allocated) free(desc->eo_desc);
|
||||
free(desc);
|
||||
}
|
||||
|
||||
static void
|
||||
_evas_signal_interface_class_constructor(Eo_Class *klass EINA_UNUSED)
|
||||
{
|
||||
signals_hash_table = eina_hash_string_superfast_new(_signal_interface_del);
|
||||
ADD_INTERFACE_SIGNALS(_evas_clickable_interface_event_desc);
|
||||
ADD_INTERFACE_SIGNALS(_evas_scrollable_interface_event_desc);
|
||||
ADD_INTERFACE_SIGNALS(_evas_zoomable_interface_event_desc);
|
||||
ADD_INTERFACE_SIGNALS(_evas_selectable_interface_event_desc);
|
||||
ADD_INTERFACE_SIGNALS(_evas_draggable_interface_event_desc);
|
||||
}
|
||||
#undef ADD_INTERFACE_SIGNALS
|
||||
#undef ADD_SIGNAL
|
||||
|
||||
static void
|
||||
_evas_signal_interface_class_destructor(Eo_Class *klass EINA_UNUSED)
|
||||
{
|
||||
eina_hash_free(signals_hash_table);
|
||||
}
|
||||
|
||||
#include "canvas/evas_signal_interface.eo.c"
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef struct
|
|||
EINA_INLIST;
|
||||
Evas_Smart_Cb func;
|
||||
void *data;
|
||||
_Evas_Event_Description *desc;
|
||||
const Eo_Event_Description *event;
|
||||
} _eo_evas_smart_cb_info;
|
||||
|
||||
|
||||
|
@ -699,25 +699,16 @@ evas_object_smart_callback_priority_add(Evas_Object *eo_obj, const char *event,
|
|||
if (!event) return;
|
||||
if (!func) return;
|
||||
|
||||
_Evas_Event_Description *event_desc = eina_hash_find(signals_hash_table, event);
|
||||
if (!event_desc)
|
||||
{
|
||||
event_desc = calloc (1, sizeof(*event_desc));
|
||||
event_desc->eo_desc = calloc(1, sizeof(Eo_Event_Description));
|
||||
event_desc->eo_desc->name = eina_stringshare_add(event);
|
||||
event_desc->eo_desc->doc = "";
|
||||
event_desc->is_desc_allocated = EINA_TRUE;
|
||||
eina_hash_add(signals_hash_table, event, event_desc);
|
||||
}
|
||||
const Eo_Event_Description *eo_desc = eo_base_legacy_only_event_description_get(event);
|
||||
_eo_evas_smart_cb_info *cb_info = calloc(1, sizeof(*cb_info));
|
||||
cb_info->func = func;
|
||||
cb_info->data = (void *)data;
|
||||
cb_info->desc = event_desc;
|
||||
cb_info->event = eo_desc;
|
||||
|
||||
o->callbacks = eina_inlist_append(o->callbacks,
|
||||
EINA_INLIST_GET(cb_info));
|
||||
|
||||
eo_do(eo_obj, eo_event_callback_priority_add(event_desc->eo_desc, priority, _eo_evas_smart_cb, cb_info));
|
||||
eo_do(eo_obj, eo_event_callback_priority_add(eo_desc, priority, _eo_evas_smart_cb, cb_info));
|
||||
}
|
||||
|
||||
EAPI void *
|
||||
|
@ -732,16 +723,15 @@ evas_object_smart_callback_del(Evas_Object *eo_obj, const char *event, Evas_Smar
|
|||
o = eo_data_scope_get(eo_obj, MY_CLASS);
|
||||
|
||||
if (!event) return NULL;
|
||||
const _Evas_Event_Description *event_desc = eina_hash_find(signals_hash_table, event);
|
||||
if (!event_desc) return NULL;
|
||||
const Eo_Event_Description *eo_desc = eo_base_legacy_only_event_description_get(event);
|
||||
|
||||
EINA_INLIST_FOREACH(o->callbacks, info)
|
||||
{
|
||||
if ((info->func == func) && (info->desc == event_desc))
|
||||
if ((info->func == func) && (info->event == eo_desc))
|
||||
{
|
||||
void *tmp = info->data;
|
||||
eo_do(eo_obj, eo_event_callback_del(
|
||||
event_desc->eo_desc, _eo_evas_smart_cb, info));
|
||||
eo_desc, _eo_evas_smart_cb, info));
|
||||
|
||||
o->callbacks =
|
||||
eina_inlist_remove(o->callbacks, EINA_INLIST_GET(info));
|
||||
|
@ -765,16 +755,15 @@ evas_object_smart_callback_del_full(Evas_Object *eo_obj, const char *event, Evas
|
|||
o = eo_data_scope_get(eo_obj, MY_CLASS);
|
||||
if (!o) return NULL;
|
||||
|
||||
const _Evas_Event_Description *event_desc = eina_hash_find(signals_hash_table, event);
|
||||
if (!event_desc) return NULL;
|
||||
const Eo_Event_Description *eo_desc = eo_base_legacy_only_event_description_get(event);
|
||||
|
||||
EINA_INLIST_FOREACH(o->callbacks, info)
|
||||
{
|
||||
if ((info->func == func) && (info->desc == event_desc) && (info->data == data))
|
||||
if ((info->func == func) && (info->event == eo_desc) && (info->data == data))
|
||||
{
|
||||
void *tmp = info->data;
|
||||
eo_do(eo_obj, eo_event_callback_del(
|
||||
event_desc->eo_desc, _eo_evas_smart_cb, info));
|
||||
eo_desc, _eo_evas_smart_cb, info));
|
||||
|
||||
o->callbacks =
|
||||
eina_inlist_remove(o->callbacks, EINA_INLIST_GET(info));
|
||||
|
@ -793,9 +782,8 @@ evas_object_smart_callback_call(Evas_Object *eo_obj, const char *event, void *ev
|
|||
MAGIC_CHECK_END();
|
||||
|
||||
if (!event) return;
|
||||
const _Evas_Event_Description *event_desc = eina_hash_find(signals_hash_table, event);
|
||||
if (event_desc)
|
||||
eo_do(eo_obj, eo_event_callback_call(event_desc->eo_desc, event_info));
|
||||
const Eo_Event_Description *eo_desc = eo_base_legacy_only_event_description_get(event);
|
||||
eo_do(eo_obj, eo_event_callback_call(eo_desc, event_info));
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
|
@ -1214,7 +1202,7 @@ evas_object_smart_cleanup(Evas_Object *eo_obj)
|
|||
{
|
||||
_eo_evas_smart_cb_info *info = (_eo_evas_smart_cb_info *)o->callbacks;
|
||||
eo_do(eo_obj, eo_event_callback_del(
|
||||
info->desc->eo_desc, _eo_evas_smart_cb, info));
|
||||
info->event, _eo_evas_smart_cb, info));
|
||||
o->callbacks = eina_inlist_remove(o->callbacks, EINA_INLIST_GET(info));
|
||||
free(info);
|
||||
}
|
||||
|
|
|
@ -1208,13 +1208,6 @@ struct _Evas_Image_Save_Func
|
|||
int (*image_save) (RGBA_Image *im, const char *file, const char *key, int quality, int compress);
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Eo_Event_Description *eo_desc;
|
||||
Eina_Bool is_desc_allocated : 1;
|
||||
} _Evas_Event_Description;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue