diff options
author | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-23 23:30:42 +1000 |
commit | 825a3d837a33f226c879cd02ad15c3fba57e8b2c (patch) | |
tree | 75f57bd9c4253508d338dc79ba8e57a7abc42255 /libraries/eina/src/include | |
parent | Add ability to disable the test harness, or the Lua compile test. (diff) | |
download | SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.zip SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.gz SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.bz2 SledjHamr-825a3d837a33f226c879cd02ad15c3fba57e8b2c.tar.xz |
Update the EFL to what I'm actually using, coz I'm using some stuff not yet released.
Diffstat (limited to '')
39 files changed, 6222 insertions, 353 deletions
diff --git a/libraries/eina/src/include/Eina.h b/libraries/eina/src/include/Eina.h index 68c41f5..721a991 100644 --- a/libraries/eina/src/include/Eina.h +++ b/libraries/eina/src/include/Eina.h | |||
@@ -47,7 +47,7 @@ | |||
47 | * | 47 | * |
48 | * @version 1.1 | 48 | * @version 1.1 |
49 | * @date 2008-2011 | 49 | * @date 2008-2011 |
50 | * | 50 | * |
51 | * @section eina_intro_sec Introduction | 51 | * @section eina_intro_sec Introduction |
52 | * | 52 | * |
53 | * The Eina library is a library that implements an API for data types | 53 | * The Eina library is a library that implements an API for data types |
@@ -59,10 +59,11 @@ | |||
59 | * Linux, BSD, Opensolaris and Windows (XP and CE). | 59 | * Linux, BSD, Opensolaris and Windows (XP and CE). |
60 | * | 60 | * |
61 | * The data types that are available are (see @ref Eina_Data_Types_Group): | 61 | * The data types that are available are (see @ref Eina_Data_Types_Group): |
62 | * @li @ref Eina_Inline_Array_Group standard array of inlined members. | ||
62 | * @li @ref Eina_Array_Group standard array of @c void* data. | 63 | * @li @ref Eina_Array_Group standard array of @c void* data. |
63 | * @li @ref Eina_Hash_Group standard hash of @c void* data. | 64 | * @li @ref Eina_Hash_Group standard hash of @c void* data. |
64 | * @li @ref Eina_Inline_List_Group list with nodes inlined into user type. | 65 | * @li @ref Eina_Inline_List_Group list with nodes inlined into user type. |
65 | * @li @ref Eina_CList_Group compact inlined list. | 66 | * @li @ref Eina_CList_Group Compact List. |
66 | * @li @ref Eina_List_Group standard list of @c void* data. | 67 | * @li @ref Eina_List_Group standard list of @c void* data. |
67 | * @li @ref Eina_Iterator_Group Iterator functions. | 68 | * @li @ref Eina_Iterator_Group Iterator functions. |
68 | * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data. | 69 | * @li @ref Eina_Matrixsparse_Group sparse matrix of @c void* data. |
@@ -89,7 +90,7 @@ | |||
89 | * | 90 | * |
90 | * Please see the @ref authors page for contact details. | 91 | * Please see the @ref authors page for contact details. |
91 | * | 92 | * |
92 | * @defgroup Eina_Data_Types_Group Data types | 93 | * @defgroup Eina_Data_Types_Group Data Types |
93 | * | 94 | * |
94 | * Eina provide easy to use and optimized data types and structures. | 95 | * Eina provide easy to use and optimized data types and structures. |
95 | * | 96 | * |
@@ -158,6 +159,7 @@ extern "C" { | |||
158 | #include "eina_mempool.h" | 159 | #include "eina_mempool.h" |
159 | #include "eina_error.h" | 160 | #include "eina_error.h" |
160 | #include "eina_log.h" | 161 | #include "eina_log.h" |
162 | #include "eina_inarray.h" | ||
161 | #include "eina_array.h" | 163 | #include "eina_array.h" |
162 | #include "eina_binshare.h" | 164 | #include "eina_binshare.h" |
163 | #include "eina_stringshare.h" | 165 | #include "eina_stringshare.h" |
@@ -186,6 +188,7 @@ extern "C" { | |||
186 | #include "eina_refcount.h" | 188 | #include "eina_refcount.h" |
187 | #include "eina_mmap.h" | 189 | #include "eina_mmap.h" |
188 | #include "eina_xattr.h" | 190 | #include "eina_xattr.h" |
191 | #include "eina_value.h" | ||
189 | 192 | ||
190 | #ifdef __cplusplus | 193 | #ifdef __cplusplus |
191 | } | 194 | } |
diff --git a/libraries/eina/src/include/Makefile.am b/libraries/eina/src/include/Makefile.am index 41a37cb..a818d5f 100644 --- a/libraries/eina/src/include/Makefile.am +++ b/libraries/eina/src/include/Makefile.am | |||
@@ -14,6 +14,8 @@ eina_hash.h \ | |||
14 | eina_inline_hash.x \ | 14 | eina_inline_hash.x \ |
15 | eina_lalloc.h \ | 15 | eina_lalloc.h \ |
16 | eina_clist.h \ | 16 | eina_clist.h \ |
17 | eina_inline_clist.x \ | ||
18 | eina_inarray.h \ | ||
17 | eina_inlist.h \ | 19 | eina_inlist.h \ |
18 | eina_list.h \ | 20 | eina_list.h \ |
19 | eina_file.h \ | 21 | eina_file.h \ |
@@ -60,7 +62,9 @@ eina_lock.h \ | |||
60 | eina_prefix.h \ | 62 | eina_prefix.h \ |
61 | eina_refcount.h \ | 63 | eina_refcount.h \ |
62 | eina_mmap.h \ | 64 | eina_mmap.h \ |
63 | eina_xattr.h | 65 | eina_xattr.h \ |
66 | eina_value.h \ | ||
67 | eina_inline_value.x | ||
64 | 68 | ||
65 | # Will be back for developper after 1.1. | 69 | # Will be back for developper after 1.1. |
66 | # eina_object.h | 70 | # eina_object.h |
diff --git a/libraries/eina/src/include/Makefile.in b/libraries/eina/src/include/Makefile.in index f6e0074..ea922e5 100644 --- a/libraries/eina/src/include/Makefile.in +++ b/libraries/eina/src/include/Makefile.in | |||
@@ -78,23 +78,24 @@ am__dist_installed_headers_DATA_DIST = eina_safety_checks.h \ | |||
78 | eina_error.h eina_log.h eina_inline_log.x eina_fp.h \ | 78 | eina_error.h eina_log.h eina_inline_log.x eina_fp.h \ |
79 | eina_inline_f32p32.x eina_inline_f16p16.x eina_inline_f8p24.x \ | 79 | eina_inline_f32p32.x eina_inline_f16p16.x eina_inline_f8p24.x \ |
80 | eina_inline_fp.x eina_hash.h eina_inline_hash.x eina_lalloc.h \ | 80 | eina_inline_fp.x eina_hash.h eina_inline_hash.x eina_lalloc.h \ |
81 | eina_clist.h eina_inlist.h eina_list.h eina_file.h \ | 81 | eina_clist.h eina_inline_clist.x eina_inarray.h eina_inlist.h \ |
82 | eina_mempool.h eina_module.h eina_rectangle.h eina_types.h \ | 82 | eina_list.h eina_file.h eina_mempool.h eina_module.h \ |
83 | eina_array.h eina_counter.h eina_inline_array.x eina_magic.h \ | 83 | eina_rectangle.h eina_types.h eina_array.h eina_counter.h \ |
84 | eina_stringshare.h eina_binshare.h eina_binbuf.h \ | 84 | eina_inline_array.x eina_magic.h eina_stringshare.h \ |
85 | eina_ustringshare.h eina_inline_stringshare.x \ | 85 | eina_binshare.h eina_binbuf.h eina_ustringshare.h \ |
86 | eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \ | 86 | eina_inline_stringshare.x eina_inline_ustringshare.x \ |
87 | eina_convert.h eina_rbtree.h eina_benchmark.h \ | 87 | eina_inline_list.x eina_accessor.h eina_convert.h \ |
88 | eina_inline_rbtree.x eina_inline_mempool.x \ | 88 | eina_rbtree.h eina_benchmark.h eina_inline_rbtree.x \ |
89 | eina_inline_rectangle.x eina_inline_trash.x eina_trash.h \ | 89 | eina_inline_mempool.x eina_inline_rectangle.x \ |
90 | eina_iterator.h eina_main.h eina_cpu.h eina_sched.h \ | 90 | eina_inline_trash.x eina_trash.h eina_iterator.h eina_main.h \ |
91 | eina_tiler.h eina_hamster.h eina_matrixsparse.h \ | 91 | eina_cpu.h eina_sched.h eina_tiler.h eina_hamster.h \ |
92 | eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \ | 92 | eina_matrixsparse.h eina_inline_tiler.x eina_str.h \ |
93 | eina_ustrbuf.h eina_unicode.h eina_quadtree.h \ | 93 | eina_inline_str.x eina_strbuf.h eina_ustrbuf.h eina_unicode.h \ |
94 | eina_simple_xml_parser.h eina_lock.h eina_prefix.h \ | 94 | eina_quadtree.h eina_simple_xml_parser.h eina_lock.h \ |
95 | eina_refcount.h eina_mmap.h eina_xattr.h \ | 95 | eina_prefix.h eina_refcount.h eina_mmap.h eina_xattr.h \ |
96 | eina_inline_lock_wince.x eina_inline_lock_win32.x \ | 96 | eina_value.h eina_inline_value.x eina_inline_lock_wince.x \ |
97 | eina_inline_lock_posix.x eina_inline_lock_void.x | 97 | eina_inline_lock_win32.x eina_inline_lock_posix.x \ |
98 | eina_inline_lock_void.x | ||
98 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; | 99 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; |
99 | am__vpath_adj = case $$p in \ | 100 | am__vpath_adj = case $$p in \ |
100 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ | 101 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ |
@@ -163,7 +164,9 @@ EFL_SIMD_FLAGS = @EFL_SIMD_FLAGS@ | |||
163 | EGREP = @EGREP@ | 164 | EGREP = @EGREP@ |
164 | EINA_CFLAGS = @EINA_CFLAGS@ | 165 | EINA_CFLAGS = @EINA_CFLAGS@ |
165 | EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ | 166 | EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@ |
167 | EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@ | ||
166 | EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ | 168 | EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ |
169 | EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@ | ||
167 | EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ | 170 | EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ |
168 | EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ | 171 | EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ |
169 | EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ | 172 | EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ |
@@ -215,8 +218,6 @@ PACKAGE_URL = @PACKAGE_URL@ | |||
215 | PACKAGE_VERSION = @PACKAGE_VERSION@ | 218 | PACKAGE_VERSION = @PACKAGE_VERSION@ |
216 | PATH_SEPARATOR = @PATH_SEPARATOR@ | 219 | PATH_SEPARATOR = @PATH_SEPARATOR@ |
217 | PKG_CONFIG = @PKG_CONFIG@ | 220 | PKG_CONFIG = @PKG_CONFIG@ |
218 | PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ | ||
219 | PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ | ||
220 | RANLIB = @RANLIB@ | 221 | RANLIB = @RANLIB@ |
221 | SED = @SED@ | 222 | SED = @SED@ |
222 | SET_MAKE = @SET_MAKE@ | 223 | SET_MAKE = @SET_MAKE@ |
@@ -295,10 +296,10 @@ EINAHEADERS = eina_safety_checks.h eina_error.h eina_log.h \ | |||
295 | eina_inline_log.x eina_fp.h eina_inline_f32p32.x \ | 296 | eina_inline_log.x eina_fp.h eina_inline_f32p32.x \ |
296 | eina_inline_f16p16.x eina_inline_f8p24.x eina_inline_fp.x \ | 297 | eina_inline_f16p16.x eina_inline_f8p24.x eina_inline_fp.x \ |
297 | eina_hash.h eina_inline_hash.x eina_lalloc.h eina_clist.h \ | 298 | eina_hash.h eina_inline_hash.x eina_lalloc.h eina_clist.h \ |
298 | eina_inlist.h eina_list.h eina_file.h eina_mempool.h \ | 299 | eina_inline_clist.x eina_inarray.h eina_inlist.h eina_list.h \ |
299 | eina_module.h eina_rectangle.h eina_types.h eina_array.h \ | 300 | eina_file.h eina_mempool.h eina_module.h eina_rectangle.h \ |
300 | eina_counter.h eina_inline_array.x eina_magic.h \ | 301 | eina_types.h eina_array.h eina_counter.h eina_inline_array.x \ |
301 | eina_stringshare.h eina_binshare.h eina_binbuf.h \ | 302 | eina_magic.h eina_stringshare.h eina_binshare.h eina_binbuf.h \ |
302 | eina_ustringshare.h eina_inline_stringshare.x \ | 303 | eina_ustringshare.h eina_inline_stringshare.x \ |
303 | eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \ | 304 | eina_inline_ustringshare.x eina_inline_list.x eina_accessor.h \ |
304 | eina_convert.h eina_rbtree.h eina_benchmark.h \ | 305 | eina_convert.h eina_rbtree.h eina_benchmark.h \ |
@@ -309,8 +310,9 @@ EINAHEADERS = eina_safety_checks.h eina_error.h eina_log.h \ | |||
309 | eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \ | 310 | eina_inline_tiler.x eina_str.h eina_inline_str.x eina_strbuf.h \ |
310 | eina_ustrbuf.h eina_unicode.h eina_quadtree.h \ | 311 | eina_ustrbuf.h eina_unicode.h eina_quadtree.h \ |
311 | eina_simple_xml_parser.h eina_lock.h eina_prefix.h \ | 312 | eina_simple_xml_parser.h eina_lock.h eina_prefix.h \ |
312 | eina_refcount.h eina_mmap.h eina_xattr.h $(am__append_1) \ | 313 | eina_refcount.h eina_mmap.h eina_xattr.h eina_value.h \ |
313 | $(am__append_2) $(am__append_3) $(am__append_4) | 314 | eina_inline_value.x $(am__append_1) $(am__append_2) \ |
315 | $(am__append_3) $(am__append_4) | ||
314 | installed_mainheaderdir = $(includedir)/eina-@VMAJ@ | 316 | installed_mainheaderdir = $(includedir)/eina-@VMAJ@ |
315 | dist_installed_mainheader_DATA = Eina.h eina_config.h | 317 | dist_installed_mainheader_DATA = Eina.h eina_config.h |
316 | installed_headersdir = $(includedir)/eina-@VMAJ@/eina | 318 | installed_headersdir = $(includedir)/eina-@VMAJ@/eina |
diff --git a/libraries/eina/src/include/eina_array.h b/libraries/eina/src/include/eina_array.h index d33f5e9..53183b4 100644 --- a/libraries/eina/src/include/eina_array.h +++ b/libraries/eina/src/include/eina_array.h | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | 32 | ||
33 | /** | 33 | /** |
34 | * @page array_01_example_page Basic array usage | 34 | * @page eina_array_01_example_page Basic array usage |
35 | * @dontinclude eina_array_01.c | 35 | * @dontinclude eina_array_01.c |
36 | * | 36 | * |
37 | * For this example we add stdlib.h, stdio.h and string.h for some | 37 | * For this example we add stdlib.h, stdio.h and string.h for some |
@@ -94,7 +94,7 @@ | |||
94 | */ | 94 | */ |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * @page array_02_example_page Removing array elements | 97 | * @page eina_array_02_example_page Removing array elements |
98 | * @dontinclude eina_array_02.c | 98 | * @dontinclude eina_array_02.c |
99 | * | 99 | * |
100 | * Just the usual includes: | 100 | * Just the usual includes: |
@@ -169,7 +169,7 @@ | |||
169 | * element, use eina_array_push() and to remove the last element, use | 169 | * element, use eina_array_push() and to remove the last element, use |
170 | * eina_array_pop(). To retrieve the element at a given position, use | 170 | * eina_array_pop(). To retrieve the element at a given position, use |
171 | * eina_array_data_get(). The number of elements can be retrieved with | 171 | * eina_array_data_get(). The number of elements can be retrieved with |
172 | * eina_array_count_get(). | 172 | * eina_array_count(). |
173 | * | 173 | * |
174 | * Eina_Array is different from a conventional C array in a number of ways, most | 174 | * Eina_Array is different from a conventional C array in a number of ways, most |
175 | * importantly they grow and shrink dynamically, this means that if you add an | 175 | * importantly they grow and shrink dynamically, this means that if you add an |
@@ -191,8 +191,8 @@ | |||
191 | * of void pointers. | 191 | * of void pointers. |
192 | * | 192 | * |
193 | * See here some examples: | 193 | * See here some examples: |
194 | * @li @ref array_01_example_page | 194 | * @li @ref eina_array_01_example_page |
195 | * @li @ref array_02_example_page | 195 | * @li @ref eina_array_02_example_page |
196 | */ | 196 | */ |
197 | 197 | ||
198 | /** | 198 | /** |
@@ -351,7 +351,8 @@ static inline void *eina_array_data_get(const Eina_Array *array, | |||
351 | static inline void eina_array_data_set(const Eina_Array *array, | 351 | static inline void eina_array_data_set(const Eina_Array *array, |
352 | unsigned int idx, | 352 | unsigned int idx, |
353 | const void *data) EINA_ARG_NONNULL(1); | 353 | const void *data) EINA_ARG_NONNULL(1); |
354 | static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1); | 354 | static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_DEPRECATED; |
355 | static inline unsigned int eina_array_count(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | ||
355 | 356 | ||
356 | /** | 357 | /** |
357 | * @brief Returned a new iterator associated to an array. | 358 | * @brief Returned a new iterator associated to an array. |
@@ -394,7 +395,7 @@ EAPI Eina_Accessor *eina_array_accessor_new(const Eina_Array *array) EINA | |||
394 | */ | 395 | */ |
395 | static inline Eina_Bool eina_array_foreach(Eina_Array *array, | 396 | static inline Eina_Bool eina_array_foreach(Eina_Array *array, |
396 | Eina_Each_Cb cb, | 397 | Eina_Each_Cb cb, |
397 | void *data); | 398 | void *fdata); |
398 | /** | 399 | /** |
399 | * @def EINA_ARRAY_ITER_NEXT | 400 | * @def EINA_ARRAY_ITER_NEXT |
400 | * @brief Macro to iterate over an array easily. | 401 | * @brief Macro to iterate over an array easily. |
@@ -429,7 +430,7 @@ static inline Eina_Bool eina_array_foreach(Eina_Array *array, | |||
429 | */ | 430 | */ |
430 | #define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \ | 431 | #define EINA_ARRAY_ITER_NEXT(array, index, item, iterator) \ |
431 | for (index = 0, iterator = (array)->data; \ | 432 | for (index = 0, iterator = (array)->data; \ |
432 | (index < eina_array_count_get(array)) && ((item = *((iterator)++))); \ | 433 | (index < eina_array_count(array)) && ((item = *((iterator)++))); \ |
433 | ++(index)) | 434 | ++(index)) |
434 | 435 | ||
435 | #include "eina_inline_array.x" | 436 | #include "eina_inline_array.x" |
diff --git a/libraries/eina/src/include/eina_benchmark.h b/libraries/eina/src/include/eina_benchmark.h index 721e1c0..9e96d64 100644 --- a/libraries/eina/src/include/eina_benchmark.h +++ b/libraries/eina/src/include/eina_benchmark.h | |||
@@ -398,9 +398,9 @@ EAPI void eina_benchmark_free(Eina_Benchmark *bench); | |||
398 | * | 398 | * |
399 | * This function adds the test named @p name to @p benchmark. @p | 399 | * This function adds the test named @p name to @p benchmark. @p |
400 | * bench_cb is the function called when the test is executed. That | 400 | * bench_cb is the function called when the test is executed. That |
401 | * test can be executed a certain amount of time. @p start, @p end and | 401 | * test can be executed a certain amount of time. @p count_start, @p count_end and |
402 | * @p step define a loop with a step increment. The integer that is | 402 | * @p count_step define a loop with a step increment. The integer that is |
403 | * increasing by @p step from @p start to @p end is passed to @p | 403 | * increasing by @p count_step from @p count_start to @p count_end is passed to @p |
404 | * bench_cb when eina_benchmark_run() is called. | 404 | * bench_cb when eina_benchmark_run() is called. |
405 | * | 405 | * |
406 | * If @p bench is @c NULL, this function returns imediatly. If the | 406 | * If @p bench is @c NULL, this function returns imediatly. If the |
@@ -413,7 +413,7 @@ EAPI Eina_Bool eina_benchmark_register(Eina_Benchmark *bench, | |||
413 | Eina_Benchmark_Specimens bench_cb, | 413 | Eina_Benchmark_Specimens bench_cb, |
414 | int count_start, | 414 | int count_start, |
415 | int count_end, | 415 | int count_end, |
416 | int count_set); | 416 | int count_step); |
417 | 417 | ||
418 | /** | 418 | /** |
419 | * @brief Run the benchmark tests that have been registered. | 419 | * @brief Run the benchmark tests that have been registered. |
diff --git a/libraries/eina/src/include/eina_binbuf.h b/libraries/eina/src/include/eina_binbuf.h index 92f788e..7c3524b 100644 --- a/libraries/eina/src/include/eina_binbuf.h +++ b/libraries/eina/src/include/eina_binbuf.h | |||
@@ -49,6 +49,24 @@ typedef struct _Eina_Strbuf Eina_Binbuf; | |||
49 | EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | 49 | EAPI Eina_Binbuf *eina_binbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * @brief Create a new string buffer using the passed string. The passed | ||
53 | * string is used directly as the buffer, it's somehow the opposite function of | ||
54 | * @ref eina_binbuf_string_steal . The passed string must be malloced. | ||
55 | * | ||
56 | * @param str the string to manage | ||
57 | * @param length the length of the string. | ||
58 | * @return Newly allocated string buffer instance. | ||
59 | * | ||
60 | * This function creates a new string buffer. On error, @c NULL is | ||
61 | * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To | ||
62 | * free the resources, use eina_binbuf_free(). | ||
63 | * | ||
64 | * @see eina_binbuf_manage_new() | ||
65 | * @since 1.2.0 | ||
66 | */ | ||
67 | EAPI Eina_Binbuf *eina_binbuf_manage_new_length(unsigned char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | ||
68 | |||
69 | /** | ||
52 | * @brief Free a string buffer. | 70 | * @brief Free a string buffer. |
53 | * | 71 | * |
54 | * @param buf The string buffer to free. | 72 | * @param buf The string buffer to free. |
diff --git a/libraries/eina/src/include/eina_clist.h b/libraries/eina/src/include/eina_clist.h index 68f15df..096a4b7 100644 --- a/libraries/eina/src/include/eina_clist.h +++ b/libraries/eina/src/include/eina_clist.h | |||
@@ -23,7 +23,22 @@ | |||
23 | #define __EINA_CLIST_H__ | 23 | #define __EINA_CLIST_H__ |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * @addtogroup Eina_CList_Group Compact inline list | 26 | * @addtogroup Eina_Data_Types_Group Data Types |
27 | * | ||
28 | * @{ | ||
29 | */ | ||
30 | |||
31 | /** | ||
32 | * @addtogroup Eina_Containers_Group Containers | ||
33 | * | ||
34 | * @{ | ||
35 | */ | ||
36 | |||
37 | /** | ||
38 | * @defgroup Eina_CList_Group Compact List | ||
39 | * | ||
40 | * @{ | ||
41 | * | ||
27 | * @brief Eina_Clist is a compact (inline) list implementation | 42 | * @brief Eina_Clist is a compact (inline) list implementation |
28 | * | 43 | * |
29 | * Elements of this list are members of the structs stored in the list | 44 | * Elements of this list are members of the structs stored in the list |
@@ -42,9 +57,8 @@ | |||
42 | * @note There's no NULL at the end of the list, the last item points to the head. | 57 | * @note There's no NULL at the end of the list, the last item points to the head. |
43 | * | 58 | * |
44 | * @note List heads must be initialized with EINA_CLIST_INIT or by calling eina_clist_element_init | 59 | * @note List heads must be initialized with EINA_CLIST_INIT or by calling eina_clist_element_init |
45 | */ | 60 | * |
46 | 61 | * Define a list like so: | |
47 | /* Define a list like so: | ||
48 | * | 62 | * |
49 | * @code | 63 | * @code |
50 | * struct gadget | 64 | * struct gadget |
@@ -88,24 +102,6 @@ | |||
88 | */ | 102 | */ |
89 | 103 | ||
90 | /** | 104 | /** |
91 | * @addtogroup Eina_Data_Types_Group Data Types | ||
92 | * | ||
93 | * @{ | ||
94 | */ | ||
95 | |||
96 | /** | ||
97 | * @addtogroup Eina_Containers_Group Containers | ||
98 | * | ||
99 | * @{ | ||
100 | */ | ||
101 | |||
102 | /** | ||
103 | * @defgroup Eina_CList_Group Compact list | ||
104 | * | ||
105 | * @{ | ||
106 | */ | ||
107 | |||
108 | /** | ||
109 | * @typedef Eina_Clist | 105 | * @typedef Eina_Clist |
110 | * This is the list head and the list entry. | 106 | * This is the list head and the list entry. |
111 | * @since 1.1.0 | 107 | * @since 1.1.0 |
@@ -135,13 +131,7 @@ struct _Eina_Clist | |||
135 | * @note There's no need to initialize an element before adding it to the list. | 131 | * @note There's no need to initialize an element before adding it to the list. |
136 | * @since 1.1.0 | 132 | * @since 1.1.0 |
137 | */ | 133 | */ |
138 | static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add) | 134 | static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add); |
139 | { | ||
140 | to_add->next = elem->next; | ||
141 | to_add->prev = elem; | ||
142 | elem->next->prev = to_add; | ||
143 | elem->next = to_add; | ||
144 | } | ||
145 | 135 | ||
146 | /** | 136 | /** |
147 | * Add an element before the specified one. | 137 | * Add an element before the specified one. |
@@ -154,13 +144,7 @@ static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add) | |||
154 | * @note There's no need to initialize an element before adding it to the list. | 144 | * @note There's no need to initialize an element before adding it to the list. |
155 | * @since 1.1.0 | 145 | * @since 1.1.0 |
156 | */ | 146 | */ |
157 | static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add) | 147 | static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add); |
158 | { | ||
159 | to_add->next = elem; | ||
160 | to_add->prev = elem->prev; | ||
161 | elem->prev->next = to_add; | ||
162 | elem->prev = to_add; | ||
163 | } | ||
164 | 148 | ||
165 | /** | 149 | /** |
166 | * Add element at the head of the list. | 150 | * Add element at the head of the list. |
@@ -173,10 +157,7 @@ static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add) | |||
173 | * @note There's no need to initialize an element before adding it to the list. | 157 | * @note There's no need to initialize an element before adding it to the list. |
174 | * @since 1.1.0 | 158 | * @since 1.1.0 |
175 | */ | 159 | */ |
176 | static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem) | 160 | static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem); |
177 | { | ||
178 | eina_clist_add_after(list, elem); | ||
179 | } | ||
180 | 161 | ||
181 | /** | 162 | /** |
182 | * Add element at the tail of the list. | 163 | * Add element at the tail of the list. |
@@ -189,10 +170,7 @@ static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem) | |||
189 | * @note There's no need to initialize an element before adding it to the list. | 170 | * @note There's no need to initialize an element before adding it to the list. |
190 | * @since 1.1.0 | 171 | * @since 1.1.0 |
191 | */ | 172 | */ |
192 | static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem) | 173 | static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem); |
193 | { | ||
194 | eina_clist_add_before(list, elem); | ||
195 | } | ||
196 | 174 | ||
197 | /** | 175 | /** |
198 | * Init an (unlinked) element. | 176 | * Init an (unlinked) element. |
@@ -207,11 +185,7 @@ static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem) | |||
207 | * @note It is not necessary to call this before adding an element to this list. | 185 | * @note It is not necessary to call this before adding an element to this list. |
208 | * @since 1.1.0 | 186 | * @since 1.1.0 |
209 | */ | 187 | */ |
210 | static inline void eina_clist_element_init(Eina_Clist *elem) | 188 | static inline void eina_clist_element_init(Eina_Clist *elem); |
211 | { | ||
212 | elem->next = NULL; | ||
213 | elem->prev = NULL; | ||
214 | } | ||
215 | 189 | ||
216 | /** | 190 | /** |
217 | * Check if an element is in a list or not. | 191 | * Check if an element is in a list or not. |
@@ -222,10 +196,7 @@ static inline void eina_clist_element_init(Eina_Clist *elem) | |||
222 | * it has been added to a list or remove from a list. | 196 | * it has been added to a list or remove from a list. |
223 | * @since 1.1.0 | 197 | * @since 1.1.0 |
224 | */ | 198 | */ |
225 | static inline int eina_clist_element_is_linked(Eina_Clist *elem) | 199 | static inline int eina_clist_element_is_linked(Eina_Clist *elem); |
226 | { | ||
227 | return (elem->next != NULL && elem->prev != NULL); | ||
228 | } | ||
229 | 200 | ||
230 | /** | 201 | /** |
231 | * Remove an element from its list. | 202 | * Remove an element from its list. |
@@ -235,12 +206,7 @@ static inline int eina_clist_element_is_linked(Eina_Clist *elem) | |||
235 | * @post The element is marked as not being in any list | 206 | * @post The element is marked as not being in any list |
236 | * @since 1.1.0 | 207 | * @since 1.1.0 |
237 | */ | 208 | */ |
238 | static inline void eina_clist_remove(Eina_Clist *elem) | 209 | static inline void eina_clist_remove(Eina_Clist *elem); |
239 | { | ||
240 | elem->next->prev = elem->prev; | ||
241 | elem->prev->next = elem->next; | ||
242 | eina_clist_element_init(elem); | ||
243 | } | ||
244 | 210 | ||
245 | /** | 211 | /** |
246 | * Get the next element. | 212 | * Get the next element. |
@@ -248,15 +214,10 @@ static inline void eina_clist_remove(Eina_Clist *elem) | |||
248 | * @param list The list | 214 | * @param list The list |
249 | * @param elem An element | 215 | * @param elem An element |
250 | * @pre @a elem is in @a list | 216 | * @pre @a elem is in @a list |
251 | * @return The element after @elem in @list or NULL if @a elem is last in @a list | 217 | * @return The element after @a elem in @a list or @c NULL if @a elem is last in @a list |
252 | * @since 1.1.0 | 218 | * @since 1.1.0 |
253 | */ | 219 | */ |
254 | static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem) | 220 | static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem); |
255 | { | ||
256 | Eina_Clist *ret = elem->next; | ||
257 | if (elem->next == list) ret = NULL; | ||
258 | return ret; | ||
259 | } | ||
260 | 221 | ||
261 | /** | 222 | /** |
262 | * Get the previous element. | 223 | * Get the previous element. |
@@ -267,12 +228,7 @@ static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Cli | |||
267 | * @return The element before @a elem or NULL if @a elem is the first in the list | 228 | * @return The element before @a elem or NULL if @a elem is the first in the list |
268 | * @since 1.1.0 | 229 | * @since 1.1.0 |
269 | */ | 230 | */ |
270 | static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem) | 231 | static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem); |
271 | { | ||
272 | Eina_Clist *ret = elem->prev; | ||
273 | if (elem->prev == list) ret = NULL; | ||
274 | return ret; | ||
275 | } | ||
276 | 232 | ||
277 | /** | 233 | /** |
278 | * Get the first element. | 234 | * Get the first element. |
@@ -281,22 +237,16 @@ static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Cli | |||
281 | * @returns The first element in @a list or NULL if @a list is empty | 237 | * @returns The first element in @a list or NULL if @a list is empty |
282 | * @since 1.1.0 | 238 | * @since 1.1.0 |
283 | */ | 239 | */ |
284 | static inline Eina_Clist *eina_clist_head(const Eina_Clist *list) | 240 | static inline Eina_Clist *eina_clist_head(const Eina_Clist *list); |
285 | { | ||
286 | return eina_clist_next(list, list); | ||
287 | } | ||
288 | 241 | ||
289 | /** | 242 | /** |
290 | * Get the last element. | 243 | * Get the last element. |
291 | * | 244 | * |
292 | * @param list The list | 245 | * @param list The list |
293 | * @returns The last element in @a list or NULL if @list is empty | 246 | * @returns The last element in @a list or NULL if @a list is empty |
294 | * @since 1.1.0 | 247 | * @since 1.1.0 |
295 | */ | 248 | */ |
296 | static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list) | 249 | static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list); |
297 | { | ||
298 | return eina_clist_prev(list, list); | ||
299 | } | ||
300 | 250 | ||
301 | /** | 251 | /** |
302 | * Check if a list is empty. | 252 | * Check if a list is empty. |
@@ -305,10 +255,7 @@ static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list) | |||
305 | * @returns non-zero if @a list is empty, zero if it is not | 255 | * @returns non-zero if @a list is empty, zero if it is not |
306 | * @since 1.1.0 | 256 | * @since 1.1.0 |
307 | */ | 257 | */ |
308 | static inline int eina_clist_empty(const Eina_Clist *list) | 258 | static inline int eina_clist_empty(const Eina_Clist *list); |
309 | { | ||
310 | return list->next == list; | ||
311 | } | ||
312 | 259 | ||
313 | /** | 260 | /** |
314 | * Initialize a list | 261 | * Initialize a list |
@@ -322,10 +269,7 @@ static inline int eina_clist_empty(const Eina_Clist *list) | |||
322 | * initialize the list by zero'ing out the list head. | 269 | * initialize the list by zero'ing out the list head. |
323 | * @since 1.1.0 | 270 | * @since 1.1.0 |
324 | */ | 271 | */ |
325 | static inline void eina_clist_init(Eina_Clist *list) | 272 | static inline void eina_clist_init(Eina_Clist *list); |
326 | { | ||
327 | list->next = list->prev = list; | ||
328 | } | ||
329 | 273 | ||
330 | /** | 274 | /** |
331 | * Count the elements of a list | 275 | * Count the elements of a list |
@@ -334,13 +278,7 @@ static inline void eina_clist_init(Eina_Clist *list) | |||
334 | * @returns The number of items in the list | 278 | * @returns The number of items in the list |
335 | * @since 1.1.0 | 279 | * @since 1.1.0 |
336 | */ | 280 | */ |
337 | static inline unsigned int eina_clist_count(const Eina_Clist *list) | 281 | static inline unsigned int eina_clist_count(const Eina_Clist *list); |
338 | { | ||
339 | unsigned count = 0; | ||
340 | const Eina_Clist *ptr; | ||
341 | for (ptr = list->next; ptr != list; ptr = ptr->next) count++; | ||
342 | return count; | ||
343 | } | ||
344 | 282 | ||
345 | /** | 283 | /** |
346 | * Move all elements from src to the tail of dst | 284 | * Move all elements from src to the tail of dst |
@@ -351,16 +289,7 @@ static inline unsigned int eina_clist_count(const Eina_Clist *list) | |||
351 | * @post @a src is initialized but empty after this operation | 289 | * @post @a src is initialized but empty after this operation |
352 | * @since 1.1.0 | 290 | * @since 1.1.0 |
353 | */ | 291 | */ |
354 | static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src) | 292 | static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src); |
355 | { | ||
356 | if (eina_clist_empty(src)) return; | ||
357 | |||
358 | dst->prev->next = src->next; | ||
359 | src->next->prev = dst->prev; | ||
360 | dst->prev = src->prev; | ||
361 | src->prev->next = dst; | ||
362 | eina_clist_init(src); | ||
363 | } | ||
364 | 293 | ||
365 | /** | 294 | /** |
366 | * move all elements from src to the head of dst | 295 | * move all elements from src to the head of dst |
@@ -371,16 +300,7 @@ static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src) | |||
371 | * @post @a src is initialized but empty after this operation | 300 | * @post @a src is initialized but empty after this operation |
372 | * @since 1.1.0 | 301 | * @since 1.1.0 |
373 | */ | 302 | */ |
374 | static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src) | 303 | static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src); |
375 | { | ||
376 | if (eina_clist_empty(src)) return; | ||
377 | |||
378 | dst->next->prev = src->prev; | ||
379 | src->prev->next = dst->next; | ||
380 | dst->next = src->next; | ||
381 | src->next->prev = dst; | ||
382 | eina_clist_init(src); | ||
383 | } | ||
384 | 304 | ||
385 | /** | 305 | /** |
386 | * iterate through the list | 306 | * iterate through the list |
@@ -441,15 +361,17 @@ static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src) | |||
441 | #define EINA_CLIST_ENTRY(elem, type, field) \ | 361 | #define EINA_CLIST_ENTRY(elem, type, field) \ |
442 | ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field))) | 362 | ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field))) |
443 | 363 | ||
444 | /* | 364 | #include "eina_inline_clist.x" |
365 | |||
366 | /** | ||
445 | * @} | 367 | * @} |
446 | */ | 368 | */ |
447 | 369 | ||
448 | /* | 370 | /** |
449 | * @} | 371 | * @} |
450 | */ | 372 | */ |
451 | 373 | ||
452 | /* | 374 | /** |
453 | * @} | 375 | * @} |
454 | */ | 376 | */ |
455 | 377 | ||
diff --git a/libraries/eina/src/include/eina_config.h b/libraries/eina/src/include/eina_config.h index 3341731..474edaa 100644 --- a/libraries/eina/src/include/eina_config.h +++ b/libraries/eina/src/include/eina_config.h | |||
@@ -64,4 +64,14 @@ | |||
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | 66 | ||
67 | #ifdef EINA_CONFIGURE_HAVE_DIRENT_H | ||
68 | # undef EINA_CONFIGURE_HAVE_DIRENT_H | ||
69 | #endif | ||
70 | #define EINA_HAVE_DIRENT_H | ||
71 | |||
72 | #ifdef EINA_CONFIGURE_ENABLE_LOG | ||
73 | # undef EINA_CONFIGURE_ENABLE_LOG | ||
74 | #endif | ||
75 | #define EINA_ENABLE_LOG | ||
76 | |||
67 | #endif /* EINA_CONFIG_H_ */ | 77 | #endif /* EINA_CONFIG_H_ */ |
diff --git a/libraries/eina/src/include/eina_config.h.in b/libraries/eina/src/include/eina_config.h.in index be328cd..2459ace 100644 --- a/libraries/eina/src/include/eina_config.h.in +++ b/libraries/eina/src/include/eina_config.h.in | |||
@@ -64,4 +64,14 @@ | |||
64 | #endif | 64 | #endif |
65 | @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ | 65 | @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ |
66 | 66 | ||
67 | #ifdef EINA_CONFIGURE_HAVE_DIRENT_H | ||
68 | # undef EINA_CONFIGURE_HAVE_DIRENT_H | ||
69 | #endif | ||
70 | @EINA_CONFIGURE_HAVE_DIRENT_H@ | ||
71 | |||
72 | #ifdef EINA_CONFIGURE_ENABLE_LOG | ||
73 | # undef EINA_CONFIGURE_ENABLE_LOG | ||
74 | #endif | ||
75 | @EINA_CONFIGURE_ENABLE_LOG@ | ||
76 | |||
67 | #endif /* EINA_CONFIG_H_ */ | 77 | #endif /* EINA_CONFIG_H_ */ |
diff --git a/libraries/eina/src/include/eina_file.h b/libraries/eina/src/include/eina_file.h index 01ef8f5..422fb65 100644 --- a/libraries/eina/src/include/eina_file.h +++ b/libraries/eina/src/include/eina_file.h | |||
@@ -94,6 +94,9 @@ typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info; | |||
94 | * @typedef Eina_File_Dir_List_Cb | 94 | * @typedef Eina_File_Dir_List_Cb |
95 | * Type for a callback to be called when iterating over the files of a | 95 | * Type for a callback to be called when iterating over the files of a |
96 | * directory. | 96 | * directory. |
97 | * @param The file name EXCLUDING the path | ||
98 | * @param path The path passed to eina_file_dir_list() | ||
99 | * @param data The data passed to eina_file_dir_list() | ||
97 | */ | 100 | */ |
98 | typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data); | 101 | typedef void (*Eina_File_Dir_List_Cb)(const char *name, const char *path, void *data); |
99 | 102 | ||
@@ -345,6 +348,33 @@ EAPI time_t eina_file_mtime_get(Eina_File *file); | |||
345 | EAPI const char *eina_file_filename_get(Eina_File *file); | 348 | EAPI const char *eina_file_filename_get(Eina_File *file); |
346 | 349 | ||
347 | /** | 350 | /** |
351 | * @brief Get the eXtended attribute of an open file. | ||
352 | * | ||
353 | * @param file The file handler to request the eXtended attribute from. | ||
354 | * @return an iterator. | ||
355 | * | ||
356 | * The iterator will list all eXtended attribute name without allocating | ||
357 | * them, so you need to copy them yourself if needed. | ||
358 | * | ||
359 | * @since 1.2 | ||
360 | */ | ||
361 | EAPI Eina_Iterator *eina_file_xattr_get(Eina_File *file); | ||
362 | |||
363 | /** | ||
364 | * @brief Get the eXtended attribute of an open file. | ||
365 | * | ||
366 | * @param file The file handler to request the eXtended attribute from. | ||
367 | * @return an iterator. | ||
368 | * | ||
369 | * The iterator will list all eXtended attribute without allocating | ||
370 | * them, so you need to copy them yourself if needed. It is returning | ||
371 | * Eina_Xattr structure. | ||
372 | * | ||
373 | * @since 1.2 | ||
374 | */ | ||
375 | EAPI Eina_Iterator *eina_file_xattr_value_get(Eina_File *file); | ||
376 | |||
377 | /** | ||
348 | * @brief Map all the file to a buffer. | 378 | * @brief Map all the file to a buffer. |
349 | * | 379 | * |
350 | * @param file The file handler to map in memory | 380 | * @param file The file handler to map in memory |
@@ -382,6 +412,16 @@ EAPI void *eina_file_map_new(Eina_File *file, Eina_File_Populate rule, | |||
382 | EAPI void eina_file_map_free(Eina_File *file, void *map); | 412 | EAPI void eina_file_map_free(Eina_File *file, void *map); |
383 | 413 | ||
384 | /** | 414 | /** |
415 | * @brief Tell if their was an IO error during the life of a mmaped file | ||
416 | * | ||
417 | * @param file The file handler to the mmaped file. | ||
418 | * @param map Memory map to check if an error occured on it. | ||
419 | * | ||
420 | * @since 1.2 | ||
421 | */ | ||
422 | EAPI Eina_Bool eina_file_map_faulted(Eina_File *file, void *map); | ||
423 | |||
424 | /** | ||
385 | * @} | 425 | * @} |
386 | */ | 426 | */ |
387 | 427 | ||
diff --git a/libraries/eina/src/include/eina_hash.h b/libraries/eina/src/include/eina_hash.h index c8eb048..57316b2 100644 --- a/libraries/eina/src/include/eina_hash.h +++ b/libraries/eina/src/include/eina_hash.h | |||
@@ -578,7 +578,7 @@ EAPI Eina_Bool eina_hash_del(Eina_Hash *hash, | |||
578 | * otherwise. | 578 | * otherwise. |
579 | */ | 579 | */ |
580 | EAPI void *eina_hash_find(const Eina_Hash *hash, | 580 | EAPI void *eina_hash_find(const Eina_Hash *hash, |
581 | const void *key) EINA_ARG_NONNULL(1, 2); | 581 | const void *key) EINA_ARG_NONNULL(2); |
582 | 582 | ||
583 | /** | 583 | /** |
584 | * @brief Modify the entry pointer at the specified key and return the old | 584 | * @brief Modify the entry pointer at the specified key and return the old |
@@ -1005,7 +1005,7 @@ EAPI Eina_Iterator *eina_hash_iterator_tuple_new(const Eina_Hash *hash) EINA_MAL | |||
1005 | * @endcode | 1005 | * @endcode |
1006 | */ | 1006 | */ |
1007 | EAPI void eina_hash_foreach(const Eina_Hash *hash, | 1007 | EAPI void eina_hash_foreach(const Eina_Hash *hash, |
1008 | Eina_Hash_Foreach cb, | 1008 | Eina_Hash_Foreach func, |
1009 | const void *fdata) EINA_ARG_NONNULL(1, 2); | 1009 | const void *fdata) EINA_ARG_NONNULL(1, 2); |
1010 | /* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */ | 1010 | /* Paul Hsieh (http://www.azillionmonkeys.com/qed/hash.html) hash function used by WebCore (http://webkit.org/blog/8/hashtables-part-2/) */ |
1011 | EAPI int eina_hash_superfast(const char *key, | 1011 | EAPI int eina_hash_superfast(const char *key, |
diff --git a/libraries/eina/src/include/eina_inarray.h b/libraries/eina/src/include/eina_inarray.h new file mode 100644 index 0000000..d37c76b --- /dev/null +++ b/libraries/eina/src/include/eina_inarray.h | |||
@@ -0,0 +1,572 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2012 ProFUSION embedded systems | ||
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 | #ifndef EINA_INARRAY_H_ | ||
20 | #define EINA_INARRAY_H_ | ||
21 | |||
22 | #include "eina_types.h" | ||
23 | #include "eina_iterator.h" | ||
24 | #include "eina_accessor.h" | ||
25 | |||
26 | /** | ||
27 | * @addtogroup Eina_Data_Types_Group Data Types | ||
28 | * | ||
29 | * @since 1.2 | ||
30 | * | ||
31 | * @{ | ||
32 | */ | ||
33 | |||
34 | /** | ||
35 | * @addtogroup Eina_Containers_Group Containers | ||
36 | * | ||
37 | * @{ | ||
38 | */ | ||
39 | |||
40 | /** | ||
41 | * @defgroup Eina_Inline_Array_Group Inline Array | ||
42 | * | ||
43 | * @{ | ||
44 | */ | ||
45 | |||
46 | |||
47 | /** | ||
48 | * @typedef Eina_Inarray | ||
49 | * Inlined array type. | ||
50 | * | ||
51 | * @since 1.2 | ||
52 | */ | ||
53 | typedef struct _Eina_Inarray Eina_Inarray; | ||
54 | |||
55 | /** | ||
56 | * Inline array structure, use #Eina_Inarray typedef instead. | ||
57 | * | ||
58 | * Do not modify these fields directly, use eina_inarray_setup() or | ||
59 | * eina_inarray_new() instead. | ||
60 | * | ||
61 | * @since 1.2 | ||
62 | */ | ||
63 | struct _Eina_Inarray | ||
64 | { | ||
65 | unsigned int member_size; /**< byte size of each entry in members */ | ||
66 | unsigned int len; /**< number of elements used in members */ | ||
67 | unsigned int max; /**< number of elements allocated in members */ | ||
68 | unsigned int step; /**< amount to grow number of members allocated */ | ||
69 | void *members; /**< actual array of elements */ | ||
70 | EINA_MAGIC | ||
71 | }; | ||
72 | |||
73 | /** | ||
74 | * @brief Create new inline array. | ||
75 | * | ||
76 | * @param member_size size of each member in the array. | ||
77 | * @param step when resizing the array, do this using the following | ||
78 | * extra amount. | ||
79 | * @return The new inline array table or @c NULL on failure. | ||
80 | * | ||
81 | * Create a new array where members are inlined in a sequence. Each | ||
82 | * member has @a member_size bytes. | ||
83 | * | ||
84 | * If the @a step is 0, then a safe default is chosen. | ||
85 | * | ||
86 | * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is | ||
87 | * set. If @a member_size is zero, then @c NULL is returned. | ||
88 | * | ||
89 | * @see eina_inarray_free() | ||
90 | * | ||
91 | * @since 1.2 | ||
92 | */ | ||
93 | EAPI Eina_Inarray *eina_inarray_new(unsigned int member_size, | ||
94 | unsigned int step) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | ||
95 | |||
96 | /** | ||
97 | * @brief Free array and its members. | ||
98 | * @param array array object | ||
99 | * | ||
100 | * @see eina_inarray_flush() | ||
101 | * | ||
102 | * @since 1.2 | ||
103 | */ | ||
104 | EAPI void eina_inarray_free(Eina_Inarray *array) EINA_ARG_NONNULL(1); | ||
105 | |||
106 | /** | ||
107 | * @brief Initialize inline array. | ||
108 | * @param array array object to initialize. | ||
109 | * @param member_size size of each member in the array. | ||
110 | * @param step when resizing the array, do this using the following | ||
111 | * extra amount. | ||
112 | * | ||
113 | * Initialize array. If the @a step is 0, then a safe default is | ||
114 | * chosen. | ||
115 | * | ||
116 | * This is useful for arrays inlined into other structures or | ||
117 | * allocated at stack. | ||
118 | * | ||
119 | * @see eina_inarray_flush() | ||
120 | * | ||
121 | * @since 1.2 | ||
122 | */ | ||
123 | EAPI void eina_inarray_setup(Eina_Inarray *array, | ||
124 | unsigned int member_size, | ||
125 | unsigned int step) EINA_ARG_NONNULL(1); | ||
126 | |||
127 | /** | ||
128 | * @brief Remove every member from array. | ||
129 | * @param array array object | ||
130 | * | ||
131 | * @since 1.2 | ||
132 | */ | ||
133 | EAPI void eina_inarray_flush(Eina_Inarray *array) EINA_ARG_NONNULL(1); | ||
134 | |||
135 | /** | ||
136 | * @brief Copy the data as the last member of the array. | ||
137 | * @param array array object | ||
138 | * @param data data to be copied at the end | ||
139 | * @return the index of the new member or -1 on errors. | ||
140 | * | ||
141 | * Copies the given pointer contents at the end of the array. The | ||
142 | * pointer is not referenced, instead it's contents is copied to the | ||
143 | * members array using the previously defined @c member_size. | ||
144 | * | ||
145 | * @see eina_inarray_insert_at(). | ||
146 | * | ||
147 | * @since 1.2 | ||
148 | */ | ||
149 | EAPI int eina_inarray_append(Eina_Inarray *array, | ||
150 | const void *data) EINA_ARG_NONNULL(1, 2); | ||
151 | |||
152 | /** | ||
153 | * @brief Copy the data to array at position found by comparison function | ||
154 | * @param array array object | ||
155 | * @param data data to be copied | ||
156 | * @param compare compare function | ||
157 | * @return the index of the new member or -1 on errors. | ||
158 | * | ||
159 | * Copies the given pointer contents at the array position defined by | ||
160 | * given @a compare function. The pointer is not referenced, instead | ||
161 | * it's contents is copied to the members array using the previously | ||
162 | * defined @c member_size. | ||
163 | * | ||
164 | * The data given to @a compare function are the pointer to member | ||
165 | * memory itself, do no change it. | ||
166 | * | ||
167 | * @see eina_inarray_insert_sorted() | ||
168 | * @see eina_inarray_insert_at() | ||
169 | * @see eina_inarray_append() | ||
170 | * | ||
171 | * @since 1.2 | ||
172 | */ | ||
173 | EAPI int eina_inarray_insert(Eina_Inarray *array, | ||
174 | const void *data, | ||
175 | Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); | ||
176 | |||
177 | /** | ||
178 | * @brief Copy the data to array at position found by comparison function | ||
179 | * @param array array object | ||
180 | * @param data data to be copied | ||
181 | * @param compare compare function | ||
182 | * @return the index of the new member or -1 on errors. | ||
183 | * | ||
184 | * Copies the given pointer contents at the array position defined by | ||
185 | * given @a compare function. The pointer is not referenced, instead | ||
186 | * it's contents is copied to the members array using the previously | ||
187 | * defined @c member_size. | ||
188 | * | ||
189 | * The data given to @a compare function are the pointer to member | ||
190 | * memory itself, do no change it. | ||
191 | * | ||
192 | * This variation will optimize insertion position assuming the array | ||
193 | * is already sorted by doing binary search. | ||
194 | * | ||
195 | * @see eina_inarray_sort() | ||
196 | * | ||
197 | * @since 1.2 | ||
198 | */ | ||
199 | EAPI int eina_inarray_insert_sorted(Eina_Inarray *array, | ||
200 | const void *data, | ||
201 | Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); | ||
202 | |||
203 | /** | ||
204 | * @brief Find data and remove matching member | ||
205 | * @param array array object | ||
206 | * @param data data to be found and removed | ||
207 | * @return the index of the removed member or -1 on errors. | ||
208 | * | ||
209 | * Find data in the array and remove it. Data may be an existing | ||
210 | * member of array (then optimized) or the contents will be matched | ||
211 | * using memcmp(). | ||
212 | * | ||
213 | * @see eina_inarray_pop() | ||
214 | * @see eina_inarray_remove_at() | ||
215 | * | ||
216 | * @since 1.2 | ||
217 | */ | ||
218 | EAPI int eina_inarray_remove(Eina_Inarray *array, | ||
219 | const void *data) EINA_ARG_NONNULL(1, 2); | ||
220 | |||
221 | /** | ||
222 | * @brief Removes the last member of the array | ||
223 | * @param array array object | ||
224 | * @return the index of the removed member or -1 on errors. | ||
225 | * | ||
226 | * @since 1.2 | ||
227 | */ | ||
228 | EAPI int eina_inarray_pop(Eina_Inarray *array) EINA_ARG_NONNULL(1); | ||
229 | |||
230 | /** | ||
231 | * @brief Get the member at given position | ||
232 | * @param array array object | ||
233 | * @param position member position | ||
234 | * @return pointer to current member memory. | ||
235 | * | ||
236 | * Gets the member given its position in the array. It is a pointer to | ||
237 | * its current memory, then it can be invalidated with functions that | ||
238 | * changes the array such as eina_inarray_append(), | ||
239 | * eina_inarray_insert_at() or eina_inarray_remove_at() or variants. | ||
240 | * | ||
241 | * See also eina_inarray_lookup() and eina_inarray_lookup_sorted(). | ||
242 | * | ||
243 | * @since 1.2 | ||
244 | */ | ||
245 | EAPI void *eina_inarray_nth(const Eina_Inarray *array, | ||
246 | unsigned int position) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | ||
247 | |||
248 | /** | ||
249 | * @brief Copy the data at given position in the array | ||
250 | * @param array array object | ||
251 | * @param position where to insert the member | ||
252 | * @param data data to be copied at position | ||
253 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
254 | * | ||
255 | * Copies the given pointer contents at the given @a position in the | ||
256 | * array. The pointer is not referenced, instead it's contents is | ||
257 | * copied to the members array using the previously defined | ||
258 | * @c member_size. | ||
259 | * | ||
260 | * All the members from @a position to the end of the array are | ||
261 | * shifted to the end. | ||
262 | * | ||
263 | * If @a position is equal to the end of the array (equals to | ||
264 | * eina_inarray_count()), then the member is appended. | ||
265 | * | ||
266 | * If @a position is bigger than the array length, it will fail. | ||
267 | * | ||
268 | * @since 1.2 | ||
269 | */ | ||
270 | EAPI Eina_Bool eina_inarray_insert_at(Eina_Inarray *array, | ||
271 | unsigned int position, | ||
272 | const void *data) EINA_ARG_NONNULL(1, 3); | ||
273 | |||
274 | /** | ||
275 | * @brief Opens a space at given position, returning its pointer. | ||
276 | * @param array array object | ||
277 | * @param position where to insert first member (open/allocate space) | ||
278 | * @param member_count how many times member_size bytes will be allocated. | ||
279 | * @return pointer to first member memory allocated or @c NULL on errors. | ||
280 | * | ||
281 | * This is similar to eina_inarray_insert_at(), but useful if the | ||
282 | * members contents are still unknown or unallocated. It will make | ||
283 | * room for the required number of items and return the pointer to the | ||
284 | * first item, similar to malloc(member_count * member_size), with the | ||
285 | * guarantee all memory is within members array. | ||
286 | * | ||
287 | * The new member memory is undefined, it's not automatically zeroed. | ||
288 | * | ||
289 | * All the members from @a position to the end of the array are | ||
290 | * shifted to the end. | ||
291 | * | ||
292 | * If @a position is equal to the end of the array (equals to | ||
293 | * eina_inarray_count()), then the member is appended. | ||
294 | * | ||
295 | * If @a position is bigger than the array length, it will fail. | ||
296 | * | ||
297 | * @since 1.2 | ||
298 | */ | ||
299 | EAPI void *eina_inarray_alloc_at(Eina_Inarray *array, | ||
300 | unsigned int position, | ||
301 | unsigned int member_count) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | ||
302 | |||
303 | /** | ||
304 | * @brief Copy the data over the given position. | ||
305 | * @param array array object | ||
306 | * @param position where to replace the member | ||
307 | * @param data data to be copied at position | ||
308 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
309 | * | ||
310 | * Copies the given pointer contents at the given @a position in the | ||
311 | * array. The pointer is not referenced, instead it's contents is | ||
312 | * copied to the members array using the previously defined | ||
313 | * @c member_size. | ||
314 | * | ||
315 | * If @a position does not exist, it will fail. | ||
316 | * | ||
317 | * @since 1.2 | ||
318 | */ | ||
319 | EAPI Eina_Bool eina_inarray_replace_at(Eina_Inarray *array, | ||
320 | unsigned int position, | ||
321 | const void *data) EINA_ARG_NONNULL(1, 3); | ||
322 | |||
323 | /** | ||
324 | * @brief Remove member at given position | ||
325 | * @param array array object | ||
326 | * @param position position to be removed | ||
327 | * @return #EINA_TRUE on success, #EINA_FALSE on failure. | ||
328 | * | ||
329 | * The member is removed from array and any members after it are moved | ||
330 | * towards the array head. | ||
331 | * | ||
332 | * See also eina_inarray_pop() and eina_inarray_remove(). | ||
333 | * | ||
334 | * @since 1.2 | ||
335 | */ | ||
336 | EAPI Eina_Bool eina_inarray_remove_at(Eina_Inarray *array, | ||
337 | unsigned int position) EINA_ARG_NONNULL(1); | ||
338 | |||
339 | /** | ||
340 | * @brief Reverse members in the array. | ||
341 | * @param array array object | ||
342 | * | ||
343 | * If you do not want to change the array, just walk its elements | ||
344 | * backwards, then use EINA_INARRAY_REVERSE_FOREACH() macro. | ||
345 | * | ||
346 | * @see EINA_INARRAY_REVERSE_FOREACH() | ||
347 | * | ||
348 | * @since 1.2 | ||
349 | */ | ||
350 | EAPI void eina_inarray_reverse(Eina_Inarray *array) EINA_ARG_NONNULL(1); | ||
351 | |||
352 | /** | ||
353 | * @brief Applies quick sort to array | ||
354 | * @param array array object | ||
355 | * @param compare compare function | ||
356 | * | ||
357 | * Applies quick sort to the @a array. | ||
358 | * | ||
359 | * The data given to @a compare function are the pointer to member | ||
360 | * memory itself, do no change it. | ||
361 | * | ||
362 | * @see eina_inarray_insert_sorted() | ||
363 | * | ||
364 | * @since 1.2 | ||
365 | */ | ||
366 | EAPI void eina_inarray_sort(Eina_Inarray *array, | ||
367 | Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2); | ||
368 | |||
369 | /** | ||
370 | * @brief Search member (linear walk) | ||
371 | * @param array array object | ||
372 | * @param data member to search using @a compare function. | ||
373 | * @param compare compare function | ||
374 | * @return the member index or -1 if not found. | ||
375 | * | ||
376 | * Walks array linearly looking for given data as compared by | ||
377 | * @a compare function. | ||
378 | * | ||
379 | * The data given to @a compare function are the pointer to member | ||
380 | * memory itself, do no change it. | ||
381 | * | ||
382 | * See also eina_inarray_lookup_sorted(). | ||
383 | * | ||
384 | * @since 1.2 | ||
385 | */ | ||
386 | EAPI int eina_inarray_search(const Eina_Inarray *array, | ||
387 | const void *data, | ||
388 | Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); | ||
389 | |||
390 | /** | ||
391 | * @brief Search member (binary search walk) | ||
392 | * @param array array object | ||
393 | * @param data member to search using @a compare function. | ||
394 | * @param compare compare function | ||
395 | * @return the member index or -1 if not found. | ||
396 | * | ||
397 | * Uses binary search for given data as compared by @a compare function. | ||
398 | * | ||
399 | * The data given to @a compare function are the pointer to member | ||
400 | * memory itself, do no change it. | ||
401 | * | ||
402 | * @since 1.2 | ||
403 | */ | ||
404 | EAPI int eina_inarray_search_sorted(const Eina_Inarray *array, | ||
405 | const void *data, | ||
406 | Eina_Compare_Cb compare) EINA_ARG_NONNULL(1, 2, 3); | ||
407 | |||
408 | /** | ||
409 | * @brief Call function for each array member | ||
410 | * @param array array object | ||
411 | * @param function callback function | ||
412 | * @param user_data user data given to callback @a function | ||
413 | * @return #EINA_TRUE if it successfully iterate all items of the array. | ||
414 | * | ||
415 | * Call @a function for every given data in @a array. | ||
416 | * | ||
417 | * Safe way to iterate over an array. @p function should return | ||
418 | * #EINA_TRUE as long as you want the function to continue iterating, | ||
419 | * by returning #EINA_FALSE it will stop and return #EINA_FALSE as a | ||
420 | * result. | ||
421 | * | ||
422 | * The data given to @a function are the pointer to member memory | ||
423 | * itself. | ||
424 | * | ||
425 | * @see EINA_INARRAY_FOREACH() | ||
426 | * | ||
427 | * @since 1.2 | ||
428 | */ | ||
429 | EAPI Eina_Bool eina_inarray_foreach(const Eina_Inarray *array, | ||
430 | Eina_Each_Cb function, | ||
431 | const void *user_data) EINA_ARG_NONNULL(1, 2); | ||
432 | |||
433 | /** | ||
434 | * @brief Remove all members that matched. | ||
435 | * @param array array object | ||
436 | * @param match match function | ||
437 | * @param user_data user data given to callback @a match. | ||
438 | * @return number of removed entries or -1 on error. | ||
439 | * | ||
440 | * Remove all entries in the @a array where @a match function | ||
441 | * returns #EINA_TRUE. | ||
442 | * | ||
443 | * @since 1.2 | ||
444 | */ | ||
445 | EAPI int eina_inarray_foreach_remove(Eina_Inarray *array, | ||
446 | Eina_Each_Cb match, | ||
447 | const void *user_data) EINA_ARG_NONNULL(1, 2); | ||
448 | |||
449 | /** | ||
450 | * @brief number of members in array. | ||
451 | * @param array array object | ||
452 | * @return number of members in array. | ||
453 | * | ||
454 | * @since 1.2 | ||
455 | */ | ||
456 | EAPI unsigned int eina_inarray_count(const Eina_Inarray *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | ||
457 | |||
458 | /** | ||
459 | * @brief Returned a new iterator associated to an array. | ||
460 | * @param array array object | ||
461 | * @return A new iterator. | ||
462 | * | ||
463 | * This function returns a newly allocated iterator associated to | ||
464 | * @p array. | ||
465 | * | ||
466 | * If the memory can not be allocated, NULL is returned and | ||
467 | * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is | ||
468 | * returned. | ||
469 | * | ||
470 | * @warning if the array structure changes then the iterator becomes | ||
471 | * invalid! That is, if you add or remove members this | ||
472 | * iterator behavior is undefined and your program may crash! | ||
473 | * | ||
474 | * @since 1.2 | ||
475 | */ | ||
476 | EAPI Eina_Iterator *eina_inarray_iterator_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); | ||
477 | |||
478 | /** | ||
479 | * @brief Returned a new reversed iterator associated to an array. | ||
480 | * @param array array object | ||
481 | * @return A new iterator. | ||
482 | * | ||
483 | * This function returns a newly allocated iterator associated to | ||
484 | * @p array. | ||
485 | * | ||
486 | * Unlike eina_inarray_iterator_new(), this will walk the array backwards. | ||
487 | * | ||
488 | * If the memory can not be allocated, NULL is returned and | ||
489 | * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid iterator is | ||
490 | * returned. | ||
491 | * | ||
492 | * @warning if the array structure changes then the iterator becomes | ||
493 | * invalid! That is, if you add or remove nodes this iterator | ||
494 | * behavior is undefined and your program may crash! | ||
495 | * | ||
496 | * @since 1.2 | ||
497 | */ | ||
498 | EAPI Eina_Iterator *eina_inarray_iterator_reversed_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); | ||
499 | |||
500 | /** | ||
501 | * @brief Returned a new accessor associated to an array. | ||
502 | * @param array array object | ||
503 | * @return A new accessor. | ||
504 | * | ||
505 | * This function returns a newly allocated accessor associated to | ||
506 | * @p array. | ||
507 | * | ||
508 | * If the memory can not be allocated, NULL is returned and | ||
509 | * #EINA_ERROR_OUT_OF_MEMORY is set. Otherwise, a valid accessor is | ||
510 | * returned. | ||
511 | * | ||
512 | * @since 1.2 | ||
513 | */ | ||
514 | EAPI Eina_Accessor *eina_inarray_accessor_new(const Eina_Inarray *array) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); | ||
515 | |||
516 | /** | ||
517 | * @def EINA_INARRAY_FOREACH | ||
518 | * @brief walks array linearly from head to tail | ||
519 | * @param array array object | ||
520 | * @param itr the iterator pointer | ||
521 | * | ||
522 | * @a itr must be a pointer with sizeof(itr*) == array->member_size. | ||
523 | * | ||
524 | * @warning This is fast as it does direct pointer access, but it will | ||
525 | * not check for @c NULL pointers or invalid array object! | ||
526 | * See eina_inarray_foreach() to do that. | ||
527 | * | ||
528 | * @warning Do not modify array as you walk it! If that is desired, | ||
529 | * then use eina_inarray_foreach_remove() | ||
530 | * | ||
531 | * @since 1.2 | ||
532 | */ | ||
533 | #define EINA_INARRAY_FOREACH(array, itr) \ | ||
534 | for ((itr) = array->members; \ | ||
535 | (itr) < (((typeof(*itr)*)array->members) + array->len); \ | ||
536 | (itr)++) | ||
537 | |||
538 | /** | ||
539 | * @def EINA_INARRAY_REVERSE_FOREACH | ||
540 | * @brief walks array linearly from tail to head | ||
541 | * @param array array object | ||
542 | * @param itr the iterator pointer | ||
543 | * | ||
544 | * @a itr must be a pointer with sizeof(itr*) == array->member_size. | ||
545 | * | ||
546 | * @warning This is fast as it does direct pointer access, but it will | ||
547 | * not check for @c NULL pointers or invalid array object! | ||
548 | * | ||
549 | * @warning Do not modify array as you walk it! If that is desired, | ||
550 | * then use eina_inarray_foreach_remove() | ||
551 | * | ||
552 | * @since 1.2 | ||
553 | */ | ||
554 | #define EINA_INARRAY_REVERSE_FOREACH(array, itr) \ | ||
555 | for ((itr) = ((((typeof(*(itr))*)array->members) + array->len) - 1); \ | ||
556 | (((itr) >= (typeof(*(itr))*)array->members) \ | ||
557 | && (array->members != NULL)); \ | ||
558 | (itr)--) | ||
559 | |||
560 | /** | ||
561 | * @} | ||
562 | */ | ||
563 | |||
564 | /** | ||
565 | * @} | ||
566 | */ | ||
567 | |||
568 | /** | ||
569 | * @} | ||
570 | */ | ||
571 | |||
572 | #endif /*EINA_INARRAY_H_*/ | ||
diff --git a/libraries/eina/src/include/eina_inline_array.x b/libraries/eina/src/include/eina_inline_array.x index f9f6026..a635ee2 100644 --- a/libraries/eina/src/include/eina_inline_array.x +++ b/libraries/eina/src/include/eina_inline_array.x | |||
@@ -19,6 +19,8 @@ | |||
19 | #ifndef EINA_INLINE_ARRAY_X_ | 19 | #ifndef EINA_INLINE_ARRAY_X_ |
20 | #define EINA_INLINE_ARRAY_X_ | 20 | #define EINA_INLINE_ARRAY_X_ |
21 | 21 | ||
22 | #include <stddef.h> | ||
23 | |||
22 | #include <stdio.h> | 24 | #include <stdio.h> |
23 | 25 | ||
24 | /** | 26 | /** |
@@ -126,6 +128,8 @@ eina_array_data_set(const Eina_Array *array, unsigned int idx, const void *data) | |||
126 | * This function returns the number of elements in @p array. For | 128 | * This function returns the number of elements in @p array. For |
127 | * performance reasons, there is no check of @p array. If it is | 129 | * performance reasons, there is no check of @p array. If it is |
128 | * @c NULL or invalid, the program may crash. | 130 | * @c NULL or invalid, the program may crash. |
131 | * | ||
132 | * @deprecated use eina_array_count() | ||
129 | */ | 133 | */ |
130 | static inline unsigned int | 134 | static inline unsigned int |
131 | eina_array_count_get(const Eina_Array *array) | 135 | eina_array_count_get(const Eina_Array *array) |
@@ -133,6 +137,22 @@ eina_array_count_get(const Eina_Array *array) | |||
133 | return array->count; | 137 | return array->count; |
134 | } | 138 | } |
135 | 139 | ||
140 | /** | ||
141 | * @brief Return the number of elements in an array. | ||
142 | * | ||
143 | * @param array The array. | ||
144 | * @return The number of elements. | ||
145 | * | ||
146 | * This function returns the number of elements in @p array. For | ||
147 | * performance reasons, there is no check of @p array. If it is | ||
148 | * @c NULL or invalid, the program may crash. | ||
149 | */ | ||
150 | static inline unsigned int | ||
151 | eina_array_count(const Eina_Array *array) | ||
152 | { | ||
153 | return array->count; | ||
154 | } | ||
155 | |||
136 | static inline Eina_Bool | 156 | static inline Eina_Bool |
137 | eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata) | 157 | eina_array_foreach(Eina_Array *array, Eina_Each_Cb cb, void *fdata) |
138 | { | 158 | { |
diff --git a/libraries/eina/src/include/eina_inline_clist.x b/libraries/eina/src/include/eina_inline_clist.x new file mode 100644 index 0000000..66223fe --- /dev/null +++ b/libraries/eina/src/include/eina_inline_clist.x | |||
@@ -0,0 +1,135 @@ | |||
1 | /* | ||
2 | * Linked lists support | ||
3 | * | ||
4 | * Copyright (C) 2002 Alexandre Julliard | ||
5 | * Copyright (C) 2011 Mike McCormack (adapted for Eina) | ||
6 | * | ||
7 | * This library is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU Lesser General Public | ||
9 | * License as published by the Free Software Foundation; either | ||
10 | * version 2.1 of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * This library is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA | ||
20 | */ | ||
21 | |||
22 | #ifndef __EINA_CLIST_INLINE_H__ | ||
23 | #define __EINA_CLIST_INLINE_H__ | ||
24 | |||
25 | #include <stddef.h> | ||
26 | |||
27 | static inline void eina_clist_add_after(Eina_Clist *elem, Eina_Clist *to_add) | ||
28 | { | ||
29 | to_add->next = elem->next; | ||
30 | to_add->prev = elem; | ||
31 | elem->next->prev = to_add; | ||
32 | elem->next = to_add; | ||
33 | } | ||
34 | |||
35 | static inline void eina_clist_add_before(Eina_Clist *elem, Eina_Clist *to_add) | ||
36 | { | ||
37 | to_add->next = elem; | ||
38 | to_add->prev = elem->prev; | ||
39 | elem->prev->next = to_add; | ||
40 | elem->prev = to_add; | ||
41 | } | ||
42 | |||
43 | static inline void eina_clist_add_head(Eina_Clist *list, Eina_Clist *elem) | ||
44 | { | ||
45 | eina_clist_add_after(list, elem); | ||
46 | } | ||
47 | |||
48 | static inline void eina_clist_add_tail(Eina_Clist *list, Eina_Clist *elem) | ||
49 | { | ||
50 | eina_clist_add_before(list, elem); | ||
51 | } | ||
52 | |||
53 | static inline void eina_clist_element_init(Eina_Clist *elem) | ||
54 | { | ||
55 | elem->next = NULL; | ||
56 | elem->prev = NULL; | ||
57 | } | ||
58 | |||
59 | static inline int eina_clist_element_is_linked(Eina_Clist *elem) | ||
60 | { | ||
61 | return (elem->next != NULL && elem->prev != NULL); | ||
62 | } | ||
63 | |||
64 | static inline void eina_clist_remove(Eina_Clist *elem) | ||
65 | { | ||
66 | elem->next->prev = elem->prev; | ||
67 | elem->prev->next = elem->next; | ||
68 | eina_clist_element_init(elem); | ||
69 | } | ||
70 | |||
71 | static inline Eina_Clist *eina_clist_next(const Eina_Clist *list, const Eina_Clist *elem) | ||
72 | { | ||
73 | Eina_Clist *ret = elem->next; | ||
74 | if (elem->next == list) ret = NULL; | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | static inline Eina_Clist *eina_clist_prev(const Eina_Clist *list, const Eina_Clist *elem) | ||
79 | { | ||
80 | Eina_Clist *ret = elem->prev; | ||
81 | if (elem->prev == list) ret = NULL; | ||
82 | return ret; | ||
83 | } | ||
84 | |||
85 | static inline Eina_Clist *eina_clist_head(const Eina_Clist *list) | ||
86 | { | ||
87 | return eina_clist_next(list, list); | ||
88 | } | ||
89 | |||
90 | static inline Eina_Clist *eina_clist_tail(const Eina_Clist *list) | ||
91 | { | ||
92 | return eina_clist_prev(list, list); | ||
93 | } | ||
94 | |||
95 | static inline int eina_clist_empty(const Eina_Clist *list) | ||
96 | { | ||
97 | return list->next == list; | ||
98 | } | ||
99 | |||
100 | static inline void eina_clist_init(Eina_Clist *list) | ||
101 | { | ||
102 | list->next = list->prev = list; | ||
103 | } | ||
104 | |||
105 | static inline unsigned int eina_clist_count(const Eina_Clist *list) | ||
106 | { | ||
107 | unsigned count = 0; | ||
108 | const Eina_Clist *ptr; | ||
109 | for (ptr = list->next; ptr != list; ptr = ptr->next) count++; | ||
110 | return count; | ||
111 | } | ||
112 | |||
113 | static inline void eina_clist_move_tail(Eina_Clist *dst, Eina_Clist *src) | ||
114 | { | ||
115 | if (eina_clist_empty(src)) return; | ||
116 | |||
117 | dst->prev->next = src->next; | ||
118 | src->next->prev = dst->prev; | ||
119 | dst->prev = src->prev; | ||
120 | src->prev->next = dst; | ||
121 | eina_clist_init(src); | ||
122 | } | ||
123 | |||
124 | static inline void eina_clist_move_head(Eina_Clist *dst, Eina_Clist *src) | ||
125 | { | ||
126 | if (eina_clist_empty(src)) return; | ||
127 | |||
128 | dst->next->prev = src->prev; | ||
129 | src->prev->next = dst->next; | ||
130 | dst->next = src->next; | ||
131 | src->next->prev = dst; | ||
132 | eina_clist_init(src); | ||
133 | } | ||
134 | |||
135 | #endif | ||
diff --git a/libraries/eina/src/include/eina_inline_hash.x b/libraries/eina/src/include/eina_inline_hash.x index f27060f..be20e8f 100644 --- a/libraries/eina/src/include/eina_inline_hash.x +++ b/libraries/eina/src/include/eina_inline_hash.x | |||
@@ -101,7 +101,7 @@ static inline unsigned int _fmix32(unsigned int h) | |||
101 | return h; | 101 | return h; |
102 | } | 102 | } |
103 | 103 | ||
104 | int | 104 | static inline int |
105 | eina_hash_murmur3(const char *key, int len) | 105 | eina_hash_murmur3(const char *key, int len) |
106 | { | 106 | { |
107 | const unsigned char * data = (const unsigned char*)key; | 107 | const unsigned char * data = (const unsigned char*)key; |
diff --git a/libraries/eina/src/include/eina_inline_lock_posix.x b/libraries/eina/src/include/eina_inline_lock_posix.x index 77f5b8b..64e049a 100644 --- a/libraries/eina/src/include/eina_inline_lock_posix.x +++ b/libraries/eina/src/include/eina_inline_lock_posix.x | |||
@@ -19,6 +19,15 @@ | |||
19 | #ifndef EINA_INLINE_LOCK_POSIX_X_ | 19 | #ifndef EINA_INLINE_LOCK_POSIX_X_ |
20 | #define EINA_INLINE_LOCK_POSIX_X_ | 20 | #define EINA_INLINE_LOCK_POSIX_X_ |
21 | 21 | ||
22 | #ifdef EINA_UNUSED | ||
23 | # undef EINA_UNUSED | ||
24 | #endif | ||
25 | #ifdef __GNUC__ | ||
26 | # define EINA_UNUSED __attribute__((unused)) | ||
27 | #else | ||
28 | # define EINA_UNUSED | ||
29 | #endif | ||
30 | |||
22 | #include <errno.h> | 31 | #include <errno.h> |
23 | #ifndef __USE_UNIX98 | 32 | #ifndef __USE_UNIX98 |
24 | # define __USE_UNIX98 | 33 | # define __USE_UNIX98 |
@@ -28,7 +37,10 @@ | |||
28 | # include <pthread.h> | 37 | # include <pthread.h> |
29 | #endif | 38 | #endif |
30 | 39 | ||
40 | #include <semaphore.h> | ||
41 | |||
31 | #include <sys/time.h> | 42 | #include <sys/time.h> |
43 | #include <stdio.h> | ||
32 | 44 | ||
33 | #ifdef EINA_HAVE_DEBUG_THREADS | 45 | #ifdef EINA_HAVE_DEBUG_THREADS |
34 | #include <stdlib.h> | 46 | #include <stdlib.h> |
@@ -45,6 +57,7 @@ typedef struct _Eina_Lock Eina_Lock; | |||
45 | typedef struct _Eina_RWLock Eina_RWLock; | 57 | typedef struct _Eina_RWLock Eina_RWLock; |
46 | typedef struct _Eina_Condition Eina_Condition; | 58 | typedef struct _Eina_Condition Eina_Condition; |
47 | typedef pthread_key_t Eina_TLS; | 59 | typedef pthread_key_t Eina_TLS; |
60 | typedef sem_t Eina_Semaphore; | ||
48 | 61 | ||
49 | struct _Eina_Lock | 62 | struct _Eina_Lock |
50 | { | 63 | { |
@@ -77,8 +90,6 @@ struct _Eina_RWLock | |||
77 | EAPI extern Eina_Bool _eina_threads_activated; | 90 | EAPI extern Eina_Bool _eina_threads_activated; |
78 | 91 | ||
79 | #ifdef EINA_HAVE_DEBUG_THREADS | 92 | #ifdef EINA_HAVE_DEBUG_THREADS |
80 | # include <sys/time.h> | ||
81 | |||
82 | EAPI extern int _eina_threads_debug; | 93 | EAPI extern int _eina_threads_debug; |
83 | EAPI extern pthread_t _eina_main_loop; | 94 | EAPI extern pthread_t _eina_main_loop; |
84 | EAPI extern pthread_mutex_t _eina_tracking_lock; | 95 | EAPI extern pthread_mutex_t _eina_tracking_lock; |
@@ -506,4 +517,40 @@ eina_tls_set(Eina_TLS key, const void *data) | |||
506 | return EINA_TRUE; | 517 | return EINA_TRUE; |
507 | } | 518 | } |
508 | 519 | ||
520 | static inline Eina_Bool | ||
521 | eina_semaphore_new(Eina_Semaphore *sem, int count_init) | ||
522 | { | ||
523 | if (!sem || (count_init <= 0)) | ||
524 | return EINA_FALSE; | ||
525 | |||
526 | return (sem_init(sem, count_init, 1) == 0) ? EINA_TRUE : EINA_FALSE; | ||
527 | } | ||
528 | |||
529 | static inline Eina_Bool | ||
530 | eina_semaphore_free(Eina_Semaphore *sem) | ||
531 | { | ||
532 | if (!sem) | ||
533 | return EINA_FALSE; | ||
534 | |||
535 | return (sem_destroy(sem) == 0) ? EINA_TRUE : EINA_FALSE; | ||
536 | } | ||
537 | |||
538 | static inline Eina_Bool | ||
539 | eina_semaphore_lock(Eina_Semaphore *sem) | ||
540 | { | ||
541 | if (!sem) | ||
542 | return EINA_FALSE; | ||
543 | |||
544 | return (sem_wait(sem) == 0) ? EINA_TRUE : EINA_FALSE; | ||
545 | } | ||
546 | |||
547 | static inline Eina_Bool | ||
548 | eina_semaphore_release(Eina_Semaphore *sem, int count_release EINA_UNUSED) | ||
549 | { | ||
550 | if (!sem) | ||
551 | return EINA_FALSE; | ||
552 | |||
553 | return (sem_post(sem) == 0) ? EINA_TRUE : EINA_FALSE; | ||
554 | } | ||
555 | |||
509 | #endif | 556 | #endif |
diff --git a/libraries/eina/src/include/eina_inline_lock_void.x b/libraries/eina/src/include/eina_inline_lock_void.x index 8cb9a49..2f5209f 100644 --- a/libraries/eina/src/include/eina_inline_lock_void.x +++ b/libraries/eina/src/include/eina_inline_lock_void.x | |||
@@ -47,6 +47,7 @@ typedef void *Eina_Lock; | |||
47 | typedef void *Eina_RWLock; | 47 | typedef void *Eina_RWLock; |
48 | typedef void *Eina_Condition; | 48 | typedef void *Eina_Condition; |
49 | typedef void *Eina_TLS; | 49 | typedef void *Eina_TLS; |
50 | typedef void *Eina_Semaphore; | ||
50 | 51 | ||
51 | /** | 52 | /** |
52 | * @brief Create a new #Eina_Lock. | 53 | * @brief Create a new #Eina_Lock. |
@@ -63,7 +64,7 @@ typedef void *Eina_TLS; | |||
63 | static inline Eina_Bool | 64 | static inline Eina_Bool |
64 | eina_lock_new(Eina_Lock *mutex EINA_UNUSED) | 65 | eina_lock_new(Eina_Lock *mutex EINA_UNUSED) |
65 | { | 66 | { |
66 | return EINA_FALSE; | 67 | return EINA_TRUE; |
67 | } | 68 | } |
68 | 69 | ||
69 | /** | 70 | /** |
@@ -94,7 +95,7 @@ eina_lock_free(Eina_Lock *mutex EINA_UNUSED) | |||
94 | static inline Eina_Lock_Result | 95 | static inline Eina_Lock_Result |
95 | eina_lock_take(Eina_Lock *mutex EINA_UNUSED) | 96 | eina_lock_take(Eina_Lock *mutex EINA_UNUSED) |
96 | { | 97 | { |
97 | return EINA_LOCK_FAIL; | 98 | return EINA_LOCK_SUCCEED; |
98 | } | 99 | } |
99 | 100 | ||
100 | /** | 101 | /** |
@@ -115,7 +116,7 @@ eina_lock_take(Eina_Lock *mutex EINA_UNUSED) | |||
115 | static inline Eina_Lock_Result | 116 | static inline Eina_Lock_Result |
116 | eina_lock_take_try(Eina_Lock *mutex EINA_UNUSED) | 117 | eina_lock_take_try(Eina_Lock *mutex EINA_UNUSED) |
117 | { | 118 | { |
118 | return EINA_LOCK_FAIL; | 119 | return EINA_LOCK_SUCCEED; |
119 | } | 120 | } |
120 | 121 | ||
121 | /** | 122 | /** |
@@ -132,7 +133,7 @@ eina_lock_take_try(Eina_Lock *mutex EINA_UNUSED) | |||
132 | static inline Eina_Lock_Result | 133 | static inline Eina_Lock_Result |
133 | eina_lock_release(Eina_Lock *mutex EINA_UNUSED) | 134 | eina_lock_release(Eina_Lock *mutex EINA_UNUSED) |
134 | { | 135 | { |
135 | return EINA_LOCK_FAIL; | 136 | return EINA_LOCK_SUCCEED; |
136 | } | 137 | } |
137 | 138 | ||
138 | static inline void | 139 | static inline void |
@@ -143,7 +144,7 @@ eina_lock_debug(const Eina_Lock *mutex EINA_UNUSED) | |||
143 | static inline Eina_Bool | 144 | static inline Eina_Bool |
144 | eina_condition_new(Eina_Condition *cond EINA_UNUSED, Eina_Lock *mutex EINA_UNUSED) | 145 | eina_condition_new(Eina_Condition *cond EINA_UNUSED, Eina_Lock *mutex EINA_UNUSED) |
145 | { | 146 | { |
146 | return EINA_FALSE; | 147 | return EINA_TRUE; |
147 | } | 148 | } |
148 | 149 | ||
149 | static inline void | 150 | static inline void |
@@ -154,72 +155,72 @@ eina_condition_free(Eina_Condition *cond EINA_UNUSED) | |||
154 | static inline Eina_Bool | 155 | static inline Eina_Bool |
155 | eina_condition_wait(Eina_Condition *cond EINA_UNUSED) | 156 | eina_condition_wait(Eina_Condition *cond EINA_UNUSED) |
156 | { | 157 | { |
157 | return EINA_FALSE; | 158 | return EINA_TRUE; |
158 | } | 159 | } |
159 | 160 | ||
160 | static inline Eina_Bool | 161 | static inline Eina_Bool |
161 | eina_condition_timedwait(Eina_Condition *cond EINA_UNUSED, double val EINA_UNUSED) | 162 | eina_condition_timedwait(Eina_Condition *cond EINA_UNUSED, double val EINA_UNUSED) |
162 | { | 163 | { |
163 | return EINA_FALSE; | 164 | return EINA_TRUE; |
164 | } | 165 | } |
165 | 166 | ||
166 | static inline Eina_Bool | 167 | static inline Eina_Bool |
167 | eina_condition_broadcast(Eina_Condition *cond EINA_UNUSED) | 168 | eina_condition_broadcast(Eina_Condition *cond EINA_UNUSED) |
168 | { | 169 | { |
169 | return EINA_FALSE; | 170 | return EINA_TRUE; |
170 | } | 171 | } |
171 | 172 | ||
172 | static inline Eina_Bool | 173 | static inline Eina_Bool |
173 | eina_condition_signal(Eina_Condition *cond EINA_UNUSED) | 174 | eina_condition_signal(Eina_Condition *cond EINA_UNUSED) |
174 | { | 175 | { |
175 | return EINA_FALSE; | 176 | return EINA_TRUE; |
176 | } | 177 | } |
177 | 178 | ||
178 | static inline Eina_Bool | 179 | static inline Eina_Bool |
179 | eina_rwlock_new(Eina_RWLock *mutex EINA_UNUSED) | 180 | eina_rwlock_new(Eina_RWLock *mutex EINA_UNUSED) |
180 | { | 181 | { |
181 | return EINA_FALSE; | 182 | return EINA_TRUE; |
182 | } | 183 | } |
183 | 184 | ||
184 | static inline void | 185 | static inline void |
185 | eina_rwlock_free(Eina_RWLock *mutex EINA_UNUSED) | 186 | eina_rwlock_free(Eina_RWLock *mutex EINA_UNUSED) |
186 | { | 187 | { |
187 | } | 188 | } |
188 | 189 | ||
189 | static inline Eina_Lock_Result | 190 | static inline Eina_Lock_Result |
190 | eina_rwlock_read_take(Eina_RWLock *mutex EINA_UNUSED) | 191 | eina_rwlock_read_take(Eina_RWLock *mutex EINA_UNUSED) |
191 | { | 192 | { |
192 | return EINA_LOCK_FAIL; | 193 | return EINA_LOCK_SUCCEED; |
193 | } | 194 | } |
194 | 195 | ||
195 | static inline Eina_Lock_Result | 196 | static inline Eina_Lock_Result |
196 | eina_rwlock_write_take(Eina_RWLock *mutex EINA_UNUSED) | 197 | eina_rwlock_write_take(Eina_RWLock *mutex EINA_UNUSED) |
197 | { | 198 | { |
198 | return EINA_LOCK_FAIL; | 199 | return EINA_LOCK_SUCCEED; |
199 | } | 200 | } |
200 | 201 | ||
201 | static inline Eina_Lock_Result | 202 | static inline Eina_Lock_Result |
202 | eina_rwlock_release(Eina_RWLock *mutex EINA_UNUSED) | 203 | eina_rwlock_release(Eina_RWLock *mutex EINA_UNUSED) |
203 | { | 204 | { |
204 | return EINA_LOCK_FAIL; | 205 | return EINA_LOCK_SUCCEED; |
205 | } | 206 | } |
206 | 207 | ||
207 | static inline Eina_Lock_Result | 208 | static inline Eina_Lock_Result |
208 | eina_rwlock_take_read(Eina_RWLock *mutex EINA_UNUSED) | 209 | eina_rwlock_take_read(Eina_RWLock *mutex EINA_UNUSED) |
209 | { | 210 | { |
210 | return EINA_LOCK_FAIL; | 211 | return EINA_LOCK_SUCCEED; |
211 | } | 212 | } |
212 | 213 | ||
213 | static inline Eina_Lock_Result | 214 | static inline Eina_Lock_Result |
214 | eina_rwlock_take_write(Eina_RWLock *mutex EINA_UNUSED) | 215 | eina_rwlock_take_write(Eina_RWLock *mutex EINA_UNUSED) |
215 | { | 216 | { |
216 | return EINA_LOCK_FAIL; | 217 | return EINA_LOCK_SUCCEED; |
217 | } | 218 | } |
218 | 219 | ||
219 | static inline Eina_Bool | 220 | static inline Eina_Bool |
220 | eina_tls_new(Eina_TLS *key EINA_UNUSED) | 221 | eina_tls_new(Eina_TLS *key EINA_UNUSED) |
221 | { | 222 | { |
222 | return EINA_FALSE; | 223 | return EINA_TRUE; |
223 | } | 224 | } |
224 | 225 | ||
225 | static inline void | 226 | static inline void |
@@ -236,9 +237,34 @@ eina_tls_get(Eina_TLS key EINA_UNUSED) | |||
236 | static inline Eina_Bool | 237 | static inline Eina_Bool |
237 | eina_tls_set(Eina_TLS key EINA_UNUSED, const void *data EINA_UNUSED) | 238 | eina_tls_set(Eina_TLS key EINA_UNUSED, const void *data EINA_UNUSED) |
238 | { | 239 | { |
239 | return EINA_FALSE; | 240 | return EINA_TRUE; |
240 | } | 241 | } |
241 | 242 | ||
243 | static inline Eina_Bool | ||
244 | eina_semaphore_new(Eina_Semaphore *sem EINA_UNUSED, | ||
245 | int count_init EINA_UNUSED) | ||
246 | { | ||
247 | return EINA_TRUE; | ||
248 | } | ||
249 | |||
250 | static inline Eina_Bool | ||
251 | eina_semaphore_free(Eina_Semaphore *sem EINA_UNUSED) | ||
252 | { | ||
253 | return EINA_TRUE; | ||
254 | } | ||
255 | |||
256 | static inline Eina_Bool | ||
257 | eina_semaphore_lock(Eina_Semaphore *sem EINA_UNUSED) | ||
258 | { | ||
259 | return EINA_TRUE; | ||
260 | } | ||
261 | |||
262 | static inline Eina_Bool | ||
263 | eina_semaphore_release(Eina_Semaphore *sem EINA_UNUSED, | ||
264 | int count_release EINA_UNUSED) | ||
265 | { | ||
266 | return EINA_TRUE; | ||
267 | } | ||
242 | 268 | ||
243 | /** | 269 | /** |
244 | * @} | 270 | * @} |
diff --git a/libraries/eina/src/include/eina_inline_lock_win32.x b/libraries/eina/src/include/eina_inline_lock_win32.x index 072095c..e8363d5 100644 --- a/libraries/eina/src/include/eina_inline_lock_win32.x +++ b/libraries/eina/src/include/eina_inline_lock_win32.x | |||
@@ -58,6 +58,8 @@ struct _Eina_Win32_RWLock | |||
58 | 58 | ||
59 | typedef DWORD Eina_TLS; | 59 | typedef DWORD Eina_TLS; |
60 | 60 | ||
61 | typedef HANDLE Eina_Semaphore; | ||
62 | |||
61 | EAPI extern Eina_Bool _eina_threads_activated; | 63 | EAPI extern Eina_Bool _eina_threads_activated; |
62 | 64 | ||
63 | static inline Eina_Bool | 65 | static inline Eina_Bool |
@@ -463,4 +465,48 @@ eina_tls_set(Eina_TLS key, const void *data) | |||
463 | return EINA_TRUE; | 465 | return EINA_TRUE; |
464 | } | 466 | } |
465 | 467 | ||
468 | static inline Eina_Bool | ||
469 | eina_semaphore_new(Eina_Semaphore *sem, int count_init) | ||
470 | { | ||
471 | if (!sem || (count_init <= 0)) | ||
472 | return EINA_FALSE; | ||
473 | |||
474 | *sem = CreateSemaphore(NULL, count_init, 32767, NULL); | ||
475 | if (!*sem) | ||
476 | return EINA_FALSE; | ||
477 | } | ||
478 | |||
479 | static inline Eina_Bool | ||
480 | eina_semaphore_free(Eina_Semaphore *sem) | ||
481 | { | ||
482 | if (!sem) | ||
483 | return EINA_FALSE; | ||
484 | |||
485 | CloseHandle(*sem); | ||
486 | } | ||
487 | |||
488 | static inline Eina_Bool | ||
489 | eina_semaphore_lock(Eina_Semaphore *sem) | ||
490 | { | ||
491 | DWORD res; | ||
492 | |||
493 | if (!sem) | ||
494 | return EINA_FALSE; | ||
495 | |||
496 | res = WaitForSingleObject(*sem, 0L); | ||
497 | if (res == WAIT_OBJECT_0) | ||
498 | return EINA_TRUE; | ||
499 | |||
500 | return EINA_FALSE; | ||
501 | } | ||
502 | |||
503 | static inline Eina_Bool | ||
504 | eina_semaphore_release(Eina_Semaphore *sem, int count_release) | ||
505 | { | ||
506 | if (!sem) | ||
507 | return EINA_FALSE; | ||
508 | |||
509 | return ReleaseSemaphore(*sem, count_release, NULL) ? EINA_TRUE : EINA_FALSE; | ||
510 | } | ||
511 | |||
466 | #endif | 512 | #endif |
diff --git a/libraries/eina/src/include/eina_inline_lock_wince.x b/libraries/eina/src/include/eina_inline_lock_wince.x index 965d475..1af1aac 100644 --- a/libraries/eina/src/include/eina_inline_lock_wince.x +++ b/libraries/eina/src/include/eina_inline_lock_wince.x | |||
@@ -19,6 +19,15 @@ | |||
19 | #ifndef EINA_INLINE_LOCK_WIN32_X_ | 19 | #ifndef EINA_INLINE_LOCK_WIN32_X_ |
20 | #define EINA_INLINE_LOCK_WIN32_X_ | 20 | #define EINA_INLINE_LOCK_WIN32_X_ |
21 | 21 | ||
22 | #ifdef EINA_UNUSED | ||
23 | # undef EINA_UNUSED | ||
24 | #endif | ||
25 | #ifdef __GNUC__ | ||
26 | # define EINA_UNUSED __attribute__((unused)) | ||
27 | #else | ||
28 | # define EINA_UNUSED | ||
29 | #endif | ||
30 | |||
22 | #include <windows.h> | 31 | #include <windows.h> |
23 | 32 | ||
24 | EAPI extern Eina_Bool _threads_activated; | 33 | EAPI extern Eina_Bool _threads_activated; |
@@ -26,6 +35,7 @@ EAPI extern Eina_Bool _threads_activated; | |||
26 | typedef HANDLE Eina_Lock; | 35 | typedef HANDLE Eina_Lock; |
27 | typedef Eina_Lock Eina_RWLock; | 36 | typedef Eina_Lock Eina_RWLock; |
28 | typedef DWORD Eina_TLS; | 37 | typedef DWORD Eina_TLS; |
38 | typedef void * Eina_Semaphore; | ||
29 | 39 | ||
30 | static inline Eina_Bool | 40 | static inline Eina_Bool |
31 | eina_lock_new(Eina_Lock *mutex) | 41 | eina_lock_new(Eina_Lock *mutex) |
@@ -173,6 +183,30 @@ eina_tls_set(Eina_TLS key, const void *data) | |||
173 | return EINA_TRUE; | 183 | return EINA_TRUE; |
174 | } | 184 | } |
175 | 185 | ||
186 | static inline Eina_Bool | ||
187 | eina_semaphore_new(Eina_Semaphore *sem EINA_UNUSED, | ||
188 | int count_init EINA_UNUSED) | ||
189 | { | ||
190 | return EINA_FALSE; | ||
191 | } | ||
176 | 192 | ||
193 | static inline Eina_Bool | ||
194 | eina_semaphore_free(Eina_Semaphore *sem EINA_UNUSED) | ||
195 | { | ||
196 | return EINA_FALSE; | ||
197 | } | ||
198 | |||
199 | static inline Eina_Bool | ||
200 | eina_semaphore_lock(Eina_Semaphore *sem EINA_UNUSED) | ||
201 | { | ||
202 | return EINA_FALSE; | ||
203 | } | ||
204 | |||
205 | static inline Eina_Bool | ||
206 | eina_semaphore_release(Eina_Semaphore *sem EINA_UNUSED, | ||
207 | int count_release EINA_UNUSED) | ||
208 | { | ||
209 | return EINA_FALSE; | ||
210 | } | ||
177 | 211 | ||
178 | #endif | 212 | #endif |
diff --git a/libraries/eina/src/include/eina_inline_log.x b/libraries/eina/src/include/eina_inline_log.x index 4cdd7d8..53d8afb 100644 --- a/libraries/eina/src/include/eina_inline_log.x +++ b/libraries/eina/src/include/eina_inline_log.x | |||
@@ -49,7 +49,7 @@ | |||
49 | static inline Eina_Bool | 49 | static inline Eina_Bool |
50 | eina_log_level_check(int level) | 50 | eina_log_level_check(int level) |
51 | { | 51 | { |
52 | return eina_log_level_get() <= level; | 52 | return eina_log_level_get() >= level; |
53 | } | 53 | } |
54 | 54 | ||
55 | /** | 55 | /** |
@@ -81,7 +81,7 @@ eina_log_domain_level_check(int domain, int level) | |||
81 | int dom_level = eina_log_domain_registered_level_get(domain); | 81 | int dom_level = eina_log_domain_registered_level_get(domain); |
82 | if (EINA_UNLIKELY(dom_level == EINA_LOG_LEVEL_UNKNOWN)) | 82 | if (EINA_UNLIKELY(dom_level == EINA_LOG_LEVEL_UNKNOWN)) |
83 | return EINA_FALSE; | 83 | return EINA_FALSE; |
84 | return dom_level <= level; | 84 | return dom_level >= level; |
85 | } | 85 | } |
86 | 86 | ||
87 | /** | 87 | /** |
diff --git a/libraries/eina/src/include/eina_inline_mempool.x b/libraries/eina/src/include/eina_inline_mempool.x index a67ec3d..729a669 100644 --- a/libraries/eina/src/include/eina_inline_mempool.x +++ b/libraries/eina/src/include/eina_inline_mempool.x | |||
@@ -19,6 +19,8 @@ | |||
19 | #ifndef EINA_INLINE_MEMPOOL_X_ | 19 | #ifndef EINA_INLINE_MEMPOOL_X_ |
20 | #define EINA_INLINE_MEMPOOL_X_ | 20 | #define EINA_INLINE_MEMPOOL_X_ |
21 | 21 | ||
22 | #include <string.h> | ||
23 | |||
22 | /** | 24 | /** |
23 | * @addtogroup Eina_Memory_Pool_Group Memory Pool | 25 | * @addtogroup Eina_Memory_Pool_Group Memory Pool |
24 | * | 26 | * |
@@ -67,17 +69,16 @@ struct _Eina_Mempool | |||
67 | }; | 69 | }; |
68 | 70 | ||
69 | /** | 71 | /** |
70 | * @brief Re-allocate a amount memory by the given mempool. | 72 | * @brief Re-allocate an amount memory by the given mempool. |
71 | * | 73 | * |
72 | * @param mp The mempool. | 74 | * @param mp The mempool. |
73 | * @param element The element to re-allocate. | 75 | * @param element The element to re-allocate. |
74 | * @param size The size in bytes to re-allocate. | 76 | * @param size The size in bytes to re-allocate. |
75 | * @return The newly re-allocated data. | 77 | * @return The newly re-allocated data. |
76 | * | 78 | * |
77 | * This function re-allocates @p element with @p size bytes, using the | 79 | * This function re-allocates and returns @p element with @p size bytes using the |
78 | * mempool @p mp and returns the allocated data. If not used anymore, | 80 | * mempool @p mp. If not used anymore, the data must be freed with eina_mempool_free(). |
79 | * the data must be freed with eina_mempool_free(). No check is done | 81 | * @warning No checks are done for @p mp. |
80 | * on @p mp, so it must be a valid mempool. | ||
81 | */ | 82 | */ |
82 | static inline void * | 83 | static inline void * |
83 | eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) | 84 | eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) |
@@ -86,16 +87,15 @@ eina_mempool_realloc(Eina_Mempool *mp, void *element, unsigned int size) | |||
86 | } | 87 | } |
87 | 88 | ||
88 | /** | 89 | /** |
89 | * @brief Allocate a amount memory by the given mempool. | 90 | * @brief Allocate memory using the given mempool. |
90 | * | 91 | * |
91 | * @param mp The mempool. | 92 | * @param mp The mempool. |
92 | * @param size The size in bytes to allocate. | 93 | * @param size The size in bytes to allocate. |
93 | * @return The newly allocated data. | 94 | * @return The newly allocated data. |
94 | * | 95 | * |
95 | * This function allocates @p size bytes, using the mempool @p mp and | 96 | * This function allocates and returns @p size bytes using the mempool @p mp. |
96 | * returns the allocated data. If not used anymore, the data must be | 97 | * If not used anymore, the data must be freed with eina_mempool_free(). |
97 | * freed with eina_mempool_free(). No check is done on @p mp, so it | 98 | * @warning No checks are done for @p mp. |
98 | * must be a valid mempool. | ||
99 | */ | 99 | */ |
100 | static inline void * | 100 | static inline void * |
101 | eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) | 101 | eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) |
@@ -104,15 +104,36 @@ eina_mempool_malloc(Eina_Mempool *mp, unsigned int size) | |||
104 | } | 104 | } |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * @brief Free the allocated ressources by the given mempool. | 107 | * @brief Allocate and zero memory using the given mempool. |
108 | * | ||
109 | * @param mp The mempool. | ||
110 | * @param size The size in bytes to allocate. | ||
111 | * @return The newly allocated data. | ||
112 | * | ||
113 | * This function allocates, zeroes, and returns @p size bytes using the mempool @p mp. | ||
114 | * If not used anymore, the data must be freed with eina_mempool_free(). | ||
115 | * @warning No checks are done for @p mp. | ||
116 | * @since 1.2 | ||
117 | */ | ||
118 | static inline void * | ||
119 | eina_mempool_calloc(Eina_Mempool *mp, unsigned int size) | ||
120 | { | ||
121 | void *r = mp->backend.alloc(mp->backend_data, size); | ||
122 | if (!r) return NULL; | ||
123 | memset(r, 0, size); | ||
124 | return r; | ||
125 | } | ||
126 | |||
127 | /** | ||
128 | * @brief Free resources previously allocated by the given mempool. | ||
108 | * | 129 | * |
109 | * @param mp The mempool. | 130 | * @param mp The mempool. |
110 | * @param element The data to free. | 131 | * @param element The data to free. |
111 | * | 132 | * |
112 | * This function frees @p element allocated by @p mp. @p element must | 133 | * This function frees @p element allocated by @p mp. @p element must |
113 | * have been obtained by eina_mempool_malloc() or | 134 | * have been obtained from eina_mempool_malloc(), eina_mempool_calloc(), or |
114 | * eina_mempool_realloc(). No check is done on @p mp, so it must be a | 135 | * eina_mempool_realloc(). |
115 | * valid mempool. | 136 | * @warning No checks are done for @p mp. |
116 | */ | 137 | */ |
117 | static inline void | 138 | static inline void |
118 | eina_mempool_free(Eina_Mempool *mp, void *element) | 139 | eina_mempool_free(Eina_Mempool *mp, void *element) |
diff --git a/libraries/eina/src/include/eina_inline_value.x b/libraries/eina/src/include/eina_inline_value.x new file mode 100644 index 0000000..59ec315 --- /dev/null +++ b/libraries/eina/src/include/eina_inline_value.x | |||
@@ -0,0 +1,1705 @@ | |||
1 | /* Eina - EFL data type library | ||
2 | * Copyright (C) 2012 ProFUSION embedded systems | ||
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 | #ifndef EINA_INLINE_VALUE_X_ | ||
20 | #define EINA_INLINE_VALUE_X_ | ||
21 | |||
22 | #include <string.h> | ||
23 | #include <alloca.h> | ||
24 | |||
25 | #include "eina_stringshare.h" | ||
26 | |||
27 | /* NOTE: most of value is implemented here for performance reasons */ | ||
28 | |||
29 | //#define EINA_VALUE_NO_OPTIMIZE 1 | ||
30 | #ifdef EINA_VALUE_NO_OPTIMIZE | ||
31 | #define EINA_VALUE_TYPE_DEFAULT(type) (0) | ||
32 | #else | ||
33 | |||
34 | /** | ||
35 | * @var _EINA_VALUE_TYPE_BASICS_START | ||
36 | * pointer to the first basic type. | ||
37 | * @since 1.2 | ||
38 | * @private | ||
39 | */ | ||
40 | EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_START; | ||
41 | |||
42 | /** | ||
43 | * @var _EINA_VALUE_TYPE_BASICS_END | ||
44 | * pointer to the last (inclusive) basic type. | ||
45 | * @since 1.2 | ||
46 | * @private | ||
47 | */ | ||
48 | EAPI extern const Eina_Value_Type *_EINA_VALUE_TYPE_BASICS_END; | ||
49 | #define EINA_VALUE_TYPE_DEFAULT(type) \ | ||
50 | ((_EINA_VALUE_TYPE_BASICS_START <= type) && \ | ||
51 | (type <= _EINA_VALUE_TYPE_BASICS_END)) | ||
52 | #endif | ||
53 | |||
54 | #define EINA_VALUE_TYPE_CHECK_RETURN(value) \ | ||
55 | EINA_SAFETY_ON_NULL_RETURN(value); \ | ||
56 | EINA_SAFETY_ON_FALSE_RETURN(eina_value_type_check(value->type)) | ||
57 | |||
58 | #define EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, retval) \ | ||
59 | EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ | ||
60 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(value->type), retval) | ||
61 | |||
62 | #define EINA_VALUE_TYPE_DISPATCH(type, method, no_method_err, ...) \ | ||
63 | do \ | ||
64 | { \ | ||
65 | if (type->method) \ | ||
66 | type->method(type, ##__VA_ARGS__); \ | ||
67 | else \ | ||
68 | eina_error_set(no_method_err); \ | ||
69 | } \ | ||
70 | while (0) | ||
71 | |||
72 | #define EINA_VALUE_TYPE_DISPATCH_RETURN(value, method, no_method_err, def_ret, ...) \ | ||
73 | do \ | ||
74 | { \ | ||
75 | if (type->method) \ | ||
76 | return type->method(type, ##__VA_ARGS__); \ | ||
77 | eina_error_set(no_method_err); \ | ||
78 | return def_ret; \ | ||
79 | } \ | ||
80 | while (0) | ||
81 | |||
82 | /** | ||
83 | * @brief Get memory for given value (inline or allocated buffer). | ||
84 | * @since 1.2 | ||
85 | * @private | ||
86 | */ | ||
87 | static inline void * | ||
88 | eina_value_memory_get(const Eina_Value *value) | ||
89 | { | ||
90 | if (value->type->value_size <= 8) | ||
91 | return (void *)value->value.buf; | ||
92 | return value->value.ptr; | ||
93 | } | ||
94 | |||
95 | /** | ||
96 | * @brief Allocate memory for internal value types. | ||
97 | * @since 1.2 | ||
98 | * @private | ||
99 | */ | ||
100 | EAPI void *eina_value_inner_alloc(size_t size); | ||
101 | /** | ||
102 | * @brief Releases memory for internal value types. | ||
103 | * @since 1.2 | ||
104 | * @private | ||
105 | */ | ||
106 | EAPI void eina_value_inner_free(size_t size, void *mem); | ||
107 | |||
108 | static inline Eina_Bool | ||
109 | eina_value_setup(Eina_Value *value, const Eina_Value_Type *type) | ||
110 | { | ||
111 | void *mem; | ||
112 | |||
113 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
114 | EINA_SAFETY_ON_FALSE_RETURN_VAL(type->value_size > 0, EINA_FALSE); | ||
115 | |||
116 | value->type = type; | ||
117 | |||
118 | if (type->value_size <= 8) mem = &value->value; | ||
119 | else | ||
120 | { | ||
121 | mem = value->value.ptr = eina_value_inner_alloc(type->value_size); | ||
122 | EINA_SAFETY_ON_NULL_RETURN_VAL(mem, EINA_FALSE); | ||
123 | } | ||
124 | |||
125 | memset(mem, 0, type->value_size); | ||
126 | |||
127 | if (EINA_VALUE_TYPE_DEFAULT(type)) | ||
128 | { | ||
129 | eina_error_set(0); | ||
130 | return EINA_TRUE; | ||
131 | } | ||
132 | |||
133 | EINA_VALUE_TYPE_DISPATCH_RETURN(type, setup, | ||
134 | EINA_ERROR_VALUE_FAILED, EINA_FALSE, mem); | ||
135 | } | ||
136 | |||
137 | static inline void | ||
138 | eina_value_flush(Eina_Value *value) | ||
139 | { | ||
140 | const Eina_Value_Type *type; | ||
141 | void *mem; | ||
142 | |||
143 | EINA_VALUE_TYPE_CHECK_RETURN(value); | ||
144 | |||
145 | type = value->type; | ||
146 | mem = eina_value_memory_get(value); | ||
147 | |||
148 | if (EINA_VALUE_TYPE_DEFAULT(type)) | ||
149 | { | ||
150 | if (type == EINA_VALUE_TYPE_STRINGSHARE) | ||
151 | { | ||
152 | if (value->value.ptr) eina_stringshare_del((const char*) value->value.ptr); | ||
153 | } | ||
154 | else if (type == EINA_VALUE_TYPE_STRING) | ||
155 | { | ||
156 | if (value->value.ptr) free(value->value.ptr); | ||
157 | } | ||
158 | else if (type->value_size > 8) | ||
159 | eina_value_inner_free(type->value_size, mem); | ||
160 | eina_error_set(0); | ||
161 | return; | ||
162 | } | ||
163 | |||
164 | EINA_VALUE_TYPE_DISPATCH(type, flush, EINA_ERROR_VALUE_FAILED, mem); | ||
165 | if (type->value_size > 8) | ||
166 | eina_value_inner_free(type->value_size, mem); | ||
167 | value->type = NULL; | ||
168 | } | ||
169 | |||
170 | static inline int | ||
171 | eina_value_compare(const Eina_Value *a, const Eina_Value *b) | ||
172 | { | ||
173 | const Eina_Value_Type *type; | ||
174 | void *pa, *pb; | ||
175 | |||
176 | EINA_VALUE_TYPE_CHECK_RETURN_VAL(a, -1); | ||
177 | EINA_SAFETY_ON_NULL_RETURN_VAL(b, -1); | ||
178 | EINA_SAFETY_ON_FALSE_RETURN_VAL(a->type == b->type, -1); | ||
179 | |||
180 | eina_error_set(0); | ||
181 | type = a->type; | ||
182 | pa = eina_value_memory_get(a); | ||
183 | pb = eina_value_memory_get(b); | ||
184 | |||
185 | #ifndef EINA_VALUE_NO_OPTIMIZE | ||
186 | if (type == EINA_VALUE_TYPE_UCHAR) | ||
187 | { | ||
188 | unsigned char *ta = (unsigned char *) pa, *tb = (unsigned char *) pb; | ||
189 | if (*ta < *tb) | ||
190 | return -1; | ||
191 | else if (*ta > *tb) | ||
192 | return 1; | ||
193 | return 0; | ||
194 | } | ||
195 | else if (type == EINA_VALUE_TYPE_USHORT) | ||
196 | { | ||
197 | unsigned short *ta = (unsigned short *) pa, *tb = (unsigned short *) pb; | ||
198 | if (*ta < *tb) | ||
199 | return -1; | ||
200 | else if (*ta > *tb) | ||
201 | return 1; | ||
202 | return 0; | ||
203 | } | ||
204 | else if (type == EINA_VALUE_TYPE_UINT) | ||
205 | { | ||
206 | unsigned int *ta = (unsigned int *) pa, *tb = (unsigned int *) pb; | ||
207 | if (*ta < *tb) | ||
208 | return -1; | ||
209 | else if (*ta > *tb) | ||
210 | return 1; | ||
211 | return 0; | ||
212 | } | ||
213 | else if (type == EINA_VALUE_TYPE_ULONG) | ||
214 | { | ||
215 | unsigned long *ta = (unsigned long *) pa, *tb = (unsigned long *) pb; | ||
216 | if (*ta < *tb) | ||
217 | return -1; | ||
218 | else if (*ta > *tb) | ||
219 | return 1; | ||
220 | return 0; | ||
221 | } | ||
222 | else if (type == EINA_VALUE_TYPE_UINT64) | ||
223 | { | ||
224 | uint64_t *ta = (uint64_t *) pa, *tb = (uint64_t *) pb; | ||
225 | if (*ta < *tb) | ||
226 | return -1; | ||
227 | else if (*ta > *tb) | ||
228 | return 1; | ||
229 | return 0; | ||
230 | } | ||
231 | else if (type == EINA_VALUE_TYPE_CHAR) | ||
232 | { | ||
233 | char *ta = (char *) pa, *tb = (char *) pb; | ||
234 | if (*ta < *tb) | ||
235 | return -1; | ||
236 | else if (*ta > *tb) | ||
237 | return 1; | ||
238 | return 0; | ||
239 | } | ||
240 | else if (type == EINA_VALUE_TYPE_SHORT) | ||
241 | { | ||
242 | short *ta = (short *) pa, *tb = (short *) pb; | ||
243 | if (*ta < *tb) | ||
244 | return -1; | ||
245 | else if (*ta > *tb) | ||
246 | return 1; | ||
247 | return 0; | ||
248 | } | ||
249 | else if (type == EINA_VALUE_TYPE_INT) | ||
250 | { | ||
251 | int *ta = (int *) pa, *tb = (int *) pb; | ||
252 | if (*ta < *tb) | ||
253 | return -1; | ||
254 | else if (*ta > *tb) | ||
255 | return 1; | ||
256 | return 0; | ||
257 | } | ||
258 | else if (type == EINA_VALUE_TYPE_LONG) | ||
259 | { | ||
260 | long *ta = (long *) pa, *tb = (long *) pb; | ||
261 | if (*ta < *tb) | ||
262 | return -1; | ||
263 | else if (*ta > *tb) | ||
264 | return 1; | ||
265 | return 0; | ||
266 | } | ||
267 | else if (type == EINA_VALUE_TYPE_INT64) | ||
268 | { | ||
269 | int64_t *ta = (int64_t *) pa, *tb = (int64_t *) pb; | ||
270 | if (*ta < *tb) | ||
271 | return -1; | ||
272 | else if (*ta > *tb) | ||
273 | return 1; | ||
274 | return 0; | ||
275 | } | ||
276 | else if (type == EINA_VALUE_TYPE_FLOAT) | ||
277 | { | ||
278 | float *ta = (float *) pa, *tb = (float *) pb; | ||
279 | if (*ta < *tb) | ||
280 | return -1; | ||
281 | else if (*ta > *tb) | ||
282 | return 1; | ||
283 | return 0; | ||
284 | } | ||
285 | else if (type == EINA_VALUE_TYPE_DOUBLE) | ||
286 | { | ||
287 | double *ta = (double *) pa, *tb = (double *) pb; | ||
288 | if (*ta < *tb) | ||
289 | return -1; | ||
290 | else if (*ta > *tb) | ||
291 | return 1; | ||
292 | return 0; | ||
293 | } | ||
294 | else if (type == EINA_VALUE_TYPE_STRINGSHARE || | ||
295 | type == EINA_VALUE_TYPE_STRING) | ||
296 | { | ||
297 | const char *sa = *(const char **)pa; | ||
298 | const char *sb = *(const char **)pb; | ||
299 | if (sa == sb) | ||
300 | return 0; | ||
301 | if (sa == NULL) | ||
302 | return -1; | ||
303 | if (sb == NULL) | ||
304 | return 1; | ||
305 | return strcmp(sa, sb); | ||
306 | } | ||
307 | #endif | ||
308 | |||
309 | EINA_VALUE_TYPE_DISPATCH_RETURN(type, compare, EINA_ERROR_VALUE_FAILED, | ||
310 | EINA_FALSE, pa, pb); | ||
311 | } | ||
312 | |||
313 | static inline Eina_Bool | ||
314 | eina_value_set(Eina_Value *value, ...) | ||
315 | { | ||
316 | va_list args; | ||
317 | Eina_Bool ret; | ||
318 | va_start(args, value); | ||
319 | ret = eina_value_vset(value, args); | ||
320 | va_end(args); | ||
321 | return ret; | ||
322 | } | ||
323 | |||
324 | static inline Eina_Bool | ||
325 | eina_value_get(const Eina_Value *value, ...) | ||
326 | { | ||
327 | va_list args; | ||
328 | Eina_Bool ret; | ||
329 | va_start(args, value); | ||
330 | ret = eina_value_vget(value, args); | ||
331 | va_end(args); | ||
332 | return ret; | ||
333 | } | ||
334 | |||
335 | static inline Eina_Bool | ||
336 | eina_value_vset(Eina_Value *value, va_list args) | ||
337 | { | ||
338 | const Eina_Value_Type *type; | ||
339 | void *mem; | ||
340 | |||
341 | EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE); | ||
342 | |||
343 | type = value->type; | ||
344 | mem = eina_value_memory_get(value); | ||
345 | eina_error_set(0); | ||
346 | #ifndef EINA_VALUE_NO_OPTIMIZE | ||
347 | if (type == EINA_VALUE_TYPE_UCHAR) | ||
348 | { | ||
349 | unsigned char *tmem = (unsigned char *) mem; | ||
350 | *tmem = va_arg(args, unsigned int); /* promoted by va_arg */ | ||
351 | return EINA_TRUE; | ||
352 | } | ||
353 | else if (type == EINA_VALUE_TYPE_USHORT) | ||
354 | { | ||
355 | unsigned short *tmem = (unsigned short *) mem; | ||
356 | *tmem = va_arg(args, unsigned int); /* promoted by va_arg */ | ||
357 | return EINA_TRUE; | ||
358 | } | ||
359 | else if (type == EINA_VALUE_TYPE_UINT) | ||
360 | { | ||
361 | unsigned int *tmem = (unsigned int *) mem; | ||
362 | *tmem = va_arg(args, unsigned int); | ||
363 | return EINA_TRUE; | ||
364 | } | ||
365 | else if (type == EINA_VALUE_TYPE_ULONG) | ||
366 | { | ||
367 | unsigned long *tmem = (unsigned long *) mem; | ||
368 | *tmem = va_arg(args, unsigned long); | ||
369 | return EINA_TRUE; | ||
370 | } | ||
371 | else if (type == EINA_VALUE_TYPE_UINT64) | ||
372 | { | ||
373 | uint64_t *tmem = (uint64_t *) mem; | ||
374 | *tmem = va_arg(args, uint64_t); | ||
375 | return EINA_TRUE; | ||
376 | } | ||
377 | else if (type == EINA_VALUE_TYPE_CHAR) | ||
378 | { | ||
379 | char *tmem = (char *) mem; | ||
380 | *tmem = va_arg(args, int); /* promoted by va_arg */ | ||
381 | return EINA_TRUE; | ||
382 | } | ||
383 | else if (type == EINA_VALUE_TYPE_SHORT) | ||
384 | { | ||
385 | short *tmem = (short *) mem; | ||
386 | *tmem = va_arg(args, int); /* promoted by va_arg */ | ||
387 | return EINA_TRUE; | ||
388 | } | ||
389 | else if (type == EINA_VALUE_TYPE_INT) | ||
390 | { | ||
391 | int *tmem = (int *) mem; | ||
392 | *tmem = va_arg(args, int); | ||
393 | return EINA_TRUE; | ||
394 | } | ||
395 | else if (type == EINA_VALUE_TYPE_LONG) | ||
396 | { | ||
397 | long *tmem = (long *) mem; | ||
398 | *tmem = va_arg(args, long); | ||
399 | return EINA_TRUE; | ||
400 | } | ||
401 | else if (type == EINA_VALUE_TYPE_INT64) | ||
402 | { | ||
403 | int64_t *tmem = (int64_t *) mem; | ||
404 | *tmem = va_arg(args, int64_t); | ||
405 | return EINA_TRUE; | ||
406 | } | ||
407 | else if (type == EINA_VALUE_TYPE_FLOAT) | ||
408 | { | ||
409 | float *tmem = (float *) mem; | ||
410 | *tmem = va_arg(args, double); /* promoted by va_arg */ | ||
411 | return EINA_TRUE; | ||
412 | } | ||
413 | else if (type == EINA_VALUE_TYPE_DOUBLE) | ||
414 | { | ||
415 | double *tmem = (double *) mem; | ||
416 | *tmem = va_arg(args, double); | ||
417 | return EINA_TRUE; | ||
418 | } | ||
419 | else if (type == EINA_VALUE_TYPE_STRINGSHARE) | ||
420 | { | ||
421 | const char *str = (const char *) va_arg(args, const char *); | ||
422 | return eina_stringshare_replace((const char **)&value->value.ptr, str); | ||
423 | } | ||
424 | else if (type == EINA_VALUE_TYPE_STRING) | ||
425 | { | ||
426 | const char *str = (const char *) va_arg(args, const char *); | ||
427 | free(value->value.ptr); | ||
428 | if (!str) | ||
429 | value->value.ptr = NULL; | ||
430 | else | ||
431 | { | ||
432 | value->value.ptr = strdup(str); | ||
433 | if (!value->value.ptr) | ||
434 | { | ||
435 | eina_error_set(EINA_ERROR_OUT_OF_MEMORY); | ||
436 | return EINA_FALSE; | ||
437 | } | ||
438 | } | ||
439 | return EINA_TRUE; | ||
440 | } | ||
441 | #endif | ||
442 | |||
443 | EINA_VALUE_TYPE_DISPATCH_RETURN(value, vset, EINA_ERROR_VALUE_FAILED, | ||
444 | EINA_FALSE, mem, args); | ||
445 | } | ||
446 | |||
447 | static inline Eina_Bool | ||
448 | eina_value_vget(const Eina_Value *value, va_list args) | ||
449 | { | ||
450 | const Eina_Value_Type *type; | ||
451 | const void *mem; | ||
452 | void *ptr; | ||
453 | |||
454 | EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE); | ||
455 | |||
456 | type = value->type; | ||
457 | mem = eina_value_memory_get(value); | ||
458 | ptr = va_arg(args, void *); | ||
459 | eina_error_set(0); | ||
460 | if (EINA_VALUE_TYPE_DEFAULT(type)) | ||
461 | { | ||
462 | memcpy(ptr, mem, type->value_size); | ||
463 | return EINA_TRUE; | ||
464 | } | ||
465 | |||
466 | EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, EINA_ERROR_VALUE_FAILED, | ||
467 | EINA_FALSE, mem, ptr); | ||
468 | } | ||
469 | |||
470 | static inline Eina_Bool | ||
471 | eina_value_pset(Eina_Value *value, const void *ptr) | ||
472 | { | ||
473 | const Eina_Value_Type *type; | ||
474 | void *mem; | ||
475 | |||
476 | EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE); | ||
477 | EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE); | ||
478 | |||
479 | type = value->type; | ||
480 | mem = eina_value_memory_get(value); | ||
481 | eina_error_set(0); | ||
482 | |||
483 | if (EINA_VALUE_TYPE_DEFAULT(type)) | ||
484 | { | ||
485 | if (type == EINA_VALUE_TYPE_STRINGSHARE) | ||
486 | { | ||
487 | const char * const *pstr = (const char * const *) ptr; | ||
488 | const char *str = *pstr; | ||
489 | |||
490 | return eina_stringshare_replace((const char **)&value->value.ptr, | ||
491 | str); | ||
492 | } | ||
493 | else if (type == EINA_VALUE_TYPE_STRING) | ||
494 | { | ||
495 | const char * const * pstr = (const char * const *) ptr; | ||
496 | const char *str = *pstr; | ||
497 | |||
498 | free(value->value.ptr); | ||
499 | if (!str) | ||
500 | value->value.ptr = NULL; | ||
501 | else | ||
502 | { | ||
503 | value->value.ptr = strdup(str); | ||
504 | if (!value->value.ptr) | ||
505 | { | ||
506 | eina_error_set(EINA_ERROR_OUT_OF_MEMORY); | ||
507 | return EINA_FALSE; | ||
508 | } | ||
509 | } | ||
510 | return EINA_TRUE; | ||
511 | } | ||
512 | else | ||
513 | memcpy(mem, ptr, type->value_size); | ||
514 | return EINA_TRUE; | ||
515 | } | ||
516 | |||
517 | EINA_VALUE_TYPE_DISPATCH_RETURN(value, pset, EINA_ERROR_VALUE_FAILED, | ||
518 | EINA_FALSE, mem, ptr); | ||
519 | } | ||
520 | |||
521 | static inline Eina_Bool | ||
522 | eina_value_pget(const Eina_Value *value, void *ptr) | ||
523 | { | ||
524 | const Eina_Value_Type *type; | ||
525 | const void *mem; | ||
526 | |||
527 | EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, EINA_FALSE); | ||
528 | EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE); | ||
529 | |||
530 | type = value->type; | ||
531 | mem = eina_value_memory_get(value); | ||
532 | eina_error_set(0); | ||
533 | if (EINA_VALUE_TYPE_DEFAULT(type)) | ||
534 | { | ||
535 | memcpy(ptr, mem, type->value_size); | ||
536 | return EINA_TRUE; | ||
537 | } | ||
538 | |||
539 | EINA_VALUE_TYPE_DISPATCH_RETURN(value, pget, EINA_ERROR_VALUE_FAILED, | ||
540 | EINA_FALSE, mem, ptr); | ||
541 | } | ||
542 | |||
543 | static inline const Eina_Value_Type * | ||
544 | eina_value_type_get(const Eina_Value *value) | ||
545 | { | ||
546 | EINA_VALUE_TYPE_CHECK_RETURN_VAL(value, NULL); | ||
547 | return value->type; | ||
548 | } | ||
549 | |||
550 | #define EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, retval) \ | ||
551 | EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ | ||
552 | EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_ARRAY, retval) | ||
553 | |||
554 | static inline Eina_Bool | ||
555 | eina_value_array_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int step) | ||
556 | { | ||
557 | Eina_Value_Array desc = { subtype, step, NULL }; | ||
558 | if (!eina_value_setup(value, EINA_VALUE_TYPE_ARRAY)) | ||
559 | return EINA_FALSE; | ||
560 | if (!eina_value_pset(value, &desc)) | ||
561 | { | ||
562 | eina_value_flush(value); | ||
563 | return EINA_FALSE; | ||
564 | } | ||
565 | return EINA_TRUE; | ||
566 | } | ||
567 | |||
568 | static inline unsigned int | ||
569 | eina_value_array_count(const Eina_Value *value) | ||
570 | { | ||
571 | Eina_Value_Array desc; | ||
572 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
573 | if (!eina_value_pget(value, &desc)) | ||
574 | return 0; | ||
575 | return eina_inarray_count(desc.array); | ||
576 | } | ||
577 | |||
578 | static inline Eina_Bool | ||
579 | eina_value_array_remove(Eina_Value *value, unsigned int position) | ||
580 | { | ||
581 | Eina_Value_Array desc; | ||
582 | void *mem; | ||
583 | |||
584 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
585 | if (!eina_value_pget(value, &desc)) | ||
586 | return EINA_FALSE; | ||
587 | |||
588 | mem = eina_inarray_nth(desc.array, position); | ||
589 | if (!mem) | ||
590 | return EINA_FALSE; | ||
591 | |||
592 | eina_value_type_flush(desc.subtype, mem); | ||
593 | return eina_inarray_remove_at(desc.array, position); | ||
594 | } | ||
595 | |||
596 | static inline Eina_Bool | ||
597 | eina_value_array_vset(Eina_Value *value, unsigned int position, va_list args) | ||
598 | { | ||
599 | Eina_Value_Array desc; | ||
600 | void *mem; | ||
601 | |||
602 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
603 | if (!eina_value_pget(value, &desc)) | ||
604 | return EINA_FALSE; | ||
605 | |||
606 | mem = eina_inarray_nth(desc.array, position); | ||
607 | if (!mem) | ||
608 | return EINA_FALSE; | ||
609 | |||
610 | eina_value_type_flush(desc.subtype, mem); | ||
611 | |||
612 | if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; | ||
613 | if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set; | ||
614 | return EINA_TRUE; | ||
615 | |||
616 | error_set: | ||
617 | eina_value_type_flush(desc.subtype, mem); | ||
618 | error_setup: | ||
619 | return EINA_FALSE; | ||
620 | } | ||
621 | |||
622 | static inline Eina_Bool | ||
623 | eina_value_array_vget(const Eina_Value *value, unsigned int position, va_list args) | ||
624 | { | ||
625 | Eina_Value_Array desc; | ||
626 | const void *mem; | ||
627 | void *ptr; | ||
628 | Eina_Bool ret; | ||
629 | |||
630 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
631 | if (!eina_value_pget(value, &desc)) | ||
632 | return EINA_FALSE; | ||
633 | |||
634 | mem = eina_inarray_nth(desc.array, position); | ||
635 | if (!mem) | ||
636 | return EINA_FALSE; | ||
637 | |||
638 | ptr = va_arg(args, void *); | ||
639 | ret = eina_value_type_pget(desc.subtype, mem, ptr); | ||
640 | return ret; | ||
641 | } | ||
642 | |||
643 | static inline Eina_Bool | ||
644 | eina_value_array_vinsert(Eina_Value *value, unsigned int position, va_list args) | ||
645 | { | ||
646 | Eina_Value_Array desc; | ||
647 | void *mem; | ||
648 | |||
649 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
650 | if (!eina_value_pget(value, &desc)) | ||
651 | return EINA_FALSE; | ||
652 | |||
653 | mem = eina_inarray_alloc_at(desc.array, position, 1); | ||
654 | if (!mem) | ||
655 | return EINA_FALSE; | ||
656 | |||
657 | if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; | ||
658 | if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set; | ||
659 | return EINA_TRUE; | ||
660 | |||
661 | error_set: | ||
662 | eina_value_type_flush(desc.subtype, mem); | ||
663 | error_setup: | ||
664 | eina_inarray_remove_at(desc.array, position); | ||
665 | return EINA_FALSE; | ||
666 | } | ||
667 | |||
668 | static inline Eina_Bool | ||
669 | eina_value_array_vappend(Eina_Value *value, va_list args) | ||
670 | { | ||
671 | Eina_Value_Array desc; | ||
672 | void *mem; | ||
673 | int position; | ||
674 | |||
675 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
676 | if (!eina_value_pget(value, &desc)) | ||
677 | return EINA_FALSE; | ||
678 | |||
679 | position = eina_inarray_count(desc.array); | ||
680 | mem = eina_inarray_alloc_at(desc.array, position, 1); | ||
681 | if (!mem) | ||
682 | return EINA_FALSE; | ||
683 | |||
684 | if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; | ||
685 | if (!eina_value_type_vset(desc.subtype, mem, args)) goto error_set; | ||
686 | return EINA_TRUE; | ||
687 | |||
688 | error_set: | ||
689 | eina_value_type_flush(desc.subtype, mem); | ||
690 | error_setup: | ||
691 | eina_inarray_remove_at(desc.array, position); | ||
692 | return EINA_FALSE; | ||
693 | } | ||
694 | |||
695 | static inline Eina_Bool | ||
696 | eina_value_array_set(Eina_Value *value, unsigned int position, ...) | ||
697 | { | ||
698 | va_list args; | ||
699 | Eina_Bool ret; | ||
700 | va_start(args, position); | ||
701 | ret = eina_value_array_vset(value, position, args); | ||
702 | va_end(args); | ||
703 | return ret; | ||
704 | } | ||
705 | |||
706 | static inline Eina_Bool | ||
707 | eina_value_array_get(const Eina_Value *value, unsigned int position, ...) | ||
708 | { | ||
709 | va_list args; | ||
710 | Eina_Bool ret; | ||
711 | va_start(args, position); | ||
712 | ret = eina_value_array_vget(value, position, args); | ||
713 | va_end(args); | ||
714 | return ret; | ||
715 | } | ||
716 | |||
717 | static inline Eina_Bool | ||
718 | eina_value_array_insert(Eina_Value *value, unsigned int position, ...) | ||
719 | { | ||
720 | va_list args; | ||
721 | Eina_Bool ret; | ||
722 | va_start(args, position); | ||
723 | ret = eina_value_array_vinsert(value, position, args); | ||
724 | va_end(args); | ||
725 | return ret; | ||
726 | } | ||
727 | |||
728 | static inline Eina_Bool eina_value_array_append(Eina_Value *value, ...) | ||
729 | { | ||
730 | va_list args; | ||
731 | Eina_Bool ret; | ||
732 | va_start(args, value); | ||
733 | ret = eina_value_array_vappend(value, args); | ||
734 | va_end(args); | ||
735 | return ret; | ||
736 | } | ||
737 | |||
738 | static inline Eina_Bool | ||
739 | eina_value_array_pset(Eina_Value *value, unsigned int position, const void *ptr) | ||
740 | { | ||
741 | Eina_Value_Array desc; | ||
742 | void *mem; | ||
743 | |||
744 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
745 | if (!eina_value_pget(value, &desc)) | ||
746 | return EINA_FALSE; | ||
747 | |||
748 | mem = eina_inarray_nth(desc.array, position); | ||
749 | if (!mem) | ||
750 | return EINA_FALSE; | ||
751 | |||
752 | eina_value_type_flush(desc.subtype, mem); | ||
753 | |||
754 | if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; | ||
755 | if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set; | ||
756 | return EINA_TRUE; | ||
757 | |||
758 | error_set: | ||
759 | eina_value_type_flush(desc.subtype, mem); | ||
760 | error_setup: | ||
761 | return EINA_FALSE; | ||
762 | } | ||
763 | |||
764 | static inline Eina_Bool | ||
765 | eina_value_array_pget(const Eina_Value *value, unsigned int position, void *ptr) | ||
766 | { | ||
767 | Eina_Value_Array desc; | ||
768 | const void *mem; | ||
769 | Eina_Bool ret; | ||
770 | |||
771 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
772 | if (!eina_value_pget(value, &desc)) | ||
773 | return EINA_FALSE; | ||
774 | |||
775 | mem = eina_inarray_nth(desc.array, position); | ||
776 | if (!mem) | ||
777 | return EINA_FALSE; | ||
778 | |||
779 | ret = eina_value_type_pget(desc.subtype, mem, ptr); | ||
780 | return ret; | ||
781 | } | ||
782 | |||
783 | static inline Eina_Bool | ||
784 | eina_value_array_pinsert(Eina_Value *value, unsigned int position, const void *ptr) | ||
785 | { | ||
786 | Eina_Value_Array desc; | ||
787 | void *mem; | ||
788 | |||
789 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
790 | if (!eina_value_pget(value, &desc)) | ||
791 | return EINA_FALSE; | ||
792 | |||
793 | mem = eina_inarray_alloc_at(desc.array, position, 1); | ||
794 | if (!mem) | ||
795 | return EINA_FALSE; | ||
796 | |||
797 | if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; | ||
798 | if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set; | ||
799 | return EINA_TRUE; | ||
800 | |||
801 | error_set: | ||
802 | eina_value_type_flush(desc.subtype, mem); | ||
803 | error_setup: | ||
804 | eina_inarray_remove_at(desc.array, position); | ||
805 | return EINA_FALSE; | ||
806 | } | ||
807 | |||
808 | static inline Eina_Bool | ||
809 | eina_value_array_pappend(Eina_Value *value, const void *ptr) | ||
810 | { | ||
811 | Eina_Value_Array desc; | ||
812 | void *mem; | ||
813 | int position; | ||
814 | |||
815 | EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(value, 0); | ||
816 | if (!eina_value_pget(value, &desc)) | ||
817 | return EINA_FALSE; | ||
818 | |||
819 | position = eina_inarray_count(desc.array); | ||
820 | mem = eina_inarray_alloc_at(desc.array, position, 1); | ||
821 | if (!mem) | ||
822 | return EINA_FALSE; | ||
823 | |||
824 | if (!eina_value_type_setup(desc.subtype, mem)) goto error_setup; | ||
825 | if (!eina_value_type_pset(desc.subtype, mem, ptr)) goto error_set; | ||
826 | return EINA_TRUE; | ||
827 | |||
828 | error_set: | ||
829 | eina_value_type_flush(desc.subtype, mem); | ||
830 | error_setup: | ||
831 | eina_inarray_remove_at(desc.array, position); | ||
832 | return EINA_FALSE; | ||
833 | } | ||
834 | |||
835 | #undef EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL | ||
836 | |||
837 | #define EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, retval) \ | ||
838 | EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ | ||
839 | EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_LIST, retval) | ||
840 | |||
841 | static inline void * | ||
842 | eina_value_list_node_memory_get(const Eina_Value_Type *type, const Eina_List *node) | ||
843 | { | ||
844 | if (node == NULL) return NULL; | ||
845 | if (type->value_size <= sizeof(void*)) | ||
846 | return (void *)&(node->data); | ||
847 | return node->data; | ||
848 | } | ||
849 | |||
850 | static inline void * | ||
851 | eina_value_list_node_memory_setup(const Eina_Value_Type *type, Eina_List *node) | ||
852 | { | ||
853 | if (type->value_size <= sizeof(void*)) | ||
854 | return (void *)&(node->data); | ||
855 | node->data = malloc(type->value_size); | ||
856 | return node->data; | ||
857 | } | ||
858 | |||
859 | static inline void | ||
860 | eina_value_list_node_memory_flush(const Eina_Value_Type *type, Eina_List *node) | ||
861 | { | ||
862 | if (type->value_size <= sizeof(void*)) | ||
863 | return; | ||
864 | free(node->data); | ||
865 | } | ||
866 | |||
867 | static inline Eina_Bool | ||
868 | eina_value_list_setup(Eina_Value *value, const Eina_Value_Type *subtype) | ||
869 | { | ||
870 | Eina_Value_List desc = { subtype, NULL }; | ||
871 | if (!eina_value_setup(value, EINA_VALUE_TYPE_LIST)) | ||
872 | return EINA_FALSE; | ||
873 | if (!eina_value_pset(value, &desc)) | ||
874 | { | ||
875 | eina_value_flush(value); | ||
876 | return EINA_FALSE; | ||
877 | } | ||
878 | return EINA_TRUE; | ||
879 | } | ||
880 | |||
881 | static inline unsigned int | ||
882 | eina_value_list_count(const Eina_Value *value) | ||
883 | { | ||
884 | Eina_Value_List *desc; | ||
885 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
886 | desc = (Eina_Value_List *)eina_value_memory_get(value); | ||
887 | if (!desc) | ||
888 | return 0; | ||
889 | return eina_list_count(desc->list); | ||
890 | } | ||
891 | |||
892 | static inline Eina_Bool | ||
893 | eina_value_list_remove(Eina_Value *value, unsigned int position) | ||
894 | { | ||
895 | Eina_Value_List *desc; | ||
896 | Eina_List *node; | ||
897 | void *mem; | ||
898 | |||
899 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
900 | desc = (Eina_Value_List *)eina_value_memory_get(value); | ||
901 | if (!desc) | ||
902 | return EINA_FALSE; | ||
903 | |||
904 | node = eina_list_nth_list(desc->list, position); | ||
905 | mem = eina_value_list_node_memory_get(desc->subtype, node); | ||
906 | if (!mem) | ||
907 | return EINA_FALSE; | ||
908 | |||
909 | eina_value_type_flush(desc->subtype, mem); | ||
910 | eina_value_list_node_memory_flush(desc->subtype, node); | ||
911 | desc->list = eina_list_remove_list(desc->list, node); | ||
912 | return EINA_TRUE; | ||
913 | } | ||
914 | |||
915 | static inline Eina_Bool | ||
916 | eina_value_list_vset(Eina_Value *value, unsigned int position, va_list args) | ||
917 | { | ||
918 | Eina_Value_List *desc; | ||
919 | Eina_List *node; | ||
920 | void *mem; | ||
921 | |||
922 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
923 | desc = (Eina_Value_List *)eina_value_memory_get(value); | ||
924 | if (!desc) | ||
925 | return EINA_FALSE; | ||
926 | |||
927 | node = eina_list_nth_list(desc->list, position); | ||
928 | mem = eina_value_list_node_memory_get(desc->subtype, node); | ||
929 | if (!mem) | ||
930 | return EINA_FALSE; | ||
931 | |||
932 | eina_value_type_flush(desc->subtype, mem); | ||
933 | |||
934 | if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; | ||
935 | if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set; | ||
936 | return EINA_TRUE; | ||
937 | |||
938 | error_set: | ||
939 | eina_value_type_flush(desc->subtype, mem); | ||
940 | error_setup: | ||
941 | return EINA_FALSE; | ||
942 | } | ||
943 | |||
944 | static inline Eina_Bool | ||
945 | eina_value_list_vget(const Eina_Value *value, unsigned int position, va_list args) | ||
946 | { | ||
947 | const Eina_Value_List *desc; | ||
948 | const Eina_List *node; | ||
949 | const void *mem; | ||
950 | void *ptr; | ||
951 | Eina_Bool ret; | ||
952 | |||
953 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
954 | desc = (const Eina_Value_List *)eina_value_memory_get(value); | ||
955 | if (!desc) | ||
956 | return EINA_FALSE; | ||
957 | |||
958 | node = eina_list_nth_list(desc->list, position); | ||
959 | mem = eina_value_list_node_memory_get(desc->subtype, node); | ||
960 | if (!mem) | ||
961 | return EINA_FALSE; | ||
962 | |||
963 | ptr = va_arg(args, void *); | ||
964 | ret = eina_value_type_pget(desc->subtype, mem, ptr); | ||
965 | return ret; | ||
966 | } | ||
967 | |||
968 | static inline Eina_Bool | ||
969 | eina_value_list_vinsert(Eina_Value *value, unsigned int position, va_list args) | ||
970 | { | ||
971 | Eina_Value_List *desc; | ||
972 | Eina_List *node; | ||
973 | void *mem; | ||
974 | |||
975 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
976 | desc = (Eina_Value_List *)eina_value_memory_get(value); | ||
977 | if (!desc) | ||
978 | return EINA_FALSE; | ||
979 | |||
980 | if (!desc->list) | ||
981 | node = desc->list = eina_list_append(NULL, (void*)1L); | ||
982 | else if (position == 0) | ||
983 | node = desc->list = eina_list_prepend(desc->list, (void*)1L); | ||
984 | else | ||
985 | { | ||
986 | Eina_List *rel = eina_list_nth_list(desc->list, position - 1); | ||
987 | desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel); | ||
988 | node = rel->next; | ||
989 | } | ||
990 | EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE); | ||
991 | EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE); | ||
992 | |||
993 | mem = eina_value_list_node_memory_setup(desc->subtype, node); | ||
994 | if (!mem) | ||
995 | { | ||
996 | desc->list = eina_list_remove_list(desc->list, node); | ||
997 | return EINA_FALSE; | ||
998 | } | ||
999 | |||
1000 | if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; | ||
1001 | if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set; | ||
1002 | return EINA_TRUE; | ||
1003 | |||
1004 | error_set: | ||
1005 | eina_value_type_flush(desc->subtype, mem); | ||
1006 | error_setup: | ||
1007 | eina_value_list_node_memory_flush(desc->subtype, node); | ||
1008 | desc->list = eina_list_remove_list(desc->list, node); | ||
1009 | return EINA_FALSE; | ||
1010 | } | ||
1011 | |||
1012 | static inline Eina_Bool | ||
1013 | eina_value_list_vappend(Eina_Value *value, va_list args) | ||
1014 | { | ||
1015 | Eina_Value_List *desc; | ||
1016 | Eina_List *node; | ||
1017 | void *mem; | ||
1018 | |||
1019 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
1020 | desc = (Eina_Value_List *)eina_value_memory_get(value); | ||
1021 | if (!desc) | ||
1022 | return EINA_FALSE; | ||
1023 | |||
1024 | desc->list = eina_list_append(desc->list, (void*)1L); | ||
1025 | node = eina_list_last(desc->list); | ||
1026 | EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE); | ||
1027 | EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE); | ||
1028 | |||
1029 | mem = eina_value_list_node_memory_setup(desc->subtype, node); | ||
1030 | if (!mem) | ||
1031 | { | ||
1032 | desc->list = eina_list_remove_list(desc->list, node); | ||
1033 | return EINA_FALSE; | ||
1034 | } | ||
1035 | |||
1036 | if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; | ||
1037 | if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set; | ||
1038 | return EINA_TRUE; | ||
1039 | |||
1040 | error_set: | ||
1041 | eina_value_type_flush(desc->subtype, mem); | ||
1042 | error_setup: | ||
1043 | eina_value_list_node_memory_flush(desc->subtype, node); | ||
1044 | desc->list = eina_list_remove_list(desc->list, node); | ||
1045 | return EINA_FALSE; | ||
1046 | } | ||
1047 | |||
1048 | static inline Eina_Bool | ||
1049 | eina_value_list_set(Eina_Value *value, unsigned int position, ...) | ||
1050 | { | ||
1051 | va_list args; | ||
1052 | Eina_Bool ret; | ||
1053 | va_start(args, position); | ||
1054 | ret = eina_value_list_vset(value, position, args); | ||
1055 | va_end(args); | ||
1056 | return ret; | ||
1057 | } | ||
1058 | |||
1059 | static inline Eina_Bool | ||
1060 | eina_value_list_get(const Eina_Value *value, unsigned int position, ...) | ||
1061 | { | ||
1062 | va_list args; | ||
1063 | Eina_Bool ret; | ||
1064 | va_start(args, position); | ||
1065 | ret = eina_value_list_vget(value, position, args); | ||
1066 | va_end(args); | ||
1067 | return ret; | ||
1068 | } | ||
1069 | |||
1070 | static inline Eina_Bool | ||
1071 | eina_value_list_insert(Eina_Value *value, unsigned int position, ...) | ||
1072 | { | ||
1073 | va_list args; | ||
1074 | Eina_Bool ret; | ||
1075 | va_start(args, position); | ||
1076 | ret = eina_value_list_vinsert(value, position, args); | ||
1077 | va_end(args); | ||
1078 | return ret; | ||
1079 | } | ||
1080 | |||
1081 | static inline Eina_Bool eina_value_list_append(Eina_Value *value, ...) | ||
1082 | { | ||
1083 | va_list args; | ||
1084 | Eina_Bool ret; | ||
1085 | va_start(args, value); | ||
1086 | ret = eina_value_list_vappend(value, args); | ||
1087 | va_end(args); | ||
1088 | return ret; | ||
1089 | } | ||
1090 | |||
1091 | static inline Eina_Bool | ||
1092 | eina_value_list_pset(Eina_Value *value, unsigned int position, const void *ptr) | ||
1093 | { | ||
1094 | Eina_Value_List *desc; | ||
1095 | Eina_List *node; | ||
1096 | void *mem; | ||
1097 | |||
1098 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
1099 | desc = (Eina_Value_List *)eina_value_memory_get(value); | ||
1100 | if (!desc) | ||
1101 | return EINA_FALSE; | ||
1102 | |||
1103 | node = eina_list_nth_list(desc->list, position); | ||
1104 | mem = eina_value_list_node_memory_get(desc->subtype, node); | ||
1105 | if (!mem) | ||
1106 | return EINA_FALSE; | ||
1107 | |||
1108 | eina_value_type_flush(desc->subtype, mem); | ||
1109 | |||
1110 | if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; | ||
1111 | if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set; | ||
1112 | return EINA_TRUE; | ||
1113 | |||
1114 | error_set: | ||
1115 | eina_value_type_flush(desc->subtype, mem); | ||
1116 | error_setup: | ||
1117 | return EINA_FALSE; | ||
1118 | } | ||
1119 | |||
1120 | static inline Eina_Bool | ||
1121 | eina_value_list_pget(const Eina_Value *value, unsigned int position, void *ptr) | ||
1122 | { | ||
1123 | const Eina_Value_List *desc; | ||
1124 | const Eina_List *node; | ||
1125 | const void *mem; | ||
1126 | Eina_Bool ret; | ||
1127 | |||
1128 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
1129 | desc = (const Eina_Value_List *)eina_value_memory_get(value); | ||
1130 | if (!desc) | ||
1131 | return EINA_FALSE; | ||
1132 | |||
1133 | node = eina_list_nth_list(desc->list, position); | ||
1134 | mem = eina_value_list_node_memory_get(desc->subtype, node); | ||
1135 | if (!mem) | ||
1136 | return EINA_FALSE; | ||
1137 | |||
1138 | ret = eina_value_type_pget(desc->subtype, mem, ptr); | ||
1139 | return ret; | ||
1140 | } | ||
1141 | |||
1142 | static inline Eina_Bool | ||
1143 | eina_value_list_pinsert(Eina_Value *value, unsigned int position, const void *ptr) | ||
1144 | { | ||
1145 | Eina_Value_List *desc; | ||
1146 | Eina_List *node; | ||
1147 | void *mem; | ||
1148 | |||
1149 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
1150 | desc = (Eina_Value_List *)eina_value_memory_get(value); | ||
1151 | if (!desc) | ||
1152 | return EINA_FALSE; | ||
1153 | |||
1154 | if (!desc->list) | ||
1155 | node = desc->list = eina_list_append(NULL, (void*)1L); | ||
1156 | else if (position == 0) | ||
1157 | node = desc->list = eina_list_prepend(desc->list, (void*)1L); | ||
1158 | else | ||
1159 | { | ||
1160 | Eina_List *rel = eina_list_nth_list(desc->list, position - 1); | ||
1161 | desc->list = eina_list_append_relative_list(desc->list, (void*)1L, rel); | ||
1162 | node = rel->next; | ||
1163 | } | ||
1164 | EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE); | ||
1165 | EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE); | ||
1166 | |||
1167 | mem = eina_value_list_node_memory_setup(desc->subtype, node); | ||
1168 | if (!mem) | ||
1169 | { | ||
1170 | desc->list = eina_list_remove_list(desc->list, node); | ||
1171 | return EINA_FALSE; | ||
1172 | } | ||
1173 | |||
1174 | if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; | ||
1175 | if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set; | ||
1176 | return EINA_TRUE; | ||
1177 | |||
1178 | error_set: | ||
1179 | eina_value_type_flush(desc->subtype, mem); | ||
1180 | error_setup: | ||
1181 | eina_value_list_node_memory_flush(desc->subtype, node); | ||
1182 | desc->list = eina_list_remove_list(desc->list, node); | ||
1183 | return EINA_FALSE; | ||
1184 | } | ||
1185 | |||
1186 | static inline Eina_Bool | ||
1187 | eina_value_list_pappend(Eina_Value *value, const void *ptr) | ||
1188 | { | ||
1189 | Eina_Value_List *desc; | ||
1190 | Eina_List *node; | ||
1191 | void *mem; | ||
1192 | |||
1193 | EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, 0); | ||
1194 | desc = (Eina_Value_List *)eina_value_memory_get(value); | ||
1195 | if (!desc) | ||
1196 | return EINA_FALSE; | ||
1197 | |||
1198 | desc->list = eina_list_append(desc->list, (void*)1L); | ||
1199 | node = eina_list_last(desc->list); | ||
1200 | EINA_SAFETY_ON_NULL_RETURN_VAL(node, EINA_FALSE); | ||
1201 | EINA_SAFETY_ON_FALSE_RETURN_VAL(node->data == (void*)1L, EINA_FALSE); | ||
1202 | |||
1203 | mem = eina_value_list_node_memory_setup(desc->subtype, node); | ||
1204 | if (!mem) | ||
1205 | { | ||
1206 | desc->list = eina_list_remove_list(desc->list, node); | ||
1207 | return EINA_FALSE; | ||
1208 | } | ||
1209 | |||
1210 | if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; | ||
1211 | if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set; | ||
1212 | return EINA_TRUE; | ||
1213 | |||
1214 | error_set: | ||
1215 | eina_value_type_flush(desc->subtype, mem); | ||
1216 | error_setup: | ||
1217 | eina_value_list_node_memory_flush(desc->subtype, node); | ||
1218 | desc->list = eina_list_remove_list(desc->list, node); | ||
1219 | return EINA_FALSE; | ||
1220 | } | ||
1221 | #undef EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL | ||
1222 | |||
1223 | #define EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, retval) \ | ||
1224 | EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ | ||
1225 | EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_HASH, retval) | ||
1226 | |||
1227 | static inline Eina_Bool | ||
1228 | eina_value_hash_setup(Eina_Value *value, const Eina_Value_Type *subtype, unsigned int buckets_power_size) | ||
1229 | { | ||
1230 | Eina_Value_Hash desc = { subtype, buckets_power_size, NULL }; | ||
1231 | if (!eina_value_setup(value, EINA_VALUE_TYPE_HASH)) | ||
1232 | return EINA_FALSE; | ||
1233 | if (!eina_value_pset(value, &desc)) | ||
1234 | { | ||
1235 | eina_value_flush(value); | ||
1236 | return EINA_FALSE; | ||
1237 | } | ||
1238 | return EINA_TRUE; | ||
1239 | } | ||
1240 | |||
1241 | static inline unsigned int | ||
1242 | eina_value_hash_population(const Eina_Value *value) | ||
1243 | { | ||
1244 | Eina_Value_Hash *desc; | ||
1245 | EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0); | ||
1246 | desc = (Eina_Value_Hash *)eina_value_memory_get(value); | ||
1247 | if (!desc) | ||
1248 | return 0; | ||
1249 | return eina_hash_population(desc->hash); | ||
1250 | } | ||
1251 | |||
1252 | static inline Eina_Bool | ||
1253 | eina_value_hash_del(Eina_Value *value, const char *key) | ||
1254 | { | ||
1255 | Eina_Value_Hash *desc; | ||
1256 | void *mem; | ||
1257 | |||
1258 | EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE); | ||
1259 | EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); | ||
1260 | desc = (Eina_Value_Hash *)eina_value_memory_get(value); | ||
1261 | if (!desc) | ||
1262 | return EINA_FALSE; | ||
1263 | |||
1264 | mem = eina_hash_find(desc->hash, key); | ||
1265 | if (!mem) | ||
1266 | return EINA_FALSE; | ||
1267 | |||
1268 | eina_value_type_flush(desc->subtype, mem); | ||
1269 | free(mem); | ||
1270 | eina_hash_del_by_key(desc->hash, key); | ||
1271 | return EINA_TRUE; | ||
1272 | } | ||
1273 | |||
1274 | static inline Eina_Bool | ||
1275 | eina_value_hash_vset(Eina_Value *value, const char *key, va_list args) | ||
1276 | { | ||
1277 | Eina_Value_Hash *desc; | ||
1278 | void *mem; | ||
1279 | |||
1280 | EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE); | ||
1281 | EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); | ||
1282 | desc = (Eina_Value_Hash *)eina_value_memory_get(value); | ||
1283 | if (!desc) | ||
1284 | return EINA_FALSE; | ||
1285 | |||
1286 | mem = eina_hash_find(desc->hash, key); | ||
1287 | if (mem) | ||
1288 | eina_value_type_flush(desc->subtype, mem); | ||
1289 | else | ||
1290 | { | ||
1291 | mem = malloc(desc->subtype->value_size); | ||
1292 | if (!mem) | ||
1293 | { | ||
1294 | eina_error_set(EINA_ERROR_OUT_OF_MEMORY); | ||
1295 | return EINA_FALSE; | ||
1296 | } | ||
1297 | if (!eina_hash_add(desc->hash, key, mem)) | ||
1298 | { | ||
1299 | free(mem); | ||
1300 | return EINA_FALSE; | ||
1301 | } | ||
1302 | } | ||
1303 | |||
1304 | if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; | ||
1305 | if (!eina_value_type_vset(desc->subtype, mem, args)) goto error_set; | ||
1306 | return EINA_TRUE; | ||
1307 | |||
1308 | error_set: | ||
1309 | eina_value_type_flush(desc->subtype, mem); | ||
1310 | error_setup: | ||
1311 | eina_hash_del_by_key(desc->hash, key); | ||
1312 | free(mem); | ||
1313 | return EINA_FALSE; | ||
1314 | } | ||
1315 | |||
1316 | static inline Eina_Bool | ||
1317 | eina_value_hash_vget(const Eina_Value *value, const char *key, va_list args) | ||
1318 | { | ||
1319 | const Eina_Value_Hash *desc; | ||
1320 | const void *mem; | ||
1321 | void *ptr; | ||
1322 | Eina_Bool ret; | ||
1323 | |||
1324 | EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, EINA_FALSE); | ||
1325 | EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); | ||
1326 | desc = (const Eina_Value_Hash *)eina_value_memory_get(value); | ||
1327 | if (!desc) | ||
1328 | return EINA_FALSE; | ||
1329 | |||
1330 | mem = eina_hash_find(desc->hash, key); | ||
1331 | if (!mem) | ||
1332 | return EINA_FALSE; | ||
1333 | |||
1334 | ptr = va_arg(args, void *); | ||
1335 | ret = eina_value_type_pget(desc->subtype, mem, ptr); | ||
1336 | return ret; | ||
1337 | } | ||
1338 | |||
1339 | static inline Eina_Bool | ||
1340 | eina_value_hash_set(Eina_Value *value, const char *key, ...) | ||
1341 | { | ||
1342 | va_list args; | ||
1343 | Eina_Bool ret; | ||
1344 | va_start(args, key); | ||
1345 | ret = eina_value_hash_vset(value, key, args); | ||
1346 | va_end(args); | ||
1347 | return ret; | ||
1348 | } | ||
1349 | |||
1350 | static inline Eina_Bool | ||
1351 | eina_value_hash_get(const Eina_Value *value, const char *key, ...) | ||
1352 | { | ||
1353 | va_list args; | ||
1354 | Eina_Bool ret; | ||
1355 | va_start(args, key); | ||
1356 | ret = eina_value_hash_vget(value, key, args); | ||
1357 | va_end(args); | ||
1358 | return ret; | ||
1359 | } | ||
1360 | |||
1361 | static inline Eina_Bool | ||
1362 | eina_value_hash_pset(Eina_Value *value, const char *key, const void *ptr) | ||
1363 | { | ||
1364 | Eina_Value_Hash *desc; | ||
1365 | void *mem; | ||
1366 | |||
1367 | EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0); | ||
1368 | EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); | ||
1369 | desc = (Eina_Value_Hash *)eina_value_memory_get(value); | ||
1370 | if (!desc) | ||
1371 | return EINA_FALSE; | ||
1372 | |||
1373 | mem = eina_hash_find(desc->hash, key); | ||
1374 | if (mem) | ||
1375 | eina_value_type_flush(desc->subtype, mem); | ||
1376 | else | ||
1377 | { | ||
1378 | mem = malloc(desc->subtype->value_size); | ||
1379 | if (!mem) | ||
1380 | { | ||
1381 | eina_error_set(EINA_ERROR_OUT_OF_MEMORY); | ||
1382 | return EINA_FALSE; | ||
1383 | } | ||
1384 | if (!eina_hash_add(desc->hash, key, mem)) | ||
1385 | { | ||
1386 | free(mem); | ||
1387 | return EINA_FALSE; | ||
1388 | } | ||
1389 | } | ||
1390 | |||
1391 | if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; | ||
1392 | if (!eina_value_type_pset(desc->subtype, mem, ptr)) goto error_set; | ||
1393 | return EINA_TRUE; | ||
1394 | |||
1395 | error_set: | ||
1396 | eina_value_type_flush(desc->subtype, mem); | ||
1397 | error_setup: | ||
1398 | eina_hash_del_by_key(desc->hash, key); | ||
1399 | free(mem); | ||
1400 | return EINA_FALSE; | ||
1401 | } | ||
1402 | |||
1403 | static inline Eina_Bool | ||
1404 | eina_value_hash_pget(const Eina_Value *value, const char *key, void *ptr) | ||
1405 | { | ||
1406 | const Eina_Value_Hash *desc; | ||
1407 | const void *mem; | ||
1408 | Eina_Bool ret; | ||
1409 | |||
1410 | EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL(value, 0); | ||
1411 | EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); | ||
1412 | desc = (const Eina_Value_Hash *)eina_value_memory_get(value); | ||
1413 | if (!desc) | ||
1414 | return EINA_FALSE; | ||
1415 | |||
1416 | mem = eina_hash_find(desc->hash, key); | ||
1417 | if (!mem) | ||
1418 | return EINA_FALSE; | ||
1419 | |||
1420 | ret = eina_value_type_pget(desc->subtype, mem, ptr); | ||
1421 | return ret; | ||
1422 | } | ||
1423 | #undef EINA_VALUE_TYPE_HASH_CHECK_RETURN_VAL | ||
1424 | |||
1425 | #define EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, retval) \ | ||
1426 | EINA_SAFETY_ON_NULL_RETURN_VAL(value, retval); \ | ||
1427 | EINA_SAFETY_ON_FALSE_RETURN_VAL(value->type == EINA_VALUE_TYPE_STRUCT, retval) | ||
1428 | |||
1429 | /** | ||
1430 | * @brief Find member of struct | ||
1431 | * @since 1.2 | ||
1432 | * @internal | ||
1433 | */ | ||
1434 | EAPI const Eina_Value_Struct_Member *eina_value_struct_member_find(const Eina_Value_Struct *st, const char *name) EINA_ARG_NONNULL(1, 2) EINA_WARN_UNUSED_RESULT; | ||
1435 | |||
1436 | static inline Eina_Bool | ||
1437 | eina_value_struct_setup(Eina_Value *value, const Eina_Value_Struct_Desc *sdesc) | ||
1438 | { | ||
1439 | Eina_Value_Struct desc = {sdesc, NULL}; | ||
1440 | if (!eina_value_setup(value, EINA_VALUE_TYPE_STRUCT)) | ||
1441 | return EINA_FALSE; | ||
1442 | if (!eina_value_pset(value, &desc)) | ||
1443 | { | ||
1444 | eina_value_flush(value); | ||
1445 | return EINA_FALSE; | ||
1446 | } | ||
1447 | return EINA_TRUE; | ||
1448 | } | ||
1449 | |||
1450 | static inline void * | ||
1451 | eina_value_struct_member_memory_get(const Eina_Value_Struct *st, const Eina_Value_Struct_Member *member) | ||
1452 | { | ||
1453 | unsigned char *base = (unsigned char *)st->memory; | ||
1454 | if (!base) return NULL; | ||
1455 | return base + member->offset; | ||
1456 | } | ||
1457 | |||
1458 | static inline Eina_Bool | ||
1459 | eina_value_struct_vset(Eina_Value *value, const char *name, va_list args) | ||
1460 | { | ||
1461 | const Eina_Value_Struct_Member *member; | ||
1462 | Eina_Value_Struct *st; | ||
1463 | void *mem; | ||
1464 | |||
1465 | EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE); | ||
1466 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); | ||
1467 | st = (Eina_Value_Struct *)eina_value_memory_get(value); | ||
1468 | if (!st) | ||
1469 | return EINA_FALSE; | ||
1470 | member = eina_value_struct_member_find(st, name); | ||
1471 | if (!member) | ||
1472 | return EINA_FALSE; | ||
1473 | mem = eina_value_struct_member_memory_get(st, member); | ||
1474 | if (!mem) | ||
1475 | return EINA_FALSE; | ||
1476 | |||
1477 | eina_value_type_flush(member->type, mem); | ||
1478 | if (!eina_value_type_setup(member->type, mem)) goto error_setup; | ||
1479 | if (!eina_value_type_vset(member->type, mem, args)) goto error_set; | ||
1480 | return EINA_TRUE; | ||
1481 | |||
1482 | error_set: | ||
1483 | eina_value_type_flush(member->type, mem); | ||
1484 | error_setup: | ||
1485 | return EINA_FALSE; | ||
1486 | } | ||
1487 | |||
1488 | static inline Eina_Bool | ||
1489 | eina_value_struct_vget(const Eina_Value *value, const char *name, va_list args) | ||
1490 | { | ||
1491 | const Eina_Value_Struct_Member *member; | ||
1492 | const Eina_Value_Struct *st; | ||
1493 | const void *mem; | ||
1494 | void *ptr; | ||
1495 | Eina_Bool ret; | ||
1496 | |||
1497 | EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE); | ||
1498 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); | ||
1499 | st = (const Eina_Value_Struct *)eina_value_memory_get(value); | ||
1500 | if (!st) | ||
1501 | return EINA_FALSE; | ||
1502 | member = eina_value_struct_member_find(st, name); | ||
1503 | if (!member) | ||
1504 | return EINA_FALSE; | ||
1505 | mem = eina_value_struct_member_memory_get(st, member); | ||
1506 | if (!mem) | ||
1507 | return EINA_FALSE; | ||
1508 | |||
1509 | ptr = va_arg(args, void *); | ||
1510 | ret = eina_value_type_pget(member->type, mem, ptr); | ||
1511 | return ret; | ||
1512 | } | ||
1513 | |||
1514 | static inline Eina_Bool | ||
1515 | eina_value_struct_set(Eina_Value *value, const char *name, ...) | ||
1516 | { | ||
1517 | va_list args; | ||
1518 | Eina_Bool ret; | ||
1519 | va_start(args, name); | ||
1520 | ret = eina_value_struct_vset(value, name, args); | ||
1521 | va_end(args); | ||
1522 | return ret; | ||
1523 | } | ||
1524 | |||
1525 | static inline Eina_Bool | ||
1526 | eina_value_struct_get(const Eina_Value *value, const char *name, ...) | ||
1527 | { | ||
1528 | va_list args; | ||
1529 | Eina_Bool ret; | ||
1530 | va_start(args, name); | ||
1531 | ret = eina_value_struct_vget(value, name, args); | ||
1532 | va_end(args); | ||
1533 | return ret; | ||
1534 | } | ||
1535 | |||
1536 | static inline Eina_Bool | ||
1537 | eina_value_struct_pset(Eina_Value *value, const char *name, const void *ptr) | ||
1538 | { | ||
1539 | const Eina_Value_Struct_Member *member; | ||
1540 | Eina_Value_Struct *st; | ||
1541 | void *mem; | ||
1542 | |||
1543 | EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, 0); | ||
1544 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); | ||
1545 | st = (Eina_Value_Struct *)eina_value_memory_get(value); | ||
1546 | if (!st) | ||
1547 | return EINA_FALSE; | ||
1548 | member = eina_value_struct_member_find(st, name); | ||
1549 | if (!member) | ||
1550 | return EINA_FALSE; | ||
1551 | mem = eina_value_struct_member_memory_get(st, member); | ||
1552 | if (!mem) | ||
1553 | return EINA_FALSE; | ||
1554 | |||
1555 | eina_value_type_flush(member->type, mem); | ||
1556 | if (!eina_value_type_setup(member->type, mem)) goto error_setup; | ||
1557 | if (!eina_value_type_pset(member->type, mem, ptr)) goto error_set; | ||
1558 | return EINA_TRUE; | ||
1559 | |||
1560 | error_set: | ||
1561 | eina_value_type_flush(member->type, mem); | ||
1562 | error_setup: | ||
1563 | return EINA_FALSE; | ||
1564 | } | ||
1565 | |||
1566 | static inline Eina_Bool | ||
1567 | eina_value_struct_pget(const Eina_Value *value, const char *name, void *ptr) | ||
1568 | { | ||
1569 | const Eina_Value_Struct_Member *member; | ||
1570 | const Eina_Value_Struct *st; | ||
1571 | const void *mem; | ||
1572 | Eina_Bool ret; | ||
1573 | |||
1574 | EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, 0); | ||
1575 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); | ||
1576 | st = (const Eina_Value_Struct *)eina_value_memory_get(value); | ||
1577 | if (!st) | ||
1578 | return EINA_FALSE; | ||
1579 | member = eina_value_struct_member_find(st, name); | ||
1580 | if (!member) | ||
1581 | return EINA_FALSE; | ||
1582 | mem = eina_value_struct_member_memory_get(st, member); | ||
1583 | if (!mem) | ||
1584 | return EINA_FALSE; | ||
1585 | |||
1586 | ret = eina_value_type_pget(member->type, mem, ptr); | ||
1587 | return ret; | ||
1588 | } | ||
1589 | #undef EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL | ||
1590 | |||
1591 | |||
1592 | static inline Eina_Bool | ||
1593 | eina_value_type_setup(const Eina_Value_Type *type, void *mem) | ||
1594 | { | ||
1595 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
1596 | if (!type->setup) | ||
1597 | { | ||
1598 | eina_error_set(EINA_ERROR_VALUE_FAILED); | ||
1599 | return EINA_FALSE; | ||
1600 | } | ||
1601 | return type->setup(type, mem); | ||
1602 | } | ||
1603 | |||
1604 | static inline Eina_Bool | ||
1605 | eina_value_type_flush(const Eina_Value_Type *type, void *mem) | ||
1606 | { | ||
1607 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
1608 | if (!type->flush) | ||
1609 | { | ||
1610 | eina_error_set(EINA_ERROR_VALUE_FAILED); | ||
1611 | return EINA_FALSE; | ||
1612 | } | ||
1613 | return type->flush(type, mem); | ||
1614 | } | ||
1615 | |||
1616 | static inline Eina_Bool | ||
1617 | eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst) | ||
1618 | { | ||
1619 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
1620 | if (!type->copy) | ||
1621 | { | ||
1622 | eina_error_set(EINA_ERROR_VALUE_FAILED); | ||
1623 | return EINA_FALSE; | ||
1624 | } | ||
1625 | return type->copy(type, src, dst); | ||
1626 | } | ||
1627 | |||
1628 | static inline int | ||
1629 | eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b) | ||
1630 | { | ||
1631 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
1632 | if (!type->compare) | ||
1633 | { | ||
1634 | eina_error_set(EINA_ERROR_VALUE_FAILED); | ||
1635 | return EINA_FALSE; | ||
1636 | } | ||
1637 | return type->compare(type, a, b); | ||
1638 | } | ||
1639 | |||
1640 | static inline Eina_Bool | ||
1641 | eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem) | ||
1642 | { | ||
1643 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
1644 | if (!type->convert_to) | ||
1645 | { | ||
1646 | eina_error_set(EINA_ERROR_VALUE_FAILED); | ||
1647 | return EINA_FALSE; | ||
1648 | } | ||
1649 | return type->convert_to(type, convert, type_mem, convert_mem); | ||
1650 | } | ||
1651 | |||
1652 | static inline Eina_Bool | ||
1653 | eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem) | ||
1654 | { | ||
1655 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
1656 | if (!type->convert_from) | ||
1657 | { | ||
1658 | eina_error_set(EINA_ERROR_VALUE_FAILED); | ||
1659 | return EINA_FALSE; | ||
1660 | } | ||
1661 | return type->convert_from(type, convert, type_mem, convert_mem); | ||
1662 | } | ||
1663 | |||
1664 | static inline Eina_Bool | ||
1665 | eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args) | ||
1666 | { | ||
1667 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
1668 | if (!type->vset) | ||
1669 | { | ||
1670 | eina_error_set(EINA_ERROR_VALUE_FAILED); | ||
1671 | return EINA_FALSE; | ||
1672 | } | ||
1673 | return type->vset(type, mem, args); | ||
1674 | } | ||
1675 | |||
1676 | static inline Eina_Bool | ||
1677 | eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr) | ||
1678 | { | ||
1679 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
1680 | if (!type->pset) | ||
1681 | { | ||
1682 | eina_error_set(EINA_ERROR_VALUE_FAILED); | ||
1683 | return EINA_FALSE; | ||
1684 | } | ||
1685 | return type->pset(type, mem, ptr); | ||
1686 | } | ||
1687 | |||
1688 | static inline Eina_Bool | ||
1689 | eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr) | ||
1690 | { | ||
1691 | EINA_SAFETY_ON_FALSE_RETURN_VAL(eina_value_type_check(type), EINA_FALSE); | ||
1692 | if (!type->pget) | ||
1693 | { | ||
1694 | eina_error_set(EINA_ERROR_VALUE_FAILED); | ||
1695 | return EINA_FALSE; | ||
1696 | } | ||
1697 | return type->pget(type, mem, ptr); | ||
1698 | } | ||
1699 | |||
1700 | #undef EINA_VALUE_TYPE_DEFAULT | ||
1701 | #undef EINA_VALUE_TYPE_CHECK_RETURN | ||
1702 | #undef EINA_VALUE_TYPE_CHECK_RETURN_VAL | ||
1703 | #undef EINA_VALUE_TYPE_DISPATCH | ||
1704 | #undef EINA_VALUE_TYPE_DISPATCH_RETURN | ||
1705 | #endif | ||
diff --git a/libraries/eina/src/include/eina_inlist.h b/libraries/eina/src/include/eina_inlist.h index 1b3ab27..cfb3159 100644 --- a/libraries/eina/src/include/eina_inlist.h +++ b/libraries/eina/src/include/eina_inlist.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <stddef.h> | 25 | #include <stddef.h> |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * @page inlist_01_example_page Eina_Inlist basic usage | 28 | * @page eina_inlist_01_example_page Eina_Inlist basic usage |
29 | * @dontinclude eina_inlist_01.c | 29 | * @dontinclude eina_inlist_01.c |
30 | * | 30 | * |
31 | * To see the full source for this example, click here: @ref | 31 | * To see the full source for this example, click here: @ref |
@@ -111,7 +111,7 @@ | |||
111 | */ | 111 | */ |
112 | 112 | ||
113 | /** | 113 | /** |
114 | * @page inlist_02_example_page Eina_Inlist advanced usage - lists and inlists | 114 | * @page eina_inlist_02_example_page Eina_Inlist advanced usage - lists and inlists |
115 | * @dontinclude eina_inlist_02.c | 115 | * @dontinclude eina_inlist_02.c |
116 | * | 116 | * |
117 | * This example describes the usage of @ref Eina_Inlist mixed with @ref | 117 | * This example describes the usage of @ref Eina_Inlist mixed with @ref |
@@ -120,7 +120,7 @@ | |||
120 | * from this normal list. | 120 | * from this normal list. |
121 | * | 121 | * |
122 | * The struct that is going to be used is the same used in @ref | 122 | * The struct that is going to be used is the same used in @ref |
123 | * inlist_01_example_page , since we still need the @ref EINA_INLIST macro to | 123 | * eina_inlist_01_example_page , since we still need the @ref EINA_INLIST macro to |
124 | * declare the inlist node info: | 124 | * declare the inlist node info: |
125 | * | 125 | * |
126 | * @skip struct | 126 | * @skip struct |
@@ -184,7 +184,7 @@ | |||
184 | */ | 184 | */ |
185 | 185 | ||
186 | /** | 186 | /** |
187 | * @page inlist_03_example_page Eina_Inlist advanced usage - multi-inlists | 187 | * @page eina_inlist_03_example_page Eina_Inlist advanced usage - multi-inlists |
188 | * @dontinclude eina_inlist_03.c | 188 | * @dontinclude eina_inlist_03.c |
189 | * | 189 | * |
190 | * This example describes the usage of multiple inlists storing the same data. | 190 | * This example describes the usage of multiple inlists storing the same data. |
@@ -315,7 +315,7 @@ | |||
315 | * exactly what type this list is. | 315 | * exactly what type this list is. |
316 | * | 316 | * |
317 | * A simple example demonstrating the basic usage of an inlist can be found | 317 | * A simple example demonstrating the basic usage of an inlist can be found |
318 | * here: @ref inlist_01_example_page | 318 | * here: @ref eina_inlist_01_example_page |
319 | * | 319 | * |
320 | * @section inlist_algo Algorithm | 320 | * @section inlist_algo Algorithm |
321 | * | 321 | * |
@@ -368,9 +368,9 @@ | |||
368 | * @ref inlist_03_example_page | 368 | * @ref inlist_03_example_page |
369 | * | 369 | * |
370 | * List of examples: | 370 | * List of examples: |
371 | * @li @ref inlist_01_example_page | 371 | * @li @ref eina_inlist_01_example_page |
372 | * @li @ref inlist_02_example_page | 372 | * @li @ref eina_inlist_02_example_page |
373 | * @li @ref inlist_03_example_page | 373 | * @li @ref eina_inlist_03_example_page |
374 | */ | 374 | */ |
375 | 375 | ||
376 | /** | 376 | /** |
@@ -428,17 +428,17 @@ struct _Eina_Inlist | |||
428 | * Add a new node to end of a list. | 428 | * Add a new node to end of a list. |
429 | * | 429 | * |
430 | * @note this code is meant to be fast: appends are O(1) and do not | 430 | * @note this code is meant to be fast: appends are O(1) and do not |
431 | * walk @a list. | 431 | * walk @a in_list. |
432 | * | 432 | * |
433 | * @note @a new_l is considered to be in no list. If it was in another | 433 | * @note @a in_item is considered to be in no list. If it was in another |
434 | * list before, eina_inlist_remove() it before adding. No | 434 | * list before, eina_inlist_remove() it before adding. No |
435 | * check of @a new_l prev and next pointers is done, so it's safe | 435 | * check of @a new_l prev and next pointers is done, so it's safe |
436 | * to have them uninitialized. | 436 | * to have them uninitialized. |
437 | * | 437 | * |
438 | * @param list existing list head or NULL to create a new list. | 438 | * @param in_list existing list head or NULL to create a new list. |
439 | * @param new_l new list node, must not be NULL. | 439 | * @param in_item new list node, must not be NULL. |
440 | * | 440 | * |
441 | * @return the new list head. Use it and not @a list anymore. | 441 | * @return the new list head. Use it and not @a in_list anymore. |
442 | */ | 442 | */ |
443 | EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list, | 443 | EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list, |
444 | Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; | 444 | Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; |
@@ -447,17 +447,17 @@ EAPI Eina_Inlist *eina_inlist_append(Eina_Inlist *in_list, | |||
447 | * Add a new node to beginning of list. | 447 | * Add a new node to beginning of list. |
448 | * | 448 | * |
449 | * @note this code is meant to be fast: appends are O(1) and do not | 449 | * @note this code is meant to be fast: appends are O(1) and do not |
450 | * walk @a list. | 450 | * walk @a in_list. |
451 | * | 451 | * |
452 | * @note @a new_l is considered to be in no list. If it was in another | 452 | * @note @a new_l is considered to be in no list. If it was in another |
453 | * list before, eina_inlist_remove() it before adding. No | 453 | * list before, eina_inlist_remove() it before adding. No |
454 | * check of @a new_l prev and next pointers is done, so it's safe | 454 | * check of @a new_l prev and next pointers is done, so it's safe |
455 | * to have them uninitialized. | 455 | * to have them uninitialized. |
456 | * | 456 | * |
457 | * @param list existing list head or NULL to create a new list. | 457 | * @param in_list existing list head or NULL to create a new list. |
458 | * @param new_l new list node, must not be NULL. | 458 | * @param in_item new list node, must not be NULL. |
459 | * | 459 | * |
460 | * @return the new list head. Use it and not @a list anymore. | 460 | * @return the new list head. Use it and not @a in_list anymore. |
461 | */ | 461 | */ |
462 | EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list, | 462 | EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list, |
463 | Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; | 463 | Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; |
@@ -466,21 +466,21 @@ EAPI Eina_Inlist *eina_inlist_prepend(Eina_Inlist *in_list, | |||
466 | * Add a new node after the given relative item in list. | 466 | * Add a new node after the given relative item in list. |
467 | * | 467 | * |
468 | * @note this code is meant to be fast: appends are O(1) and do not | 468 | * @note this code is meant to be fast: appends are O(1) and do not |
469 | * walk @a list. | 469 | * walk @a in_list. |
470 | * | 470 | * |
471 | * @note @a new_l is considered to be in no list. If it was in another | 471 | * @note @a in_item_l is considered to be in no list. If it was in another |
472 | * list before, eina_inlist_remove() it before adding. No | 472 | * list before, eina_inlist_remove() it before adding. No |
473 | * check of @a new_l prev and next pointers is done, so it's safe | 473 | * check of @a in_item prev and next pointers is done, so it's safe |
474 | * to have them uninitialized. | 474 | * to have them uninitialized. |
475 | * | 475 | * |
476 | * @note @a relative is considered to be inside @a list, no checks are | 476 | * @note @a in_relative is considered to be inside @a in_list, no checks are |
477 | * done to confirm that and giving nodes from different lists | 477 | * done to confirm that and giving nodes from different lists |
478 | * will lead to problems. Giving NULL @a relative is the same as | 478 | * will lead to problems. Giving NULL @a in_relative is the same as |
479 | * eina_list_append(). | 479 | * eina_list_append(). |
480 | * | 480 | * |
481 | * @param list existing list head or NULL to create a new list. | 481 | * @param in_list existing list head or NULL to create a new list. |
482 | * @param new_l new list node, must not be NULL. | 482 | * @param in_item new list node, must not be NULL. |
483 | * @param relative reference node, @a new_l will be added after it. | 483 | * @param in_relative reference node, @a in_item will be added after it. |
484 | * | 484 | * |
485 | * @return the new list head. Use it and not @a list anymore. | 485 | * @return the new list head. Use it and not @a list anymore. |
486 | */ | 486 | */ |
@@ -492,23 +492,23 @@ EAPI Eina_Inlist *eina_inlist_append_relative(Eina_Inlist *in_list, | |||
492 | * Add a new node before the given relative item in list. | 492 | * Add a new node before the given relative item in list. |
493 | * | 493 | * |
494 | * @note this code is meant to be fast: appends are O(1) and do not | 494 | * @note this code is meant to be fast: appends are O(1) and do not |
495 | * walk @a list. | 495 | * walk @a in_list. |
496 | * | 496 | * |
497 | * @note @a new_l is considered to be in no list. If it was in another | 497 | * @note @a in_item is considered to be in no list. If it was in another |
498 | * list before, eina_inlist_remove() it before adding. No | 498 | * list before, eina_inlist_remove() it before adding. No |
499 | * check of @a new_l prev and next pointers is done, so it's safe | 499 | * check of @a in_item prev and next pointers is done, so it's safe |
500 | * to have them uninitialized. | 500 | * to have them uninitialized. |
501 | * | 501 | * |
502 | * @note @a relative is considered to be inside @a list, no checks are | 502 | * @note @a in_relative is considered to be inside @a in_list, no checks are |
503 | * done to confirm that and giving nodes from different lists | 503 | * done to confirm that and giving nodes from different lists |
504 | * will lead to problems. Giving NULL @a relative is the same as | 504 | * will lead to problems. Giving NULL @a in_relative is the same as |
505 | * eina_list_prepend(). | 505 | * eina_list_prepend(). |
506 | * | 506 | * |
507 | * @param list existing list head or NULL to create a new list. | 507 | * @param in_list existing list head or NULL to create a new list. |
508 | * @param new_l new list node, must not be NULL. | 508 | * @param in_item new list node, must not be NULL. |
509 | * @param relative reference node, @a new_l will be added before it. | 509 | * @param in_relative reference node, @a in_item will be added before it. |
510 | * | 510 | * |
511 | * @return the new list head. Use it and not @a list anymore. | 511 | * @return the new list head. Use it and not @a in_list anymore. |
512 | */ | 512 | */ |
513 | EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list, | 513 | EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list, |
514 | Eina_Inlist *in_item, | 514 | Eina_Inlist *in_item, |
@@ -520,14 +520,14 @@ EAPI Eina_Inlist *eina_inlist_prepend_relative(Eina_Inlist *in_list, | |||
520 | * @note this code is meant to be fast: appends are O(1) and do not | 520 | * @note this code is meant to be fast: appends are O(1) and do not |
521 | * walk @a list. | 521 | * walk @a list. |
522 | * | 522 | * |
523 | * @note @a item is considered to be inside @a list, no checks are | 523 | * @note @a in_item is considered to be inside @a in_list, no checks are |
524 | * done to confirm that and giving nodes from different lists | 524 | * done to confirm that and giving nodes from different lists |
525 | * will lead to problems, especially if @a item is the head since | 525 | * will lead to problems, especially if @a in_item is the head since |
526 | * it will be different from @a list and the wrong new head will | 526 | * it will be different from @a list and the wrong new head will |
527 | * be returned. | 527 | * be returned. |
528 | * | 528 | * |
529 | * @param list existing list head, must not be NULL. | 529 | * @param in_list existing list head, must not be NULL. |
530 | * @param item existing list node, must not be NULL. | 530 | * @param in_item existing list node, must not be NULL. |
531 | * | 531 | * |
532 | * @return the new list head. Use it and not @a list anymore. | 532 | * @return the new list head. Use it and not @a list anymore. |
533 | */ | 533 | */ |
@@ -540,10 +540,10 @@ EAPI Eina_Inlist *eina_inlist_remove(Eina_Inlist *in_list, | |||
540 | * @warning this is an expensive call and has O(n) cost, possibly | 540 | * @warning this is an expensive call and has O(n) cost, possibly |
541 | * walking the whole list. | 541 | * walking the whole list. |
542 | * | 542 | * |
543 | * @param list existing list to search @a item in, must not be NULL. | 543 | * @param in_list existing list to search @a in_item in, must not be NULL. |
544 | * @param item what to search for, must not be NULL. | 544 | * @param in_item what to search for, must not be NULL. |
545 | * | 545 | * |
546 | * @return @a item if found, NULL if not. | 546 | * @return @a in_item if found, NULL if not. |
547 | */ | 547 | */ |
548 | EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist *in_list, | 548 | EAPI Eina_Inlist *eina_inlist_find(Eina_Inlist *in_list, |
549 | Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; | 549 | Eina_Inlist *in_item) EINA_ARG_NONNULL(2) EINA_WARN_UNUSED_RESULT; |
@@ -603,11 +603,11 @@ EAPI unsigned int eina_inlist_count(const Eina_Inlist *list) EINA_WARN_UNUSED_ | |||
603 | /** | 603 | /** |
604 | * @brief Returns a new iterator associated to @a list. | 604 | * @brief Returns a new iterator associated to @a list. |
605 | * | 605 | * |
606 | * @param list The list. | 606 | * @param in_list The list. |
607 | * @return A new iterator. | 607 | * @return A new iterator. |
608 | * | 608 | * |
609 | * This function returns a newly allocated iterator associated to @p | 609 | * This function returns a newly allocated iterator associated to @p |
610 | * list. If @p list is @c NULL or the count member of @p list is less | 610 | * in_list. If @p in_list is @c NULL or the count member of @p in_list is less |
611 | * or equal than 0, this function still returns a valid iterator that | 611 | * or equal than 0, this function still returns a valid iterator that |
612 | * will always return false on eina_iterator_next(), thus keeping API | 612 | * will always return false on eina_iterator_next(), thus keeping API |
613 | * sane. | 613 | * sane. |
@@ -625,13 +625,13 @@ EAPI Eina_Iterator *eina_inlist_iterator_new(const Eina_Inlist *in_list) EINA_MA | |||
625 | /** | 625 | /** |
626 | * @brief Returns a new accessor associated to a list. | 626 | * @brief Returns a new accessor associated to a list. |
627 | * | 627 | * |
628 | * @param list The list. | 628 | * @param in_list The list. |
629 | * @return A new accessor. | 629 | * @return A new accessor. |
630 | * | 630 | * |
631 | * This function returns a newly allocated accessor associated to | 631 | * This function returns a newly allocated accessor associated to |
632 | * @p list. If @p list is @c NULL or the count member of @p list is | 632 | * @p in_list. If @p in_list is @c NULL or the count member of @p in_list is |
633 | * less or equal than 0, this function returns NULL. If the memory can | 633 | * less or equal than 0, this function returns @c NULL. If the memory can |
634 | * not be allocated, NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is | 634 | * not be allocated, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY is |
635 | * set. Otherwise, a valid accessor is returned. | 635 | * set. Otherwise, a valid accessor is returned. |
636 | */ | 636 | */ |
637 | EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | 637 | EAPI Eina_Accessor *eina_inlist_accessor_new(const Eina_Inlist *in_list) EINA_MALLOC EINA_WARN_UNUSED_RESULT; |
@@ -728,13 +728,13 @@ EAPI Eina_Inlist *eina_inlist_sorted_state_insert(Eina_Inlist *list, | |||
728 | /** | 728 | /** |
729 | * @brief Sort a list according to the ordering func will return. | 729 | * @brief Sort a list according to the ordering func will return. |
730 | * | 730 | * |
731 | * @param list The list handle to sort. | 731 | * @param head The list handle to sort. |
732 | * @param func A function pointer that can handle comparing the list data | 732 | * @param func A function pointer that can handle comparing the list data |
733 | * nodes. | 733 | * nodes. |
734 | * @return the new head of list. | 734 | * @return the new head of list. |
735 | * | 735 | * |
736 | * This function sorts all the elements of @p list. @p func is used to | 736 | * This function sorts all the elements of @p head. @p func is used to |
737 | * compare two elements of @p list. If @p list or @p func are @c NULL, | 737 | * compare two elements of @p head. If @p head or @p func are @c NULL, |
738 | * this function returns @c NULL. | 738 | * this function returns @c NULL. |
739 | * | 739 | * |
740 | * @note @b in-place: this will change the given list, so you should | 740 | * @note @b in-place: this will change the given list, so you should |
@@ -787,6 +787,7 @@ EAPI Eina_Inlist *eina_inlist_sort(Eina_Inlist *head, Eina_Compare_Cb func); | |||
787 | _EINA_INLIST_OFFSET(ref)) | 787 | _EINA_INLIST_OFFSET(ref)) |
788 | #endif | 788 | #endif |
789 | 789 | ||
790 | /** Macro to iterate over an inlist */ | ||
790 | #define EINA_INLIST_FOREACH(list, l) \ | 791 | #define EINA_INLIST_FOREACH(list, l) \ |
791 | for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \ | 792 | for (l = NULL, l = (list ? _EINA_INLIST_CONTAINER(l, list) : NULL); l; \ |
792 | l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL)) | 793 | l = (EINA_INLIST_GET(l)->next ? _EINA_INLIST_CONTAINER(l, EINA_INLIST_GET(l)->next) : NULL)) |
diff --git a/libraries/eina/src/include/eina_iterator.h b/libraries/eina/src/include/eina_iterator.h index 1c8e6ce..10a9ece 100644 --- a/libraries/eina/src/include/eina_iterator.h +++ b/libraries/eina/src/include/eina_iterator.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "eina_magic.h" | 25 | #include "eina_magic.h" |
26 | 26 | ||
27 | /** | 27 | /** |
28 | * @page eina_iterator_example Eina_Iterator usage | 28 | * @page eina_iterator_example_page Eina_Iterator usage |
29 | * @dontinclude eina_iterator_01.c | 29 | * @dontinclude eina_iterator_01.c |
30 | * | 30 | * |
31 | * As always when using eina we need to include it: | 31 | * As always when using eina we need to include it: |
@@ -48,7 +48,7 @@ | |||
48 | * @until eina_init | 48 | * @until eina_init |
49 | * | 49 | * |
50 | * Next we populate both an array and a list with our strings, for more details | 50 | * Next we populate both an array and a list with our strings, for more details |
51 | * see @ref eina_list_01_example and @ref eina_array_01_example: | 51 | * see @ref eina_list_01_example_page and @ref eina_array_01_example_page : |
52 | * @until } | 52 | * @until } |
53 | * | 53 | * |
54 | * And now we create an array and because the first element of the container | 54 | * And now we create an array and because the first element of the container |
@@ -63,7 +63,7 @@ | |||
63 | * iterator itself: | 63 | * iterator itself: |
64 | * @until eina_iterator_free | 64 | * @until eina_iterator_free |
65 | * | 65 | * |
66 | * But so far you're not impressed in @ref eina_array_01_example an array is | 66 | * But so far you're not impressed in @ref eina_array_01_example_page an array is |
67 | * also printed, so now we go to the cool stuff and use an iterator to do same | 67 | * also printed, so now we go to the cool stuff and use an iterator to do same |
68 | * stuff to a list: | 68 | * stuff to a list: |
69 | * @until eina_iterator_free | 69 | * @until eina_iterator_free |
@@ -99,7 +99,7 @@ | |||
99 | * eina_iterator_next(). To call a function on all the elements of a | 99 | * eina_iterator_next(). To call a function on all the elements of a |
100 | * container, use eina_iterator_foreach(). | 100 | * container, use eina_iterator_foreach(). |
101 | * | 101 | * |
102 | * Here an @ref eina_iterator_example "example" | 102 | * Here an @ref eina_iterator_example_page "example" |
103 | */ | 103 | */ |
104 | 104 | ||
105 | /** | 105 | /** |
diff --git a/libraries/eina/src/include/eina_list.h b/libraries/eina/src/include/eina_list.h index 8a8f25e..db65e17 100644 --- a/libraries/eina/src/include/eina_list.h +++ b/libraries/eina/src/include/eina_list.h | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "eina_magic.h" | 29 | #include "eina_magic.h" |
30 | 30 | ||
31 | /** | 31 | /** |
32 | * @page list_01_example_page Adding elements to Eina_List | 32 | * @page eina_list_01_example_page Adding elements to Eina_List |
33 | * @dontinclude eina_list_01.c | 33 | * @dontinclude eina_list_01.c |
34 | * | 34 | * |
35 | * Creating an @ref Eina_List and adding elements to it is very easy and can be | 35 | * Creating an @ref Eina_List and adding elements to it is very easy and can be |
@@ -99,11 +99,11 @@ | |||
99 | */ | 99 | */ |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * @page list_02_example_page Sorting Eina_List elements | 102 | * @page eina_list_02_example_page Sorting Eina_List elements |
103 | * @dontinclude eina_list_02.c | 103 | * @dontinclude eina_list_02.c |
104 | * | 104 | * |
105 | * If you don't know how to create lists see | 105 | * If you don't know how to create lists see |
106 | * @ref list_01_example_page. | 106 | * @ref eina_list_01_example_page. |
107 | * | 107 | * |
108 | * @skip #include | 108 | * @skip #include |
109 | * @until boomer | 109 | * @until boomer |
@@ -151,11 +151,11 @@ | |||
151 | */ | 151 | */ |
152 | 152 | ||
153 | /** | 153 | /** |
154 | * @page list_03_example_page Reordering Eina_List elments | 154 | * @page eina_list_03_example_page Reordering Eina_List elments |
155 | * @dontinclude eina_list_03.c | 155 | * @dontinclude eina_list_03.c |
156 | * | 156 | * |
157 | * If you don't know how to create lists see | 157 | * If you don't know how to create lists see |
158 | * @ref list_01_example_page. | 158 | * @ref eina_list_01_example_page. |
159 | * | 159 | * |
160 | * We start out with code that should be familiar by now: | 160 | * We start out with code that should be familiar by now: |
161 | * @skip #include | 161 | * @skip #include |
@@ -197,12 +197,12 @@ | |||
197 | */ | 197 | */ |
198 | 198 | ||
199 | /** | 199 | /** |
200 | * @page list_04_example_page Eina_List and memory allocation | 200 | * @page eina_list_04_example_page Eina_List and memory allocation |
201 | * @dontinclude eina_list_04.c | 201 | * @dontinclude eina_list_04.c |
202 | * | 202 | * |
203 | * If you don't know how to create lists see | 203 | * If you don't know how to create lists see |
204 | * @ref list_01_example_page. In this example we also use | 204 | * @ref eina_list_01_example_page. In this example we also use |
205 | * @ref eina_stringshare, however it should be possible to understand the code | 205 | * @ref Eina_Stringshare_Group, however it should be possible to understand the code |
206 | * regardless of previous knowledge about it. | 206 | * regardless of previous knowledge about it. |
207 | * | 207 | * |
208 | * Here we have the usual list creation code with a twist, now we are using as | 208 | * Here we have the usual list creation code with a twist, now we are using as |
@@ -276,10 +276,10 @@ | |||
276 | * list as the list! | 276 | * list as the list! |
277 | * | 277 | * |
278 | * Here are some examples of @ref Eina_List usage: | 278 | * Here are some examples of @ref Eina_List usage: |
279 | * @li @ref list_01_example_page | 279 | * @li @ref eina_list_01_example_page |
280 | * @li @ref list_02_example_page | 280 | * @li @ref eina_list_02_example_page |
281 | * @li @ref list_03_example_page | 281 | * @li @ref eina_list_03_example_page |
282 | * @li @ref list_04_example_page | 282 | * @li @ref eina_list_04_example_page |
283 | */ | 283 | */ |
284 | 284 | ||
285 | /** | 285 | /** |
@@ -582,7 +582,7 @@ EAPI Eina_List *eina_list_remove(Eina_List *list, const void *data) E | |||
582 | 582 | ||
583 | 583 | ||
584 | /** | 584 | /** |
585 | * @brief Remove the specified data. | 585 | * @brief Remove the specified list node. |
586 | * | 586 | * |
587 | * @param list The given linked list. | 587 | * @param list The given linked list. |
588 | * @param remove_list The list node which is to be removed. | 588 | * @param remove_list The list node which is to be removed. |
diff --git a/libraries/eina/src/include/eina_lock.h b/libraries/eina/src/include/eina_lock.h index 7c26dc0..16f4314 100644 --- a/libraries/eina/src/include/eina_lock.h +++ b/libraries/eina/src/include/eina_lock.h | |||
@@ -81,6 +81,10 @@ static inline void eina_tls_free(Eina_TLS key); | |||
81 | static inline void *eina_tls_get(Eina_TLS key); | 81 | static inline void *eina_tls_get(Eina_TLS key); |
82 | static inline Eina_Bool eina_tls_set(Eina_TLS key, const void *data); | 82 | static inline Eina_Bool eina_tls_set(Eina_TLS key, const void *data); |
83 | 83 | ||
84 | static inline Eina_Bool eina_semaphore_new(Eina_Semaphore *sem, int count_init); | ||
85 | static inline Eina_Bool eina_semaphore_free(Eina_Semaphore *sem); | ||
86 | static inline Eina_Bool eina_semaphore_lock(Eina_Semaphore *sem); | ||
87 | static inline Eina_Bool eina_semaphore_release(Eina_Semaphore *sem, int count_release); | ||
84 | 88 | ||
85 | #ifdef EINA_HAVE_DEBUG_THREADS | 89 | #ifdef EINA_HAVE_DEBUG_THREADS |
86 | # define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) \ | 90 | # define EINA_MAIN_LOOP_CHECK_RETURN_VAL(val) \ |
diff --git a/libraries/eina/src/include/eina_log.h b/libraries/eina/src/include/eina_log.h index 5cd7c59..186397d 100644 --- a/libraries/eina/src/include/eina_log.h +++ b/libraries/eina/src/include/eina_log.h | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <stdarg.h> | 23 | #include <stdarg.h> |
24 | #include <sys/types.h> | ||
24 | 25 | ||
25 | #include "eina_types.h" | 26 | #include "eina_types.h" |
26 | 27 | ||
@@ -297,22 +298,27 @@ EAPI extern int EINA_LOG_DOMAIN_GLOBAL; | |||
297 | * paths. Never define @c EINA_LOG_LEVEL_MAXIMUM on public | 298 | * paths. Never define @c EINA_LOG_LEVEL_MAXIMUM on public |
298 | * header files. | 299 | * header files. |
299 | */ | 300 | */ |
300 | #ifdef EINA_LOG_LEVEL_MAXIMUM | 301 | #ifdef EINA_ENABLE_LOG |
301 | #define EINA_LOG(DOM, LEVEL, fmt, ...) \ | 302 | # ifdef EINA_LOG_LEVEL_MAXIMUM |
302 | do { \ | 303 | # define EINA_LOG(DOM, LEVEL, fmt, ...) \ |
303 | if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \ | 304 | do { \ |
304 | eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \ | 305 | if (LEVEL <= EINA_LOG_LEVEL_MAXIMUM) { \ |
305 | fmt, ## __VA_ARGS__); } \ | 306 | eina_log_print(DOM, LEVEL, __FILE__, __FUNCTION__, __LINE__, \ |
306 | } while (0) | 307 | fmt, ## __VA_ARGS__); } \ |
307 | #else | 308 | } while (0) |
308 | #define EINA_LOG(DOM, LEVEL, fmt, ...) \ | 309 | # else |
309 | eina_log_print(DOM, \ | 310 | # define EINA_LOG(DOM, LEVEL, fmt, ...) \ |
310 | LEVEL, \ | 311 | eina_log_print(DOM, \ |
311 | __FILE__, \ | 312 | LEVEL, \ |
312 | __FUNCTION__, \ | 313 | __FILE__, \ |
313 | __LINE__, \ | 314 | __FUNCTION__, \ |
314 | fmt, \ | 315 | __LINE__, \ |
316 | fmt, \ | ||
315 | ## __VA_ARGS__) | 317 | ## __VA_ARGS__) |
318 | # endif | ||
319 | #else | ||
320 | #define EINA_LOG(DOM, LEVEL, fmt, ...) \ | ||
321 | do { (void) DOM; (void) LEVEL; (void) fmt; } while (0) | ||
316 | #endif | 322 | #endif |
317 | 323 | ||
318 | /** | 324 | /** |
@@ -726,7 +732,7 @@ EAPI void eina_log_domain_unregister(int domain); | |||
726 | * specified value (eina_log_level_set() or environment | 732 | * specified value (eina_log_level_set() or environment |
727 | * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored. | 733 | * variables EINA_LOG_LEVEL, EINA_LOG_LEVELS) will be ignored. |
728 | * @param file filename that originated the call, must @b not be @c NULL. | 734 | * @param file filename that originated the call, must @b not be @c NULL. |
729 | * @param fnc function that originated the call, must @b not be @c NULL. | 735 | * @param function function that originated the call, must @b not be @c NULL. |
730 | * @param line originating line in @a file. | 736 | * @param line originating line in @a file. |
731 | * @param fmt printf-like format to use. Should not provide trailing | 737 | * @param fmt printf-like format to use. Should not provide trailing |
732 | * '\n' as it is automatically included. | 738 | * '\n' as it is automatically included. |
@@ -780,7 +786,7 @@ EAPI void eina_log_vprint(int domain, | |||
780 | */ | 786 | */ |
781 | 787 | ||
782 | /** | 788 | /** |
783 | * Alternative logging method, this will output to standard output stream. | 789 | * @brief Alternative logging method, this will output to standard output stream. |
784 | * | 790 | * |
785 | * @param d The domain. | 791 | * @param d The domain. |
786 | * @param level The level. | 792 | * @param level The level. |
@@ -815,7 +821,16 @@ EAPI void eina_log_print_cb_stdout(const Eina_Log_Domain *d, | |||
815 | va_list args); | 821 | va_list args); |
816 | 822 | ||
817 | /** | 823 | /** |
818 | * Default logging method, this will output to standard error stream. | 824 | * @brief Default logging method, this will output to standard error stream. |
825 | * | ||
826 | * @param d The domain. | ||
827 | * @param level The level. | ||
828 | * @param file The file which is logged. | ||
829 | * @param fnc The function which is logged. | ||
830 | * @param line The line which is logged. | ||
831 | * @param fmt The ouptut format to use. | ||
832 | * @param data Not used. | ||
833 | * @param args The arguments needed by the format. | ||
819 | * | 834 | * |
820 | * This method will colorize output based on domain provided color and | 835 | * This method will colorize output based on domain provided color and |
821 | * message logging level. | 836 | * message logging level. |
diff --git a/libraries/eina/src/include/eina_magic.h b/libraries/eina/src/include/eina_magic.h index 44cd4e9..d4909d8 100644 --- a/libraries/eina/src/include/eina_magic.h +++ b/libraries/eina/src/include/eina_magic.h | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include "eina_config.h" | 22 | #include "eina_config.h" |
23 | #include "eina_types.h" | 23 | #include "eina_types.h" |
24 | #include "eina_error.h" | ||
24 | 25 | ||
25 | /** | 26 | /** |
26 | * @page eina_magic_example_01_page | 27 | * @page eina_magic_example_01_page |
@@ -200,6 +201,13 @@ EAPI Eina_Bool eina_magic_string_static_set(Eina_Magic magic, | |||
200 | */ | 201 | */ |
201 | #define EINA_MAGIC_NONE 0x1234fedc | 202 | #define EINA_MAGIC_NONE 0x1234fedc |
202 | 203 | ||
204 | /** | ||
205 | * @var EINA_ERROR_MAGIC_FAILED | ||
206 | * Error identifier corresponding to magic check failure. | ||
207 | */ | ||
208 | EAPI extern Eina_Error EINA_ERROR_MAGIC_FAILED; | ||
209 | |||
210 | |||
203 | #ifdef EINA_MAGIC_DEBUG | 211 | #ifdef EINA_MAGIC_DEBUG |
204 | 212 | ||
205 | /** | 213 | /** |
diff --git a/libraries/eina/src/include/eina_main.h b/libraries/eina/src/include/eina_main.h index fa34d59..4baf40e 100644 --- a/libraries/eina/src/include/eina_main.h +++ b/libraries/eina/src/include/eina_main.h | |||
@@ -50,7 +50,7 @@ | |||
50 | * @def EINA_VERSION_MINOR | 50 | * @def EINA_VERSION_MINOR |
51 | * @brief Minor version of Eina | 51 | * @brief Minor version of Eina |
52 | */ | 52 | */ |
53 | #define EINA_VERSION_MINOR 0 | 53 | #define EINA_VERSION_MINOR 2 |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * @typedef Eina_Version | 56 | * @typedef Eina_Version |
@@ -134,6 +134,9 @@ EAPI int eina_threads_shutdown(void); | |||
134 | 134 | ||
135 | /** | 135 | /** |
136 | * @brief Check if you are calling this function from the same thread Eina was initialized or not | 136 | * @brief Check if you are calling this function from the same thread Eina was initialized or not |
137 | * | ||
138 | * @return #EINA_TRUE is the calling function is the same thread, #EINA_FALSE otherwise. | ||
139 | * | ||
137 | * @since 1.1.0 | 140 | * @since 1.1.0 |
138 | * | 141 | * |
139 | * Most EFL function are not thread safe and all the call need to happen in | 142 | * Most EFL function are not thread safe and all the call need to happen in |
diff --git a/libraries/eina/src/include/eina_module.h b/libraries/eina/src/include/eina_module.h index 58e38f9..178fa9a 100644 --- a/libraries/eina/src/include/eina_module.h +++ b/libraries/eina/src/include/eina_module.h | |||
@@ -67,6 +67,10 @@ | |||
67 | */ | 67 | */ |
68 | typedef struct _Eina_Module Eina_Module; | 68 | typedef struct _Eina_Module Eina_Module; |
69 | 69 | ||
70 | /** | ||
71 | * @typedef Eina_Module_Cb | ||
72 | * Dynamic module loader callback. | ||
73 | */ | ||
70 | typedef Eina_Bool (*Eina_Module_Cb)(Eina_Module *m, void *data); | 74 | typedef Eina_Bool (*Eina_Module_Cb)(Eina_Module *m, void *data); |
71 | 75 | ||
72 | /** | 76 | /** |
@@ -135,21 +139,21 @@ EAPI Eina_Module * | |||
135 | /** | 139 | /** |
136 | * @brief Delete a module. | 140 | * @brief Delete a module. |
137 | * | 141 | * |
138 | * @param m The module to delete. | 142 | * @param module The module to delete. |
139 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | 143 | * @return EINA_TRUE on success, EINA_FALSE otherwise. |
140 | * | 144 | * |
141 | * This function calls eina_module_unload() if @p m has been previously | 145 | * This function calls eina_module_unload() if @p module has been previously |
142 | * loaded and frees the allocated memory. On success this function | 146 | * loaded and frees the allocated memory. On success this function |
143 | * returns EINA_TRUE and EINA_FALSE otherwise. If @p m is @c NULL, the | 147 | * returns EINA_TRUE and EINA_FALSE otherwise. If @p module is @c NULL, the |
144 | * function returns immediately. | 148 | * function returns immediately. |
145 | */ | 149 | */ |
146 | EAPI Eina_Bool | 150 | EAPI Eina_Bool |
147 | eina_module_free(Eina_Module *m) EINA_ARG_NONNULL(1); | 151 | eina_module_free(Eina_Module *module) EINA_ARG_NONNULL(1); |
148 | 152 | ||
149 | /** | 153 | /** |
150 | * @brief Load a module. | 154 | * @brief Load a module. |
151 | * | 155 | * |
152 | * @param m The module to load. | 156 | * @param module The module to load. |
153 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | 157 | * @return EINA_TRUE on success, EINA_FALSE otherwise. |
154 | * | 158 | * |
155 | * This function load the shared file object passed in | 159 | * This function load the shared file object passed in |
@@ -160,7 +164,7 @@ EAPI Eina_Bool | |||
160 | * module can not be initialized, the error | 164 | * module can not be initialized, the error |
161 | * #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is | 165 | * #EINA_ERROR_MODULE_INIT_FAILED is set and #EINA_FALSE is |
162 | * returned. If the module has already been loaded, it's refeence | 166 | * returned. If the module has already been loaded, it's refeence |
163 | * counter is increased by one and #EINA_TRUE is returned. If @p m is | 167 | * counter is increased by one and #EINA_TRUE is returned. If @p module is |
164 | * @c NULL, the function returns immediately #EINA_FALSE. | 168 | * @c NULL, the function returns immediately #EINA_FALSE. |
165 | * | 169 | * |
166 | * When the symbols of the shared file objetcts are not needed | 170 | * When the symbols of the shared file objetcts are not needed |
@@ -172,29 +176,29 @@ EAPI Eina_Bool | |||
172 | /** | 176 | /** |
173 | * @brief Unload a module. | 177 | * @brief Unload a module. |
174 | * | 178 | * |
175 | * @param m The module to load. | 179 | * @param module The module to load. |
176 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | 180 | * @return EINA_TRUE on success, EINA_FALSE otherwise. |
177 | * | 181 | * |
178 | * This function unload the module @p m that has been previously | 182 | * This function unload the module @p module that has been previously |
179 | * loaded by eina_module_load(). If the reference counter of @p m is | 183 | * loaded by eina_module_load(). If the reference counter of @p module is |
180 | * strictly greater than @c 1, #EINA_FALSE is returned. Otherwise, the | 184 | * strictly greater than @c 1, #EINA_FALSE is returned. Otherwise, the |
181 | * shared object file is closed and if it is a internal Eina module, it | 185 | * shared object file is closed and if it is a internal Eina module, it |
182 | * is shutted down just before. In that case, #EINA_TRUE is | 186 | * is shutted down just before. In that case, #EINA_TRUE is |
183 | * returned. In all case, the reference counter is decreased. If @p m | 187 | * returned. In all case, the reference counter is decreased. If @p module |
184 | * is @c NULL, the function returns immediately #EINA_FALSE. | 188 | * is @c NULL, the function returns immediately #EINA_FALSE. |
185 | */ | 189 | */ |
186 | EAPI Eina_Bool | 190 | EAPI Eina_Bool |
187 | eina_module_unload(Eina_Module *m) EINA_ARG_NONNULL(1); | 191 | eina_module_unload(Eina_Module *module) EINA_ARG_NONNULL(1); |
188 | 192 | ||
189 | /** | 193 | /** |
190 | * @brief Retrive the data associated to a symbol. | 194 | * @brief Retrive the data associated to a symbol. |
191 | * | 195 | * |
192 | * @param m The module. | 196 | * @param module The module. |
193 | * @param symbol The symbol. | 197 | * @param symbol The symbol. |
194 | * @return The data associated to the symbol, or @c NULL on failure. | 198 | * @return The data associated to the symbol, or @c NULL on failure. |
195 | * | 199 | * |
196 | * This function returns the data associated to @p symbol of @p m. @p | 200 | * This function returns the data associated to @p symbol of @p module. @p |
197 | * m must have been loaded before with eina_module_load(). If @p m | 201 | * module must have been loaded before with eina_module_load(). If @p module |
198 | * is @c NULL, or if it has not been correctly loaded before, the | 202 | * is @c NULL, or if it has not been correctly loaded before, the |
199 | * function returns immediately @c NULL. | 203 | * function returns immediately @c NULL. |
200 | */ | 204 | */ |
@@ -204,15 +208,15 @@ EAPI void * | |||
204 | /** | 208 | /** |
205 | * @brief Return the file name associated to the module. | 209 | * @brief Return the file name associated to the module. |
206 | * | 210 | * |
207 | * @param m The module. | 211 | * @param module The module. |
208 | * @return The file name. | 212 | * @return The file name. |
209 | * | 213 | * |
210 | * This function returns the file name passed in eina_module_new(). If | 214 | * This function returns the file name passed in eina_module_new(). If |
211 | * @p m is @c NULL, the function returns immediately @c NULL. The | 215 | * @p module is @c NULL, the function returns immediately @c NULL. The |
212 | * returned value must no be freed. | 216 | * returned value must no be freed. |
213 | */ | 217 | */ |
214 | EAPI const char * | 218 | EAPI const char * |
215 | eina_module_file_get(const Eina_Module *m) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); | 219 | eina_module_file_get(const Eina_Module *module) EINA_PURE EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1); |
216 | 220 | ||
217 | 221 | ||
218 | /** | 222 | /** |
@@ -256,6 +260,7 @@ EAPI char * | |||
256 | * @param array The array that stores the list of the modules. | 260 | * @param array The array that stores the list of the modules. |
257 | * @param path The directory's path to search for modules. | 261 | * @param path The directory's path to search for modules. |
258 | * @param arch The architecture string. | 262 | * @param arch The architecture string. |
263 | * @return The array of modules found in @p path matching @p arch. | ||
259 | * | 264 | * |
260 | * This function adds to @p array the module names found in @p path | 265 | * This function adds to @p array the module names found in @p path |
261 | * which match the cpu architecture @p arch. If @p path or @p arch is | 266 | * which match the cpu architecture @p arch. If @p path or @p arch is |
@@ -273,6 +278,7 @@ EAPI Eina_Array * | |||
273 | * @param recursive Iterate recursively on the path. | 278 | * @param recursive Iterate recursively on the path. |
274 | * @param cb Callback function to call on each module. | 279 | * @param cb Callback function to call on each module. |
275 | * @param data Data passed to the callback function. | 280 | * @param data Data passed to the callback function. |
281 | * @return The array of modules found in @p path. | ||
276 | * | 282 | * |
277 | * This function adds to @p array the list of modules found in | 283 | * This function adds to @p array the list of modules found in |
278 | * @p path. If @p recursive is #EINA_TRUE, then recursive search is | 284 | * @p path. If @p recursive is #EINA_TRUE, then recursive search is |
@@ -295,7 +301,7 @@ EAPI Eina_Array * | |||
295 | * @p array. If @p array is @c NULL, this function does nothing. | 301 | * @p array. If @p array is @c NULL, this function does nothing. |
296 | */ | 302 | */ |
297 | EAPI void | 303 | EAPI void |
298 | eina_module_list_load(Eina_Array *list) EINA_ARG_NONNULL(1); | 304 | eina_module_list_load(Eina_Array *array) EINA_ARG_NONNULL(1); |
299 | 305 | ||
300 | /** | 306 | /** |
301 | * @brief Unload every module on the list of modules. | 307 | * @brief Unload every module on the list of modules. |
@@ -306,7 +312,7 @@ EAPI void | |||
306 | * @p array. If @p array is @c NULL, this function does nothing. | 312 | * @p array. If @p array is @c NULL, this function does nothing. |
307 | */ | 313 | */ |
308 | EAPI void | 314 | EAPI void |
309 | eina_module_list_unload(Eina_Array *list) EINA_ARG_NONNULL(1); | 315 | eina_module_list_unload(Eina_Array *array) EINA_ARG_NONNULL(1); |
310 | 316 | ||
311 | /** | 317 | /** |
312 | * @p Free every module on the list of modules. | 318 | * @p Free every module on the list of modules. |
@@ -317,13 +323,14 @@ EAPI void | |||
317 | * @p array. If @p array is @c NULL, this function does nothing. | 323 | * @p array. If @p array is @c NULL, this function does nothing. |
318 | */ | 324 | */ |
319 | EAPI void | 325 | EAPI void |
320 | eina_module_list_free(Eina_Array *list) EINA_ARG_NONNULL(1); | 326 | eina_module_list_free(Eina_Array *array) EINA_ARG_NONNULL(1); |
321 | 327 | ||
322 | /** | 328 | /** |
323 | * @brief Find an module in array. | 329 | * @brief Find an module in array. |
324 | * | 330 | * |
325 | * @param array The array to find the module. | 331 | * @param array The array to find the module. |
326 | * @param module The name of module to be searched. | 332 | * @param module The name of module to be searched. |
333 | * @return The module to find on success, @c NULL otherwise. | ||
327 | * | 334 | * |
328 | * This function finds an @p module in @p array. | 335 | * This function finds an @p module in @p array. |
329 | * If the element is found the function returns the module, else | 336 | * If the element is found the function returns the module, else |
diff --git a/libraries/eina/src/include/eina_simple_xml_parser.h b/libraries/eina/src/include/eina_simple_xml_parser.h index db9a4e1..78660ef 100644 --- a/libraries/eina/src/include/eina_simple_xml_parser.h +++ b/libraries/eina/src/include/eina_simple_xml_parser.h | |||
@@ -119,16 +119,16 @@ struct _Eina_Simple_XML_Node_Data | |||
119 | 119 | ||
120 | typedef enum _Eina_Simple_XML_Type | 120 | typedef enum _Eina_Simple_XML_Type |
121 | { | 121 | { |
122 | EINA_SIMPLE_XML_OPEN = 0, /* <tag attribute="value"> */ | 122 | EINA_SIMPLE_XML_OPEN = 0, /*!< <tag attribute="value"> */ |
123 | EINA_SIMPLE_XML_OPEN_EMPTY, /* <tag attribute="value" /> */ | 123 | EINA_SIMPLE_XML_OPEN_EMPTY, /*!< <tag attribute="value" /> */ |
124 | EINA_SIMPLE_XML_CLOSE, /* </tag> */ | 124 | EINA_SIMPLE_XML_CLOSE, /*!< </tag> */ |
125 | EINA_SIMPLE_XML_DATA, /* tag text data */ | 125 | EINA_SIMPLE_XML_DATA, /*!< tag text data */ |
126 | EINA_SIMPLE_XML_CDATA, /* <![CDATA[something]]> */ | 126 | EINA_SIMPLE_XML_CDATA, /*!< <![CDATA[something]]> */ |
127 | EINA_SIMPLE_XML_ERROR, /* error contents */ | 127 | EINA_SIMPLE_XML_ERROR, /*!< error contents */ |
128 | EINA_SIMPLE_XML_PROCESSING, /* <?xml ... ?> <?php .. ?> */ | 128 | EINA_SIMPLE_XML_PROCESSING, /*!< <?xml ... ?> <?php .. ?> */ |
129 | EINA_SIMPLE_XML_DOCTYPE, /* <!DOCTYPE html */ | 129 | EINA_SIMPLE_XML_DOCTYPE, /*!< <!DOCTYPE html */ |
130 | EINA_SIMPLE_XML_COMMENT, /* <!-- something --> */ | 130 | EINA_SIMPLE_XML_COMMENT, /*!< <!-- something --> */ |
131 | EINA_SIMPLE_XML_IGNORED /* whatever is ignored by parser, like whitespace */ | 131 | EINA_SIMPLE_XML_IGNORED /*!< whatever is ignored by parser, like whitespace */ |
132 | } Eina_Simple_XML_Type; | 132 | } Eina_Simple_XML_Type; |
133 | 133 | ||
134 | typedef Eina_Bool (*Eina_Simple_XML_Cb)(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset, unsigned length); | 134 | typedef Eina_Bool (*Eina_Simple_XML_Cb)(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset, unsigned length); |
@@ -137,7 +137,7 @@ typedef Eina_Bool (*Eina_Simple_XML_Attribute_Cb)(void *data, const char *key, c | |||
137 | 137 | ||
138 | /** | 138 | /** |
139 | * Parse a section of XML string text | 139 | * Parse a section of XML string text |
140 | * | 140 | * |
141 | * @param buf the input string. May not contain \0 terminator. | 141 | * @param buf the input string. May not contain \0 terminator. |
142 | * @param buflen the input string size. | 142 | * @param buflen the input string size. |
143 | * @param strip whenever this parser should strip leading and trailing | 143 | * @param strip whenever this parser should strip leading and trailing |
@@ -164,12 +164,15 @@ EAPI Eina_Bool eina_simple_xml_parse(const char *buf, unsigned buflen, | |||
164 | /** | 164 | /** |
165 | * Given the contents of a tag, find where the attributes start. | 165 | * Given the contents of a tag, find where the attributes start. |
166 | * | 166 | * |
167 | * The tag contents is returned by eina_simple_xml_parse() when | 167 | * @param buf the input string. May not contain \0 terminator. |
168 | * type is #EINA_SIMPLE_XML_OPEN or #EINA_SIMPLE_XML_OPEN_EMPTY. | 168 | * @param buflen the input string size. |
169 | * | ||
170 | * @return pointer to the start of attributes, it can be used | 169 | * @return pointer to the start of attributes, it can be used |
171 | * to feed eina_simple_xml_attributes_parse(). NULL is returned | 170 | * to feed eina_simple_xml_attributes_parse(). NULL is returned |
172 | * if no attributes were found. | 171 | * if no attributes were found. |
172 | * | ||
173 | * The tag contents is returned by eina_simple_xml_parse() when | ||
174 | * type is #EINA_SIMPLE_XML_OPEN or #EINA_SIMPLE_XML_OPEN_EMPTY. | ||
175 | * | ||
173 | */ | 176 | */ |
174 | EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned buflen); | 177 | EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned buflen); |
175 | 178 | ||
@@ -183,6 +186,7 @@ EAPI const char * eina_simple_xml_tag_attributes_find(const char *buf, unsigned | |||
183 | * key (null-terminated) and the last is the value (null | 186 | * key (null-terminated) and the last is the value (null |
184 | * terminated). These strings should not be modified and | 187 | * terminated). These strings should not be modified and |
185 | * reference is just valid until the function return. | 188 | * reference is just valid until the function return. |
189 | * @param data data to pass to the callback function. | ||
186 | * | 190 | * |
187 | * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or | 191 | * @return EINA_TRUE on success or EINA_FALSE if it was aborted by user or |
188 | * parsing error. | 192 | * parsing error. |
@@ -238,8 +242,8 @@ EAPI void eina_simple_xml_node_tag_free(Eina_Simple_XML_Node_Tag *tag); | |||
238 | * | 242 | * |
239 | * @param parent if provided, will be set in the resulting structure | 243 | * @param parent if provided, will be set in the resulting structure |
240 | * as well as the data will be appended to children list. | 244 | * as well as the data will be appended to children list. |
241 | * @param content string to be used. Must not be NULL. | 245 | * @param contents string to be used. Must not be NULL. |
242 | * @param length size in bytes of @a content. | 246 | * @param length size in bytes of @a contents. |
243 | * | 247 | * |
244 | * @return newly allocated memory or NULL on error. This memory should be | 248 | * @return newly allocated memory or NULL on error. This memory should be |
245 | * released with eina_simple_xml_node_data_free() or indirectly | 249 | * released with eina_simple_xml_node_data_free() or indirectly |
@@ -250,7 +254,7 @@ EAPI Eina_Simple_XML_Node_Data * eina_simple_xml_node_data_new(Eina_Simple_XML_N | |||
250 | /** | 254 | /** |
251 | * Remove data from parent and delete it. | 255 | * Remove data from parent and delete it. |
252 | * | 256 | * |
253 | * @param data to release memory. | 257 | * @param node to release memory. |
254 | */ | 258 | */ |
255 | EAPI void eina_simple_xml_node_data_free(Eina_Simple_XML_Node_Data *node); | 259 | EAPI void eina_simple_xml_node_data_free(Eina_Simple_XML_Node_Data *node); |
256 | 260 | ||
@@ -260,7 +264,7 @@ EAPI void eina_simple_xml_node_data_free(Eina_Simple_XML_Node_Data *node); | |||
260 | * | 264 | * |
261 | * @param parent if provided, will be set in the resulting structure | 265 | * @param parent if provided, will be set in the resulting structure |
262 | * as well as the cdata will be appended to children list. | 266 | * as well as the cdata will be appended to children list. |
263 | * @param content string to be used. Must not be NULL. | 267 | * @param contents string to be used. Must not be NULL. |
264 | * @param length size in bytes of @a content. | 268 | * @param length size in bytes of @a content. |
265 | * | 269 | * |
266 | * @return newly allocated memory or NULL on error. This memory should be | 270 | * @return newly allocated memory or NULL on error. This memory should be |
@@ -272,7 +276,7 @@ EAPI Eina_Simple_XML_Node_CData * eina_simple_xml_node_cdata_new(Eina_Simple_XML | |||
272 | /** | 276 | /** |
273 | * Remove cdata from parent and delete it. | 277 | * Remove cdata from parent and delete it. |
274 | * | 278 | * |
275 | * @param cdata to release memory. | 279 | * @param node to release memory. |
276 | */ | 280 | */ |
277 | EAPI void eina_simple_xml_node_cdata_free(Eina_Simple_XML_Node_Data *node); | 281 | EAPI void eina_simple_xml_node_cdata_free(Eina_Simple_XML_Node_Data *node); |
278 | 282 | ||
@@ -282,8 +286,8 @@ EAPI void eina_simple_xml_node_cdata_free(Eina_Simple_XML_Node_Data *node); | |||
282 | * | 286 | * |
283 | * @param parent if provided, will be set in the resulting structure | 287 | * @param parent if provided, will be set in the resulting structure |
284 | * as well as the processing will be appended to children list. | 288 | * as well as the processing will be appended to children list. |
285 | * @param content string to be used. Must not be NULL. | 289 | * @param contents string to be used. Must not be NULL. |
286 | * @param length size in bytes of @a content. | 290 | * @param length size in bytes of @a contents. |
287 | * | 291 | * |
288 | * @return newly allocated memory or NULL on error. This memory should be | 292 | * @return newly allocated memory or NULL on error. This memory should be |
289 | * released with eina_simple_xml_node_processing_free() or indirectly | 293 | * released with eina_simple_xml_node_processing_free() or indirectly |
@@ -294,7 +298,7 @@ EAPI Eina_Simple_XML_Node_Processing * eina_simple_xml_node_processing_new(Eina_ | |||
294 | /** | 298 | /** |
295 | * Remove processing from parent and delete it. | 299 | * Remove processing from parent and delete it. |
296 | * | 300 | * |
297 | * @param processing to release memory. | 301 | * @param node processing to release memory. |
298 | */ | 302 | */ |
299 | EAPI void eina_simple_xml_node_processing_free(Eina_Simple_XML_Node_Data *node); | 303 | EAPI void eina_simple_xml_node_processing_free(Eina_Simple_XML_Node_Data *node); |
300 | 304 | ||
@@ -304,8 +308,8 @@ EAPI void eina_simple_xml_node_processing_free(Eina_Simple_XML_Node_Data *node); | |||
304 | * | 308 | * |
305 | * @param parent if provided, will be set in the resulting structure | 309 | * @param parent if provided, will be set in the resulting structure |
306 | * as well as the doctype will be appended to children list. | 310 | * as well as the doctype will be appended to children list. |
307 | * @param content string to be used. Must not be NULL. | 311 | * @param contents string to be used. Must not be NULL. |
308 | * @param length size in bytes of @a content. | 312 | * @param length size in bytes of @a contents. |
309 | * | 313 | * |
310 | * @return newly allocated memory or NULL on error. This memory should be | 314 | * @return newly allocated memory or NULL on error. This memory should be |
311 | * released with eina_simple_xml_node_doctype_free() or indirectly | 315 | * released with eina_simple_xml_node_doctype_free() or indirectly |
@@ -316,7 +320,7 @@ EAPI Eina_Simple_XML_Node_Doctype * eina_simple_xml_node_doctype_new(Eina_Simple | |||
316 | /** | 320 | /** |
317 | * Remove doctype from parent and delete it. | 321 | * Remove doctype from parent and delete it. |
318 | * | 322 | * |
319 | * @param doctype to release memory. | 323 | * @param node doctype to release memory. |
320 | */ | 324 | */ |
321 | EAPI void eina_simple_xml_node_doctype_free(Eina_Simple_XML_Node_Data *node); | 325 | EAPI void eina_simple_xml_node_doctype_free(Eina_Simple_XML_Node_Data *node); |
322 | 326 | ||
@@ -326,8 +330,8 @@ EAPI void eina_simple_xml_node_doctype_free(Eina_Simple_XML_Node_Data *node); | |||
326 | * | 330 | * |
327 | * @param parent if provided, will be set in the resulting structure | 331 | * @param parent if provided, will be set in the resulting structure |
328 | * as well as the comment will be appended to children list. | 332 | * as well as the comment will be appended to children list. |
329 | * @param content string to be used. Must not be NULL. | 333 | * @param contents string to be used. Must not be NULL. |
330 | * @param length size in bytes of @a content. | 334 | * @param length size in bytes of @a contents. |
331 | * | 335 | * |
332 | * @return newly allocated memory or NULL on error. This memory should be | 336 | * @return newly allocated memory or NULL on error. This memory should be |
333 | * released with eina_simple_xml_node_comment_free() or indirectly | 337 | * released with eina_simple_xml_node_comment_free() or indirectly |
@@ -338,7 +342,7 @@ EAPI Eina_Simple_XML_Node_Comment * eina_simple_xml_node_comment_new(Eina_Simple | |||
338 | /** | 342 | /** |
339 | * Remove comment from parent and delete it. | 343 | * Remove comment from parent and delete it. |
340 | * | 344 | * |
341 | * @param comment to release memory. | 345 | * @param node comment to release memory. |
342 | */ | 346 | */ |
343 | EAPI void eina_simple_xml_node_comment_free(Eina_Simple_XML_Node_Data *node); | 347 | EAPI void eina_simple_xml_node_comment_free(Eina_Simple_XML_Node_Data *node); |
344 | 348 | ||
@@ -370,7 +374,7 @@ EAPI void eina_simple_xml_node_root_free(Eina_Simple_XML_Node_Root *root); | |||
370 | * @param node the base node to convert. | 374 | * @param node the base node to convert. |
371 | * @param indent indentation string, or NULL to disable it. | 375 | * @param indent indentation string, or NULL to disable it. |
372 | * | 376 | * |
373 | * @param NULL on errors or a newly allocated string on success. | 377 | * @return NULL on errors or a newly allocated string on success. |
374 | */ | 378 | */ |
375 | EAPI char * eina_simple_xml_node_dump(Eina_Simple_XML_Node *node, const char *indent); | 379 | EAPI char * eina_simple_xml_node_dump(Eina_Simple_XML_Node *node, const char *indent); |
376 | 380 | ||
diff --git a/libraries/eina/src/include/eina_str.h b/libraries/eina/src/include/eina_str.h index 8b52ab2..2913fbf 100644 --- a/libraries/eina/src/include/eina_str.h +++ b/libraries/eina/src/include/eina_str.h | |||
@@ -161,14 +161,14 @@ EAPI Eina_Bool eina_str_has_extension(const char *str, const char *ext) EI | |||
161 | /** | 161 | /** |
162 | * @brief Split a string using a delimiter. | 162 | * @brief Split a string using a delimiter. |
163 | * | 163 | * |
164 | * @param str The string to split. | 164 | * @param string The string to split. |
165 | * @param delim The string which specifies the places at which to split the string. | 165 | * @param delimiter The string which specifies the places at which to split the string. |
166 | * @param max_tokens The maximum number of strings to split string into. | 166 | * @param max_tokens The maximum number of strings to split string into. |
167 | * @return A newly-allocated NULL-terminated array of strings or NULL if it | 167 | * @return A newly-allocated NULL-terminated array of strings or NULL if it |
168 | * fails to allocate the array. | 168 | * fails to allocate the array. |
169 | * | 169 | * |
170 | * This functin splits @p str into a maximum of @p max_tokens pieces, | 170 | * This functin splits @p string into a maximum of @p max_tokens pieces, |
171 | * using the given delimiter @p delim. @p delim is not included in any | 171 | * using the given delimiter @p delimiter. @p delimiter is not included in any |
172 | * of the resulting strings, unless @p max_tokens is reached. If | 172 | * of the resulting strings, unless @p max_tokens is reached. If |
173 | * @p max_tokens is less than @c 1, the string is splitted completely. If | 173 | * @p max_tokens is less than @c 1, the string is splitted completely. If |
174 | * @p max_tokens is reached, the last string in the returned string | 174 | * @p max_tokens is reached, the last string in the returned string |
@@ -185,16 +185,16 @@ EAPI char **eina_str_split(const char *string, const char *delimiter, i | |||
185 | /** | 185 | /** |
186 | * @brief Split a string using a delimiter and returns number of elements. | 186 | * @brief Split a string using a delimiter and returns number of elements. |
187 | * | 187 | * |
188 | * @param str The string to split. | 188 | * @param string The string to split. |
189 | * @param delim The string which specifies the places at which to split the string. | 189 | * @param delimiter The string which specifies the places at which to split the string. |
190 | * @param max_tokens The maximum number of strings to split string into. | 190 | * @param max_tokens The maximum number of strings to split string into. |
191 | * @param elements Where to return the number of elements in returned | 191 | * @param elements Where to return the number of elements in returned |
192 | * array (not counting the terminating @c NULL). May be @c NULL. | 192 | * array (not counting the terminating @c NULL). May be @c NULL. |
193 | * @return A newly-allocated NULL-terminated array of strings or NULL if it | 193 | * @return A newly-allocated NULL-terminated array of strings or NULL if it |
194 | * fails to allocate the array. | 194 | * fails to allocate the array. |
195 | * | 195 | * |
196 | * This functin splits @p str into a maximum of @p max_tokens pieces, | 196 | * This function splits @p string into a maximum of @p max_tokens pieces, |
197 | * using the given delimiter @p delim. @p delim is not included in any | 197 | * using the given delimiter @p delimiter. @p delimiter is not included in any |
198 | * of the resulting strings, unless @p max_tokens is reached. If | 198 | * of the resulting strings, unless @p max_tokens is reached. If |
199 | * @p max_tokens is less than @c 1, the string is splitted completely. If | 199 | * @p max_tokens is less than @c 1, the string is splitted completely. If |
200 | * @p max_tokens is reached, the last string in the returned string | 200 | * @p max_tokens is reached, the last string in the returned string |
diff --git a/libraries/eina/src/include/eina_strbuf.h b/libraries/eina/src/include/eina_strbuf.h index 7043575..34c200f 100644 --- a/libraries/eina/src/include/eina_strbuf.h +++ b/libraries/eina/src/include/eina_strbuf.h | |||
@@ -99,6 +99,24 @@ EAPI Eina_Strbuf *eina_strbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | |||
99 | EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | 99 | EAPI Eina_Strbuf *eina_strbuf_manage_new(char *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * @brief Create a new string buffer using the passed string. The passed | ||
103 | * string is used directly as the buffer, it's somehow the opposite function of | ||
104 | * @ref eina_strbuf_string_steal . The passed string must be malloced. | ||
105 | * | ||
106 | * @param str the string to manage | ||
107 | * @param length the length of the string. | ||
108 | * @return Newly allocated string buffer instance. | ||
109 | * | ||
110 | * This function creates a new string buffer. On error, @c NULL is | ||
111 | * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To | ||
112 | * free the resources, use eina_strbuf_free(). | ||
113 | * | ||
114 | * @see eina_strbuf_manage_new() | ||
115 | * @since 1.2.0 | ||
116 | */ | ||
117 | EAPI Eina_Strbuf *eina_strbuf_manage_new_length(char *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | ||
118 | |||
119 | /** | ||
102 | * @brief Free a string buffer. | 120 | * @brief Free a string buffer. |
103 | * | 121 | * |
104 | * @param buf The string buffer to free. | 122 | * @param buf The string buffer to free. |
diff --git a/libraries/eina/src/include/eina_stringshare.h b/libraries/eina/src/include/eina_stringshare.h index af58add..862b2b2 100644 --- a/libraries/eina/src/include/eina_stringshare.h +++ b/libraries/eina/src/include/eina_stringshare.h | |||
@@ -289,6 +289,7 @@ EAPI void eina_stringshare_del(const char *str); | |||
289 | * | 289 | * |
290 | * @param str the shared string to know the length. It is safe to | 290 | * @param str the shared string to know the length. It is safe to |
291 | * give NULL, in that case -1 is returned. | 291 | * give NULL, in that case -1 is returned. |
292 | * @return The length of a shared string. | ||
292 | * | 293 | * |
293 | * This function is a cheap way to known the length of a shared | 294 | * This function is a cheap way to known the length of a shared |
294 | * string. Note that if the given pointer is not shared, bad | 295 | * string. Note that if the given pointer is not shared, bad |
diff --git a/libraries/eina/src/include/eina_types.h b/libraries/eina/src/include/eina_types.h index 8c77cdf..1653949 100644 --- a/libraries/eina/src/include/eina_types.h +++ b/libraries/eina/src/include/eina_types.h | |||
@@ -251,6 +251,10 @@ typedef int (*Eina_Compare_Cb)(const void *data1, const void *data2); | |||
251 | */ | 251 | */ |
252 | #define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function) | 252 | #define EINA_COMPARE_CB(function) ((Eina_Compare_Cb)function) |
253 | 253 | ||
254 | /** | ||
255 | * @typedef Eina_Each_Cb | ||
256 | * A callback type used when iterating over a container. | ||
257 | */ | ||
254 | typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata); | 258 | typedef Eina_Bool (*Eina_Each_Cb)(const void *container, void *data, void *fdata); |
255 | 259 | ||
256 | /** | 260 | /** |
diff --git a/libraries/eina/src/include/eina_unicode.h b/libraries/eina/src/include/eina_unicode.h index aed59af..2bbfe45 100644 --- a/libraries/eina/src/include/eina_unicode.h +++ b/libraries/eina/src/include/eina_unicode.h | |||
@@ -68,7 +68,16 @@ EAPI Eina_Unicode *eina_unicode_strdup(const Eina_Unicode *text) EINA_WARN_UNUSE | |||
68 | 68 | ||
69 | 69 | ||
70 | /** | 70 | /** |
71 | * @brief Same as strdup but cuts on n. Assumes n < len | 71 | * @brief Same as strdup but cuts on the given size. Assumes n < len |
72 | * | ||
73 | * @param text The text to duplicate. | ||
74 | * @param n The maximum size of the text to duplicate. | ||
75 | * @return The duplicated string. | ||
76 | * | ||
77 | * This function duplicates @p text. The resuting string is cut on @p | ||
78 | * n. @p n is assumed to be lesser (<) than the length of @p | ||
79 | * text. When not needed anymore, the returned string must be freed. | ||
80 | * | ||
72 | * @since 1.1.0 | 81 | * @since 1.1.0 |
73 | */ | 82 | */ |
74 | EAPI Eina_Unicode *eina_unicode_strndup(const Eina_Unicode *text, size_t n) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; | 83 | EAPI Eina_Unicode *eina_unicode_strndup(const Eina_Unicode *text, size_t n) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; |
@@ -107,9 +116,9 @@ EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NONNULL | |||
107 | 116 | ||
108 | 117 | ||
109 | /** | 118 | /** |
110 | * Reads UTF8 bytes from @buf, starting at *@index and returns | 119 | * Reads UTF8 bytes from @p buf, starting at @p iindex and returns |
111 | * the decoded code point at iindex offset, and advances iindex | 120 | * the decoded code point at @p iindex offset, and advances @p iindex |
112 | * to the next code point after this. iindex is always advanced, | 121 | * to the next code point after this. @p iindex is always advanced, |
113 | * unless if the advancement is after the NULL. | 122 | * unless if the advancement is after the NULL. |
114 | * On error: return a codepoint between DC80 to DCFF where the low 8 bits | 123 | * On error: return a codepoint between DC80 to DCFF where the low 8 bits |
115 | * are the byte's value. | 124 | * are the byte's value. |
@@ -122,9 +131,9 @@ EAPI Eina_Unicode *eina_unicode_escape(const Eina_Unicode *str) EINA_ARG_NONNULL | |||
122 | EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2); | 131 | EAPI Eina_Unicode eina_unicode_utf8_get_next(const char *buf, int *iindex) EINA_ARG_NONNULL(1, 2); |
123 | 132 | ||
124 | /** | 133 | /** |
125 | * Reads UTF8 bytes from @buf, starting at *@iindex and returns | 134 | * Reads UTF8 bytes from @p buf, starting at @p iindex and returns |
126 | * the decoded code point at iindex offset, and moves iindex | 135 | * the decoded code point at @p iindex offset, and moves à p iindex |
127 | * to the previous code point. iindex is always moved, as long | 136 | * to the previous code point. @p iindex is always moved, as long |
128 | * as it's not past the start of the string. | 137 | * as it's not past the start of the string. |
129 | * On error: return a codepoint between DC80 to DCFF where the low 8 bits | 138 | * On error: return a codepoint between DC80 to DCFF where the low 8 bits |
130 | * are the byte's value. | 139 | * are the byte's value. |
diff --git a/libraries/eina/src/include/eina_ustrbuf.h b/libraries/eina/src/include/eina_ustrbuf.h index f68cb7b..9710c42 100644 --- a/libraries/eina/src/include/eina_ustrbuf.h +++ b/libraries/eina/src/include/eina_ustrbuf.h | |||
@@ -65,7 +65,25 @@ EAPI Eina_UStrbuf *eina_ustrbuf_new(void) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | |||
65 | * @see eina_ustrbuf_string_get() | 65 | * @see eina_ustrbuf_string_get() |
66 | * @since 1.1.0 | 66 | * @since 1.1.0 |
67 | */ | 67 | */ |
68 | EAPI Eina_Strbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | 68 | EAPI Eina_UStrbuf *eina_ustrbuf_manage_new(Eina_Unicode *str) EINA_MALLOC EINA_WARN_UNUSED_RESULT; |
69 | |||
70 | /** | ||
71 | * @brief Create a new string buffer using the passed string. The passed | ||
72 | * string is used directly as the buffer, it's somehow the opposite function of | ||
73 | * @ref eina_ustrbuf_string_steal . The passed string must be malloced. | ||
74 | * | ||
75 | * @param str the string to manage | ||
76 | * @param length the length of the string. | ||
77 | * @return Newly allocated string buffer instance. | ||
78 | * | ||
79 | * This function creates a new string buffer. On error, @c NULL is | ||
80 | * returned and Eina error is set to #EINA_ERROR_OUT_OF_MEMORY. To | ||
81 | * free the resources, use eina_ustrbuf_free(). | ||
82 | * | ||
83 | * @see eina_ustrbuf_manage_new() | ||
84 | * @since 1.2.0 | ||
85 | */ | ||
86 | EAPI Eina_UStrbuf *eina_ustrbuf_manage_new_length(Eina_Unicode *str, size_t length) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | ||
69 | 87 | ||
70 | /** | 88 | /** |
71 | * @brief Free a string buffer. | 89 | * @brief Free a string buffer. |
diff --git a/libraries/eina/src/include/eina_value.h b/libraries/eina/src/include/eina_value.h new file mode 100644 index 0000000..846c4ef --- /dev/null +++ b/libraries/eina/src/include/eina_value.h | |||
@@ -0,0 +1,3114 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2012 ProFUSION embedded systems | ||
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 | #ifndef EINA_VALUE_H_ | ||
20 | #define EINA_VALUE_H_ | ||
21 | |||
22 | #include "eina_types.h" | ||
23 | #include "eina_fp.h" /* defines int64_t and uint64_t */ | ||
24 | #include "eina_inarray.h" | ||
25 | #include "eina_list.h" | ||
26 | #include "eina_hash.h" | ||
27 | #include <stdarg.h> | ||
28 | |||
29 | /** | ||
30 | * @addtogroup Eina_Data_Types_Group Data Types | ||
31 | * | ||
32 | * @since 1.2 | ||
33 | * | ||
34 | * @{ | ||
35 | */ | ||
36 | |||
37 | /** | ||
38 | * @addtogroup Eina_Containers_Group Containers | ||
39 | * | ||
40 | * @{ | ||
41 | */ | ||
42 | |||
43 | /** | ||
44 | * @defgroup Eina_Value_Group Generic Value Storage | ||
45 | * | ||
46 | * @{ | ||
47 | */ | ||
48 | |||
49 | |||
50 | /** | ||
51 | * @typedef Eina_Value | ||
52 | * Store generic values. | ||
53 | * | ||
54 | * @since 1.2 | ||
55 | */ | ||
56 | typedef struct _Eina_Value Eina_Value; | ||
57 | |||
58 | /** | ||
59 | * @typedef Eina_Value_Type | ||
60 | * Describes the data contained by the value | ||
61 | * | ||
62 | * @since 1.2 | ||
63 | */ | ||
64 | typedef struct _Eina_Value_Type Eina_Value_Type; | ||
65 | |||
66 | /** | ||
67 | * @typedef Eina_Value_Union | ||
68 | * Union of all known value types. | ||
69 | * | ||
70 | * @since 1.2 | ||
71 | */ | ||
72 | typedef union _Eina_Value_Union Eina_Value_Union; | ||
73 | |||
74 | /** | ||
75 | * @union _Eina_Value_Union | ||
76 | * All possible value types. | ||
77 | * | ||
78 | * @since 1.2 | ||
79 | */ | ||
80 | union _Eina_Value_Union | ||
81 | { | ||
82 | unsigned char buf[8]; /**< just hold 8-bytes, more goes into ptr */ | ||
83 | void *ptr; /**< used as generic pointer */ | ||
84 | uint64_t _guarantee; /**< guarantees 8-byte alignment */ | ||
85 | }; | ||
86 | |||
87 | /** | ||
88 | * @var EINA_VALUE_TYPE_UCHAR | ||
89 | * manages unsigned char type. | ||
90 | * | ||
91 | * @since 1.2 | ||
92 | */ | ||
93 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UCHAR; | ||
94 | |||
95 | /** | ||
96 | * @var EINA_VALUE_TYPE_USHORT | ||
97 | * manages unsigned short type. | ||
98 | * | ||
99 | * @since 1.2 | ||
100 | */ | ||
101 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_USHORT; | ||
102 | |||
103 | /** | ||
104 | * @var EINA_VALUE_TYPE_UINT | ||
105 | * manages unsigned int type. | ||
106 | * | ||
107 | * @since 1.2 | ||
108 | */ | ||
109 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT; | ||
110 | |||
111 | /** | ||
112 | * @var EINA_VALUE_TYPE_ULONG | ||
113 | * manages unsigned long type. | ||
114 | * | ||
115 | * @since 1.2 | ||
116 | */ | ||
117 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ULONG; | ||
118 | |||
119 | /** | ||
120 | * @var EINA_VALUE_TYPE_UINT64 | ||
121 | * manages unsigned integer of 64 bits type. | ||
122 | * | ||
123 | * @since 1.2 | ||
124 | */ | ||
125 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT64; | ||
126 | |||
127 | /** | ||
128 | * @var EINA_VALUE_TYPE_CHAR | ||
129 | * manages char type. | ||
130 | * | ||
131 | * @since 1.2 | ||
132 | */ | ||
133 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_CHAR; | ||
134 | |||
135 | /** | ||
136 | * @var EINA_VALUE_TYPE_SHORT | ||
137 | * manages short type. | ||
138 | * | ||
139 | * @since 1.2 | ||
140 | */ | ||
141 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_SHORT; | ||
142 | |||
143 | /** | ||
144 | * @var EINA_VALUE_TYPE_INT | ||
145 | * manages int type. | ||
146 | * | ||
147 | * @since 1.2 | ||
148 | */ | ||
149 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT; | ||
150 | |||
151 | /** | ||
152 | * @var EINA_VALUE_TYPE_LONG | ||
153 | * manages long type. | ||
154 | * | ||
155 | * @since 1.2 | ||
156 | */ | ||
157 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LONG; | ||
158 | |||
159 | /** | ||
160 | * @var EINA_VALUE_TYPE_INT64 | ||
161 | * manages integer of 64 bits type. | ||
162 | * | ||
163 | * @since 1.2 | ||
164 | */ | ||
165 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_INT64; | ||
166 | |||
167 | /** | ||
168 | * @var EINA_VALUE_TYPE_FLOAT | ||
169 | * manages float type. | ||
170 | * | ||
171 | * @since 1.2 | ||
172 | */ | ||
173 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_FLOAT; | ||
174 | |||
175 | /** | ||
176 | * @var EINA_VALUE_TYPE_DOUBLE | ||
177 | * manages double type. | ||
178 | * | ||
179 | * @since 1.2 | ||
180 | */ | ||
181 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_DOUBLE; | ||
182 | |||
183 | /** | ||
184 | * @var EINA_VALUE_TYPE_STRINGSHARE | ||
185 | * manages stringshared string type. | ||
186 | * | ||
187 | * @since 1.2 | ||
188 | */ | ||
189 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRINGSHARE; | ||
190 | |||
191 | /** | ||
192 | * @var EINA_VALUE_TYPE_STRING | ||
193 | * manages string type. | ||
194 | * | ||
195 | * @since 1.2 | ||
196 | */ | ||
197 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRING; | ||
198 | |||
199 | |||
200 | /** | ||
201 | * @var EINA_VALUE_TYPE_ARRAY | ||
202 | * | ||
203 | * manages array type. Use the value get/set for arrays: | ||
204 | * @li eina_value_array_get() and eina_value_array_set() | ||
205 | * @li eina_value_array_vget() and eina_value_array_vset() | ||
206 | * @li eina_value_array_pget() and eina_value_array_pset() | ||
207 | * | ||
208 | * eina_value_set() takes an #Eina_Value_Array where just @c subtype | ||
209 | * and @c step are used. If there is an @c array, it will be adopted | ||
210 | * and its contents must be properly configurable as @c subtype | ||
211 | * expects. eina_value_pset() takes a pointer to an #Eina_Value_Array. | ||
212 | * For your convenience, use eina_value_array_setup(). | ||
213 | * | ||
214 | * eina_value_get() and eina_value_pget() takes a pointer to | ||
215 | * #Eina_Value_Array, it's an exact copy of the current structure in | ||
216 | * use by value, no copies are done. | ||
217 | * | ||
218 | * @since 1.2 | ||
219 | */ | ||
220 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ARRAY; | ||
221 | |||
222 | /** | ||
223 | * @var EINA_VALUE_TYPE_LIST | ||
224 | * | ||
225 | * manages list type. Use the value get/set for lists: | ||
226 | * @li eina_value_list_get() and eina_value_list_set() | ||
227 | * @li eina_value_list_vget() and eina_value_list_vset() | ||
228 | * @li eina_value_list_pget() and eina_value_list_pset() | ||
229 | * | ||
230 | * eina_value_set() takes an #Eina_Value_List where just @c subtype is | ||
231 | * used. If there is an @c list, it will be adopted and its contents | ||
232 | * must be properly configurable as @c subtype | ||
233 | * expects. eina_value_pset() takes a pointer to an #Eina_Value_List. | ||
234 | * For your convenience, use eina_value_list_setup(). | ||
235 | * | ||
236 | * eina_value_get() and eina_value_pget() takes a pointer to | ||
237 | * #Eina_Value_List, it's an exact copy of the current structure in | ||
238 | * use by value, no copies are done. | ||
239 | * | ||
240 | * @since 1.2 | ||
241 | */ | ||
242 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LIST; | ||
243 | |||
244 | /** | ||
245 | * @var EINA_VALUE_TYPE_HASH | ||
246 | * | ||
247 | * manages hash type. Use the value get/set for hashes: | ||
248 | * @li eina_value_hash_get() and eina_value_hash_set() | ||
249 | * @li eina_value_hash_vget() and eina_value_hash_vset() | ||
250 | * @li eina_value_hash_pget() and eina_value_hash_pset() | ||
251 | * | ||
252 | * eina_value_set() takes an #Eina_Value_Hash where just @c subtype | ||
253 | * and @c buckets_power_size are used. If there is an @c hash, it will | ||
254 | * be adopted and its contents must be properly configurable as @c | ||
255 | * subtype expects. eina_value_pset() takes a pointer to an | ||
256 | * #Eina_Value_Hash. For your convenience, use | ||
257 | * eina_value_hash_setup(). | ||
258 | * | ||
259 | * eina_value_get() and eina_value_pget() takes a pointer to | ||
260 | * #Eina_Value_Hash, it's an exact copy of the current structure in | ||
261 | * use by value, no copies are done. | ||
262 | * | ||
263 | * @note be aware that hash data is always an allocated memory of size | ||
264 | * defined by @c subtype->value_size. If your @c subtype is an | ||
265 | * integer, add as data malloc(sizeof(int)). If your @c subtype | ||
266 | * is an string, add as data malloc(sizeof(char*)) and this data | ||
267 | * value must point to strdup(string)! | ||
268 | * | ||
269 | * @since 1.2 | ||
270 | */ | ||
271 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_HASH; | ||
272 | |||
273 | /** | ||
274 | * @var EINA_VALUE_TYPE_TIMEVAL | ||
275 | * manages 'struct timeval' type | ||
276 | * | ||
277 | * eina_value_set() takes a "struct timeval" from sys/time.h. | ||
278 | * eina_value_pset() takes a pointer to "struct timeval". | ||
279 | * | ||
280 | * eina_value_get() and eina_value_pget() takes a pointer to "struct | ||
281 | * timeval" and it's an exact copy of value. | ||
282 | * | ||
283 | * @since 1.2 | ||
284 | */ | ||
285 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_TIMEVAL; | ||
286 | |||
287 | /** | ||
288 | * @var EINA_VALUE_TYPE_BLOB | ||
289 | * manages blob of bytes type, see @ref Eina_Value_Blob | ||
290 | * | ||
291 | * eina_value_set() takes an #Eina_Value_Blob | ||
292 | * eina_value_pset() takes a pointer to #Eina_Value_Blob. | ||
293 | * | ||
294 | * eina_value_get() and eina_value_pget() takes a pointer to | ||
295 | * #Eina_Value_Blob and it's an exact copy of value, no allocations | ||
296 | * are made. | ||
297 | * | ||
298 | * Memory is untouched unless you provide @c ops (operations) pointer. | ||
299 | * | ||
300 | * @since 1.2 | ||
301 | */ | ||
302 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_BLOB; | ||
303 | |||
304 | /** | ||
305 | * @var EINA_VALUE_TYPE_STRUCT | ||
306 | * | ||
307 | * manages struct type. Use the value get/set for structs: | ||
308 | * @li eina_value_struct_get() and eina_value_struct_set() | ||
309 | * @li eina_value_struct_vget() and eina_value_struct_vset() | ||
310 | * @li eina_value_struct_pget() and eina_value_struct_pset() | ||
311 | * | ||
312 | * eina_value_set() takes an #Eina_Value_Struct where just @c desc is | ||
313 | * used. If there is an @c memory, it will be adopted and its contents | ||
314 | * must be properly configurable as @c desc expects. eina_value_pset() | ||
315 | * takes a pointer to an #Eina_Value_Struct. For your convenience, use | ||
316 | * eina_value_struct_setup(). | ||
317 | * | ||
318 | * eina_value_get() and eina_value_pget() takes a pointer to | ||
319 | * #Eina_Value_Struct, it's an exact copy of the current structure in | ||
320 | * use by value, no copies are done. | ||
321 | * | ||
322 | * @since 1.2 | ||
323 | */ | ||
324 | EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRUCT; | ||
325 | |||
326 | /** | ||
327 | * @var EINA_ERROR_VALUE_FAILED | ||
328 | * Error identifier corresponding to value check failure. | ||
329 | * | ||
330 | * @since 1.2 | ||
331 | */ | ||
332 | EAPI extern int EINA_ERROR_VALUE_FAILED; | ||
333 | |||
334 | /** | ||
335 | * @defgroup Eina_Value_Value_Group Generic Value management | ||
336 | * | ||
337 | * @{ | ||
338 | */ | ||
339 | |||
340 | /** | ||
341 | * @struct _Eina_Value | ||
342 | * defines the contents of a value | ||
343 | * | ||
344 | * @since 1.2 | ||
345 | */ | ||
346 | struct _Eina_Value | ||
347 | { | ||
348 | const Eina_Value_Type *type; /**< how to access values */ | ||
349 | Eina_Value_Union value; /**< to be accessed with type descriptor */ | ||
350 | }; | ||
351 | |||
352 | /** | ||
353 | * @brief Create generic value storage. | ||
354 | * @param type how to manage this value. | ||
355 | * @return The new value or @c NULL on failure. | ||
356 | * | ||
357 | * Create a new generic value storage. The members are managed using | ||
358 | * the description specified by @a type. | ||
359 | * | ||
360 | * Some types may specify more operations: | ||
361 | * eg. #EINA_VALUE_TYPE_ARRAY uses eina_value_array_set(), | ||
362 | * eina_value_array_get() and so on. | ||
363 | * | ||
364 | * On failure, @c NULL is returned and either #EINA_ERROR_OUT_OF_MEMORY or | ||
365 | * #EINA_ERROR_VALUE_FAILED is set. | ||
366 | * | ||
367 | * @note this calls creates from mempool and then uses | ||
368 | * eina_value_setup(). Consider using eina_value_flush() and | ||
369 | * eina_value_setup() instead to avoid memory allocations. | ||
370 | * | ||
371 | * @see eina_value_free() | ||
372 | * | ||
373 | * @since 1.2 | ||
374 | */ | ||
375 | EAPI Eina_Value *eina_value_new(const Eina_Value_Type *type) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT; | ||
376 | |||
377 | /** | ||
378 | * @brief Free value and its data. | ||
379 | * @param value value object | ||
380 | * | ||
381 | * @see eina_value_flush() | ||
382 | * | ||
383 | * @since 1.2 | ||
384 | */ | ||
385 | EAPI void eina_value_free(Eina_Value *value) EINA_ARG_NONNULL(1); | ||
386 | |||
387 | |||
388 | /** | ||
389 | * @brief Initialize generic value storage. | ||
390 | * @param value value object | ||
391 | * @param type how to manage this value. | ||
392 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
393 | * | ||
394 | * Initializes existing generic value storage. The members are managed using the | ||
395 | * description specified by @a type. | ||
396 | * | ||
397 | * Some types may specify more operations, as an example | ||
398 | * #EINA_VALUE_TYPE_ARRAY uses eina_value_array_set(), | ||
399 | * eina_value_array_get() and so on. | ||
400 | * | ||
401 | * @note Existing contents are ignored! If the value was previously used, then | ||
402 | * use eina_value_flush() first. | ||
403 | * | ||
404 | * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY | ||
405 | * or #EINA_ERROR_VALUE_FAILED is set. | ||
406 | * | ||
407 | * @see eina_value_flush() | ||
408 | * | ||
409 | * @since 1.2 | ||
410 | */ | ||
411 | static inline Eina_Bool eina_value_setup(Eina_Value *value, | ||
412 | const Eina_Value_Type *type) EINA_ARG_NONNULL(1, 2); | ||
413 | |||
414 | /** | ||
415 | * @brief Create generic value storage. | ||
416 | * @param value value object | ||
417 | * | ||
418 | * Releases all the resources associated with an #Eina_Value. The | ||
419 | * value must be already set with eina_value_setup() or | ||
420 | * eina_value_new(). | ||
421 | * | ||
422 | * After this call returns, the contents of the value are undefined, | ||
423 | * but the value can be reused by calling eina_value_setup() again. | ||
424 | * | ||
425 | * @see eina_value_setup() | ||
426 | * @see eina_value_free() | ||
427 | * | ||
428 | * @since 1.2 | ||
429 | */ | ||
430 | static inline void eina_value_flush(Eina_Value *value) EINA_ARG_NONNULL(1); | ||
431 | |||
432 | /** | ||
433 | * @brief Copy generic value storage. | ||
434 | * @param value source value object | ||
435 | * @param copy destination value object | ||
436 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
437 | * | ||
438 | * The @a copy object is considered internalized and its existing | ||
439 | * contents are overwritten (just as if eina_value_flush() was called on | ||
440 | * it). | ||
441 | * | ||
442 | * The copy happens by calling eina_value_setup() on @a copy, followed | ||
443 | * by getting the contents of @a value and setting it to @a copy. | ||
444 | * | ||
445 | * @since 1.2 | ||
446 | */ | ||
447 | EAPI Eina_Bool eina_value_copy(const Eina_Value *value, | ||
448 | Eina_Value *copy) EINA_ARG_NONNULL(1, 2); | ||
449 | |||
450 | /** | ||
451 | * @brief Compare generic value storage. | ||
452 | * @param a left side of comparison | ||
453 | * @param b right side of comparison | ||
454 | * @return less than zero if a < b, greater than zero if a > b, zero | ||
455 | * if a == b | ||
456 | * | ||
457 | * @since 1.2 | ||
458 | */ | ||
459 | static inline int eina_value_compare(const Eina_Value *a, | ||
460 | const Eina_Value *b) EINA_ARG_NONNULL(1, 2); | ||
461 | |||
462 | /** | ||
463 | * @brief Set the generic value. | ||
464 | * @param value source value object | ||
465 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
466 | * | ||
467 | * The variable argument is dependent on chosen type. The list for | ||
468 | * basic types: | ||
469 | * | ||
470 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char | ||
471 | * @li EINA_VALUE_TYPE_USHORT: unsigned short | ||
472 | * @li EINA_VALUE_TYPE_UINT: unsigned int | ||
473 | * @li EINA_VALUE_TYPE_ULONG: unsigned long | ||
474 | * @li EINA_VALUE_TYPE_UINT64: uint64_t | ||
475 | * @li EINA_VALUE_TYPE_CHAR: char | ||
476 | * @li EINA_VALUE_TYPE_SHORT: short | ||
477 | * @li EINA_VALUE_TYPE_INT: int | ||
478 | * @li EINA_VALUE_TYPE_LONG: long | ||
479 | * @li EINA_VALUE_TYPE_INT64: int64_t | ||
480 | * @li EINA_VALUE_TYPE_FLOAT: float | ||
481 | * @li EINA_VALUE_TYPE_DOUBLE: double | ||
482 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char * | ||
483 | * @li EINA_VALUE_TYPE_STRING: const char * | ||
484 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array | ||
485 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List | ||
486 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash | ||
487 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval | ||
488 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob | ||
489 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct | ||
490 | * | ||
491 | * @code | ||
492 | * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT); | ||
493 | * int x = 567; | ||
494 | * eina_value_set(value, 1234); | ||
495 | * eina_value_set(value, x); | ||
496 | * | ||
497 | * eina_value_flush(value); | ||
498 | * | ||
499 | * eina_value_setup(value, EINA_VALUE_TYPE_STRING); | ||
500 | * eina_value_set(value, "hello world!"); | ||
501 | * | ||
502 | * eina_value_free(value); | ||
503 | * @endcode | ||
504 | * | ||
505 | * @note for array member see eina_value_array_set() | ||
506 | * @note for list member see eina_value_list_set() | ||
507 | * @note for hash member see eina_value_hash_set() | ||
508 | * | ||
509 | * @see eina_value_get() | ||
510 | * @see eina_value_vset() | ||
511 | * @see eina_value_pset() | ||
512 | * | ||
513 | * @since 1.2 | ||
514 | */ | ||
515 | static inline Eina_Bool eina_value_set(Eina_Value *value, | ||
516 | ...) EINA_ARG_NONNULL(1); | ||
517 | |||
518 | /** | ||
519 | * @brief Get the generic value. | ||
520 | * @param value source value object | ||
521 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
522 | * | ||
523 | * The value is returned in the variable argument parameter, the | ||
524 | * actual value is type-dependent, but usually it will be what is | ||
525 | * stored inside the object. There shouldn't be any memory allocation, | ||
526 | * thus the contents should @b not be freed. | ||
527 | * | ||
528 | * The variable argument is dependent on chosen type. The list for | ||
529 | * basic types: | ||
530 | * | ||
531 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
532 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
533 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
534 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
535 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
536 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
537 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
538 | * @li EINA_VALUE_TYPE_INT: int* | ||
539 | * @li EINA_VALUE_TYPE_LONG: long* | ||
540 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
541 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
542 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
543 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
544 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
545 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* | ||
546 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
547 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
548 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
549 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
550 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
551 | * | ||
552 | * @code | ||
553 | * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT); | ||
554 | * int x; | ||
555 | * const char *s; | ||
556 | * | ||
557 | * eina_value_set(value, 1234); | ||
558 | * eina_value_get(value, &x); | ||
559 | * | ||
560 | * eina_value_flush(value); | ||
561 | * | ||
562 | * eina_value_setup(value, EINA_VALUE_TYPE_STRING); | ||
563 | * eina_value_set(value, "hello world!"); | ||
564 | * eina_value_get(value, &s); | ||
565 | * | ||
566 | * eina_value_free(value); | ||
567 | * @endcode | ||
568 | * | ||
569 | * @note for array member see eina_value_array_get() | ||
570 | * @note for list member see eina_value_list_get() | ||
571 | * @note for hash member see eina_value_hash_get() | ||
572 | * | ||
573 | * @see eina_value_set() | ||
574 | * @see eina_value_vset() | ||
575 | * @see eina_value_pset() | ||
576 | * | ||
577 | * @since 1.2 | ||
578 | */ | ||
579 | static inline Eina_Bool eina_value_get(const Eina_Value *value, | ||
580 | ...) EINA_ARG_NONNULL(1); | ||
581 | |||
582 | /** | ||
583 | * @brief Set the generic value. | ||
584 | * @param value source value object | ||
585 | * @param args variable argument | ||
586 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
587 | * | ||
588 | * @note for array member see eina_value_array_vset() | ||
589 | * @note for list member see eina_value_list_vset() | ||
590 | * @note for hash member see eina_value_hash_vset() | ||
591 | * | ||
592 | * @see eina_value_vget() | ||
593 | * @see eina_value_set() | ||
594 | * @see eina_value_pset() | ||
595 | * | ||
596 | * @since 1.2 | ||
597 | */ | ||
598 | static inline Eina_Bool eina_value_vset(Eina_Value *value, | ||
599 | va_list args) EINA_ARG_NONNULL(1); | ||
600 | |||
601 | /** | ||
602 | * @brief Get the generic value. | ||
603 | * @param value source value object | ||
604 | * @param args variable argument | ||
605 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
606 | * | ||
607 | * The value is returned in the variable argument parameter, the | ||
608 | * actual value is type-dependent, but usually it will be what is | ||
609 | * stored inside the object. There shouldn't be any memory allocation, | ||
610 | * thus the contents should @b not be freed. | ||
611 | * | ||
612 | * @note for array member see eina_value_array_vget() | ||
613 | * @note for list member see eina_value_list_vget() | ||
614 | * @note for hash member see eina_value_hash_vget() | ||
615 | * | ||
616 | * @see eina_value_vset() | ||
617 | * @see eina_value_get() | ||
618 | * @see eina_value_pget() | ||
619 | * | ||
620 | * @since 1.2 | ||
621 | */ | ||
622 | static inline Eina_Bool eina_value_vget(const Eina_Value *value, | ||
623 | va_list args) EINA_ARG_NONNULL(1); | ||
624 | |||
625 | /** | ||
626 | * @brief Set the generic value from pointer. | ||
627 | * @param value source value object | ||
628 | * @param ptr pointer to specify the contents. | ||
629 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
630 | * | ||
631 | * The pointer type is dependent on chosen value type. The list for | ||
632 | * basic types: | ||
633 | * | ||
634 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
635 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
636 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
637 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
638 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
639 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
640 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
641 | * @li EINA_VALUE_TYPE_INT: int* | ||
642 | * @li EINA_VALUE_TYPE_LONG: long* | ||
643 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
644 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
645 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
646 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
647 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
648 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* | ||
649 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
650 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
651 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
652 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
653 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
654 | * | ||
655 | * @note the pointer contents are written using the size defined by | ||
656 | * type. It can be larger than void* or uint64_t. | ||
657 | * | ||
658 | * @code | ||
659 | * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT); | ||
660 | * int x = 567; | ||
661 | * const char *s = "hello world!"; | ||
662 | * | ||
663 | * eina_value_pset(value, &x); | ||
664 | * | ||
665 | * eina_value_flush(value); | ||
666 | * | ||
667 | * eina_value_setup(value, EINA_VALUE_TYPE_STRING); | ||
668 | * eina_value_pset(value, &s); | ||
669 | * | ||
670 | * eina_value_free(value); | ||
671 | * @endcode | ||
672 | * | ||
673 | * @note for array member see eina_value_array_pset() | ||
674 | * @note for list member see eina_value_list_pset() | ||
675 | * @note for hash member see eina_value_hash_pset() | ||
676 | * | ||
677 | * @see eina_value_pget() | ||
678 | * @see eina_value_set() | ||
679 | * @see eina_value_vset() | ||
680 | * | ||
681 | * @since 1.2 | ||
682 | */ | ||
683 | static inline Eina_Bool eina_value_pset(Eina_Value *value, | ||
684 | const void *ptr) EINA_ARG_NONNULL(1, 2); | ||
685 | |||
686 | /** | ||
687 | * @brief Get the generic value to pointer. | ||
688 | * @param value source value object | ||
689 | * @param ptr pointer to receive the contents. | ||
690 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
691 | * | ||
692 | * The value is returned in pointer contents, the actual value is | ||
693 | * type-dependent, but usually it will be what is stored inside the | ||
694 | * object. There shouldn't be any memory allocation, thus the contents | ||
695 | * should @b not be freed. | ||
696 | * | ||
697 | * The pointer type is dependent on chosen value type. The list for | ||
698 | * basic types: | ||
699 | * | ||
700 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
701 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
702 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
703 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
704 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
705 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
706 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
707 | * @li EINA_VALUE_TYPE_INT: int* | ||
708 | * @li EINA_VALUE_TYPE_LONG: long* | ||
709 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
710 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
711 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
712 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
713 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
714 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* | ||
715 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
716 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
717 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
718 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
719 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
720 | * | ||
721 | * @code | ||
722 | * Eina_Value *value = eina_value_new(EINA_VALUE_TYPE_INT); | ||
723 | * int x; | ||
724 | * const char *s; | ||
725 | * | ||
726 | * eina_value_set(value, 1234); | ||
727 | * eina_value_pget(value, &x); | ||
728 | * | ||
729 | * eina_value_flush(value); | ||
730 | * | ||
731 | * eina_value_setup(value, EINA_VALUE_TYPE_STRING); | ||
732 | * eina_value_set(value, "hello world!"); | ||
733 | * eina_value_pget(value, &s); | ||
734 | * | ||
735 | * eina_value_free(value); | ||
736 | * @endcode | ||
737 | * | ||
738 | * @note for array member see eina_value_array_get() | ||
739 | * @note for list member see eina_value_list_get() | ||
740 | * @note for hash member see eina_value_hash_get() | ||
741 | * | ||
742 | * @see eina_value_set() | ||
743 | * @see eina_value_vset() | ||
744 | * @see eina_value_pset() | ||
745 | * | ||
746 | * @since 1.2 | ||
747 | */ | ||
748 | static inline Eina_Bool eina_value_pget(const Eina_Value *value, | ||
749 | void *ptr) EINA_ARG_NONNULL(1, 2); | ||
750 | |||
751 | /** | ||
752 | * @brief Convert one value to another type. | ||
753 | * @param value source value object. | ||
754 | * @param convert destination value object. | ||
755 | * @return #EINA_TRUE if converted, #EINA_FALSE otherwise. | ||
756 | * | ||
757 | * Converts one value to another trying first @a value type | ||
758 | * @c convert_to() function. If unsuccessful, tries using @c convert_from() | ||
759 | * function in @a convert. | ||
760 | * | ||
761 | * Conversion functions are type defined, and the basic types can convert | ||
762 | * between themselves, but conversion is strict! That is, if | ||
763 | * converting from negative value to unsigned type, it will fail. It | ||
764 | * also fails on value overflow. | ||
765 | * | ||
766 | * It is recommended that all types implement at least convert to | ||
767 | * string, used by eina_value_to_string(). | ||
768 | * | ||
769 | * @note Both objects must have eina_value_setup() called on them beforehand! | ||
770 | * | ||
771 | * @since 1.2 | ||
772 | */ | ||
773 | EAPI Eina_Bool eina_value_convert(const Eina_Value *value, | ||
774 | Eina_Value *convert) EINA_ARG_NONNULL(1, 2); | ||
775 | |||
776 | |||
777 | /** | ||
778 | * @brief Convert value to string. | ||
779 | * @param value value object. | ||
780 | * @return newly allocated memory or @c NULL on failure. | ||
781 | * | ||
782 | * @see eina_value_convert() | ||
783 | * @since 1.2 | ||
784 | */ | ||
785 | EAPI char *eina_value_to_string(const Eina_Value *value) EINA_ARG_NONNULL(1); | ||
786 | |||
787 | /** | ||
788 | * @brief Query value type. | ||
789 | * @param value value object. | ||
790 | * @return type instance or @c NULL if type is invalid. | ||
791 | * | ||
792 | * Check if value type is valid and returns it. A type is invalid if | ||
793 | * it does not exist or if it is using a different version field. | ||
794 | * | ||
795 | * @see eina_value_type_check() | ||
796 | * | ||
797 | * @since 1.2 | ||
798 | */ | ||
799 | static inline const Eina_Value_Type *eina_value_type_get(const Eina_Value *value) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | ||
800 | |||
801 | /** | ||
802 | * @} | ||
803 | */ | ||
804 | |||
805 | |||
806 | /** | ||
807 | * @defgroup Eina_Value_Array_Group Generic Value Array management | ||
808 | * | ||
809 | * @{ | ||
810 | */ | ||
811 | |||
812 | |||
813 | /** | ||
814 | * @typedef Eina_Value_Array | ||
815 | * Value type for #EINA_VALUE_TYPE_ARRAY | ||
816 | * | ||
817 | * @since 1.2 | ||
818 | */ | ||
819 | typedef struct _Eina_Value_Array Eina_Value_Array; | ||
820 | |||
821 | /** | ||
822 | * @struct _Eina_Value_Array | ||
823 | * Used to store the array and its subtype. | ||
824 | */ | ||
825 | struct _Eina_Value_Array | ||
826 | { | ||
827 | const Eina_Value_Type *subtype; /**< how to allocate and access items */ | ||
828 | unsigned int step; /**< how to grow the members array */ | ||
829 | Eina_Inarray *array; /**< the array that holds data, members are of subtype->value_size bytes. */ | ||
830 | }; | ||
831 | |||
832 | /** | ||
833 | * @brief Create generic value storage of type array. | ||
834 | * @param subtype how to manage this array members. | ||
835 | * @param step how to grow the members array. | ||
836 | * @return The new value or @c NULL on failure. | ||
837 | * | ||
838 | * Create a new generic value storage of type array. The members are | ||
839 | * managed using the description specified by @a subtype. | ||
840 | * | ||
841 | * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or | ||
842 | * #EINA_ERROR_VALUE_FAILED is set. | ||
843 | * | ||
844 | * @note this creates from mempool and then uses | ||
845 | * eina_value_array_setup(). @see eina_value_free() @see | ||
846 | * eina_value_array_setup() | ||
847 | * | ||
848 | * @since 1.2 | ||
849 | */ | ||
850 | EAPI Eina_Value *eina_value_array_new(const Eina_Value_Type *subtype, | ||
851 | unsigned int step) EINA_ARG_NONNULL(1); | ||
852 | |||
853 | /** | ||
854 | * @brief Initialize generic value storage of type array. | ||
855 | * @param value value object | ||
856 | * @param subtype how to manage array members. | ||
857 | * @param step how to grow the members array. | ||
858 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
859 | * | ||
860 | * Initializes new generic value storage of type array with the given | ||
861 | * @a subtype. | ||
862 | * | ||
863 | * This is the same as calling eina_value_set() with | ||
864 | * #EINA_VALUE_TYPE_ARRAY followed by eina_value_pset() with the | ||
865 | * #Eina_Value_Array description configured. | ||
866 | * | ||
867 | * @note Existing contents are ignored! If the value was previously used, then | ||
868 | * use eina_value_flush() first. | ||
869 | * | ||
870 | * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY | ||
871 | * or #EINA_ERROR_VALUE_FAILED is set. | ||
872 | * | ||
873 | * @see eina_value_flush() | ||
874 | * | ||
875 | * @since 1.2 | ||
876 | */ | ||
877 | static inline Eina_Bool eina_value_array_setup(Eina_Value *value, | ||
878 | const Eina_Value_Type *subtype, | ||
879 | unsigned int step) EINA_ARG_NONNULL(1, 2); | ||
880 | |||
881 | /** | ||
882 | * @brief Query number of elements in value of array type. | ||
883 | * @param value value object. | ||
884 | * @return number of child elements. | ||
885 | * @since 1.2 | ||
886 | */ | ||
887 | static inline unsigned int eina_value_array_count(const Eina_Value *value); | ||
888 | |||
889 | /** | ||
890 | * @brief Remove element at given position in value of array type. | ||
891 | * @param value value object. | ||
892 | * @param position index of the member | ||
893 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
894 | * @since 1.2 | ||
895 | */ | ||
896 | static inline Eina_Bool eina_value_array_remove(Eina_Value *value, | ||
897 | unsigned int position) EINA_ARG_NONNULL(1); | ||
898 | |||
899 | /** | ||
900 | * @brief Set the generic value in an array member. | ||
901 | * @param value source value object | ||
902 | * @param position index of the member | ||
903 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
904 | * | ||
905 | * The variable argument is dependent on chosen subtype. The list for | ||
906 | * basic types: | ||
907 | * | ||
908 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char | ||
909 | * @li EINA_VALUE_TYPE_USHORT: unsigned short | ||
910 | * @li EINA_VALUE_TYPE_UINT: unsigned int | ||
911 | * @li EINA_VALUE_TYPE_ULONG: unsigned long | ||
912 | * @li EINA_VALUE_TYPE_UINT64: uint64_t | ||
913 | * @li EINA_VALUE_TYPE_CHAR: char | ||
914 | * @li EINA_VALUE_TYPE_SHORT: short | ||
915 | * @li EINA_VALUE_TYPE_INT: int | ||
916 | * @li EINA_VALUE_TYPE_LONG: long | ||
917 | * @li EINA_VALUE_TYPE_INT64: int64_t | ||
918 | * @li EINA_VALUE_TYPE_FLOAT: float | ||
919 | * @li EINA_VALUE_TYPE_DOUBLE: double | ||
920 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char * | ||
921 | * @li EINA_VALUE_TYPE_STRING: const char * | ||
922 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array | ||
923 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List | ||
924 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash | ||
925 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval | ||
926 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob | ||
927 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct | ||
928 | * | ||
929 | * @code | ||
930 | * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); | ||
931 | * int x; | ||
932 | * | ||
933 | * eina_value_array_append(value, 1234); | ||
934 | * eina_value_array_set(value, 0, 5678); | ||
935 | * eina_value_array_get(value, 0, &x); | ||
936 | * eina_value_free(value); | ||
937 | * @endcode | ||
938 | * | ||
939 | * @see eina_value_array_get() | ||
940 | * @see eina_value_array_vset() | ||
941 | * @see eina_value_array_pset() | ||
942 | * @see eina_value_array_insert() | ||
943 | * @see eina_value_array_vinsert() | ||
944 | * @see eina_value_array_pinsert() | ||
945 | * @see eina_value_array_append() | ||
946 | * @see eina_value_array_vappend() | ||
947 | * @see eina_value_array_pappend() | ||
948 | * | ||
949 | * @since 1.2 | ||
950 | */ | ||
951 | static inline Eina_Bool eina_value_array_set(Eina_Value *value, | ||
952 | unsigned int position, | ||
953 | ...) EINA_ARG_NONNULL(1); | ||
954 | |||
955 | /** | ||
956 | * @brief Get the generic value from an array member. | ||
957 | * @param value source value object | ||
958 | * @param position index of the member | ||
959 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
960 | * | ||
961 | * The value is returned in the variable argument parameter, and the | ||
962 | * actual value is type-dependent, but usually it will be what is | ||
963 | * stored inside the object. There shouldn't be any memory allocation; | ||
964 | * thus the contents should @b not be freed. | ||
965 | * | ||
966 | * The variable argument is dependent on chosen subtype. The list for | ||
967 | * basic types: | ||
968 | * | ||
969 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
970 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
971 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
972 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
973 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
974 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
975 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
976 | * @li EINA_VALUE_TYPE_INT: int* | ||
977 | * @li EINA_VALUE_TYPE_LONG: long* | ||
978 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
979 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
980 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
981 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
982 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
983 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* | ||
984 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
985 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
986 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
987 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
988 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
989 | * | ||
990 | * @code | ||
991 | * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); | ||
992 | * int x; | ||
993 | * | ||
994 | * eina_value_array_append(value, 1234); | ||
995 | * eina_value_array_get(value, 0, &x); | ||
996 | * eina_value_free(value); | ||
997 | * @endcode | ||
998 | * | ||
999 | * @see eina_value_array_set() | ||
1000 | * @see eina_value_array_vset() | ||
1001 | * @see eina_value_array_pset() | ||
1002 | * | ||
1003 | * @since 1.2 | ||
1004 | */ | ||
1005 | static inline Eina_Bool eina_value_array_get(const Eina_Value *value, | ||
1006 | unsigned int position, | ||
1007 | ...) EINA_ARG_NONNULL(1); | ||
1008 | |||
1009 | /** | ||
1010 | * @brief Insert a generic value in an array member position. | ||
1011 | * @param value source value object | ||
1012 | * @param position index of the member | ||
1013 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1014 | * | ||
1015 | * The variable argument is dependent on chosen subtype. The list for | ||
1016 | * basic types: | ||
1017 | * | ||
1018 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char | ||
1019 | * @li EINA_VALUE_TYPE_USHORT: unsigned short | ||
1020 | * @li EINA_VALUE_TYPE_UINT: unsigned int | ||
1021 | * @li EINA_VALUE_TYPE_ULONG: unsigned long | ||
1022 | * @li EINA_VALUE_TYPE_UINT64: uint64_t | ||
1023 | * @li EINA_VALUE_TYPE_CHAR: char | ||
1024 | * @li EINA_VALUE_TYPE_SHORT: short | ||
1025 | * @li EINA_VALUE_TYPE_INT: int | ||
1026 | * @li EINA_VALUE_TYPE_LONG: long | ||
1027 | * @li EINA_VALUE_TYPE_INT64: int64_t | ||
1028 | * @li EINA_VALUE_TYPE_FLOAT: float | ||
1029 | * @li EINA_VALUE_TYPE_DOUBLE: double | ||
1030 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char * | ||
1031 | * @li EINA_VALUE_TYPE_STRING: const char * | ||
1032 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array | ||
1033 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List | ||
1034 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash | ||
1035 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval | ||
1036 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob | ||
1037 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct | ||
1038 | * | ||
1039 | * @code | ||
1040 | * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); | ||
1041 | * int x; | ||
1042 | * | ||
1043 | * eina_value_array_insert(value, 0, 1234); | ||
1044 | * eina_value_array_get(value, 0, &x); | ||
1045 | * eina_value_free(value); | ||
1046 | * @endcode | ||
1047 | * | ||
1048 | * @see eina_value_array_set() | ||
1049 | * @see eina_value_array_get() | ||
1050 | * @see eina_value_array_vset() | ||
1051 | * @see eina_value_array_pset() | ||
1052 | * @see eina_value_array_vinsert() | ||
1053 | * @see eina_value_array_pinsert() | ||
1054 | * @see eina_value_array_append() | ||
1055 | * @see eina_value_array_vappend() | ||
1056 | * @see eina_value_array_pappend() | ||
1057 | * | ||
1058 | * @since 1.2 | ||
1059 | */ | ||
1060 | static inline Eina_Bool eina_value_array_insert(Eina_Value *value, | ||
1061 | unsigned int position, | ||
1062 | ...) EINA_ARG_NONNULL(1); | ||
1063 | |||
1064 | |||
1065 | /** | ||
1066 | * @brief Append a generic value in an array. | ||
1067 | * @param value source value object | ||
1068 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1069 | * | ||
1070 | * The variable argument is dependent on chosen subtype. The list for | ||
1071 | * basic types: | ||
1072 | * | ||
1073 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char | ||
1074 | * @li EINA_VALUE_TYPE_USHORT: unsigned short | ||
1075 | * @li EINA_VALUE_TYPE_UINT: unsigned int | ||
1076 | * @li EINA_VALUE_TYPE_ULONG: unsigned long | ||
1077 | * @li EINA_VALUE_TYPE_UINT64: uint64_t | ||
1078 | * @li EINA_VALUE_TYPE_CHAR: char | ||
1079 | * @li EINA_VALUE_TYPE_SHORT: short | ||
1080 | * @li EINA_VALUE_TYPE_INT: int | ||
1081 | * @li EINA_VALUE_TYPE_LONG: long | ||
1082 | * @li EINA_VALUE_TYPE_INT64: int64_t | ||
1083 | * @li EINA_VALUE_TYPE_FLOAT: float | ||
1084 | * @li EINA_VALUE_TYPE_DOUBLE: double | ||
1085 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char * | ||
1086 | * @li EINA_VALUE_TYPE_STRING: const char * | ||
1087 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array | ||
1088 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List | ||
1089 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash | ||
1090 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval | ||
1091 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob | ||
1092 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct | ||
1093 | * | ||
1094 | * @code | ||
1095 | * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); | ||
1096 | * int x; | ||
1097 | * | ||
1098 | * eina_value_array_append(value, 1234); | ||
1099 | * eina_value_array_get(value, 0, &x); | ||
1100 | * eina_value_free(value); | ||
1101 | * @endcode | ||
1102 | * | ||
1103 | * @see eina_value_array_set() | ||
1104 | * @see eina_value_array_get() | ||
1105 | * @see eina_value_array_vset() | ||
1106 | * @see eina_value_array_pset() | ||
1107 | * @see eina_value_array_vinsert() | ||
1108 | * @see eina_value_array_pinsert() | ||
1109 | * @see eina_value_array_append() | ||
1110 | * @see eina_value_array_vappend() | ||
1111 | * @see eina_value_array_pappend() | ||
1112 | * | ||
1113 | * @since 1.2 | ||
1114 | */ | ||
1115 | static inline Eina_Bool eina_value_array_append(Eina_Value *value, | ||
1116 | ...) EINA_ARG_NONNULL(1); | ||
1117 | |||
1118 | /** | ||
1119 | * @brief Set a generic value to an array member. | ||
1120 | * @param value source value object | ||
1121 | * @param position index of the member | ||
1122 | * @param args variable argument | ||
1123 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1124 | * @see eina_value_array_set() | ||
1125 | * @see eina_value_array_get() | ||
1126 | * @see eina_value_array_pset() | ||
1127 | * @see eina_value_array_insert() | ||
1128 | * @see eina_value_array_vinsert() | ||
1129 | * @see eina_value_array_pinsert() | ||
1130 | * @see eina_value_array_append() | ||
1131 | * @see eina_value_array_vappend() | ||
1132 | * @see eina_value_array_pappend() | ||
1133 | * | ||
1134 | * @since 1.2 | ||
1135 | */ | ||
1136 | static inline Eina_Bool eina_value_array_vset(Eina_Value *value, | ||
1137 | unsigned int position, | ||
1138 | va_list args) EINA_ARG_NONNULL(1); | ||
1139 | |||
1140 | /** | ||
1141 | * @brief Get the generic value from an array member. | ||
1142 | * @param value source value object | ||
1143 | * @param position index of the member | ||
1144 | * @param args variable argument | ||
1145 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1146 | * | ||
1147 | * The value is returned in the variable argument parameter, the | ||
1148 | * actual value is type-dependent, but usually it will be what is | ||
1149 | * stored inside the object. There shouldn't be any memory allocation, | ||
1150 | * thus the contents should @b not be freed. | ||
1151 | * | ||
1152 | * @see eina_value_array_vset() | ||
1153 | * @see eina_value_array_get() | ||
1154 | * @see eina_value_array_pget() | ||
1155 | * | ||
1156 | * @since 1.2 | ||
1157 | */ | ||
1158 | static inline Eina_Bool eina_value_array_vget(const Eina_Value *value, | ||
1159 | unsigned int position, | ||
1160 | va_list args) EINA_ARG_NONNULL(1); | ||
1161 | /** | ||
1162 | * @brief Insert a generic value to an array member position. | ||
1163 | * @param value source value object | ||
1164 | * @param position index of the member | ||
1165 | * @param args variable argument | ||
1166 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1167 | * @see eina_value_array_set() | ||
1168 | * @see eina_value_array_get() | ||
1169 | * @see eina_value_array_vset() | ||
1170 | * @see eina_value_array_pset() | ||
1171 | * @see eina_value_array_insert() | ||
1172 | * @see eina_value_array_pinsert() | ||
1173 | * @see eina_value_array_append() | ||
1174 | * @see eina_value_array_vappend() | ||
1175 | * @see eina_value_array_pappend() | ||
1176 | * | ||
1177 | * @since 1.2 | ||
1178 | */ | ||
1179 | static inline Eina_Bool eina_value_array_vinsert(Eina_Value *value, | ||
1180 | unsigned int position, | ||
1181 | va_list args) EINA_ARG_NONNULL(1); | ||
1182 | |||
1183 | /** | ||
1184 | * @brief Append a generic value to an array. | ||
1185 | * @param value source value object | ||
1186 | * @param args variable argument | ||
1187 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1188 | * @see eina_value_array_set() | ||
1189 | * @see eina_value_array_get() | ||
1190 | * @see eina_value_array_vget() | ||
1191 | * @see eina_value_array_pset() | ||
1192 | * @see eina_value_array_insert() | ||
1193 | * @see eina_value_array_vinsert() | ||
1194 | * @see eina_value_array_pinsert() | ||
1195 | * @see eina_value_array_append() | ||
1196 | * @see eina_value_array_pappend() | ||
1197 | * | ||
1198 | * @since 1.2 | ||
1199 | */ | ||
1200 | static inline Eina_Bool eina_value_array_vappend(Eina_Value *value, | ||
1201 | va_list args) EINA_ARG_NONNULL(1); | ||
1202 | |||
1203 | |||
1204 | /** | ||
1205 | * @brief Set a generic value to an array member from a pointer. | ||
1206 | * @param value source value object | ||
1207 | * @param position index of the member | ||
1208 | * @param ptr pointer to specify the contents. | ||
1209 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1210 | * | ||
1211 | * The pointer type is dependent on chosen value type. The list for | ||
1212 | * basic types: | ||
1213 | * | ||
1214 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
1215 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
1216 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
1217 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
1218 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
1219 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
1220 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
1221 | * @li EINA_VALUE_TYPE_INT: int* | ||
1222 | * @li EINA_VALUE_TYPE_LONG: long* | ||
1223 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
1224 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
1225 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
1226 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
1227 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
1228 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* | ||
1229 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
1230 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
1231 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
1232 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
1233 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
1234 | * | ||
1235 | * @note the pointer contents are written using the size defined by | ||
1236 | * type. It can be larger than void* or uint64_t. | ||
1237 | * | ||
1238 | * @code | ||
1239 | * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); | ||
1240 | * int x = 1234; | ||
1241 | * | ||
1242 | * eina_value_array_append(value, 1234); | ||
1243 | * eina_value_array_pset(value, 0, &x); | ||
1244 | * eina_value_array_pget(value, 0, &x); | ||
1245 | * eina_value_free(value); | ||
1246 | * @endcode | ||
1247 | * | ||
1248 | * @see eina_value_array_set() | ||
1249 | * @see eina_value_array_get() | ||
1250 | * @see eina_value_array_vset() | ||
1251 | * @see eina_value_array_insert() | ||
1252 | * @see eina_value_array_vinsert() | ||
1253 | * @see eina_value_array_pinsert() | ||
1254 | * @see eina_value_array_append() | ||
1255 | * @see eina_value_array_vappend() | ||
1256 | * @see eina_value_array_pappend() | ||
1257 | * | ||
1258 | * @since 1.2 | ||
1259 | */ | ||
1260 | static inline Eina_Bool eina_value_array_pset(Eina_Value *value, | ||
1261 | unsigned int position, | ||
1262 | const void *ptr) EINA_ARG_NONNULL(1, 3); | ||
1263 | |||
1264 | /** | ||
1265 | * @brief Retrieve a generic value into a pointer from an array member. | ||
1266 | * @param value source value object | ||
1267 | * @param position index of the member | ||
1268 | * @param ptr pointer to receive the contents. | ||
1269 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1270 | * | ||
1271 | * The value is returned in pointer contents, the actual value is | ||
1272 | * type-dependent, but usually it will be what is stored inside the | ||
1273 | * object. There shouldn't be any memory allocation, thus the contents | ||
1274 | * should @b not be freed. | ||
1275 | * | ||
1276 | * The pointer type is dependent on chosen value type. The list for | ||
1277 | * basic types: | ||
1278 | * | ||
1279 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
1280 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
1281 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
1282 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
1283 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
1284 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
1285 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
1286 | * @li EINA_VALUE_TYPE_INT: int* | ||
1287 | * @li EINA_VALUE_TYPE_LONG: long* | ||
1288 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
1289 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
1290 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
1291 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
1292 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
1293 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* | ||
1294 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
1295 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
1296 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
1297 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
1298 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
1299 | * | ||
1300 | * @code | ||
1301 | * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); | ||
1302 | * int x; | ||
1303 | * | ||
1304 | * eina_value_array_append(value, 1234); | ||
1305 | * eina_value_array_pget(value, 0, &x); | ||
1306 | * eina_value_free(value); | ||
1307 | * @endcode | ||
1308 | * | ||
1309 | * @see eina_value_array_set() | ||
1310 | * @see eina_value_array_vset() | ||
1311 | * @see eina_value_array_pset() | ||
1312 | * | ||
1313 | * @since 1.2 | ||
1314 | */ | ||
1315 | static inline Eina_Bool eina_value_array_pget(const Eina_Value *value, | ||
1316 | unsigned int position, | ||
1317 | void *ptr) EINA_ARG_NONNULL(1, 3); | ||
1318 | |||
1319 | /** | ||
1320 | * @brief Insert a generic value to an array member position from a pointer. | ||
1321 | * @param value source value object | ||
1322 | * @param position index of the member | ||
1323 | * @param ptr pointer to specify the contents. | ||
1324 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1325 | * | ||
1326 | * The pointer type is dependent on chosen value type. The list for | ||
1327 | * basic types: | ||
1328 | * | ||
1329 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
1330 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
1331 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
1332 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
1333 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
1334 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
1335 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
1336 | * @li EINA_VALUE_TYPE_INT: int* | ||
1337 | * @li EINA_VALUE_TYPE_LONG: long* | ||
1338 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
1339 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
1340 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
1341 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
1342 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
1343 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* | ||
1344 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
1345 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
1346 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
1347 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
1348 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
1349 | * | ||
1350 | * @note the pointer contents are written using the size defined by | ||
1351 | * type. It can be larger than void* or uint64_t. | ||
1352 | * | ||
1353 | * @code | ||
1354 | * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); | ||
1355 | * int x = 1234; | ||
1356 | * | ||
1357 | * eina_value_array_pinsert(value, 0, &x); | ||
1358 | * eina_value_array_pget(value, 0, &x); | ||
1359 | * eina_value_free(value); | ||
1360 | * @endcode | ||
1361 | * | ||
1362 | * @see eina_value_array_set() | ||
1363 | * @see eina_value_array_get() | ||
1364 | * @see eina_value_array_vset() | ||
1365 | * @see eina_value_array_insert() | ||
1366 | * @see eina_value_array_vinsert() | ||
1367 | * @see eina_value_array_pinsert() | ||
1368 | * @see eina_value_array_append() | ||
1369 | * @see eina_value_array_vappend() | ||
1370 | * @see eina_value_array_pappend() | ||
1371 | * | ||
1372 | * @since 1.2 | ||
1373 | */ | ||
1374 | static inline Eina_Bool eina_value_array_pinsert(Eina_Value *value, | ||
1375 | unsigned int position, | ||
1376 | const void *ptr) EINA_ARG_NONNULL(1); | ||
1377 | |||
1378 | /** | ||
1379 | * @brief Append a generic value to an array from a pointer. | ||
1380 | * @param value source value object | ||
1381 | * @param ptr pointer to specify the contents. | ||
1382 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1383 | * | ||
1384 | * The pointer type is dependent on chosen value type. The list for | ||
1385 | * basic types: | ||
1386 | * | ||
1387 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
1388 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
1389 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
1390 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
1391 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
1392 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
1393 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
1394 | * @li EINA_VALUE_TYPE_INT: int* | ||
1395 | * @li EINA_VALUE_TYPE_LONG: long* | ||
1396 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
1397 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
1398 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
1399 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
1400 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
1401 | * @li EINA_VALUE_TYPE_ARRAY: Eina_Value_Array* | ||
1402 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
1403 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
1404 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
1405 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
1406 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
1407 | * | ||
1408 | * @note the pointer contents are written using the size defined by | ||
1409 | * type. It can be larger than void* or uint64_t. | ||
1410 | * | ||
1411 | * @code | ||
1412 | * Eina_Value *value = eina_value_array_new(EINA_VALUE_TYPE_INT, 0); | ||
1413 | * int x = 1234; | ||
1414 | * | ||
1415 | * eina_value_array_pappend(value, &x); | ||
1416 | * eina_value_array_pget(value, 0, &x); | ||
1417 | * eina_value_free(value); | ||
1418 | * @endcode | ||
1419 | * | ||
1420 | * @see eina_value_array_set() | ||
1421 | * @see eina_value_array_get() | ||
1422 | * @see eina_value_array_vset() | ||
1423 | * @see eina_value_array_insert() | ||
1424 | * @see eina_value_array_vinsert() | ||
1425 | * @see eina_value_array_pinsert() | ||
1426 | * @see eina_value_array_append() | ||
1427 | * @see eina_value_array_vappend() | ||
1428 | * @see eina_value_array_pappend() | ||
1429 | * | ||
1430 | * @since 1.2 | ||
1431 | */ | ||
1432 | static inline Eina_Bool eina_value_array_pappend(Eina_Value *value, | ||
1433 | const void *ptr) EINA_ARG_NONNULL(1); | ||
1434 | |||
1435 | /** | ||
1436 | * @} | ||
1437 | */ | ||
1438 | |||
1439 | |||
1440 | /** | ||
1441 | * @defgroup Eina_Value_List_Group Generic Value List management | ||
1442 | * | ||
1443 | * @{ | ||
1444 | */ | ||
1445 | |||
1446 | |||
1447 | /** | ||
1448 | * @typedef Eina_Value_List | ||
1449 | * Value type for #EINA_VALUE_TYPE_LIST | ||
1450 | * | ||
1451 | * @since 1.2 | ||
1452 | */ | ||
1453 | typedef struct _Eina_Value_List Eina_Value_List; | ||
1454 | |||
1455 | /** | ||
1456 | * @struct _Eina_Value_List | ||
1457 | * Used to store the list and its subtype. | ||
1458 | */ | ||
1459 | struct _Eina_Value_List | ||
1460 | { | ||
1461 | const Eina_Value_Type *subtype; /**< how to allocate and access items */ | ||
1462 | Eina_List *list; /**< the list that holds data, members are of subtype->value_size bytes. */ | ||
1463 | }; | ||
1464 | |||
1465 | /** | ||
1466 | * @brief Create generic value storage of type list. | ||
1467 | * @param subtype how to manage this list members. | ||
1468 | * @return The new value or @c NULL on failure. | ||
1469 | * | ||
1470 | * Create a new generic value storage of type list. The members are | ||
1471 | * managed using the description specified by @a subtype. | ||
1472 | * | ||
1473 | * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or | ||
1474 | * #EINA_ERROR_VALUE_FAILED is set. | ||
1475 | * | ||
1476 | * @note this creates from mempool and then uses | ||
1477 | * eina_value_list_setup(). | ||
1478 | * | ||
1479 | * @see eina_value_free() | ||
1480 | * @see eina_value_list_setup() | ||
1481 | * | ||
1482 | * @since 1.2 | ||
1483 | */ | ||
1484 | EAPI Eina_Value *eina_value_list_new(const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1); | ||
1485 | |||
1486 | /** | ||
1487 | * @brief Initialize generic value storage of type list. | ||
1488 | * @param value value object | ||
1489 | * @param subtype how to manage this list members. | ||
1490 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1491 | * | ||
1492 | * Initializes new generic value storage of type list with the given | ||
1493 | * @a subtype. | ||
1494 | * | ||
1495 | * This is the same as calling eina_value_set() with | ||
1496 | * #EINA_VALUE_TYPE_LIST followed by eina_value_pset() with the | ||
1497 | * #Eina_Value_List description configured. | ||
1498 | * | ||
1499 | * @note Existing contents are ignored! If the value was previously used, then | ||
1500 | * use eina_value_flush() first. | ||
1501 | * | ||
1502 | * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY | ||
1503 | * or #EINA_ERROR_VALUE_FAILED is set. | ||
1504 | * | ||
1505 | * @see eina_value_flush() | ||
1506 | * | ||
1507 | * @since 1.2 | ||
1508 | */ | ||
1509 | static inline Eina_Bool eina_value_list_setup(Eina_Value *value, | ||
1510 | const Eina_Value_Type *subtype) EINA_ARG_NONNULL(1, 2); | ||
1511 | |||
1512 | /** | ||
1513 | * @brief Query number of elements in value of list type. | ||
1514 | * @param value value object. | ||
1515 | * @return number of child elements. | ||
1516 | * @since 1.2 | ||
1517 | */ | ||
1518 | static inline unsigned int eina_value_list_count(const Eina_Value *value); | ||
1519 | |||
1520 | /** | ||
1521 | * @brief Remove element at given position in value of list type. | ||
1522 | * @param value value object. | ||
1523 | * @param position index of the member | ||
1524 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1525 | * @since 1.2 | ||
1526 | */ | ||
1527 | static inline Eina_Bool eina_value_list_remove(Eina_Value *value, | ||
1528 | unsigned int position) EINA_ARG_NONNULL(1); | ||
1529 | |||
1530 | /** | ||
1531 | * @brief Set the generic value in an list member. | ||
1532 | * @param value source value object | ||
1533 | * @param position index of the member | ||
1534 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1535 | * | ||
1536 | * The variable argument is dependent on chosen subtype. The list for | ||
1537 | * basic types: | ||
1538 | * | ||
1539 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char | ||
1540 | * @li EINA_VALUE_TYPE_USHORT: unsigned short | ||
1541 | * @li EINA_VALUE_TYPE_UINT: unsigned int | ||
1542 | * @li EINA_VALUE_TYPE_ULONG: unsigned long | ||
1543 | * @li EINA_VALUE_TYPE_UINT64: uint64_t | ||
1544 | * @li EINA_VALUE_TYPE_CHAR: char | ||
1545 | * @li EINA_VALUE_TYPE_SHORT: short | ||
1546 | * @li EINA_VALUE_TYPE_INT: int | ||
1547 | * @li EINA_VALUE_TYPE_LONG: long | ||
1548 | * @li EINA_VALUE_TYPE_INT64: int64_t | ||
1549 | * @li EINA_VALUE_TYPE_FLOAT: float | ||
1550 | * @li EINA_VALUE_TYPE_DOUBLE: double | ||
1551 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char * | ||
1552 | * @li EINA_VALUE_TYPE_STRING: const char * | ||
1553 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List | ||
1554 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash | ||
1555 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval | ||
1556 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob | ||
1557 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct | ||
1558 | * | ||
1559 | * @code | ||
1560 | * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); | ||
1561 | * int x; | ||
1562 | * | ||
1563 | * eina_value_list_append(value, 1234); | ||
1564 | * eina_value_list_set(value, 0, 5678); | ||
1565 | * eina_value_list_get(value, 0, &x); | ||
1566 | * eina_value_free(value); | ||
1567 | * @endcode | ||
1568 | * | ||
1569 | * @see eina_value_list_get() | ||
1570 | * @see eina_value_list_vset() | ||
1571 | * @see eina_value_list_pset() | ||
1572 | * @see eina_value_list_insert() | ||
1573 | * @see eina_value_list_vinsert() | ||
1574 | * @see eina_value_list_pinsert() | ||
1575 | * @see eina_value_list_append() | ||
1576 | * @see eina_value_list_vappend() | ||
1577 | * @see eina_value_list_pappend() | ||
1578 | * | ||
1579 | * @since 1.2 | ||
1580 | */ | ||
1581 | static inline Eina_Bool eina_value_list_set(Eina_Value *value, | ||
1582 | unsigned int position, | ||
1583 | ...) EINA_ARG_NONNULL(1); | ||
1584 | |||
1585 | /** | ||
1586 | * @brief Get the generic value from an list member. | ||
1587 | * @param value source value object | ||
1588 | * @param position index of the member | ||
1589 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1590 | * | ||
1591 | * The value is returned in the variable argument parameter, the | ||
1592 | * actual value is type-dependent, but usually it will be what is | ||
1593 | * stored inside the object. There shouldn't be any memory allocation, | ||
1594 | * thus the contents should @b not be freed. | ||
1595 | * | ||
1596 | * The variable argument is dependent on chosen subtype. The list for | ||
1597 | * basic types: | ||
1598 | * | ||
1599 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
1600 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
1601 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
1602 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
1603 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
1604 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
1605 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
1606 | * @li EINA_VALUE_TYPE_INT: int* | ||
1607 | * @li EINA_VALUE_TYPE_LONG: long* | ||
1608 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
1609 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
1610 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
1611 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
1612 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
1613 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
1614 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
1615 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
1616 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
1617 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
1618 | * | ||
1619 | * @code | ||
1620 | * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); | ||
1621 | * int x; | ||
1622 | * | ||
1623 | * eina_value_list_append(value, 1234); | ||
1624 | * eina_value_list_get(value, 0, &x); | ||
1625 | * eina_value_free(value); | ||
1626 | * @endcode | ||
1627 | * | ||
1628 | * @see eina_value_list_set() | ||
1629 | * @see eina_value_list_vset() | ||
1630 | * @see eina_value_list_pset() | ||
1631 | * | ||
1632 | * @since 1.2 | ||
1633 | */ | ||
1634 | static inline Eina_Bool eina_value_list_get(const Eina_Value *value, | ||
1635 | unsigned int position, | ||
1636 | ...) EINA_ARG_NONNULL(1); | ||
1637 | |||
1638 | /** | ||
1639 | * @brief Insert the generic value in an list member position. | ||
1640 | * @param value source value object | ||
1641 | * @param position index of the member | ||
1642 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1643 | * | ||
1644 | * The variable argument is dependent on chosen subtype. The list for | ||
1645 | * basic types: | ||
1646 | * | ||
1647 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char | ||
1648 | * @li EINA_VALUE_TYPE_USHORT: unsigned short | ||
1649 | * @li EINA_VALUE_TYPE_UINT: unsigned int | ||
1650 | * @li EINA_VALUE_TYPE_ULONG: unsigned long | ||
1651 | * @li EINA_VALUE_TYPE_UINT64: uint64_t | ||
1652 | * @li EINA_VALUE_TYPE_CHAR: char | ||
1653 | * @li EINA_VALUE_TYPE_SHORT: short | ||
1654 | * @li EINA_VALUE_TYPE_INT: int | ||
1655 | * @li EINA_VALUE_TYPE_LONG: long | ||
1656 | * @li EINA_VALUE_TYPE_INT64: int64_t | ||
1657 | * @li EINA_VALUE_TYPE_FLOAT: float | ||
1658 | * @li EINA_VALUE_TYPE_DOUBLE: double | ||
1659 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char * | ||
1660 | * @li EINA_VALUE_TYPE_STRING: const char * | ||
1661 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List | ||
1662 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash | ||
1663 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval | ||
1664 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob | ||
1665 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct | ||
1666 | * | ||
1667 | * @code | ||
1668 | * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); | ||
1669 | * int x; | ||
1670 | * | ||
1671 | * eina_value_list_insert(value, 0, 1234); | ||
1672 | * eina_value_list_get(value, 0, &x); | ||
1673 | * eina_value_free(value); | ||
1674 | * @endcode | ||
1675 | * | ||
1676 | * @see eina_value_list_set() | ||
1677 | * @see eina_value_list_get() | ||
1678 | * @see eina_value_list_vset() | ||
1679 | * @see eina_value_list_pset() | ||
1680 | * @see eina_value_list_vinsert() | ||
1681 | * @see eina_value_list_pinsert() | ||
1682 | * @see eina_value_list_append() | ||
1683 | * @see eina_value_list_vappend() | ||
1684 | * @see eina_value_list_pappend() | ||
1685 | * | ||
1686 | * @since 1.2 | ||
1687 | */ | ||
1688 | static inline Eina_Bool eina_value_list_insert(Eina_Value *value, | ||
1689 | unsigned int position, | ||
1690 | ...) EINA_ARG_NONNULL(1); | ||
1691 | |||
1692 | |||
1693 | /** | ||
1694 | * @brief Append the generic value in an list. | ||
1695 | * @param value source value object | ||
1696 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1697 | * | ||
1698 | * The variable argument is dependent on chosen subtype. The list for | ||
1699 | * basic types: | ||
1700 | * | ||
1701 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char | ||
1702 | * @li EINA_VALUE_TYPE_USHORT: unsigned short | ||
1703 | * @li EINA_VALUE_TYPE_UINT: unsigned int | ||
1704 | * @li EINA_VALUE_TYPE_ULONG: unsigned long | ||
1705 | * @li EINA_VALUE_TYPE_UINT64: uint64_t | ||
1706 | * @li EINA_VALUE_TYPE_CHAR: char | ||
1707 | * @li EINA_VALUE_TYPE_SHORT: short | ||
1708 | * @li EINA_VALUE_TYPE_INT: int | ||
1709 | * @li EINA_VALUE_TYPE_LONG: long | ||
1710 | * @li EINA_VALUE_TYPE_INT64: int64_t | ||
1711 | * @li EINA_VALUE_TYPE_FLOAT: float | ||
1712 | * @li EINA_VALUE_TYPE_DOUBLE: double | ||
1713 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char * | ||
1714 | * @li EINA_VALUE_TYPE_STRING: const char * | ||
1715 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List | ||
1716 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash | ||
1717 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval | ||
1718 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob | ||
1719 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct | ||
1720 | * | ||
1721 | * @code | ||
1722 | * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); | ||
1723 | * int x; | ||
1724 | * | ||
1725 | * eina_value_list_append(value, 1234); | ||
1726 | * eina_value_list_get(value, 0, &x); | ||
1727 | * eina_value_free(value); | ||
1728 | * @endcode | ||
1729 | * | ||
1730 | * @see eina_value_list_set() | ||
1731 | * @see eina_value_list_get() | ||
1732 | * @see eina_value_list_vset() | ||
1733 | * @see eina_value_list_pset() | ||
1734 | * @see eina_value_list_vinsert() | ||
1735 | * @see eina_value_list_pinsert() | ||
1736 | * @see eina_value_list_append() | ||
1737 | * @see eina_value_list_vappend() | ||
1738 | * @see eina_value_list_pappend() | ||
1739 | * | ||
1740 | * @since 1.2 | ||
1741 | */ | ||
1742 | static inline Eina_Bool eina_value_list_append(Eina_Value *value, | ||
1743 | ...) EINA_ARG_NONNULL(1); | ||
1744 | |||
1745 | /** | ||
1746 | * @brief Set the generic value in an list member. | ||
1747 | * @param value source value object | ||
1748 | * @param position index of the member | ||
1749 | * @param args variable argument | ||
1750 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1751 | * @see eina_value_list_set() | ||
1752 | * @see eina_value_list_get() | ||
1753 | * @see eina_value_list_pset() | ||
1754 | * @see eina_value_list_insert() | ||
1755 | * @see eina_value_list_vinsert() | ||
1756 | * @see eina_value_list_pinsert() | ||
1757 | * @see eina_value_list_append() | ||
1758 | * @see eina_value_list_vappend() | ||
1759 | * @see eina_value_list_pappend() | ||
1760 | * | ||
1761 | * @since 1.2 | ||
1762 | */ | ||
1763 | static inline Eina_Bool eina_value_list_vset(Eina_Value *value, | ||
1764 | unsigned int position, | ||
1765 | va_list args) EINA_ARG_NONNULL(1); | ||
1766 | |||
1767 | /** | ||
1768 | * @brief Get the generic value from an list member. | ||
1769 | * @param value source value object | ||
1770 | * @param position index of the member | ||
1771 | * @param args variable argument | ||
1772 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1773 | * | ||
1774 | * The value is returned in the variable argument parameter, the | ||
1775 | * actual value is type-dependent, but usually it will be what is | ||
1776 | * stored inside the object. There shouldn't be any memory allocation, | ||
1777 | * thus the contents should @b not be freed. | ||
1778 | * | ||
1779 | * @see eina_value_list_vset() | ||
1780 | * @see eina_value_list_get() | ||
1781 | * @see eina_value_list_pget() | ||
1782 | * | ||
1783 | * @since 1.2 | ||
1784 | */ | ||
1785 | static inline Eina_Bool eina_value_list_vget(const Eina_Value *value, | ||
1786 | unsigned int position, | ||
1787 | va_list args) EINA_ARG_NONNULL(1); | ||
1788 | /** | ||
1789 | * @brief Insert the generic value in an list member position. | ||
1790 | * @param value source value object | ||
1791 | * @param position index of the member | ||
1792 | * @param args variable argument | ||
1793 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1794 | * @see eina_value_list_set() | ||
1795 | * @see eina_value_list_get() | ||
1796 | * @see eina_value_list_vset() | ||
1797 | * @see eina_value_list_pset() | ||
1798 | * @see eina_value_list_insert() | ||
1799 | * @see eina_value_list_pinsert() | ||
1800 | * @see eina_value_list_append() | ||
1801 | * @see eina_value_list_vappend() | ||
1802 | * @see eina_value_list_pappend() | ||
1803 | * | ||
1804 | * @since 1.2 | ||
1805 | */ | ||
1806 | static inline Eina_Bool eina_value_list_vinsert(Eina_Value *value, | ||
1807 | unsigned int position, | ||
1808 | va_list args) EINA_ARG_NONNULL(1); | ||
1809 | |||
1810 | /** | ||
1811 | * @brief Append the generic value in an list. | ||
1812 | * @param value source value object | ||
1813 | * @param args variable argument | ||
1814 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1815 | * @see eina_value_list_set() | ||
1816 | * @see eina_value_list_get() | ||
1817 | * @see eina_value_list_vget() | ||
1818 | * @see eina_value_list_pset() | ||
1819 | * @see eina_value_list_insert() | ||
1820 | * @see eina_value_list_vinsert() | ||
1821 | * @see eina_value_list_pinsert() | ||
1822 | * @see eina_value_list_append() | ||
1823 | * @see eina_value_list_pappend() | ||
1824 | * | ||
1825 | * @since 1.2 | ||
1826 | */ | ||
1827 | static inline Eina_Bool eina_value_list_vappend(Eina_Value *value, | ||
1828 | va_list args) EINA_ARG_NONNULL(1); | ||
1829 | |||
1830 | |||
1831 | /** | ||
1832 | * @brief Set the generic value in an list member from pointer. | ||
1833 | * @param value source value object | ||
1834 | * @param position index of the member | ||
1835 | * @param ptr pointer to specify the contents. | ||
1836 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1837 | * | ||
1838 | * The pointer type is dependent on chosen value type. The list for | ||
1839 | * basic types: | ||
1840 | * | ||
1841 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
1842 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
1843 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
1844 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
1845 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
1846 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
1847 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
1848 | * @li EINA_VALUE_TYPE_INT: int* | ||
1849 | * @li EINA_VALUE_TYPE_LONG: long* | ||
1850 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
1851 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
1852 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
1853 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
1854 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
1855 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
1856 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
1857 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
1858 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
1859 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
1860 | * | ||
1861 | * @note the pointer contents are written using the size defined by | ||
1862 | * type. It can be larger than void* or uint64_t. | ||
1863 | * | ||
1864 | * @code | ||
1865 | * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); | ||
1866 | * int x = 1234; | ||
1867 | * | ||
1868 | * eina_value_list_append(value, 1234); | ||
1869 | * eina_value_list_pset(value, 0, &x); | ||
1870 | * eina_value_list_pget(value, 0, &x); | ||
1871 | * eina_value_free(value); | ||
1872 | * @endcode | ||
1873 | * | ||
1874 | * @see eina_value_list_set() | ||
1875 | * @see eina_value_list_get() | ||
1876 | * @see eina_value_list_vset() | ||
1877 | * @see eina_value_list_insert() | ||
1878 | * @see eina_value_list_vinsert() | ||
1879 | * @see eina_value_list_pinsert() | ||
1880 | * @see eina_value_list_append() | ||
1881 | * @see eina_value_list_vappend() | ||
1882 | * @see eina_value_list_pappend() | ||
1883 | * | ||
1884 | * @since 1.2 | ||
1885 | */ | ||
1886 | static inline Eina_Bool eina_value_list_pset(Eina_Value *value, | ||
1887 | unsigned int position, | ||
1888 | const void *ptr) EINA_ARG_NONNULL(1, 3); | ||
1889 | |||
1890 | /** | ||
1891 | * @brief Get the generic value to pointer from an list member. | ||
1892 | * @param value source value object | ||
1893 | * @param position index of the member | ||
1894 | * @param ptr pointer to receive the contents. | ||
1895 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1896 | * | ||
1897 | * The value is returned in pointer contents, the actual value is | ||
1898 | * type-dependent, but usually it will be what is stored inside the | ||
1899 | * object. There shouldn't be any memory allocation, thus the contents | ||
1900 | * should @b not be freed. | ||
1901 | * | ||
1902 | * The pointer type is dependent on chosen value type. The list for | ||
1903 | * basic types: | ||
1904 | * | ||
1905 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
1906 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
1907 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
1908 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
1909 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
1910 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
1911 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
1912 | * @li EINA_VALUE_TYPE_INT: int* | ||
1913 | * @li EINA_VALUE_TYPE_LONG: long* | ||
1914 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
1915 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
1916 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
1917 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
1918 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
1919 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
1920 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
1921 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
1922 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
1923 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
1924 | * | ||
1925 | * @code | ||
1926 | * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); | ||
1927 | * int x; | ||
1928 | * | ||
1929 | * eina_value_list_append(value, 1234); | ||
1930 | * eina_value_list_pget(value, 0, &x); | ||
1931 | * eina_value_free(value); | ||
1932 | * @endcode | ||
1933 | * | ||
1934 | * @see eina_value_list_set() | ||
1935 | * @see eina_value_list_vset() | ||
1936 | * @see eina_value_list_pset() | ||
1937 | * | ||
1938 | * @since 1.2 | ||
1939 | */ | ||
1940 | static inline Eina_Bool eina_value_list_pget(const Eina_Value *value, | ||
1941 | unsigned int position, | ||
1942 | void *ptr) EINA_ARG_NONNULL(1, 3); | ||
1943 | |||
1944 | /** | ||
1945 | * @brief Insert the generic value in an list member position from pointer. | ||
1946 | * @param value source value object | ||
1947 | * @param position index of the member | ||
1948 | * @param ptr pointer to specify the contents. | ||
1949 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
1950 | * | ||
1951 | * The pointer type is dependent on chosen value type. The list for | ||
1952 | * basic types: | ||
1953 | * | ||
1954 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
1955 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
1956 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
1957 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
1958 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
1959 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
1960 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
1961 | * @li EINA_VALUE_TYPE_INT: int* | ||
1962 | * @li EINA_VALUE_TYPE_LONG: long* | ||
1963 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
1964 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
1965 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
1966 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
1967 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
1968 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
1969 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
1970 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
1971 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
1972 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
1973 | * | ||
1974 | * @note the pointer contents are written using the size defined by | ||
1975 | * type. It can be larger than void* or uint64_t. | ||
1976 | * | ||
1977 | * @code | ||
1978 | * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); | ||
1979 | * int x = 1234; | ||
1980 | * | ||
1981 | * eina_value_list_pinsert(value, 0, &x); | ||
1982 | * eina_value_list_pget(value, 0, &x); | ||
1983 | * eina_value_free(value); | ||
1984 | * @endcode | ||
1985 | * | ||
1986 | * @see eina_value_list_set() | ||
1987 | * @see eina_value_list_get() | ||
1988 | * @see eina_value_list_vset() | ||
1989 | * @see eina_value_list_insert() | ||
1990 | * @see eina_value_list_vinsert() | ||
1991 | * @see eina_value_list_pinsert() | ||
1992 | * @see eina_value_list_append() | ||
1993 | * @see eina_value_list_vappend() | ||
1994 | * @see eina_value_list_pappend() | ||
1995 | * | ||
1996 | * @since 1.2 | ||
1997 | */ | ||
1998 | static inline Eina_Bool eina_value_list_pinsert(Eina_Value *value, | ||
1999 | unsigned int position, | ||
2000 | const void *ptr) EINA_ARG_NONNULL(1); | ||
2001 | |||
2002 | /** | ||
2003 | * @brief Append the generic value in an list from pointer. | ||
2004 | * @param value source value object | ||
2005 | * @param ptr pointer to specify the contents. | ||
2006 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2007 | * | ||
2008 | * The pointer type is dependent on chosen value type. The list for | ||
2009 | * basic types: | ||
2010 | * | ||
2011 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
2012 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
2013 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
2014 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
2015 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
2016 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
2017 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
2018 | * @li EINA_VALUE_TYPE_INT: int* | ||
2019 | * @li EINA_VALUE_TYPE_LONG: long* | ||
2020 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
2021 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
2022 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
2023 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
2024 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
2025 | * @li EINA_VALUE_TYPE_LIST: Eina_Value_List* | ||
2026 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
2027 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
2028 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
2029 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
2030 | * | ||
2031 | * @note the pointer contents are written using the size defined by | ||
2032 | * type. It can be larger than void* or uint64_t. | ||
2033 | * | ||
2034 | * @code | ||
2035 | * Eina_Value *value = eina_value_list_new(EINA_VALUE_TYPE_INT); | ||
2036 | * int x = 1234; | ||
2037 | * | ||
2038 | * eina_value_list_pappend(value, &x); | ||
2039 | * eina_value_list_pget(value, 0, &x); | ||
2040 | * eina_value_free(value); | ||
2041 | * @endcode | ||
2042 | * | ||
2043 | * @see eina_value_list_set() | ||
2044 | * @see eina_value_list_get() | ||
2045 | * @see eina_value_list_vset() | ||
2046 | * @see eina_value_list_insert() | ||
2047 | * @see eina_value_list_vinsert() | ||
2048 | * @see eina_value_list_pinsert() | ||
2049 | * @see eina_value_list_append() | ||
2050 | * @see eina_value_list_vappend() | ||
2051 | * @see eina_value_list_pappend() | ||
2052 | * | ||
2053 | * @since 1.2 | ||
2054 | */ | ||
2055 | static inline Eina_Bool eina_value_list_pappend(Eina_Value *value, | ||
2056 | const void *ptr) EINA_ARG_NONNULL(1); | ||
2057 | |||
2058 | /** | ||
2059 | * @} | ||
2060 | */ | ||
2061 | |||
2062 | /** | ||
2063 | * @defgroup Eina_Value_Hash_Group Generic Value Hash management | ||
2064 | * | ||
2065 | * @{ | ||
2066 | */ | ||
2067 | |||
2068 | /** | ||
2069 | * @typedef Eina_Value_Hash | ||
2070 | * Value type for #EINA_VALUE_TYPE_HASH | ||
2071 | * | ||
2072 | * @since 1.2 | ||
2073 | */ | ||
2074 | typedef struct _Eina_Value_Hash Eina_Value_Hash; | ||
2075 | |||
2076 | /** | ||
2077 | * @struct _Eina_Value_Hash | ||
2078 | * Used to store the hash and its subtype. | ||
2079 | */ | ||
2080 | struct _Eina_Value_Hash | ||
2081 | { | ||
2082 | const Eina_Value_Type *subtype; /**< how to allocate and access items */ | ||
2083 | unsigned int buckets_power_size; /**< how to allocate hash buckets, if zero a sane default is chosen. */ | ||
2084 | Eina_Hash *hash; /**< the hash that holds data, members are of subtype->value_size bytes. */ | ||
2085 | }; | ||
2086 | |||
2087 | /** | ||
2088 | * @brief Create generic value storage of type hash. | ||
2089 | * @param subtype how to manage this hash members. | ||
2090 | * @param buckets_power_size how to allocate hash buckets (2 ^ | ||
2091 | * buckets_power_size), if zero then a sane value is chosen. | ||
2092 | * @return The new value or @c NULL on failure. | ||
2093 | * | ||
2094 | * Create a new generic value storage of type hash. The members are | ||
2095 | * managed using the description specified by @a subtype. | ||
2096 | * | ||
2097 | * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or | ||
2098 | * #EINA_ERROR_VALUE_FAILED is set. | ||
2099 | * | ||
2100 | * @note this creates from mempool and then uses | ||
2101 | * eina_value_hash_setup(). | ||
2102 | * | ||
2103 | * @see eina_value_free() | ||
2104 | * @see eina_value_hash_setup() | ||
2105 | * | ||
2106 | * @since 1.2 | ||
2107 | */ | ||
2108 | EAPI Eina_Value *eina_value_hash_new(const Eina_Value_Type *subtype, unsigned int buckets_power_size) EINA_ARG_NONNULL(1); | ||
2109 | |||
2110 | /** | ||
2111 | * @brief Initialize generic value storage of type hash. | ||
2112 | * @param value value object | ||
2113 | * @param subtype how to manage this hash members. | ||
2114 | * @param buckets_power_size how to allocate hash buckets (2 ^ | ||
2115 | * buckets_power_size), if zero then a sane value is chosen. | ||
2116 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2117 | * | ||
2118 | * Initializes new generic value storage of type hash with the given | ||
2119 | * @a subtype. | ||
2120 | * | ||
2121 | * This is the same as calling eina_value_set() with | ||
2122 | * #EINA_VALUE_TYPE_HASH followed by eina_value_pset() with the | ||
2123 | * #Eina_Value_Hash description configured. | ||
2124 | * | ||
2125 | * @note Existing contents are ignored! If the value was previously used, then | ||
2126 | * use eina_value_flush() first. | ||
2127 | * | ||
2128 | * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY | ||
2129 | * or #EINA_ERROR_VALUE_FAILED is set. | ||
2130 | * | ||
2131 | * @see eina_value_flush() | ||
2132 | * | ||
2133 | * @since 1.2 | ||
2134 | */ | ||
2135 | static inline Eina_Bool eina_value_hash_setup(Eina_Value *value, | ||
2136 | const Eina_Value_Type *subtype, | ||
2137 | unsigned int buckets_power_size) EINA_ARG_NONNULL(1, 2); | ||
2138 | |||
2139 | /** | ||
2140 | * @brief Query number of elements in value of hash type. | ||
2141 | * @param value value object. | ||
2142 | * @return number of child elements. | ||
2143 | * @since 1.2 | ||
2144 | */ | ||
2145 | static inline unsigned int eina_value_hash_population(const Eina_Value *value); | ||
2146 | |||
2147 | /** | ||
2148 | * @brief Remove element at given position in value of hash type. | ||
2149 | * @param value value object. | ||
2150 | * @param key key to find the member | ||
2151 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2152 | * @since 1.2 | ||
2153 | */ | ||
2154 | static inline Eina_Bool eina_value_hash_del(Eina_Value *value, | ||
2155 | const char *key) EINA_ARG_NONNULL(1); | ||
2156 | |||
2157 | /** | ||
2158 | * @brief Set the generic value in an hash member. | ||
2159 | * @param value source value object | ||
2160 | * @param key key to find the member | ||
2161 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2162 | * | ||
2163 | * The variable argument is dependent on chosen subtype. The list for | ||
2164 | * basic types: | ||
2165 | * | ||
2166 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char | ||
2167 | * @li EINA_VALUE_TYPE_USHORT: unsigned short | ||
2168 | * @li EINA_VALUE_TYPE_UINT: unsigned int | ||
2169 | * @li EINA_VALUE_TYPE_ULONG: unsigned long | ||
2170 | * @li EINA_VALUE_TYPE_UINT64: uint64_t | ||
2171 | * @li EINA_VALUE_TYPE_CHAR: char | ||
2172 | * @li EINA_VALUE_TYPE_SHORT: short | ||
2173 | * @li EINA_VALUE_TYPE_INT: int | ||
2174 | * @li EINA_VALUE_TYPE_LONG: long | ||
2175 | * @li EINA_VALUE_TYPE_INT64: int64_t | ||
2176 | * @li EINA_VALUE_TYPE_FLOAT: float | ||
2177 | * @li EINA_VALUE_TYPE_DOUBLE: double | ||
2178 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char * | ||
2179 | * @li EINA_VALUE_TYPE_STRING: const char * | ||
2180 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash | ||
2181 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
2182 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
2183 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
2184 | * | ||
2185 | * @code | ||
2186 | * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); | ||
2187 | * int x; | ||
2188 | * | ||
2189 | * eina_value_hash_set(value, "abc", 5678); | ||
2190 | * eina_value_hash_get(value, "abc", &x); | ||
2191 | * eina_value_free(value); | ||
2192 | * @endcode | ||
2193 | * | ||
2194 | * @see eina_value_hash_get() | ||
2195 | * @see eina_value_hash_vset() | ||
2196 | * @see eina_value_hash_pset() | ||
2197 | * @see eina_value_hash_del() | ||
2198 | * | ||
2199 | * @since 1.2 | ||
2200 | */ | ||
2201 | static inline Eina_Bool eina_value_hash_set(Eina_Value *value, | ||
2202 | const char *key, | ||
2203 | ...) EINA_ARG_NONNULL(1); | ||
2204 | |||
2205 | /** | ||
2206 | * @brief Get the generic value from an hash member. | ||
2207 | * @param value source value object | ||
2208 | * @param key key to find the member | ||
2209 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2210 | * | ||
2211 | * The value is returned in the variable argument parameter, the | ||
2212 | * actual value is type-dependent, but usually it will be what is | ||
2213 | * stored inside the object. There shouldn't be any memory allocation, | ||
2214 | * thus the contents should @b not be freed. | ||
2215 | * | ||
2216 | * The variable argument is dependent on chosen subtype. The list for | ||
2217 | * basic types: | ||
2218 | * | ||
2219 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
2220 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
2221 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
2222 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
2223 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
2224 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
2225 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
2226 | * @li EINA_VALUE_TYPE_INT: int* | ||
2227 | * @li EINA_VALUE_TYPE_LONG: long* | ||
2228 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
2229 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
2230 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
2231 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
2232 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
2233 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
2234 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
2235 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
2236 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
2237 | * | ||
2238 | * @code | ||
2239 | * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); | ||
2240 | * int x; | ||
2241 | * | ||
2242 | * eina_value_hash_set(value, "abc", 1234); | ||
2243 | * eina_value_hash_get(value, "abc", &x); | ||
2244 | * eina_value_free(value); | ||
2245 | * @endcode | ||
2246 | * | ||
2247 | * @see eina_value_hash_set() | ||
2248 | * @see eina_value_hash_vset() | ||
2249 | * @see eina_value_hash_pset() | ||
2250 | * | ||
2251 | * @since 1.2 | ||
2252 | */ | ||
2253 | static inline Eina_Bool eina_value_hash_get(const Eina_Value *value, | ||
2254 | const char *key, | ||
2255 | ...) EINA_ARG_NONNULL(1); | ||
2256 | |||
2257 | /** | ||
2258 | * @brief Set the generic value in an hash member. | ||
2259 | * @param value source value object | ||
2260 | * @param key key to find the member | ||
2261 | * @param args variable argument | ||
2262 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2263 | * @see eina_value_hash_set() | ||
2264 | * @see eina_value_hash_get() | ||
2265 | * @see eina_value_hash_pset() | ||
2266 | * | ||
2267 | * @since 1.2 | ||
2268 | */ | ||
2269 | static inline Eina_Bool eina_value_hash_vset(Eina_Value *value, | ||
2270 | const char *key, | ||
2271 | va_list args) EINA_ARG_NONNULL(1); | ||
2272 | |||
2273 | /** | ||
2274 | * @brief Get the generic value from an hash member. | ||
2275 | * @param value source value object | ||
2276 | * @param key key to find the member | ||
2277 | * @param args variable argument | ||
2278 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2279 | * | ||
2280 | * The value is returned in the variable argument parameter, the | ||
2281 | * actual value is type-dependent, but usually it will be what is | ||
2282 | * stored inside the object. There shouldn't be any memory allocation, | ||
2283 | * thus the contents should @b not be freed. | ||
2284 | * | ||
2285 | * @see eina_value_hash_vset() | ||
2286 | * @see eina_value_hash_get() | ||
2287 | * @see eina_value_hash_pget() | ||
2288 | * | ||
2289 | * @since 1.2 | ||
2290 | */ | ||
2291 | static inline Eina_Bool eina_value_hash_vget(const Eina_Value *value, | ||
2292 | const char *key, | ||
2293 | va_list args) EINA_ARG_NONNULL(1); | ||
2294 | |||
2295 | /** | ||
2296 | * @brief Set the generic value in an hash member from pointer. | ||
2297 | * @param value source value object | ||
2298 | * @param key key to find the member | ||
2299 | * @param ptr pointer to specify the contents. | ||
2300 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2301 | * | ||
2302 | * The pointer type is dependent on chosen value type. The list for | ||
2303 | * basic types: | ||
2304 | * | ||
2305 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
2306 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
2307 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
2308 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
2309 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
2310 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
2311 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
2312 | * @li EINA_VALUE_TYPE_INT: int* | ||
2313 | * @li EINA_VALUE_TYPE_LONG: long* | ||
2314 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
2315 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
2316 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
2317 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
2318 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
2319 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
2320 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
2321 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
2322 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
2323 | * | ||
2324 | * @note the pointer contents are written using the size defined by | ||
2325 | * type. It can be larger than void* or uint64_t. | ||
2326 | * | ||
2327 | * @code | ||
2328 | * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); | ||
2329 | * int x = 1234; | ||
2330 | * | ||
2331 | * eina_value_hash_pset(value, "abc", &x); | ||
2332 | * eina_value_hash_pget(value, "abc", &x); | ||
2333 | * eina_value_free(value); | ||
2334 | * @endcode | ||
2335 | * | ||
2336 | * @see eina_value_hash_set() | ||
2337 | * @see eina_value_hash_get() | ||
2338 | * @see eina_value_hash_vset() | ||
2339 | * | ||
2340 | * @since 1.2 | ||
2341 | */ | ||
2342 | static inline Eina_Bool eina_value_hash_pset(Eina_Value *value, | ||
2343 | const char *key, | ||
2344 | const void *ptr) EINA_ARG_NONNULL(1, 3); | ||
2345 | |||
2346 | /** | ||
2347 | * @brief Get the generic value to pointer from an hash member. | ||
2348 | * @param value source value object | ||
2349 | * @param key key to find the member | ||
2350 | * @param ptr pointer to receive the contents. | ||
2351 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2352 | * | ||
2353 | * The value is returned in pointer contents, the actual value is | ||
2354 | * type-dependent, but usually it will be what is stored inside the | ||
2355 | * object. There shouldn't be any memory allocation, thus the contents | ||
2356 | * should @b not be freed. | ||
2357 | * | ||
2358 | * The pointer type is dependent on chosen value type. The list for | ||
2359 | * basic types: | ||
2360 | * | ||
2361 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
2362 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
2363 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
2364 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
2365 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
2366 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
2367 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
2368 | * @li EINA_VALUE_TYPE_INT: int* | ||
2369 | * @li EINA_VALUE_TYPE_LONG: long* | ||
2370 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
2371 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
2372 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
2373 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
2374 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
2375 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
2376 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
2377 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
2378 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
2379 | * | ||
2380 | * @code | ||
2381 | * Eina_Value *value = eina_value_hash_new(EINA_VALUE_TYPE_INT, 0); | ||
2382 | * int x; | ||
2383 | * | ||
2384 | * eina_value_hash_set(value, "abc", 1234); | ||
2385 | * eina_value_hash_pget(value, "abc", &x); | ||
2386 | * eina_value_free(value); | ||
2387 | * @endcode | ||
2388 | * | ||
2389 | * @see eina_value_hash_set() | ||
2390 | * @see eina_value_hash_vset() | ||
2391 | * @see eina_value_hash_pset() | ||
2392 | * | ||
2393 | * @since 1.2 | ||
2394 | */ | ||
2395 | static inline Eina_Bool eina_value_hash_pget(const Eina_Value *value, | ||
2396 | const char *key, | ||
2397 | void *ptr) EINA_ARG_NONNULL(1, 3); | ||
2398 | |||
2399 | /** | ||
2400 | * @} | ||
2401 | */ | ||
2402 | |||
2403 | /** | ||
2404 | * @defgroup Eina_Value_Blob_Group Generic Value Blob management | ||
2405 | * | ||
2406 | * @{ | ||
2407 | */ | ||
2408 | |||
2409 | /** | ||
2410 | * @typedef Eina_Value_Blob_Operations | ||
2411 | * How to manage blob. Any @c NULL callback is ignored. | ||
2412 | * @since 1.2 | ||
2413 | */ | ||
2414 | typedef struct _Eina_Value_Blob_Operations Eina_Value_Blob_Operations; | ||
2415 | |||
2416 | /** | ||
2417 | * @struct _Eina_Value_Blob_Operations | ||
2418 | * How to manage blob. Any @c NULL callback is ignored. | ||
2419 | * @since 1.2 | ||
2420 | */ | ||
2421 | struct _Eina_Value_Blob_Operations | ||
2422 | { | ||
2423 | #define EINA_VALUE_BLOB_OPERATIONS_VERSION (1) | ||
2424 | unsigned int version; /**< must be EINA_VALUE_BLOB_OPERATIONS_VERSION */ | ||
2425 | void (*free)(const Eina_Value_Blob_Operations *ops, void *memory, size_t size); | ||
2426 | void *(*copy)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size); | ||
2427 | int (*compare)(const Eina_Value_Blob_Operations *ops, const void *data1, size_t size_data1, const void *data2, size_t size_data2); | ||
2428 | char *(*to_string)(const Eina_Value_Blob_Operations *ops, const void *memory, size_t size); | ||
2429 | }; | ||
2430 | |||
2431 | /** | ||
2432 | * @var EINA_VALUE_BLOB_OPERATIONS_MALLOC | ||
2433 | * | ||
2434 | * Assumes @c memory was create with malloc() and applies free() to it | ||
2435 | * during flush (Eina_Value_Blob_Operations::free). Copy is done with | ||
2436 | * malloc() as well. | ||
2437 | * | ||
2438 | * No compare or to_string are provided, defaults will be used. | ||
2439 | */ | ||
2440 | EAPI extern const Eina_Value_Blob_Operations *EINA_VALUE_BLOB_OPERATIONS_MALLOC; | ||
2441 | |||
2442 | /** | ||
2443 | * @typedef Eina_Value_Blob | ||
2444 | * @since 1.2 | ||
2445 | */ | ||
2446 | typedef struct _Eina_Value_Blob Eina_Value_Blob; | ||
2447 | |||
2448 | /** | ||
2449 | * @struct _Eina_Value_Blob | ||
2450 | * @since 1.2 | ||
2451 | */ | ||
2452 | struct _Eina_Value_Blob | ||
2453 | { | ||
2454 | const Eina_Value_Blob_Operations *ops; /**< if @c NULL, nothing is freed, copy will just copy the memory pointer, not its value. */ | ||
2455 | const void *memory; | ||
2456 | unsigned int size; | ||
2457 | }; | ||
2458 | |||
2459 | /** | ||
2460 | * @} | ||
2461 | */ | ||
2462 | |||
2463 | /** | ||
2464 | * @defgroup Eina_Value_Struct_Group Generic Value Struct management | ||
2465 | * | ||
2466 | * @{ | ||
2467 | */ | ||
2468 | |||
2469 | /** | ||
2470 | * @typedef Eina_Value_Struct_Operations | ||
2471 | * How to manage struct. Any @c NULL callback is ignored. | ||
2472 | * @since 1.2 | ||
2473 | */ | ||
2474 | typedef struct _Eina_Value_Struct_Operations Eina_Value_Struct_Operations; | ||
2475 | |||
2476 | /** | ||
2477 | * @typedef Eina_Value_Struct_Member | ||
2478 | * Describes a single member of struct. | ||
2479 | * @since 1.2 | ||
2480 | */ | ||
2481 | typedef struct _Eina_Value_Struct_Member Eina_Value_Struct_Member; | ||
2482 | |||
2483 | /** | ||
2484 | * @typedef Eina_Value_Struct_Desc | ||
2485 | * Describes the struct by listing its size, members and operations. | ||
2486 | * @since 1.2 | ||
2487 | */ | ||
2488 | typedef struct _Eina_Value_Struct_Desc Eina_Value_Struct_Desc; | ||
2489 | |||
2490 | /** | ||
2491 | * @typedef Eina_Value_Struct | ||
2492 | * @since 1.2 | ||
2493 | */ | ||
2494 | typedef struct _Eina_Value_Struct Eina_Value_Struct; | ||
2495 | |||
2496 | /** | ||
2497 | * @struct _Eina_Value_Struct_Operations | ||
2498 | * How to manage struct. Any @c NULL callback is ignored. | ||
2499 | * @since 1.2 | ||
2500 | */ | ||
2501 | struct _Eina_Value_Struct_Operations | ||
2502 | { | ||
2503 | #define EINA_VALUE_STRUCT_OPERATIONS_VERSION (1) | ||
2504 | unsigned int version; /**< must be EINA_VALUE_STRUCT_OPERATIONS_VERSION */ | ||
2505 | void *(*alloc)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc); | ||
2506 | void (*free)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, void *memory); | ||
2507 | void *(*copy)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *memory); | ||
2508 | int (*compare)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *data1, const void *data2); | ||
2509 | const Eina_Value_Struct_Member *(*find_member)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const char *name); /**< replace the function to find description for member. For huge structures consider using binary search, stringshared, hash or gperf. The default function does linear search using strcmp(). */ | ||
2510 | }; | ||
2511 | |||
2512 | /** | ||
2513 | * @var EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH | ||
2514 | * | ||
2515 | * Assumes @c members is sorted by name and applies binary search for | ||
2516 | * names. | ||
2517 | * | ||
2518 | * Ideally the @c member_count field is set to speed it up. | ||
2519 | * | ||
2520 | * No other methods are set (alloc, free, copy, compare), then it uses | ||
2521 | * the default operations. | ||
2522 | */ | ||
2523 | EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH; | ||
2524 | |||
2525 | /** | ||
2526 | * @var EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE | ||
2527 | * | ||
2528 | * Assumes @c members name are stringshared and can be compared for | ||
2529 | * equality without using its contents (simple pointer comparison). | ||
2530 | * | ||
2531 | * Ideally the search @c name will be stringshared as well, but it | ||
2532 | * will do a second loop with a forced stringshare if it did not find | ||
2533 | * the member. | ||
2534 | * | ||
2535 | * No other methods are set (alloc, free, copy, compare), then it uses | ||
2536 | * the default operations. | ||
2537 | */ | ||
2538 | EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE; | ||
2539 | |||
2540 | /** | ||
2541 | * @struct _Eina_Value_Struct_Member | ||
2542 | * @since 1.2 | ||
2543 | */ | ||
2544 | struct _Eina_Value_Struct_Member | ||
2545 | { | ||
2546 | const char *name; | ||
2547 | const Eina_Value_Type *type; | ||
2548 | unsigned int offset; | ||
2549 | }; | ||
2550 | |||
2551 | /** | ||
2552 | * @struct _Eina_Value_Struct_Desc | ||
2553 | * @since 1.2 | ||
2554 | */ | ||
2555 | struct _Eina_Value_Struct_Desc | ||
2556 | { | ||
2557 | #define EINA_VALUE_STRUCT_DESC_VERSION (1) | ||
2558 | unsigned int version; /**< must be EINA_VALUE_STRUCT_DESC_VERSION */ | ||
2559 | const Eina_Value_Struct_Operations *ops; /**< operations, if @c NULL defaults will be used. You may use operations to optimize member lookup using binary search or gperf hash. */ | ||
2560 | const Eina_Value_Struct_Member *members; /**< array of member descriptions, if @c member_count is zero, then it must be @c NULL terminated. */ | ||
2561 | unsigned int member_count; /**< if > 0, specifies number of members. If zero then @c members must be NULL terminated. */ | ||
2562 | unsigned int size; /**< byte size to allocate, may be bigger than sum of members */ | ||
2563 | }; | ||
2564 | |||
2565 | /** | ||
2566 | * @def EINA_VALUE_STRUCT_MEMBER | ||
2567 | * | ||
2568 | * Helper to define Eina_Value_Struct_Member fields, uses offsetof() | ||
2569 | * with type and member. | ||
2570 | * | ||
2571 | * @since 1.2 | ||
2572 | */ | ||
2573 | #define EINA_VALUE_STRUCT_MEMBER(eina_value_type, type, member) \ | ||
2574 | {#member, eina_value_type, offsetof(type, member)} | ||
2575 | |||
2576 | /** | ||
2577 | * @def EINA_VALUE_STRUCT_MEMBER_SENTINEL | ||
2578 | * | ||
2579 | * Helper to define Eina_Value_Struct_Member fields for sentinel (last | ||
2580 | * item), useful if you did not define @c member_count. | ||
2581 | * | ||
2582 | * @since 1.2 | ||
2583 | */ | ||
2584 | #define EINA_VALUE_STRUCT_MEMBER_SENTINEL {NULL, NULL, 0} | ||
2585 | |||
2586 | |||
2587 | /** | ||
2588 | * @struct _Eina_Value_Struct | ||
2589 | * @since 1.2 | ||
2590 | */ | ||
2591 | struct _Eina_Value_Struct | ||
2592 | { | ||
2593 | const Eina_Value_Struct_Desc *desc; | ||
2594 | void *memory; | ||
2595 | }; | ||
2596 | |||
2597 | /** | ||
2598 | * @brief Create generic value storage of type struct. | ||
2599 | * @param desc how to manage this struct members. | ||
2600 | * @return The new value or @c NULL on failure. | ||
2601 | * | ||
2602 | * Create a new generic value storage of type struct. The members are | ||
2603 | * managed using the description specified by @a desc. | ||
2604 | * | ||
2605 | * On failure, @c NULL is returned and #EINA_ERROR_OUT_OF_MEMORY or | ||
2606 | * #EINA_ERROR_VALUE_FAILED is set. | ||
2607 | * | ||
2608 | * @note this creates from mempool and then uses | ||
2609 | * eina_value_struct_setup(). | ||
2610 | * | ||
2611 | * @see eina_value_free() | ||
2612 | * @see eina_value_struct_setup() | ||
2613 | * | ||
2614 | * @since 1.2 | ||
2615 | */ | ||
2616 | EAPI Eina_Value *eina_value_struct_new(const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1); | ||
2617 | |||
2618 | /** | ||
2619 | * @brief Initialize generic value storage of type struct. | ||
2620 | * @param value value object | ||
2621 | * @param desc how to manage this struct members. | ||
2622 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2623 | * | ||
2624 | * Initializes new generic value storage of type struct with the given | ||
2625 | * @a desc. | ||
2626 | * | ||
2627 | * This is the same as calling eina_value_set() with | ||
2628 | * #EINA_VALUE_TYPE_STRUCT followed by eina_value_pset() with the | ||
2629 | * #Eina_Value_Struct description configured. | ||
2630 | * | ||
2631 | * @note Existing contents are ignored! If the value was previously used, then | ||
2632 | * use eina_value_flush() first. | ||
2633 | * | ||
2634 | * On failure, #EINA_FALSE is returned and #EINA_ERROR_OUT_OF_MEMORY | ||
2635 | * or #EINA_ERROR_VALUE_FAILED is set. | ||
2636 | * | ||
2637 | * @see eina_value_flush() | ||
2638 | * | ||
2639 | * @since 1.2 | ||
2640 | */ | ||
2641 | static inline Eina_Bool eina_value_struct_setup(Eina_Value *value, | ||
2642 | const Eina_Value_Struct_Desc *desc) EINA_ARG_NONNULL(1, 2); | ||
2643 | |||
2644 | /** | ||
2645 | * @brief Set the generic value in an struct member. | ||
2646 | * @param value source value object | ||
2647 | * @param name name to find the member | ||
2648 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2649 | * | ||
2650 | * The variable argument is dependent on chosen member type. The list | ||
2651 | * for basic types: | ||
2652 | * | ||
2653 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char | ||
2654 | * @li EINA_VALUE_TYPE_USHORT: unsigned short | ||
2655 | * @li EINA_VALUE_TYPE_UINT: unsigned int | ||
2656 | * @li EINA_VALUE_TYPE_ULONG: unsigned long | ||
2657 | * @li EINA_VALUE_TYPE_UINT64: uint64_t | ||
2658 | * @li EINA_VALUE_TYPE_CHAR: char | ||
2659 | * @li EINA_VALUE_TYPE_SHORT: short | ||
2660 | * @li EINA_VALUE_TYPE_INT: int | ||
2661 | * @li EINA_VALUE_TYPE_LONG: long | ||
2662 | * @li EINA_VALUE_TYPE_INT64: int64_t | ||
2663 | * @li EINA_VALUE_TYPE_FLOAT: float | ||
2664 | * @li EINA_VALUE_TYPE_DOUBLE: double | ||
2665 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char * | ||
2666 | * @li EINA_VALUE_TYPE_STRING: const char * | ||
2667 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash | ||
2668 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
2669 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
2670 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
2671 | * | ||
2672 | * @code | ||
2673 | * struct myst { | ||
2674 | * int i; | ||
2675 | * char c; | ||
2676 | * }; | ||
2677 | * const Eina_Value_Struct_Member myst_members[] = { | ||
2678 | * {"i", EINA_VALUE_TYPE_INT, 0}, | ||
2679 | * {"c", EINA_VALUE_TYPE_CHAR, 4}, | ||
2680 | * {NULL, NULL, 0} | ||
2681 | * }; | ||
2682 | * const Eina_Value_Struct_Desc myst_desc = { | ||
2683 | * EINA_VALUE_STRUCT_DESC_VERSION, | ||
2684 | * NULL, myst_members, 2, sizeof(struct myst) | ||
2685 | * }; | ||
2686 | * Eina_Value *value = eina_value_struct_new(&my_desc); | ||
2687 | * int x; | ||
2688 | * char y; | ||
2689 | * | ||
2690 | * eina_value_struct_set(value, "i", 5678); | ||
2691 | * eina_value_struct_get(value, "i", &x); | ||
2692 | * eina_value_struct_set(value, "c", 0xf); | ||
2693 | * eina_value_struct_get(value, "c", &y); | ||
2694 | * eina_value_free(value); | ||
2695 | * @endcode | ||
2696 | * | ||
2697 | * @see eina_value_struct_get() | ||
2698 | * @see eina_value_struct_vset() | ||
2699 | * @see eina_value_struct_pset() | ||
2700 | * | ||
2701 | * @since 1.2 | ||
2702 | */ | ||
2703 | static inline Eina_Bool eina_value_struct_set(Eina_Value *value, | ||
2704 | const char *name, | ||
2705 | ...) EINA_ARG_NONNULL(1); | ||
2706 | |||
2707 | /** | ||
2708 | * @brief Get the generic value from an struct member. | ||
2709 | * @param value source value object | ||
2710 | * @param name name to find the member | ||
2711 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2712 | * | ||
2713 | * The value is returned in the variable argument parameter, the | ||
2714 | * actual value is type-dependent, but usually it will be what is | ||
2715 | * stored inside the object. There shouldn't be any memory allocation, | ||
2716 | * thus the contents should @b not be freed. | ||
2717 | * | ||
2718 | * The variable argument is dependent on chosen member type. The list | ||
2719 | * for basic types: | ||
2720 | * | ||
2721 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
2722 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
2723 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
2724 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
2725 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
2726 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
2727 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
2728 | * @li EINA_VALUE_TYPE_INT: int* | ||
2729 | * @li EINA_VALUE_TYPE_LONG: long* | ||
2730 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
2731 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
2732 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
2733 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
2734 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
2735 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
2736 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
2737 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
2738 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
2739 | * | ||
2740 | * @code | ||
2741 | * struct myst { | ||
2742 | * int i; | ||
2743 | * char c; | ||
2744 | * }; | ||
2745 | * const Eina_Value_Struct_Member myst_members[] = { | ||
2746 | * {"i", EINA_VALUE_TYPE_INT, 0}, | ||
2747 | * {"c", EINA_VALUE_TYPE_CHAR, 4}, | ||
2748 | * {NULL, NULL, 0} | ||
2749 | * }; | ||
2750 | * const Eina_Value_Struct_Desc myst_desc = { | ||
2751 | * EINA_VALUE_STRUCT_DESC_VERSION, | ||
2752 | * NULL, myst_members, 2, sizeof(struct myst) | ||
2753 | * }; | ||
2754 | * Eina_Value *value = eina_value_struct_new(&my_desc); | ||
2755 | * int x; | ||
2756 | * char y; | ||
2757 | * | ||
2758 | * eina_value_struct_set(value, "i", 5678); | ||
2759 | * eina_value_struct_get(value, "i", &x); | ||
2760 | * eina_value_struct_set(value, "c", 0xf); | ||
2761 | * eina_value_struct_get(value, "c", &y); | ||
2762 | * eina_value_free(value); | ||
2763 | * @endcode | ||
2764 | * | ||
2765 | * @see eina_value_struct_set() | ||
2766 | * @see eina_value_struct_vset() | ||
2767 | * @see eina_value_struct_pset() | ||
2768 | * | ||
2769 | * @since 1.2 | ||
2770 | */ | ||
2771 | static inline Eina_Bool eina_value_struct_get(const Eina_Value *value, | ||
2772 | const char *name, | ||
2773 | ...) EINA_ARG_NONNULL(1); | ||
2774 | |||
2775 | /** | ||
2776 | * @brief Set the generic value in an struct member. | ||
2777 | * @param value source value object | ||
2778 | * @param name name to find the member | ||
2779 | * @param args variable argument | ||
2780 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2781 | * @see eina_value_struct_set() | ||
2782 | * @see eina_value_struct_get() | ||
2783 | * @see eina_value_struct_pset() | ||
2784 | * | ||
2785 | * @since 1.2 | ||
2786 | */ | ||
2787 | static inline Eina_Bool eina_value_struct_vset(Eina_Value *value, | ||
2788 | const char *name, | ||
2789 | va_list args) EINA_ARG_NONNULL(1); | ||
2790 | |||
2791 | /** | ||
2792 | * @brief Get the generic value from an struct member. | ||
2793 | * @param value source value object | ||
2794 | * @param name name to find the member | ||
2795 | * @param args variable argument | ||
2796 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2797 | * | ||
2798 | * The value is returned in the variable argument parameter, the | ||
2799 | * actual value is type-dependent, but usually it will be what is | ||
2800 | * stored inside the object. There shouldn't be any memory allocation, | ||
2801 | * thus the contents should @b not be freed. | ||
2802 | * | ||
2803 | * @see eina_value_struct_vset() | ||
2804 | * @see eina_value_struct_get() | ||
2805 | * @see eina_value_struct_pget() | ||
2806 | * | ||
2807 | * @since 1.2 | ||
2808 | */ | ||
2809 | static inline Eina_Bool eina_value_struct_vget(const Eina_Value *value, | ||
2810 | const char *name, | ||
2811 | va_list args) EINA_ARG_NONNULL(1); | ||
2812 | |||
2813 | /** | ||
2814 | * @brief Set the generic value in an struct member from pointer. | ||
2815 | * @param value source value object | ||
2816 | * @param name name to find the member | ||
2817 | * @param ptr pointer to specify the contents. | ||
2818 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2819 | * | ||
2820 | * The pointer type is dependent on chosen value type. The list for | ||
2821 | * basic types: | ||
2822 | * | ||
2823 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
2824 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
2825 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
2826 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
2827 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
2828 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
2829 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
2830 | * @li EINA_VALUE_TYPE_INT: int* | ||
2831 | * @li EINA_VALUE_TYPE_LONG: long* | ||
2832 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
2833 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
2834 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
2835 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
2836 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
2837 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
2838 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
2839 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
2840 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
2841 | * | ||
2842 | * @note the pointer contents are written using the size defined by | ||
2843 | * type. It can be larger than void* or uint64_t. | ||
2844 | * | ||
2845 | * @code | ||
2846 | * struct myst { | ||
2847 | * int i; | ||
2848 | * char c; | ||
2849 | * }; | ||
2850 | * const Eina_Value_Struct_Member myst_members[] = { | ||
2851 | * {"i", EINA_VALUE_TYPE_INT, 0}, | ||
2852 | * {"c", EINA_VALUE_TYPE_CHAR, 4}, | ||
2853 | * {NULL, NULL, 0} | ||
2854 | * }; | ||
2855 | * const Eina_Value_Struct_Desc myst_desc = { | ||
2856 | * EINA_VALUE_STRUCT_DESC_VERSION, | ||
2857 | * NULL, myst_members, 2, sizeof(struct myst) | ||
2858 | * }; | ||
2859 | * Eina_Value *value = eina_value_struct_new(&my_desc); | ||
2860 | * int x = 5678; | ||
2861 | * char y = 0xf; | ||
2862 | * | ||
2863 | * eina_value_struct_pset(value, "i", &); | ||
2864 | * eina_value_struct_pget(value, "i", &x); | ||
2865 | * eina_value_struct_pset(value, "c", &y); | ||
2866 | * eina_value_struct_pget(value, "c", &y); | ||
2867 | * eina_value_free(value); | ||
2868 | * @endcode | ||
2869 | * | ||
2870 | * @see eina_value_struct_set() | ||
2871 | * @see eina_value_struct_get() | ||
2872 | * @see eina_value_struct_vset() | ||
2873 | * | ||
2874 | * @since 1.2 | ||
2875 | */ | ||
2876 | static inline Eina_Bool eina_value_struct_pset(Eina_Value *value, | ||
2877 | const char *name, | ||
2878 | const void *ptr) EINA_ARG_NONNULL(1, 3); | ||
2879 | |||
2880 | /** | ||
2881 | * @brief Get the generic value to pointer from an struct member. | ||
2882 | * @param value source value object | ||
2883 | * @param name name to find the member | ||
2884 | * @param ptr pointer to receive the contents. | ||
2885 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
2886 | * | ||
2887 | * The value is returned in pointer contents, the actual value is | ||
2888 | * type-dependent, but usually it will be what is stored inside the | ||
2889 | * object. There shouldn't be any memory allocation, thus the contents | ||
2890 | * should @b not be freed. | ||
2891 | * | ||
2892 | * The pointer type is dependent on chosen value type. The list for | ||
2893 | * basic types: | ||
2894 | * | ||
2895 | * @li EINA_VALUE_TYPE_UCHAR: unsigned char* | ||
2896 | * @li EINA_VALUE_TYPE_USHORT: unsigned short* | ||
2897 | * @li EINA_VALUE_TYPE_UINT: unsigned int* | ||
2898 | * @li EINA_VALUE_TYPE_ULONG: unsigned long* | ||
2899 | * @li EINA_VALUE_TYPE_UINT64: uint64_t* | ||
2900 | * @li EINA_VALUE_TYPE_CHAR: char* | ||
2901 | * @li EINA_VALUE_TYPE_SHORT: short* | ||
2902 | * @li EINA_VALUE_TYPE_INT: int* | ||
2903 | * @li EINA_VALUE_TYPE_LONG: long* | ||
2904 | * @li EINA_VALUE_TYPE_INT64: int64_t* | ||
2905 | * @li EINA_VALUE_TYPE_FLOAT: float* | ||
2906 | * @li EINA_VALUE_TYPE_DOUBLE: double* | ||
2907 | * @li EINA_VALUE_TYPE_STRINGSHARE: const char ** | ||
2908 | * @li EINA_VALUE_TYPE_STRING: const char ** | ||
2909 | * @li EINA_VALUE_TYPE_HASH: Eina_Value_Hash* | ||
2910 | * @li EINA_VALUE_TYPE_TIMEVAL: struct timeval* | ||
2911 | * @li EINA_VALUE_TYPE_BLOB: Eina_Value_Blob* | ||
2912 | * @li EINA_VALUE_TYPE_STRUCT: Eina_Value_Struct* | ||
2913 | * | ||
2914 | * @code | ||
2915 | * struct myst { | ||
2916 | * int i; | ||
2917 | * char c; | ||
2918 | * }; | ||
2919 | * const Eina_Value_Struct_Member myst_members[] = { | ||
2920 | * {"i", EINA_VALUE_TYPE_INT, 0}, | ||
2921 | * {"c", EINA_VALUE_TYPE_CHAR, 4}, | ||
2922 | * {NULL, NULL, 0} | ||
2923 | * }; | ||
2924 | * const Eina_Value_Struct_Desc myst_desc = { | ||
2925 | * EINA_VALUE_STRUCT_DESC_VERSION, | ||
2926 | * NULL, myst_members, 2, sizeof(struct myst) | ||
2927 | * }; | ||
2928 | * Eina_Value *value = eina_value_struct_new(&my_desc); | ||
2929 | * int x = 5678; | ||
2930 | * char y = 0xf; | ||
2931 | * | ||
2932 | * eina_value_struct_pset(value, "i", &); | ||
2933 | * eina_value_struct_pget(value, "i", &x); | ||
2934 | * eina_value_struct_pset(value, "c", &y); | ||
2935 | * eina_value_struct_pget(value, "c", &y); | ||
2936 | * eina_value_free(value); | ||
2937 | * @endcode | ||
2938 | * | ||
2939 | * @see eina_value_struct_set() | ||
2940 | * @see eina_value_struct_vset() | ||
2941 | * @see eina_value_struct_pset() | ||
2942 | * | ||
2943 | * @since 1.2 | ||
2944 | */ | ||
2945 | static inline Eina_Bool eina_value_struct_pget(const Eina_Value *value, | ||
2946 | const char *name, | ||
2947 | void *ptr) EINA_ARG_NONNULL(1, 3); | ||
2948 | |||
2949 | /** | ||
2950 | * @} | ||
2951 | */ | ||
2952 | |||
2953 | |||
2954 | /** | ||
2955 | * @defgroup Eina_Value_Type_Group Generic Value Type management | ||
2956 | * | ||
2957 | * @{ | ||
2958 | */ | ||
2959 | |||
2960 | /** | ||
2961 | * @struct _Eina_Value_Type | ||
2962 | * API to access values. | ||
2963 | * | ||
2964 | * @since 1.2 | ||
2965 | */ | ||
2966 | struct _Eina_Value_Type | ||
2967 | { | ||
2968 | /** | ||
2969 | * @def EINA_VALUE_TYPE_VERSION | ||
2970 | * Current API version, used to validate type. | ||
2971 | */ | ||
2972 | #define EINA_VALUE_TYPE_VERSION (1) | ||
2973 | unsigned int version; /**< must be #EINA_VALUE_TYPE_VERSION */ | ||
2974 | unsigned int value_size; /**< byte size of value */ | ||
2975 | const char *name; /**< name for debug and introspection */ | ||
2976 | Eina_Bool (*setup)(const Eina_Value_Type *type, void *mem); /**< mem will be malloc(value_size) and should be configured */ | ||
2977 | Eina_Bool (*flush)(const Eina_Value_Type *type, void *mem); /**< clear any values from mem */ | ||
2978 | Eina_Bool (*copy)(const Eina_Value_Type *type, const void *src, void *dst); /**< how to copy values, both memory are @c value_size */ | ||
2979 | int (*compare)(const Eina_Value_Type *type, const void *a, const void *b); /**< how to compare values, both memory are @c value_size */ | ||
2980 | Eina_Bool (*convert_to)(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem); /**< how to convert values, both memory are @c value_size */ | ||
2981 | Eina_Bool (*convert_from)(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem); /**< how to convert values, both memory are @c value_size */ | ||
2982 | Eina_Bool (*vset)(const Eina_Value_Type *type, void *mem, va_list args); /**< how to set memory from variable argument */ | ||
2983 | Eina_Bool (*pset)(const Eina_Value_Type *type, void *mem, const void *ptr); /**< how to set memory from pointer */ | ||
2984 | Eina_Bool (*pget)(const Eina_Value_Type *type, const void *mem, void *ptr); /**< how to read memory */ | ||
2985 | }; | ||
2986 | |||
2987 | /** | ||
2988 | * @brief Query type name. | ||
2989 | * @param type type reference. | ||
2990 | * @return string or @c NULL if type is invalid. | ||
2991 | * @since 1.2 | ||
2992 | */ | ||
2993 | EAPI const char *eina_value_type_name_get(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | ||
2994 | |||
2995 | /** | ||
2996 | * @brief Check if type is valid. | ||
2997 | * @param type type reference. | ||
2998 | * @return #EINA_TRUE if valid, #EINA_FALSE otherwise. | ||
2999 | * | ||
3000 | * A type is invalid if it's NULL or if version field is not the same | ||
3001 | * as runtime #EINA_VALUE_TYPE_VERSION. | ||
3002 | * | ||
3003 | * @since 1.2 | ||
3004 | */ | ||
3005 | EAPI Eina_Bool eina_value_type_check(const Eina_Value_Type *type) EINA_PURE EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; | ||
3006 | |||
3007 | /** | ||
3008 | * @brief Initialize memory using type descriptor. | ||
3009 | * @param type type reference. | ||
3010 | * @param mem memory to operate, must be of size @c type->value_size. | ||
3011 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
3012 | * @since 1.2 | ||
3013 | */ | ||
3014 | static inline Eina_Bool eina_value_type_setup(const Eina_Value_Type *type, void *mem); | ||
3015 | |||
3016 | /** | ||
3017 | * @brief Flush (clear) memory using type descriptor. | ||
3018 | * @param type type reference. | ||
3019 | * @param mem memory to operate, must be of size @c type->value_size. | ||
3020 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
3021 | * @since 1.2 | ||
3022 | */ | ||
3023 | static inline Eina_Bool eina_value_type_flush(const Eina_Value_Type *type, void *mem); | ||
3024 | |||
3025 | /** | ||
3026 | * @brief Copy memory using type descriptor. | ||
3027 | * @param type type reference. | ||
3028 | * @param src memory to operate, must be of size @c type->value_size. | ||
3029 | * @param dst memory to operate, must be of size @c type->value_size. | ||
3030 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
3031 | * @since 1.2 | ||
3032 | */ | ||
3033 | static inline Eina_Bool eina_value_type_copy(const Eina_Value_Type *type, const void *src, void *dst); | ||
3034 | |||
3035 | /** | ||
3036 | * @brief Compare memory using type descriptor. | ||
3037 | * @param type type reference. | ||
3038 | * @param a memory to operate, must be of size @c type->value_size. | ||
3039 | * @param b memory to operate, must be of size @c type->value_size. | ||
3040 | * @return less than zero if a < b, greater than zero if a > b, zero if equal. | ||
3041 | * @since 1.2 | ||
3042 | */ | ||
3043 | static inline int eina_value_type_compare(const Eina_Value_Type *type, const void *a, const void *b); | ||
3044 | |||
3045 | /** | ||
3046 | * @brief Convert memory using type descriptor. | ||
3047 | * @param type type reference of the source. | ||
3048 | * @param convert type reference of the destination. | ||
3049 | * @param type_mem memory to operate, must be of size @c type->value_size. | ||
3050 | * @param convert_mem memory to operate, must be of size @c convert->value_size. | ||
3051 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
3052 | * @since 1.2 | ||
3053 | */ | ||
3054 | static inline Eina_Bool eina_value_type_convert_to(const Eina_Value_Type *type, const Eina_Value_Type *convert, const void *type_mem, void *convert_mem); | ||
3055 | |||
3056 | /** | ||
3057 | * @brief Convert memory using type descriptor. | ||
3058 | * @param type type reference of the destination. | ||
3059 | * @param convert type reference of the source. | ||
3060 | * @param type_mem memory to operate, must be of size @c type->value_size. | ||
3061 | * @param convert_mem memory to operate, must be of size @c convert->value_size. | ||
3062 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
3063 | * @since 1.2 | ||
3064 | */ | ||
3065 | static inline Eina_Bool eina_value_type_convert_from(const Eina_Value_Type *type, const Eina_Value_Type *convert, void *type_mem, const void *convert_mem); | ||
3066 | |||
3067 | /** | ||
3068 | * @brief Set memory using type descriptor and variable argument. | ||
3069 | * @param type type reference of the source. | ||
3070 | * @param mem memory to operate, must be of size @c type->value_size. | ||
3071 | * @param args input value. | ||
3072 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
3073 | * @since 1.2 | ||
3074 | */ | ||
3075 | static inline Eina_Bool eina_value_type_vset(const Eina_Value_Type *type, void *mem, va_list args); | ||
3076 | |||
3077 | /** | ||
3078 | * @brief Set memory using type descriptor and pointer. | ||
3079 | * @param type type reference of the source. | ||
3080 | * @param mem memory to operate, must be of size @c type->value_size. | ||
3081 | * @param ptr pointer to input value. | ||
3082 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
3083 | * @since 1.2 | ||
3084 | */ | ||
3085 | static inline Eina_Bool eina_value_type_pset(const Eina_Value_Type *type, void *mem, const void *ptr); | ||
3086 | |||
3087 | /** | ||
3088 | * @brief Get memory using type descriptor. | ||
3089 | * @param type type reference of the source. | ||
3090 | * @param mem memory to operate, must be of size @c type->value_size. | ||
3091 | * @param ptr pointer to output. | ||
3092 | * @return #EINA_TRUE on success, #EINA_FALSE otherwise. | ||
3093 | * @since 1.2 | ||
3094 | */ | ||
3095 | static inline Eina_Bool eina_value_type_pget(const Eina_Value_Type *type, const void *mem, void *ptr); | ||
3096 | |||
3097 | /** | ||
3098 | * @} | ||
3099 | */ | ||
3100 | |||
3101 | #include "eina_inline_value.x" | ||
3102 | |||
3103 | /** | ||
3104 | * @} | ||
3105 | */ | ||
3106 | |||
3107 | /** | ||
3108 | * @} | ||
3109 | */ | ||
3110 | |||
3111 | /** | ||
3112 | * @} | ||
3113 | */ | ||
3114 | #endif | ||
diff --git a/libraries/eina/src/include/eina_xattr.h b/libraries/eina/src/include/eina_xattr.h index 8ddb30a..0f89cc3 100644 --- a/libraries/eina/src/include/eina_xattr.h +++ b/libraries/eina/src/include/eina_xattr.h | |||
@@ -39,6 +39,14 @@ typedef enum { | |||
39 | EINA_XATTR_CREATED /**< This will only succeed if the extended attribute wasn't previously set */ | 39 | EINA_XATTR_CREATED /**< This will only succeed if the extended attribute wasn't previously set */ |
40 | } Eina_Xattr_Flags; | 40 | } Eina_Xattr_Flags; |
41 | 41 | ||
42 | typedef struct _Eina_Xattr Eina_Xattr; | ||
43 | struct _Eina_Xattr | ||
44 | { | ||
45 | const char *name; /**< The eXtended attribute name @since 1.2 */ | ||
46 | const char *value; /**< The eXtended attribute value @since 1.2 */ | ||
47 | |||
48 | size_t length; /**< The length of the eXtended attribute value @since 1.2 */ | ||
49 | }; | ||
42 | 50 | ||
43 | /** | 51 | /** |
44 | * @brief Get an iterator that list all extended attribute of a file. | 52 | * @brief Get an iterator that list all extended attribute of a file. |
@@ -54,10 +62,49 @@ typedef enum { | |||
54 | EAPI Eina_Iterator *eina_xattr_ls(const char *file); | 62 | EAPI Eina_Iterator *eina_xattr_ls(const char *file); |
55 | 63 | ||
56 | /** | 64 | /** |
65 | * @brief Get an iterator that list all extended attribute value related to a fd. | ||
66 | * | ||
67 | * @param file The filename to retrieve the extended attribute list from. | ||
68 | * @return an iterator. | ||
69 | * | ||
70 | * The iterator will not allocate any data during the iteration step, so you need to copy them yourself | ||
71 | * if you need. The iterator will provide an Eina_Xattr structure. | ||
72 | * | ||
73 | * @since 1.2 | ||
74 | */ | ||
75 | EAPI Eina_Iterator *eina_xattr_value_ls(const char *file); | ||
76 | |||
77 | /** | ||
78 | * @brief Get an iterator that list all extended attribute related to a fd. | ||
79 | * | ||
80 | * @param fd The file descriptor to retrieve the extended attribute list from. | ||
81 | * @return an iterator. | ||
82 | * | ||
83 | * The iterator will not allocate any data during the iteration step, so you need to copy them yourself | ||
84 | * if you need. | ||
85 | * | ||
86 | * @since 1.2 | ||
87 | */ | ||
88 | EAPI Eina_Iterator *eina_xattr_fd_ls(int fd); | ||
89 | |||
90 | /** | ||
91 | * @brief Get an iterator that list all extended attribute value related to a fd. | ||
92 | * | ||
93 | * @param fd The file descriptor to retrieve the extended attribute list from. | ||
94 | * @return an iterator. | ||
95 | * | ||
96 | * The iterator will not allocate any data during the iteration step, so you need to copy them yourself | ||
97 | * if you need. The iterator will provide an Eina_Xattr structure. | ||
98 | * | ||
99 | * @since 1.2 | ||
100 | */ | ||
101 | EAPI Eina_Iterator *eina_xattr_value_fd_ls(int fd); | ||
102 | |||
103 | /** | ||
57 | * @brief Retrieve an extended attribute from a file. | 104 | * @brief Retrieve an extended attribute from a file. |
58 | * | 105 | * |
59 | * @param file The file to retrieve the extended attribute from. | 106 | * @param file The file to retrieve the extended attribute from. |
60 | * @param atttribute The extended attribute name to retrieve. | 107 | * @param attribute The extended attribute name to retrieve. |
61 | * @param size The size of the retrieved extended attribute. | 108 | * @param size The size of the retrieved extended attribute. |
62 | * @return the allocated data that hold the extended attribute value. | 109 | * @return the allocated data that hold the extended attribute value. |
63 | * | 110 | * |
@@ -112,7 +159,7 @@ EAPI char *eina_xattr_string_get(const char *file, const char *attribute); | |||
112 | * | 159 | * |
113 | * @param file The file to set the double to. | 160 | * @param file The file to set the double to. |
114 | * @param attribute The attribute to set. | 161 | * @param attribute The attribute to set. |
115 | * @param data The NULL terminated double to set. | 162 | * @param value The NULL terminated double to set. |
116 | * @param flags Define the set policy. | 163 | * @param flags Define the set policy. |
117 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | 164 | * @return EINA_TRUE on success, EINA_FALSE otherwise. |
118 | * | 165 | * |
@@ -139,7 +186,7 @@ EAPI Eina_Bool eina_xattr_double_get(const char *file, const char *attribute, do | |||
139 | * | 186 | * |
140 | * @param file The file to set the int to. | 187 | * @param file The file to set the int to. |
141 | * @param attribute The attribute to set. | 188 | * @param attribute The attribute to set. |
142 | * @param data The NULL terminated int to set. | 189 | * @param value The NULL terminated int to set. |
143 | * @param flags Define the set policy. | 190 | * @param flags Define the set policy. |
144 | * @return EINA_TRUE on success, EINA_FALSE otherwise. | 191 | * @return EINA_TRUE on success, EINA_FALSE otherwise. |
145 | * | 192 | * |