aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/include
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-04-22 09:19:23 +1000
committerDavid Walter Seikel2012-04-22 09:19:23 +1000
commitc963d75dfdeec11f82e79e727062fbf89afa2c04 (patch)
tree895633dbf641110be46f117c29890c49b3ffc0bd /libraries/eina/src/include
parentAdding the new extantz viewer and grid manager. (diff)
downloadSledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.zip
SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.gz
SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.bz2
SledjHamr-c963d75dfdeec11f82e79e727062fbf89afa2c04.tar.xz
Update EFL to latest beta.
Diffstat (limited to 'libraries/eina/src/include')
-rw-r--r--libraries/eina/src/include/Eina.h44
-rw-r--r--libraries/eina/src/include/Makefile.am3
-rw-r--r--libraries/eina/src/include/Makefile.in48
-rw-r--r--libraries/eina/src/include/eina_array.h2
-rw-r--r--libraries/eina/src/include/eina_config.h9
-rw-r--r--libraries/eina/src/include/eina_config.h.in9
-rw-r--r--libraries/eina/src/include/eina_error.h2
-rw-r--r--libraries/eina/src/include/eina_file.h51
-rw-r--r--libraries/eina/src/include/eina_inarray.h148
-rw-r--r--libraries/eina/src/include/eina_inline_lock_win32.x70
-rw-r--r--libraries/eina/src/include/eina_inline_stringshare.x4
-rw-r--r--libraries/eina/src/include/eina_inline_value.x281
-rw-r--r--libraries/eina/src/include/eina_list.h6
-rw-r--r--libraries/eina/src/include/eina_stringshare.h43
-rw-r--r--libraries/eina/src/include/eina_types.h32
-rw-r--r--libraries/eina/src/include/eina_value.h511
16 files changed, 1047 insertions, 216 deletions
diff --git a/libraries/eina/src/include/Eina.h b/libraries/eina/src/include/Eina.h
index 721a991..d99b129 100644
--- a/libraries/eina/src/include/Eina.h
+++ b/libraries/eina/src/include/Eina.h
@@ -1,5 +1,5 @@
1/* EINA - EFL data type library 1/* EINA - EFL data type library
2 * Copyright (C) 2008-2011 Enlightenment Developers: 2 * Copyright (C) 2008-2012 Enlightenment Developers:
3 * Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com> 3 * Albin "Lutin" Tonnerre <albin.tonnerre@gmail.com>
4 * Alexandre "diaxen" Becoulet <diaxen@free.fr> 4 * Alexandre "diaxen" Becoulet <diaxen@free.fr>
5 * Andre Dieb <andre.dieb@gmail.com> 5 * Andre Dieb <andre.dieb@gmail.com>
@@ -16,6 +16,7 @@
16 * Tilman Sauerbeck <tilman@code-monkey.de> 16 * Tilman Sauerbeck <tilman@code-monkey.de>
17 * Vincent "caro" Torri <vtorri at univ-evry dot fr> 17 * Vincent "caro" Torri <vtorri at univ-evry dot fr>
18 * Tom Hacohen <tom@stosb.com> 18 * Tom Hacohen <tom@stosb.com>
19 * Jonas M. Gastal <jgastal@profusion.mobi>
19 * 20 *
20 * This library is free software; you can redistribute it and/or 21 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public 22 * modify it under the terms of the GNU Lesser General Public
@@ -46,7 +47,7 @@
46 * @mainpage Eina 47 * @mainpage Eina
47 * 48 *
48 * @version 1.1 49 * @version 1.1
49 * @date 2008-2011 50 * @date 2008-2012
50 * 51 *
51 * @section eina_intro_sec Introduction 52 * @section eina_intro_sec Introduction
52 * 53 *
@@ -72,6 +73,8 @@
72 * @li @ref Eina_Stringshare_Group saves memory by sharing read-only string references. 73 * @li @ref Eina_Stringshare_Group saves memory by sharing read-only string references.
73 * @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regions. 74 * @li @ref Eina_Tiler_Group split, merge and navigates into 2D tiled regions.
74 * @li @ref Eina_Trash_Group container of unused but allocated data. 75 * @li @ref Eina_Trash_Group container of unused but allocated data.
76 * @li @ref Eina_Value_Group container for generic value storage and access.
77 * @li @ref Eina_Model_Group container for data with user defined hierarchy/structure.
75 * 78 *
76 * The tools that are available are (see @ref Eina_Tools_Group): 79 * The tools that are available are (see @ref Eina_Tools_Group):
77 * @li @ref Eina_Benchmark_Group helper to write benchmarks. 80 * @li @ref Eina_Benchmark_Group helper to write benchmarks.
@@ -101,6 +104,31 @@
101 * their elements with an @ref Eina_Iterator_Group, or eventually an 104 * their elements with an @ref Eina_Iterator_Group, or eventually an
102 * @ref Eina_Accessor_Group. 105 * @ref Eina_Accessor_Group.
103 * 106 *
107 * The containers in eina are designed with performance in mind, one consequence
108 * of this is that they @b don't check the validity of data structures given to
109 * them(@ref Eina_Magic_Group).
110 *
111 * The choice of which container to use in each situation is very important in
112 * achieving good performance and readable code. The most common container types
113 * to be used are:
114 * @li List
115 * @li Inline list
116 * @li Array
117 * @li Inline array
118 * @li Hash
119 *
120 * All types have virtues and vices. The following considerations are good
121 * starting point in deciding which container to use:
122 * @li Hashes are appropriate for datasets which will be searched often;
123 * @li arrays are good when accessing members by position;
124 * @li lists provide good versatility for adding elements in any position with
125 * minimal overhead;
126 * @li inline arrays use very little memory and don't cause fragmentation and
127 * therefore are a good option in memory constrained systems;
128 * @li inline lists are the appropriate type to use when the flexibility of a
129 * list is required but the overhead of pointer indirection is not acceptable.
130 * @warning These are general considerations, every situation is different,
131 * don't follow these recommendations blindly.
104 * 132 *
105 * @defgroup Eina_Tools_Group Tools 133 * @defgroup Eina_Tools_Group Tools
106 * 134 *
@@ -120,15 +148,22 @@
120 * @author Carsten Haitzler <raster@@rasterman.com> 148 * @author Carsten Haitzler <raster@@rasterman.com>
121 * @author Cedric Bail <cedric.bail@@free.fr> 149 * @author Cedric Bail <cedric.bail@@free.fr>
122 * @author Corey "atmos" Donohoe <atmos@@atmos.org> 150 * @author Corey "atmos" Donohoe <atmos@@atmos.org>
151 * @author Vincent "caro" Torri <vtorri at univ-evry dot fr>
123 * @author Fabiano FidĂȘncio <fidencio@@profusion.mobi> 152 * @author Fabiano FidĂȘncio <fidencio@@profusion.mobi>
124 * @author Gustavo Chaves <glima@@profusion.mobi> 153 * @author Gustavo Chaves <glima@@profusion.mobi>
125 * @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi> 154 * @author Gustavo Sverzut Barbieri <barbieri@@profusion.mobi>
126 * @author Jorge Luis "turran" Zapata <jorgeluis.zapata@@gmail.com> 155 * @author Jorge Luis "turran" Zapata <jorgeluis.zapata@@gmail.com>
156 * @author Tilman Sauerbeck <tilman@@code-monkey.de>
127 * @author Peter "pfritz" Wehrfritz <peter.wehrfritz@@web.de> 157 * @author Peter "pfritz" Wehrfritz <peter.wehrfritz@@web.de>
128 * @author Raphael Kubo da Costa <kubo@@profusion.mobi> 158 * @author Raphael Kubo da Costa <kubo@@profusion.mobi>
129 * @author Tilman Sauerbeck <tilman@@code-monkey.de>
130 * @author Vincent "caro" Torri <vtorri at univ-evry dot fr>
131 * @author Tom Hacohen <tom@@stosb.com> 159 * @author Tom Hacohen <tom@@stosb.com>
160 * @author Brett Nash <nash@@nash.id.au>
161 * @author Sebastian Dransfeld <sd@@tango.flipp.net>
162 * @author Myungjae Lee <mjae.lee@@samsung.com>
163 * @author Youness Alaoui <kakaroto@@kakaroto.homelinux.net>
164 * @author Boris "billiob" Faure <billiob@@gmail.com>
165 * @author Sung W. Park <sungwoo@@gmail.com>
166 * @author Guillaume Friloux <guillaume.friloux@@asp64.com>
132 * 167 *
133 * Please contact <enlightenment-devel@lists.sourceforge.net> to get in 168 * Please contact <enlightenment-devel@lists.sourceforge.net> to get in
134 * contact with the developers and maintainers. 169 * contact with the developers and maintainers.
@@ -189,6 +224,7 @@ extern "C" {
189#include "eina_mmap.h" 224#include "eina_mmap.h"
190#include "eina_xattr.h" 225#include "eina_xattr.h"
191#include "eina_value.h" 226#include "eina_value.h"
227#include "eina_model.h"
192 228
193#ifdef __cplusplus 229#ifdef __cplusplus
194} 230}
diff --git a/libraries/eina/src/include/Makefile.am b/libraries/eina/src/include/Makefile.am
index a818d5f..31ef71e 100644
--- a/libraries/eina/src/include/Makefile.am
+++ b/libraries/eina/src/include/Makefile.am
@@ -64,7 +64,8 @@ eina_refcount.h \
64eina_mmap.h \ 64eina_mmap.h \
65eina_xattr.h \ 65eina_xattr.h \
66eina_value.h \ 66eina_value.h \
67eina_inline_value.x 67eina_inline_value.x \
68eina_model.h
68 69
69# Will be back for developper after 1.1. 70# Will be back for developper after 1.1.
70# eina_object.h 71# eina_object.h
diff --git a/libraries/eina/src/include/Makefile.in b/libraries/eina/src/include/Makefile.in
index ea922e5..7e819b8 100644
--- a/libraries/eina/src/include/Makefile.in
+++ b/libraries/eina/src/include/Makefile.in
@@ -46,20 +46,24 @@ DIST_COMMON = $(am__dist_installed_headers_DATA_DIST) \
46 $(dist_installed_mainheader_DATA) $(srcdir)/Makefile.am \ 46 $(dist_installed_mainheader_DATA) $(srcdir)/Makefile.am \
47 $(srcdir)/Makefile.in $(srcdir)/eina_config.h.in 47 $(srcdir)/Makefile.in $(srcdir)/eina_config.h.in
48ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 48ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
49am__aclocal_m4_deps = $(top_srcdir)/m4/efl_attribute.m4 \ 49am__aclocal_m4_deps = $(top_srcdir)/m4/eina/eina_bench.m4 \
50 $(top_srcdir)/m4/efl_benchmark.m4 \ 50 $(top_srcdir)/m4/eina/eina_check.m4 \
51 $(top_srcdir)/m4/efl_compiler_flag.m4 \ 51 $(top_srcdir)/m4/common/efl_attribute.m4 \
52 $(top_srcdir)/m4/efl_coverage.m4 $(top_srcdir)/m4/efl_cpu.m4 \ 52 $(top_srcdir)/m4/common/efl_benchmark.m4 \
53 $(top_srcdir)/m4/efl_doxygen.m4 \ 53 $(top_srcdir)/m4/common/efl_compiler_flag.m4 \
54 $(top_srcdir)/m4/efl_examples.m4 \ 54 $(top_srcdir)/m4/common/efl_coverage.m4 \
55 $(top_srcdir)/m4/efl_fnmatch.m4 \ 55 $(top_srcdir)/m4/common/efl_cpu.m4 \
56 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \ 56 $(top_srcdir)/m4/common/efl_doxygen.m4 \
57 $(top_srcdir)/m4/efl_threads.m4 \ 57 $(top_srcdir)/m4/common/efl_examples.m4 \
58 $(top_srcdir)/m4/efl_voltron.m4 $(top_srcdir)/m4/eina_bench.m4 \ 58 $(top_srcdir)/m4/common/efl_fnmatch.m4 \
59 $(top_srcdir)/m4/eina_check.m4 $(top_srcdir)/m4/libtool.m4 \ 59 $(top_srcdir)/m4/common/efl_path_max.m4 \
60 $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ 60 $(top_srcdir)/m4/common/efl_tests.m4 \
61 $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ 61 $(top_srcdir)/m4/common/efl_threads.m4 \
62 $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac 62 $(top_srcdir)/m4/common/efl_voltron.m4 \
63 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
64 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
65 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/acinclude.m4 \
66 $(top_srcdir)/configure.ac
63am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 67am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
64 $(ACLOCAL_M4) 68 $(ACLOCAL_M4)
65mkinstalldirs = $(install_sh) -d 69mkinstalldirs = $(install_sh) -d
@@ -93,9 +97,9 @@ am__dist_installed_headers_DATA_DIST = eina_safety_checks.h \
93 eina_inline_str.x eina_strbuf.h eina_ustrbuf.h eina_unicode.h \ 97 eina_inline_str.x eina_strbuf.h eina_ustrbuf.h eina_unicode.h \
94 eina_quadtree.h eina_simple_xml_parser.h eina_lock.h \ 98 eina_quadtree.h eina_simple_xml_parser.h eina_lock.h \
95 eina_prefix.h eina_refcount.h eina_mmap.h eina_xattr.h \ 99 eina_prefix.h eina_refcount.h eina_mmap.h eina_xattr.h \
96 eina_value.h eina_inline_value.x eina_inline_lock_wince.x \ 100 eina_value.h eina_inline_value.x eina_model.h \
97 eina_inline_lock_win32.x eina_inline_lock_posix.x \ 101 eina_inline_lock_wince.x eina_inline_lock_win32.x \
98 eina_inline_lock_void.x 102 eina_inline_lock_posix.x eina_inline_lock_void.x
99am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 103am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
100am__vpath_adj = case $$p in \ 104am__vpath_adj = case $$p in \
101 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 105 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@@ -167,13 +171,13 @@ EINA_CONFIGURE_DEFAULT_MEMPOOL = @EINA_CONFIGURE_DEFAULT_MEMPOOL@
167EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@ 171EINA_CONFIGURE_ENABLE_LOG = @EINA_CONFIGURE_ENABLE_LOG@
168EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@ 172EINA_CONFIGURE_HAVE_DEBUG_THREADS = @EINA_CONFIGURE_HAVE_DEBUG_THREADS@
169EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@ 173EINA_CONFIGURE_HAVE_DIRENT_H = @EINA_CONFIGURE_HAVE_DIRENT_H@
174EINA_CONFIGURE_HAVE_EXOTIC = @EINA_CONFIGURE_HAVE_EXOTIC@
170EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@ 175EINA_CONFIGURE_HAVE_INTTYPES_H = @EINA_CONFIGURE_HAVE_INTTYPES_H@
171EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@ 176EINA_CONFIGURE_HAVE_ON_OFF_THREADS = @EINA_CONFIGURE_HAVE_ON_OFF_THREADS@
172EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@ 177EINA_CONFIGURE_HAVE_STDINT_H = @EINA_CONFIGURE_HAVE_STDINT_H@
173EINA_CONFIGURE_HAVE_THREADS = @EINA_CONFIGURE_HAVE_THREADS@ 178EINA_CONFIGURE_HAVE_THREADS = @EINA_CONFIGURE_HAVE_THREADS@
174EINA_CONFIGURE_MAGIC_DEBUG = @EINA_CONFIGURE_MAGIC_DEBUG@ 179EINA_CONFIGURE_MAGIC_DEBUG = @EINA_CONFIGURE_MAGIC_DEBUG@
175EINA_CONFIGURE_SAFETY_CHECKS = @EINA_CONFIGURE_SAFETY_CHECKS@ 180EINA_CONFIGURE_SAFETY_CHECKS = @EINA_CONFIGURE_SAFETY_CHECKS@
176EINA_CPPFLAGS = @EINA_CPPFLAGS@
177EINA_LIBS = @EINA_LIBS@ 181EINA_LIBS = @EINA_LIBS@
178EINA_SIZEOF_WCHAR_T = @EINA_SIZEOF_WCHAR_T@ 182EINA_SIZEOF_WCHAR_T = @EINA_SIZEOF_WCHAR_T@
179EMEMOA_CFLAGS = @EMEMOA_CFLAGS@ 183EMEMOA_CFLAGS = @EMEMOA_CFLAGS@
@@ -183,6 +187,8 @@ ESCAPE_LIBS = @ESCAPE_LIBS@
183EVIL_CFLAGS = @EVIL_CFLAGS@ 187EVIL_CFLAGS = @EVIL_CFLAGS@
184EVIL_LIBS = @EVIL_LIBS@ 188EVIL_LIBS = @EVIL_LIBS@
185EXEEXT = @EXEEXT@ 189EXEEXT = @EXEEXT@
190EXOTIC_CFLAGS = @EXOTIC_CFLAGS@
191EXOTIC_LIBS = @EXOTIC_LIBS@
186FGREP = @FGREP@ 192FGREP = @FGREP@
187GLIB_CFLAGS = @GLIB_CFLAGS@ 193GLIB_CFLAGS = @GLIB_CFLAGS@
188GLIB_LIBS = @GLIB_LIBS@ 194GLIB_LIBS = @GLIB_LIBS@
@@ -218,6 +224,8 @@ PACKAGE_URL = @PACKAGE_URL@
218PACKAGE_VERSION = @PACKAGE_VERSION@ 224PACKAGE_VERSION = @PACKAGE_VERSION@
219PATH_SEPARATOR = @PATH_SEPARATOR@ 225PATH_SEPARATOR = @PATH_SEPARATOR@
220PKG_CONFIG = @PKG_CONFIG@ 226PKG_CONFIG = @PKG_CONFIG@
227PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
228PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
221RANLIB = @RANLIB@ 229RANLIB = @RANLIB@
222SED = @SED@ 230SED = @SED@
223SET_MAKE = @SET_MAKE@ 231SET_MAKE = @SET_MAKE@
@@ -311,8 +319,8 @@ EINAHEADERS = eina_safety_checks.h eina_error.h eina_log.h \
311 eina_ustrbuf.h eina_unicode.h eina_quadtree.h \ 319 eina_ustrbuf.h eina_unicode.h eina_quadtree.h \
312 eina_simple_xml_parser.h eina_lock.h eina_prefix.h \ 320 eina_simple_xml_parser.h eina_lock.h eina_prefix.h \
313 eina_refcount.h eina_mmap.h eina_xattr.h eina_value.h \ 321 eina_refcount.h eina_mmap.h eina_xattr.h eina_value.h \
314 eina_inline_value.x $(am__append_1) $(am__append_2) \ 322 eina_inline_value.x eina_model.h $(am__append_1) \
315 $(am__append_3) $(am__append_4) 323 $(am__append_2) $(am__append_3) $(am__append_4)
316installed_mainheaderdir = $(includedir)/eina-@VMAJ@ 324installed_mainheaderdir = $(includedir)/eina-@VMAJ@
317dist_installed_mainheader_DATA = Eina.h eina_config.h 325dist_installed_mainheader_DATA = Eina.h eina_config.h
318installed_headersdir = $(includedir)/eina-@VMAJ@/eina 326installed_headersdir = $(includedir)/eina-@VMAJ@/eina
diff --git a/libraries/eina/src/include/eina_array.h b/libraries/eina/src/include/eina_array.h
index 53183b4..4ab3b50 100644
--- a/libraries/eina/src/include/eina_array.h
+++ b/libraries/eina/src/include/eina_array.h
@@ -351,7 +351,7 @@ static inline void *eina_array_data_get(const Eina_Array *array,
351static inline void eina_array_data_set(const Eina_Array *array, 351static 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);
354static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT EINA_DEPRECATED; 354static inline unsigned int eina_array_count_get(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
355static inline unsigned int eina_array_count(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT; 355static inline unsigned int eina_array_count(const Eina_Array *array) EINA_ARG_NONNULL(1) EINA_WARN_UNUSED_RESULT;
356 356
357/** 357/**
diff --git a/libraries/eina/src/include/eina_config.h b/libraries/eina/src/include/eina_config.h
index 474edaa..b1108b6 100644
--- a/libraries/eina/src/include/eina_config.h
+++ b/libraries/eina/src/include/eina_config.h
@@ -19,6 +19,15 @@
19#ifndef EINA_CONFIG_H_ 19#ifndef EINA_CONFIG_H_
20#define EINA_CONFIG_H_ 20#define EINA_CONFIG_H_
21 21
22#ifdef EINA_HAVE_EXOTIC_H
23# undef EINA_HAVE_EXOTIC_H
24#endif
25
26
27#ifdef EINA_HAVE_EXOTIC
28# include <Exotic.h>
29#endif
30
22#ifdef EINA_MAGIC_DEBUG 31#ifdef EINA_MAGIC_DEBUG
23# undef EINA_MAGIC_DEBUG 32# undef EINA_MAGIC_DEBUG
24#endif 33#endif
diff --git a/libraries/eina/src/include/eina_config.h.in b/libraries/eina/src/include/eina_config.h.in
index 2459ace..937d208 100644
--- a/libraries/eina/src/include/eina_config.h.in
+++ b/libraries/eina/src/include/eina_config.h.in
@@ -19,6 +19,15 @@
19#ifndef EINA_CONFIG_H_ 19#ifndef EINA_CONFIG_H_
20#define EINA_CONFIG_H_ 20#define EINA_CONFIG_H_
21 21
22#ifdef EINA_HAVE_EXOTIC_H
23# undef EINA_HAVE_EXOTIC_H
24#endif
25@EINA_CONFIGURE_HAVE_EXOTIC@
26
27#ifdef EINA_HAVE_EXOTIC
28# include <Exotic.h>
29#endif
30
22#ifdef EINA_MAGIC_DEBUG 31#ifdef EINA_MAGIC_DEBUG
23# undef EINA_MAGIC_DEBUG 32# undef EINA_MAGIC_DEBUG
24#endif 33#endif
diff --git a/libraries/eina/src/include/eina_error.h b/libraries/eina/src/include/eina_error.h
index 2b0ae77..dd87edf 100644
--- a/libraries/eina/src/include/eina_error.h
+++ b/libraries/eina/src/include/eina_error.h
@@ -180,7 +180,7 @@ EAPI const char *eina_error_msg_get(Eina_Error error) EINA_PURE;
180 180
181/** 181/**
182 * @brief Find the #Eina_Error corresponding to a message string 182 * @brief Find the #Eina_Error corresponding to a message string
183 * @param msg The error message string to match (NOT #NULL) 183 * @param msg The error message string to match (NOT @c NULL)
184 * @return The #Eina_Error matching @p msg, or 0 on failure 184 * @return The #Eina_Error matching @p msg, or 0 on failure
185 * This function attempts to match @p msg with its corresponding #Eina_Error value. 185 * This function attempts to match @p msg with its corresponding #Eina_Error value.
186 * If no such value is found, 0 is returned. 186 * If no such value is found, 0 is returned.
diff --git a/libraries/eina/src/include/eina_file.h b/libraries/eina/src/include/eina_file.h
index 422fb65..1af22af 100644
--- a/libraries/eina/src/include/eina_file.h
+++ b/libraries/eina/src/include/eina_file.h
@@ -22,6 +22,7 @@
22 22
23#include <limits.h> 23#include <limits.h>
24#include <time.h> 24#include <time.h>
25#include <sys/stat.h>
25 26
26#include "eina_types.h" 27#include "eina_types.h"
27#include "eina_array.h" 28#include "eina_array.h"
@@ -91,6 +92,13 @@
91typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info; 92typedef struct _Eina_File_Direct_Info Eina_File_Direct_Info;
92 93
93/** 94/**
95 * @typedef Eina_Stat
96 * A typedef to #_Eina_Stat.
97 * @since 1.2
98 */
99typedef struct _Eina_Stat Eina_Stat;
100
101/**
94 * @typedef Eina_File_Dir_List_Cb 102 * @typedef Eina_File_Dir_List_Cb
95 * Type for a callback to be called when iterating over the files of a 103 * Type for a callback to be called when iterating over the files of a
96 * directory. 104 * directory.
@@ -149,6 +157,31 @@ struct _Eina_File_Direct_Info
149}; 157};
150 158
151/** 159/**
160 * @struct _Eina_Stat
161 * A structure to store informations of a path.
162 * @since 1.2
163 */
164struct _Eina_Stat
165{
166 unsigned long int dev;
167 unsigned long int ino;
168 unsigned int mode;
169 unsigned int nlink;
170 unsigned int uid;
171 unsigned int gid;
172 unsigned long int rdev;
173 unsigned long int size;
174 unsigned long int blksize;
175 unsigned long int blocks;
176 unsigned long int atime;
177 unsigned long int atimensec;
178 unsigned long int mtime;
179 unsigned long int mtimensec;
180 unsigned long int ctime;
181 unsigned long int ctimensec;
182};
183
184/**
152 * @def EINA_FILE_DIR_LIST_CB 185 * @def EINA_FILE_DIR_LIST_CB
153 * @brief cast to an #Eina_File_Dir_List_Cb. 186 * @brief cast to an #Eina_File_Dir_List_Cb.
154 * 187 *
@@ -247,6 +280,24 @@ EAPI Eina_Iterator *eina_file_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_A
247EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC; 280EAPI Eina_Iterator *eina_file_stat_ls(const char *dir) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_MALLOC;
248 281
249/** 282/**
283 * @brief Use information provided by Eina_Iterator of eina_file_stat_ls or eina_file_direct_ls
284 * to call stat in the most efficient way on your system.
285 *
286 * @param container The container returned by the Eina_Iterator using eina_iterator_container_get().
287 * @param info The content of the current Eina_File_Direct_Info provided by the Eina_Iterator
288 * @param buf Where to put the result of the stat
289 * @return On success 0 is returned, On error -1 is returned and errno is set appropriately.
290 *
291 * This function calls fstatat or stat depending on what your system supports. This makes it efficient and simple
292 * to use on your side without complex detection already done inside Eina on what the system can do.
293 *
294 * @see eina_file_direct_ls()
295 * @see eina_file_stat_ls()
296 * @since 1.2
297 */
298EAPI int eina_file_statat(void *container, Eina_File_Direct_Info *info, Eina_Stat *buf) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2, 3);
299
300/**
250 * @brief Get an iterator to list the content of a directory, with direct 301 * @brief Get an iterator to list the content of a directory, with direct
251 * information. 302 * information.
252 * 303 *
diff --git a/libraries/eina/src/include/eina_inarray.h b/libraries/eina/src/include/eina_inarray.h
index d37c76b..079f1e3 100644
--- a/libraries/eina/src/include/eina_inarray.h
+++ b/libraries/eina/src/include/eina_inarray.h
@@ -24,6 +24,131 @@
24#include "eina_accessor.h" 24#include "eina_accessor.h"
25 25
26/** 26/**
27 * @page eina_inarray_example_01 Eina inline array usage
28 * @dontinclude eina_inarray_01.c
29 *
30 * This example will create an inline array of chars, add some elements, print
31 * it, re-purpose the array to store ints, add some elements and print that.
32 *
33 * We'll start with a function to compare ints we need this because the '>'
34 * operator is not a function and can't be used where Eina_Compare_Cb is needed.
35 * @skip int
36 * @until }
37 *
38 * And then move on to the code we actually care about, starting with variable
39 * declarations and eina initialization:
40 * @until eina_init
41 *
42 * Creating an inline array is very simple, we just need to know what type we
43 * want to store:
44 * @until inarray_new
45 * @note The second parameter(the step) is left at zero which means that eina
46 * will choose an appropriate value, this should @b only be changed if it's
47 * known, beforehand, how many elements the array will have.
48 *
49 * Once we have an array we can start adding elements to it. Because the
50 * insertion function expect a memory address we have to put the value we want
51 * to store in a variable(this should be no problem since in real world usage
52 * that's usually where the value will be anyways):
53 * @until append
54 * @note Because the inline array copies the value given to it we can later
55 * change @c ch, which we do, without affecting the contents of the array.
56 *
57 * So let's add some more elements:
58 * @until append
59 * @until append
60 * @until append
61 *
62 * We will then iterate over our array and print every position of it. The thing
63 * to note here is not so much the values which will be the expected 'a', 'b',
64 * 'c' and 'd', but rather the memory address of these values, they are
65 * sequential:
66 * @until printf
67 * @until printf
68 *
69 * We'll now use our array to store ints, so we need to first erase every member
70 * currently on the array:
71 * @until _flush
72 *
73 * And then to be able to store a different type on the same array we use the
74 * eina_array_setup() function, which is just like the eina_inarray_new()
75 * function except it receives already allocated memory. This time we're going
76 * to ask eina to use a step of size 4 because that's how many elements we'll be
77 * putting on the array:
78 * @until _setup
79 * @note Strictly speaking the reason to call eina_inarray_setup() is not
80 * because we're storing different type, but rather because our types have
81 * different sizes. Eina inline arrays don't actually know anything about types,
82 * they only deal in blocks of memory of a given size.
83 * @note Since eina_array_setup() receives already allocated memory you can(and
84 * it is in fact good practice) use inline arrays not declared as pointers:
85 * @code
86 * Eina_Inarray arr;
87 * eina_inarray_setup(&arr, sizeof(int), 4);
88 * @endcode
89 *
90 * And now to add our integer values to the array:
91 * @until append
92 * @until append
93 * @until append
94 *
95 * Just to change things up a bit we've left out the 99 value, but will still
96 * add it in such a way to keep the array ordered. There are many ways to do
97 * this, we could use eina_inarray_insert_at(), or we could change the value
98 * of the last member using eina_inarray_replace_at() and then append the values
99 * in the right order, but for no particular reason we're going to use
100 * eina_inarray_insert_sorted() instead:
101 * @until insert_sorted
102 *
103 * We then print the size of our array, and the array itself, much like last
104 * time the values are not surprising, and neither should it be that the memory
105 * addresses are contiguous:
106 * @until printf
107 * @until printf
108 *
109 * Once done we free our array and shutdown eina:
110 * @until }
111 *
112 * The source for this example: @ref eina_inarray_01_c
113 */
114
115/**
116 * @page eina_inarray_01_c eina_inarray_01.c
117 * @include eina_inarray_01.c
118 * @example eina_inarray_01.c
119 */
120
121/**
122 * @page eina_inarray_example_02 Eina inline array of strings
123 * @dontinclude eina_inarray_02.c
124 *
125 * This example will create an inline array of strings, add some elements and
126 * then print them. This example is based on @ref eina_array_01_example_page and
127 * @ref eina_inarray_example_01.
128 *
129 * We start with some variable declarations and eina initialization:
130 * @skip int
131 * @until eina_init
132 *
133 * We then create the array much like we did on @ref eina_inarray_example_01:
134 * @until inarray_new
135 *
136 * The point were this example significantly differs from the first eina inline
137 * array example. We'll not be adding the strings themselves to the array since
138 * their size varies, we'll store pointer to the strings instead. We therefore
139 * use @c char** to populate our inline array:
140 * @until }
141 *
142 * The source for this example: @ref eina_inarray_02_c
143 */
144
145/**
146 * @page eina_inarray_02_c eina_inarray_02.c
147 * @include eina_inarray_02.c
148 * @example eina_inarray_02.c
149 */
150
151/**
27 * @addtogroup Eina_Data_Types_Group Data Types 152 * @addtogroup Eina_Data_Types_Group Data Types
28 * 153 *
29 * @since 1.2 154 * @since 1.2
@@ -40,6 +165,19 @@
40/** 165/**
41 * @defgroup Eina_Inline_Array_Group Inline Array 166 * @defgroup Eina_Inline_Array_Group Inline Array
42 * 167 *
168 * Inline array is a container that stores the data itself not pointers to data,
169 * this means there is no memory fragmentation, also for small data types(such
170 * as char, short, int, etc.) it's more memory efficient.
171 *
172 * Usage of the inline array is very similar to that of other
173 * @ref Eina_Containers_Group, like all arrays adding elements to the beginning
174 * of the array is a lot more costly than appending, so those operations should
175 * be minimized.
176 *
177 * Examples:
178 * @li @ref eina_inarray_example_01
179 * @li @ref eina_inarray_example_02
180 *
43 * @{ 181 * @{
44 */ 182 */
45 183
@@ -531,8 +669,8 @@ EAPI Eina_Accessor *eina_inarray_accessor_new(const Eina_Inarray *array) EINA_MA
531 * @since 1.2 669 * @since 1.2
532 */ 670 */
533#define EINA_INARRAY_FOREACH(array, itr) \ 671#define EINA_INARRAY_FOREACH(array, itr) \
534 for ((itr) = array->members; \ 672 for ((itr) = (array)->members; \
535 (itr) < (((typeof(*itr)*)array->members) + array->len); \ 673 (itr) < (((typeof(*itr)*)(array)->members) + (array)->len); \
536 (itr)++) 674 (itr)++)
537 675
538/** 676/**
@@ -552,9 +690,9 @@ EAPI Eina_Accessor *eina_inarray_accessor_new(const Eina_Inarray *array) EINA_MA
552 * @since 1.2 690 * @since 1.2
553 */ 691 */
554#define EINA_INARRAY_REVERSE_FOREACH(array, itr) \ 692#define EINA_INARRAY_REVERSE_FOREACH(array, itr) \
555 for ((itr) = ((((typeof(*(itr))*)array->members) + array->len) - 1); \ 693 for ((itr) = ((((typeof(*(itr))*)(array)->members) + (array)->len) - 1); \
556 (((itr) >= (typeof(*(itr))*)array->members) \ 694 (((itr) >= (typeof(*(itr))*)(array)->members) \
557 && (array->members != NULL)); \ 695 && ((array)->members != NULL)); \
558 (itr)--) 696 (itr)--)
559 697
560/** 698/**
diff --git a/libraries/eina/src/include/eina_inline_lock_win32.x b/libraries/eina/src/include/eina_inline_lock_win32.x
index e8363d5..1988724 100644
--- a/libraries/eina/src/include/eina_inline_lock_win32.x
+++ b/libraries/eina/src/include/eina_inline_lock_win32.x
@@ -23,6 +23,9 @@
23 23
24typedef CRITICAL_SECTION Eina_Lock; 24typedef CRITICAL_SECTION Eina_Lock;
25typedef struct _Eina_Condition Eina_Condition; 25typedef struct _Eina_Condition Eina_Condition;
26typedef struct _Eina_RWLock Eina_RWLock;
27typedef DWORD Eina_TLS;
28typedef HANDLE Eina_Semaphore;
26 29
27#if _WIN32_WINNT >= 0x0600 30#if _WIN32_WINNT >= 0x0600
28struct _Eina_Condition 31struct _Eina_Condition
@@ -30,6 +33,13 @@ struct _Eina_Condition
30 CRITICAL_SECTION *mutex; 33 CRITICAL_SECTION *mutex;
31 CONDITION_VARIABLE condition; 34 CONDITION_VARIABLE condition;
32}; 35};
36
37struct _Eina_RWLock
38{
39 SRWLOCK mutex;
40
41 Eina_Bool is_read_mode : 1;
42};
33#else 43#else
34struct _Eina_Condition 44struct _Eina_Condition
35{ 45{
@@ -40,28 +50,24 @@ struct _Eina_Condition
40 HANDLE waiters_done; 50 HANDLE waiters_done;
41 Eina_Bool was_broadcast; 51 Eina_Bool was_broadcast;
42}; 52};
43#endif
44 53
45typedef struct _Eina_Win32_RWLock Eina_RWLock; 54struct _Eina_RWLock
46
47struct _Eina_Win32_RWLock
48{ 55{
49 LONG readers_count; 56 LONG readers_count;
50 LONG writers_count; 57 LONG writers_count;
51 int readers; 58 int readers;
52 int writers; 59 int writers;
53 60
54 Eina_Lock mutex; 61 Eina_Lock mutex;
55 Eina_Condition cond_read; 62 Eina_Condition cond_read;
56 Eina_Condition cond_write; 63 Eina_Condition cond_write;
57}; 64};
65#endif
58 66
59typedef DWORD Eina_TLS;
60
61typedef HANDLE Eina_Semaphore;
62 67
63EAPI extern Eina_Bool _eina_threads_activated; 68EAPI extern Eina_Bool _eina_threads_activated;
64 69
70
65static inline Eina_Bool 71static inline Eina_Bool
66eina_lock_new(Eina_Lock *mutex) 72eina_lock_new(Eina_Lock *mutex)
67{ 73{
@@ -143,9 +149,9 @@ eina_condition_new(Eina_Condition *cond, Eina_Lock *mutex)
143 CloseHandle(cond->semaphore); 149 CloseHandle(cond->semaphore);
144 return EINA_FALSE; 150 return EINA_FALSE;
145 } 151 }
152#endif
146 153
147 return EINA_TRUE; 154 return EINA_TRUE;
148#endif
149} 155}
150 156
151static inline void 157static inline void
@@ -153,6 +159,7 @@ eina_condition_free(Eina_Condition *cond)
153{ 159{
154#if _WIN32_WINNT >= 0x0600 160#if _WIN32_WINNT >= 0x0600
155 /* Nothing to do */ 161 /* Nothing to do */
162 (void)cond;
156#else 163#else
157 CloseHandle(cond->waiters_done); 164 CloseHandle(cond->waiters_done);
158 DeleteCriticalSection(&cond->waiters_count_lock); 165 DeleteCriticalSection(&cond->waiters_count_lock);
@@ -309,20 +316,29 @@ eina_condition_signal(Eina_Condition *cond)
309 if (!ReleaseSemaphore(cond->semaphore, 1, 0)) 316 if (!ReleaseSemaphore(cond->semaphore, 1, 0))
310 return EINA_FALSE; 317 return EINA_FALSE;
311 } 318 }
319#endif
312 320
313 return EINA_TRUE; 321 return EINA_TRUE;
314#endif
315} 322}
316 323
317static inline Eina_Bool 324static inline Eina_Bool
318eina_rwlock_new(Eina_RWLock *mutex) 325eina_rwlock_new(Eina_RWLock *mutex)
319{ 326{
327#if _WIN32_WINNT >= 0x0600
328 InitializeSRWLock(&mutex->mutex);
329 return EINA_TRUE;
330#else
320 if (!eina_lock_new(&(mutex->mutex))) return EINA_FALSE; 331 if (!eina_lock_new(&(mutex->mutex))) return EINA_FALSE;
321 if (!eina_condition_new(&(mutex->cond_read), &(mutex->mutex))) 332 if (!eina_condition_new(&(mutex->cond_read), &(mutex->mutex)))
322 goto on_error1; 333 goto on_error1;
323 if (!eina_condition_new(&(mutex->cond_write), &(mutex->mutex))) 334 if (!eina_condition_new(&(mutex->cond_write), &(mutex->mutex)))
324 goto on_error2; 335 goto on_error2;
325 336
337 mutex->readers_count = 0;
338 mutex->writers_count = 0;
339 mutex->readers = 0;
340 mutex->writers = 0;
341
326 return EINA_TRUE; 342 return EINA_TRUE;
327 343
328 on_error2: 344 on_error2:
@@ -330,20 +346,29 @@ eina_rwlock_new(Eina_RWLock *mutex)
330 on_error1: 346 on_error1:
331 eina_lock_free(&(mutex->mutex)); 347 eina_lock_free(&(mutex->mutex));
332 return EINA_FALSE; 348 return EINA_FALSE;
349#endif
333} 350}
334 351
335static inline void 352static inline void
336eina_rwlock_free(Eina_RWLock *mutex) 353eina_rwlock_free(Eina_RWLock *mutex)
337{ 354{
355#if _WIN32_WINNT >= 0x0600
356 (void)mutex;
357#else
338 eina_condition_free(&(mutex->cond_read)); 358 eina_condition_free(&(mutex->cond_read));
339 eina_condition_free(&(mutex->cond_write)); 359 eina_condition_free(&(mutex->cond_write));
340 eina_lock_free(&(mutex->mutex)); 360 eina_lock_free(&(mutex->mutex));
361#endif
341} 362}
342 363
343static inline Eina_Lock_Result 364static inline Eina_Lock_Result
344eina_rwlock_take_read(Eina_RWLock *mutex) 365eina_rwlock_take_read(Eina_RWLock *mutex)
345{ 366{
346 DWORD res; 367#if _WIN32_WINNT >= 0x0600
368 AcquireSRWLockShared(&mutex->mutex);
369 mutex->is_read_mode = EINA_TRUE;
370#else
371 DWORD res = 0;
347 372
348 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL) 373 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
349 return EINA_LOCK_FAIL; 374 return EINA_LOCK_FAIL;
@@ -364,6 +389,7 @@ eina_rwlock_take_read(Eina_RWLock *mutex)
364 if (res == 0) 389 if (res == 0)
365 mutex->readers++; 390 mutex->readers++;
366 eina_lock_release(&(mutex->mutex)); 391 eina_lock_release(&(mutex->mutex));
392#endif
367 393
368 return EINA_LOCK_SUCCEED; 394 return EINA_LOCK_SUCCEED;
369} 395}
@@ -371,7 +397,11 @@ eina_rwlock_take_read(Eina_RWLock *mutex)
371static inline Eina_Lock_Result 397static inline Eina_Lock_Result
372eina_rwlock_take_write(Eina_RWLock *mutex) 398eina_rwlock_take_write(Eina_RWLock *mutex)
373{ 399{
374 DWORD res; 400#if _WIN32_WINNT >= 0x0600
401 AcquireSRWLockExclusive(&mutex->mutex);
402 mutex->is_read_mode = EINA_FALSE;
403#else
404 DWORD res = 0;
375 405
376 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL) 406 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
377 return EINA_LOCK_FAIL; 407 return EINA_LOCK_FAIL;
@@ -389,8 +419,9 @@ eina_rwlock_take_write(Eina_RWLock *mutex)
389 } 419 }
390 mutex->writers_count--; 420 mutex->writers_count--;
391 } 421 }
392 if (res == 0) mutex->writers_count = 1; 422 if (res == 0) mutex->writers = 1;
393 eina_lock_release(&(mutex->mutex)); 423 eina_lock_release(&(mutex->mutex));
424#endif
394 425
395 return EINA_LOCK_SUCCEED; 426 return EINA_LOCK_SUCCEED;
396} 427}
@@ -398,6 +429,12 @@ eina_rwlock_take_write(Eina_RWLock *mutex)
398static inline Eina_Lock_Result 429static inline Eina_Lock_Result
399eina_rwlock_release(Eina_RWLock *mutex) 430eina_rwlock_release(Eina_RWLock *mutex)
400{ 431{
432#if _WIN32_WINNT >= 0x0600
433 if (mutex->is_read_mode)
434 ReleaseSRWLockShared(&mutex->mutex);
435 else
436 ReleaseSRWLockExclusive(&mutex->mutex);
437#else
401 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL) 438 if (eina_lock_take(&(mutex->mutex)) == EINA_LOCK_FAIL)
402 return EINA_LOCK_FAIL; 439 return EINA_LOCK_FAIL;
403 440
@@ -433,6 +470,7 @@ eina_rwlock_release(Eina_RWLock *mutex)
433 } 470 }
434 } 471 }
435 eina_lock_release(&(mutex->mutex)); 472 eina_lock_release(&(mutex->mutex));
473#endif
436 474
437 return EINA_LOCK_SUCCEED; 475 return EINA_LOCK_SUCCEED;
438} 476}
diff --git a/libraries/eina/src/include/eina_inline_stringshare.x b/libraries/eina/src/include/eina_inline_stringshare.x
index bfd7677..19827c5 100644
--- a/libraries/eina/src/include/eina_inline_stringshare.x
+++ b/libraries/eina/src/include/eina_inline_stringshare.x
@@ -43,7 +43,7 @@
43 * #EINA_FALSE if the strings were the same after shared. 43 * #EINA_FALSE if the strings were the same after shared.
44 */ 44 */
45static inline Eina_Bool 45static inline Eina_Bool
46eina_stringshare_replace(const char **p_str, const char *news) 46eina_stringshare_replace(Eina_Stringshare **p_str, const char *news)
47{ 47{
48 if (*p_str == news) return EINA_FALSE; 48 if (*p_str == news) return EINA_FALSE;
49 49
@@ -72,7 +72,7 @@ eina_stringshare_replace(const char **p_str, const char *news)
72 * #EINA_FALSE if the strings were the same after shared. 72 * #EINA_FALSE if the strings were the same after shared.
73 */ 73 */
74static inline Eina_Bool 74static inline Eina_Bool
75eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen) 75eina_stringshare_replace_length(Eina_Stringshare **p_str, const char *news, unsigned int slen)
76{ 76{
77 if (*p_str == news) return EINA_FALSE; 77 if (*p_str == news) return EINA_FALSE;
78 78
diff --git a/libraries/eina/src/include/eina_inline_value.x b/libraries/eina/src/include/eina_inline_value.x
index 59ec315..33c83f5 100644
--- a/libraries/eina/src/include/eina_inline_value.x
+++ b/libraries/eina/src/include/eina_inline_value.x
@@ -19,8 +19,8 @@
19#ifndef EINA_INLINE_VALUE_X_ 19#ifndef EINA_INLINE_VALUE_X_
20#define EINA_INLINE_VALUE_X_ 20#define EINA_INLINE_VALUE_X_
21 21
22#include <stdlib.h>
22#include <string.h> 23#include <string.h>
23#include <alloca.h>
24 24
25#include "eina_stringshare.h" 25#include "eina_stringshare.h"
26 26
@@ -210,7 +210,7 @@ eina_value_compare(const Eina_Value *a, const Eina_Value *b)
210 return 1; 210 return 1;
211 return 0; 211 return 0;
212 } 212 }
213 else if (type == EINA_VALUE_TYPE_ULONG) 213 else if ((type == EINA_VALUE_TYPE_ULONG) || (type == EINA_VALUE_TYPE_TIMESTAMP))
214 { 214 {
215 unsigned long *ta = (unsigned long *) pa, *tb = (unsigned long *) pb; 215 unsigned long *ta = (unsigned long *) pa, *tb = (unsigned long *) pb;
216 if (*ta < *tb) 216 if (*ta < *tb)
@@ -362,7 +362,7 @@ eina_value_vset(Eina_Value *value, va_list args)
362 *tmem = va_arg(args, unsigned int); 362 *tmem = va_arg(args, unsigned int);
363 return EINA_TRUE; 363 return EINA_TRUE;
364 } 364 }
365 else if (type == EINA_VALUE_TYPE_ULONG) 365 else if ((type == EINA_VALUE_TYPE_ULONG) || (type == EINA_VALUE_TYPE_TIMESTAMP))
366 { 366 {
367 unsigned long *tmem = (unsigned long *) mem; 367 unsigned long *tmem = (unsigned long *) mem;
368 *tmem = va_arg(args, unsigned long); 368 *tmem = va_arg(args, unsigned long);
@@ -424,17 +424,22 @@ eina_value_vset(Eina_Value *value, va_list args)
424 else if (type == EINA_VALUE_TYPE_STRING) 424 else if (type == EINA_VALUE_TYPE_STRING)
425 { 425 {
426 const char *str = (const char *) va_arg(args, const char *); 426 const char *str = (const char *) va_arg(args, const char *);
427 free(value->value.ptr); 427 if (value->value.ptr == str) return EINA_TRUE;
428 if (!str) 428 if (!str)
429 value->value.ptr = NULL; 429 {
430 free(value->value.ptr);
431 value->value.ptr = NULL;
432 }
430 else 433 else
431 { 434 {
432 value->value.ptr = strdup(str); 435 char *tmp = strdup(str);
433 if (!value->value.ptr) 436 if (!tmp)
434 { 437 {
435 eina_error_set(EINA_ERROR_OUT_OF_MEMORY); 438 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
436 return EINA_FALSE; 439 return EINA_FALSE;
437 } 440 }
441 free(value->value.ptr);
442 value->value.ptr = tmp;
438 } 443 }
439 return EINA_TRUE; 444 return EINA_TRUE;
440 } 445 }
@@ -494,18 +499,22 @@ eina_value_pset(Eina_Value *value, const void *ptr)
494 { 499 {
495 const char * const * pstr = (const char * const *) ptr; 500 const char * const * pstr = (const char * const *) ptr;
496 const char *str = *pstr; 501 const char *str = *pstr;
497 502 if (value->value.ptr == str) return EINA_TRUE;
498 free(value->value.ptr);
499 if (!str) 503 if (!str)
500 value->value.ptr = NULL; 504 {
505 free(value->value.ptr);
506 value->value.ptr = NULL;
507 }
501 else 508 else
502 { 509 {
503 value->value.ptr = strdup(str); 510 char *tmp = strdup(str);
504 if (!value->value.ptr) 511 if (!tmp)
505 { 512 {
506 eina_error_set(EINA_ERROR_OUT_OF_MEMORY); 513 eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
507 return EINA_FALSE; 514 return EINA_FALSE;
508 } 515 }
516 free(value->value.ptr);
517 value->value.ptr = tmp;
509 } 518 }
510 return EINA_TRUE; 519 return EINA_TRUE;
511 } 520 }
@@ -607,16 +616,7 @@ eina_value_array_vset(Eina_Value *value, unsigned int position, va_list args)
607 if (!mem) 616 if (!mem)
608 return EINA_FALSE; 617 return EINA_FALSE;
609 618
610 eina_value_type_flush(desc.subtype, mem); 619 return eina_value_type_vset(desc.subtype, mem, args);
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} 620}
621 621
622static inline Eina_Bool 622static inline Eina_Bool
@@ -749,16 +749,7 @@ eina_value_array_pset(Eina_Value *value, unsigned int position, const void *ptr)
749 if (!mem) 749 if (!mem)
750 return EINA_FALSE; 750 return EINA_FALSE;
751 751
752 eina_value_type_flush(desc.subtype, mem); 752 return eina_value_type_pset(desc.subtype, mem, ptr);
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} 753}
763 754
764static inline Eina_Bool 755static inline Eina_Bool
@@ -832,6 +823,29 @@ eina_value_array_pappend(Eina_Value *value, const void *ptr)
832 return EINA_FALSE; 823 return EINA_FALSE;
833} 824}
834 825
826static inline Eina_Bool
827eina_value_array_value_get(const Eina_Value *src, unsigned int position, Eina_Value *dst)
828{
829 Eina_Value_Array desc;
830
831 EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL(src, EINA_FALSE);
832 EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE);
833
834 if (!eina_value_pget(src, &desc))
835 return EINA_FALSE;
836 if (position >= eina_inarray_count(desc.array))
837 return EINA_FALSE;
838 if (!eina_value_setup(dst, desc.subtype))
839 return EINA_FALSE;
840 if (!eina_value_pset(dst, eina_inarray_nth(desc.array, position)))
841 {
842 eina_value_flush(dst);
843 return EINA_FALSE;
844 }
845
846 return EINA_TRUE;
847}
848
835#undef EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL 849#undef EINA_VALUE_TYPE_ARRAY_CHECK_RETURN_VAL
836 850
837#define EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, retval) \ 851#define EINA_VALUE_TYPE_LIST_CHECK_RETURN_VAL(value, retval) \
@@ -929,16 +943,7 @@ eina_value_list_vset(Eina_Value *value, unsigned int position, va_list args)
929 if (!mem) 943 if (!mem)
930 return EINA_FALSE; 944 return EINA_FALSE;
931 945
932 eina_value_type_flush(desc->subtype, mem); 946 return eina_value_type_vset(desc->subtype, mem, args);
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} 947}
943 948
944static inline Eina_Bool 949static inline Eina_Bool
@@ -1105,16 +1110,7 @@ eina_value_list_pset(Eina_Value *value, unsigned int position, const void *ptr)
1105 if (!mem) 1110 if (!mem)
1106 return EINA_FALSE; 1111 return EINA_FALSE;
1107 1112
1108 eina_value_type_flush(desc->subtype, mem); 1113 return eina_value_type_pset(desc->subtype, mem, ptr);
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} 1114}
1119 1115
1120static inline Eina_Bool 1116static inline Eina_Bool
@@ -1284,9 +1280,7 @@ eina_value_hash_vset(Eina_Value *value, const char *key, va_list args)
1284 return EINA_FALSE; 1280 return EINA_FALSE;
1285 1281
1286 mem = eina_hash_find(desc->hash, key); 1282 mem = eina_hash_find(desc->hash, key);
1287 if (mem) 1283 if (!mem)
1288 eina_value_type_flush(desc->subtype, mem);
1289 else
1290 { 1284 {
1291 mem = malloc(desc->subtype->value_size); 1285 mem = malloc(desc->subtype->value_size);
1292 if (!mem) 1286 if (!mem)
@@ -1299,18 +1293,15 @@ eina_value_hash_vset(Eina_Value *value, const char *key, va_list args)
1299 free(mem); 1293 free(mem);
1300 return EINA_FALSE; 1294 return EINA_FALSE;
1301 } 1295 }
1296 if (!eina_value_type_setup(desc->subtype, mem))
1297 {
1298 eina_value_type_flush(desc->subtype, mem);
1299 eina_hash_del_by_key(desc->hash, key);
1300 free(mem);
1301 }
1302 } 1302 }
1303 1303
1304 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; 1304 return eina_value_type_vset(desc->subtype, mem, args);
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} 1305}
1315 1306
1316static inline Eina_Bool 1307static inline Eina_Bool
@@ -1371,9 +1362,7 @@ eina_value_hash_pset(Eina_Value *value, const char *key, const void *ptr)
1371 return EINA_FALSE; 1362 return EINA_FALSE;
1372 1363
1373 mem = eina_hash_find(desc->hash, key); 1364 mem = eina_hash_find(desc->hash, key);
1374 if (mem) 1365 if (!mem)
1375 eina_value_type_flush(desc->subtype, mem);
1376 else
1377 { 1366 {
1378 mem = malloc(desc->subtype->value_size); 1367 mem = malloc(desc->subtype->value_size);
1379 if (!mem) 1368 if (!mem)
@@ -1386,18 +1375,15 @@ eina_value_hash_pset(Eina_Value *value, const char *key, const void *ptr)
1386 free(mem); 1375 free(mem);
1387 return EINA_FALSE; 1376 return EINA_FALSE;
1388 } 1377 }
1378 if (!eina_value_type_setup(desc->subtype, mem))
1379 {
1380 eina_value_type_flush(desc->subtype, mem);
1381 eina_hash_del_by_key(desc->hash, key);
1382 free(mem);
1383 }
1389 } 1384 }
1390 1385
1391 if (!eina_value_type_setup(desc->subtype, mem)) goto error_setup; 1386 return eina_value_type_pset(desc->subtype, mem, ptr);
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} 1387}
1402 1388
1403static inline Eina_Bool 1389static inline Eina_Bool
@@ -1474,15 +1460,7 @@ eina_value_struct_vset(Eina_Value *value, const char *name, va_list args)
1474 if (!mem) 1460 if (!mem)
1475 return EINA_FALSE; 1461 return EINA_FALSE;
1476 1462
1477 eina_value_type_flush(member->type, mem); 1463 return eina_value_type_vset(member->type, mem, args);
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} 1464}
1487 1465
1488static inline Eina_Bool 1466static inline Eina_Bool
@@ -1540,8 +1518,9 @@ eina_value_struct_pset(Eina_Value *value, const char *name, const void *ptr)
1540 Eina_Value_Struct *st; 1518 Eina_Value_Struct *st;
1541 void *mem; 1519 void *mem;
1542 1520
1543 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, 0); 1521 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
1544 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); 1522 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1523 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
1545 st = (Eina_Value_Struct *)eina_value_memory_get(value); 1524 st = (Eina_Value_Struct *)eina_value_memory_get(value);
1546 if (!st) 1525 if (!st)
1547 return EINA_FALSE; 1526 return EINA_FALSE;
@@ -1552,15 +1531,7 @@ eina_value_struct_pset(Eina_Value *value, const char *name, const void *ptr)
1552 if (!mem) 1531 if (!mem)
1553 return EINA_FALSE; 1532 return EINA_FALSE;
1554 1533
1555 eina_value_type_flush(member->type, mem); 1534 return eina_value_type_pset(member->type, mem, ptr);
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} 1535}
1565 1536
1566static inline Eina_Bool 1537static inline Eina_Bool
@@ -1571,8 +1542,9 @@ eina_value_struct_pget(const Eina_Value *value, const char *name, void *ptr)
1571 const void *mem; 1542 const void *mem;
1572 Eina_Bool ret; 1543 Eina_Bool ret;
1573 1544
1574 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, 0); 1545 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(value, EINA_FALSE);
1575 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE); 1546 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1547 EINA_SAFETY_ON_NULL_RETURN_VAL(ptr, EINA_FALSE);
1576 st = (const Eina_Value_Struct *)eina_value_memory_get(value); 1548 st = (const Eina_Value_Struct *)eina_value_memory_get(value);
1577 if (!st) 1549 if (!st)
1578 return EINA_FALSE; 1550 return EINA_FALSE;
@@ -1586,6 +1558,119 @@ eina_value_struct_pget(const Eina_Value *value, const char *name, void *ptr)
1586 ret = eina_value_type_pget(member->type, mem, ptr); 1558 ret = eina_value_type_pget(member->type, mem, ptr);
1587 return ret; 1559 return ret;
1588} 1560}
1561
1562static inline Eina_Bool
1563eina_value_struct_value_get(const Eina_Value *src, const char *name, Eina_Value *dst)
1564{
1565 const Eina_Value_Struct_Member *member;
1566 const Eina_Value_Struct *st;
1567 const void *mem;
1568
1569 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(src, EINA_FALSE);
1570 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1571 EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE);
1572 st = (const Eina_Value_Struct *)eina_value_memory_get(src);
1573 if (!st)
1574 return EINA_FALSE;
1575 member = eina_value_struct_member_find(st, name);
1576 if (!member)
1577 return EINA_FALSE;
1578 mem = eina_value_struct_member_memory_get(st, member);
1579 if (!mem)
1580 return EINA_FALSE;
1581 if (!eina_value_setup(dst, member->type))
1582 return EINA_FALSE;
1583 if (!eina_value_pset(dst, mem))
1584 {
1585 eina_value_flush(dst);
1586 return EINA_FALSE;
1587 }
1588 return EINA_TRUE;
1589}
1590
1591static inline Eina_Bool
1592eina_value_struct_value_set(Eina_Value *dst, const char *name, const Eina_Value *src)
1593{
1594 const Eina_Value_Struct_Member *member;
1595 Eina_Value_Struct *st;
1596 void *mem;
1597 const void *ptr;
1598
1599 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(dst, EINA_FALSE);
1600 EINA_SAFETY_ON_NULL_RETURN_VAL(name, EINA_FALSE);
1601 EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
1602
1603 st = (Eina_Value_Struct *)eina_value_memory_get(dst);
1604 if (!st)
1605 return EINA_FALSE;
1606 member = eina_value_struct_member_find(st, name);
1607 if (!member)
1608 return EINA_FALSE;
1609 EINA_SAFETY_ON_FALSE_RETURN_VAL(src->type == member->type, EINA_FALSE);
1610
1611 mem = eina_value_struct_member_memory_get(st, member);
1612 if (!mem)
1613 return EINA_FALSE;
1614
1615 ptr = eina_value_memory_get(src);
1616 if (!ptr)
1617 return EINA_FALSE;
1618
1619 return eina_value_type_pset(member->type, mem, ptr);
1620}
1621
1622static inline Eina_Bool
1623eina_value_struct_member_value_get(const Eina_Value *src, const Eina_Value_Struct_Member *member, Eina_Value *dst)
1624{
1625 const Eina_Value_Struct *st;
1626 const void *mem;
1627
1628 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(src, EINA_FALSE);
1629 EINA_SAFETY_ON_NULL_RETURN_VAL(member, EINA_FALSE);
1630 EINA_SAFETY_ON_NULL_RETURN_VAL(dst, EINA_FALSE);
1631 st = (const Eina_Value_Struct *)eina_value_memory_get(src);
1632 if (!st)
1633 return EINA_FALSE;
1634 mem = eina_value_struct_member_memory_get(st, member);
1635 if (!mem)
1636 return EINA_FALSE;
1637 if (!eina_value_setup(dst, member->type))
1638 return EINA_FALSE;
1639 if (!eina_value_pset(dst, mem))
1640 {
1641 eina_value_flush(dst);
1642 return EINA_FALSE;
1643 }
1644 return EINA_TRUE;
1645}
1646
1647static inline Eina_Bool
1648eina_value_struct_member_value_set(Eina_Value *dst, const Eina_Value_Struct_Member *member, const Eina_Value *src)
1649{
1650 Eina_Value_Struct *st;
1651 void *mem;
1652 const void *ptr;
1653
1654 EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL(dst, EINA_FALSE);
1655 EINA_SAFETY_ON_NULL_RETURN_VAL(member, EINA_FALSE);
1656 EINA_SAFETY_ON_NULL_RETURN_VAL(src, EINA_FALSE);
1657
1658 st = (Eina_Value_Struct *)eina_value_memory_get(dst);
1659 if (!st)
1660 return EINA_FALSE;
1661 EINA_SAFETY_ON_FALSE_RETURN_VAL(src->type == member->type, EINA_FALSE);
1662
1663 mem = eina_value_struct_member_memory_get(st, member);
1664 if (!mem)
1665 return EINA_FALSE;
1666
1667 ptr = eina_value_memory_get(src);
1668 if (!ptr)
1669 return EINA_FALSE;
1670
1671 return eina_value_type_pset(member->type, mem, ptr);
1672}
1673
1589#undef EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL 1674#undef EINA_VALUE_TYPE_STRUCT_CHECK_RETURN_VAL
1590 1675
1591 1676
diff --git a/libraries/eina/src/include/eina_list.h b/libraries/eina/src/include/eina_list.h
index db65e17..c8ef06d 100644
--- a/libraries/eina/src/include/eina_list.h
+++ b/libraries/eina/src/include/eina_list.h
@@ -881,13 +881,13 @@ EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN_UNUS
881 * @brief Sort a list according to the ordering func will return. 881 * @brief Sort a list according to the ordering func will return.
882 * 882 *
883 * @param list The list handle to sort. 883 * @param list The list handle to sort.
884 * @param size The length of the list to sort. 884 * @param limit The maximum number of list elements to sort.
885 * @param func A function pointer that can handle comparing the list data 885 * @param func A function pointer that can handle comparing the list data
886 * nodes. 886 * nodes.
887 * @return the new head of list. 887 * @return the new head of list.
888 * 888 *
889 * This function sorts @p list. @p size if the number of the first 889 * This function sorts @p list. @p size if the number of the first
890 * element to sort. If @p size is 0 or greater than the number of 890 * element to sort. If @p limit is 0 or greater than the number of
891 * elements in @p list, all the elements are sorted. @p func is used to 891 * elements in @p list, all the elements are sorted. @p func is used to
892 * compare two elements of @p list. If @p list or @p func are @c NULL, 892 * compare two elements of @p list. If @p list or @p func are @c NULL,
893 * this function returns @c NULL. 893 * this function returns @c NULL.
@@ -920,7 +920,7 @@ EAPI Eina_List *eina_list_clone(const Eina_List *list) EINA_WARN_UNUS
920 * 920 *
921 * @warning @p list must be a pointer to the first element of the list. 921 * @warning @p list must be a pointer to the first element of the list.
922 */ 922 */
923EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int size, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT; 923EAPI Eina_List *eina_list_sort(Eina_List *list, unsigned int limit, Eina_Compare_Cb func) EINA_ARG_NONNULL(3) EINA_WARN_UNUSED_RESULT;
924 924
925 925
926/** 926/**
diff --git a/libraries/eina/src/include/eina_stringshare.h b/libraries/eina/src/include/eina_stringshare.h
index 862b2b2..8edadd2 100644
--- a/libraries/eina/src/include/eina_stringshare.h
+++ b/libraries/eina/src/include/eina_stringshare.h
@@ -126,6 +126,20 @@
126 * string creation/destruction speed, reduces memory use and decreases 126 * string creation/destruction speed, reduces memory use and decreases
127 * memory fragmentation, so a win all-around. 127 * memory fragmentation, so a win all-around.
128 * 128 *
129 * Using eina stringshares usually boils down to:
130 * @code
131 * const char *str = eina_stringshare_add("My string");
132 * ...
133 * //Use str
134 * ...
135 * eina_stringshare_del(str);
136 * @endcode
137 * @note It's very important to note that string shares are @b @c const,
138 * changing them will result in undefined behavior.
139 * @note eina_stringshare_del() @b doesn't guarantee the string share will be
140 * freed, it releases a reference to it, but if other references to it still
141 * exist the string share will live until those are released.
142 *
129 * The following diagram gives an idea of what happens as you create strings 143 * The following diagram gives an idea of what happens as you create strings
130 * with eina_stringshare_add(): 144 * with eina_stringshare_add():
131 * 145 *
@@ -148,6 +162,15 @@
148 * @{ 162 * @{
149 */ 163 */
150 164
165/**
166 * @typedef Eina_Stringshare
167 *
168 * Interchangeable with "const char *" but still a good visual hint for the
169 * purpose. Maybe in the far far future we'll even add strict type checking.
170 *
171 * @since 1.2.0
172 */
173typedef const char Eina_Stringshare;
151 174
152/** 175/**
153 * @brief Retrieve an instance of a string for use in a program. 176 * @brief Retrieve an instance of a string for use in a program.
@@ -168,7 +191,7 @@
168 * 191 *
169 * @see eina_share_common_add() 192 * @see eina_share_common_add()
170 */ 193 */
171EAPI const char *eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT; 194EAPI Eina_Stringshare *eina_stringshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT;
172 195
173/** 196/**
174 * @brief Retrieve an instance of a string for use in a program. 197 * @brief Retrieve an instance of a string for use in a program.
@@ -188,7 +211,7 @@ EAPI const char *eina_stringshare_add_length(const char *str, unsigned in
188 * 211 *
189 * @see eina_stringshare_add_length() 212 * @see eina_stringshare_add_length()
190 */ 213 */
191EAPI const char *eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT; 214EAPI Eina_Stringshare *eina_stringshare_add(const char *str) EINA_WARN_UNUSED_RESULT;
192 215
193/** 216/**
194 * @brief Retrieve an instance of a string for use in a program 217 * @brief Retrieve an instance of a string for use in a program
@@ -209,7 +232,7 @@ EAPI const char *eina_stringshare_add(const char *str) EINA_WARN_UNUSED_R
209 * 232 *
210 * @see eina_stringshare_nprintf() 233 * @see eina_stringshare_nprintf()
211 */ 234 */
212EAPI const char *eina_stringshare_printf(const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(1, 2); 235EAPI Eina_Stringshare *eina_stringshare_printf(const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(1, 2);
213 236
214/** 237/**
215 * @brief Retrieve an instance of a string for use in a program 238 * @brief Retrieve an instance of a string for use in a program
@@ -231,7 +254,7 @@ EAPI const char *eina_stringshare_printf(const char *fmt, ...) EINA_WARN_
231 * 254 *
232 * @see eina_stringshare_nprintf() 255 * @see eina_stringshare_nprintf()
233 */ 256 */
234EAPI const char *eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT; 257EAPI Eina_Stringshare *eina_stringshare_vprintf(const char *fmt, va_list args) EINA_WARN_UNUSED_RESULT;
235 258
236/** 259/**
237 * @brief Retrieve an instance of a string for use in a program 260 * @brief Retrieve an instance of a string for use in a program
@@ -251,7 +274,7 @@ EAPI const char *eina_stringshare_vprintf(const char *fmt, va_list args)
251 * 274 *
252 * @see eina_stringshare_printf() 275 * @see eina_stringshare_printf()
253 */ 276 */
254EAPI const char *eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3); 277EAPI Eina_Stringshare *eina_stringshare_nprintf(unsigned int len, const char *fmt, ...) EINA_WARN_UNUSED_RESULT EINA_PRINTF(2, 3);
255 278
256/** 279/**
257 * Increment references of the given shared string. 280 * Increment references of the given shared string.
@@ -267,7 +290,7 @@ EAPI const char *eina_stringshare_nprintf(unsigned int len, const char *f
267 * 290 *
268 * There is no unref since this is the work of eina_share_common_del(). 291 * There is no unref since this is the work of eina_share_common_del().
269 */ 292 */
270EAPI const char *eina_stringshare_ref(const char *str); 293EAPI Eina_Stringshare *eina_stringshare_ref(Eina_Stringshare *str);
271 294
272/** 295/**
273 * @brief Note that the given string has lost an instance. 296 * @brief Note that the given string has lost an instance.
@@ -282,7 +305,7 @@ EAPI const char *eina_stringshare_ref(const char *str);
282 * Note that if the given pointer is not shared or NULL, bad things 305 * Note that if the given pointer is not shared or NULL, bad things
283 * will happen, likely a segmentation fault. 306 * will happen, likely a segmentation fault.
284 */ 307 */
285EAPI void eina_stringshare_del(const char *str); 308EAPI void eina_stringshare_del(Eina_Stringshare *str);
286 309
287/** 310/**
288 * @brief Note that the given string @b must be shared. 311 * @brief Note that the given string @b must be shared.
@@ -296,7 +319,7 @@ EAPI void eina_stringshare_del(const char *str);
296 * things will happen, likely a segmentation fault. If in doubt, try 319 * things will happen, likely a segmentation fault. If in doubt, try
297 * strlen(). 320 * strlen().
298 */ 321 */
299EAPI int eina_stringshare_strlen(const char *str) EINA_PURE EINA_WARN_UNUSED_RESULT; 322EAPI int eina_stringshare_strlen(Eina_Stringshare *str) EINA_PURE EINA_WARN_UNUSED_RESULT;
300 323
301/** 324/**
302 * @brief Dump the contents of the share_common. 325 * @brief Dump the contents of the share_common.
@@ -306,8 +329,8 @@ EAPI int eina_stringshare_strlen(const char *str) EINA_PURE EINA_
306 */ 329 */
307EAPI void eina_stringshare_dump(void); 330EAPI void eina_stringshare_dump(void);
308 331
309static inline Eina_Bool eina_stringshare_replace(const char **p_str, const char *news) EINA_ARG_NONNULL(1); 332static inline Eina_Bool eina_stringshare_replace(Eina_Stringshare **p_str, const char *news) EINA_ARG_NONNULL(1);
310static inline Eina_Bool eina_stringshare_replace_length(const char **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1); 333static inline Eina_Bool eina_stringshare_replace_length(Eina_Stringshare **p_str, const char *news, unsigned int slen) EINA_ARG_NONNULL(1);
311 334
312#include "eina_inline_stringshare.x" 335#include "eina_inline_stringshare.x"
313 336
diff --git a/libraries/eina/src/include/eina_types.h b/libraries/eina/src/include/eina_types.h
index 1653949..b0a7cf8 100644
--- a/libraries/eina/src/include/eina_types.h
+++ b/libraries/eina/src/include/eina_types.h
@@ -98,13 +98,13 @@
98 98
99#ifdef __GNUC__ 99#ifdef __GNUC__
100# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) 100# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
101# define EINA_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) 101# define EINA_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__))
102# else 102# else
103# define EINA_WARN_UNUSED_RESULT 103# define EINA_WARN_UNUSED_RESULT
104# endif 104# endif
105 105
106# if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) 106# if (!defined(EINA_SAFETY_CHECKS)) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
107# define EINA_ARG_NONNULL(idx, ...) __attribute__ ((nonnull(idx, ## __VA_ARGS__))) 107# define EINA_ARG_NONNULL(idx, ...) __attribute__ ((__nonnull__(idx, ## __VA_ARGS__)))
108# else 108# else
109# define EINA_ARG_NONNULL(idx, ...) 109# define EINA_ARG_NONNULL(idx, ...)
110# endif 110# endif
@@ -116,19 +116,23 @@
116# endif 116# endif
117 117
118# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 118# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
119# define EINA_MALLOC __attribute__ ((malloc)) 119# define EINA_MALLOC __attribute__ ((__malloc__))
120# define EINA_PURE __attribute__ ((pure)) 120# define EINA_PURE __attribute__ ((__pure__))
121# else 121# else
122# define EINA_MALLOC 122# define EINA_MALLOC
123# define EINA_PURE 123# define EINA_PURE
124# endif 124# endif
125 125
126# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) 126# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
127# define EINA_PRINTF(fmt, arg) __attribute__((format (printf, fmt, arg))) 127# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 3)
128# define EINA_SCANF(fmt, arg) __attribute__((format (scanf, fmt, arg))) 128# define EINA_PRINTF(fmt, arg) __attribute__((__format__ (__gnu_printf__, fmt, arg)))
129# define EINA_FORMAT(fmt) __attribute__((format_arg(fmt))) 129# else
130# define EINA_CONST __attribute__((const)) 130# define EINA_PRINTF(fmt, arg) __attribute__((__format__ (__printf__, fmt, arg)))
131# define EINA_NOINSTRUMENT __attribute__((no_instrument_function)) 131# endif
132# define EINA_SCANF(fmt, arg) __attribute__((__format__ (__scanf__, fmt, arg)))
133# define EINA_FORMAT(fmt) __attribute__((__format_arg__(fmt)))
134# define EINA_CONST __attribute__((__const__))
135# define EINA_NOINSTRUMENT __attribute__((__no_instrument_function__))
132# define EINA_UNLIKELY(exp) __builtin_expect((exp), 0) 136# define EINA_UNLIKELY(exp) __builtin_expect((exp), 0)
133# define EINA_LIKELY(exp) __builtin_expect((exp), 1) 137# define EINA_LIKELY(exp) __builtin_expect((exp), 1)
134# else 138# else
@@ -276,6 +280,16 @@ typedef void (*Eina_Free_Cb)(void *data);
276#define EINA_FREE_CB(Function) ((Eina_Free_Cb)Function) 280#define EINA_FREE_CB(Function) ((Eina_Free_Cb)Function)
277 281
278/** 282/**
283 * @def EINA_C_ARRAY_LENGTH
284 * Macro to return the array length of a standard c array.
285 * For example:
286 * int foo[] = { 0, 1, 2, 3 };
287 * would return 4 and not 4 * sizeof(int).
288 * @since 1.2.0
289 */
290#define EINA_C_ARRAY_LENGTH(arr) (sizeof(arr) / sizeof((arr)[0]))
291
292/**
279 * @} 293 * @}
280 */ 294 */
281 295
diff --git a/libraries/eina/src/include/eina_value.h b/libraries/eina/src/include/eina_value.h
index 846c4ef..341781f 100644
--- a/libraries/eina/src/include/eina_value.h
+++ b/libraries/eina/src/include/eina_value.h
@@ -19,12 +19,244 @@
19#ifndef EINA_VALUE_H_ 19#ifndef EINA_VALUE_H_
20#define EINA_VALUE_H_ 20#define EINA_VALUE_H_
21 21
22#include <stdarg.h>
23
22#include "eina_types.h" 24#include "eina_types.h"
23#include "eina_fp.h" /* defines int64_t and uint64_t */ 25#include "eina_fp.h" /* defines int64_t and uint64_t */
24#include "eina_inarray.h" 26#include "eina_inarray.h"
25#include "eina_list.h" 27#include "eina_list.h"
26#include "eina_hash.h" 28#include "eina_hash.h"
27#include <stdarg.h> 29
30/**
31 * @page eina_value_example_01_page Eina_Value usage
32 * @dontinclude eina_value_01.c
33 *
34 * This very simple example shows how to use some of the basic features of eina
35 * value: setting and getting values, converting between types and printing a
36 * value as a string.
37 *
38 * Our main function starts out with the basic, declaring some variables and
39 * initializing eina:
40 * @until eina_init
41 *
42 * Now we can jump into using eina value. We set a value, get this value and
43 * then print it:
44 * @until printf
45 *
46 * In the above snippet of code we printed an @c int value, we can however print
47 * the value as a string:
48 * @until free
49 *
50 * And once done with a value it's good practice to destroy it:
51 * @until eina_value_flush
52 *
53 * We now reuse @c v to store a string, get its value and print it:
54 * @until printf
55 * @note Since @c s is the value and not returned by @c eina_value_to_string()
56 * we don't need to free it.
57 *
58 * Just because we stored a string doesn't mean we can't use the @c
59 * eina_value_to_string() function, we can and it's important to note that it
60 * will return not the stored string but rather a copy of it(one we have to
61 * free):
62 * @until eina_value_flush
63 *
64 * And now to explore conversions between two type we'll create another value:
65 * @until eina_value_setup
66 *
67 * And make sure @c v and @c otherv have different types:
68 * @until eina_value_setup
69 *
70 * We then set a value to @c v and have it converted, to do this we don't need
71 * to tell to which type we want to convert, we just say were we want to store
72 * the converted value and eina value will figure out what to convert to, and
73 * how:
74 * @until eina_value_convert
75 *
76 * And now let's check the conversion worked:
77 * @until printf
78 *
79 * But converting to strings is not particularly exciting, @c
80 * eina_value_to_string() already did that, so now let's make the conversion the
81 * other way around, from string to @c int:
82 * @until printf
83 *
84 * And once done, destroy the values:
85 * @until }
86 *
87 * Full source code: @ref eina_value_01_c
88 */
89
90/**
91 * @page eina_value_01_c eina_value_01.c
92 * @include eina_value_01.c
93 * @example eina_value_01.c
94 */
95
96/**
97 * @page eina_value_example_02_page Eina_Value struct usage
98 * @dontinclude eina_value_02.c
99 *
100 * This example will examine a hypothetical situation in which we had a
101 * structure(which represented parameters) with two fields, and then need to add
102 * a third field to our structure. If using structs directly we'd need to
103 * rewrite every piece of code that touches the struct, by using eina value, and
104 * thus having the compiler not even know the struct, we can reduce the amount
105 * of changes needed and retain interoperability between the old and new format.
106 *
107 * Our example will start with a function that creates descriptions of both of
108 * our structs for eina value usage. The first step is to create a struct and
109 * describe its members:
110 * @until v1_members[1]
111 * @note We can't pass the types of the members to EINA_VALUE_STRUCT_MEMBER
112 * macro because they are not constant initializers.
113 *
114 * So far it should be pretty easy to understand, we said @c My_Struct_V1 has
115 * two members, one of type @c int and another of type @c char. We now create
116 * the description of the actual struct, again nothing overly complex, we signal
117 * which version of EINA_VALUE_STRUCT we're using, we declare no special
118 * operations, our members and our size:
119 * @until V1_DESC
120 *
121 * We now repeat the process for the second version of our struct, the only
122 * difference is the addition of a third parameter of type @c int :
123 * @until V2_DESC
124 * @until }
125 *
126 * We'll now look at a function that sets the values of our structs. For
127 * simplicity's sake we initialize it we random values, a real world case would
128 * read these values from a file, a database or even from the network. The
129 * fundamental detail here is that this function works for both V1 and V2
130 * structs, this is because setting a parameter that a struct that doesn't have
131 * does nothing without throwing any errors:
132 * @until }
133 * @note While using eina_value_struct_set() with an in-existing parameter
134 * causes no error, it does return #EINA_FALSE, to notify it was not possible
135 * to set the value. This could be used to determine that we're handling a V1
136 * struct and take some action based on that.
137 *
138 * The next thing is to do is see what a function that uses the values of the
139 * struct looks like. We'll again be very simplistic in our usage, we'll just
140 * print the values, but a real world case, might send these values to another
141 * process use them to open a network/database connection or anything else.
142 * Since all versions of the struct have @c param1 and @c param2 we'll
143 * unconditionally use them:
144 * @until printf
145 *
146 * The next step is to conditionally use @c param3, which can fortunately be
147 * done in the same step in which we get it's value:
148 * @until }
149 *
150 * There we've now got functions that can both populate and use values from both
151 * our structs, so now let's actually use them in our main function by creating
152 * a struct of each type, initializing them and them using them:
153 * @until }
154 *
155 * This concludes our example. For the full source code see @ref
156 * eina_value_02_c.
157 */
158
159/**
160 * @page eina_value_02_c eina_value_02.c
161 * @include eina_value_02.c
162 * @example eina_value_02.c
163 */
164
165/**
166 * @page eina_value_example_03_page Eina value custom type example
167 * @dontinclude eina_value_03.c
168 *
169 * For this example we'll be creating our own custom type of eina value. Eina
170 * value can already store struct timeval(man gettimeofday for more information)
171 * but it has no type to store struct timezone, so that's what this example will
172 * do.
173 * @note struct timezone is actually obsolete, so using it in real world
174 * programs is probably not a good idea, but this is an example so, bear with
175 * us.
176 *
177 * To create our own custom eina value type we need to define functions to
178 * do the following operations on it:
179 * @li Setup
180 * @li Flush
181 * @li Copy
182 * @li Compare
183 * @li Set
184 * @li Get
185 * @li Conversion
186 *
187 * Most of this functions are very simple, so let's look at them, starting with
188 * setup which only clear the memory so that we can be certain we won't be using
189 * stale data:
190 * @until }
191 *
192 * Now the flush function, which is even simpler, it does nothing, that's
193 * because there is nothing we need to do, all the necessary steps are taken by
194 * eina value itself:
195 * @until }
196 *
197 * Our next function, copy, is a bit more interesting, but not much, it just
198 * casts our void pointers to struct timezone pointers and does the copy:
199 * @until }
200 * @note By now you might be wondering why our functions receive void pointers
201 * instead of pointers to struct timezone, and this is a good point. The reason
202 * for this is that eina value doesn't know anything about our type so it must
203 * use a generic void pointer, casting that pointer into a proper value is the
204 * job of the implementor of the new type.
205 *
206 * Next we have the comparison function, which compares the @c tz_minuteswest
207 * field of struct timezone, we don't compare @c tz_dsttime because that field
208 * is not used in linux:
209 * @until }
210 *
211 * Next we have setting, this however requires not one but rather two functions,
212 * the reason for this is because to be able to receive arguments of any type
213 * eina value uses @ref https://wikipedia.org/wiki/Variadic_functions "variadic
214 * functions", so we need a function to get the argument from a va_list and
215 * another to actually to the setting.
216 *
217 * Lets first look at the pset function which sets the received value to a
218 * pointer:
219 * @until }
220 *
221 * Next we have the vset function which get the argument from the va_list and
222 * passes it to the pset function:
223 * @until }
224 *
225 * And now the function to get the value, a very simple copying of the value to
226 * the given pointer:
227 * @until }
228 *
229 * And finally our conversion function, this is our longest and most interesting
230 * one. For numeric type we simply assign the value of @c tz_minuteswest to the
231 * new type and call a set function using it:
232 * @until EINA_VALUE_TYPE_DOUBLE
233 * @until return
234 * @note It would be a good idea to add checks for over and underflow for these
235 * types and return #EINA_FALSE in thoses cases, we omit this here for brevity.
236 *
237 * For string types we use @c snprintf() to format our @c tz_minuteswest field
238 * and put it in a string(again @c tz_dsttime is ignored because it's not used):
239 * @until }
240 *
241 * Finally we handle any other types by returning an error in that case:
242 * @until }
243 *
244 * Now that we have all the functions, we can populate an @c Eina_Value_Type to
245 * later use it with @c eina_value_setup():
246 * @until }
247 *
248 * We can now finally use our new TZ_TYPE with eina value, so lets conclude our
249 * example by practicing that by setting its value and printing it:
250 * @until }
251 *
252 * For the full source code see @ref eina_value_03_c.
253 */
254
255/**
256 * @page eina_value_03_c eina_value_03.c
257 * @include eina_value_03.c
258 * @example eina_value_03.c
259 */
28 260
29/** 261/**
30 * @addtogroup Eina_Data_Types_Group Data Types 262 * @addtogroup Eina_Data_Types_Group Data Types
@@ -43,6 +275,24 @@
43/** 275/**
44 * @defgroup Eina_Value_Group Generic Value Storage 276 * @defgroup Eina_Value_Group Generic Value Storage
45 * 277 *
278 * Abstracts generic data storage and access to it in an extensible
279 * and efficient way.
280 *
281 * It comes with pre-defined types for numbers, array, list, hash,
282 * blob and structs. It is able to convert between data types,
283 * including to string.
284 *
285 * It is meant for simple data types, providing uniform access and
286 * release functions, useful to exchange data preserving their
287 * types. For more complex hierarchical data, with properties and
288 * children, reference counting, inheritance and interfaces, see @ref
289 * Eina_Model_Group.
290 *
291 * Examples of usage of the Eina_Value API:
292 * @li @ref eina_value_example_01_page
293 * @li @ref eina_value_example_02_page
294 * @li @ref eina_value_example_03_page
295 *
46 * @{ 296 * @{
47 */ 297 */
48 298
@@ -67,6 +317,9 @@ typedef struct _Eina_Value_Type Eina_Value_Type;
67 * @typedef Eina_Value_Union 317 * @typedef Eina_Value_Union
68 * Union of all known value types. 318 * Union of all known value types.
69 * 319 *
320 * This is only used to specify the minimum payload memory for #Eina_Value.
321 *
322 * @internal
70 * @since 1.2 323 * @since 1.2
71 */ 324 */
72typedef union _Eina_Value_Union Eina_Value_Union; 325typedef union _Eina_Value_Union Eina_Value_Union;
@@ -75,6 +328,9 @@ typedef union _Eina_Value_Union Eina_Value_Union;
75 * @union _Eina_Value_Union 328 * @union _Eina_Value_Union
76 * All possible value types. 329 * All possible value types.
77 * 330 *
331 * This is only used to specify the minimum payload memory for #Eina_Value.
332 *
333 * @internal
78 * @since 1.2 334 * @since 1.2
79 */ 335 */
80union _Eina_Value_Union 336union _Eina_Value_Union
@@ -117,6 +373,15 @@ EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_UINT;
117EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ULONG; 373EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ULONG;
118 374
119/** 375/**
376 * @var EINA_VALUE_TYPE_TIMESTAMP
377 * manages unsigned long type used for timestamps.
378 * @note this is identical in function to EINA_VALUE_TYPE_ULONG
379 *
380 * @since 1.2
381 */
382EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_TIMESTAMP;
383
384/**
120 * @var EINA_VALUE_TYPE_UINT64 385 * @var EINA_VALUE_TYPE_UINT64
121 * manages unsigned integer of 64 bits type. 386 * manages unsigned integer of 64 bits type.
122 * 387 *
@@ -206,10 +471,11 @@ EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRING;
206 * @li eina_value_array_pget() and eina_value_array_pset() 471 * @li eina_value_array_pget() and eina_value_array_pset()
207 * 472 *
208 * eina_value_set() takes an #Eina_Value_Array where just @c subtype 473 * 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 474 * and @c step are used. If there is an @c array, it will be copied
210 * and its contents must be properly configurable as @c subtype 475 * (including each item) and its contents must be properly
211 * expects. eina_value_pset() takes a pointer to an #Eina_Value_Array. 476 * configurable as @c subtype expects. eina_value_pset() takes a
212 * For your convenience, use eina_value_array_setup(). 477 * pointer to an #Eina_Value_Array. For your convenience, use
478 * eina_value_array_setup().
213 * 479 *
214 * eina_value_get() and eina_value_pget() takes a pointer to 480 * 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 481 * #Eina_Value_Array, it's an exact copy of the current structure in
@@ -228,10 +494,11 @@ EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_ARRAY;
228 * @li eina_value_list_pget() and eina_value_list_pset() 494 * @li eina_value_list_pget() and eina_value_list_pset()
229 * 495 *
230 * eina_value_set() takes an #Eina_Value_List where just @c subtype is 496 * 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 497 * used. If there is an @c list, it will be copied (including each
232 * must be properly configurable as @c subtype 498 * item) and its contents must be properly configurable as @c
233 * expects. eina_value_pset() takes a pointer to an #Eina_Value_List. 499 * subtype expects. eina_value_pset() takes a pointer to an
234 * For your convenience, use eina_value_list_setup(). 500 * #Eina_Value_List. For your convenience, use
501 * eina_value_list_setup().
235 * 502 *
236 * eina_value_get() and eina_value_pget() takes a pointer to 503 * 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 504 * #Eina_Value_List, it's an exact copy of the current structure in
@@ -251,9 +518,9 @@ EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_LIST;
251 * 518 *
252 * eina_value_set() takes an #Eina_Value_Hash where just @c subtype 519 * 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 520 * 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 521 * be copied (including each item) and its contents must be
255 * subtype expects. eina_value_pset() takes a pointer to an 522 * properly configurable as @c subtype expects. eina_value_pset()
256 * #Eina_Value_Hash. For your convenience, use 523 * takes a pointer to an #Eina_Value_Hash. For your convenience, use
257 * eina_value_hash_setup(). 524 * eina_value_hash_setup().
258 * 525 *
259 * eina_value_get() and eina_value_pget() takes a pointer to 526 * eina_value_get() and eina_value_pget() takes a pointer to
@@ -310,9 +577,10 @@ EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_BLOB;
310 * @li eina_value_struct_pget() and eina_value_struct_pset() 577 * @li eina_value_struct_pget() and eina_value_struct_pset()
311 * 578 *
312 * eina_value_set() takes an #Eina_Value_Struct where just @c desc is 579 * 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 580 * used. If there is an @c memory, it will be copied (including each
314 * must be properly configurable as @c desc expects. eina_value_pset() 581 * member) and its contents must be properly configurable as @c desc
315 * takes a pointer to an #Eina_Value_Struct. For your convenience, use 582 * expects. eina_value_pset() takes a pointer to an
583 * #Eina_Value_Struct. For your convenience, use
316 * eina_value_struct_setup(). 584 * eina_value_struct_setup().
317 * 585 *
318 * eina_value_get() and eina_value_pget() takes a pointer to 586 * eina_value_get() and eina_value_pget() takes a pointer to
@@ -324,6 +592,23 @@ EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_BLOB;
324EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRUCT; 592EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_STRUCT;
325 593
326/** 594/**
595 * @var EINA_VALUE_TYPE_MODEL
596 *
597 * manages Eina_Model type. Use the value get/set to change the model
598 * in use, it will increase the reference while in use by the value.
599 *
600 * eina_value_set() takes a pointer to #Eina_Model, increasing the
601 * reference.
602 *
603 * eina_value_get() takes a pointer to pointer to #Eina_Model, it's an
604 * exact copy of the current model, no copies are done, no references
605 * are increased.
606 *
607 * @since 1.2
608 */
609EAPI extern const Eina_Value_Type *EINA_VALUE_TYPE_MODEL;
610
611/**
327 * @var EINA_ERROR_VALUE_FAILED 612 * @var EINA_ERROR_VALUE_FAILED
328 * Error identifier corresponding to value check failure. 613 * Error identifier corresponding to value check failure.
329 * 614 *
@@ -435,7 +720,7 @@ static inline void eina_value_flush(Eina_Value *value) EINA_ARG_NONNULL(1);
435 * @param copy destination value object 720 * @param copy destination value object
436 * @return #EINA_TRUE on success, #EINA_FALSE otherwise. 721 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
437 * 722 *
438 * The @a copy object is considered internalized and its existing 723 * The @a copy object is considered uninitialized and its existing
439 * contents are overwritten (just as if eina_value_flush() was called on 724 * contents are overwritten (just as if eina_value_flush() was called on
440 * it). 725 * it).
441 * 726 *
@@ -812,8 +1097,9 @@ static inline const Eina_Value_Type *eina_value_type_get(const Eina_Value *value
812 1097
813/** 1098/**
814 * @typedef Eina_Value_Array 1099 * @typedef Eina_Value_Array
815 * Value type for #EINA_VALUE_TYPE_ARRAY 1100 * Value type for #EINA_VALUE_TYPE_ARRAY.
816 * 1101 *
1102 * @see #_Eina_Value_Array explains fields.
817 * @since 1.2 1103 * @since 1.2
818 */ 1104 */
819typedef struct _Eina_Value_Array Eina_Value_Array; 1105typedef struct _Eina_Value_Array Eina_Value_Array;
@@ -821,6 +1107,7 @@ typedef struct _Eina_Value_Array Eina_Value_Array;
821/** 1107/**
822 * @struct _Eina_Value_Array 1108 * @struct _Eina_Value_Array
823 * Used to store the array and its subtype. 1109 * Used to store the array and its subtype.
1110 * @since 1.2
824 */ 1111 */
825struct _Eina_Value_Array 1112struct _Eina_Value_Array
826{ 1113{
@@ -1433,6 +1720,22 @@ static inline Eina_Bool eina_value_array_pappend(Eina_Value *value,
1433 const void *ptr) EINA_ARG_NONNULL(1); 1720 const void *ptr) EINA_ARG_NONNULL(1);
1434 1721
1435/** 1722/**
1723 * @brief Retrieves a value from the array as an Eina_Value copy.
1724 * @param value source value object
1725 * @param position index of the member
1726 * @param dst where to return the array member
1727 * @return #EINA_TRUE on success, #EINA_FALSE otherwise.
1728 *
1729 * The argument @a dst is considered uninitialized and it's setup to
1730 * the type of the member.
1731 *
1732 * @since 1.2
1733 */
1734static inline Eina_Bool eina_value_array_value_get(const Eina_Value *src,
1735 unsigned int position,
1736 Eina_Value *dst) EINA_ARG_NONNULL(1, 3);
1737
1738/**
1436 * @} 1739 * @}
1437 */ 1740 */
1438 1741
@@ -1446,8 +1749,9 @@ static inline Eina_Bool eina_value_array_pappend(Eina_Value *value,
1446 1749
1447/** 1750/**
1448 * @typedef Eina_Value_List 1751 * @typedef Eina_Value_List
1449 * Value type for #EINA_VALUE_TYPE_LIST 1752 * Value type for #EINA_VALUE_TYPE_LIST.
1450 * 1753 *
1754 * @see #_Eina_Value_List explains fields.
1451 * @since 1.2 1755 * @since 1.2
1452 */ 1756 */
1453typedef struct _Eina_Value_List Eina_Value_List; 1757typedef struct _Eina_Value_List Eina_Value_List;
@@ -1455,6 +1759,7 @@ typedef struct _Eina_Value_List Eina_Value_List;
1455/** 1759/**
1456 * @struct _Eina_Value_List 1760 * @struct _Eina_Value_List
1457 * Used to store the list and its subtype. 1761 * Used to store the list and its subtype.
1762 * @since 1.2
1458 */ 1763 */
1459struct _Eina_Value_List 1764struct _Eina_Value_List
1460{ 1765{
@@ -2067,8 +2372,9 @@ static inline Eina_Bool eina_value_list_pappend(Eina_Value *value,
2067 2372
2068/** 2373/**
2069 * @typedef Eina_Value_Hash 2374 * @typedef Eina_Value_Hash
2070 * Value type for #EINA_VALUE_TYPE_HASH 2375 * Value type for #EINA_VALUE_TYPE_HASH.
2071 * 2376 *
2377 * @see #_Eina_Value_Hash explains fields.
2072 * @since 1.2 2378 * @since 1.2
2073 */ 2379 */
2074typedef struct _Eina_Value_Hash Eina_Value_Hash; 2380typedef struct _Eina_Value_Hash Eina_Value_Hash;
@@ -2076,6 +2382,7 @@ typedef struct _Eina_Value_Hash Eina_Value_Hash;
2076/** 2382/**
2077 * @struct _Eina_Value_Hash 2383 * @struct _Eina_Value_Hash
2078 * Used to store the hash and its subtype. 2384 * Used to store the hash and its subtype.
2385 * @since 1.2
2079 */ 2386 */
2080struct _Eina_Value_Hash 2387struct _Eina_Value_Hash
2081{ 2388{
@@ -2409,19 +2716,25 @@ static inline Eina_Bool eina_value_hash_pget(const Eina_Value *value,
2409/** 2716/**
2410 * @typedef Eina_Value_Blob_Operations 2717 * @typedef Eina_Value_Blob_Operations
2411 * How to manage blob. Any @c NULL callback is ignored. 2718 * How to manage blob. Any @c NULL callback is ignored.
2719 * @see #_Eina_Value_Blob_Operations explains fields.
2412 * @since 1.2 2720 * @since 1.2
2413 */ 2721 */
2414typedef struct _Eina_Value_Blob_Operations Eina_Value_Blob_Operations; 2722typedef struct _Eina_Value_Blob_Operations Eina_Value_Blob_Operations;
2415 2723
2416/** 2724/**
2725 * @def EINA_VALUE_BLOB_OPERATIONS_VERSION
2726 * Current API version, used to validate #_Eina_Value_Blob_Operations.
2727 */
2728#define EINA_VALUE_BLOB_OPERATIONS_VERSION (1)
2729
2730/**
2417 * @struct _Eina_Value_Blob_Operations 2731 * @struct _Eina_Value_Blob_Operations
2418 * How to manage blob. Any @c NULL callback is ignored. 2732 * How to manage blob. Any @c NULL callback is ignored.
2419 * @since 1.2 2733 * @since 1.2
2420 */ 2734 */
2421struct _Eina_Value_Blob_Operations 2735struct _Eina_Value_Blob_Operations
2422{ 2736{
2423#define EINA_VALUE_BLOB_OPERATIONS_VERSION (1) 2737 unsigned int version; /**< must be #EINA_VALUE_BLOB_OPERATIONS_VERSION */
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); 2738 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); 2739 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); 2740 int (*compare)(const Eina_Value_Blob_Operations *ops, const void *data1, size_t size_data1, const void *data2, size_t size_data2);
@@ -2441,12 +2754,16 @@ EAPI extern const Eina_Value_Blob_Operations *EINA_VALUE_BLOB_OPERATIONS_MALLOC;
2441 2754
2442/** 2755/**
2443 * @typedef Eina_Value_Blob 2756 * @typedef Eina_Value_Blob
2757 * Value type for #EINA_VALUE_TYPE_BLOB.
2758 *
2759 * @see #_Eina_Value_Blob explains fields.
2444 * @since 1.2 2760 * @since 1.2
2445 */ 2761 */
2446typedef struct _Eina_Value_Blob Eina_Value_Blob; 2762typedef struct _Eina_Value_Blob Eina_Value_Blob;
2447 2763
2448/** 2764/**
2449 * @struct _Eina_Value_Blob 2765 * @struct _Eina_Value_Blob
2766 * Used to store the blob information and management operations.
2450 * @since 1.2 2767 * @since 1.2
2451 */ 2768 */
2452struct _Eina_Value_Blob 2769struct _Eina_Value_Blob
@@ -2469,6 +2786,11 @@ struct _Eina_Value_Blob
2469/** 2786/**
2470 * @typedef Eina_Value_Struct_Operations 2787 * @typedef Eina_Value_Struct_Operations
2471 * How to manage struct. Any @c NULL callback is ignored. 2788 * How to manage struct. Any @c NULL callback is ignored.
2789 *
2790 * A structure can specify alternative methods to allocate, free and
2791 * copy itself. See structure definition for all methods.
2792 *
2793 * @see #_Eina_Value_Struct_Operations explains fields.
2472 * @since 1.2 2794 * @since 1.2
2473 */ 2795 */
2474typedef struct _Eina_Value_Struct_Operations Eina_Value_Struct_Operations; 2796typedef struct _Eina_Value_Struct_Operations Eina_Value_Struct_Operations;
@@ -2476,6 +2798,12 @@ typedef struct _Eina_Value_Struct_Operations Eina_Value_Struct_Operations;
2476/** 2798/**
2477 * @typedef Eina_Value_Struct_Member 2799 * @typedef Eina_Value_Struct_Member
2478 * Describes a single member of struct. 2800 * Describes a single member of struct.
2801 *
2802 * The member holds a name, type and its byte offset within the struct
2803 * memory. Most Eina_Value_Struct functions takes the member name as
2804 * parameter, as in eina_value_struct_set().
2805 *
2806 * @see #_Eina_Value_Struct_Member explains fields.
2479 * @since 1.2 2807 * @since 1.2
2480 */ 2808 */
2481typedef struct _Eina_Value_Struct_Member Eina_Value_Struct_Member; 2809typedef struct _Eina_Value_Struct_Member Eina_Value_Struct_Member;
@@ -2483,30 +2811,39 @@ typedef struct _Eina_Value_Struct_Member Eina_Value_Struct_Member;
2483/** 2811/**
2484 * @typedef Eina_Value_Struct_Desc 2812 * @typedef Eina_Value_Struct_Desc
2485 * Describes the struct by listing its size, members and operations. 2813 * Describes the struct by listing its size, members and operations.
2814 * @see #_Eina_Value_Struct_Desc explains fields.
2486 * @since 1.2 2815 * @since 1.2
2487 */ 2816 */
2488typedef struct _Eina_Value_Struct_Desc Eina_Value_Struct_Desc; 2817typedef struct _Eina_Value_Struct_Desc Eina_Value_Struct_Desc;
2489 2818
2490/** 2819/**
2491 * @typedef Eina_Value_Struct 2820 * @typedef Eina_Value_Struct
2821 * Value type for #EINA_VALUE_TYPE_STRUCT.
2822 *
2823 * @see #_Eina_Value_Struct explains fields.
2492 * @since 1.2 2824 * @since 1.2
2493 */ 2825 */
2494typedef struct _Eina_Value_Struct Eina_Value_Struct; 2826typedef struct _Eina_Value_Struct Eina_Value_Struct;
2495 2827
2496/** 2828/**
2829 * @def EINA_VALUE_STRUCT_OPERATIONS_VERSION
2830 * Current API version, used to validate #_Eina_Value_Struct_Operations.
2831 */
2832#define EINA_VALUE_STRUCT_OPERATIONS_VERSION (1)
2833
2834/**
2497 * @struct _Eina_Value_Struct_Operations 2835 * @struct _Eina_Value_Struct_Operations
2498 * How to manage struct. Any @c NULL callback is ignored. 2836 * How to manage struct. Any @c NULL callback is ignored.
2499 * @since 1.2 2837 * @since 1.2
2500 */ 2838 */
2501struct _Eina_Value_Struct_Operations 2839struct _Eina_Value_Struct_Operations
2502{ 2840{
2503#define EINA_VALUE_STRUCT_OPERATIONS_VERSION (1) 2841 unsigned int version; /**< must be #EINA_VALUE_STRUCT_OPERATIONS_VERSION */
2504 unsigned int version; /**< must be EINA_VALUE_STRUCT_OPERATIONS_VERSION */ 2842 void *(*alloc)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc); /**< How to allocate struct memory to be managed by the Eina_Value */
2505 void *(*alloc)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc); 2843 void (*free)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, void *memory); /**< How to release memory managed by the Eina_Value */
2506 void (*free)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, void *memory); 2844 void *(*copy)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *memory); /**< How to copy struct memory from an existing Eina_Value, if not provided alloc() will be used, then every member is copied using eina_value_type_copy() with member's type. */
2507 void *(*copy)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *memory); 2845 int (*compare)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *data1, const void *data2); /**< How to compare two struct memories */
2508 int (*compare)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const void *data1, const void *data2); 2846 const Eina_Value_Struct_Member *(*find_member)(const Eina_Value_Struct_Operations *ops, const Eina_Value_Struct_Desc *desc, const char *name); /**< How to find description for member. For huge structures consider using binary search, stringshared, hash or gperf. The default function does linear search using strcmp(). */
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}; 2847};
2511 2848
2512/** 2849/**
@@ -2539,23 +2876,48 @@ EAPI extern const Eina_Value_Struct_Operations *EINA_VALUE_STRUCT_OPERATIONS_STR
2539 2876
2540/** 2877/**
2541 * @struct _Eina_Value_Struct_Member 2878 * @struct _Eina_Value_Struct_Member
2879 * Describes a single member of struct.
2880 *
2881 * The name is used to lookup the member description. This is done as
2882 * specified as _Eina_Value_Struct_Operations::find_member(). For
2883 * structures with huge number of members, consider using a better
2884 * find_member function to quickly finding it! There are two helper
2885 * operations provided to help this:
2886 * #EINA_VALUE_STRUCT_OPERATIONS_BINSEARCH and
2887 * #EINA_VALUE_STRUCT_OPERATIONS_STRINGSHARE, both depend on properly
2888 * set #_Eina_Value_Struct_Desc and #_Eina_Value_Struct_Member.
2889 *
2890 * @see #EINA_VALUE_STRUCT_MEMBER
2891 * @see #EINA_VALUE_STRUCT_MEMBER_SENTINEL
2892 *
2542 * @since 1.2 2893 * @since 1.2
2543 */ 2894 */
2544struct _Eina_Value_Struct_Member 2895struct _Eina_Value_Struct_Member
2545{ 2896{
2546 const char *name; 2897 const char *name; /**< member name, used in lookups such as eina_value_struct_get() */
2547 const Eina_Value_Type *type; 2898 const Eina_Value_Type *type; /**< how to use this member */
2548 unsigned int offset; 2899 unsigned int offset; /**< where this member is located within the structure memory */
2549}; 2900};
2550 2901
2551/** 2902/**
2903 * @def EINA_VALUE_STRUCT_DESC_VERSION
2904 * Current API version, used to validate #_Eina_Value_Struct_Desc.
2905 */
2906#define EINA_VALUE_STRUCT_DESC_VERSION (1)
2907
2908/**
2552 * @struct _Eina_Value_Struct_Desc 2909 * @struct _Eina_Value_Struct_Desc
2910 * Describes the struct by listing its size, members and operations.
2911 *
2912 * This is the root of Eina_Value knowledge about the memory it's
2913 * handling as a structure. It adds introspection, saying the byte
2914 * size of the structure, its members and how to manage such members.
2915 *
2553 * @since 1.2 2916 * @since 1.2
2554 */ 2917 */
2555struct _Eina_Value_Struct_Desc 2918struct _Eina_Value_Struct_Desc
2556{ 2919{
2557#define EINA_VALUE_STRUCT_DESC_VERSION (1) 2920 unsigned int version; /**< must be #EINA_VALUE_STRUCT_DESC_VERSION */
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. */ 2921 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. */ 2922 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. */ 2923 unsigned int member_count; /**< if > 0, specifies number of members. If zero then @c members must be NULL terminated. */
@@ -2586,12 +2948,13 @@ struct _Eina_Value_Struct_Desc
2586 2948
2587/** 2949/**
2588 * @struct _Eina_Value_Struct 2950 * @struct _Eina_Value_Struct
2951 * Used to store the memory and its description.
2589 * @since 1.2 2952 * @since 1.2
2590 */ 2953 */
2591struct _Eina_Value_Struct 2954struct _Eina_Value_Struct
2592{ 2955{
2593 const Eina_Value_Struct_Desc *desc; 2956 const Eina_Value_Struct_Desc *desc; /**< How to manage the structure */
2594 void *memory; 2957 void *memory; /**< The managed structure memory */
2595}; 2958};
2596 2959
2597/** 2960/**
@@ -2702,7 +3065,7 @@ static inline Eina_Bool eina_value_struct_setup(Eina_Value *value,
2702 */ 3065 */
2703static inline Eina_Bool eina_value_struct_set(Eina_Value *value, 3066static inline Eina_Bool eina_value_struct_set(Eina_Value *value,
2704 const char *name, 3067 const char *name,
2705 ...) EINA_ARG_NONNULL(1); 3068 ...) EINA_ARG_NONNULL(1, 2);
2706 3069
2707/** 3070/**
2708 * @brief Get the generic value from an struct member. 3071 * @brief Get the generic value from an struct member.
@@ -2770,7 +3133,7 @@ static inline Eina_Bool eina_value_struct_set(Eina_Value *value,
2770 */ 3133 */
2771static inline Eina_Bool eina_value_struct_get(const Eina_Value *value, 3134static inline Eina_Bool eina_value_struct_get(const Eina_Value *value,
2772 const char *name, 3135 const char *name,
2773 ...) EINA_ARG_NONNULL(1); 3136 ...) EINA_ARG_NONNULL(1, 2);
2774 3137
2775/** 3138/**
2776 * @brief Set the generic value in an struct member. 3139 * @brief Set the generic value in an struct member.
@@ -2786,7 +3149,7 @@ static inline Eina_Bool eina_value_struct_get(const Eina_Value *value,
2786 */ 3149 */
2787static inline Eina_Bool eina_value_struct_vset(Eina_Value *value, 3150static inline Eina_Bool eina_value_struct_vset(Eina_Value *value,
2788 const char *name, 3151 const char *name,
2789 va_list args) EINA_ARG_NONNULL(1); 3152 va_list args) EINA_ARG_NONNULL(1, 2);
2790 3153
2791/** 3154/**
2792 * @brief Get the generic value from an struct member. 3155 * @brief Get the generic value from an struct member.
@@ -2808,7 +3171,7 @@ static inline Eina_Bool eina_value_struct_vset(Eina_Value *value,
2808 */ 3171 */
2809static inline Eina_Bool eina_value_struct_vget(const Eina_Value *value, 3172static inline Eina_Bool eina_value_struct_vget(const Eina_Value *value,
2810 const char *name, 3173 const char *name,
2811 va_list args) EINA_ARG_NONNULL(1); 3174 va_list args) EINA_ARG_NONNULL(1, 2);
2812 3175
2813/** 3176/**
2814 * @brief Set the generic value in an struct member from pointer. 3177 * @brief Set the generic value in an struct member from pointer.
@@ -2875,7 +3238,7 @@ static inline Eina_Bool eina_value_struct_vget(const Eina_Value *value,
2875 */ 3238 */
2876static inline Eina_Bool eina_value_struct_pset(Eina_Value *value, 3239static inline Eina_Bool eina_value_struct_pset(Eina_Value *value,
2877 const char *name, 3240 const char *name,
2878 const void *ptr) EINA_ARG_NONNULL(1, 3); 3241 const void *ptr) EINA_ARG_NONNULL(1, 2, 3);
2879 3242
2880/** 3243/**
2881 * @brief Get the generic value to pointer from an struct member. 3244 * @brief Get the generic value to pointer from an struct member.
@@ -2944,7 +3307,62 @@ static inline Eina_Bool eina_value_struct_pset(Eina_Value *value,
2944 */ 3307 */
2945static inline Eina_Bool eina_value_struct_pget(const Eina_Value *value, 3308static inline Eina_Bool eina_value_struct_pget(const Eina_Value *value,
2946 const char *name, 3309 const char *name,
2947 void *ptr) EINA_ARG_NONNULL(1, 3); 3310 void *ptr) EINA_ARG_NONNULL(1, 2, 3);
3311
3312/**
3313 * @brief Get the member as Eina_Value copy
3314 * @param src source value object
3315 * @param name name to find the member
3316 * @param dst where to return the member value.
3317 *
3318 * The argument @a dst is considered uninitialized and it's setup to
3319 * the type of the member.
3320 *
3321 * @since 1.2
3322 */
3323static inline Eina_Bool eina_value_struct_value_get(const Eina_Value *src,
3324 const char *name,
3325 Eina_Value *dst) EINA_ARG_NONNULL(1, 2, 3);
3326
3327/**
3328 * @brief Set the member from Eina_Value source
3329 * @param dst destination value object
3330 * @param name name to find the member
3331 * @param src source value
3332 *
3333 * @since 1.2
3334 */
3335static inline Eina_Bool eina_value_struct_value_set(Eina_Value *dst,
3336 const char *name,
3337 const Eina_Value *src) EINA_ARG_NONNULL(1, 2, 3);
3338
3339/**
3340 * @brief Get the member as Eina_Value copy given its member description.
3341 * @param src source value object
3342 * @param member the member description to use
3343 * @param dst where to return the member value.
3344 *
3345 * The argument @a dst is considered uninitialized and it's setup to
3346 * the type of the member.
3347 *
3348 * @since 1.2
3349 */
3350static inline Eina_Bool eina_value_struct_member_value_get(const Eina_Value *src,
3351 const Eina_Value_Struct_Member *member,
3352 Eina_Value *dst) EINA_ARG_NONNULL(1, 2, 3);
3353
3354/**
3355 * @brief Set the member from Eina_Value source
3356 * @param dst destination value object
3357 * @param member the member description to use
3358 * @param src source value
3359 *
3360 * @since 1.2
3361 */
3362static inline Eina_Bool eina_value_struct_member_value_set(Eina_Value *dst,
3363 const Eina_Value_Struct_Member *member,
3364 const Eina_Value *src) EINA_ARG_NONNULL(1, 2, 3);
3365
2948 3366
2949/** 3367/**
2950 * @} 3368 * @}
@@ -2958,6 +3376,12 @@ static inline Eina_Bool eina_value_struct_pget(const Eina_Value *value,
2958 */ 3376 */
2959 3377
2960/** 3378/**
3379 * @def EINA_VALUE_TYPE_VERSION
3380 * Current API version, used to validate type.
3381 */
3382#define EINA_VALUE_TYPE_VERSION (1)
3383
3384/**
2961 * @struct _Eina_Value_Type 3385 * @struct _Eina_Value_Type
2962 * API to access values. 3386 * API to access values.
2963 * 3387 *
@@ -2965,11 +3389,6 @@ static inline Eina_Bool eina_value_struct_pget(const Eina_Value *value,
2965 */ 3389 */
2966struct _Eina_Value_Type 3390struct _Eina_Value_Type
2967{ 3391{
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 */ 3392 unsigned int version; /**< must be #EINA_VALUE_TYPE_VERSION */
2974 unsigned int value_size; /**< byte size of value */ 3393 unsigned int value_size; /**< byte size of value */
2975 const char *name; /**< name for debug and introspection */ 3394 const char *name; /**< name for debug and introspection */