diff options
Diffstat (limited to 'libraries/eina/src/lib/eina_accessor.c')
-rw-r--r-- | libraries/eina/src/lib/eina_accessor.c | 176 |
1 files changed, 0 insertions, 176 deletions
diff --git a/libraries/eina/src/lib/eina_accessor.c b/libraries/eina/src/lib/eina_accessor.c deleted file mode 100644 index aec44ef..0000000 --- a/libraries/eina/src/lib/eina_accessor.c +++ /dev/null | |||
@@ -1,176 +0,0 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2002-2008 Cedric Bail | ||
3 | * | ||
4 | * This library is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU Lesser General Public | ||
6 | * License as published by the Free Software Foundation; either | ||
7 | * version 2.1 of the License, or (at your option) any later version. | ||
8 | * | ||
9 | * This library is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * Lesser General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU Lesser General Public | ||
15 | * License along with this library; | ||
16 | * if not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include "config.h" | ||
21 | #endif | ||
22 | |||
23 | #include <stdlib.h> | ||
24 | |||
25 | #include "eina_config.h" | ||
26 | #include "eina_private.h" | ||
27 | |||
28 | /* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */ | ||
29 | #include "eina_safety_checks.h" | ||
30 | #include "eina_accessor.h" | ||
31 | |||
32 | /*============================================================================* | ||
33 | * Local * | ||
34 | *============================================================================*/ | ||
35 | |||
36 | /** | ||
37 | * @cond LOCAL | ||
38 | */ | ||
39 | |||
40 | static const char EINA_MAGIC_ACCESSOR_STR[] = "Eina Accessor"; | ||
41 | |||
42 | #define EINA_MAGIC_CHECK_ACCESSOR(d) \ | ||
43 | do { \ | ||
44 | if (!EINA_MAGIC_CHECK(d, EINA_MAGIC_ACCESSOR)) { \ | ||
45 | EINA_MAGIC_FAIL(d, EINA_MAGIC_ACCESSOR); } \ | ||
46 | } while(0) | ||
47 | |||
48 | /** | ||
49 | * @endcond | ||
50 | */ | ||
51 | |||
52 | /*============================================================================* | ||
53 | * Global * | ||
54 | *============================================================================*/ | ||
55 | |||
56 | /** | ||
57 | * @internal | ||
58 | * @brief Initialize the accessor module. | ||
59 | * | ||
60 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
61 | * | ||
62 | * This function sets up the accessor module of Eina. It is called by | ||
63 | * eina_init(). | ||
64 | * | ||
65 | * @see eina_init() | ||
66 | */ | ||
67 | Eina_Bool | ||
68 | eina_accessor_init(void) | ||
69 | { | ||
70 | return eina_magic_string_set(EINA_MAGIC_ACCESSOR, EINA_MAGIC_ACCESSOR_STR); | ||
71 | } | ||
72 | |||
73 | /** | ||
74 | * @internal | ||
75 | * @brief Shut down the accessor module. | ||
76 | * | ||
77 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
78 | * | ||
79 | * This function shuts down the accessor module set up by | ||
80 | * eina_accessor_init(). It is called by eina_shutdown(). | ||
81 | * | ||
82 | * @see eina_shutdown() | ||
83 | */ | ||
84 | Eina_Bool | ||
85 | eina_accessor_shutdown(void) | ||
86 | { | ||
87 | return EINA_TRUE; | ||
88 | } | ||
89 | |||
90 | /*============================================================================* | ||
91 | * API * | ||
92 | *============================================================================*/ | ||
93 | |||
94 | |||
95 | EAPI void | ||
96 | eina_accessor_free(Eina_Accessor *accessor) | ||
97 | { | ||
98 | EINA_MAGIC_CHECK_ACCESSOR(accessor); | ||
99 | EINA_SAFETY_ON_NULL_RETURN(accessor); | ||
100 | EINA_SAFETY_ON_NULL_RETURN(accessor->free); | ||
101 | accessor->free(accessor); | ||
102 | } | ||
103 | |||
104 | EAPI void * | ||
105 | eina_accessor_container_get(Eina_Accessor *accessor) | ||
106 | { | ||
107 | EINA_MAGIC_CHECK_ACCESSOR(accessor); | ||
108 | EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, NULL); | ||
109 | EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_container, NULL); | ||
110 | return accessor->get_container(accessor); | ||
111 | } | ||
112 | |||
113 | EAPI Eina_Bool | ||
114 | eina_accessor_data_get(Eina_Accessor *accessor, | ||
115 | unsigned int position, | ||
116 | void **data) | ||
117 | { | ||
118 | EINA_MAGIC_CHECK_ACCESSOR(accessor); | ||
119 | EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE); | ||
120 | EINA_SAFETY_ON_NULL_RETURN_VAL(accessor->get_at, EINA_FALSE); | ||
121 | EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE); | ||
122 | return accessor->get_at(accessor, position, data); | ||
123 | } | ||
124 | |||
125 | EAPI void | ||
126 | eina_accessor_over(Eina_Accessor *accessor, | ||
127 | Eina_Each_Cb cb, | ||
128 | unsigned int start, | ||
129 | unsigned int end, | ||
130 | const void *fdata) | ||
131 | { | ||
132 | const void *container; | ||
133 | void *data; | ||
134 | unsigned int i; | ||
135 | |||
136 | EINA_MAGIC_CHECK_ACCESSOR(accessor); | ||
137 | EINA_SAFETY_ON_NULL_RETURN(accessor); | ||
138 | EINA_SAFETY_ON_NULL_RETURN(accessor->get_container); | ||
139 | EINA_SAFETY_ON_NULL_RETURN(accessor->get_at); | ||
140 | EINA_SAFETY_ON_NULL_RETURN(cb); | ||
141 | EINA_SAFETY_ON_FALSE_RETURN(start < end); | ||
142 | |||
143 | if (!eina_accessor_lock(accessor)) | ||
144 | return ; | ||
145 | |||
146 | container = accessor->get_container(accessor); | ||
147 | for (i = start; i < end && accessor->get_at(accessor, i, &data) == EINA_TRUE; | ||
148 | ++i) | ||
149 | if (cb(container, data, (void *)fdata) != EINA_TRUE) | ||
150 | goto on_exit; | ||
151 | |||
152 | on_exit: | ||
153 | (void) eina_accessor_unlock(accessor); | ||
154 | } | ||
155 | |||
156 | EAPI Eina_Bool | ||
157 | eina_accessor_lock(Eina_Accessor *accessor) | ||
158 | { | ||
159 | EINA_MAGIC_CHECK_ACCESSOR(accessor); | ||
160 | EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE); | ||
161 | |||
162 | if (accessor->lock) | ||
163 | return accessor->lock(accessor); | ||
164 | return EINA_TRUE; | ||
165 | } | ||
166 | |||
167 | EAPI Eina_Bool | ||
168 | eina_accessor_unlock(Eina_Accessor *accessor) | ||
169 | { | ||
170 | EINA_MAGIC_CHECK_ACCESSOR(accessor); | ||
171 | EINA_SAFETY_ON_NULL_RETURN_VAL(accessor, EINA_FALSE); | ||
172 | |||
173 | if (accessor->unlock) | ||
174 | return accessor->unlock(accessor); | ||
175 | return EINA_TRUE; | ||
176 | } | ||