aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/canvas/evas_data.c
blob: 3ac9d63577a0f008209ee1a388b27b9e4ee07985 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "evas_common.h"
#include "evas_private.h"


EAPI void
evas_object_data_set(Evas_Object *obj, const char *key, const void *data)
{
   Evas_Data_Node *node;

   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
   return;
   MAGIC_CHECK_END();
   if (!key) return;

   evas_object_data_del(obj, key);
   if (!data) return;
   node = malloc(sizeof(Evas_Data_Node) + strlen(key) + 1);
   node->key = (char *)node + sizeof(Evas_Data_Node);
   strcpy(node->key, key);
   node->data = (void *)data;
   obj->data.elements = eina_list_prepend(obj->data.elements, node);
}

EAPI void *
evas_object_data_get(const Evas_Object *obj, const char *key)
{
   Eina_List *l;
   Evas_Data_Node *node;

   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
   return NULL;
   MAGIC_CHECK_END();
   if (!key) return NULL;

   EINA_LIST_FOREACH(obj->data.elements, l, node)
     {
	if (!strcmp(node->key, key))
	  {
	     Eina_List *lst;
	     lst = obj->data.elements;
	     lst = eina_list_promote_list(lst, l);
	     ((Evas_Object *)obj)->data.elements = lst;
	     return node->data;
	  }
     }
   return NULL;
}

EAPI void *
evas_object_data_del(Evas_Object *obj, const char *key)
{
   Eina_List *l;
   Evas_Data_Node *node;

   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
   return NULL;
   MAGIC_CHECK_END();
   if (!key) return NULL;
   EINA_LIST_FOREACH(obj->data.elements, l, node)
     {
	if (!strcmp(node->key, key))
	  {
	     void *data;

	     data = node->data;
	     obj->data.elements = eina_list_remove_list(obj->data.elements, l);
	     free(node);
	     return data;
	  }
     }
   return NULL;
}