/* XXX: Legacy support, remove when legacy is dead. */
static Eina_Hash *_legacy_events_hash = NULL;
+#define _LEGACY_EVENT_FIRST_CHAR 1
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);
+ char buf[1024];
+ buf[0] = _LEGACY_EVENT_FIRST_CHAR; /* Encode it's a legacy event */
+ strncpy(buf + 1, _event_name, sizeof(buf) - 1);
+ buf[sizeof(buf) - 1] = '\0';
+ Eina_Stringshare *event_name = eina_stringshare_add(buf);
Eo_Event_Description *event_desc = eina_hash_find(_legacy_events_hash, event_name);
if (!event_desc)
{
return event_desc;
}
+static Eina_Bool
+_legacy_event_desc_is(const Eo_Event_Description *desc)
+{
+ return (desc->name[0] == _LEGACY_EVENT_FIRST_CHAR);
+}
+
+/* Also supports non legacy. */
+static const char *
+_legacy_event_desc_name_get(const Eo_Event_Description *desc)
+{
+ if (_legacy_event_desc_is(desc))
+ {
+ return desc->name + 1;
+ }
+ else
+ {
+ return desc->name;
+ }
+}
+
static void
_legacy_events_hash_free_cb(void *_desc)
{
if (!a)
return EINA_FALSE;
- if (a == b)
+ if (_legacy_event_desc_is(a) && _legacy_event_desc_is(b))
+ {
+ return (a->name == b->name);
+ }
+ else if (_legacy_event_desc_is(a) || _legacy_event_desc_is(b))
{
- return EINA_TRUE;
+ const char *aname = _legacy_event_desc_name_get(a);
+ const char *bname = _legacy_event_desc_name_get(b);
+ return !strcmp(aname, bname);
}
else
{
- return !strcmp(a->name, b->name);
+ return (a == b);
}
}
{
const Eo_Event_Description *a_desc = eo_base_legacy_only_event_description_get("a,changed");
fail_if(!a_desc);
- ck_assert_str_eq(a_desc->name, "a,changed");
+ ck_assert_str_eq(a_desc->name, "\x01" "a,changed");
fail_if(a_desc == EV_A_CHANGED);
const Eo_Event_Description *bad_desc = eo_base_legacy_only_event_description_get("bad");
fail_if(!bad_desc);
- ck_assert_str_eq(bad_desc->name, "bad");
+ ck_assert_str_eq(bad_desc->name, "\x01" "bad");
/* Call Eo event with legacy and non-legacy callbacks. */
_eo_signals_cb_current = 0;