aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/evas/src/lib/canvas/evas_data.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-01-04 18:41:13 +1000
committerDavid Walter Seikel2012-01-04 18:41:13 +1000
commitdd7595a3475407a7fa96a97393bae8c5220e8762 (patch)
treee341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/evas/src/lib/canvas/evas_data.c
parentAdd the skeleton. (diff)
downloadSledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2
SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/evas/src/lib/canvas/evas_data.c')
-rw-r--r--libraries/evas/src/lib/canvas/evas_data.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/libraries/evas/src/lib/canvas/evas_data.c b/libraries/evas/src/lib/canvas/evas_data.c
new file mode 100644
index 0000000..3ac9d63
--- /dev/null
+++ b/libraries/evas/src/lib/canvas/evas_data.c
@@ -0,0 +1,72 @@
1#include "evas_common.h"
2#include "evas_private.h"
3
4
5EAPI void
6evas_object_data_set(Evas_Object *obj, const char *key, const void *data)
7{
8 Evas_Data_Node *node;
9
10 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
11 return;
12 MAGIC_CHECK_END();
13 if (!key) return;
14
15 evas_object_data_del(obj, key);
16 if (!data) return;
17 node = malloc(sizeof(Evas_Data_Node) + strlen(key) + 1);
18 node->key = (char *)node + sizeof(Evas_Data_Node);
19 strcpy(node->key, key);
20 node->data = (void *)data;
21 obj->data.elements = eina_list_prepend(obj->data.elements, node);
22}
23
24EAPI void *
25evas_object_data_get(const Evas_Object *obj, const char *key)
26{
27 Eina_List *l;
28 Evas_Data_Node *node;
29
30 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
31 return NULL;
32 MAGIC_CHECK_END();
33 if (!key) return NULL;
34
35 EINA_LIST_FOREACH(obj->data.elements, l, node)
36 {
37 if (!strcmp(node->key, key))
38 {
39 Eina_List *lst;
40 lst = obj->data.elements;
41 lst = eina_list_promote_list(lst, l);
42 ((Evas_Object *)obj)->data.elements = lst;
43 return node->data;
44 }
45 }
46 return NULL;
47}
48
49EAPI void *
50evas_object_data_del(Evas_Object *obj, const char *key)
51{
52 Eina_List *l;
53 Evas_Data_Node *node;
54
55 MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
56 return NULL;
57 MAGIC_CHECK_END();
58 if (!key) return NULL;
59 EINA_LIST_FOREACH(obj->data.elements, l, node)
60 {
61 if (!strcmp(node->key, key))
62 {
63 void *data;
64
65 data = node->data;
66 obj->data.elements = eina_list_remove_list(obj->data.elements, l);
67 free(node);
68 return data;
69 }
70 }
71 return NULL;
72}