* @param name The name of the event.
* @see Eo_Event_Description
*/
-#define EO_EVENT_DESCRIPTION(name) { name, EINA_FALSE }
+#define EO_EVENT_DESCRIPTION(name) { name, EINA_FALSE, EINA_FALSE }
/**
* @def EO_EVENT_DESCRIPTION_HOT(name)
* @see Eo_Event_Description
* @see EO_EVENT_DESCRIPTION
*/
-#define EO_EVENT_DESCRIPTION_HOT(name) { name, EINA_TRUE }
+#define EO_EVENT_DESCRIPTION_HOT(name) { name, EINA_TRUE, EINA_FALSE }
/* 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)
{
char buf[1024];
- buf[0] = _LEGACY_EVENT_FIRST_CHAR; /* Encode it's a legacy event */
- strncpy(buf + 1, _event_name, sizeof(buf) - 1);
+ strncpy(buf, _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);
{
event_desc = calloc(1, sizeof(Eo_Event_Description));
event_desc->name = event_name;
+ event_desc->legacy_is = EINA_TRUE;
eina_hash_add(_legacy_events_hash, event_name, event_desc);
}
else
return event_desc;
}
-static Eina_Bool
+static inline 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;
- }
+ return desc->legacy_is;
}
static void
}
else if (_legacy_event_desc_is(a) || _legacy_event_desc_is(b))
{
- const char *aname = _legacy_event_desc_name_get(a);
- const char *bname = _legacy_event_desc_name_get(b);
- return !strcmp(aname, bname);
+ return !strcmp(a->name, b->name);
}
else
{
{
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, "\x01" "a,changed");
+ ck_assert_str_eq(a_desc->name, "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, "\x01" "bad");
+ ck_assert_str_eq(bad_desc->name, "bad");
/* Call Eo event with legacy and non-legacy callbacks. */
_eo_signals_cb_current = 0;