2013-12-25 06:13:41 -08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <Eina.h>
|
2016-04-20 02:26:35 -07:00
|
|
|
#include <fnmatch.h>
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2015-05-08 06:21:23 -07:00
|
|
|
#define EO_BASE_BETA
|
2015-05-01 04:57:40 -07:00
|
|
|
|
2013-12-25 06:19:07 -08:00
|
|
|
#include "Eo.h"
|
2013-12-25 06:13:41 -08:00
|
|
|
#include "eo_ptr_indirection.h"
|
|
|
|
#include "eo_private.h"
|
|
|
|
|
|
|
|
static int event_freeze_count = 0;
|
|
|
|
|
|
|
|
typedef struct _Eo_Callback_Description Eo_Callback_Description;
|
|
|
|
|
2016-04-19 01:21:21 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
2016-04-19 01:40:11 -07:00
|
|
|
const char *id;
|
|
|
|
const char *comment;
|
2016-05-05 08:08:08 -07:00
|
|
|
Eo *composite_parent;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eina_Inlist *generic_data;
|
|
|
|
Eo ***wrefs;
|
2016-04-19 01:21:21 -07:00
|
|
|
} Eo_Base_Extension;
|
|
|
|
|
2013-12-25 06:13:41 -08:00
|
|
|
typedef struct
|
|
|
|
{
|
2016-04-19 01:40:11 -07:00
|
|
|
Eina_List *children;
|
|
|
|
Eo *parent;
|
|
|
|
Eina_List *parent_list;
|
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext;
|
2016-04-19 01:40:11 -07:00
|
|
|
Eo_Callback_Description *callbacks;
|
2016-04-20 15:50:46 -07:00
|
|
|
|
|
|
|
Eina_Inlist *current;
|
|
|
|
|
2016-04-19 01:40:11 -07:00
|
|
|
unsigned short walking_list;
|
|
|
|
unsigned short event_freeze_count;
|
|
|
|
Eina_Bool deletions_waiting : 1;
|
2014-06-03 03:23:53 -07:00
|
|
|
} Eo_Base_Data;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2016-04-29 05:43:36 -07:00
|
|
|
typedef enum {
|
|
|
|
DATA_PTR,
|
|
|
|
DATA_OBJ,
|
|
|
|
DATA_VAL
|
|
|
|
} Eo_Generic_Data_Node_Type;
|
|
|
|
|
2013-12-25 06:13:41 -08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
EINA_INLIST;
|
2016-04-19 01:40:11 -07:00
|
|
|
Eina_Stringshare *key;
|
2016-04-29 05:08:07 -07:00
|
|
|
union {
|
|
|
|
Eina_Value *val;
|
|
|
|
Eo *obj;
|
|
|
|
void *ptr;
|
|
|
|
} d;
|
2016-04-29 05:43:36 -07:00
|
|
|
Eo_Generic_Data_Node_Type d_type;
|
2013-12-25 06:13:41 -08:00
|
|
|
} Eo_Generic_Data_Node;
|
|
|
|
|
2016-04-20 15:50:46 -07:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
EINA_INLIST;
|
|
|
|
const Eo_Event_Description *desc;
|
|
|
|
Eo_Callback_Description *current;
|
|
|
|
} Eo_Current_Callback_Description;
|
2016-04-19 01:21:21 -07:00
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
static inline void
|
|
|
|
_eo_base_extension_free(Eo_Base_Extension *ext)
|
2016-04-19 01:21:21 -07:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
free(ext);
|
2016-04-19 01:21:21 -07:00
|
|
|
}
|
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
static inline void
|
|
|
|
_eo_base_extension_need(Eo_Base_Data *pd)
|
2016-04-19 01:21:21 -07:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
if (pd->ext) return;
|
|
|
|
pd->ext = calloc(1, sizeof(Eo_Base_Extension));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_eo_base_extension_noneed(Eo_Base_Data *pd)
|
|
|
|
{
|
|
|
|
Eo_Base_Extension *ext = pd->ext;
|
|
|
|
if ((!ext) || (ext->id) || (ext->comment) || (ext->generic_data) ||
|
2016-05-05 08:08:08 -07:00
|
|
|
(ext->wrefs) || (ext->composite_parent)) return;
|
2016-04-23 22:38:02 -07:00
|
|
|
_eo_base_extension_free(pd->ext);
|
|
|
|
pd->ext = NULL;
|
2016-04-19 01:21:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
|
2013-12-25 06:13:41 -08:00
|
|
|
static void
|
|
|
|
_eo_generic_data_node_free(Eo_Generic_Data_Node *node)
|
|
|
|
{
|
2016-04-29 05:20:21 -07:00
|
|
|
switch (node->d_type)
|
|
|
|
{
|
|
|
|
case DATA_OBJ:
|
|
|
|
eo_unref(node->d.obj);
|
|
|
|
break;
|
|
|
|
case DATA_VAL:
|
|
|
|
eina_value_free(node->d.val);
|
|
|
|
break;
|
|
|
|
case DATA_PTR:
|
|
|
|
break;
|
|
|
|
}
|
2013-12-25 06:13:41 -08:00
|
|
|
eina_stringshare_del(node->key);
|
|
|
|
free(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-04-29 05:13:00 -07:00
|
|
|
_eo_generic_data_del_all(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2016-04-12 09:04:11 -07:00
|
|
|
Eo_Generic_Data_Node *node;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext = pd->ext;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
if (!ext) return;
|
2016-04-29 05:20:21 -07:00
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
while (ext->generic_data)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
node = (Eo_Generic_Data_Node *)ext->generic_data;
|
|
|
|
ext->generic_data = eina_inlist_remove(ext->generic_data,
|
2016-04-29 05:20:21 -07:00
|
|
|
EINA_INLIST_GET(node));
|
|
|
|
|
2013-12-25 06:13:41 -08:00
|
|
|
_eo_generic_data_node_free(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 09:04:11 -07:00
|
|
|
EOLIAN static void
|
2016-04-29 05:13:00 -07:00
|
|
|
_eo_base_key_del(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key)
|
2016-04-12 09:04:11 -07:00
|
|
|
{
|
|
|
|
Eo_Generic_Data_Node *node;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext = pd->ext;
|
2016-04-12 09:04:11 -07:00
|
|
|
|
|
|
|
if (!key) return;
|
2016-04-23 22:38:02 -07:00
|
|
|
if (!ext) return;
|
|
|
|
EINA_INLIST_FOREACH(ext->generic_data, node)
|
2016-04-12 09:04:11 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(node->key, key))
|
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
ext->generic_data = eina_inlist_remove
|
|
|
|
(ext->generic_data, EINA_INLIST_GET(node));
|
2016-04-12 09:04:11 -07:00
|
|
|
_eo_generic_data_node_free(node);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-29 05:43:36 -07:00
|
|
|
/* Return TRUE if the object was newly added. */
|
|
|
|
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)
|
2016-04-12 09:04:11 -07:00
|
|
|
{
|
|
|
|
Eo_Generic_Data_Node *node;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext = pd->ext;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2016-04-29 05:43:36 -07:00
|
|
|
if (!key) return EINA_FALSE;
|
2016-04-23 22:38:02 -07:00
|
|
|
if (ext)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
EINA_INLIST_FOREACH(ext->generic_data, node)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
if (!strcmp(node->key, key))
|
2016-04-12 09:04:11 -07:00
|
|
|
{
|
2016-04-29 05:43:36 -07:00
|
|
|
if ((node->d_type == d_type) && (node->d.ptr == data))
|
|
|
|
return EINA_FALSE;
|
2016-04-23 22:38:02 -07:00
|
|
|
ext->generic_data = eina_inlist_remove
|
|
|
|
(ext->generic_data, EINA_INLIST_GET(node));
|
|
|
|
_eo_generic_data_node_free(node);
|
|
|
|
break;
|
2016-04-12 09:04:11 -07:00
|
|
|
}
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
_eo_base_extension_need(pd);
|
|
|
|
ext = pd->ext;
|
|
|
|
if (ext)
|
|
|
|
{
|
|
|
|
node = calloc(1, sizeof(Eo_Generic_Data_Node));
|
2016-04-29 05:43:36 -07:00
|
|
|
if (!node) return EINA_FALSE;
|
2016-04-23 22:38:02 -07:00
|
|
|
node->key = eina_stringshare_add(key);
|
2016-04-29 05:43:36 -07:00
|
|
|
node->d.ptr = (void *) data;
|
|
|
|
node->d_type = d_type;
|
2016-04-23 22:38:02 -07:00
|
|
|
ext->generic_data = eina_inlist_prepend
|
|
|
|
(ext->generic_data, EINA_INLIST_GET(node));
|
2016-04-29 05:43:36 -07:00
|
|
|
return EINA_TRUE;
|
2016-04-23 22:38:02 -07:00
|
|
|
}
|
2016-04-29 05:43:36 -07:00
|
|
|
|
|
|
|
return EINA_FALSE;
|
2016-04-12 09:04:11 -07:00
|
|
|
}
|
|
|
|
|
2016-04-29 05:43:36 -07:00
|
|
|
static void *
|
|
|
|
_key_generic_get(const Eo *obj, Eo_Base_Data *pd, const char *key, Eo_Generic_Data_Node_Type d_type)
|
2016-04-12 09:04:11 -07:00
|
|
|
{
|
|
|
|
Eo_Generic_Data_Node *node;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext = pd->ext;
|
2016-04-12 09:04:11 -07:00
|
|
|
|
|
|
|
if (!key) return NULL;
|
2016-04-23 22:38:02 -07:00
|
|
|
if (!ext) return NULL;
|
|
|
|
EINA_INLIST_FOREACH(ext->generic_data, node)
|
2016-04-12 09:04:11 -07:00
|
|
|
{
|
|
|
|
if (!strcmp(node->key, key))
|
|
|
|
{
|
2016-04-29 05:43:36 -07:00
|
|
|
if (node->d_type == d_type)
|
2016-04-12 09:04:11 -07:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
ext->generic_data = eina_inlist_promote
|
|
|
|
(ext->generic_data, EINA_INLIST_GET(node));
|
2016-04-29 05:43:36 -07:00
|
|
|
return node->d.ptr;
|
2016-04-12 09:04:11 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-29 05:43:36 -07:00
|
|
|
ERR("Object %p key '%s' asked for %d but is %d'",
|
|
|
|
obj, key, d_type, node->d_type);
|
2016-04-12 09:04:11 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-12-25 06:13:41 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-04-19 02:25:15 -07:00
|
|
|
EOLIAN static void
|
2016-04-29 05:43:36 -07:00
|
|
|
_eo_base_key_data_set(Eo *obj, Eo_Base_Data *pd, const char *key, const void *data)
|
2016-04-19 02:25:15 -07:00
|
|
|
{
|
2016-04-29 05:43:36 -07:00
|
|
|
_key_generic_set(obj, pd, key, data, DATA_PTR);
|
|
|
|
}
|
2016-04-19 02:25:15 -07:00
|
|
|
|
2016-04-29 05:43:36 -07:00
|
|
|
EOLIAN static void *
|
|
|
|
_eo_base_key_data_get(const Eo *obj, Eo_Base_Data *pd, const char *key)
|
|
|
|
{
|
|
|
|
return _key_generic_get(obj, pd, key, DATA_PTR);
|
|
|
|
}
|
2016-04-19 02:25:15 -07:00
|
|
|
|
2016-04-29 05:43:36 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_key_obj_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, Eo *objdata)
|
|
|
|
{
|
|
|
|
if (_key_generic_set(obj, pd, key, objdata, DATA_OBJ))
|
|
|
|
eo_ref(objdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eo *
|
|
|
|
_eo_base_key_obj_get(const Eo *obj, Eo_Base_Data *pd, const char *key)
|
|
|
|
{
|
|
|
|
return _key_generic_get(obj, pd, key, DATA_OBJ);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_key_value_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *key, Eina_Value *value)
|
|
|
|
{
|
|
|
|
_key_generic_set(obj, pd, key, value, DATA_VAL);
|
2016-04-19 02:25:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Value *
|
|
|
|
_eo_base_key_value_get(const Eo *obj, Eo_Base_Data *pd, const char *key)
|
|
|
|
{
|
2016-04-29 05:43:36 -07:00
|
|
|
return _key_generic_get(obj, pd, key, DATA_VAL);
|
2016-04-19 02:25:15 -07:00
|
|
|
}
|
|
|
|
|
2016-04-19 00:34:53 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_id_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *id)
|
|
|
|
{
|
|
|
|
if ((id) && (!id[0])) id = NULL;
|
2016-04-19 01:21:21 -07:00
|
|
|
if (id)
|
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
_eo_base_extension_need(pd);
|
|
|
|
if (pd->ext) eina_stringshare_replace(&(pd->ext->id), id);
|
2016-04-19 01:21:21 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
if (!pd->ext) return;
|
|
|
|
if (pd->ext->id)
|
2016-04-19 01:21:21 -07:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
eina_stringshare_replace(&(pd->ext->id), id);
|
|
|
|
_eo_base_extension_noneed(pd);
|
2016-04-19 01:21:21 -07:00
|
|
|
}
|
|
|
|
}
|
2016-04-19 00:34:53 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static const char *
|
|
|
|
_eo_base_id_get(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
|
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
if (!pd->ext) return NULL;
|
|
|
|
return pd->ext->id;
|
2016-04-19 01:21:21 -07:00
|
|
|
}
|
|
|
|
|
2016-04-20 02:26:35 -07:00
|
|
|
static inline Eina_Bool
|
|
|
|
_idmatch(const char *match, Eina_Bool is_glob, const char *str)
|
|
|
|
{
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
if (is_glob)
|
|
|
|
{
|
|
|
|
// if match string is empty - then it matches - same as "*"
|
|
|
|
if (!match[0]) return EINA_TRUE;
|
|
|
|
// if match string is "*" special case it and match
|
|
|
|
if ((match[0] == '*') && (match[1] == 0)) return EINA_TRUE;
|
|
|
|
// actual compare
|
|
|
|
if (!fnmatch(match, str, 0)) return EINA_TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if match string is empty - then it matches - same as "*"
|
|
|
|
if (!match[0]) return EINA_TRUE;
|
|
|
|
// if pointers are the same they must be the same
|
|
|
|
if (match == str) return EINA_TRUE;
|
|
|
|
// actual compare
|
|
|
|
if (!strcmp(match, str)) return EINA_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
_matchall(const char *match)
|
|
|
|
{
|
|
|
|
if ((match[0] == 0) || ((match[0] == '*') && (match[1] == 0)))
|
|
|
|
return EINA_TRUE;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_hasglob(const char *match)
|
|
|
|
{
|
|
|
|
if (strpbrk(match, "*?[")) return EINA_TRUE;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_ismultiglob(const char *match)
|
|
|
|
{
|
|
|
|
if ((match[0] == '*') && (match[1] == '*') && (match[2] == 0))
|
|
|
|
return EINA_TRUE;
|
|
|
|
if ((match[0] == '*') && (match[1] == '*') && (match[2] == '/'))
|
|
|
|
return EINA_TRUE;
|
|
|
|
if ((match[0] == '/') && (match[1] == '*') && (match[2] == '*') && (match[3] == 0))
|
|
|
|
return EINA_TRUE;
|
|
|
|
if ((match[0] == '/') && (match[1] == '*') && (match[2] == '*') && (match[3] == '/'))
|
|
|
|
return EINA_TRUE;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eo_Base *
|
|
|
|
_eo_base_id_find(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *search)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Eo *child;
|
|
|
|
const char *id, *p, *klass_name;
|
|
|
|
|
|
|
|
// notes:
|
|
|
|
// if search contains NO "/" char, then its just a name search.
|
|
|
|
// if there is one or more "/" chars, then these are explicitly object
|
|
|
|
// delimiters.
|
|
|
|
// a name of "**" means 0 or more objects in the heirachy chain
|
|
|
|
// if the string has no "/" char at the start, it implies "/**/"
|
|
|
|
// a name can be a name or the form "class:name" where the object must
|
|
|
|
// be of class named "class" and name "name". if "name" is empty like:
|
|
|
|
// "class:" then an object of any name will match like "class:*". an
|
|
|
|
// empty class like ":name" is the sanme as "*:name" which is the same
|
|
|
|
// as "name". class ane name of course can be basic globs but not **
|
|
|
|
|
|
|
|
// search string NULL or "" is invalid
|
|
|
|
if (!search) return NULL;
|
|
|
|
if (!search[0]) return NULL;
|
|
|
|
|
|
|
|
if (strchr(search, '/'))
|
|
|
|
{
|
|
|
|
ERR("Looking up object by path '%s' is not supported", search);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if this is a multi glob - "**" then we don't have a name or
|
|
|
|
// class to match at all so just don't look
|
|
|
|
if (_ismultiglob(search)) return NULL;
|
|
|
|
// check if this is "class:name" or just "name"
|
|
|
|
if ((p = strchr(search, ':')))
|
|
|
|
{
|
|
|
|
// "class:name"
|
2016-05-16 09:41:59 -07:00
|
|
|
char *klass;
|
|
|
|
char *name;
|
|
|
|
size_t colon_location = p - search;
|
2016-04-20 02:26:35 -07:00
|
|
|
Eina_Bool klass_glob = EINA_FALSE;
|
|
|
|
Eina_Bool name_glob = EINA_FALSE;
|
|
|
|
|
|
|
|
// split class:name into 2 strings dropping :
|
2016-05-16 09:41:59 -07:00
|
|
|
klass = alloca(strlen(search) + 1);
|
|
|
|
strcpy(klass, search);
|
|
|
|
klass[colon_location] = '\0';
|
|
|
|
name = klass + colon_location + 1;
|
2016-04-20 02:26:35 -07:00
|
|
|
|
|
|
|
// figure out if class or name are globs
|
|
|
|
klass_glob = _hasglob(klass);
|
|
|
|
name_glob = _hasglob(name);
|
|
|
|
EINA_LIST_FOREACH(pd->children, l, child)
|
|
|
|
{
|
|
|
|
id = eo_id_get(child);
|
|
|
|
klass_name = eo_class_name_get(eo_class_get(child));
|
|
|
|
if (_idmatch(klass, klass_glob, klass_name) &&
|
|
|
|
(((!_matchall(klass)) && (!id) && (_matchall(name))) ||
|
|
|
|
((id) && _idmatch(name, name_glob, id))))
|
|
|
|
return child;
|
|
|
|
child = eo_id_find(child, search);
|
|
|
|
if (child) return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (_hasglob(search))
|
|
|
|
{
|
|
|
|
// we have a glob - fnmatch
|
|
|
|
EINA_LIST_FOREACH(pd->children, l, child)
|
|
|
|
{
|
|
|
|
id = eo_id_get(child);
|
|
|
|
if ((id) && (_idmatch(search, EINA_TRUE, id)))
|
|
|
|
return child;
|
|
|
|
child = eo_id_find(child, search);
|
|
|
|
if (child) return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// fast path for simple "name"
|
|
|
|
EINA_LIST_FOREACH(pd->children, l, child)
|
|
|
|
{
|
|
|
|
id = eo_id_get(child);
|
|
|
|
if ((id) && (_idmatch(search, EINA_FALSE, id)))
|
|
|
|
return child;
|
|
|
|
child = eo_id_find(child, search);
|
|
|
|
if (child) return child;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-04-19 01:21:21 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_comment_set(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const char *comment)
|
|
|
|
{
|
|
|
|
if ((comment) && (!comment[0])) comment = NULL;
|
|
|
|
if (comment)
|
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
_eo_base_extension_need(pd);
|
|
|
|
if (pd->ext) eina_stringshare_replace(&(pd->ext->comment), comment);
|
2016-04-19 01:21:21 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
if (!pd->ext) return;
|
|
|
|
if (pd->ext->comment)
|
2016-04-19 01:21:21 -07:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
eina_stringshare_replace(&(pd->ext->comment), comment);
|
|
|
|
_eo_base_extension_noneed(pd);
|
2016-04-19 01:21:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static const char *
|
|
|
|
_eo_base_comment_get(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
|
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
if (!pd->ext) return NULL;
|
|
|
|
return pd->ext->comment;
|
2016-04-19 00:34:53 -07:00
|
|
|
}
|
|
|
|
|
2016-04-26 08:19:44 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_del(const Eo *obj, Eo_Base_Data *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
if (eo_parent_get((Eo *) obj))
|
|
|
|
{
|
|
|
|
eo_parent_set((Eo *) obj, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eo_unref(obj);
|
|
|
|
}
|
|
|
|
}
|
2016-04-19 00:34:53 -07:00
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_parent_set(Eo *obj, Eo_Base_Data *pd, Eo *parent_id)
|
2013-12-26 12:11:48 -08:00
|
|
|
{
|
|
|
|
if (pd->parent == parent_id)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pd->parent)
|
|
|
|
{
|
2014-06-03 03:23:53 -07:00
|
|
|
Eo_Base_Data *old_parent_pd;
|
2013-12-26 12:11:48 -08:00
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
old_parent_pd = eo_data_scope_get(pd->parent, EO_BASE_CLASS);
|
2013-12-26 12:11:48 -08:00
|
|
|
if (old_parent_pd)
|
|
|
|
{
|
2014-07-06 04:15:21 -07:00
|
|
|
old_parent_pd->children = eina_list_remove_list(old_parent_pd->children,
|
|
|
|
pd->parent_list);
|
|
|
|
pd->parent_list = NULL;
|
2013-12-26 12:11:48 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("CONTACT DEVS!!! SHOULD NEVER HAPPEN!!! Old parent %p for object %p is not a valid Eo object.",
|
|
|
|
pd->parent, obj);
|
|
|
|
}
|
2015-08-26 02:47:06 -07:00
|
|
|
|
|
|
|
/* Only unref if we don't have a new parent instead. */
|
|
|
|
if (!parent_id)
|
|
|
|
{
|
|
|
|
eo_unref(obj);
|
|
|
|
}
|
2013-12-26 12:11:48 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set new parent */
|
|
|
|
if (parent_id)
|
|
|
|
{
|
2014-06-03 03:23:53 -07:00
|
|
|
Eo_Base_Data *parent_pd = NULL;
|
|
|
|
parent_pd = eo_data_scope_get(parent_id, EO_BASE_CLASS);
|
2013-12-26 12:11:48 -08:00
|
|
|
|
|
|
|
if (EINA_LIKELY(parent_pd != NULL))
|
|
|
|
{
|
|
|
|
pd->parent = parent_id;
|
2015-08-20 03:16:00 -07:00
|
|
|
parent_pd->children = eina_list_append(parent_pd->children, obj);
|
2014-07-06 04:15:21 -07:00
|
|
|
pd->parent_list = eina_list_last(parent_pd->children);
|
2013-12-26 12:11:48 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pd->parent = NULL;
|
|
|
|
ERR("New parent %p for object %p is not a valid Eo object.",
|
|
|
|
parent_id, obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pd->parent = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static Eo *
|
|
|
|
_eo_base_parent_get(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
|
2013-12-26 12:11:48 -08:00
|
|
|
{
|
|
|
|
return pd->parent;
|
|
|
|
}
|
|
|
|
|
2014-08-29 01:55:02 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_eo_base_finalized_get(Eo *obj_id, Eo_Base_Data *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_FALSE);
|
|
|
|
|
|
|
|
return obj->finalized;
|
|
|
|
}
|
|
|
|
|
2016-04-20 23:15:13 -07:00
|
|
|
EOLIAN static Eo_Base *
|
2016-05-04 01:08:00 -07:00
|
|
|
_eo_base_provider_find(Eo *obj EINA_UNUSED, Eo_Base_Data *pd, const Eo_Base *klass)
|
2016-04-20 23:15:13 -07:00
|
|
|
{
|
2016-05-04 01:08:00 -07:00
|
|
|
if (pd->parent) return eo_provider_find(pd->parent, klass);
|
2016-04-20 23:15:13 -07:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-05-04 01:08:00 -07:00
|
|
|
|
2013-12-26 12:11:48 -08:00
|
|
|
/* Children accessor */
|
|
|
|
typedef struct _Eo_Children_Iterator Eo_Children_Iterator;
|
|
|
|
struct _Eo_Children_Iterator
|
|
|
|
{
|
|
|
|
Eina_Iterator iterator;
|
|
|
|
Eina_List *current;
|
|
|
|
_Eo_Object *obj;
|
|
|
|
Eo *obj_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_eo_children_iterator_next(Eo_Children_Iterator *it, void **data)
|
|
|
|
{
|
|
|
|
if (!it->current) return EINA_FALSE;
|
|
|
|
|
|
|
|
if (data) *data = eina_list_data_get(it->current);
|
|
|
|
it->current = eina_list_next(it->current);
|
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eo *
|
|
|
|
_eo_children_iterator_container(Eo_Children_Iterator *it)
|
|
|
|
{
|
|
|
|
return it->obj_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_eo_children_iterator_free(Eo_Children_Iterator *it)
|
|
|
|
{
|
|
|
|
_Eo_Class *klass;
|
|
|
|
_Eo_Object *obj;
|
|
|
|
|
|
|
|
klass = (_Eo_Class*) it->obj->klass;
|
|
|
|
obj = it->obj;
|
|
|
|
|
|
|
|
eina_spinlock_take(&klass->iterators.trash_lock);
|
|
|
|
if (klass->iterators.trash_count < 8)
|
|
|
|
{
|
|
|
|
klass->iterators.trash_count++;
|
|
|
|
eina_trash_push(&klass->iterators.trash, it);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
free(it);
|
|
|
|
}
|
|
|
|
eina_spinlock_release(&klass->iterators.trash_lock);
|
|
|
|
|
|
|
|
_eo_unref(obj);
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static Eina_Iterator *
|
|
|
|
_eo_base_children_iterator_new(Eo *obj_id, Eo_Base_Data *pd)
|
2013-12-26 12:11:48 -08:00
|
|
|
{
|
|
|
|
_Eo_Class *klass;
|
|
|
|
Eo_Children_Iterator *it;
|
|
|
|
|
|
|
|
EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, NULL);
|
|
|
|
|
|
|
|
if (!pd->children) return NULL;
|
|
|
|
|
|
|
|
klass = (_Eo_Class *) obj->klass;
|
|
|
|
|
|
|
|
eina_spinlock_take(&klass->iterators.trash_lock);
|
|
|
|
it = eina_trash_pop(&klass->iterators.trash);
|
|
|
|
if (it)
|
|
|
|
{
|
|
|
|
klass->iterators.trash_count--;
|
|
|
|
memset(it, 0, sizeof (Eo_Children_Iterator));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
it = calloc(1, sizeof (Eo_Children_Iterator));
|
|
|
|
}
|
|
|
|
eina_spinlock_release(&klass->iterators.trash_lock);
|
|
|
|
if (!it) return NULL;
|
|
|
|
|
|
|
|
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
|
2014-04-17 10:36:10 -07:00
|
|
|
it->current = pd->children;
|
2013-12-26 12:11:48 -08:00
|
|
|
it->obj = _eo_ref(obj);
|
|
|
|
it->obj_id = obj_id;
|
|
|
|
|
|
|
|
it->iterator.next = FUNC_ITERATOR_NEXT(_eo_children_iterator_next);
|
|
|
|
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eo_children_iterator_container);
|
|
|
|
it->iterator.free = FUNC_ITERATOR_FREE(_eo_children_iterator_free);
|
|
|
|
|
|
|
|
return (Eina_Iterator *)it;
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_dbg_info_get(Eo *obj EINA_UNUSED, Eo_Base_Data *pd EINA_UNUSED, Eo_Dbg_Info *root_node EINA_UNUSED)
|
2013-12-25 06:13:41 -08:00
|
|
|
{ /* No info required in the meantime */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Weak reference. */
|
|
|
|
|
|
|
|
static inline size_t
|
2014-06-03 03:23:53 -07:00
|
|
|
_wref_count(Eo_Base_Data *pd)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo ***itr;
|
2013-12-25 06:13:41 -08:00
|
|
|
size_t count = 0;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext = pd->ext;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
if ((!ext) || (!ext->wrefs)) return 0;
|
|
|
|
for (itr = ext->wrefs; *itr; itr++) count++;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_wref_add(Eo *obj, Eo_Base_Data *pd, Eo **wref)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
size_t count;
|
2013-12-26 11:56:59 -08:00
|
|
|
Eo ***tmp;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
|
|
|
count = _wref_count(pd);
|
|
|
|
count += 1; /* New wref. */
|
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
_eo_base_extension_need(pd);
|
|
|
|
ext = pd->ext;
|
|
|
|
if (!ext) return;
|
|
|
|
|
|
|
|
tmp = realloc(ext->wrefs, sizeof(*ext->wrefs) * (count + 1));
|
2013-12-26 11:56:59 -08:00
|
|
|
if (!tmp) return;
|
2016-04-23 22:38:02 -07:00
|
|
|
ext->wrefs = tmp;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
ext->wrefs[count - 1] = wref;
|
|
|
|
ext->wrefs[count] = NULL;
|
2013-12-25 06:13:41 -08:00
|
|
|
*wref = obj;
|
|
|
|
}
|
|
|
|
|
2016-01-12 22:19:07 -08:00
|
|
|
EOLIAN static void
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_wref_del(Eo *obj, Eo_Base_Data *pd, Eo **wref)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
size_t count;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext = pd->ext;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
|
|
|
if (*wref != obj)
|
|
|
|
{
|
|
|
|
ERR("Wref is a weak ref to %p, while this function was called on %p.",
|
2016-04-23 22:38:02 -07:00
|
|
|
*wref, obj);
|
2013-12-25 06:13:41 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
if ((!ext) || (!ext->wrefs))
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
ERR("There are no weak refs for object %p", obj);
|
|
|
|
*wref = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Move the last item in the array instead of the current wref. */
|
|
|
|
count = _wref_count(pd);
|
|
|
|
|
|
|
|
{
|
|
|
|
Eo ***itr;
|
2016-04-23 22:38:02 -07:00
|
|
|
for (itr = ext->wrefs; *itr; itr++)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
if (*itr == wref)
|
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
*itr = ext->wrefs[count - 1];
|
2013-12-25 06:13:41 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*itr)
|
|
|
|
{
|
|
|
|
ERR("Wref %p is not associated with object %p", wref, obj);
|
|
|
|
*wref = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count > 1)
|
|
|
|
{
|
2013-12-26 11:56:59 -08:00
|
|
|
Eo ***tmp;
|
2016-04-23 22:38:02 -07:00
|
|
|
// No count--; because of the NULL that is not included in the count
|
|
|
|
tmp = realloc(ext->wrefs, sizeof(*ext->wrefs) * count);
|
2013-12-26 11:56:59 -08:00
|
|
|
if (!tmp) return;
|
2016-04-23 22:38:02 -07:00
|
|
|
ext->wrefs = tmp;
|
|
|
|
ext->wrefs[count - 1] = NULL;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
free(ext->wrefs);
|
|
|
|
ext->wrefs = NULL;
|
|
|
|
_eo_base_extension_noneed(pd);
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
*wref = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
2014-06-03 03:23:53 -07:00
|
|
|
_wref_destruct(Eo_Base_Data *pd)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
Eo ***itr;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext = pd->ext;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
if ((!ext) || (!ext->wrefs)) return;
|
|
|
|
for (itr = ext->wrefs; *itr; itr++) **itr = NULL;
|
|
|
|
free(ext->wrefs);
|
|
|
|
ext->wrefs = NULL;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF Weak reference. */
|
|
|
|
|
|
|
|
/* Event callbacks */
|
|
|
|
|
|
|
|
/* Callbacks */
|
|
|
|
|
2014-05-19 07:17:08 -07:00
|
|
|
/* XXX: Legacy support, remove when legacy is dead. */
|
|
|
|
static Eina_Hash *_legacy_events_hash = NULL;
|
|
|
|
|
|
|
|
EAPI const Eo_Event_Description *
|
|
|
|
eo_base_legacy_only_event_description_get(const char *_event_name)
|
|
|
|
{
|
2016-03-04 06:17:55 -08:00
|
|
|
Eina_Stringshare *event_name = eina_stringshare_add(_event_name);
|
2014-05-19 07:17:08 -07:00
|
|
|
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;
|
2015-10-16 03:42:37 -07:00
|
|
|
event_desc->legacy_is = EINA_TRUE;
|
2014-05-29 01:24:28 -07:00
|
|
|
eina_hash_add(_legacy_events_hash, event_name, event_desc);
|
2014-05-19 07:17:08 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eina_stringshare_del(event_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return event_desc;
|
|
|
|
}
|
|
|
|
|
2015-10-16 03:42:37 -07:00
|
|
|
static inline Eina_Bool
|
2015-09-28 16:45:34 -07:00
|
|
|
_legacy_event_desc_is(const Eo_Event_Description *desc)
|
|
|
|
{
|
2015-10-16 03:42:37 -07:00
|
|
|
return desc->legacy_is;
|
2015-09-28 16:45:34 -07:00
|
|
|
}
|
|
|
|
|
2014-05-19 07:17:08 -07:00
|
|
|
static void
|
|
|
|
_legacy_events_hash_free_cb(void *_desc)
|
|
|
|
{
|
|
|
|
Eo_Event_Description *desc = _desc;
|
|
|
|
eina_stringshare_del(desc->name);
|
|
|
|
free(desc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF Legacy */
|
|
|
|
|
2013-12-25 06:13:41 -08:00
|
|
|
struct _Eo_Callback_Description
|
|
|
|
{
|
|
|
|
Eo_Callback_Description *next;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
Eo_Callback_Array_Item item;
|
|
|
|
const Eo_Callback_Array_Item *item_array;
|
|
|
|
} items;
|
|
|
|
|
|
|
|
void *func_data;
|
|
|
|
Eo_Callback_Priority priority;
|
|
|
|
|
|
|
|
Eina_Bool delete_me : 1;
|
|
|
|
Eina_Bool func_array : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Actually remove, doesn't care about walking list, or delete_me */
|
|
|
|
static void
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_callback_remove(Eo_Base_Data *pd, Eo_Callback_Description *cb)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2013-09-30 06:15:37 -07:00
|
|
|
Eo_Callback_Description *itr, *pitr = NULL;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2013-09-30 06:15:37 -07:00
|
|
|
itr = pd->callbacks;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2013-12-26 12:00:23 -08:00
|
|
|
for ( ; itr; )
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
Eo_Callback_Description *titr = itr;
|
|
|
|
itr = itr->next;
|
|
|
|
|
|
|
|
if (titr == cb)
|
|
|
|
{
|
|
|
|
if (pitr)
|
|
|
|
{
|
|
|
|
pitr->next = titr->next;
|
|
|
|
}
|
2013-09-30 06:16:46 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
pd->callbacks = titr->next;
|
|
|
|
}
|
2013-12-25 06:13:41 -08:00
|
|
|
free(titr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pitr = titr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Actually remove, doesn't care about walking list, or delete_me */
|
|
|
|
static void
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_callback_remove_all(Eo_Base_Data *pd)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
while (pd->callbacks)
|
|
|
|
{
|
|
|
|
Eo_Callback_Description *next = pd->callbacks->next;
|
|
|
|
free(pd->callbacks);
|
|
|
|
pd->callbacks = next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_callbacks_clear(Eo_Base_Data *pd)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
Eo_Callback_Description *cb = NULL;
|
|
|
|
|
|
|
|
/* If there are no deletions waiting. */
|
|
|
|
if (!pd->deletions_waiting)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Abort if we are currently walking the list. */
|
|
|
|
if (pd->walking_list > 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pd->deletions_waiting = EINA_FALSE;
|
|
|
|
|
2013-12-26 12:00:23 -08:00
|
|
|
for (cb = pd->callbacks; cb; )
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
Eo_Callback_Description *titr = cb;
|
|
|
|
cb = cb->next;
|
|
|
|
|
|
|
|
if (titr->delete_me)
|
|
|
|
{
|
|
|
|
_eo_callback_remove(pd, titr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_callbacks_sorted_insert(Eo_Base_Data *pd, Eo_Callback_Description *cb)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
Eo_Callback_Description *itr, *itrp = NULL;
|
2013-12-26 12:00:23 -08:00
|
|
|
for (itr = pd->callbacks; itr && (itr->priority < cb->priority);
|
2013-12-25 06:13:41 -08:00
|
|
|
itr = itr->next)
|
|
|
|
{
|
|
|
|
itrp = itr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itrp)
|
|
|
|
{
|
|
|
|
cb->next = itrp->next;
|
|
|
|
itrp->next = cb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cb->next = pd->callbacks;
|
|
|
|
pd->callbacks = cb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-27 11:42:48 -08:00
|
|
|
EOLIAN static Eina_Bool
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_event_callback_priority_add(Eo *obj, Eo_Base_Data *pd,
|
2013-12-25 06:13:41 -08:00
|
|
|
const Eo_Event_Description *desc,
|
|
|
|
Eo_Callback_Priority priority,
|
|
|
|
Eo_Event_Cb func,
|
|
|
|
const void *user_data)
|
|
|
|
{
|
2016-01-27 11:42:48 -08:00
|
|
|
const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}};
|
2013-12-25 06:13:41 -08:00
|
|
|
Eo_Callback_Description *cb;
|
|
|
|
|
|
|
|
cb = calloc(1, sizeof(*cb));
|
2015-10-15 04:04:05 -07:00
|
|
|
if (!cb || !desc || !func)
|
|
|
|
{
|
|
|
|
ERR("Tried adding callback with invalid values: cb: %p desc: %p func: %p\n", cb, desc, func);
|
2015-12-28 07:09:36 -08:00
|
|
|
free(cb);
|
2016-01-27 11:42:48 -08:00
|
|
|
return EINA_FALSE;
|
2015-10-15 04:04:05 -07:00
|
|
|
}
|
2013-12-25 06:13:41 -08:00
|
|
|
cb->items.item.desc = desc;
|
|
|
|
cb->items.item.func = func;
|
|
|
|
cb->func_data = (void *) user_data;
|
|
|
|
cb->priority = priority;
|
|
|
|
_eo_callbacks_sorted_insert(pd, cb);
|
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_event_callback_call(obj, EO_BASE_EVENT_CALLBACK_ADD, (void *)arr);
|
2016-01-27 11:42:48 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
2016-01-27 11:42:48 -08:00
|
|
|
EOLIAN static Eina_Bool
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_event_callback_del(Eo *obj, Eo_Base_Data *pd,
|
2013-12-25 06:13:41 -08:00
|
|
|
const Eo_Event_Description *desc,
|
|
|
|
Eo_Event_Cb func,
|
2014-06-03 03:23:53 -07:00
|
|
|
const void *user_data)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
Eo_Callback_Description *cb;
|
|
|
|
|
2013-12-26 12:00:23 -08:00
|
|
|
for (cb = pd->callbacks; cb; cb = cb->next)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2015-09-26 12:37:03 -07:00
|
|
|
if (!cb->delete_me && (cb->items.item.desc == desc) &&
|
|
|
|
(cb->items.item.func == func) && (cb->func_data == user_data))
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
const Eo_Callback_Array_Item arr[] = { {desc, func}, {NULL, NULL}};
|
|
|
|
|
|
|
|
cb->delete_me = EINA_TRUE;
|
|
|
|
pd->deletions_waiting = EINA_TRUE;
|
|
|
|
_eo_callbacks_clear(pd);
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_event_callback_call(obj, EO_BASE_EVENT_CALLBACK_DEL, (void *)arr);
|
2016-01-27 11:42:48 -08:00
|
|
|
return EINA_TRUE;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG("Callback of object %p with function %p and data %p not found.", obj, func, user_data);
|
2016-01-27 11:42:48 -08:00
|
|
|
return EINA_FALSE;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
2016-01-27 11:42:48 -08:00
|
|
|
EOLIAN static Eina_Bool
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_event_callback_array_priority_add(Eo *obj, Eo_Base_Data *pd,
|
2013-12-25 06:13:41 -08:00
|
|
|
const Eo_Callback_Array_Item *array,
|
|
|
|
Eo_Callback_Priority priority,
|
|
|
|
const void *user_data)
|
|
|
|
{
|
|
|
|
Eo_Callback_Description *cb;
|
|
|
|
|
|
|
|
cb = calloc(1, sizeof(*cb));
|
2016-01-27 11:42:48 -08:00
|
|
|
if (!cb || !array)
|
|
|
|
{
|
|
|
|
ERR("Tried adding array of callbacks with invalid values: cb: %p array: %p\n", cb, array);
|
|
|
|
free(cb);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2013-12-25 06:13:41 -08:00
|
|
|
cb->func_data = (void *) user_data;
|
|
|
|
cb->priority = priority;
|
|
|
|
cb->items.item_array = array;
|
|
|
|
cb->func_array = EINA_TRUE;
|
|
|
|
_eo_callbacks_sorted_insert(pd, cb);
|
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_event_callback_call(obj, EO_BASE_EVENT_CALLBACK_ADD, (void *)array);
|
2016-01-27 11:42:48 -08:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
2016-01-27 11:42:48 -08:00
|
|
|
EOLIAN static Eina_Bool
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_event_callback_array_del(Eo *obj, Eo_Base_Data *pd,
|
2013-12-25 06:13:41 -08:00
|
|
|
const Eo_Callback_Array_Item *array,
|
2014-06-03 03:23:53 -07:00
|
|
|
const void *user_data)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
Eo_Callback_Description *cb;
|
|
|
|
|
2013-12-26 12:00:23 -08:00
|
|
|
for (cb = pd->callbacks; cb; cb = cb->next)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2015-09-26 12:37:03 -07:00
|
|
|
if (!cb->delete_me &&
|
|
|
|
(cb->items.item_array == array) && (cb->func_data == user_data))
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
cb->delete_me = EINA_TRUE;
|
|
|
|
pd->deletions_waiting = EINA_TRUE;
|
|
|
|
_eo_callbacks_clear(pd);
|
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_event_callback_call(obj, EO_BASE_EVENT_CALLBACK_DEL, (void *)array);
|
2016-01-27 11:42:48 -08:00
|
|
|
return EINA_TRUE;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DBG("Callback of object %p with function array %p and data %p not found.", obj, array, user_data);
|
2016-01-27 11:42:48 -08:00
|
|
|
return EINA_FALSE;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
2014-05-19 07:28:49 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_cb_desc_match(const Eo_Event_Description *a, const Eo_Event_Description *b)
|
|
|
|
{
|
2015-10-15 04:04:05 -07:00
|
|
|
/* If one is legacy and the other is not, strcmp. Else, pointer compare. */
|
|
|
|
if (EINA_UNLIKELY(_legacy_event_desc_is(a) != _legacy_event_desc_is(b)))
|
2014-05-19 07:28:49 -07:00
|
|
|
{
|
2015-10-16 03:42:37 -07:00
|
|
|
return !strcmp(a->name, b->name);
|
2014-05-19 07:28:49 -07:00
|
|
|
}
|
2015-10-15 04:04:05 -07:00
|
|
|
|
|
|
|
return (a == b);
|
2014-05-19 07:28:49 -07:00
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_eo_base_event_callback_call(Eo *obj_id, Eo_Base_Data *pd,
|
2013-12-25 06:13:41 -08:00
|
|
|
const Eo_Event_Description *desc,
|
|
|
|
void *event_info)
|
|
|
|
{
|
2015-10-15 04:22:14 -07:00
|
|
|
Eina_Bool ret = EINA_TRUE;
|
2013-12-25 06:13:41 -08:00
|
|
|
Eo_Callback_Description *cb;
|
2016-04-20 15:50:46 -07:00
|
|
|
Eo_Current_Callback_Description *lookup = NULL;
|
|
|
|
Eo_Current_Callback_Description saved;
|
2016-02-29 01:12:35 -08:00
|
|
|
Eo_Event ev;
|
2016-04-20 15:50:46 -07:00
|
|
|
|
2016-02-29 01:12:35 -08:00
|
|
|
ev.obj = obj_id;
|
|
|
|
ev.desc = desc;
|
2016-04-12 07:23:55 -07:00
|
|
|
ev.info = event_info;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
|
|
|
pd->walking_list++;
|
|
|
|
|
2016-04-20 15:50:46 -07:00
|
|
|
// Handle event that require to restart where we were in the nested list walking
|
|
|
|
if (desc->restart)
|
|
|
|
{
|
|
|
|
EINA_INLIST_FOREACH(pd->current, lookup)
|
|
|
|
if (lookup->desc == desc)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// This is the first event to trigger it, so register it here
|
|
|
|
if (!lookup)
|
|
|
|
{
|
|
|
|
// This following trick get us a zero allocation list
|
|
|
|
saved.desc = desc;
|
|
|
|
saved.current = NULL;
|
|
|
|
lookup = &saved;
|
|
|
|
// Ideally there will most of the time be only one item in this list
|
|
|
|
// But just to speed up things, prepend so we find it fast at the end
|
|
|
|
// of this function
|
|
|
|
pd->current = eina_inlist_prepend(pd->current, EINA_INLIST_GET(lookup));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lookup->current) lookup->current = pd->callbacks;
|
|
|
|
cb = lookup->current;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cb = pd->callbacks;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (; cb; cb = cb->next)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2015-11-09 06:06:39 -08:00
|
|
|
if (!cb->delete_me)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2015-11-09 06:06:39 -08:00
|
|
|
if (cb->func_array)
|
|
|
|
{
|
|
|
|
const Eo_Callback_Array_Item *it;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2015-11-09 06:06:39 -08:00
|
|
|
for (it = cb->items.item_array; it->func; it++)
|
|
|
|
{
|
|
|
|
if (!_cb_desc_match(it->desc, desc))
|
|
|
|
continue;
|
|
|
|
if (!it->desc->unfreezable &&
|
|
|
|
(event_freeze_count || pd->event_freeze_count))
|
|
|
|
continue;
|
|
|
|
|
2016-04-20 15:50:46 -07:00
|
|
|
// Handle nested restart of walking list
|
|
|
|
if (lookup) lookup->current = cb->next;
|
2015-11-09 06:06:39 -08:00
|
|
|
/* Abort callback calling if the func says so. */
|
2016-02-29 01:12:35 -08:00
|
|
|
if (!it->func((void *) cb->func_data, &ev))
|
2015-11-09 06:06:39 -08:00
|
|
|
{
|
|
|
|
ret = EINA_FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
2016-04-20 15:50:46 -07:00
|
|
|
// We have actually walked this list during a nested call
|
|
|
|
if (lookup &&
|
|
|
|
lookup->current == NULL)
|
|
|
|
goto end;
|
2015-11-09 06:06:39 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2015-11-09 06:06:39 -08:00
|
|
|
if (!_cb_desc_match(cb->items.item.desc, desc))
|
|
|
|
continue;
|
|
|
|
if (!cb->items.item.desc->unfreezable &&
|
|
|
|
(event_freeze_count || pd->event_freeze_count))
|
2013-12-25 06:13:41 -08:00
|
|
|
continue;
|
|
|
|
|
2016-04-20 15:50:46 -07:00
|
|
|
// Handle nested restart of walking list
|
|
|
|
if (lookup) lookup->current = cb->next;
|
2013-12-25 06:13:41 -08:00
|
|
|
/* Abort callback calling if the func says so. */
|
2016-02-29 01:12:35 -08:00
|
|
|
if (!cb->items.item.func((void *) cb->func_data, &ev))
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
ret = EINA_FALSE;
|
|
|
|
goto end;
|
|
|
|
}
|
2016-04-20 15:50:46 -07:00
|
|
|
// We have actually walked this list during a nested call
|
|
|
|
if (lookup &&
|
|
|
|
lookup->current == NULL)
|
|
|
|
goto end;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
2016-04-20 15:50:46 -07:00
|
|
|
// Handling restarting list walking complete exit.
|
|
|
|
if (lookup) lookup->current = NULL;
|
|
|
|
if (lookup == &saved)
|
|
|
|
{
|
|
|
|
pd->current = eina_inlist_remove(pd->current, EINA_INLIST_GET(lookup));
|
|
|
|
}
|
|
|
|
|
2013-12-25 06:13:41 -08:00
|
|
|
pd->walking_list--;
|
|
|
|
_eo_callbacks_clear(pd);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2016-02-29 02:18:40 -08:00
|
|
|
_eo_event_forwarder_callback(void *data, const Eo_Event *event)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
Eo *new_obj = (Eo *) data;
|
2013-07-25 17:34:46 -07:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2016-04-12 07:23:55 -07:00
|
|
|
ret = eo_event_callback_call(new_obj, event->desc, event->info);
|
2013-12-25 06:13:41 -08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: Change default priority? Maybe call later? */
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_event_callback_forwarder_add(Eo *obj, Eo_Base_Data *pd EINA_UNUSED,
|
2013-12-25 06:13:41 -08:00
|
|
|
const Eo_Event_Description *desc,
|
|
|
|
Eo *new_obj)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */
|
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_event_callback_add(obj, desc, _eo_event_forwarder_callback, new_obj);
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_event_callback_forwarder_del(Eo *obj, Eo_Base_Data *pd EINA_UNUSED,
|
2013-12-25 06:13:41 -08:00
|
|
|
const Eo_Event_Description *desc,
|
|
|
|
Eo *new_obj)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* FIXME: Add it EO_MAGIC_RETURN(new_obj, EO_EINA_MAGIC); */
|
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_event_callback_del(obj, desc, _eo_event_forwarder_callback, new_obj);
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_event_freeze(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
pd->event_freeze_count++;
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_eo_base_event_thaw(Eo *obj, Eo_Base_Data *pd)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
if (pd->event_freeze_count > 0)
|
|
|
|
{
|
|
|
|
pd->event_freeze_count--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Events for object %p have already been thawed.", obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static int
|
|
|
|
_eo_base_event_freeze_count_get(Eo *obj EINA_UNUSED, Eo_Base_Data *pd)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
return pd->event_freeze_count;
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static void
|
2014-07-24 06:41:23 -07:00
|
|
|
_eo_base_event_global_freeze(Eo *klass EINA_UNUSED, void *pd EINA_UNUSED)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
event_freeze_count++;
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static void
|
2014-07-24 06:41:23 -07:00
|
|
|
_eo_base_event_global_thaw(Eo *klass EINA_UNUSED, void *pd EINA_UNUSED)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
if (event_freeze_count > 0)
|
|
|
|
{
|
|
|
|
event_freeze_count--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("Global events have already been thawed.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
EOLIAN static int
|
2014-07-24 06:41:23 -07:00
|
|
|
_eo_base_event_global_freeze_count_get(Eo *klass EINA_UNUSED, void *pd EINA_UNUSED)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
return event_freeze_count;
|
|
|
|
}
|
|
|
|
|
2014-10-21 04:37:00 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_eo_base_composite_attach(Eo *parent_id, Eo_Base_Data *pd EINA_UNUSED, Eo *comp_obj_id)
|
|
|
|
{
|
|
|
|
EO_OBJ_POINTER_RETURN_VAL(comp_obj_id, comp_obj, EINA_FALSE);
|
|
|
|
EO_OBJ_POINTER_RETURN_VAL(parent_id, parent, EINA_FALSE);
|
|
|
|
|
2016-05-05 08:08:08 -07:00
|
|
|
if (!eo_isa(parent_id, _eo_class_id_get(comp_obj->klass)))
|
|
|
|
{
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
2014-10-21 04:37:00 -07:00
|
|
|
|
2016-05-05 08:08:08 -07:00
|
|
|
Eo_Base_Data *comp_pd = eo_data_scope_get(comp_obj_id, EO_BASE_CLASS);
|
|
|
|
/* Don't composite if we already have a composite object of this type */
|
2014-10-21 04:37:00 -07:00
|
|
|
{
|
|
|
|
Eina_List *itr;
|
|
|
|
Eo *emb_obj_id;
|
|
|
|
EINA_LIST_FOREACH(parent->composite_objects, itr, emb_obj_id)
|
|
|
|
{
|
|
|
|
EO_OBJ_POINTER_RETURN_VAL(emb_obj_id, emb_obj, EINA_FALSE);
|
2016-05-05 08:08:08 -07:00
|
|
|
if (emb_obj->klass == comp_obj->klass)
|
2014-10-21 04:37:00 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-05 08:08:08 -07:00
|
|
|
if (eo_composite_part_is(comp_obj_id))
|
|
|
|
{
|
|
|
|
eo_composite_detach(comp_pd->ext->composite_parent, comp_obj_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the parent comp on the child. */
|
|
|
|
_eo_base_extension_need(comp_pd);
|
|
|
|
comp_pd->ext->composite_parent = parent_id;
|
2014-10-21 04:37:00 -07:00
|
|
|
|
2016-05-05 08:08:08 -07:00
|
|
|
parent->composite_objects = eina_list_prepend(parent->composite_objects, comp_obj_id);
|
2014-10-21 04:37:00 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_eo_base_composite_detach(Eo *parent_id, Eo_Base_Data *pd EINA_UNUSED, Eo *comp_obj_id)
|
|
|
|
{
|
|
|
|
EO_OBJ_POINTER_RETURN_VAL(comp_obj_id, comp_obj, EINA_FALSE);
|
|
|
|
EO_OBJ_POINTER_RETURN_VAL(parent_id, parent, EINA_FALSE);
|
|
|
|
|
2016-05-05 08:08:08 -07:00
|
|
|
if (!eo_composite_part_is(comp_obj_id))
|
2014-10-21 04:37:00 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
parent->composite_objects = eina_list_remove(parent->composite_objects, comp_obj_id);
|
2016-05-05 08:08:08 -07:00
|
|
|
/* Clear the comp parent on the child. */
|
|
|
|
{
|
|
|
|
Eo_Base_Data *comp_pd = eo_data_scope_get(comp_obj_id, EO_BASE_CLASS);
|
|
|
|
comp_pd->ext->composite_parent = NULL;
|
|
|
|
|
|
|
|
_eo_base_extension_noneed(comp_pd);
|
|
|
|
}
|
2014-10-21 04:37:00 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2016-05-05 08:08:08 -07:00
|
|
|
_eo_base_composite_part_is(Eo *comp_obj_id EINA_UNUSED, Eo_Base_Data *pd)
|
2014-10-21 04:37:00 -07:00
|
|
|
{
|
2016-05-05 08:08:08 -07:00
|
|
|
return pd->ext && pd->ext->composite_parent;
|
2014-10-21 04:37:00 -07:00
|
|
|
}
|
|
|
|
|
2013-12-25 06:13:41 -08:00
|
|
|
/* Eo_Dbg */
|
|
|
|
EAPI void
|
2014-04-02 01:46:34 -07:00
|
|
|
eo_dbg_info_free(Eo_Dbg_Info *info)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
eina_value_flush(&(info->value));
|
|
|
|
free(info);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_eo_dbg_info_setup(const Eina_Value_Type *type, void *mem)
|
|
|
|
{
|
|
|
|
memset(mem, 0, type->value_size);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_eo_dbg_info_flush(const Eina_Value_Type *type EINA_UNUSED, void *_mem)
|
|
|
|
{
|
|
|
|
Eo_Dbg_Info *mem = *(Eo_Dbg_Info **) _mem;
|
|
|
|
eina_stringshare_del(mem->name);
|
|
|
|
eina_value_flush(&(mem->value));
|
|
|
|
free(mem);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_eo_dbg_info_copy(const Eina_Value_Type *type EINA_UNUSED, const void *_src, void *_dst)
|
|
|
|
{
|
|
|
|
const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) _src;
|
|
|
|
Eo_Dbg_Info **dst = _dst;
|
2013-12-26 11:56:59 -08:00
|
|
|
|
2013-12-25 06:13:41 -08:00
|
|
|
*dst = calloc(1, sizeof(Eo_Dbg_Info));
|
2013-12-26 11:56:59 -08:00
|
|
|
if (!*dst) return EINA_FALSE;
|
2013-12-25 06:13:41 -08:00
|
|
|
(*dst)->name = eina_stringshare_ref((*src)->name);
|
|
|
|
eina_value_copy(&((*src)->value), &((*dst)->value));
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_eo_dbg_info_convert_to(const Eina_Value_Type *type EINA_UNUSED, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem)
|
|
|
|
{
|
|
|
|
/* FIXME: For the meanwhile, just use the inner type for the value. */
|
|
|
|
const Eo_Dbg_Info **src = (const Eo_Dbg_Info **) type_mem;
|
|
|
|
if (convert == EINA_VALUE_TYPE_STRINGSHARE ||
|
|
|
|
convert == EINA_VALUE_TYPE_STRING)
|
|
|
|
{
|
|
|
|
Eina_Bool ret;
|
|
|
|
const char *other_mem;
|
|
|
|
char *inner_val = eina_value_to_string(&(*src)->value);
|
|
|
|
other_mem = inner_val;
|
|
|
|
ret = eina_value_type_pset(convert, convert_mem, &other_mem);
|
|
|
|
free(inner_val);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
eina_error_set(EINA_ERROR_VALUE_FAILED);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_eo_dbg_info_pset(const Eina_Value_Type *type EINA_UNUSED, void *_mem, const void *_ptr)
|
|
|
|
{
|
|
|
|
Eo_Dbg_Info **mem = _mem;
|
|
|
|
if (*mem)
|
|
|
|
free(*mem);
|
|
|
|
*mem = (void *) _ptr;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_eo_dbg_info_pget(const Eina_Value_Type *type EINA_UNUSED, const void *_mem, void *_ptr)
|
|
|
|
{
|
|
|
|
Eo_Dbg_Info **ptr = _ptr;
|
|
|
|
*ptr = (void *) _mem;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2014-04-02 01:46:34 -07:00
|
|
|
static const Eina_Value_Type _EO_DBG_INFO_TYPE = {
|
2013-12-25 06:13:41 -08:00
|
|
|
EINA_VALUE_TYPE_VERSION,
|
|
|
|
sizeof(Eo_Dbg_Info *),
|
|
|
|
"Eo_Dbg_Info_Ptr",
|
|
|
|
_eo_dbg_info_setup,
|
|
|
|
_eo_dbg_info_flush,
|
|
|
|
_eo_dbg_info_copy,
|
|
|
|
NULL,
|
|
|
|
_eo_dbg_info_convert_to,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
_eo_dbg_info_pset,
|
|
|
|
_eo_dbg_info_pget
|
|
|
|
};
|
|
|
|
|
2014-04-02 01:46:34 -07:00
|
|
|
EAPI const Eina_Value_Type *EO_DBG_INFO_TYPE = &_EO_DBG_INFO_TYPE;
|
2013-12-25 06:13:41 -08:00
|
|
|
|
|
|
|
|
|
|
|
/* EOF event callbacks */
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
/* EO_BASE_CLASS stuff */
|
|
|
|
#define MY_CLASS EO_BASE_CLASS
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2015-05-19 03:41:27 -07:00
|
|
|
EOLIAN static Eo *
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_constructor(Eo *obj, Eo_Base_Data *pd EINA_UNUSED)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2016-01-04 00:44:02 -08:00
|
|
|
DBG("%p - %s.", obj, eo_class_name_get(obj));
|
2013-12-25 06:13:41 -08:00
|
|
|
|
|
|
|
_eo_condtor_done(obj);
|
2015-05-19 03:41:27 -07:00
|
|
|
|
|
|
|
return obj;
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
2014-07-24 07:01:36 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_destructor(Eo *obj, Eo_Base_Data *pd)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
2013-11-08 04:24:40 -08:00
|
|
|
Eo *child;
|
2016-04-23 22:38:02 -07:00
|
|
|
Eo_Base_Extension *ext;
|
2013-11-08 04:24:40 -08:00
|
|
|
|
2016-01-04 00:44:02 -08:00
|
|
|
DBG("%p - %s.", obj, eo_class_name_get(obj));
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2015-08-18 01:23:16 -07:00
|
|
|
// special removal - remove from children list by hand after getting
|
|
|
|
// child handle in case unparent method is overridden and does
|
|
|
|
// extra things like removes other children too later on in the list
|
|
|
|
while (pd->children)
|
|
|
|
{
|
|
|
|
child = eina_list_data_get(pd->children);
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_parent_set(child, NULL);
|
2015-08-18 01:23:16 -07:00
|
|
|
}
|
2015-08-21 09:19:47 -07:00
|
|
|
|
2016-05-05 08:08:08 -07:00
|
|
|
/* If we are a composite object, detach children */
|
|
|
|
{
|
|
|
|
EO_OBJ_POINTER_RETURN(obj, obj_data);
|
|
|
|
Eina_List *itr;
|
|
|
|
Eo *emb_obj_id;
|
|
|
|
EINA_LIST_FOREACH(obj_data->composite_objects, itr, emb_obj_id)
|
|
|
|
{
|
|
|
|
eo_composite_detach(obj, emb_obj_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pd->ext && pd->ext->composite_parent)
|
|
|
|
{
|
|
|
|
eo_composite_detach(pd->ext->composite_parent, obj);
|
|
|
|
}
|
|
|
|
|
2015-08-19 20:50:52 -07:00
|
|
|
if (pd->parent)
|
|
|
|
{
|
2015-08-26 06:17:26 -07:00
|
|
|
ERR("Object '%p' still has a parent at the time of destruction.", obj);
|
2015-08-21 09:19:47 -07:00
|
|
|
eo_ref(obj);
|
2016-03-01 10:06:28 -08:00
|
|
|
eo_parent_set(obj, NULL);
|
2015-08-19 20:50:52 -07:00
|
|
|
}
|
2013-11-08 04:24:40 -08:00
|
|
|
|
2016-04-12 09:04:11 -07:00
|
|
|
_eo_generic_data_del_all(obj, pd);
|
2014-06-03 03:23:53 -07:00
|
|
|
_wref_destruct(pd);
|
|
|
|
_eo_callback_remove_all(pd);
|
2013-12-25 06:13:41 -08:00
|
|
|
|
2016-04-23 22:38:02 -07:00
|
|
|
ext = pd->ext;
|
|
|
|
if (ext)
|
2016-04-19 01:21:21 -07:00
|
|
|
{
|
2016-04-23 22:38:02 -07:00
|
|
|
eina_stringshare_del(ext->id);
|
|
|
|
ext->id = NULL;
|
|
|
|
eina_stringshare_del(ext->comment);
|
|
|
|
ext->comment = NULL;
|
|
|
|
_eo_base_extension_free(ext);
|
|
|
|
pd->ext = NULL;
|
2016-04-19 01:21:21 -07:00
|
|
|
}
|
2016-04-19 00:34:53 -07:00
|
|
|
|
2013-12-25 06:13:41 -08:00
|
|
|
_eo_condtor_done(obj);
|
|
|
|
}
|
|
|
|
|
2014-07-24 07:01:36 -07:00
|
|
|
EOLIAN static Eo *
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_finalize(Eo *obj, Eo_Base_Data *pd EINA_UNUSED)
|
2014-05-30 03:17:36 -07:00
|
|
|
{
|
2015-05-20 06:56:45 -07:00
|
|
|
return obj;
|
2014-05-30 03:17:36 -07:00
|
|
|
}
|
|
|
|
|
2014-07-24 07:01:36 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_class_constructor(Eo_Class *klass EINA_UNUSED)
|
2013-12-25 06:13:41 -08:00
|
|
|
{
|
|
|
|
event_freeze_count = 0;
|
2014-05-19 07:17:08 -07:00
|
|
|
_legacy_events_hash = eina_hash_stringshared_new(_legacy_events_hash_free_cb);
|
|
|
|
}
|
|
|
|
|
2014-07-24 07:01:36 -07:00
|
|
|
EOLIAN static void
|
2014-06-03 03:23:53 -07:00
|
|
|
_eo_base_class_destructor(Eo_Class *klass EINA_UNUSED)
|
2014-05-19 07:17:08 -07:00
|
|
|
{
|
|
|
|
eina_hash_free(_legacy_events_hash);
|
2013-12-25 06:13:41 -08:00
|
|
|
}
|
|
|
|
|
2014-06-03 03:23:53 -07:00
|
|
|
#include "eo_base.eo.c"
|